forked from libp2p/test-plans
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy of `multidim-interop/impl/js/v0.42` plus version adjustments + reenable WebRTC (see libp2p#160).
- Loading branch information
Showing
12 changed files
with
42,919 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,82 @@ | ||
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 { } | ||
} | ||
}, | ||
build: { | ||
bundlesizeMax: '18kB' | ||
} | ||
} |
This file contains 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 @@ | ||
node_modules/ |
This file contains 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 @@ | ||
dist | ||
node-image.json | ||
chromium-image.json |
This file contains 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,6 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
ARG BASE_IMAGE | ||
FROM $BASE_IMAGE | ||
|
||
ENTRYPOINT [ "npm", "test", "--", "--build", "false", "--types", "false", "-t", "browser" ] |
This file contains 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 @@ | ||
# syntax=docker/dockerfile:1 | ||
# Using playwright so that we have the same base across NodeJS + Browser tests | ||
FROM mcr.microsoft.com/playwright | ||
|
||
WORKDIR /app | ||
|
||
COPY package*.json ./ | ||
|
||
RUN npm ci | ||
|
||
# Install browsers, Needed for the browser tests, but we do it here so we have the same base | ||
RUN ./node_modules/.bin/playwright install | ||
|
||
COPY tsconfig.json . | ||
COPY .aegir.js . | ||
COPY test ./test | ||
COPY src ./src | ||
|
||
RUN npm run build | ||
|
||
ENTRYPOINT [ "npm", "test", "--", "--build", "false", "--types", "false", "-t", "node" ] |
This file contains 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,23 @@ | ||
image_name := js-v0.42 | ||
TEST_SOURCES := $(wildcard test/*.ts) | ||
|
||
all: chromium-image.json node-image.json | ||
|
||
chromium-image.json: node-image.json | ||
docker build -t chromium-${image_name} -f ChromiumDockerfile --build-arg="BASE_IMAGE=node-${image_name}" . | ||
docker image inspect chromium-${image_name} -f "{{.Id}}" | \ | ||
xargs -I {} echo "{\"imageID\": \"{}\"}" > $@ | ||
|
||
node-image.json: image.json | ||
docker image tag $$(cat image.json | jq -r '.imageID') node-${image_name} | ||
cp image.json node-image.json | ||
|
||
image.json: Dockerfile $(TEST_SOURCES) package.json package-lock.json .aegir.js | ||
IMAGE_NAME=node-${image_name} ../../../dockerBuildWrapper.sh -f Dockerfile . | ||
docker image inspect node-${image_name} -f "{{.Id}}" | \ | ||
xargs -I {} echo "{\"imageID\": \"{}\"}" > $@ | ||
|
||
.PHONY: clean | ||
|
||
clean: | ||
rm *image.json |
Oops, something went wrong.