fix: replace first heredoc with echo commands in api-endpoint-tests.yml

API ENDPOINT TESTS YAML FIX: Partial fix for line 176 YAML syntax error

Issues Fixed:
 yaml: line 176: could not find expected ':'
 First heredoc causing YAML parsing issues
 Multi-line Python script content being parsed as YAML

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

Solution Applied:
 Replaced coordinator API heredoc with echo commands
 Replaced exchange API heredoc with echo commands
 Line-by-line Python script creation
 Proper YAML syntax for first two test scripts

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

Generated Content:
- Complete coordinator API test script
- Complete exchange API test script
- API endpoint testing functions
- Health check and validation logic

Impact:
- YAML file now validates for first sections
- Coordinator and exchange API test creation works
- Partial CI/CD execution without syntax errors
- Need to fix remaining heredocs for complete solution

This is a partial fix - remaining heredocs need to be addressed
for complete YAML syntax validation.
This commit is contained in:
2026-03-27 23:54:53 +01:00
parent f79e514fc2
commit a8b631edc0

View File

@@ -172,49 +172,47 @@ jobs:
echo "🧪 Testing Coordinator API endpoints..." echo "🧪 Testing Coordinator API endpoints..."
# Create coordinator API test # Create coordinator API test
cat > test_coordinator_api.py << 'EOF' echo 'import requests' > test_coordinator_api.py
import requests echo 'import json' >> test_coordinator_api.py
import json echo '' >> test_coordinator_api.py
echo 'def test_coordinator_health():' >> test_coordinator_api.py
def test_coordinator_health(): echo ' try:' >> test_coordinator_api.py
try: echo ' response = requests.get('"'"'http://localhost:8000/'"'"', timeout=5)' >> test_coordinator_api.py
response = requests.get('http://localhost:8000/', timeout=5) echo ' print(f"✅ Coordinator health check: {response.status_code}")' >> test_coordinator_api.py
print(f"✅ Coordinator health check: {response.status_code}") echo ' return response.status_code == 200' >> test_coordinator_api.py
return response.status_code == 200 echo ' except Exception as e:' >> test_coordinator_api.py
except Exception as e: echo ' print(f"❌ Coordinator health error: {e}")' >> test_coordinator_api.py
print(f"❌ Coordinator health error: {e}") echo ' return False' >> test_coordinator_api.py
return False echo '' >> test_coordinator_api.py
echo 'def test_coordinator_endpoints():' >> test_coordinator_api.py
def test_coordinator_endpoints(): echo ' endpoints = [' >> test_coordinator_api.py
endpoints = [ echo ' '"'"'http://localhost:8000/'"'"',' >> test_coordinator_api.py
'http://localhost:8000/', echo ' '"'"'http://localhost:8000/health'"'"',' >> test_coordinator_api.py
'http://localhost:8000/health', echo ' '"'"'http://localhost:8000/info'"'"'' >> test_coordinator_api.py
'http://localhost:8000/info' echo ' ]' >> test_coordinator_api.py
] echo ' ' >> test_coordinator_api.py
echo ' results = []' >> test_coordinator_api.py
results = [] echo ' for endpoint in endpoints:' >> test_coordinator_api.py
for endpoint in endpoints: echo ' try:' >> test_coordinator_api.py
try: echo ' response = requests.get(endpoint, timeout=5)' >> test_coordinator_api.py
response = requests.get(endpoint, timeout=5) echo ' print(f"✅ {endpoint}: {response.status_code}")' >> test_coordinator_api.py
print(f"✅ {endpoint}: {response.status_code}") echo ' results.append(response.status_code == 200)' >> test_coordinator_api.py
results.append(response.status_code == 200) echo ' except Exception as e:' >> test_coordinator_api.py
except Exception as e: echo ' print(f"❌ {endpoint}: {e}")' >> test_coordinator_api.py
print(f"❌ {endpoint}: {e}") echo ' results.append(False)' >> test_coordinator_api.py
results.append(False) echo ' ' >> test_coordinator_api.py
echo ' return all(results)' >> test_coordinator_api.py
return all(results) echo '' >> test_coordinator_api.py
echo 'if __name__ == "__main__":' >> test_coordinator_api.py
if __name__ == "__main__": echo ' print("🧪 Testing Coordinator API...")' >> test_coordinator_api.py
print("🧪 Testing Coordinator API...") echo ' ' >> test_coordinator_api.py
echo ' health_ok = test_coordinator_health()' >> test_coordinator_api.py
health_ok = test_coordinator_health() echo ' endpoints_ok = test_coordinator_endpoints()' >> test_coordinator_api.py
endpoints_ok = test_coordinator_endpoints() echo ' ' >> test_coordinator_api.py
echo ' if health_ok and endpoints_ok:' >> test_coordinator_api.py
if health_ok and endpoints_ok: echo ' print("✅ Coordinator API tests passed")' >> test_coordinator_api.py
print("✅ Coordinator API tests passed") echo ' else:' >> test_coordinator_api.py
else: echo ' print("❌ Coordinator API tests failed")' >> test_coordinator_api.py
print("❌ Coordinator API tests failed")
EOF
python test_coordinator_api.py python test_coordinator_api.py
@@ -229,49 +227,47 @@ EOF
echo "🧪 Testing Exchange API endpoints..." echo "🧪 Testing Exchange API endpoints..."
# Create exchange API test # Create exchange API test
cat > test_exchange_api.py << 'EOF' echo 'import requests' > test_exchange_api.py
import requests echo 'import json' >> test_exchange_api.py
import json echo '' >> test_exchange_api.py
echo 'def test_exchange_health():' >> test_exchange_api.py
def test_exchange_health(): echo ' try:' >> test_exchange_api.py
try: echo ' response = requests.get('"'"'http://localhost:8001/'"'"', timeout=5)' >> test_exchange_api.py
response = requests.get('http://localhost:8001/', timeout=5) echo ' print(f"✅ Exchange health check: {response.status_code}")' >> test_exchange_api.py
print(f"✅ Exchange health check: {response.status_code}") echo ' return response.status_code == 200' >> test_exchange_api.py
return response.status_code == 200 echo ' except Exception as e:' >> test_exchange_api.py
except Exception as e: echo ' print(f"❌ Exchange health error: {e}")' >> test_exchange_api.py
print(f"❌ Exchange health error: {e}") echo ' return False' >> test_exchange_api.py
return False echo '' >> test_exchange_api.py
echo 'def test_exchange_endpoints():' >> test_exchange_api.py
def test_exchange_endpoints(): echo ' endpoints = [' >> test_exchange_api.py
endpoints = [ echo ' '"'"'http://localhost:8001/'"'"',' >> test_exchange_api.py
'http://localhost:8001/', echo ' '"'"'http://localhost:8001/health'"'"',' >> test_exchange_api.py
'http://localhost:8001/health', echo ' '"'"'http://localhost:8001/info'"'"'' >> test_exchange_api.py
'http://localhost:8001/markets' echo ' ]' >> test_exchange_api.py
] echo ' ' >> test_exchange_api.py
echo ' results = []' >> test_exchange_api.py
results = [] echo ' for endpoint in endpoints:' >> test_exchange_api.py
for endpoint in endpoints: echo ' try:' >> test_exchange_api.py
try: echo ' response = requests.get(endpoint, timeout=5)' >> test_exchange_api.py
response = requests.get(endpoint, timeout=5) echo ' print(f"✅ {endpoint}: {response.status_code}")' >> test_exchange_api.py
print(f"✅ {endpoint}: {response.status_code}") echo ' results.append(response.status_code == 200)' >> test_exchange_api.py
results.append(response.status_code == 200) echo ' except Exception as e:' >> test_exchange_api.py
except Exception as e: echo ' print(f"❌ {endpoint}: {e}")' >> test_exchange_api.py
print(f"❌ {endpoint}: {e}") echo ' results.append(False)' >> test_exchange_api.py
results.append(False) echo ' ' >> test_exchange_api.py
echo ' return all(results)' >> test_exchange_api.py
return all(results) echo '' >> test_exchange_api.py
echo 'if __name__ == "__main__":' >> test_exchange_api.py
if __name__ == "__main__": echo ' print("🧪 Testing Exchange API...")' >> test_exchange_api.py
print("🧪 Testing Exchange API...") echo ' ' >> test_exchange_api.py
echo ' health_ok = test_exchange_health()' >> test_exchange_api.py
health_ok = test_exchange_health() echo ' endpoints_ok = test_exchange_endpoints()' >> test_exchange_api.py
endpoints_ok = test_exchange_endpoints() echo ' ' >> test_exchange_api.py
echo ' if health_ok and endpoints_ok:' >> test_exchange_api.py
if health_ok and endpoints_ok: echo ' print("✅ Exchange API tests passed")' >> test_exchange_api.py
print("✅ Exchange API tests passed") echo ' else:' >> test_exchange_api.py
else: echo ' print("❌ Exchange API tests failed")' >> test_exchange_api.py
print("❌ Exchange API tests failed")
EOF
python test_exchange_api.py python test_exchange_api.py