@cryptotaxi247 / kubo / commits / b8c741d8b

test(gateway-conformance): also run gateway conformance tests against a gateway-over-libp2p endpoint

Adin Schmahmann committed Aug 31, 2023 at 03:53 UTC b8c741d8bf18080e1f29c3dadd384b580953ce83
1 file changed +102 -2
.github/workflows/gateway-conformance.yml
+102 -2
@@ -58,8 +58,10 @@ jobs:
58 }
59 }
60 run: |
61 - ./ipfs init
61 + ./ipfs init --profile=test
62 ./ipfs config --json Gateway.PublicGateways "$GATEWAY_PUBLIC_GATEWAYS"
63 + ./ipfs config Addresses.Gateway "/ip4/127.0.0.1/tcp/8080"
64 + ./ipfs config Addresses.API "/ip4/127.0.0.1/tcp/5001"
65 working-directory: kubo-gateway/cmd/ipfs
66
67 # 4. Populate the Kubo gateway with the gateway-conformance fixtures
@@ -85,7 +87,28 @@ jobs:
87 # 5. Start the kubo-gateway
88 - name: Start kubo-gateway
89 run: |
88 - ./ipfs daemon --offline &
90 + ./ipfs daemon &
91 + endpoint="http://127.0.0.1:5001/api/v0/version"
92 + max_retries=5
93 + retry_interval=3
94 +
95 + check_endpoint() {
96 + curl -X POST --silent --fail "$endpoint" > /dev/null
97 + return $?
98 + }
99 +
100 + retries=0
101 + while ! check_endpoint; do
102 + retries=$((retries+1))
103 +
104 + if [ $retries -ge $max_retries ]; then
105 + echo "daemon took too long to start"
106 + exit 1
107 + fi
108 +
109 + sleep $retry_interval
110 + done
111 + echo "daemon started and ready to receive API calls"
112 working-directory: kubo-gateway/cmd/ipfs
113
114 # 6. Run the gateway-conformance tests
@@ -115,3 +138,80 @@ jobs:
138 with:
139 name: gateway-conformance.json
140 path: output.json
141 +
142 + # 8. Setup a kubo http-p2p-proxy to run gateway conformance tests
143 + - name: Init p2p-proxy kubo node
144 + env:
145 + IPFS_PATH: "~/.kubo-p2p-proxy"
146 + run: |
147 + ./ipfs init --profile=test
148 + ./ipfs config --json Experimental.Libp2pStreamMounting true
149 + ./ipfs config Addresses.Gateway "/ip4/127.0.0.1/tcp/8081"
150 + ./ipfs config Addresses.API "/ip4/127.0.0.1/tcp/5002"
151 + working-directory: kubo-gateway/cmd/ipfs
152 +
153 + # 9. Start the kubo http-p2p-proxy
154 + - name: Start kubo http-p2p-proxy
155 + env:
156 + IPFS_PATH: "~/.kubo-p2p-proxy"
157 + run: |
158 + ./ipfs daemon &
159 +
160 + endpoint="http://127.0.0.1:5002/api/v0/version"
161 + max_retries=5
162 + retry_interval=3
163 +
164 + check_endpoint() {
165 + curl -X POST --silent --fail "$endpoint" > /dev/null
166 + return $?
167 + }
168 +
169 + retries=0
170 + while ! check_endpoint; do
171 + retries=$((retries+1))
172 +
173 + if [ $retries -ge $max_retries ]; then
174 + echo "daemon took too long to start"
175 + exit 1
176 + fi
177 +
178 + sleep $retry_interval
179 + done
180 + echo "daemon started and ready to receive API calls"
181 + working-directory: kubo-gateway/cmd/ipfs
182 +
183 + # 10. Start forwarding data from the http-p2p-proxy to the node serving the Gateway API over libp2p
184 + - name: Start http-over-libp2p forwarding proxy
185 + run: |
186 + gatewayNodeId=$(./ipfs --api=/ip4/127.0.0.1/tcp/5001 id -f="<id>")
187 + ./ipfs --api=/ip4/127.0.0.1/tcp/5002 swarm connect $(./ipfs --api=/ip4/127.0.0.1/tcp/5001 swarm addrs local --id | head -n 1)
188 + ./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
189 + working-directory: kubo-gateway/cmd/ipfs
190 +
191 + # 11. Run the gateway-conformance tests over libp2p
192 + - name: Run gateway-conformance tests over libp2p
193 + uses: ipfs/gateway-conformance/.github/actions/test@v0.3
194 + with:
195 + gateway-url: http://127.0.0.1:8081
196 + json: output.json
197 + xml: output.xml
198 + html: output.html
199 + markdown: output.md
200 + args: --specs "trustless-gateway,-trustless-ipns-gateway" -skip 'TestGatewayCar/GET_response_for_application/vnd.ipld.car/Header_Content-Length'
201 +
202 + # 11. Upload the results
203 + - name: Upload MD summary
204 + if: failure() || success()
205 + run: cat output.md >> $GITHUB_STEP_SUMMARY
206 + - name: Upload HTML report
207 + if: failure() || success()
208 + uses: actions/upload-artifact@v3
209 + with:
210 + name: gateway-conformance-libp2p.html
211 + path: output.html
212 + - name: Upload JSON report
213 + if: failure() || success()
214 + uses: actions/upload-artifact@v3
215 + with:
216 + name: gateway-conformance-libp2p.json
217 + path: output.json
\ No newline at end of file