Skip to content

Commit

Permalink
chore: fix hanging and erroring tests (#466)
Browse files Browse the repository at this point in the history
- Use `127.0.0.1` instead of `localhost` to fix ipv4 vs ipv6 issues
- Reduce traefik test flakiness
- Fix grpcwebproxy download for arm64
- Get rid of `get-port` dependency for `nice-grpc`
  • Loading branch information
aikoven authored Oct 17, 2023
1 parent 0509986 commit 0d169ec
Show file tree
Hide file tree
Showing 43 changed files with 250 additions and 391 deletions.
13 changes: 6 additions & 7 deletions packages/nice-grpc-client-middleware-deadline/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import defer = require('defer-promise');
import {forever} from 'abort-controller-x';
import {
createChannel,
Expand Down Expand Up @@ -27,9 +26,9 @@ test('successful call', async () => {
testBidiStream: throwUnimplemented,
});

const port = await server.listen('localhost:0');
const port = await server.listen('127.0.0.1:0');

const channel = createChannel(`localhost:${port}`);
const channel = createChannel(`127.0.0.1:${port}`);
const client = createClientFactory()
.use(deadlineMiddleware)
.create(TestService, channel);
Expand Down Expand Up @@ -57,9 +56,9 @@ test('absolute deadline', async () => {
testBidiStream: throwUnimplemented,
});

const port = await server.listen('localhost:0');
const port = await server.listen('127.0.0.1:0');

const channel = createChannel(`localhost:${port}`);
const channel = createChannel(`127.0.0.1:${port}`);
const client = createClientFactory()
.use(deadlineMiddleware)
.create(TestService, channel);
Expand Down Expand Up @@ -89,9 +88,9 @@ test('relative deadline', async () => {
testBidiStream: throwUnimplemented,
});

const port = await server.listen('localhost:0');
const port = await server.listen('127.0.0.1:0');

const channel = createChannel(`localhost:${port}`);
const channel = createChannel(`127.0.0.1:${port}`);
const client = createClientFactory()
.use(deadlineMiddleware)
.create(TestService, channel);
Expand Down
12 changes: 6 additions & 6 deletions packages/nice-grpc-client-middleware-retry/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ test('basic', async () => {
},
});

const port = await server.listen('localhost:0');
const port = await server.listen('127.0.0.1:0');

const channel = createChannel(`localhost:${port}`);
const channel = createChannel(`127.0.0.1:${port}`);
const client = createClientFactory()
.use(retryMiddleware)
.create(TestDefinition, channel);
Expand Down Expand Up @@ -71,9 +71,9 @@ test('retries enabled', async () => {
},
});

const port = await server.listen('localhost:0');
const port = await server.listen('127.0.0.1:0');

const channel = createChannel(`localhost:${port}`);
const channel = createChannel(`127.0.0.1:${port}`);
const client = createClientFactory()
.use(retryMiddleware)
.create(TestDefinition, channel);
Expand Down Expand Up @@ -120,9 +120,9 @@ test('idempotent', async () => {
},
});

const port = await server.listen('localhost:0');
const port = await server.listen('127.0.0.1:0');

const channel = createChannel(`localhost:${port}`);
const channel = createChannel(`127.0.0.1:${port}`);
const client = createClientFactory()
.use(retryMiddleware)
.create(TestDefinition, channel);
Expand Down
4 changes: 2 additions & 2 deletions packages/nice-grpc-error-details/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ const beforeEachServerAndClientTest = async (
},
});

const port = await server.listen('localhost:0');
const port = await server.listen('127.0.0.1:0');

const channel = createChannel(`localhost:${port}`);
const channel = createChannel(`127.0.0.1:${port}`);

const rawClient = createClient(TestDefinition, channel);

Expand Down
18 changes: 9 additions & 9 deletions packages/nice-grpc-opentelemetry/src/__tests__/bidiStreaming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ test('basic', async () => {
},
});

const port = await server.listen('localhost:0');
const port = await server.listen('127.0.0.1:0');

const channel = createChannel(`localhost:${port}`);
const channel = createChannel(`127.0.0.1:${port}`);
const client = createClientFactory()
.use(openTelemetryClientMiddleware())
.create(TestDefinition, channel);
Expand Down Expand Up @@ -120,7 +120,7 @@ test('basic', async () => {
expect(dumpSpan(serverSpan)).toMatchInlineSnapshot(`
{
"attributes": {
"net.peer.ip": "::1",
"net.peer.ip": "127.0.0.1",
"rpc.grpc.status_code": 0,
"rpc.grpc.status_text": "OK",
"rpc.method": "TestBidiStream",
Expand Down Expand Up @@ -185,9 +185,9 @@ test('error', async () => {
},
});

const port = await server.listen('localhost:0');
const port = await server.listen('127.0.0.1:0');

const channel = createChannel(`localhost:${port}`);
const channel = createChannel(`127.0.0.1:${port}`);
const client = createClientFactory()
.use(openTelemetryClientMiddleware())
.create(TestDefinition, channel);
Expand Down Expand Up @@ -249,7 +249,7 @@ test('error', async () => {
expect(dumpSpan(serverSpan)).toMatchInlineSnapshot(`
{
"attributes": {
"net.peer.ip": "::1",
"net.peer.ip": "127.0.0.1",
"rpc.grpc.status_code": 5,
"rpc.grpc.status_text": "NOT_FOUND",
"rpc.method": "TestBidiStream",
Expand Down Expand Up @@ -295,9 +295,9 @@ test('aborted iteration on client', async () => {
},
});

const port = await server.listen('localhost:0');
const port = await server.listen('127.0.0.1:0');

const channel = createChannel(`localhost:${port}`);
const channel = createChannel(`127.0.0.1:${port}`);
const client = createClientFactory()
.use(openTelemetryClientMiddleware())
.create(TestDefinition, channel);
Expand Down Expand Up @@ -365,7 +365,7 @@ test('aborted iteration on client', async () => {
expect(dumpSpan(serverSpan)).toMatchInlineSnapshot(`
{
"attributes": {
"net.peer.ip": "::1",
"net.peer.ip": "127.0.0.1",
"rpc.grpc.status_code": 1,
"rpc.grpc.status_text": "CANCELLED",
"rpc.method": "TestBidiStream",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ test('basic', async () => {
testBidiStream: throwUnimplemented,
});

const port = await server.listen('localhost:0');
const port = await server.listen('127.0.0.1:0');

const channel = createChannel(`localhost:${port}`);
const channel = createChannel(`127.0.0.1:${port}`);
const client = createClientFactory()
.use(openTelemetryClientMiddleware())
.create(TestDefinition, channel);
Expand Down Expand Up @@ -105,7 +105,7 @@ test('basic', async () => {
expect(dumpSpan(serverSpan)).toMatchInlineSnapshot(`
{
"attributes": {
"net.peer.ip": "::1",
"net.peer.ip": "127.0.0.1",
"rpc.grpc.status_code": 0,
"rpc.grpc.status_text": "OK",
"rpc.method": "TestClientStream",
Expand Down Expand Up @@ -157,9 +157,9 @@ test('error', async () => {
testBidiStream: throwUnimplemented,
});

const port = await server.listen('localhost:0');
const port = await server.listen('127.0.0.1:0');

const channel = createChannel(`localhost:${port}`);
const channel = createChannel(`127.0.0.1:${port}`);
const client = createClientFactory()
.use(openTelemetryClientMiddleware())
.create(TestDefinition, channel);
Expand Down Expand Up @@ -216,7 +216,7 @@ test('error', async () => {
expect(dumpSpan(serverSpan)).toMatchInlineSnapshot(`
{
"attributes": {
"net.peer.ip": "::1",
"net.peer.ip": "127.0.0.1",
"rpc.grpc.status_code": 5,
"rpc.grpc.status_text": "NOT_FOUND",
"rpc.method": "TestClientStream",
Expand Down
4 changes: 2 additions & 2 deletions packages/nice-grpc-opentelemetry/src/__tests__/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ test('context propagation', async () => {
testBidiStream: throwUnimplemented,
});

const port = await server.listen('localhost:0');
const port = await server.listen('127.0.0.1:0');

const channel = createChannel(`localhost:${port}`);
const channel = createChannel(`127.0.0.1:${port}`);
const client = createClientFactory()
.use(async function* testClientMiddleware(call, options) {
traceIdInClientMiddlewareStart = getCurrentTraceId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ test('basic', async () => {
testBidiStream: throwUnimplemented,
});

const port = await server.listen('localhost:0');
const port = await server.listen('127.0.0.1:0');

const channel = createChannel(`localhost:${port}`);
const channel = createChannel(`127.0.0.1:${port}`);
const client = createClientFactory()
.use(openTelemetryClientMiddleware())
.create(TestDefinition, channel);
Expand Down Expand Up @@ -100,7 +100,7 @@ test('basic', async () => {
expect(dumpSpan(serverSpan)).toMatchInlineSnapshot(`
{
"attributes": {
"net.peer.ip": "::1",
"net.peer.ip": "127.0.0.1",
"rpc.grpc.status_code": 0,
"rpc.grpc.status_text": "OK",
"rpc.method": "TestServerStream",
Expand Down Expand Up @@ -150,9 +150,9 @@ test('error', async () => {
testBidiStream: throwUnimplemented,
});

const port = await server.listen('localhost:0');
const port = await server.listen('127.0.0.1:0');

const channel = createChannel(`localhost:${port}`);
const channel = createChannel(`127.0.0.1:${port}`);
const client = createClientFactory()
.use(openTelemetryClientMiddleware())
.create(TestDefinition, channel);
Expand Down Expand Up @@ -202,7 +202,7 @@ test('error', async () => {
expect(dumpSpan(serverSpan)).toMatchInlineSnapshot(`
{
"attributes": {
"net.peer.ip": "::1",
"net.peer.ip": "127.0.0.1",
"rpc.grpc.status_code": 5,
"rpc.grpc.status_text": "NOT_FOUND",
"rpc.method": "TestServerStream",
Expand Down Expand Up @@ -245,9 +245,9 @@ test('aborted iteration on client', async () => {
testBidiStream: throwUnimplemented,
});

const port = await server.listen('localhost:0');
const port = await server.listen('127.0.0.1:0');

const channel = createChannel(`localhost:${port}`);
const channel = createChannel(`127.0.0.1:${port}`);
const client = createClientFactory()
.use(openTelemetryClientMiddleware())
.create(TestDefinition, channel);
Expand Down Expand Up @@ -296,7 +296,7 @@ test('aborted iteration on client', async () => {
expect(dumpSpan(serverSpan)).toMatchInlineSnapshot(`
{
"attributes": {
"net.peer.ip": "::1",
"net.peer.ip": "127.0.0.1",
"rpc.grpc.status_code": 1,
"rpc.grpc.status_text": "CANCELLED",
"rpc.method": "TestServerStream",
Expand Down
24 changes: 12 additions & 12 deletions packages/nice-grpc-opentelemetry/src/__tests__/unary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ test('basic', async () => {
testBidiStream: throwUnimplemented,
});

const port = await server.listen('localhost:0');
const port = await server.listen('127.0.0.1:0');

const channel = createChannel(`localhost:${port}`);
const channel = createChannel(`127.0.0.1:${port}`);
const client = createClientFactory()
.use(openTelemetryClientMiddleware())
.create(TestDefinition, channel);
Expand Down Expand Up @@ -84,7 +84,7 @@ test('basic', async () => {
expect(dumpSpan(serverSpan)).toMatchInlineSnapshot(`
{
"attributes": {
"net.peer.ip": "::1",
"net.peer.ip": "127.0.0.1",
"rpc.grpc.status_code": 0,
"rpc.grpc.status_text": "OK",
"rpc.method": "TestUnary",
Expand Down Expand Up @@ -118,9 +118,9 @@ test('error', async () => {
testBidiStream: throwUnimplemented,
});

const port = await server.listen('localhost:0');
const port = await server.listen('127.0.0.1:0');

const channel = createChannel(`localhost:${port}`);
const channel = createChannel(`127.0.0.1:${port}`);
const client = createClientFactory()
.use(openTelemetryClientMiddleware())
.create(TestDefinition, channel);
Expand Down Expand Up @@ -157,7 +157,7 @@ test('error', async () => {
expect(dumpSpan(serverSpan)).toMatchInlineSnapshot(`
{
"attributes": {
"net.peer.ip": "::1",
"net.peer.ip": "127.0.0.1",
"rpc.grpc.status_code": 5,
"rpc.grpc.status_text": "NOT_FOUND",
"rpc.method": "TestUnary",
Expand Down Expand Up @@ -191,9 +191,9 @@ test('unknown error', async () => {
testBidiStream: throwUnimplemented,
});

const port = await server.listen('localhost:0');
const port = await server.listen('127.0.0.1:0');

const channel = createChannel(`localhost:${port}`);
const channel = createChannel(`127.0.0.1:${port}`);
const client = createClientFactory()
.use(openTelemetryClientMiddleware())
.create(TestDefinition, channel);
Expand Down Expand Up @@ -235,7 +235,7 @@ test('unknown error', async () => {
expect(dumpSpan(serverSpan)).toMatchInlineSnapshot(`
{
"attributes": {
"net.peer.ip": "::1",
"net.peer.ip": "127.0.0.1",
"rpc.grpc.status_code": 2,
"rpc.grpc.status_text": "UNKNOWN",
"rpc.method": "TestUnary",
Expand Down Expand Up @@ -281,9 +281,9 @@ test('cancel', async () => {
testBidiStream: throwUnimplemented,
});

const port = await server.listen('localhost:0');
const port = await server.listen('127.0.0.1:0');

const channel = createChannel(`localhost:${port}`);
const channel = createChannel(`127.0.0.1:${port}`);
const client = createClientFactory()
.use(openTelemetryClientMiddleware())
.create(TestDefinition, channel);
Expand Down Expand Up @@ -328,7 +328,7 @@ test('cancel', async () => {
expect(dumpSpan(serverSpan)).toMatchInlineSnapshot(`
{
"attributes": {
"net.peer.ip": "::1",
"net.peer.ip": "127.0.0.1",
"rpc.grpc.status_code": 1,
"rpc.grpc.status_text": "CANCELLED",
"rpc.method": "TestUnary",
Expand Down
12 changes: 6 additions & 6 deletions packages/nice-grpc-prometheus/src/__tests__/bidiStreaming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ test('basic', async () => {
},
});

const port = await server.listen('localhost:0');
const port = await server.listen('127.0.0.1:0');

const channel = createChannel(`localhost:${port}`);
const channel = createChannel(`127.0.0.1:${port}`);
const client = createClientFactory()
.use(prometheusClientMiddleware())
.create(TestDefinition, channel);
Expand Down Expand Up @@ -138,9 +138,9 @@ test('error', async () => {
},
});

const port = await server.listen('localhost:0');
const port = await server.listen('127.0.0.1:0');

const channel = createChannel(`localhost:${port}`);
const channel = createChannel(`127.0.0.1:${port}`);
const client = createClientFactory()
.use(prometheusClientMiddleware())
.create(TestDefinition, channel);
Expand Down Expand Up @@ -247,9 +247,9 @@ test('aborted iteration on client', async () => {
},
});

const port = await server.listen('localhost:0');
const port = await server.listen('127.0.0.1:0');

const channel = createChannel(`localhost:${port}`);
const channel = createChannel(`127.0.0.1:${port}`);
const client = createClientFactory()
.use(prometheusClientMiddleware())
.create(TestDefinition, channel);
Expand Down
Loading

0 comments on commit 0d169ec

Please sign in to comment.