Skip to content

Commit

Permalink
tests: reorganise
Browse files Browse the repository at this point in the history
  • Loading branch information
josephjclark committed Feb 15, 2024
1 parent c41f7f5 commit 854a586
Showing 1 changed file with 68 additions and 69 deletions.
137 changes: 68 additions & 69 deletions integration-tests/worker/test/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,75 +151,6 @@ test.serial('run a job which does NOT autoinstall common', (t) => {
});
});

test.serial("Don't send job logs to stdout", (t) => {
return new Promise(async (done) => {
const attempt = {
id: crypto.randomUUID(),
jobs: [
{
adaptor: '@openfn/language-common@latest',
body: 'fn((s) => { console.log("@@@"); return s })',
},
],
};

lightning.once('run:complete', () => {
const jsonLogs = engineLogger._history;
// The engine logger shouldn't print out any job logs
const jobLog = jsonLogs.find((l) => l.name === 'JOB');
t.falsy(jobLog);
const jobLog2 = jsonLogs.find((l) => l.message[0] === '@@@');
t.falsy(jobLog2);

// But it SHOULD log engine stuff
const runtimeLog = jsonLogs.find(
(l) => l.name === 'engine' && l.message[0].match(/complete workflow/i)
);
t.truthy(runtimeLog);
done();
});

lightning.enqueueRun(attempt);
});
});

test.serial("Don't send adaptor logs to stdout", (t) => {
return new Promise(async (done) => {
// We have to create a new worker with a different repo for this one
await worker.destroy();
({ worker, engineLogger } = await createDummyWorker());

const message = 've have been expecting you meester bond';
const attempt = {
id: crypto.randomUUID(),
jobs: [
{
adaptor: '@openfn/[email protected]',
body: `import { log } from '@openfn/test-adaptor'; log("${message}")`,
},
],
};

lightning.once('run:complete', () => {
const jsonLogs = engineLogger._history;
// The engine logger shouldn't print out any adaptor logs
const jobLog = jsonLogs.find((l) => l.name === 'ADA');
t.falsy(jobLog);
const jobLog2 = jsonLogs.find((l) => l.message[0] === message);
t.falsy(jobLog2);

// But it SHOULD log engine stuff
const runtimeLog = jsonLogs.find(
(l) => l.name === 'engine' && l.message[0].match(/complete workflow/i)
);
t.truthy(runtimeLog);
done();
});

lightning.enqueueRun(attempt);
});
});

test.serial('run a job with initial state (with data)', (t) => {
return new Promise(async (done) => {
const attempt = {
Expand Down Expand Up @@ -506,6 +437,74 @@ test.serial('an OOM error should still call step-complete', (t) => {
// });
// });
// });
test.serial("Don't send job logs to stdout", (t) => {
return new Promise(async (done) => {
const attempt = {
id: crypto.randomUUID(),
jobs: [
{
adaptor: '@openfn/language-common@latest',
body: 'fn((s) => { console.log("@@@"); return s })',
},
],
};

lightning.once('run:complete', () => {
const jsonLogs = engineLogger._history;
// The engine logger shouldn't print out any job logs
const jobLog = jsonLogs.find((l) => l.name === 'JOB');
t.falsy(jobLog);
const jobLog2 = jsonLogs.find((l) => l.message[0] === '@@@');
t.falsy(jobLog2);

// But it SHOULD log engine stuff
const runtimeLog = jsonLogs.find(
(l) => l.name === 'engine' && l.message[0].match(/complete workflow/i)
);
t.truthy(runtimeLog);
done();
});

lightning.enqueueRun(attempt);
});
});

test.serial("Don't send adaptor logs to stdout", (t) => {
return new Promise(async (done) => {
// We have to create a new worker with a different repo for this one
await worker.destroy();
({ worker, engineLogger } = await createDummyWorker());

const message = 've have been expecting you meester bond';
const attempt = {
id: crypto.randomUUID(),
jobs: [
{
adaptor: '@openfn/[email protected]',
body: `import { log } from '@openfn/test-adaptor'; log("${message}")`,
},
],
};

lightning.once('run:complete', () => {
const jsonLogs = engineLogger._history;
// The engine logger shouldn't print out any adaptor logs
const jobLog = jsonLogs.find((l) => l.name === 'ADA');
t.falsy(jobLog);
const jobLog2 = jsonLogs.find((l) => l.message[0] === message);
t.falsy(jobLog2);

// But it SHOULD log engine stuff
const runtimeLog = jsonLogs.find(
(l) => l.name === 'engine' && l.message[0].match(/complete workflow/i)
);
t.truthy(runtimeLog);
done();
});

lightning.enqueueRun(attempt);
});
});

test.serial(
'stateful adaptor should create a new client for each attempt',
Expand Down

0 comments on commit 854a586

Please sign in to comment.