99} from "../sdk" ;
1010import { cleanupWorkflowsAndTasks } from "./utils/cleanup" ;
1111import { waitForWorkflowStatus } from "./utils/waitForWorkflowStatus" ;
12- import { describeForOrkesV5 } from "./utils/customJestDescribe" ;
1312
1413describe ( "TaskRunner" , ( ) => {
1514 const clientPromise = orkesConductorClient ( ) ;
@@ -27,87 +26,85 @@ describe("TaskRunner", () => {
2726 ) ;
2827 } ) ;
2928
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 ( ) } ` ;
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 ( ) } ` ;
3634
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- } ,
49- } ,
50- options : {
51- pollInterval : 1000 ,
52- domain : undefined ,
53- concurrency : 2 ,
54- workerID : "" ,
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+ } ;
5546 } ,
56- } ) ;
57- taskRunner . startPolling ( ) ;
47+ } ,
48+ options : {
49+ pollInterval : 1000 ,
50+ domain : undefined ,
51+ concurrency : 2 ,
52+ workerID : "" ,
53+ } ,
54+ } ) ;
55+ taskRunner . startPolling ( ) ;
5856
59- expect ( taskRunner . isPolling ) . toEqual ( true ) ;
57+ expect ( taskRunner . isPolling ) . toEqual ( true ) ;
6058
61- await executor . registerWorkflow ( true , {
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 { workflowId : executionId } = await executor . executeWorkflow (
71+ {
6272 name : workflowName ,
6373 version : 1 ,
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 } ) ;
71-
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 ( ) ;
74+ } ,
75+ workflowName ,
76+ 1 ,
77+ `${ workflowName } -id`
78+ ) ;
79+ expect ( executionId ) . toBeDefined ( ) ;
8280
83- taskRunner . updateOptions ( { concurrency : 1 , pollInterval : 100 } ) ;
81+ taskRunner . updateOptions ( { concurrency : 1 , pollInterval : 100 } ) ;
8482
85- expect ( executionId ) . toBeDefined ( ) ;
86- if ( ! executionId ) {
87- throw new Error ( "Execution ID is undefined" ) ;
88- }
83+ expect ( executionId ) . toBeDefined ( ) ;
84+ if ( ! executionId ) {
85+ throw new Error ( "Execution ID is undefined" ) ;
86+ }
8987
90- const workflowStatus = await waitForWorkflowStatus (
91- executor ,
92- executionId ,
93- "COMPLETED"
94- ) ;
88+ const workflowStatus = await waitForWorkflowStatus (
89+ executor ,
90+ executionId ,
91+ "COMPLETED"
92+ ) ;
9593
96- const [ firstTask ] = workflowStatus . tasks || [ ] ;
97- expect ( firstTask ?. taskType ) . toEqual ( taskName ) ;
98- expect ( workflowStatus . status ) . toEqual ( "COMPLETED" ) ;
94+ const [ firstTask ] = workflowStatus . tasks || [ ] ;
95+ expect ( firstTask ?. taskType ) . toEqual ( taskName ) ;
96+ expect ( workflowStatus . status ) . toEqual ( "COMPLETED" ) ;
9997
100- await taskRunner . stopPolling ( ) ;
98+ await taskRunner . stopPolling ( ) ;
10199
102- expect ( taskRunner . isPolling ) . toEqual ( false ) ;
103- const taskDetails = await executor . getTask ( firstTask ?. taskId || "" ) ;
104- expect ( taskDetails ?. status ) . toEqual ( "COMPLETED" ) ;
100+ expect ( taskRunner . isPolling ) . toEqual ( false ) ;
101+ const taskDetails = await executor . getTask ( firstTask ?. taskId || "" ) ;
102+ expect ( taskDetails ?. status ) . toEqual ( "COMPLETED" ) ;
105103
106- const metadataClient = new OrkesClients ( client ) . getMetadataClient ( ) ;
107- await cleanupWorkflowsAndTasks ( metadataClient , {
108- workflows : [ { name : workflowName , version : 1 } ] ,
109- tasks : [ taskName ] ,
110- } ) ;
111- } , 120000 ) ;
112- } ) ;
104+ const metadataClient = new OrkesClients ( client ) . getMetadataClient ( ) ;
105+ await cleanupWorkflowsAndTasks ( metadataClient , {
106+ workflows : [ { name : workflowName , version : 1 } ] ,
107+ tasks : [ taskName ] ,
108+ } ) ;
109+ } , 120000 ) ;
113110} ) ;
0 commit comments