Marco Munizaga 3b6d87b532
Update Go & JS tests to conform to the multidim interop test spec. (#121)
* Update Go test implementations to match new spec

* Update JS test implementation

* Update Rust test Implementation

* Update root Makefile

* Update runner to new spec

* Use composite action and S3 caching

* Not using GHA cache anymore

* Try removing access key from env

* Test workflow without cache keys (#131)

* Test if it works without s3 cache keys

* Fix if statement

* Fix if statement

* Always use buildkit

* Undo debug change

* Add no cache workflow

* Skip test in no-cache workflow

* Update .github/workflows/no-cache-multidim-interop.yml

* Same workflow; use CACHING_OPTIONS

* Add Browser WebRTC test (#130)

* Add webrtc to JS test

* Add onlyDial to all queries

* Update versions.ts

* Remove unneeded timeout overrides
2023-02-10 17:00:53 -08:00

90 lines
2.3 KiB
JavaScript

import { spawn, exec } from "child_process";
import { existsSync } from "fs";
import { createClient } from 'redis'
import http from "http"
const isDialer = process.env.is_dialer === "true"
const redis_addr = process.env.redis_addr || 'redis:6379'
// Used to preinstall the browsers in the docker image
const initialSetup = process.env.initial_setup === "true"
/** @type {import('aegir/types').PartialOptions} */
export default {
test: {
async before() {
if (initialSetup) {
return {}
}
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 }) {
if (initialSetup) {
return
}
await new Promise(resolve => {
proxyServer.close(() => resolve());
})
try {
// We don't care if this fails
await redisClient.disconnect()
} catch { }
}
},
build: {
bundlesizeMax: '18kB'
}
}