2019-03-13 00:04:16 +00:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import { setupRenderingTest } from 'ember-qunit';
|
2019-07-23 19:40:32 +00:00
|
|
|
import { click, find, render } from '@ember/test-helpers';
|
2018-01-31 23:27:29 +00:00
|
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
|
|
import moment from 'moment';
|
|
|
|
import { startMirage } from 'nomad-ui/initializers/ember-cli-mirage';
|
|
|
|
import { initialize as fragmentSerializerInitializer } from 'nomad-ui/initializers/fragment-serializer';
|
2020-08-25 15:56:02 +00:00
|
|
|
import { componentA11yAudit } from 'nomad-ui/tests/helpers/a11y-audit';
|
2018-01-31 23:27:29 +00:00
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
module('Integration | Component | job-page/parts/latest-deployment', function (hooks) {
|
2019-03-13 00:04:16 +00:00
|
|
|
setupRenderingTest(hooks);
|
2018-01-31 23:27:29 +00:00
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
hooks.beforeEach(function () {
|
2019-03-13 00:04:16 +00:00
|
|
|
fragmentSerializerInitializer(this.owner);
|
|
|
|
window.localStorage.clear();
|
|
|
|
this.store = this.owner.lookup('service:store');
|
|
|
|
this.server = startMirage();
|
|
|
|
this.server.create('namespace');
|
|
|
|
});
|
2018-01-31 23:27:29 +00:00
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
hooks.afterEach(function () {
|
2019-03-13 00:04:16 +00:00
|
|
|
this.server.shutdown();
|
|
|
|
window.localStorage.clear();
|
|
|
|
});
|
2018-01-31 23:27:29 +00:00
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
test('there is no latest deployment section when the job has no deployments', async function (assert) {
|
2019-03-13 00:04:16 +00:00
|
|
|
this.server.create('job', {
|
|
|
|
type: 'service',
|
|
|
|
noDeployments: true,
|
|
|
|
createAllocations: false,
|
2018-01-31 23:27:29 +00:00
|
|
|
});
|
|
|
|
|
2019-07-23 19:40:32 +00:00
|
|
|
await this.store.findAll('job');
|
2019-03-13 00:04:16 +00:00
|
|
|
|
2019-07-23 19:40:32 +00:00
|
|
|
this.set('job', this.store.peekAll('job').get('firstObject'));
|
|
|
|
await render(hbs`
|
2020-07-09 17:30:11 +00:00
|
|
|
<JobPage::Parts::LatestDeployment @job={{job}} />)
|
2019-07-23 19:40:32 +00:00
|
|
|
`);
|
2019-03-13 00:04:16 +00:00
|
|
|
|
2019-07-23 19:40:32 +00:00
|
|
|
assert.notOk(find('[data-test-active-deployment]'), 'No active deployment');
|
2018-01-31 23:27:29 +00:00
|
|
|
});
|
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
test('the latest deployment section shows up for the currently running deployment', async function (assert) {
|
2019-03-13 00:40:39 +00:00
|
|
|
this.server.create('job', {
|
|
|
|
type: 'service',
|
|
|
|
createAllocations: false,
|
|
|
|
activeDeployment: true,
|
|
|
|
});
|
2018-07-30 22:20:58 +00:00
|
|
|
|
2019-07-23 19:40:32 +00:00
|
|
|
await this.store.findAll('job');
|
|
|
|
|
|
|
|
this.set('job', this.store.peekAll('job').get('firstObject'));
|
|
|
|
await render(hbs`
|
2020-07-09 17:30:11 +00:00
|
|
|
<JobPage::Parts::LatestDeployment @job={{job}} />
|
2019-07-23 19:40:32 +00:00
|
|
|
`);
|
|
|
|
|
|
|
|
const deployment = await this.get('job.latestDeployment');
|
|
|
|
const version = await deployment.get('version');
|
|
|
|
|
|
|
|
assert.ok(find('[data-test-active-deployment]'), 'Active deployment');
|
|
|
|
assert.ok(
|
|
|
|
find('[data-test-active-deployment]').classList.contains('is-info'),
|
|
|
|
'Running deployment gets the is-info class'
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
find('[data-test-active-deployment-stat="id"]').textContent.trim(),
|
|
|
|
deployment.get('shortId'),
|
|
|
|
'The active deployment is the most recent running deployment'
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
find('[data-test-active-deployment-stat="submit-time"]').textContent.trim(),
|
|
|
|
moment(version.get('submitTime')).fromNow(),
|
|
|
|
'Time since the job was submitted is in the active deployment header'
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
find('[data-test-deployment-metric="canaries"]').textContent.trim(),
|
|
|
|
`${deployment.get('placedCanaries')} / ${deployment.get('desiredCanaries')}`,
|
|
|
|
'Canaries, both places and desired, are in the metrics'
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
find('[data-test-deployment-metric="placed"]').textContent.trim(),
|
|
|
|
deployment.get('placedAllocs'),
|
|
|
|
'Placed allocs aggregates across task groups'
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
find('[data-test-deployment-metric="desired"]').textContent.trim(),
|
|
|
|
deployment.get('desiredTotal'),
|
|
|
|
'Desired allocs aggregates across task groups'
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
find('[data-test-deployment-metric="healthy"]').textContent.trim(),
|
|
|
|
deployment.get('healthyAllocs'),
|
|
|
|
'Healthy allocs aggregates across task groups'
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
find('[data-test-deployment-metric="unhealthy"]').textContent.trim(),
|
|
|
|
deployment.get('unhealthyAllocs'),
|
|
|
|
'Unhealthy allocs aggregates across task groups'
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
find('[data-test-deployment-notification]').textContent.trim(),
|
|
|
|
deployment.get('statusDescription'),
|
|
|
|
'Status description is in the metrics block'
|
|
|
|
);
|
2020-08-25 15:56:02 +00:00
|
|
|
|
|
|
|
await componentA11yAudit(this.element, assert);
|
2018-01-31 23:27:29 +00:00
|
|
|
});
|
2018-06-07 00:35:18 +00:00
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
test('when there is no running deployment, the latest deployment section shows up for the last deployment', async function (assert) {
|
2019-03-13 00:04:16 +00:00
|
|
|
this.server.create('job', {
|
|
|
|
type: 'service',
|
|
|
|
createAllocations: false,
|
|
|
|
noActiveDeployment: true,
|
|
|
|
});
|
|
|
|
|
2019-07-23 19:40:32 +00:00
|
|
|
await this.store.findAll('job');
|
|
|
|
|
|
|
|
this.set('job', this.store.peekAll('job').get('firstObject'));
|
|
|
|
await render(hbs`
|
2020-07-09 17:30:11 +00:00
|
|
|
<JobPage::Parts::LatestDeployment @job={{job}} />
|
2019-07-23 19:40:32 +00:00
|
|
|
`);
|
|
|
|
|
|
|
|
assert.ok(find('[data-test-active-deployment]'), 'Active deployment');
|
|
|
|
assert.notOk(
|
|
|
|
find('[data-test-active-deployment]').classList.contains('is-info'),
|
|
|
|
'Non-running deployment does not get the is-info class'
|
|
|
|
);
|
2019-03-13 00:04:16 +00:00
|
|
|
});
|
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
test('the latest deployment section can be expanded to show task groups and allocations', async function (assert) {
|
2019-03-13 00:04:16 +00:00
|
|
|
this.server.create('node');
|
|
|
|
this.server.create('job', { type: 'service', activeDeployment: true });
|
2018-06-07 00:35:18 +00:00
|
|
|
|
2019-07-23 19:40:32 +00:00
|
|
|
await this.store.findAll('job');
|
2018-06-07 00:35:18 +00:00
|
|
|
|
2019-07-23 19:40:32 +00:00
|
|
|
this.set('job', this.store.peekAll('job').get('firstObject'));
|
|
|
|
await render(hbs`
|
2020-07-09 17:30:11 +00:00
|
|
|
<JobPage::Parts::LatestDeployment @job={{job}} />
|
2019-07-23 19:40:32 +00:00
|
|
|
`);
|
2018-06-07 00:35:18 +00:00
|
|
|
|
2019-07-23 19:40:32 +00:00
|
|
|
assert.notOk(find('[data-test-deployment-task-groups]'), 'Task groups not found');
|
|
|
|
assert.notOk(find('[data-test-deployment-allocations]'), 'Allocations not found');
|
2018-06-07 00:35:18 +00:00
|
|
|
|
2019-07-23 19:40:32 +00:00
|
|
|
await click('[data-test-deployment-toggle-details]');
|
2019-03-13 00:04:16 +00:00
|
|
|
|
2019-07-23 19:40:32 +00:00
|
|
|
assert.ok(find('[data-test-deployment-task-groups]'), 'Task groups found');
|
|
|
|
assert.ok(find('[data-test-deployment-allocations]'), 'Allocations found');
|
2020-08-25 15:56:02 +00:00
|
|
|
|
|
|
|
await componentA11yAudit(this.element, assert);
|
2019-03-13 00:04:16 +00:00
|
|
|
});
|
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
test('each task group in the expanded task group section shows task group details', async function (assert) {
|
2019-03-13 00:04:16 +00:00
|
|
|
this.server.create('node');
|
|
|
|
this.server.create('job', { type: 'service', activeDeployment: true });
|
|
|
|
|
2019-07-23 19:40:32 +00:00
|
|
|
await this.store.findAll('job');
|
|
|
|
|
|
|
|
const job = this.store.peekAll('job').get('firstObject');
|
|
|
|
|
|
|
|
this.set('job', job);
|
|
|
|
await render(hbs`
|
2020-07-09 17:30:11 +00:00
|
|
|
<JobPage::Parts::LatestDeployment @job={{job}} />
|
2019-07-23 19:40:32 +00:00
|
|
|
`);
|
|
|
|
|
|
|
|
await click('[data-test-deployment-toggle-details]');
|
|
|
|
|
|
|
|
const task = job.get('runningDeployment.taskGroupSummaries.firstObject');
|
2021-12-28 14:45:20 +00:00
|
|
|
const findForTaskGroup = (selector) => find(`[data-test-deployment-task-group-${selector}]`);
|
2019-07-23 19:40:32 +00:00
|
|
|
assert.equal(findForTaskGroup('name').textContent.trim(), task.get('name'));
|
|
|
|
assert.equal(
|
|
|
|
findForTaskGroup('progress-deadline').textContent.trim(),
|
|
|
|
moment(task.get('requireProgressBy')).format("MMM DD, 'YY HH:mm:ss ZZ")
|
|
|
|
);
|
2018-06-07 00:35:18 +00:00
|
|
|
});
|
|
|
|
});
|