fix: replace heredoc with echo commands in integration-tests.yml
All checks were successful
security-scanning / audit (push) Successful in 1m35s

INTEGRATION TESTS YAML FIX: Resolve line 218 could not find expected ':' error

Issues Fixed:
 yaml: line 218: could not find expected ':'
 Heredoc causing YAML parsing issues in integration-tests.yml
 Workflow config file invalid
 Multi-line content being parsed as YAML

Root Cause:
- Heredoc syntax in integration-tests.yml causing YAML parsing errors
- Multi-line Python script content being interpreted as YAML
- YAML parser expecting key-value pairs throughout
- Heredoc syntax incompatible with YAML structure

Solution Applied:
 Replaced heredoc with echo commands
 Line-by-line Python script creation
 Proper YAML syntax throughout
 Valid shell script commands

Implementation Changes:
- Removed heredoc syntax completely
- Used echo commands for each Python line
- Proper shell escaping for quotes and strings
- Line-by-line file construction

Generated Content:
- Complete Python integration test script
- Service-to-service communication tests
- API endpoint testing functions
- Cross-service validation logic

Impact:
- YAML file now validates correctly
- Workflow config file is valid
- Integration test script creation works
- CI/CD execution without syntax errors
- Complete test functionality preserved

This resolves the YAML syntax error that was preventing
the integration tests workflow from being parsed correctly.
This commit is contained in:
2026-03-27 23:47:12 +01:00
parent a759810085
commit 620f3c70fb

View File

@@ -214,64 +214,62 @@ jobs:
echo "🔗 Testing service-to-service communication..."
# Create test script
cat > test_integration.py << 'EOF'
import requests
import json
import time
def test_coordinator_api():
try:
response = requests.get('http://localhost:8000/', timeout=5)
print(f"✅ Coordinator API responded: {response.status_code}")
return True
except Exception as e:
print(f"❌ Coordinator API error: {e}")
return False
def test_blockchain_rpc():
try:
payload = {
"jsonrpc": "2.0",
"method": "eth_blockNumber",
"params": [],
"id": 1
}
response = requests.post('http://localhost:8545', json=payload, timeout=5)
if response.status_code == 200:
result = response.json()
print(f"✅ Blockchain RPC responded: {result.get('result', 'Unknown')}")
return True
except Exception as e:
print(f"❌ Blockchain RPC error: {e}")
return False
def test_marketplace():
try:
response = requests.get('http://localhost:3001/', timeout=5)
print(f"✅ Marketplace responded: {response.status_code}")
return True
except Exception as e:
print(f"❌ Marketplace error: {e}")
return False
if __name__ == "__main__":
print("🧪 Running cross-service communication tests...")
results = []
results.append(test_coordinator_api())
results.append(test_blockchain_rpc())
results.append(test_marketplace())
success_count = sum(results)
total_count = len(results)
print(f"\n📊 Test Results: {success_count}/{total_count} services working")
if success_count == total_count:
print("✅ All services communicating successfully")
else:
print("⚠️ Some services not communicating properly")
EOF
echo 'import requests' > test_integration.py
echo 'import json' >> test_integration.py
echo 'import time' >> test_integration.py
echo '' >> test_integration.py
echo 'def test_coordinator_api():' >> test_integration.py
echo ' try:' >> test_integration.py
echo ' response = requests.get('"'"'http://localhost:8000/'"'"', timeout=5)' >> test_integration.py
echo ' print(f"✅ Coordinator API responded: {response.status_code}")' >> test_integration.py
echo ' return True' >> test_integration.py
echo ' except Exception as e:' >> test_integration.py
echo ' print(f"❌ Coordinator API error: {e}")' >> test_integration.py
echo ' return False' >> test_integration.py
echo '' >> test_integration.py
echo 'def test_blockchain_rpc():' >> test_integration.py
echo ' try:' >> test_integration.py
echo ' payload = {' >> test_integration.py
echo ' "jsonrpc": "2.0",' >> test_integration.py
echo ' "method": "eth_blockNumber",' >> test_integration.py
echo ' "params": [],' >> test_integration.py
echo ' "id": 1' >> test_integration.py
echo ' }' >> test_integration.py
echo ' response = requests.post('"'"'http://localhost:8545'"'"', json=payload, timeout=5)' >> test_integration.py
echo ' if response.status_code == 200:' >> test_integration.py
echo ' result = response.json()' >> test_integration.py
echo ' print(f"✅ Blockchain RPC responded: {result.get('"'"'result'"'"', '"'"'Unknown'"'"')}")' >> test_integration.py
echo ' return True' >> test_integration.py
echo ' except Exception as e:' >> test_integration.py
echo ' print(f"❌ Blockchain RPC error: {e}")' >> test_integration.py
echo ' return False' >> test_integration.py
echo '' >> test_integration.py
echo 'def test_marketplace():' >> test_integration.py
echo ' try:' >> test_integration.py
echo ' response = requests.get('"'"'http://localhost:3001/'"'"', timeout=5)' >> test_integration.py
echo ' print(f"✅ Marketplace responded: {response.status_code}")' >> test_integration.py
echo ' return True' >> test_integration.py
echo ' except Exception as e:' >> test_integration.py
echo ' print(f"❌ Marketplace error: {e}")' >> test_integration.py
echo ' return False' >> test_integration.py
echo '' >> test_integration.py
echo 'if __name__ == "__main__":' >> test_integration.py
echo ' print("🧪 Running cross-service communication tests...")' >> test_integration.py
echo ' ' >> test_integration.py
echo ' results = []' >> test_integration.py
echo ' results.append(test_coordinator_api())' >> test_integration.py
echo ' results.append(test_blockchain_rpc())' >> test_integration.py
echo ' results.append(test_marketplace())' >> test_integration.py
echo ' ' >> test_integration.py
echo ' success_count = sum(results)' >> test_integration.py
echo ' total_count = len(results)' >> test_integration.py
echo ' ' >> test_integration.py
echo ' print(f"\n📊 Test Results: {success_count}/{total_count} services working")' >> test_integration.py
echo ' ' >> test_integration.py
echo ' if success_count == total_count:' >> test_integration.py
echo ' print("✅ All services communicating successfully")' >> test_integration.py
echo ' else:' >> test_integration.py
echo ' print("⚠️ Some services not communicating properly")' >> test_integration.py
# Run integration test
python test_integration.py