diff --git a/ui/mirage/factories/task-group.js b/ui/mirage/factories/task-group.js index 5f1c6f44e..f4e0482b4 100644 --- a/ui/mirage/factories/task-group.js +++ b/ui/mirage/factories/task-group.js @@ -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; + }, {}); +} diff --git a/ui/mirage/factories/task.js b/ui/mirage/factories/task.js index bdcdeaeb3..598175766 100644 --- a/ui/mirage/factories/task.js +++ b/ui/mirage/factories/task.js @@ -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}`, diff --git a/ui/tests/acceptance/client-detail-test.js b/ui/tests/acceptance/client-detail-test.js index 32763fdd7..bbb806d96 100644 --- a/ui/tests/acceptance/client-detail-test.js +++ b/ui/tests/acceptance/client-detail-test.js @@ -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, diff --git a/ui/tests/acceptance/task-group-detail-test.js b/ui/tests/acceptance/task-group-detail-test.js index 445124506..4a42cfcd0 100644 --- a/ui/tests/acceptance/task-group-detail-test.js +++ b/ui/tests/acceptance/task-group-detail-test.js @@ -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(); diff --git a/ui/tests/integration/job-page/parts/task-groups-test.js b/ui/tests/integration/job-page/parts/task-groups-test.js index 5fea0c765..46e642df0 100644 --- a/ui/tests/integration/job-page/parts/task-groups-test.js +++ b/ui/tests/integration/job-page/parts/task-groups-test.js @@ -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`, diff --git a/ui/tests/pages/components/allocations.js b/ui/tests/pages/components/allocations.js index e00c129be..5c519bf39 100644 --- a/ui/tests/pages/components/allocations.js +++ b/ui/tests/pages/components/allocations.js @@ -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]'),