Test coverage for change in resource rows
This commit is contained in:
parent
c57993f0a5
commit
895d74c503
|
@ -1,5 +1,6 @@
|
|||
import { Factory } from 'ember-cli-mirage';
|
||||
import { Factory, trait } from 'ember-cli-mirage';
|
||||
import faker from 'nomad-ui/mirage/faker';
|
||||
import { provide } from '../utils';
|
||||
|
||||
const DISK_RESERVATIONS = [200, 500, 1000, 2000, 5000, 10000, 100000];
|
||||
|
||||
|
@ -13,6 +14,12 @@ export default Factory.extend({
|
|||
Migrate: faker.random.boolean(),
|
||||
}),
|
||||
|
||||
noHostVolumes: trait({
|
||||
hostVolumes: () => ({}),
|
||||
}),
|
||||
|
||||
volumes: makeHostVolumes(),
|
||||
|
||||
// Directive used to control whether or not allocations are automatically
|
||||
// created.
|
||||
createAllocations: true,
|
||||
|
@ -29,10 +36,20 @@ export default Factory.extend({
|
|||
|
||||
afterCreate(group, server) {
|
||||
let taskIds = [];
|
||||
let volumes = Object.keys(group.volumes);
|
||||
|
||||
if (!group.shallow) {
|
||||
const tasks = server.createList('task', group.count, {
|
||||
taskGroup: group,
|
||||
const tasks = provide(group.count, () => {
|
||||
const mounts = faker.helpers.shuffle(volumes).slice(0, faker.random.number(2));
|
||||
return server.create('task', {
|
||||
taskGroup: group,
|
||||
volumeMounts: mounts.map(mount => ({
|
||||
Volume: mount,
|
||||
Destination: `/${faker.internet.userName()}/${faker.internet.domainWord()}/${faker.internet.color()}`,
|
||||
PropagationMode: '',
|
||||
ReadOnly: faker.random.boolean(),
|
||||
})),
|
||||
});
|
||||
});
|
||||
taskIds = tasks.mapBy('id');
|
||||
}
|
||||
|
@ -76,3 +93,18 @@ export default Factory.extend({
|
|||
}
|
||||
},
|
||||
});
|
||||
|
||||
function makeHostVolumes() {
|
||||
const generate = () => ({
|
||||
Name: faker.internet.domainWord(),
|
||||
Type: 'host',
|
||||
source: faker.internet.domainWord(),
|
||||
ReadOnly: faker.random.boolean(),
|
||||
});
|
||||
|
||||
const volumes = provide(faker.random.number({ min: 1, max: 5 }), generate);
|
||||
return volumes.reduce((hash, volume) => {
|
||||
hash[volume.Name] = volume;
|
||||
return hash;
|
||||
}, {});
|
||||
}
|
||||
|
|
|
@ -8,6 +8,9 @@ export default Factory.extend({
|
|||
// Hidden property used to compute the Summary hash
|
||||
groupNames: [],
|
||||
|
||||
// Set in the TaskGroup factory
|
||||
volumeMounts: [],
|
||||
|
||||
JobID: '',
|
||||
|
||||
name: id => `task-${faker.hacker.noun().dasherize()}-${id}`,
|
||||
|
|
|
@ -150,6 +150,7 @@ module('Acceptance | client detail', function(hooks) {
|
|||
assert.equal(allocationRow.job, server.db.jobs.find(allocation.jobId).name, 'Job name');
|
||||
assert.ok(allocationRow.taskGroup, 'Task group name');
|
||||
assert.ok(allocationRow.jobVersion, 'Job Version');
|
||||
assert.equal(allocationRow.volume, 'Yes', 'Volume');
|
||||
assert.equal(
|
||||
allocationRow.cpu,
|
||||
Math.floor(allocStats.resourceUsage.CpuStats.TotalTicks) / cpuUsed,
|
||||
|
|
|
@ -161,6 +161,11 @@ module('Acceptance | task group detail', function(hooks) {
|
|||
server.db.nodes.find(allocation.nodeId).id.split('-')[0],
|
||||
'Node ID'
|
||||
);
|
||||
assert.equal(
|
||||
allocationRow.volume,
|
||||
Object.keys(taskGroup.volumes).length ? 'Yes' : '',
|
||||
'Volumes'
|
||||
);
|
||||
|
||||
await allocationRow.visitClient();
|
||||
|
||||
|
|
|
@ -95,6 +95,11 @@ module('Integration | Component | job-page/parts/task-groups', function(hooks) {
|
|||
taskGroup.get('count'),
|
||||
'Count'
|
||||
);
|
||||
assert.equal(
|
||||
taskGroupRow.querySelector('[data-test-task-group-volume]').textContent.trim(),
|
||||
taskGroup.get('volumes.length') ? 'Yes' : '',
|
||||
'Volumes'
|
||||
);
|
||||
assert.equal(
|
||||
taskGroupRow.querySelector('[data-test-task-group-cpu]').textContent.trim(),
|
||||
`${taskGroup.get('reservedCPU')} MHz`,
|
||||
|
|
|
@ -12,6 +12,7 @@ export default function(selector = '[data-test-allocation]', propKey = 'allocati
|
|||
taskGroup: text('[data-test-task-group]'),
|
||||
client: text('[data-test-client]'),
|
||||
jobVersion: text('[data-test-job-version]'),
|
||||
volume: text('[data-test-volume]'),
|
||||
cpu: text('[data-test-cpu]'),
|
||||
cpuTooltip: attribute('aria-label', '[data-test-cpu] .tooltip'),
|
||||
mem: text('[data-test-mem]'),
|
||||
|
|
Loading…
Reference in a new issue