-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trying to debug these tests in CI is incredibly difficult and since they depend on older versions of previously published modules, if something breaks it's very hard to fix it. Instead follow the pattern in the perf tests and include the full test implementations here.
- Loading branch information
1 parent
7ce1a02
commit 07d6ef6
Showing
30 changed files
with
31,050 additions
and
6,385 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 |
---|---|---|
|
@@ -43,6 +43,7 @@ __pycache__/ | |
### NodeJS | ||
|
||
node_modules | ||
dist | ||
|
||
# ignore system files | ||
.DS_Store |
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,117 @@ | ||
/* eslint-disable no-console */ | ||
import http from 'http' | ||
import { pEvent } from 'p-event' | ||
import { createClient } from 'redis' | ||
|
||
const redisAddr = process.env.redis_addr || 'redis:6379' | ||
const transport = process.env.transport | ||
const isDialer = process.env.is_dialer === 'true' | ||
|
||
/** @type {import('aegir/types').PartialOptions} */ | ||
export default { | ||
test: { | ||
browser: { | ||
config: { | ||
// Ignore self signed certificates | ||
browserContextOptions: { ignoreHTTPSErrors: true } | ||
} | ||
}, | ||
async before () { | ||
// import after build is complete | ||
const { createRelay } = await import('./dist/test/fixtures/relay.js') | ||
|
||
let relayNode | ||
let relayAddr | ||
if (transport === 'webrtc' && !isDialer) { | ||
relayNode = await createRelay() | ||
|
||
const sortByNonLocalIp = (a, b) => { | ||
if (a.toString().includes('127.0.0.1')) { | ||
return 1 | ||
} | ||
return -1 | ||
} | ||
|
||
relayAddr = relayNode.getMultiaddrs().sort(sortByNonLocalIp)[0].toString() | ||
} | ||
|
||
const redisClient = createClient({ | ||
url: `redis://${redisAddr}` | ||
}) | ||
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) { | ||
console.error('Redis failure - sent', requestJSON, 'received', redisRes) | ||
|
||
res.writeHead(500, { | ||
'Access-Control-Allow-Origin': '*' | ||
}) | ||
res.end(JSON.stringify({ | ||
message: 'Redis sent back null' | ||
})) | ||
|
||
return | ||
} | ||
|
||
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()) | ||
} | ||
} | ||
|
||
const proxyServer = http.createServer(requestListener) | ||
proxyServer.listen(0) | ||
|
||
await pEvent(proxyServer, 'listening', { | ||
signal: AbortSignal.timeout(5000) | ||
}) | ||
|
||
return { | ||
redisClient, | ||
relayNode, | ||
proxyServer, | ||
env: { | ||
...process.env, | ||
RELAY_ADDR: relayAddr, | ||
REDIS_PROXY_PORT: proxyServer.address().port | ||
} | ||
} | ||
}, | ||
async after (_, { proxyServer, redisClient, relayNode }) { | ||
await new Promise(resolve => { | ||
proxyServer?.close(() => resolve()) | ||
}) | ||
|
||
try { | ||
// We don't care if this fails | ||
await redisClient?.disconnect() | ||
await relayNode?.stop() | ||
} catch { } | ||
} | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,11 +1,17 @@ | ||
# Here because we want to fetch the node_modules within docker so that it's | ||
# installed on the same platform the test is run. Otherwise tools like `esbuild` will fail to run | ||
FROM node:18 | ||
FROM node:22-bullseye-slim | ||
|
||
WORKDIR /app | ||
COPY . . | ||
RUN npm i && npm run build | ||
|
||
WORKDIR /app/interop | ||
RUN npm i && npm run build | ||
COPY package*.json .aegir.js tsconfig.json ./ | ||
COPY src ./src | ||
COPY test ./test | ||
|
||
# disable colored output and CLI animation from test runners | ||
ENV CI true | ||
|
||
RUN npm ci | ||
RUN npm run build | ||
|
||
ENTRYPOINT [ "npm", "test", "--", "--build", "false", "--types", "false", "-t", "node" ] | ||
ENTRYPOINT npm test -- -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
Oops, something went wrong.