Initial
This commit is contained in:
@@ -97,6 +97,32 @@ test('script test runs generate the same FileLocker job output artifacts', async
|
||||
updateSettings({ allow_script_execution: 'true' });
|
||||
});
|
||||
|
||||
test('job output status is successful when at least one host completed', async () => {
|
||||
const scriptId = 'scr_job_output_mixed_status_test';
|
||||
const jobId = 'job_output_mixed_status_test';
|
||||
db.prepare(`INSERT INTO scripts (id, name, content, visibility, owner_user_id, version, created_at, updated_at)
|
||||
VALUES (?, 'Mixed Host Status.ps1', 'Write-Output mixed', 'personal', ?, 1, ?, ?)`).run(scriptId, owner, ts, ts);
|
||||
const hostA = createHost({ name: 'Mixed Success Host', address: 'mixed-a.local', transport: 'local', osFamily: 'linux', visibility: 'personal' }, owner);
|
||||
const hostB = createHost({ name: 'Mixed Failed Host', address: 'mixed-b.local', transport: 'local', osFamily: 'linux', visibility: 'personal' }, owner);
|
||||
db.prepare(`INSERT INTO jobs (id, runplan_id, script_id, status, triggered_by, started_at, ended_at, created_at)
|
||||
VALUES (?, NULL, ?, 'failed', ?, ?, ?, ?)`).run(jobId, scriptId, owner, ts, ts, ts);
|
||||
db.prepare(`INSERT INTO job_hosts (id, job_id, host_id, status, exit_code, started_at, ended_at)
|
||||
VALUES (?, ?, ?, 'completed', 0, ?, ?)`).run('jhost_mixed_success', jobId, hostA.id, ts, ts);
|
||||
db.prepare(`INSERT INTO job_hosts (id, job_id, host_id, status, exit_code, started_at, ended_at)
|
||||
VALUES (?, ?, ?, 'failed', 1, ?, ?)`).run('jhost_mixed_failed', jobId, hostB.id, ts, ts);
|
||||
addLog(jobId, hostA.id, 'stdout', 'success payload', 1);
|
||||
addLog(jobId, hostB.id, 'stderr', 'failed payload', 2);
|
||||
|
||||
await generateJobOutputs(jobId);
|
||||
const output = listJobOutputsForJob(jobId, owner, false).find((row) => row.kind === 'stdout-pdf');
|
||||
|
||||
assert.equal(output.jobStatus, 'failed');
|
||||
assert.equal(output.outputStatus, 'completed');
|
||||
assert.equal(output.hostSuccessCount, 1);
|
||||
assert.equal(output.hostFailedCount, 1);
|
||||
assert.equal(output.hostTotalCount, 2);
|
||||
});
|
||||
|
||||
test('job output datatable uses one last-stdout row per host for unstructured output', async () => {
|
||||
const scriptId = 'scr_job_output_last_line_test';
|
||||
const jobId = 'job_output_last_line_test';
|
||||
|
||||
Reference in New Issue
Block a user