Skip to content
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

Reproducable JS yamux <> Rust yamux test failure #178

Closed
wants to merge 1 commit 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
82 changes: 82 additions & 0 deletions multidim-interop/impl/js/head/.aegir.js
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'
}
}
1 change: 1 addition & 0 deletions multidim-interop/impl/js/head/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
3 changes: 3 additions & 0 deletions multidim-interop/impl/js/head/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist
node-image.json
chromium-image.json
6 changes: 6 additions & 0 deletions multidim-interop/impl/js/head/ChromiumDockerfile
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" ]
21 changes: 21 additions & 0 deletions multidim-interop/impl/js/head/Dockerfile
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" ]
23 changes: 23 additions & 0 deletions multidim-interop/impl/js/head/Makefile
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
Loading