Skip to content

Commit

Permalink
chore: revert interop changes
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed May 28, 2024
1 parent 3994b6a commit 6a335f9
Show file tree
Hide file tree
Showing 18 changed files with 1,064 additions and 360 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ jobs:
path: |
package-lock.json
interop/package-lock.json
- uses: libp2p/test-plans/.github/actions/run-interop-ping-test@fix/wait-for-healthy-redis
- uses: libp2p/test-plans/.github/actions/run-interop-ping-test@main
with:
test-filter: js-libp2p-head
test-ignore: nim
Expand Down
42 changes: 8 additions & 34 deletions interop/.aegir.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable no-console */
import http from 'http'
import { pEvent } from 'p-event'
import { createClient } from 'redis'
import { createRelay } from './relay.js'

const redisAddr = process.env.redis_addr || 'redis:6379'
const transport = process.env.transport
Expand All @@ -17,8 +16,6 @@ export default {
}
},
async before () {
const { createRelay } = await import('./dist/test/fixtures/relay.js')

let relayNode = { stop: () => {} }
let relayAddr = ''
if (transport === 'webrtc' && !isDialer) {
Expand All @@ -34,14 +31,9 @@ export default {
const redisClient = createClient({
url: `redis://${redisAddr}`
})
redisClient.on('error', (err) => {
console.error('Redis client error:', err)
})

let start = Date.now()
console.error('connect redis client')
// eslint-disable-next-line no-console
redisClient.on('error', (err) => console.error(`Redis Client Error: ${err}`))
await redisClient.connect()
console.error('connected redis client after', Date.now() - start, 'ms')

const requestListener = async function (req, res) {
const requestJSON = await new Promise(resolve => {
Expand All @@ -57,18 +49,8 @@ export default {

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
if (redisRes === null) {
throw new Error('redis sent back null')
}

res.writeHead(200, {
Expand All @@ -85,25 +67,17 @@ export default {
}
}

start = Date.now()
console.error('start proxy server')
const proxyServer = http.createServer(requestListener)
proxyServer.listen(0)

await pEvent(proxyServer, 'listening', {
signal: AbortSignal.timeout(5000)
})

console.error('redis proxy is listening on port', proxyServer.address().port, 'after', Date.now() - start, 'ms')
await new Promise(resolve => { proxyServer.listen(0, () => { resolve() }) })

return {
redisClient,
relayNode,
proxyServer,
env: {
...process.env,
RELAY_ADDR: relayAddr,
REDIS_PROXY_PORT: proxyServer.address().port
relayAddr,
proxyPort: proxyServer.address().port
}
}
},
Expand Down
5 changes: 5 additions & 0 deletions interop/.gitignore
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
25 changes: 7 additions & 18 deletions interop/BrowserDockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
# syntax=docker/dockerfile:1

# Copied since we won't have the repo to use if expanding from cache.

# Workaround: https://github.com/docker/cli/issues/996
ARG BASE_IMAGE=node-js-libp2p-head
FROM ${BASE_IMAGE} as js-libp2p-base

FROM mcr.microsoft.com/playwright

COPY --from=js-libp2p-base /app/ /app/

# We install browsers here instead of the cached version so that we use the latest browsers at run time.
# Ideally this would also be pinned, but playwright controls this, so there isn't much we can do about it.
# By installing here, we avoid installing it at test time.
RUN npx playwright install-deps
RUN npx playwright install

COPY --from=node-js-libp2p-head /app/ /app/
WORKDIR /app/interop
# Options: chromium, firefox, webkit
ARG BROWSER=chromium
ENV BROWSER=${BROWSER}

WORKDIR /app/interop
ENV BROWSER=$BROWSER
# disable colored output and CLI animation from test runners
ENV CI true

ENTRYPOINT npm test -- -t browser -- --browser $BROWSER
# manually specify runner until https://github.com/hugomrdias/playwright-test/issues/572 is resolved
ENTRYPOINT npm run test:interop:multidim -- --build false --types false -t browser -- --browser $BROWSER
Loading

0 comments on commit 6a335f9

Please sign in to comment.