2019-07-23 19:40:32 +00:00
|
|
|
import { find, findAll, render } from '@ember/test-helpers';
|
2019-03-13 00:04:16 +00:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import { setupRenderingTest } from 'ember-qunit';
|
2018-01-19 13:56:43 +00:00
|
|
|
import { assign } from '@ember/polyfills';
|
2018-01-15 12:49:08 +00:00
|
|
|
import hbs from 'htmlbars-inline-precompile';
|
2020-08-25 15:56:02 +00:00
|
|
|
import cleanWhitespace from '../../utils/clean-whitespace';
|
|
|
|
import { componentA11yAudit } from 'nomad-ui/tests/helpers/a11y-audit';
|
2018-01-15 12:49:08 +00:00
|
|
|
|
2019-03-13 00:04:16 +00:00
|
|
|
module('Integration | Component | placement failures', function(hooks) {
|
|
|
|
setupRenderingTest(hooks);
|
2018-01-15 12:49:08 +00:00
|
|
|
|
2019-03-13 00:04:16 +00:00
|
|
|
const commonTemplate = hbs`
|
2020-06-01 19:03:56 +00:00
|
|
|
<PlacementFailure @taskGroup={{taskGroup}} />
|
2019-03-13 00:04:16 +00:00
|
|
|
`;
|
2018-01-15 12:49:08 +00:00
|
|
|
|
2019-03-13 00:04:16 +00:00
|
|
|
test('should render the placement failure (basic render)', async function(assert) {
|
|
|
|
const name = 'Placement Failure';
|
|
|
|
const failures = 11;
|
|
|
|
this.set(
|
|
|
|
'taskGroup',
|
|
|
|
createFixture(
|
|
|
|
{
|
|
|
|
coalescedFailures: failures - 1,
|
|
|
|
},
|
|
|
|
name
|
|
|
|
)
|
|
|
|
);
|
2018-01-19 13:56:43 +00:00
|
|
|
|
2019-03-13 00:04:16 +00:00
|
|
|
await render(commonTemplate);
|
2018-01-19 13:56:43 +00:00
|
|
|
|
2019-03-13 00:04:16 +00:00
|
|
|
assert.equal(
|
|
|
|
cleanWhitespace(find('[data-test-placement-failure-task-group]').firstChild.wholeText),
|
|
|
|
name,
|
|
|
|
'Title is rendered with the name of the placement failure'
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
parseInt(find('[data-test-placement-failure-coalesced-failures]').textContent),
|
|
|
|
failures,
|
|
|
|
'Title is rendered correctly with a count of unplaced'
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
findAll('[data-test-placement-failure-no-evaluated-nodes]').length,
|
|
|
|
1,
|
|
|
|
'No evaluated nodes message shown'
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
findAll('[data-test-placement-failure-no-nodes-available]').length,
|
|
|
|
1,
|
|
|
|
'No nodes in datacenter message shown'
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
findAll('[data-test-placement-failure-class-filtered]').length,
|
|
|
|
1,
|
|
|
|
'Class filtered message shown'
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
findAll('[data-test-placement-failure-constraint-filtered]').length,
|
|
|
|
1,
|
|
|
|
'Constraint filtered message shown'
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
findAll('[data-test-placement-failure-nodes-exhausted]').length,
|
|
|
|
1,
|
|
|
|
'Node exhausted message shown'
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
findAll('[data-test-placement-failure-class-exhausted]').length,
|
|
|
|
1,
|
|
|
|
'Class exhausted message shown'
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
findAll('[data-test-placement-failure-dimension-exhausted]').length,
|
|
|
|
1,
|
|
|
|
'Dimension exhausted message shown'
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
findAll('[data-test-placement-failure-quota-exhausted]').length,
|
|
|
|
1,
|
|
|
|
'Quota exhausted message shown'
|
|
|
|
);
|
|
|
|
assert.equal(findAll('[data-test-placement-failure-scores]').length, 1, 'Scores message shown');
|
2020-08-25 15:56:02 +00:00
|
|
|
|
|
|
|
await componentA11yAudit(this.element, assert);
|
2019-03-13 00:04:16 +00:00
|
|
|
});
|
2018-01-19 13:56:43 +00:00
|
|
|
|
2019-03-13 00:04:16 +00:00
|
|
|
test('should render correctly when a node is not evaluated', async function(assert) {
|
|
|
|
this.set(
|
|
|
|
'taskGroup',
|
|
|
|
createFixture({
|
|
|
|
nodesEvaluated: 1,
|
|
|
|
nodesExhausted: 0,
|
|
|
|
})
|
|
|
|
);
|
2018-01-19 13:56:43 +00:00
|
|
|
|
2019-03-13 00:04:16 +00:00
|
|
|
await render(commonTemplate);
|
2018-01-19 13:56:43 +00:00
|
|
|
|
2019-03-13 00:04:16 +00:00
|
|
|
assert.equal(
|
|
|
|
findAll('[data-test-placement-failure-no-evaluated-nodes]').length,
|
|
|
|
0,
|
|
|
|
'No evaluated nodes message shown'
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
findAll('[data-test-placement-failure-nodes-exhausted]').length,
|
|
|
|
0,
|
|
|
|
'Nodes exhausted message NOT shown when there are no nodes exhausted'
|
|
|
|
);
|
2020-08-25 15:56:02 +00:00
|
|
|
|
|
|
|
await componentA11yAudit(this.element, assert);
|
2019-03-13 00:04:16 +00:00
|
|
|
});
|
2018-01-15 12:49:08 +00:00
|
|
|
|
2019-03-13 00:04:16 +00:00
|
|
|
function createFixture(obj = {}, name = 'Placement Failure') {
|
|
|
|
return {
|
|
|
|
name: name,
|
|
|
|
placementFailures: assign(
|
|
|
|
{
|
|
|
|
name: name,
|
|
|
|
coalescedFailures: 10,
|
|
|
|
nodesEvaluated: 0,
|
|
|
|
nodesAvailable: {
|
|
|
|
datacenter: 0,
|
|
|
|
},
|
|
|
|
classFiltered: {
|
|
|
|
filtered: 1,
|
|
|
|
},
|
|
|
|
constraintFiltered: {
|
|
|
|
'prop = val': 1,
|
|
|
|
},
|
|
|
|
nodesExhausted: 3,
|
|
|
|
classExhausted: {
|
|
|
|
class: 3,
|
|
|
|
},
|
|
|
|
dimensionExhausted: {
|
|
|
|
iops: 3,
|
|
|
|
},
|
|
|
|
quotaExhausted: {
|
|
|
|
quota: 'dimension',
|
|
|
|
},
|
|
|
|
scores: {
|
|
|
|
name: 3,
|
|
|
|
},
|
2018-02-16 02:55:59 +00:00
|
|
|
},
|
2019-03-13 00:04:16 +00:00
|
|
|
obj
|
|
|
|
),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|