Skip to content

Commit df04b3e

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
test(e2e): force IPv4 for hosted test origin
Accept safe dual-stack loopback resolution while pinning Chromium and Node traffic to 127.0.0.1 so CI reaches IPv4-only services reliably.
1 parent d3c3703 commit df04b3e

5 files changed

Lines changed: 12 additions & 5 deletions

File tree

apps/sim/e2e/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ per-run pgvector database.
1616
echo "127.0.0.1 e2e.sim.ai" | sudo tee -a /etc/hosts
1717
```
1818

19-
The runner refuses to start unless every resolved address is loopback.
19+
The runner refuses to start unless every resolved address is loopback and an
20+
IPv4 `127.0.0.1` result is present. Chromium and Node are configured to prefer
21+
that IPv4 mapping, so CI environments that also synthesize `::1` remain safe.
2022

2123
2. Start a local pgvector/Postgres admin instance:
2224

apps/sim/e2e/foundation/safety.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ test.describe('foundation safety guards', () => {
8484
expect(isLoopbackAddress('::1')).toBe(true)
8585
expect(isLoopbackAddress('8.8.8.8')).toBe(false)
8686
expect(areValidE2eHostAddresses(['127.0.0.1'])).toBe(true)
87-
expect(areValidE2eHostAddresses(['127.0.0.1', '::1'])).toBe(false)
87+
expect(areValidE2eHostAddresses(['127.0.0.1', '::1'])).toBe(true)
8888
expect(areValidE2eHostAddresses(['::1'])).toBe(false)
8989
expect(areValidE2eHostAddresses(['127.0.0.2'])).toBe(false)
9090
})

apps/sim/e2e/support/deployment-profile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export function createHostedBillingProfile({
6363
}: HostedBillingProfileOptions): HostedBillingProfile {
6464
const values: Record<string, string> = {
6565
NODE_ENV: 'production',
66-
NODE_OPTIONS: '--no-warnings --max-old-space-size=8192',
66+
NODE_OPTIONS: '--no-warnings --max-old-space-size=8192 --dns-result-order=ipv4first',
6767
NEXT_TELEMETRY_DISABLED: '1',
6868
HOME: homeDirectory,
6969
XDG_CONFIG_HOME: `${homeDirectory}/xdg`,

apps/sim/e2e/support/hosts.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ export function isLoopbackAddress(address: string): boolean {
1212
}
1313

1414
export function areValidE2eHostAddresses(addresses: string[]): boolean {
15-
return addresses.length > 0 && addresses.every((address) => address === '127.0.0.1')
15+
return (
16+
addresses.length > 0 && addresses.every(isLoopbackAddress) && addresses.includes('127.0.0.1')
17+
)
1618
}
1719

1820
export async function assertE2eHostResolvesToLoopback(hostname = E2E_HOST): Promise<string[]> {
@@ -33,7 +35,7 @@ export async function assertE2eHostResolvesToLoopback(hostname = E2E_HOST): Prom
3335
function getHostMappingError(hostname: string, addresses: string[]): string {
3436
const observed = addresses.length > 0 ? addresses.join(', ') : 'no addresses'
3537
return [
36-
`${hostname} must resolve exclusively to IPv4 127.0.0.1; observed ${observed}.`,
38+
`${hostname} must resolve only to loopback and include IPv4 127.0.0.1; observed ${observed}.`,
3739
`Add it once with: echo "127.0.0.1 ${hostname}" | sudo tee -a /etc/hosts`,
3840
].join(' ')
3941
}

apps/sim/playwright.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ export default defineConfig({
2929
use: {
3030
...devices['Desktop Chrome'],
3131
baseURL,
32+
launchOptions: {
33+
args: ['--host-resolver-rules=MAP e2e.sim.ai 127.0.0.1'],
34+
},
3235
actionTimeout: 15_000,
3336
navigationTimeout: 30_000,
3437
trace: 'retain-on-failure',

0 commit comments

Comments
 (0)