From 69a09c1e0ef959cbaa2de4b8594453d5f942748a Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Fri, 1 Sep 2023 14:41:46 -0400 Subject: [PATCH] test(gateway-conformance): separate out steps for gateway-over-libp2p testing --- .github/workflows/gateway-conformance.yml | 72 ++++++++++++++++++++--- 1 file changed, 63 insertions(+), 9 deletions(-) diff --git a/.github/workflows/gateway-conformance.yml b/.github/workflows/gateway-conformance.yml index 0c6a19024998..0f91ebbdbad0 100644 --- a/.github/workflows/gateway-conformance.yml +++ b/.github/workflows/gateway-conformance.yml @@ -58,10 +58,12 @@ jobs: } } run: | - ./ipfs init + ./ipfs init --profile=test ./ipfs config --json Gateway.PublicGateways "$GATEWAY_PUBLIC_GATEWAYS" ./ipfs config --json Experimental.Libp2pStreamMounting true ./ipfs config --json Experimental.GatewayOverLibp2p true + ./ipfs config Addresses.Gateway "/ip4/127.0.0.1/tcp/8080" + ./ipfs config Addresses.API "/ip4/127.0.0.1/tcp/5001" working-directory: kubo-gateway/cmd/ipfs # 4. Populate the Kubo gateway with the gateway-conformance fixtures @@ -87,7 +89,28 @@ jobs: # 5. Start the kubo-gateway - name: Start kubo-gateway run: | - ./ipfs daemon --offline & + ./ipfs daemon & + endpoint="http://127.0.0.1:5001/api/v0/version" + max_retries=5 + retry_interval=3 + + check_endpoint() { + curl -X POST --silent --fail "$endpoint" > /dev/null + return $? + } + + retries=0 + while ! check_endpoint; do + retries=$((retries+1)) + + if [ $retries -ge $max_retries ]; then + echo "daemon took too long to start" + exit 1 + fi + + sleep $retry_interval + done + echo "daemon started and ready to receive API calls" working-directory: kubo-gateway/cmd/ipfs # 6. Run the gateway-conformance tests @@ -123,23 +146,54 @@ jobs: env: IPFS_PATH: "~/.kubo-p2p-proxy" run: | - ./ipfs init --profile=randomports + ./ipfs init --profile=test ./ipfs config --json Experimental.Libp2pStreamMounting true ./ipfs config Addresses.Gateway "/ip4/127.0.0.1/tcp/8081" ./ipfs config Addresses.API "/ip4/127.0.0.1/tcp/5002" working-directory: kubo-gateway/cmd/ipfs - # 9. Start the kubo http-p2p-proxy and setup the forwarder - - name: Start kubo-gateway + # 9. Start the kubo http-p2p-proxy + - name: Start kubo http-p2p-proxy env: IPFS_PATH: "~/.kubo-p2p-proxy" run: | - gatewayNodeId=$(./ipfs id -f="" --api=/ip4/127.0.0.1/tcp/5001) - ./ipfs daemon --offline & - ./ipfs p2p forward --allow-custom-protocol /http/1.1 /ip4/127.0.0.1/tcp/8082 /p2p/$gatewayNodeId + ./ipfs daemon & + + endpoint="http://127.0.0.1:5002/api/v0/version" + max_retries=5 + retry_interval=3 + + check_endpoint() { + curl -X POST --silent --fail "$endpoint" > /dev/null + return $? + } + + retries=0 + while ! check_endpoint; do + retries=$((retries+1)) + + if [ $retries -ge $max_retries ]; then + echo "daemon took too long to start" + exit 1 + fi + + sleep $retry_interval + done + echo "daemon started and ready to receive API calls" + working-directory: kubo-gateway/cmd/ipfs + + # 10. Start forwarding data from the http-p2p-proxy to the node serving the Gateway API over libp2p + - name: Start http-over-libp2p forwarding proxy + run: | + gatewayNodeId=$(./ipfs --api=/ip4/127.0.0.1/tcp/5001 id -f="") + echo gatewayNodeId $gatewayNodeId + proxyNodeId=$(./ipfs --api=/ip4/127.0.0.1/tcp/5002 id -f="") + echo proxyNodeId $proxyNodeId + ./ipfs --api=/ip4/127.0.0.1/tcp/5002 swarm connect $(./ipfs --api=/ip4/127.0.0.1/tcp/5001 id -f="") + ./ipfs --api=/ip4/127.0.0.1/tcp/5002 p2p forward --allow-custom-protocol /http/1.1 /ip4/127.0.0.1/tcp/8082 /p2p/$gatewayNodeId working-directory: kubo-gateway/cmd/ipfs - # 10. Run the gateway-conformance tests + # 11. Run the gateway-conformance tests over libp2p - name: Run gateway-conformance tests over libp2p uses: ipfs/gateway-conformance/.github/actions/test@v0.3 with: