From 97eb6fbf26cfc46555ee8d34c75547fd6337fbdc Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Tue, 7 Mar 2023 13:11:45 +0100 Subject: [PATCH 1/2] feat: run kubo gateway sharness tests --- .github/workflows/gateway-sharness.yml | 55 ++++++++++++++++++++++++++ routing.go | 8 ++-- 2 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/gateway-sharness.yml diff --git a/.github/workflows/gateway-sharness.yml b/.github/workflows/gateway-sharness.yml new file mode 100644 index 0000000..c6624e5 --- /dev/null +++ b/.github/workflows/gateway-sharness.yml @@ -0,0 +1,55 @@ +name: Gateway Sharness + +on: + workflow_dispatch: + pull_request: + push: + branches: ['main'] + +jobs: + sharness: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: 1.19.1 + - name: Checkout Bifrost Gateway + uses: actions/checkout@v3 + with: + path: bifrost + - name: Checkout Kubo + uses: actions/checkout@v3 + with: + repository: ipfs/kubo + ref: feat/sharness-gw-override + path: kubo + - name: Install Missing Tools + run: sudo apt install -y socat net-tools fish libxml2-utils + - name: Restore Go Cache + uses: protocol/cache-go-action@v1 + with: + name: ${{ github.job }} + - name: Install sharness dependencies + run: make test_sharness_deps + working-directory: kubo + - name: Run Bifrost Gateway + env: + PROXY_GATEWAY_URL: http://127.0.0.1:60080 + KUBO_RPC_URL: http://127.0.0.1:60050 + GOLOG_LOG_LEVEL: error,bifrost-gateway=debug + run: | + go build -o bifrost-gateway + ./bifrost-gateway --gateway-port 8083 & + sleep 5s + working-directory: bifrost + - name: Run Kubo Sharness Tests + env: + TEST_NODE_GWAY_MADDR: /ip4/127.0.0.1/tcp/60080 + TEST_NODE_API_MADDR: /ip4/127.0.0.1/tcp/60050 + TEST_GWAY_MADDR: /ip4/127.0.0.1/tcp/8083 + run: find . -maxdepth 1 -name "*gateway*.sh" ! -name "*t0400*.sh" ! -name "*t0111*.sh" -type f -print0 | xargs -0 -I {} bash -c "echo {}; {} -v" + working-directory: kubo/test/sharness \ No newline at end of file diff --git a/routing.go b/routing.go index e724557..310c061 100644 --- a/routing.go +++ b/routing.go @@ -109,15 +109,15 @@ func (ps *proxyRouting) fetch(ctx context.Context, key string) (rb []byte, err e } defer resp.Body.Close() - if resp.StatusCode != http.StatusOK { - return nil, fmt.Errorf("routing/get RPC returned unexpected status: %s", resp.Status) - } - rb, err = io.ReadAll(resp.Body) if err != nil { return nil, err } + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("routing/get RPC returned unexpected status: %s, body: %s", resp.Status, string(rb)) + } + parts := bytes.Split(bytes.TrimSpace(rb), []byte("\n")) var b64 string From 40a23d6befa9f11067b5bdb532286016d6923eed Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Tue, 21 Mar 2023 16:47:49 +0100 Subject: [PATCH 2/2] fix: ensure basic codecs are installed --- gateway.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gateway.go b/gateway.go index 5ba40c2..0c4288c 100644 --- a/gateway.go +++ b/gateway.go @@ -32,6 +32,12 @@ import ( "github.com/libp2p/go-libp2p/core/peer" "github.com/libp2p/go-libp2p/core/routing" mc "github.com/multiformats/go-multicodec" + + // Ensure basic codecs are installed. + _ "github.com/ipld/go-ipld-prime/codec/cbor" + _ "github.com/ipld/go-ipld-prime/codec/dagcbor" + _ "github.com/ipld/go-ipld-prime/codec/dagjson" + _ "github.com/ipld/go-ipld-prime/codec/json" ) type bifrostGateway struct {