Skip to content

Commit 89d7b4c

Browse files
committed
Review changes, fixed failing integration test.
1 parent defc1ad commit 89d7b4c

File tree

4 files changed

+30
-20
lines changed

4 files changed

+30
-20
lines changed

packages/client/src/helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export async function executionInfoFromRaw<T>(
8989
};
9090
}
9191

92-
export function countWorkflowExecutionFromRaw(raw: RawCountWorkflowExecutions): CountWorkflowExecution {
92+
export function decodeCountWorkflowExecutionsResponse(raw: RawCountWorkflowExecutions): CountWorkflowExecution {
9393
return {
9494
// Note: lossy conversion of Long to number
9595
count: raw.count!.toNumber(),
@@ -103,7 +103,7 @@ export function executionCountAggregationGroupFromRaw(
103103
return {
104104
// Note: lossy conversion of Long to number
105105
count: raw.count!.toNumber(),
106-
group_values: raw.groupValues!.map((group_value) => searchAttributePayloadConverter.fromPayload(group_value)),
106+
groupValues: raw.groupValues!.map((group_value) => searchAttributePayloadConverter.fromPayload(group_value)),
107107
};
108108
}
109109

packages/client/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export interface CountWorkflowExecution {
6262

6363
export interface CountWorkflowExecutionsAggregationGroup {
6464
count: number;
65-
group_values: SearchAttributeValue[];
65+
groupValues: SearchAttributeValue[];
6666
}
6767

6868
export type WorkflowExecutionDescription = Replace<

packages/client/src/workflow-client.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ import {
7878
WorkflowStartOptions,
7979
WorkflowUpdateOptions,
8080
} from './workflow-options';
81-
import { countWorkflowExecutionFromRaw, executionInfoFromRaw, rethrowKnownErrorTypes } from './helpers';
81+
import { decodeCountWorkflowExecutionsResponse, executionInfoFromRaw, rethrowKnownErrorTypes } from './helpers';
8282
import {
8383
BaseClient,
8484
BaseClientOptions,
@@ -1325,10 +1325,10 @@ export class WorkflowClient extends BaseClient {
13251325
query,
13261326
});
13271327
} catch (e) {
1328-
this.rethrowGrpcError(e, 'Failed to count workflows', undefined);
1328+
this.rethrowGrpcError(e, 'Failed to count workflows');
13291329
}
13301330

1331-
return countWorkflowExecutionFromRaw(response);
1331+
return decodeCountWorkflowExecutionsResponse(response);
13321332
}
13331333

13341334
protected getOrMakeInterceptors(workflowId: string, runId?: string): WorkflowClientInterceptor[] {

packages/test/src/test-integration-workflows.ts

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import { activityStartedSignal } from './workflows/definitions';
1515
import * as workflows from './workflows';
1616
import { Context, helpers, makeTestFunction } from './helpers-integration';
1717
import { overrideSdkInternalFlag } from './mock-internal-flags';
18-
import { asSdkLoggerSink, loadHistory, RUN_TIME_SKIPPING_TESTS } from './helpers';
18+
import { asSdkLoggerSink, loadHistory, RUN_TIME_SKIPPING_TESTS, waitUntil } from './helpers';
19+
import asyncRetry from 'async-retry';
1920

2021
const test = makeTestFunction({
2122
workflowsPath: __filename,
@@ -1274,27 +1275,36 @@ test('Count workflow executions', async (t) => {
12741275
const worker = await createWorker();
12751276
const client = t.context.env.client;
12761277

1277-
await worker.runUntil(async () => {
1278-
// Run 3 workflows that complete.
1279-
for (let i = 0; i < 3; i++) {
1280-
await executeWorkflow(completableWorkflow, { args: [true] });
1281-
}
1282-
});
1283-
12841278
// Run 2 workflows that don't complete
12851279
// (use startWorkflow to avoid waiting for workflows to complete, which they never will)
12861280
for (let i = 0; i < 2; i++) {
12871281
await startWorkflow(completableWorkflow, { args: [false] });
12881282
}
12891283

1290-
const actual = await client.workflow.count(`TaskQueue = '${taskQueue}' GROUP BY ExecutionStatus`);
1291-
const expected: CountWorkflowExecution = {
1284+
await worker.runUntil(async () => {
1285+
try {
1286+
// Run 3 workflows that complete.
1287+
await Promise.all([
1288+
executeWorkflow(completableWorkflow, { args: [true] }),
1289+
executeWorkflow(completableWorkflow, { args: [true] }),
1290+
executeWorkflow(completableWorkflow, { args: [true] })
1291+
])
1292+
} catch (err) {
1293+
throw new Error('executing workflow unexpectedly failed')
1294+
};
1295+
});
1296+
1297+
const actualTotal = await client.workflow.count(`TaskQueue = '${taskQueue}'`);
1298+
t.deepEqual(actualTotal, { count: 5, groups: [] });
1299+
1300+
const expectedByExecutionStatus: CountWorkflowExecution = {
12921301
count: 5,
12931302
groups: [
1294-
{ count: 2, group_values: [['Runningggg']] },
1295-
{ count: 3, group_values: [['Completedddd']] },
1303+
{ count: 2, groupValues: [['Running']] },
1304+
{ count: 3, groupValues: [['Completed']] },
12961305
],
12971306
};
1298-
1299-
t.deepEqual(expected, actual);
1307+
1308+
const actualByExecutionStatus = await client.workflow.count(`TaskQueue = '${taskQueue}' GROUP BY ExecutionStatus`);
1309+
t.deepEqual(actualByExecutionStatus, expectedByExecutionStatus);
13001310
});

0 commit comments

Comments
 (0)