Skip to content

Commit a057aa8

Browse files
committed
Remove tests using Client backed by native connection
1 parent 543ca38 commit a057aa8

File tree

2 files changed

+14
-87
lines changed

2 files changed

+14
-87
lines changed

packages/test/src/test-native-connection-headers.ts

Lines changed: 2 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import util from 'node:util';
2-
import path from 'node:path';
3-
import assert from 'node:assert';
1+
import * as util from 'node:util';
2+
import * as path from 'node:path';
43
import test from 'ava';
54
import { Subject, firstValueFrom, skip } from 'rxjs';
65
import * as grpc from '@grpc/grpc-js';
@@ -9,19 +8,6 @@ import { NativeConnection } from '@temporalio/worker';
98
import { temporal } from '@temporalio/proto';
109
import { Worker } from './helpers';
1110

12-
const workflowServicePackageDefinition = protoLoader.loadSync(
13-
path.resolve(
14-
__dirname,
15-
'../../core-bridge/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/service.proto'
16-
),
17-
{ includeDirs: [path.resolve(__dirname, '../../core-bridge/sdk-core/sdk-core-protos/protos/api_upstream')] }
18-
);
19-
const workflowServiceProtoDescriptor = grpc.loadPackageDefinition(workflowServicePackageDefinition) as any;
20-
21-
async function bindLocalhost(server: grpc.Server): Promise<number> {
22-
return await util.promisify(server.bindAsync.bind(server))('127.0.0.1:0', grpc.ServerCredentials.createInsecure());
23-
}
24-
2511
test('NativeConnection passes headers provided in options', async (t) => {
2612
const packageDefinition = protoLoader.loadSync(
2713
path.resolve(
@@ -103,44 +89,3 @@ test('NativeConnection passes headers provided in options', async (t) => {
10389
});
10490
await Promise.all([firstValueFrom(newValuesSubject.pipe(skip(1))).then(() => worker.shutdown()), worker.run()]);
10591
});
106-
107-
test('apiKey sets temporal-namespace header appropriately', async (t) => {
108-
let getSystemInfoHeaders: grpc.Metadata = new grpc.Metadata();
109-
let startWorkflowExecutionHeaders: grpc.Metadata = new grpc.Metadata();
110-
111-
const server = new grpc.Server();
112-
server.addService(workflowServiceProtoDescriptor.temporal.api.workflowservice.v1.WorkflowService.service, {
113-
getSystemInfo(
114-
call: grpc.ServerUnaryCall<
115-
temporal.api.workflowservice.v1.IGetSystemInfoRequest,
116-
temporal.api.workflowservice.v1.IGetSystemInfoResponse
117-
>,
118-
callback: grpc.sendUnaryData<temporal.api.workflowservice.v1.IGetSystemInfoResponse>
119-
) {
120-
getSystemInfoHeaders = call.metadata.clone();
121-
callback(null, {});
122-
},
123-
startWorkflowExecution(call: grpc.ServerUnaryCall<any, any>, callback: grpc.sendUnaryData<any>) {
124-
startWorkflowExecutionHeaders = call.metadata.clone();
125-
callback(null, {});
126-
},
127-
});
128-
const port = await bindLocalhost(server);
129-
const conn = await NativeConnection.connect({
130-
address: `127.0.0.1:${port}`,
131-
metadata: { staticKey: 'set' },
132-
apiKey: 'test-token',
133-
});
134-
135-
await conn.workflowService.startWorkflowExecution({ namespace: 'test-namespace' });
136-
137-
assert(getSystemInfoHeaders !== undefined);
138-
t.deepEqual(getSystemInfoHeaders.get('temporal-namespace'), []);
139-
t.deepEqual(getSystemInfoHeaders.get('authorization'), ['Bearer test-token']);
140-
t.deepEqual(getSystemInfoHeaders.get('staticKey'), ['set']);
141-
142-
assert(startWorkflowExecutionHeaders);
143-
t.deepEqual(startWorkflowExecutionHeaders.get('temporal-namespace'), ['test-namespace']);
144-
t.deepEqual(startWorkflowExecutionHeaders.get('authorization'), ['Bearer test-token']);
145-
t.deepEqual(startWorkflowExecutionHeaders.get('staticKey'), ['set']);
146-
});

packages/test/src/test-temporal-cloud.ts

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ test('Can connect to Temporal Cloud using mTLS', async (t) => {
3636
},
3737
},
3838
});
39-
const nativeClient = new Client({ connection: nativeConnection, namespace });
40-
4139
const taskQueue = `test-temporal-cloud-mtls-${randomUUID()}`;
4240
const worker = await Worker.create({
4341
namespace,
@@ -46,21 +44,14 @@ test('Can connect to Temporal Cloud using mTLS', async (t) => {
4644
taskQueue,
4745
});
4846

49-
const [res1, res2] = await worker.runUntil(async () => {
50-
return Promise.all([
51-
client.workflow.execute(workflows.successString, {
52-
workflowId: randomUUID(),
53-
taskQueue,
54-
}),
55-
nativeClient.workflow.execute(workflows.successString, {
56-
workflowId: randomUUID(),
57-
taskQueue,
58-
}),
59-
]);
47+
const res = await worker.runUntil(async () => {
48+
return await client.workflow.execute(workflows.successString, {
49+
workflowId: randomUUID(),
50+
taskQueue,
51+
});
6052
});
6153

62-
t.is(res1, 'success');
63-
t.is(res2, 'success');
54+
t.is(res, 'success');
6455
});
6556

6657
test('Can connect to Temporal Cloud using API Keys', async (t) => {
@@ -85,8 +76,6 @@ test('Can connect to Temporal Cloud using API Keys', async (t) => {
8576
apiKey,
8677
tls: true,
8778
});
88-
const nativeClient = new Client({ connection: nativeConnection, namespace });
89-
9079
const taskQueue = `test-temporal-cloud-api-key-${randomUUID()}`;
9180
const worker = await Worker.create({
9281
namespace,
@@ -95,21 +84,14 @@ test('Can connect to Temporal Cloud using API Keys', async (t) => {
9584
taskQueue,
9685
});
9786

98-
const [res1, res2] = await worker.runUntil(async () => {
99-
return Promise.all([
100-
client.workflow.execute(workflows.successString, {
101-
workflowId: randomUUID(),
102-
taskQueue,
103-
}),
104-
nativeClient.workflow.execute(workflows.successString, {
105-
workflowId: randomUUID(),
106-
taskQueue,
107-
}),
108-
]);
87+
const res = await worker.runUntil(async () => {
88+
return await client.workflow.execute(workflows.successString, {
89+
workflowId: randomUUID(),
90+
taskQueue,
91+
});
10992
});
11093

111-
t.is(res1, 'success');
112-
t.is(res2, 'success');
94+
t.is(res, 'success');
11395
});
11496

11597
test('Can create connection to Temporal Cloud Operation service', async (t) => {

0 commit comments

Comments
 (0)