diff --git a/ui/mirage/factories/agent.js b/ui/mirage/factories/agent.js index e3b52834d..c57a12681 100644 --- a/ui/mirage/factories/agent.js +++ b/ui/mirage/factories/agent.js @@ -11,7 +11,7 @@ export default Factory.extend({ name: () => `nomad@${faker.internet.ip()}`, status: () => faker.helpers.randomize(AGENT_STATUSES), - serf_port: () => faker.random.number({ min: 4000, max: 4999 }), + serfPort: () => faker.random.number({ min: 4000, max: 4999 }), address() { return this.name.split('@')[1]; @@ -20,7 +20,7 @@ export default Factory.extend({ tags() { const rpcPortCandidate = faker.random.number({ min: 4000, max: 4999 }); return { - port: rpcPortCandidate === this.serf_port ? rpcPortCandidate + 1 : rpcPortCandidate, + port: rpcPortCandidate === this.serfPort ? rpcPortCandidate + 1 : rpcPortCandidate, dc: faker.helpers.randomize(DATACENTERS), }; }, diff --git a/ui/mirage/factories/evaluation.js b/ui/mirage/factories/evaluation.js index d906190e3..8a3666d16 100644 --- a/ui/mirage/factories/evaluation.js +++ b/ui/mirage/factories/evaluation.js @@ -104,7 +104,6 @@ function assignJob(evaluation, server) { const job = evaluation.jobId ? server.db.jobs.find(evaluation.jobId) : pickOne(server.db.jobs); evaluation.update({ jobId: job.id, - job_id: job.id, }); } diff --git a/ui/mirage/factories/job-summary.js b/ui/mirage/factories/job-summary.js index 7a76f8986..c5b372407 100644 --- a/ui/mirage/factories/job-summary.js +++ b/ui/mirage/factories/job-summary.js @@ -6,7 +6,6 @@ export default Factory.extend({ // Hidden property used to compute the Summary hash groupNames: [], - JobID: '', namespace: null, withSummary: trait({ diff --git a/ui/mirage/factories/job.js b/ui/mirage/factories/job.js index c09eae9d8..04fb128df 100644 --- a/ui/mirage/factories/job.js +++ b/ui/mirage/factories/job.js @@ -25,7 +25,7 @@ export default Factory.extend({ region: () => 'global', type: () => faker.helpers.randomize(JOB_TYPES), priority: () => faker.random.number(100), - all_at_once: faker.random.boolean, + allAtOnce: faker.random.boolean, status: () => faker.helpers.randomize(JOB_STATUSES), datacenters: () => faker.helpers.shuffle(DATACENTERS).slice(0, faker.random.number({ min: 1, max: 4 })), @@ -141,21 +141,17 @@ export default Factory.extend({ job.update({ taskGroupIds: groups.mapBy('id'), - task_group_ids: groups.mapBy('id'), }); const hasChildren = job.periodic || (job.parameterized && !job.parentId); const jobSummary = server.create('job-summary', hasChildren ? 'withChildren' : 'withSummary', { + jobId: job.id, groupNames: groups.mapBy('name'), - job, - job_id: job.id, - JobID: job.id, namespace: job.namespace, }); job.update({ jobSummaryId: jobSummary.id, - job_summary_id: jobSummary.id, }); const jobScale = server.create('job-scale', { diff --git a/ui/mirage/factories/node.js b/ui/mirage/factories/node.js index aeb901dc4..03d6427d6 100644 --- a/ui/mirage/factories/node.js +++ b/ui/mirage/factories/node.js @@ -17,7 +17,7 @@ export default Factory.extend({ nodeClass: () => faker.helpers.randomize(NODE_CLASSES), drain: faker.random.boolean, status: () => faker.helpers.randomize(NODE_STATUSES), - tls_enabled: faker.random.boolean, + tlsEnabled: faker.random.boolean, schedulingEligibility: () => (faker.random.boolean() ? 'eligible' : 'ineligible'), createIndex: i => i, diff --git a/ui/mirage/factories/task-group.js b/ui/mirage/factories/task-group.js index 92a031944..7d6822c22 100644 --- a/ui/mirage/factories/task-group.js +++ b/ui/mirage/factories/task-group.js @@ -85,7 +85,6 @@ export default Factory.extend({ group.update({ taskIds: taskIds, - task_ids: taskIds, }); if (group.createAllocations) { @@ -116,7 +115,7 @@ export default Factory.extend({ .fill(null) .forEach(() => { server.create('service', { - task_group: group, + taskGroup: group, }); }); } diff --git a/ui/mirage/models/allocation.js b/ui/mirage/models/allocation.js index fde6d52ac..d3738c127 100644 --- a/ui/mirage/models/allocation.js +++ b/ui/mirage/models/allocation.js @@ -1,6 +1,6 @@ import { Model, hasMany } from 'ember-cli-mirage'; export default Model.extend({ - task_states: hasMany('task-state'), - task_resources: hasMany('task-resource'), + taskStates: hasMany('task-state'), + taskResources: hasMany('task-resource'), }); diff --git a/ui/mirage/models/job-summary.js b/ui/mirage/models/job-summary.js deleted file mode 100644 index 5e76efb41..000000000 --- a/ui/mirage/models/job-summary.js +++ /dev/null @@ -1,5 +0,0 @@ -import { Model, belongsTo } from 'ember-cli-mirage'; - -export default Model.extend({ - job: belongsTo(), -}); diff --git a/ui/mirage/models/job.js b/ui/mirage/models/job.js index da8bc0c0c..e0ea63340 100644 --- a/ui/mirage/models/job.js +++ b/ui/mirage/models/job.js @@ -1,7 +1,7 @@ import { Model, hasMany, belongsTo } from 'ember-cli-mirage'; export default Model.extend({ - task_groups: hasMany('task-group'), - job_summary: belongsTo('job-summary'), + taskGroups: hasMany('task-group'), + jobSummary: belongsTo('job-summary'), jobScale: belongsTo('job-scale'), }); diff --git a/ui/mirage/models/service.js b/ui/mirage/models/service.js index b6def868c..d3fbf3b03 100644 --- a/ui/mirage/models/service.js +++ b/ui/mirage/models/service.js @@ -1,5 +1,5 @@ import { Model, belongsTo } from 'ember-cli-mirage'; export default Model.extend({ - task_group: belongsTo('task-group'), + taskGroup: belongsTo('task-group'), }); diff --git a/ui/mirage/serializers/allocation.js b/ui/mirage/serializers/allocation.js index 883e3cfe8..9f5801a6f 100644 --- a/ui/mirage/serializers/allocation.js +++ b/ui/mirage/serializers/allocation.js @@ -3,7 +3,7 @@ import { arrToObj } from '../utils'; export default ApplicationSerializer.extend({ embed: true, - include: ['task_states', 'task_resources'], + include: ['taskStates', 'taskResources'], serialize() { var json = ApplicationSerializer.prototype.serialize.apply(this, arguments); diff --git a/ui/mirage/serializers/application.js b/ui/mirage/serializers/application.js index a39f8167e..bdff0968f 100644 --- a/ui/mirage/serializers/application.js +++ b/ui/mirage/serializers/application.js @@ -19,6 +19,8 @@ export default RestSerializer.extend({ } }, + keyForModel: keyCase, + keyForForeignKey: str => `${keyCase(str)}ID`, keyForCollection: keyCase, keyForAttribute: keyCase, keyForRelationship: keyCase, diff --git a/ui/mirage/serializers/job.js b/ui/mirage/serializers/job.js index a9df11f0a..2eef5e074 100644 --- a/ui/mirage/serializers/job.js +++ b/ui/mirage/serializers/job.js @@ -2,7 +2,7 @@ import ApplicationSerializer from './application'; export default ApplicationSerializer.extend({ embed: true, - include: ['task_groups', 'job_summary'], + include: ['taskGroups', 'jobSummary'], serialize() { var json = ApplicationSerializer.prototype.serialize.apply(this, arguments); diff --git a/ui/tests/acceptance/allocation-detail-test.js b/ui/tests/acceptance/allocation-detail-test.js index 2ebdf1f29..3223868e5 100644 --- a/ui/tests/acceptance/allocation-detail-test.js +++ b/ui/tests/acceptance/allocation-detail-test.js @@ -265,7 +265,7 @@ module('Acceptance | allocation detail', function(hooks) { jobId: job.id, }); - const taskState = allocation.task_states.models.sortBy('name')[0]; + const taskState = allocation.taskStates.models.sortBy('name')[0]; const task = server.schema.tasks.findBy({ name: taskState.name }); task.update('kind', 'connect-proxy:task'); task.save(); @@ -295,7 +295,9 @@ module('Acceptance | allocation detail', function(hooks) { assert.equal(renderedPort.name, serverPort.Label); assert.equal(renderedPort.to, serverPort.To); - const expectedAddr = isIp.v6(serverPort.HostIP) ? `[${serverPort.HostIP}]:${serverPort.Value}` : `${serverPort.HostIP}:${serverPort.Value}`; + const expectedAddr = isIp.v6(serverPort.HostIP) + ? `[${serverPort.HostIP}]:${serverPort.Value}` + : `${serverPort.HostIP}:${serverPort.Value}`; assert.equal(renderedPort.address, expectedAddr); }); }); diff --git a/ui/tests/acceptance/exec-test.js b/ui/tests/acceptance/exec-test.js index b7d0817c6..2ce12ff0d 100644 --- a/ui/tests/acceptance/exec-test.js +++ b/ui/tests/acceptance/exec-test.js @@ -25,10 +25,10 @@ module('Acceptance | exec', function(hooks) { status: 'running', }); - this.job.task_group_ids.forEach(taskGroupId => { + this.job.taskGroups.models.forEach(taskGroup => { server.create('allocation', { jobId: this.job.id, - taskGroup: server.db.taskGroups.find(taskGroupId).name, + taskGroup: taskGroup.name, forceRunningClientStatus: true, }); }); @@ -71,10 +71,10 @@ module('Acceptance | exec', function(hooks) { }); test('/exec/:job should show the task groups collapsed by default and allow the tasks to be shown', async function(assert) { - const firstTaskGroup = this.job.task_groups.models.sortBy('name')[0]; + const firstTaskGroup = this.job.taskGroups.models.sortBy('name')[0]; await Exec.visitJob({ job: this.job.id }); - assert.equal(Exec.taskGroups.length, this.job.task_groups.length); + assert.equal(Exec.taskGroups.length, this.job.taskGroups.length); assert.equal(Exec.taskGroups[0].name, firstTaskGroup.name); assert.equal(Exec.taskGroups[0].tasks.length, 0); @@ -103,7 +103,7 @@ module('Acceptance | exec', function(hooks) { }); test('a task group with a pending allocation shows a loading spinner', async function(assert) { - let taskGroup = this.job.task_groups.models.sortBy('name')[0]; + let taskGroup = this.job.taskGroups.models.sortBy('name')[0]; this.server.db.allocations.update({ taskGroup: taskGroup.name }, { clientStatus: 'pending' }); await Exec.visitJob({ job: this.job.id }); @@ -111,7 +111,7 @@ module('Acceptance | exec', function(hooks) { }); test('a task group with no running task states or pending allocations should not be shown', async function(assert) { - let taskGroup = this.job.task_groups.models.sortBy('name')[0]; + let taskGroup = this.job.taskGroups.models.sortBy('name')[0]; this.server.db.allocations.update({ taskGroup: taskGroup.name }, { clientStatus: 'failed' }); await Exec.visitJob({ job: this.job.id }); @@ -119,13 +119,13 @@ module('Acceptance | exec', function(hooks) { }); test('an inactive task should not be shown', async function(assert) { - let notRunningTaskGroup = this.job.task_groups.models.sortBy('name')[0]; + let notRunningTaskGroup = this.job.taskGroups.models.sortBy('name')[0]; this.server.db.allocations.update( { taskGroup: notRunningTaskGroup.name }, { clientStatus: 'failed' } ); - let runningTaskGroup = this.job.task_groups.models.sortBy('name')[1]; + let runningTaskGroup = this.job.taskGroups.models.sortBy('name')[1]; runningTaskGroup.tasks.models.forEach((task, index) => { if (index > 0) { this.server.db.taskStates.update({ name: task.name }, { finishedAt: new Date() }); @@ -139,13 +139,13 @@ module('Acceptance | exec', function(hooks) { }); test('a task that becomes active should appear', async function(assert) { - let notRunningTaskGroup = this.job.task_groups.models.sortBy('name')[0]; + let notRunningTaskGroup = this.job.taskGroups.models.sortBy('name')[0]; this.server.db.allocations.update( { taskGroup: notRunningTaskGroup.name }, { clientStatus: 'failed' } ); - let runningTaskGroup = this.job.task_groups.models.sortBy('name')[1]; + let runningTaskGroup = this.job.taskGroups.models.sortBy('name')[1]; let changingTaskStateName; runningTaskGroup.tasks.models.sortBy('name').forEach((task, index) => { if (index > 0) { @@ -184,7 +184,7 @@ module('Acceptance | exec', function(hooks) { this.job.status = 'dead'; this.job.save(); - let taskGroup = this.job.task_groups.models.sortBy('name')[0]; + let taskGroup = this.job.taskGroups.models.sortBy('name')[0]; let task = taskGroup.tasks.models.sortBy('name')[0]; this.server.db.taskStates.update({ finishedAt: new Date() }); @@ -217,7 +217,7 @@ module('Acceptance | exec', function(hooks) { }); test('visiting a path with a task group should open the group by default', async function(assert) { - let taskGroup = this.job.task_groups.models.sortBy('name')[0]; + let taskGroup = this.job.taskGroups.models.sortBy('name')[0]; await Exec.visitTaskGroup({ job: this.job.id, task_group: taskGroup.name }); assert.equal(Exec.taskGroups[0].tasks.length, taskGroup.tasks.length); @@ -235,7 +235,7 @@ module('Acceptance | exec', function(hooks) { await Exec.taskGroups[0].click(); await Exec.taskGroups[0].tasks[0].click(); - let taskGroup = this.job.task_groups.models.sortBy('name')[0]; + let taskGroup = this.job.taskGroups.models.sortBy('name')[0]; let task = taskGroup.tasks.models.sortBy('name')[0]; let taskStates = this.server.db.taskStates.where({ @@ -274,7 +274,7 @@ module('Acceptance | exec', function(hooks) { }); test('an allocation can be specified', async function(assert) { - let taskGroup = this.job.task_groups.models.sortBy('name')[0]; + let taskGroup = this.job.taskGroups.models.sortBy('name')[0]; let task = taskGroup.tasks.models.sortBy('name')[0]; let allocations = this.server.db.allocations.where({ jobId: this.job.id, @@ -322,7 +322,7 @@ module('Acceptance | exec', function(hooks) { this.owner.register('service:sockets', mockSockets); - let taskGroup = this.job.task_groups.models.sortBy('name')[0]; + let taskGroup = this.job.taskGroups.models.sortBy('name')[0]; let task = taskGroup.tasks.models.sortBy('name')[0]; let allocations = this.server.db.allocations.where({ jobId: this.job.id, @@ -393,7 +393,7 @@ module('Acceptance | exec', function(hooks) { this.owner.register('service:sockets', mockSockets); - let taskGroup = this.job.task_groups.models[0]; + let taskGroup = this.job.taskGroups.models[0]; let task = taskGroup.tasks.models[0]; let allocations = this.server.db.allocations.where({ jobId: this.job.id, @@ -463,7 +463,7 @@ module('Acceptance | exec', function(hooks) { await Exec.taskGroups[0].click(); await Exec.taskGroups[0].tasks[0].click(); - let taskGroup = this.job.task_groups.models.sortBy('name')[0]; + let taskGroup = this.job.taskGroups.models.sortBy('name')[0]; let task = taskGroup.tasks.models.sortBy('name')[0]; let allocation = this.server.db.allocations.findBy({ jobId: this.job.id, @@ -509,7 +509,7 @@ module('Acceptance | exec', function(hooks) { test('a persisted customised command is recalled', async function(assert) { window.localStorage.setItem('nomadExecCommand', JSON.stringify('/bin/sh')); - let taskGroup = this.job.task_groups.models[0]; + let taskGroup = this.job.taskGroups.models[0]; let task = taskGroup.tasks.models[0]; let allocations = this.server.db.allocations.where({ jobId: this.job.id, @@ -536,7 +536,7 @@ module('Acceptance | exec', function(hooks) { }); skip('when a task state finishes submitting a command displays an error', async function(assert) { - let taskGroup = this.job.task_groups.models.sortBy('name')[0]; + let taskGroup = this.job.taskGroups.models.sortBy('name')[0]; let task = taskGroup.tasks.models.sortBy('name')[0]; await Exec.visitTask({ diff --git a/ui/tests/acceptance/servers-list-test.js b/ui/tests/acceptance/servers-list-test.js index 9f6fb9fd5..e4ac8986c 100644 --- a/ui/tests/acceptance/servers-list-test.js +++ b/ui/tests/acceptance/servers-list-test.js @@ -60,7 +60,7 @@ module('Acceptance | servers list', function(hooks) { assert.equal(agentRow.status, agent.status, 'Status'); assert.equal(agentRow.leader, 'True', 'Leader?'); assert.equal(agentRow.address, agent.address, 'Address'); - assert.equal(agentRow.serfPort, agent.serf_port, 'Serf Port'); + assert.equal(agentRow.serfPort, agent.serfPort, 'Serf Port'); assert.equal(agentRow.datacenter, agent.tags.dc, 'Datacenter'); }); diff --git a/ui/tests/acceptance/task-detail-test.js b/ui/tests/acceptance/task-detail-test.js index 10e150ffc..85d49c5fa 100644 --- a/ui/tests/acceptance/task-detail-test.js +++ b/ui/tests/acceptance/task-detail-test.js @@ -109,15 +109,15 @@ module('Acceptance | task detail', function(hooks) { status: 'running', }); - job.task_group_ids.forEach(taskGroupId => { + job.taskGroups.models.forEach(taskGroup => { server.create('allocation', { jobId: job.id, - taskGroup: server.db.taskGroups.find(taskGroupId).name, + taskGroup: taskGroup.name, forceRunningClientStatus: true, }); }); - const taskGroup = job.task_groups.models[0]; + const taskGroup = job.taskGroups.models[0]; const [mainTask, sidecarTask, prestartTask] = taskGroup.tasks.models; mainTask.attrs.Lifecycle = null; @@ -131,7 +131,7 @@ module('Acceptance | task detail', function(hooks) { taskGroup.save(); - const noPrestartTasksTaskGroup = job.task_groups.models[1]; + const noPrestartTasksTaskGroup = job.taskGroups.models[1]; noPrestartTasksTaskGroup.tasks.models.forEach(task => { task.attrs.Lifecycle = null; task.save(); @@ -421,7 +421,7 @@ module('Acceptance | proxy task detail', function(hooks) { server.create('job', { createAllocations: false }); allocation = server.create('allocation', 'withTaskWithPorts', { clientStatus: 'running' }); - const taskState = allocation.task_states.models[0]; + const taskState = allocation.taskStates.models[0]; const task = server.schema.tasks.findBy({ name: taskState.name }); task.update('kind', 'connect-proxy:task'); task.save(); diff --git a/ui/tests/integration/components/scale-events-accordion-test.js b/ui/tests/integration/components/scale-events-accordion-test.js index 73f45b9b9..5b4af356b 100644 --- a/ui/tests/integration/components/scale-events-accordion-test.js +++ b/ui/tests/integration/components/scale-events-accordion-test.js @@ -18,7 +18,7 @@ module('Integration | Component | scale-events-accordion', function(hooks) { this.server.create('node'); this.taskGroupWithEvents = async function(events) { const job = this.server.create('job', { createAllocations: false }); - const group = job.task_groups.models[0]; + const group = job.taskGroups.models[0]; job.jobScale.taskGroupScales.models.findBy('name', group.name).update({ events }); const jobModel = await this.store.find('job', JSON.stringify([job.id, 'default']));