From 945c36bab3d39eefdea5e90f593f61d673d57fdd Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Wed, 22 May 2024 21:49:43 +0200 Subject: [PATCH] test(ci): both block and car gws Block and CAR backends have significate difference in code paths and abstractions. We need to run conformance against them separately to ensure both code paths behave the same way. --- .github/workflows/gateway-conformance.yml | 88 +++++++++++++++-------- 1 file changed, 60 insertions(+), 28 deletions(-) diff --git a/.github/workflows/gateway-conformance.yml b/.github/workflows/gateway-conformance.yml index a4a1806..f53a49f 100644 --- a/.github/workflows/gateway-conformance.yml +++ b/.github/workflows/gateway-conformance.yml @@ -1,45 +1,54 @@ name: Gateway Conformance on: + workflow_dispatch: push: branches: - main pull_request: + paths-ignore: + - '**/*.md' + +env: + KUBO_VER: 'v0.28.0' # kubo daemon used as no-libp2p-remote-* backend + +concurrency: + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }} + cancel-in-progress: true jobs: - gateway-conformance: + tests: runs-on: ubuntu-latest strategy: matrix: - libp2p: ["libp2p", "no_libp2p"] + backend: ["libp2p-bitswap", "remote-block-gw", "remote-car-gw"] + steps: # 1. Start the Kubo gateway - - name: Setup Go - uses: actions/setup-go@v5 + - name: Install Kubo + uses: ipfs/download-ipfs-distribution-action@v1 with: - go-version: 1.21.x + name: kubo + version: "${{ env.KUBO_VER }}" - - name: Install Kubo gateway from source - #uses: ipfs/download-ipfs-distribution-action@v1 - run: | - go install github.com/ipfs/kubo/cmd/ipfs@v0.24.0-rc1 - name: Setup kubo config run: | ipfs init --profile=test ipfs config Addresses.Gateway "/ip4/127.0.0.1/tcp/8080" ipfs config Addresses.API "/ip4/127.0.0.1/tcp/5001" ipfs config --json Gateway.ExposeRoutingAPI true + ipfs config Routing.Type "autoclient" + + - name: Start Kubo gateway + uses: ipfs/start-ipfs-daemon-action@v1 # 2. Download the gateway-conformance fixtures - name: Download gateway-conformance fixtures - uses: ipfs/gateway-conformance/.github/actions/extract-fixtures@v0.5.1 + uses: ipfs/gateway-conformance/.github/actions/extract-fixtures@v0.5.2 with: output: fixtures - - name: Start Kubo gateway - uses: ipfs/start-ipfs-daemon-action@v1 - - # 3. Populate the Kubo gateway with the gateway-conformance fixtures + # 3. Populate the Kubo node with the gateway-conformance fixtures - name: Import fixtures run: | # Import car files @@ -60,6 +69,11 @@ jobs: echo "IPFS_NS_MAP=${IPFS_NS_MAP}" >> $GITHUB_ENV # 4. Build rainbow + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: 1.21.x + - name: Checkout rainbow uses: actions/checkout@v4 with: @@ -68,30 +82,48 @@ jobs: run: go build working-directory: rainbow - # 5.1. Start rainbow (Libp2p) - - name: Start rainbow (Libp2p) - if: ${{ matrix.libp2p == 'libp2p' }} + # 5. Start rainbow variant + - name: Start rainbow (libp2p and bitswap) + if: ${{ matrix.backend == 'libp2p-bitswap' }} env: - GATEWAY_CONFORMANCE_TEST: true + RAINBOW_DHT_ROUTING: off + RAINBOW_HTTP_ROUTERS: http://127.0.0.1:8080 run: | - # get kubo peerID + # set up peering with kubo to ensure fixtures can be found fast kuboNodeMultiaddr=$(ipfs --api=/ip4/127.0.0.1/tcp/5001 swarm addrs local --id | head -n 1) - ./rainbow --http-routers=http://127.0.0.1:8080 --dht-routing=off --peering=$kuboNodeMultiaddr & + ./rainbow --peering=$kuboNodeMultiaddr & working-directory: rainbow - # 5.2. Start rainbow (No Libp2p) - - name: Start rainbow (No Libp2p) - if: ${{ matrix.libp2p == 'no_libp2p' }} + # 5. Start rainbow variant + - name: Start rainbow (no libp2p, remote block gateway) + if: ${{ matrix.backend == 'remote-block-gw' }} + env: + GATEWAY_CONFORMANCE_TEST: true + RAINBOW_HTTP_ROUTERS: http://127.0.0.1:8080 + RAINBOW_REMOTE_BACKENDS: http://127.0.0.1:8080 + RAINBOW_REMOTE_BACKENDS_MODE: block + RAINBOW_LIBP2P: false + run: | + ./rainbow & + working-directory: rainbow + # + # 5. Start rainbow variant + - name: Start rainbow (no libp2p, remote car gateway) + if: ${{ matrix.backend == 'remote-car-gw' }} env: GATEWAY_CONFORMANCE_TEST: true + RAINBOW_HTTP_ROUTERS: http://127.0.0.1:8080 + RAINBOW_REMOTE_BACKENDS: http://127.0.0.1:8080 + RAINBOW_REMOTE_BACKENDS_MODE: car + RAINBOW_LIBP2P: false run: | - ./rainbow --http-routers=http://127.0.0.1:8080 --remote-backends=http://127.0.0.1:8080 --libp2p=false & + ./rainbow & working-directory: rainbow # 6. Run the gateway-conformance tests - name: Run gateway-conformance tests - uses: ipfs/gateway-conformance/.github/actions/test@v0.5.1 + uses: ipfs/gateway-conformance/.github/actions/test@v0.5.2 with: gateway-url: http://127.0.0.1:8090 json: output.json @@ -104,7 +136,7 @@ jobs: # # only-if-cached: rainbow does not guarantee local cache, we will adjust upstream test (which was Kubo-specific) # for now disabling these test cases - args: -skip 'TestGatewayCache/.*_for_/ipfs/_with_only-if-cached_succeeds_when_in_local_datastore' + args: -skip 'TestGatewayCache/.*_with_only-if-cached_succeeds_when_in_local_datastore' # 7. Upload the results - name: Upload MD summary @@ -114,11 +146,11 @@ jobs: if: failure() || success() uses: actions/upload-artifact@v4 with: - name: ${{ matrix.libp2p }}_gateway-conformance.html + name: ${{ matrix.backend }}_gateway-conformance.html path: output.html - name: Upload JSON report if: failure() || success() uses: actions/upload-artifact@v4 with: - name: ${{ matrix.libp2p }}_gateway-conformance.json + name: ${{ matrix.backend }}_gateway-conformance.json path: output.json