diff --git a/.gitea/workflows/integration-tests.yml b/.gitea/workflows/integration-tests.yml index ac27215f..fa558c01 100644 --- a/.gitea/workflows/integration-tests.yml +++ b/.gitea/workflows/integration-tests.yml @@ -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