Skip to content

Commit 43e3322

Browse files
committed
distributed in other envs
1 parent e7d916a commit 43e3322

File tree

5 files changed

+56
-8
lines changed

5 files changed

+56
-8
lines changed

docker-bake.hcl

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ group "e2e" {
4242
targets = [
4343
"gateway_e2e",
4444
"gateway_e2e_openapi-javascript-wiki",
45-
"gateway_e2e_operation-field-permissions"
45+
"gateway_e2e_operation-field-permissions",
46+
"gateway_e2e_distributed-subscriptions-webhooks"
4647
]
4748
}
4849

@@ -114,3 +115,20 @@ target "gateway_e2e_operation-field-permissions_bun" {
114115
"gateway_e2e-bun": "target:gateway_e2e-bun"
115116
}
116117
}
118+
119+
target "gateway_e2e_distributed-subscriptions-webhooks" {
120+
context = "e2e/distributed-subscriptions-webhooks"
121+
dockerfile = "gateway.Dockerfile"
122+
tags = ["ghcr.io/graphql-hive/gateway:e2e.distributed-subscriptions-webhooks"]
123+
contexts = {
124+
"gateway_e2e": "target:gateway_e2e"
125+
}
126+
}
127+
target "gateway_e2e_distributed-subscriptions-webhooks_bun" {
128+
context = "e2e/distributed-subscriptions-webhooks"
129+
dockerfile = "gateway_bun.Dockerfile"
130+
tags = ["ghcr.io/graphql-hive/gateway:e2e.distributed-subscriptions-webhooks-bun"]
131+
contexts = {
132+
"gateway_e2e-bun": "target:gateway_e2e-bun"
133+
}
134+
}

e2e/distributed-subscriptions-webhooks/distributed-subscriptions-webhooks.e2e.ts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1-
import { Container, createTenv, getAvailablePort } from '@internal/e2e';
1+
import fs from 'fs/promises';
2+
import {
3+
Container,
4+
createTenv,
5+
dockerHostName,
6+
getAvailablePort,
7+
handleDockerHostNameInURLOrAtPath,
8+
} from '@internal/e2e';
29
import { fetch } from '@whatwg-node/fetch';
310
import { createClient } from 'graphql-sse';
411
import { beforeAll, expect, it } from 'vitest';
512

6-
const { container, gateway, service, composeWithMesh } = createTenv(__dirname);
13+
const { container, gateway, service, composeWithMesh, gatewayRunner } =
14+
createTenv(__dirname);
715

816
let redis!: Container;
917
beforeAll(async () => {
@@ -33,16 +41,25 @@ it('should receive subscription event on distributed gateway', async () => {
3341
services: [products],
3442
});
3543

44+
if (gatewayRunner.includes('docker')) {
45+
await handleDockerHostNameInURLOrAtPath(supergraph, []);
46+
}
47+
48+
const gwEnv = {
49+
REDIS_HOST: gatewayRunner.includes('docker') ? dockerHostName : '0.0.0.0',
50+
REDIS_PORT: redis.port,
51+
};
52+
3653
const mainGw = await gateway({
3754
port: mainGwPort,
3855
supergraph,
39-
env: { REDIS_PORT: redis.port },
56+
env: gwEnv,
4057
});
4158

4259
const gws = [
4360
mainGw, // main
44-
await gateway({ supergraph, env: { REDIS_PORT: redis.port } }), // replica 1
45-
await gateway({ supergraph, env: { REDIS_PORT: redis.port } }), // replica 2
61+
await gateway({ supergraph, env: gwEnv }), // replica 1
62+
await gateway({ supergraph, env: gwEnv }), // replica 2
4663
];
4764

4865
const clients = gws.map((gw) =>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM gateway_e2e
2+
3+
RUN npm i ioredis

e2e/distributed-subscriptions-webhooks/gateway.config.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,17 @@ import Redis from 'ioredis';
77
* subscriber commands (SUBSCRIBE, UNSUBSCRIBE, etc.). Meaning, it cannot execute other commands like PUBLISH.
88
* To avoid this, we use two separate Redis clients: one for publishing and one for subscribing.
99
*/
10-
const pub = new Redis({ port: parseInt(process.env['REDIS_PORT']!) });
11-
const sub = new Redis({ port: parseInt(process.env['REDIS_PORT']!) });
10+
const pub = new Redis({
11+
host: process.env['REDIS_HOST'],
12+
port: parseInt(process.env['REDIS_PORT']!),
13+
});
14+
const sub = new Redis({
15+
host: process.env['REDIS_HOST'],
16+
port: parseInt(process.env['REDIS_PORT']!),
17+
});
1218

1319
export const gatewayConfig = defineConfig({
20+
maskedErrors: false,
1421
webhooks: true,
1522
pubsub: new RedisPubSub({ pub, sub }),
1623
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM gateway_e2e-bun
2+
3+
RUN bun i ioredis

0 commit comments

Comments
 (0)