Skip to content

Commit 8a9f8f9

Browse files
trying to sort out inscrutible and inexplicable issues. without a whole lot of luck
1 parent f4b7c63 commit 8a9f8f9

1 file changed

Lines changed: 36 additions & 14 deletions

File tree

src/integration-tests/WorkflowExecutor.test.ts

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import { HTTPBIN_BASE_URL } from "./utils/testConstants";
3737
describe("WorkflowExecutor", () => {
3838
const clientPromise = createClientWithRetry();
3939

40-
jest.setTimeout(120000);
40+
jest.setTimeout(60000);
4141

4242
const name = `jsSdkTest-Workflow-${Date.now()}`;
4343
const version = 1;
@@ -175,20 +175,28 @@ describe("WorkflowExecutor", () => {
175175
const workflowName = `jsSdkTest-wf_with_asyncComplete_http_task-${Date.now()}`;
176176
const taskName = `jsSdkTest-http_task_with_asyncComplete_true-${Date.now()}`;
177177

178+
// v5 uses the internal httpbin service. For v4 we fall back to a public URL
179+
// (http://www.yahoo.com).
180+
// NOTE: httpbin-server IS now deployed in the v4 test cluster, but the HTTP
181+
// task inexplicably cannot talk to it there - the task stays SCHEDULED and
182+
// never reaches IN_PROGRESS, even though `curl`-ing the same URL from inside
183+
// the worker pod succeeds and the SSRF blocklist logs nothing. Requires
184+
// further investigation; until then v4 keeps using the public URL.
185+
const asyncHttpUri =
186+
Number(process.env.ORKES_BACKEND_VERSION) >= 5
187+
? `${HTTPBIN_BASE_URL}/api/hello?name=test1`
188+
: "http://www.yahoo.com";
189+
178190
await executor.registerWorkflow(true, {
179191
name: workflowName,
180192
version: 1,
181193
ownerEmail: "developers@orkes.io",
182194
tasks: [
183-
httpTask(
184-
taskName,
185-
{ uri: `${HTTPBIN_BASE_URL}/api/hello?name=test1`, method: "GET" },
186-
true
187-
),
195+
httpTask(taskName, { uri: asyncHttpUri, method: "GET" }, true),
188196
],
189197
inputParameters: [],
190198
outputParameters: {},
191-
timeoutSeconds: 300,
199+
timeoutSeconds: 30,
192200
});
193201

194202
const executionId = await executor.startWorkflow({
@@ -201,19 +209,33 @@ describe("WorkflowExecutor", () => {
201209
throw new Error("Execution ID is undefined");
202210
}
203211

212+
// Log the id so a failed/incomplete run can be inspected in the Conductor UI.
213+
console.log(
214+
`[asyncComplete http] workflowId=${executionId} workflow=${workflowName} task=${taskName}`
215+
);
216+
204217
await waitForWorkflowStatus(executor, executionId, "RUNNING");
205218

206219
// Wait for the task to be IN_PROGRESS before updating (V4 may take longer; server requires "running" task)
207-
const taskReadyTimeout = 90000;
208-
const pollInterval = 1000;
220+
const taskReadyTimeout = 30000;
221+
const pollInterval = 3000;
209222
const taskReadyStart = Date.now();
210223
let taskStatus: string | undefined;
211224
while (Date.now() - taskReadyStart < taskReadyTimeout) {
212225
const wf = await executor.getWorkflow(executionId, true);
213226
taskStatus = wf?.tasks?.[0]?.status;
214227
if (taskStatus === "IN_PROGRESS") break;
215-
if (taskStatus === "FAILED" || taskStatus === "COMPLETED")
216-
throw new Error(`Task ended in unexpected state: ${taskStatus}`);
228+
if (taskStatus === "FAILED" || taskStatus === "COMPLETED") {
229+
const failedTask = wf?.tasks?.[0];
230+
throw new Error(
231+
`Task ended in unexpected state: ${taskStatus} ` +
232+
`(workflowId=${executionId}, workflow=${workflowName}, task=${taskName}` +
233+
(failedTask?.reasonForIncompletion
234+
? `, reason=${failedTask.reasonForIncompletion}`
235+
: "") +
236+
")"
237+
);
238+
}
217239
await new Promise((resolve) => setTimeout(resolve, pollInterval));
218240
}
219241
expect(taskStatus).toEqual("IN_PROGRESS");
@@ -227,7 +249,7 @@ describe("WorkflowExecutor", () => {
227249
executor,
228250
executionId,
229251
"COMPLETED",
230-
120000,
252+
30000,
231253
5000
232254
);
233255

@@ -258,7 +280,7 @@ describe("WorkflowExecutor", () => {
258280
],
259281
inputParameters: [],
260282
outputParameters: {},
261-
timeoutSeconds: 300,
283+
timeoutSeconds: 30,
262284
});
263285

264286
const executionId = await executor.startWorkflow({
@@ -311,7 +333,7 @@ describe("WorkflowExecutor", () => {
311333

312334
// Register all test workflows
313335
await registerAllWorkflows();
314-
}, 90000);
336+
}, 30000);
315337

316338
afterEach(async () => {
317339
// Clean up executions first

0 commit comments

Comments
 (0)