Skip to content

Commit 5bbed6c

Browse files
separate common and v5 only tests
1 parent f45bc55 commit 5bbed6c

17 files changed

Lines changed: 203 additions & 201 deletions

integration-tests/EventResourceService.test.ts renamed to integration-tests/common/EventResourceService.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect, describe, test } from "@jest/globals";
2-
import { orkesConductorClient } from "../src/orkes";
2+
import { orkesConductorClient } from "../../src/orkes";
33

44
describe("EventResourceService", () => {
55
test("Should create an event handler with description and tags and then delete it", async () => {

integration-tests/MetadataClient.test.ts renamed to integration-tests/common/MetadataClient.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect, describe, test, jest } from "@jest/globals";
2-
import { MetadataClient } from "../src/core/metadataClient";
3-
import { taskDefinition } from "../src/core/sdk";
4-
import { orkesConductorClient } from "../src/orkes";
2+
import { MetadataClient } from "../../src/core/metadataClient";
3+
import { taskDefinition } from "../../src/core/sdk";
4+
import { orkesConductorClient } from "../../src/orkes";
55

66
describe("MetadataClient", () => {
77
const clientPromise = orkesConductorClient();

integration-tests/TaskManager.test.ts renamed to integration-tests/common/TaskManager.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { expect, describe, test, jest } from "@jest/globals";
2-
import { simpleTask, taskDefinition, WorkflowExecutor } from "../src/core";
3-
import { orkesConductorClient } from "../src/orkes";
4-
import { TaskManager, ConductorWorker } from "../src/task/index";
5-
import { mockLogger } from "./utils/mockLogger";
6-
import { TestUtil } from "./utils/test-util";
2+
import { simpleTask, taskDefinition, WorkflowExecutor } from "../../src/core";
3+
import { orkesConductorClient } from "../../src/orkes";
4+
import { TaskManager, ConductorWorker } from "../../src/task/index";
5+
import { mockLogger } from "../utils/mockLogger";
6+
import { TestUtil } from "../utils/test-util";
77

88

99
const BASE_TIME = 500;

integration-tests/TaskRunnerIntTest.test.ts renamed to integration-tests/common/TaskRunnerIntTest.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect, describe, test, jest } from "@jest/globals";
2-
import { TaskRunner } from "../src/task/TaskRunner";
3-
import { WorkflowExecutor, simpleTask } from "../src/core";
4-
import { orkesConductorClient } from "../src/orkes";
2+
import { TaskRunner } from "../../src/task/TaskRunner";
3+
import { WorkflowExecutor, simpleTask } from "../../src/core";
4+
import { orkesConductorClient } from "../../src/orkes";
55

66
describe("TaskManager", () => {
77
const clientPromise = orkesConductorClient();

integration-tests/WorkflowResourceService.test.ts renamed to integration-tests/common/WorkflowResourceService.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { expect, describe, test, jest } from "@jest/globals";
2-
import { MetadataClient } from "../src/core";
3-
import { simpleTask, workflow } from "../src/core/sdk";
4-
import { orkesConductorClient } from "../src/orkes";
5-
import { TaskDefTypes } from "../src/common/types";
2+
import { MetadataClient } from "../../src/core";
3+
import { simpleTask, workflow } from "../../src/core/sdk";
4+
import { orkesConductorClient } from "../../src/orkes";
5+
import { TaskDefTypes } from "../../src/common/types";
66

77
describe("WorkflowResourceService", () => {
88
jest.setTimeout(120000);
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
import {expect, describe, test, jest} from "@jest/globals";
2+
import { SetVariableTaskDef, TaskType, WorkflowDef} from "../../src/common";
3+
import { orkesConductorClient } from "../../src/orkes";
4+
import { WorkflowExecutor } from "../../src/core/executor";
5+
import { v4 as uuidv4 } from "uuid";
6+
import {TestUtil} from "../utils/test-util";
7+
import { httpTask } from "../../src/core/sdk";
8+
import { TaskClient } from "../../src/core/taskClient";
9+
10+
describe("Executor", () => {
11+
const clientPromise = orkesConductorClient();
12+
13+
jest.setTimeout(15000);
14+
const name = `testWorkflow-${Date.now()}`;
15+
const version = 1;
16+
test("Should be able to register a workflow", async () => {
17+
const client = await clientPromise;
18+
const executor = new WorkflowExecutor(client);
19+
20+
const workflowDefinition: WorkflowDef = {
21+
name,
22+
version,
23+
tasks: [
24+
{
25+
type: TaskType.SET_VARIABLE,
26+
name: "setVariable",
27+
taskReferenceName: "httpTaskRef",
28+
inputParameters: {
29+
hello: "world",
30+
},
31+
},
32+
],
33+
inputParameters: [],
34+
timeoutSeconds: 15,
35+
};
36+
37+
await expect(
38+
executor.registerWorkflow(true, workflowDefinition)
39+
).resolves.not.toThrow();
40+
const workflowDefinitionFromApi = await client.metadataResource.get(
41+
name,
42+
version
43+
);
44+
expect(workflowDefinitionFromApi.name).toEqual(name);
45+
expect(workflowDefinitionFromApi.version).toEqual(version);
46+
expect(workflowDefinitionFromApi.tasks[0].name).toEqual(
47+
workflowDefinition.tasks[0].name
48+
);
49+
expect(workflowDefinitionFromApi.tasks[0].taskReferenceName).toEqual(
50+
workflowDefinition.tasks[0].taskReferenceName
51+
);
52+
expect(workflowDefinitionFromApi.tasks[0].inputParameters).toEqual(
53+
(workflowDefinition.tasks[0] as SetVariableTaskDef).inputParameters
54+
);
55+
});
56+
57+
let executionId: string | undefined = undefined;
58+
test("Should be able to start a workflow", async () => {
59+
const client = await clientPromise;
60+
const executor = new WorkflowExecutor(client);
61+
executionId = await executor.startWorkflow({ name, version });
62+
expect(executionId).toBeTruthy();
63+
});
64+
65+
test("Should be able to execute workflow synchronously", async () => {
66+
const client = await clientPromise;
67+
const executor = new WorkflowExecutor(client);
68+
const workflowRun = await executor.executeWorkflow(
69+
{
70+
name: name,
71+
version: version,
72+
},
73+
name,
74+
version,
75+
uuidv4()
76+
);
77+
expect(workflowRun.status).toEqual("COMPLETED");
78+
});
79+
80+
test("Should be able to get workflow execution status ", async () => {
81+
const client = await clientPromise;
82+
const executor = new WorkflowExecutor(client);
83+
const workflowStatus = await executor.getWorkflowStatus(
84+
executionId!,
85+
true,
86+
true
87+
);
88+
expect(workflowStatus.status).toBeTruthy();
89+
});
90+
91+
test("Should return workflow status detail", async () => {
92+
const client = await clientPromise;
93+
const executor = new WorkflowExecutor(client);
94+
const workflowStatus = await executor.getWorkflow(executionId!, true);
95+
96+
expect(workflowStatus.status).toBeTruthy();
97+
expect(workflowStatus.tasks?.length).toBe(1);
98+
});
99+
test("Should execute a workflow with indempotency key", async () => {
100+
const client = await clientPromise;
101+
const executor = new WorkflowExecutor(client);
102+
const idempotencyKey = uuidv4();
103+
const executionId = await executor.startWorkflow({
104+
name: name,
105+
version: version,
106+
idempotencyKey,
107+
idempotencyStrategy: "RETURN_EXISTING",
108+
});
109+
110+
const executionDetails = await executor.getWorkflow(executionId!, true);
111+
expect(executionDetails.idempotencyKey).toEqual(idempotencyKey);
112+
});
113+
114+
test("Should run workflow with http task with asyncComplete true", async () => {
115+
const client = await clientPromise;
116+
const executor = new WorkflowExecutor(client);
117+
118+
await executor.registerWorkflow(true, {
119+
name: "test_jssdk_workflow_with_http_task_with_asyncComplete_true",
120+
version: 1,
121+
ownerEmail: "developers@orkes.io",
122+
tasks: [httpTask("test_jssdk_http_task_with_asyncComplete_true", { uri: "http://www.yahoo.com", method: "GET" }, true)],
123+
inputParameters: [],
124+
outputParameters: {},
125+
timeoutSeconds: 300,
126+
});
127+
128+
const executionId = await executor.startWorkflow({
129+
name: "test_jssdk_workflow_with_http_task_with_asyncComplete_true",
130+
input: {},
131+
version: 1,
132+
});
133+
134+
const workflowStatusBefore = await TestUtil.waitForWorkflowStatus(executor, executionId, "RUNNING");
135+
136+
expect(["IN_PROGRESS", "SCHEDULED"]).toContain(workflowStatusBefore.tasks?.[0]?.status);
137+
138+
const taskClient = new TaskClient(client);
139+
taskClient.updateTaskResult(executionId, "test_jssdk_http_task_with_asyncComplete_true", "COMPLETED", { hello: "From manuall api call updating task result" });
140+
141+
const workflowStatusAfter = await TestUtil.waitForWorkflowStatus(executor, executionId, "COMPLETED");
142+
143+
expect(workflowStatusAfter.tasks?.[0]?.status).toEqual("COMPLETED");
144+
});
145+
146+
test("Should run workflow with an optional http task", async () => {
147+
const executor = new WorkflowExecutor(await clientPromise);
148+
149+
await executor.registerWorkflow(true, {
150+
name: "test_jssdk_workflow_with_optional_http_task",
151+
version: 1,
152+
ownerEmail: "developers@orkes.io",
153+
tasks: [httpTask("test_jssdk_optional_http_task", { uri: "uncorrect_uri", method: "GET" }, false, true)],
154+
inputParameters: [],
155+
outputParameters: {},
156+
timeoutSeconds: 300,
157+
});
158+
159+
const executionId = await executor.startWorkflow({
160+
name: "test_jssdk_workflow_with_optional_http_task",
161+
input: {},
162+
version: 1,
163+
});
164+
165+
const workflowStatus = await TestUtil.waitForWorkflowStatus(executor, executionId, "COMPLETED");
166+
expect(["FAILED", "COMPLETED_WITH_ERRORS"]).toContain(workflowStatus.tasks?.[0]?.status);
167+
});
168+
});

integration-tests/utils/metadata/complex_wf_signal_test.json renamed to integration-tests/common/metadata/complex_wf_signal_test.json

File renamed without changes.

integration-tests/utils/metadata/complex_wf_signal_test_subworkflow_1.json renamed to integration-tests/common/metadata/complex_wf_signal_test_subworkflow_1.json

File renamed without changes.

integration-tests/utils/metadata/complex_wf_signal_test_subworkflow_2.json renamed to integration-tests/common/metadata/complex_wf_signal_test_subworkflow_2.json

File renamed without changes.

integration-tests/utils/metadata/wait_signal_test.json renamed to integration-tests/common/metadata/wait_signal_test.json

File renamed without changes.

0 commit comments

Comments
 (0)