Skip to content
Open
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
20 changes: 19 additions & 1 deletion transport/images/js/v1.x/.aegir.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,25 @@ export default {
redisClient.on('error', (err) => {
console.error('Redis client error:', err)
})
await redisClient.connect()

// Sometimes Docker DNS is slow and Redis hostname isn't found right away
// so we just try a few times instead of giving up immediately
const maxRetries = 10
for (let attempt = 1; attempt <= maxRetries; attempt++) {
try {
await redisClient.connect()
if (attempt > 1) {
console.error(`Redis connected on attempt ${attempt}`)
}
break
} catch (err) {
if (attempt === maxRetries) {
throw new Error(`Failed to connect to Redis after ${maxRetries} attempts: ${err.message}`)
}
console.error(`Redis connection attempt ${attempt}/${maxRetries} failed: ${err.message}`)
await new Promise(resolve => setTimeout(resolve, attempt * 1000))
}
}

const requestListener = async function (req, res) {
let requestJSON
Expand Down
8 changes: 8 additions & 0 deletions transport/images/js/v1.x/BrowserDockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@ ENV BROWSER=${BROWSER}
# container and not during the test run which slows everything down
RUN npx playwright-test --runner mocha --browser $BROWSER --grep do-not-match-anything

# Playwright install can break /etc/resolv.conf by turning it into
# a dead symlink. If that happens, DNS lookups fail with EAI_AGAIN.
# This just checks for that and fixes it.
RUN if [ -L /etc/resolv.conf ]; then \
rm -f /etc/resolv.conf && \
echo "nameserver 8.8.8.8" > /etc/resolv.conf; \
fi

ENTRYPOINT ["sh", "-c", "npm test -- -t browser -- --browser \"$BROWSER\""]
20 changes: 19 additions & 1 deletion transport/images/js/v2.x/.aegir.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,25 @@ export default {
redisClient.on('error', (err) => {
console.error('Redis client error:', err)
})
await redisClient.connect()

// Sometimes Docker DNS is slow and Redis hostname isn't found right away
// so we just try a few times instead of giving up immediately
const maxRetries = 10
for (let attempt = 1; attempt <= maxRetries; attempt++) {
try {
await redisClient.connect()
if (attempt > 1) {
console.error(`Redis connected on attempt ${attempt}`)
}
break
} catch (err) {
if (attempt === maxRetries) {
throw new Error(`Failed to connect to Redis after ${maxRetries} attempts: ${err.message}`)
}
console.error(`Redis connection attempt ${attempt}/${maxRetries} failed: ${err.message}`)
await new Promise(resolve => setTimeout(resolve, attempt * 1000))
}
}

const requestListener = async function (req, res) {
let requestJSON
Expand Down
8 changes: 8 additions & 0 deletions transport/images/js/v2.x/BrowserDockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@ ENV BROWSER=${BROWSER}
# container and not during the test run which slows everything down
RUN npx playwright-test --runner mocha --browser $BROWSER --grep do-not-match-anything

# Playwright install can break /etc/resolv.conf by turning it into
# a dead symlink. If that happens, DNS lookups fail with EAI_AGAIN.
# This just checks for that and fixes it.
RUN if [ -L /etc/resolv.conf ]; then \
rm -f /etc/resolv.conf && \
echo "nameserver 8.8.8.8" > /etc/resolv.conf; \
fi

ENTRYPOINT ["sh", "-c", "npm test -- -t browser -- --browser \"$BROWSER\""]
19 changes: 18 additions & 1 deletion transport/images/js/v3.x/.aegir.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,26 @@ export default {
console.error('Redis client error:', err)
})

// Sometimes Docker DNS is slow and Redis hostname isn't found right away
// so we just try a few times instead of giving up immediately
const maxRetries = 10
let start = Date.now()
console.error('connect redis client')
await redisClient.connect()
for (let attempt = 1; attempt <= maxRetries; attempt++) {
try {
await redisClient.connect()
if (attempt > 1) {
console.error(`Redis connected on attempt ${attempt}`)
}
break
} catch (err) {
if (attempt === maxRetries) {
throw new Error(`Failed to connect to Redis after ${maxRetries} attempts: ${err.message}`)
}
console.error(`Redis connection attempt ${attempt}/${maxRetries} failed: ${err.message}`)
await new Promise(resolve => setTimeout(resolve, attempt * 1000))
}
}
console.error('connected redis client after', Date.now() - start, 'ms')

const requestListener = async function (req, res) {
Expand Down
8 changes: 8 additions & 0 deletions transport/images/js/v3.x/BrowserDockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@ ENV BROWSER=${BROWSER}
# container and not during the test run which slows everything down
RUN npx playwright-test --runner mocha --browser $BROWSER --grep do-not-match-anything

# Playwright install can break /etc/resolv.conf by turning it into
# a dead symlink. If that happens, DNS lookups fail with EAI_AGAIN.
# This just checks for that and fixes it.
RUN if [ -L /etc/resolv.conf ]; then \
rm -f /etc/resolv.conf && \
echo "nameserver 8.8.8.8" > /etc/resolv.conf; \
fi

ENTRYPOINT ["sh", "-c", "npm test -- -t browser -- --browser \"$BROWSER\""]
5 changes: 5 additions & 0 deletions transport/lib/run-single-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ services:
image: "${LISTENER_IMAGE}"
container_name: ${TEST_SLUG}_listener
init: true
dns:
- 127.0.0.11
networks:
- transport-network
environment:
Expand All @@ -112,6 +114,9 @@ ${LISTENER_ENV}
dialer:
image: "${DIALER_IMAGE}"
container_name: ${TEST_SLUG}_dialer
init: true
dns:
- 127.0.0.11
depends_on:
- listener
networks:
Expand Down