Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

engine: Include timestamp on JOB_ERROR #793

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions integration-tests/worker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @openfn/integration-tests-worker

## 1.0.62

### Patch Changes

- Updated dependencies [ae55a6a]
- @openfn/[email protected]
- @openfn/[email protected]
- @openfn/[email protected]

## 1.0.61

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/worker/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@openfn/integration-tests-worker",
"private": true,
"version": "1.0.61",
"version": "1.0.62",
"description": "Lightning WOrker integration tests",
"author": "Open Function Group <[email protected]>",
"license": "ISC",
Expand Down
6 changes: 6 additions & 0 deletions packages/engine-multi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# engine-multi

## 1.3.0

### Minor Changes

- ae55a6a: Include timestamp on JOB_ERROR payload

## 1.2.5

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/engine-multi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/engine-multi",
"version": "1.2.5",
"version": "1.3.0",
"description": "Multi-process runtime engine",
"main": "dist/index.js",
"type": "module",
Expand Down
1 change: 1 addition & 0 deletions packages/engine-multi/src/api/lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export const jobError = (
duration,
jobId,
next,
time: timestamp(),
});
};

Expand Down
1 change: 1 addition & 0 deletions packages/engine-multi/src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export interface JobCompletePayload extends ExternalEvent {
export interface JobErrorPayload extends ExternalEvent {
jobId: string;
duration: number;
time: bigint;
state: any; // the result state
error: any;
next: string[]; // downstream jobs
Expand Down
44 changes: 44 additions & 0 deletions packages/engine-multi/test/api/lifecycle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
jobStart,
jobComplete,
error,
jobError,
} from '../../src/api/lifecycle';
import { WorkflowState } from '../../src/types';
import ExecutionContext from '../../src/classes/ExecutionContext';
Expand Down Expand Up @@ -194,6 +195,49 @@ test(`job-complete: emits ${e.JOB_COMPLETE} with key fields`, (t) => {
});
});

test(`job-error: emits ${e.JOB_ERROR} with key fields`, (t) => {
return new Promise((done) => {
const workflowId = 'a';

const state = {
id: workflowId,
startTime: Date.now() - 1000,
} as WorkflowState;

const context = createContext(workflowId, state);

const event: w.JobErrorEvent = {
type: w.JOB_ERROR,
error: {
message: 'Unexpected content returned',
name: 'JobError',
severity: 'fail',
},
workflowId,
threadId: '1',
jobId: 'j',
duration: 2,
state: 22,
next: [],
};

context.on(e.JOB_ERROR, (evt) => {
t.is(evt.workflowId, workflowId);
t.is(evt.threadId, '1');
t.is(evt.jobId, 'j');
t.is(evt.state, 22);
t.is(evt.duration, 2);
t.deepEqual(evt.next, []);
t.deepEqual(evt.error, event.error);
t.assert(evt.time > 0);
t.assert(typeof evt.time === 'bigint');
done();
});

jobError(context, event);
});
});

test(`log: emits ${e.WORKFLOW_LOG}`, (t) => {
return new Promise((done) => {
const workflowId = 'a';
Expand Down
7 changes: 7 additions & 0 deletions packages/lightning-mock/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @openfn/lightning-mock

## 2.0.20

### Patch Changes

- Updated dependencies [ae55a6a]
- @openfn/[email protected]

## 2.0.19

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/lightning-mock/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/lightning-mock",
"version": "2.0.19",
"version": "2.0.20",
"private": true,
"description": "A mock Lightning server",
"main": "dist/index.js",
Expand Down
11 changes: 11 additions & 0 deletions packages/ws-worker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# ws-worker

## 1.7.0

### Minor Changes

- ae55a6a: Include timestamp on step complete even if the step failed

### Patch Changes

- Updated dependencies [ae55a6a]
- @openfn/[email protected]

## 1.6.7

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ws-worker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/ws-worker",
"version": "1.6.7",
"version": "1.7.0",
"description": "A Websocket Worker to connect Lightning to a Runtime Engine",
"main": "dist/index.js",
"type": "module",
Expand Down