Skip to content

Commit 709e533

Browse files
committed
test(workflows): improve reliability of workflow execution tests
1 parent f461601 commit 709e533

4 files changed

Lines changed: 29 additions & 16 deletions

File tree

workflows/quickstart/test/executeWorkflow.test.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,11 @@ describe('Cloud Workflows JavaScript Execution Samples', () => {
5151
});
5252
return workflowGet.state === 'ACTIVE';
5353
} catch (e) {
54-
// If there is an error getting the workflow, it probably doesn't exist.
55-
return false;
54+
if (e.code === 5) {
55+
// NOT_FOUND
56+
return false;
57+
}
58+
throw e;
5659
}
5760
}
5861

@@ -89,7 +92,7 @@ describe('Cloud Workflows JavaScript Execution Samples', () => {
8992
it('should execute the workflow using the executeWithoutArguments sample', async () => {
9093
// Execute workflow, with long test timeout
9194
const result = execSync(
92-
`node --require ts-node/register ./executeWithoutArguments.js ${PROJECT_ID} ${LOCATION_ID} ${WORKFLOW_ID}`
95+
`node ./executeWithoutArguments.js ${PROJECT_ID} ${LOCATION_ID} ${WORKFLOW_ID}`
9396
);
9497

9598
assert.ok(
@@ -101,7 +104,7 @@ describe('Cloud Workflows JavaScript Execution Samples', () => {
101104
it('should execute the workflow using the executeWithArguments sample', async () => {
102105
// Execute workflow, with long test timeout
103106
const result = execSync(
104-
`node --require ts-node/register ./executeWithArguments.js ${PROJECT_ID} ${LOCATION_ID} ${WORKFLOW_ID} ${SEARCH_TERM}`
107+
`node ./executeWithArguments.js ${PROJECT_ID} ${LOCATION_ID} ${WORKFLOW_ID} ${SEARCH_TERM}`
105108
);
106109

107110
assert.ok(

workflows/quickstart/test/executeWorkflow.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,13 @@ describe('Cloud Workflows TypeScript Execution Samples', () => {
4646
name: client.workflowPath(PROJECT_ID, LOCATION_ID, WORKFLOW_ID),
4747
});
4848
return workflowGet.state === 'ACTIVE';
49-
} catch {
50-
// If there is an error getting the workflow, it probably doesn't exist.
51-
return false;
49+
} catch (e) {
50+
if ((e as {code?: number})?.code === 5) {
51+
// NOT_FOUND
52+
// If there is an error getting the workflow, it probably doesn't exist.
53+
return false;
54+
}
55+
throw e;
5256
}
5357
}
5458

workflows/quickstart/test/quickstart.test.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ describe('Cloud Workflows JavaScript Quickstart Tests', () => {
5050
});
5151
return workflowGet.state === 'ACTIVE';
5252
} catch (e) {
53-
// If there is an error getting the workflow, it probably doesn't exist.
54-
return false;
53+
if (e.code === 5) {
54+
// NOT_FOUND
55+
return false;
56+
}
57+
throw e;
5558
}
5659
}
5760

@@ -88,9 +91,9 @@ describe('Cloud Workflows JavaScript Quickstart Tests', () => {
8891
it('should execute the quickstart', async () => {
8992
// Execute workflow, with long test timeout
9093
const result = execSync(
91-
`node --require ts-node/register ./index.js ${PROJECT_ID} ${LOCATION_ID} ${WORKFLOW_ID}`
94+
`node ./index.js ${PROJECT_ID} ${LOCATION_ID} ${WORKFLOW_ID}`
9295
);
9396

9497
assert.ok(result.length > 0, 'Quickstart must return non-empty result');
95-
}).timeout(5000);
98+
}).timeout(60000);
9699
});

workflows/quickstart/test/quickstart.test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,12 @@ describe('Cloud Workflows TypeScript Quickstart Tests', () => {
4646
name: client.workflowPath(PROJECT_ID, LOCATION_ID, WORKFLOW_ID),
4747
});
4848
return workflowGet.state === 'ACTIVE';
49-
} catch {
50-
// If there is an error getting the workflow, it probably doesn't exist.
51-
return false;
49+
} catch (e) {
50+
if ((e as {code?: number})?.code === 5) {
51+
// If there is an error getting the workflow, it probably doesn't exist.
52+
return false;
53+
}
54+
throw e;
5255
}
5356
}
5457

@@ -89,7 +92,7 @@ describe('Cloud Workflows TypeScript Quickstart Tests', () => {
8992
);
9093

9194
assert.ok(result.length > 0, 'Quickstart must return non-empty result');
92-
}).timeout(5000);
95+
}).timeout(60000);
9396

9497
it('should execute the quickstart with optional search term', async () => {
9598
// Execute workflow, with long test timeout
@@ -98,5 +101,5 @@ describe('Cloud Workflows TypeScript Quickstart Tests', () => {
98101
);
99102

100103
assert.ok(result.length > 0, 'Quickstart must return non-empty result');
101-
}).timeout(5000);
104+
}).timeout(60000);
102105
});

0 commit comments

Comments
 (0)