Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

feat: run kubo gateway sharness tests #59

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/gateway-sharness.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down