-
Notifications
You must be signed in to change notification settings - Fork 521
test: Add multidimensional interop test #1615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
d4b000d
Add libp2p-ping-interop test
MarcoPolo f9f3bf0
Update interop test
MarcoPolo 705f0ee
Merge branch 'master' into marco/interop-test
MarcoPolo aa447b7
Update interop deps
MarcoPolo 545eb68
Use master interop runner
MarcoPolo 04f0446
Save package locks as artifacts
MarcoPolo cfb2ae0
Run chromium and firefox tests
MarcoPolo 14e8ccc
Cleanup
MarcoPolo 3000da3
Run webrtc test in firefox
MarcoPolo 09b5ff7
Don't deny any dials in interop test
MarcoPolo 4d0fe28
Merge branch 'master' into marco/interop-test
MarcoPolo c851378
PR nits
MarcoPolo 3d6ac52
Lint
MarcoPolo 1f2b89e
Split into two tests
MarcoPolo 09c74ab
Dynamically skip test
MarcoPolo 76df717
Set isDialer earlier
MarcoPolo 3c52888
Merge branch 'master' into marco/interop-test
achingbrain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ChromiumDockerfile | ||
| Dockerfile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| name: Interoperability Testing | ||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: | ||
| - "master" | ||
|
|
||
| jobs: | ||
| run-multidim-interop: | ||
| name: Run multidimensional interoperability tests | ||
| runs-on: ubuntu-22.04 | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - uses: ipfs/aegir/actions/cache-node-modules@master | ||
| with: | ||
| directories: | | ||
| ./interop/node_modules | ||
| - name: Build interop | ||
| run: (cd interop && npm i && npm run build) | ||
| - name: Build images | ||
| run: (cd interop && make) | ||
| - name: Save package-lock.json as artifact | ||
| uses: actions/upload-artifact@v2 | ||
| with: | ||
| name: package locks | ||
| path: | | ||
| package-lock.json | ||
| interop/package-lock.json | ||
| - uses: libp2p/test-plans/.github/actions/run-interop-ping-test@master | ||
| with: | ||
| test-filter: js-libp2p-head | ||
| extra-versions: ${{ github.workspace }}/interop/node-version.json ${{ github.workspace }}/interop/chromium-version.json ${{ github.workspace }}/interop/firefox-version.json | ||
| s3-cache-bucket: ${{ vars.S3_LIBP2P_BUILD_CACHE_BUCKET_NAME }} | ||
| s3-access-key-id: ${{ vars.S3_LIBP2P_BUILD_CACHE_AWS_ACCESS_KEY_ID }} | ||
| s3-secret-access-key: ${{ secrets.S3_LIBP2P_BUILD_CACHE_AWS_SECRET_ACCESS_KEY }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import { createClient } from 'redis' | ||
| import http from "http" | ||
|
|
||
| const redis_addr = process.env.redis_addr || 'redis:6379' | ||
|
|
||
| /** @type {import('aegir/types').PartialOptions} */ | ||
| export default { | ||
| test: { | ||
| browser: { | ||
| config: { | ||
| // Ignore self signed certificates | ||
| browserContextOptions: { ignoreHTTPSErrors: true } | ||
| } | ||
| }, | ||
| async before() { | ||
| const redisClient = createClient({ | ||
| url: `redis://${redis_addr}` | ||
| }) | ||
| redisClient.on('error', (err) => console.error(`Redis Client Error: ${err}`)) | ||
| await redisClient.connect() | ||
|
|
||
| const requestListener = async function (req, res) { | ||
| const requestJSON = await new Promise(resolve => { | ||
| let body = "" | ||
| req.on('data', function (data) { | ||
| body += data; | ||
| }); | ||
|
|
||
| req.on('end', function () { | ||
| resolve(JSON.parse(body)) | ||
| }); | ||
| }) | ||
|
|
||
| try { | ||
| const redisRes = await redisClient.sendCommand(requestJSON) | ||
| if (redisRes === null) { | ||
| throw new Error("redis sent back null") | ||
| } | ||
|
|
||
| res.writeHead(200, { | ||
| 'Access-Control-Allow-Origin': '*' | ||
| }) | ||
| res.end(JSON.stringify(redisRes)) | ||
| } catch (err) { | ||
| console.error("Error in redis command:", err) | ||
| res.writeHead(500, { | ||
| 'Access-Control-Allow-Origin': '*' | ||
| }) | ||
| res.end(err.toString()) | ||
| return | ||
| } | ||
|
|
||
|
|
||
| }; | ||
|
|
||
| const proxyServer = http.createServer(requestListener); | ||
| await new Promise(resolve => { proxyServer.listen(0, "localhost", () => { resolve() }); }) | ||
|
|
||
| return { | ||
| redisClient, | ||
| proxyServer: proxyServer, | ||
| env: { | ||
| ...process.env, | ||
| proxyPort: proxyServer.address().port | ||
| } | ||
| } | ||
| }, | ||
| async after(_, { proxyServer, redisClient }) { | ||
| await new Promise(resolve => { | ||
| proxyServer.close(() => resolve()); | ||
| }) | ||
|
|
||
| try { | ||
| // We don't care if this fails | ||
| await redisClient.disconnect() | ||
| } catch { } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| dist | ||
| node-image.json | ||
| chromium-image.json | ||
| firefox-image.json | ||
| webkit-image.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # syntax=docker/dockerfile:1 | ||
|
|
||
| FROM mcr.microsoft.com/playwright | ||
|
|
||
| COPY --from=node-js-libp2p-head /app/ /app/ | ||
| WORKDIR /app/interop | ||
| RUN ./node_modules/.bin/playwright install | ||
| ARG BROWSER=chromium # Options: chromium, firefox, webkit | ||
| ENV BROWSER=$BROWSER | ||
|
|
||
| ENTRYPOINT npm test -- --build false --types false -t browser -- --browser $BROWSER |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| FROM node:18 | ||
| WORKDIR /app | ||
| COPY package.json . | ||
| COPY ./node_modules ./node_modules | ||
|
|
||
| WORKDIR /app/interop | ||
| COPY ./interop/node_modules ./node_modules | ||
|
|
||
| WORKDIR /app | ||
| COPY ./dist ./dist | ||
|
|
||
| WORKDIR /app/interop | ||
| COPY ./interop/dist ./dist | ||
|
|
||
| COPY ./interop/package.json . | ||
| COPY ./interop/.aegir.js . | ||
|
|
||
| ENTRYPOINT [ "npm", "test", "--", "--build", "false", "--types", "false", "-t", "node" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| image_name := js-libp2p-head | ||
| TEST_SOURCES := $(wildcard test/*.ts) | ||
|
|
||
| # Enable webkit once https://github.com/libp2p/js-libp2p/pull/1627 is in | ||
| # all: node-image.json webkit-image.json firefox-image.json chromium-image.json | ||
| all: node-image.json firefox-image.json chromium-image.json | ||
|
|
||
| node-image.json: Dockerfile $(TEST_SOURCES) package.json .aegir.js | ||
| cd .. && docker build -f interop/Dockerfile -t node-${image_name} . | ||
| docker image inspect node-${image_name} -f "{{.Id}}" | \ | ||
| xargs -I {} echo "{\"imageID\": \"{}\"}" > $@ | ||
|
|
||
| chromium-image.json: node-image.json BrowserDockerfile $(TEST_SOURCES) package.json .aegir.js | ||
| cd .. && docker build -f interop/BrowserDockerfile --build-arg=BROWSER=chromium -t chromium-${image_name} . | ||
| docker image inspect chromium-${image_name} -f "{{.Id}}" | \ | ||
| xargs -I {} echo "{\"imageID\": \"{}\"}" > $@ | ||
|
|
||
| firefox-image.json: node-image.json BrowserDockerfile $(TEST_SOURCES) package.json .aegir.js | ||
| cd .. && docker build -f interop/BrowserDockerfile --build-arg=BROWSER=firefox -t firefox-${image_name} . | ||
| docker image inspect firefox-${image_name} -f "{{.Id}}" | \ | ||
| xargs -I {} echo "{\"imageID\": \"{}\"}" > $@ | ||
|
|
||
| webkit-image.json: node-image.json BrowserDockerfile $(TEST_SOURCES) package.json .aegir.js | ||
| cd .. && docker build -f interop/BrowserDockerfile --build-arg=BROWSER=webkit -t webkit-${image_name} . | ||
| docker image inspect webkit-${image_name} -f "{{.Id}}" | \ | ||
| xargs -I {} echo "{\"imageID\": \"{}\"}" > $@ | ||
|
|
||
| .PHONY: clean | ||
|
|
||
| clean: | ||
| rm *image.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| { | ||
| "id": "chromium-js-libp2p-head", | ||
| "containerImageID": "chromium-js-libp2p-head", | ||
| "transports": [ | ||
| { | ||
| "name": "webtransport", | ||
| "onlyDial": true | ||
| }, | ||
| { | ||
| "name": "webrtc", | ||
| "onlyDial": true | ||
| }, | ||
| { | ||
| "name": "wss", | ||
| "onlyDial": true | ||
| } | ||
| ], | ||
| "secureChannels": [ | ||
| "noise" | ||
| ], | ||
| "muxers": [ | ||
| "mplex", | ||
| "yamux" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| { | ||
| "id": "firefox-js-libp2p-head", | ||
| "containerImageID": "firefox-js-libp2p-head", | ||
| "transports": [ | ||
| { | ||
| "name": "webrtc", | ||
| "onlyDial": true | ||
| }, | ||
| { | ||
| "name": "wss", | ||
| "onlyDial": true | ||
| } | ||
| ], | ||
| "secureChannels": [ | ||
| "noise" | ||
| ], | ||
| "muxers": [ | ||
| "mplex", | ||
| "yamux" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| { | ||
| "id": "node-js-libp2p-head", | ||
| "containerImageID": "node-js-libp2p-head", | ||
| "transports": [ | ||
| "tcp", | ||
| "ws", | ||
| { | ||
| "name": "wss", | ||
| "onlyDial": true | ||
| } | ||
| ], | ||
| "secureChannels": [ | ||
| "noise" | ||
| ], | ||
| "muxers": [ | ||
| "mplex", | ||
| "yamux" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| { | ||
| "name": "multidim-interop", | ||
| "private": true, | ||
| "version": "1.0.0", | ||
| "description": "Multidimension Interop Test", | ||
| "type": "module", | ||
| "main": "index.js", | ||
| "author": "Glen De Cauwsemaecker <glen@littlebearlabs.io> / @marcopolo", | ||
| "license": "MIT", | ||
| "engines": { | ||
| "node": ">=18" | ||
| }, | ||
| "scripts": { | ||
| "start": "node index.js", | ||
| "build": "aegir build", | ||
| "test": "aegir test" | ||
| }, | ||
| "dependencies": { | ||
| "@chainsafe/libp2p-noise": "^12.0.0", | ||
| "@chainsafe/libp2p-yamux": "^4.0.1", | ||
| "@libp2p/mplex": "^8.0.1", | ||
| "@libp2p/tcp": "^7.0.1", | ||
| "@libp2p/webrtc": "^2.0.2", | ||
| "@libp2p/websockets": "^6.0.1", | ||
| "@libp2p/webtransport": "^2.0.1", | ||
| "@multiformats/mafmt": "^12.1.2", | ||
| "@multiformats/multiaddr": "^12.1.3", | ||
| "libp2p": "../", | ||
| "redis": "4.5.1" | ||
| }, | ||
| "browser": { | ||
| "@libp2p/tcp": false | ||
| }, | ||
| "devDependencies": { | ||
| "aegir": "^39.0.5" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| console.log("Everything is defined in the test folder") | ||
|
|
||
| export { } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.