Fix flaky lifecycle chart tests

This commit is contained in:
Michael Lange 2020-09-01 10:02:10 -07:00
parent f543137ec9
commit c041236629
3 changed files with 12 additions and 3 deletions

View file

@ -103,6 +103,7 @@ module('Acceptance | allocation detail', function(hooks) {
const prestartEphemeralTask = server.db.taskStates
.where({ allocationId: allocation.id })
.sortBy('name')
.find(taskState => {
const task = server.db.tasks.findBy({ name: taskState.name });
return task.Lifecycle && task.Lifecycle.Hook === 'prestart' && !task.Lifecycle.Sidecar;

View file

@ -37,8 +37,16 @@ module('Acceptance | task detail', function(hooks) {
);
const lifecycle = server.db.tasks.where({ name: task.name })[0].Lifecycle;
const prestartString = lifecycle && lifecycle.Sidecar ? 'sidecar' : 'prestart';
assert.equal(Task.lifecycle, lifecycle ? prestartString : 'main');
let lifecycleName = 'main';
if (lifecycle && (lifecycle.Hook === 'prestart' || lifecycle.Hook === 'poststart')) {
lifecycleName = `${lifecycle.Hook}-${lifecycle.Sidecar ? 'sidecar' : 'ephemeral'}`;
}
if (lifecycle && lifecycle.Hook === 'poststop') {
lifecycleName = 'poststop';
}
assert.equal(Task.lifecycle, lifecycleName);
assert.equal(document.title, `Task ${task.name} - Nomad`);
});

View file

@ -105,7 +105,7 @@ module('Integration | Component | lifecycle-chart', function(hooks) {
this.set('tasks', [tasks[0], tasks[6]]);
await render(hbs`<LifecycleChart @tasks={{tasks}} />`);
assert.ok(Chart.phases.length, 4);
assert.equal(Chart.phases.length, 4);
});
test('it reflects phase and task states when states are passed in', async function(assert) {