fix(xo-server-test/job with non-existent VM): logged as failed task (#5112)

Since c061505bf8, missing VMs are logged as a failure tasks
This commit is contained in:
badrAZ 2020-06-29 14:04:23 +02:00 committed by GitHub
parent 04f2f50d6d
commit b6a6694abf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 13 deletions

View File

@ -22,16 +22,18 @@ Object {
exports[`backupNg .runJob() : fails trying to run a backup job with no matching VMs 1`] = `[JsonRpcError: unknown error from the peer]`;
exports[`backupNg .runJob() : fails trying to run a backup job with non-existent vm 1`] = `
Array [
Object {
"data": Object {
"vms": Array [
"non-existent-id",
],
},
"message": "missingVms",
Object {
"data": Object {
"id": Any<String>,
"type": "VM",
},
]
"end": Any<Number>,
"id": Any<String>,
"message": Any<String>,
"result": Any<Object>,
"start": Any<Number>,
"status": "failure",
}
`;
exports[`backupNg .runJob() : fails trying to run a backup job without schedule 1`] = `[JsonRpcError: invalid parameters]`;

View File

@ -198,7 +198,7 @@ describe('backupNg', () => {
it('fails trying to run a backup job with non-existent vm', async () => {
jest.setTimeout(7e3)
const scheduleTempId = randomId()
const { id: jobId } = await xo.createTempBackupNgJob({
const jobInput = {
schedules: {
[scheduleTempId]: getDefaultSchedule(),
},
@ -208,16 +208,39 @@ describe('backupNg', () => {
vms: {
id: 'non-existent-id',
},
})
}
const { id: jobId } = await xo.createTempBackupNgJob(jobInput)
const schedule = await xo.getSchedule({ jobId })
expect(typeof schedule).toBe('object')
await xo.call('backupNg.runJob', { id: jobId, schedule: schedule.id })
const [log] = await xo.getBackupLogs({
const [
{
tasks: [vmTask],
...log
},
] = await xo.getBackupLogs({
scheduleId: schedule.id,
})
expect(log.warnings).toMatchSnapshot()
validateRootTask(log, {
data: {
mode: jobInput.mode,
reportWhen: jobInput.settings[''].reportWhen,
},
jobId,
jobName: jobInput.name,
scheduleId: schedule.id,
status: 'failure',
})
validateVmTask(vmTask, jobInput.vms.id, {
status: 'failure',
result: expect.any(Object),
})
expect(noSuchObject.is(vmTask.result)).toBe(true)
})
it('fails trying to run a backup job with a VM without disks', async () => {