Skip to content

Commit cd1f1a4

Browse files
committed
Update tests to be v5 only as they are using the v5 endpoint POST /api/tasks/update-v2
1 parent c116441 commit cd1f1a4

2 files changed

Lines changed: 135 additions & 129 deletions

File tree

src/integration-tests/TaskRunner.test.ts

Lines changed: 71 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
} from "../sdk";
1010
import { cleanupWorkflowsAndTasks } from "./utils/cleanup";
1111
import { waitForWorkflowStatus } from "./utils/waitForWorkflowStatus";
12+
import { describeForOrkesV5 } from "./utils/customJestDescribe";
1213

1314
describe("TaskRunner", () => {
1415
const clientPromise = orkesConductorClient();
@@ -26,85 +27,87 @@ describe("TaskRunner", () => {
2627
);
2728
});
2829

29-
test("worker example ", async () => {
30-
const client = await clientPromise;
31-
const executor = new WorkflowExecutor(client);
32-
const taskName = `jsSdkTest-task-manager-int-test-${Date.now()}`;
33-
const workflowName = `jsSdkTest-task-manager-int-test-wf-${Date.now()}`;
30+
describeForOrkesV5("worker example (requires update-v2)", () => {
31+
test("worker example ", async () => {
32+
const client = await clientPromise;
33+
const executor = new WorkflowExecutor(client);
34+
const taskName = `jsSdkTest-task-manager-int-test-${Date.now()}`;
35+
const workflowName = `jsSdkTest-task-manager-int-test-wf-${Date.now()}`;
3436

35-
const taskRunner = new TaskRunner({
36-
client: client,
37-
worker: {
38-
taskDefName: taskName,
39-
execute: async () => {
40-
return {
41-
outputData: {
42-
hello: "From your worker",
43-
},
44-
status: "COMPLETED",
45-
};
37+
const taskRunner = new TaskRunner({
38+
client: client,
39+
worker: {
40+
taskDefName: taskName,
41+
execute: async () => {
42+
return {
43+
outputData: {
44+
hello: "From your worker",
45+
},
46+
status: "COMPLETED",
47+
};
48+
},
4649
},
47-
},
48-
options: {
49-
pollInterval: 1000,
50-
domain: undefined,
51-
concurrency: 2,
52-
workerID: "",
53-
},
54-
});
55-
taskRunner.startPolling();
56-
57-
expect(taskRunner.isPolling).toEqual(true);
50+
options: {
51+
pollInterval: 1000,
52+
domain: undefined,
53+
concurrency: 2,
54+
workerID: "",
55+
},
56+
});
57+
taskRunner.startPolling();
5858

59-
await executor.registerWorkflow(true, {
60-
name: workflowName,
61-
version: 1,
62-
ownerEmail: "developers@orkes.io",
63-
tasks: [simpleTask(taskName, taskName, {})],
64-
inputParameters: [],
65-
outputParameters: {},
66-
timeoutSeconds: 0,
67-
});
68-
workflowsToCleanup.push({ name: workflowName, version: 1 });
59+
expect(taskRunner.isPolling).toEqual(true);
6960

70-
const { workflowId: executionId } = await executor.executeWorkflow(
71-
{
61+
await executor.registerWorkflow(true, {
7262
name: workflowName,
7363
version: 1,
74-
},
75-
workflowName,
76-
1,
77-
`${workflowName}-id`
78-
);
79-
expect(executionId).toBeDefined();
64+
ownerEmail: "developers@orkes.io",
65+
tasks: [simpleTask(taskName, taskName, {})],
66+
inputParameters: [],
67+
outputParameters: {},
68+
timeoutSeconds: 0,
69+
});
70+
workflowsToCleanup.push({ name: workflowName, version: 1 });
8071

81-
taskRunner.updateOptions({ concurrency: 1, pollInterval: 100 });
72+
const { workflowId: executionId } = await executor.executeWorkflow(
73+
{
74+
name: workflowName,
75+
version: 1,
76+
},
77+
workflowName,
78+
1,
79+
`${workflowName}-id`
80+
);
81+
expect(executionId).toBeDefined();
8282

83-
expect(executionId).toBeDefined();
84-
if (!executionId) {
85-
throw new Error("Execution ID is undefined");
86-
}
83+
taskRunner.updateOptions({ concurrency: 1, pollInterval: 100 });
8784

88-
const workflowStatus = await waitForWorkflowStatus(
89-
executor,
90-
executionId,
91-
"COMPLETED"
92-
);
85+
expect(executionId).toBeDefined();
86+
if (!executionId) {
87+
throw new Error("Execution ID is undefined");
88+
}
9389

94-
const [firstTask] = workflowStatus.tasks || [];
95-
expect(firstTask?.taskType).toEqual(taskName);
96-
expect(workflowStatus.status).toEqual("COMPLETED");
90+
const workflowStatus = await waitForWorkflowStatus(
91+
executor,
92+
executionId,
93+
"COMPLETED"
94+
);
9795

98-
await taskRunner.stopPolling();
96+
const [firstTask] = workflowStatus.tasks || [];
97+
expect(firstTask?.taskType).toEqual(taskName);
98+
expect(workflowStatus.status).toEqual("COMPLETED");
9999

100-
expect(taskRunner.isPolling).toEqual(false);
101-
const taskDetails = await executor.getTask(firstTask?.taskId || "");
102-
expect(taskDetails?.status).toEqual("COMPLETED");
100+
await taskRunner.stopPolling();
103101

104-
const metadataClient = new OrkesClients(client).getMetadataClient();
105-
await cleanupWorkflowsAndTasks(metadataClient, {
106-
workflows: [{ name: workflowName, version: 1 }],
107-
tasks: [taskName],
108-
});
109-
}, 120000);
102+
expect(taskRunner.isPolling).toEqual(false);
103+
const taskDetails = await executor.getTask(firstTask?.taskId || "");
104+
expect(taskDetails?.status).toEqual("COMPLETED");
105+
106+
const metadataClient = new OrkesClients(client).getMetadataClient();
107+
await cleanupWorkflowsAndTasks(metadataClient, {
108+
workflows: [{ name: workflowName, version: 1 }],
109+
tasks: [taskName],
110+
});
111+
}, 120000);
112+
});
110113
});

src/integration-tests/readme.test.ts

Lines changed: 64 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
} from "../sdk";
1010
import { TaskType } from "../open-api";
1111
import { waitForWorkflowStatus } from "./utils/waitForWorkflowStatus";
12+
import { describeForOrkesV5 } from "./utils/customJestDescribe";
1213

1314
describe("TaskManager", () => {
1415
const clientPromise = orkesConductorClient();
@@ -26,69 +27,71 @@ describe("TaskManager", () => {
2627
);
2728
});
2829

29-
test("worker example ", async () => {
30-
const client = await clientPromise;
31-
const executor = new WorkflowExecutor(client);
32-
const workflowName = `jsSdkTest-my_first_js_wf-${Date.now()}`;
33-
const taskName = `jsSdkTest-taskmanager-test-${Date.now()}`;
34-
35-
const taskRunner = new TaskRunner({
36-
client: client,
37-
worker: {
38-
taskDefName: taskName,
39-
execute: async () => {
40-
return {
41-
outputData: {
42-
hello: "From your worker",
43-
},
44-
status: "COMPLETED",
45-
};
30+
describeForOrkesV5("worker example (requires update-v2)", () => {
31+
test("worker example ", async () => {
32+
const client = await clientPromise;
33+
const executor = new WorkflowExecutor(client);
34+
const workflowName = `jsSdkTest-my_first_js_wf-${Date.now()}`;
35+
const taskName = `jsSdkTest-taskmanager-test-${Date.now()}`;
36+
37+
const taskRunner = new TaskRunner({
38+
client: client,
39+
worker: {
40+
taskDefName: taskName,
41+
execute: async () => {
42+
return {
43+
outputData: {
44+
hello: "From your worker",
45+
},
46+
status: "COMPLETED",
47+
};
48+
},
4649
},
47-
},
48-
options: {
49-
pollInterval: 10,
50-
domain: undefined,
51-
concurrency: 1,
52-
workerID: "",
53-
},
54-
});
55-
taskRunner.startPolling();
56-
57-
await executor.registerWorkflow(true, {
58-
name: workflowName,
59-
version: 1,
60-
ownerEmail: "developers@orkes.io",
61-
tasks: [simpleTask(taskName, taskName, {})],
62-
inputParameters: [],
63-
outputParameters: {},
64-
timeoutSeconds: 0,
65-
});
66-
workflowsToCleanup.push({ name: workflowName, version: 1 });
67-
68-
const executionId = await executor.startWorkflow({
69-
name: workflowName,
70-
input: {},
71-
version: 1,
72-
});
73-
74-
if (!executionId) {
75-
throw new Error("Execution ID is undefined");
76-
}
77-
78-
const workflowStatus = await waitForWorkflowStatus(
79-
executor,
80-
executionId,
81-
"COMPLETED"
82-
);
83-
84-
const [firstTask] = workflowStatus.tasks || [];
85-
expect(firstTask?.taskType).toEqual(taskName);
86-
expect(workflowStatus.status).toEqual("COMPLETED");
50+
options: {
51+
pollInterval: 10,
52+
domain: undefined,
53+
concurrency: 1,
54+
workerID: "",
55+
},
56+
});
57+
taskRunner.startPolling();
8758

88-
taskRunner.stopPolling();
89-
const taskDetails = await executor.getTask(firstTask?.taskId || "");
90-
expect(taskDetails?.status).toEqual("COMPLETED");
91-
}, 120000);
59+
await executor.registerWorkflow(true, {
60+
name: workflowName,
61+
version: 1,
62+
ownerEmail: "developers@orkes.io",
63+
tasks: [simpleTask(taskName, taskName, {})],
64+
inputParameters: [],
65+
outputParameters: {},
66+
timeoutSeconds: 0,
67+
});
68+
workflowsToCleanup.push({ name: workflowName, version: 1 });
69+
70+
const executionId = await executor.startWorkflow({
71+
name: workflowName,
72+
input: {},
73+
version: 1,
74+
});
75+
76+
if (!executionId) {
77+
throw new Error("Execution ID is undefined");
78+
}
79+
80+
const workflowStatus = await waitForWorkflowStatus(
81+
executor,
82+
executionId,
83+
"COMPLETED"
84+
);
85+
86+
const [firstTask] = workflowStatus.tasks || [];
87+
expect(firstTask?.taskType).toEqual(taskName);
88+
expect(workflowStatus.status).toEqual("COMPLETED");
89+
90+
taskRunner.stopPolling();
91+
const taskDetails = await executor.getTask(firstTask?.taskId || "");
92+
expect(taskDetails?.status).toEqual("COMPLETED");
93+
}, 120000);
94+
});
9295

9396
test("update task example ", async () => {
9497
const client = await clientPromise;

0 commit comments

Comments
 (0)