From b44e828aa6bd8cda970e634a202b156e7775b41c Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Mon, 4 Jun 2018 15:34:16 -0700 Subject: [PATCH 1/2] Use the network ip as the task address instead of the node ip --- .../allocations/allocation/index.hbs | 34 ++++++++----------- .../allocations/allocation/task/index.hbs | 4 +-- ui/tests/acceptance/task-detail-test.js | 5 ++- 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/ui/app/templates/allocations/allocation/index.hbs b/ui/app/templates/allocations/allocation/index.hbs index c2e0a60ce616..d1c0375ed2ba 100644 --- a/ui/app/templates/allocations/allocation/index.hbs +++ b/ui/app/templates/allocations/allocation/index.hbs @@ -72,26 +72,20 @@ {{moment-format row.model.events.lastObject.time "MM/DD/YY HH:mm:ss"}} diff --git a/ui/app/templates/allocations/allocation/task/index.hbs b/ui/app/templates/allocations/allocation/task/index.hbs index 46fdd49f97df..ac13a5034869 100644 --- a/ui/app/templates/allocations/allocation/task/index.hbs +++ b/ui/app/templates/allocations/allocation/task/index.hbs @@ -54,8 +54,8 @@ {{if row.model.isDynamic "Yes" "No"}} {{row.model.name}} - - {{model.allocation.node.address}}:{{row.model.port}} + + {{network.ip}}:{{row.model.port}} diff --git a/ui/tests/acceptance/task-detail-test.js b/ui/tests/acceptance/task-detail-test.js index e475e840b4c4..ee9e83821f5d 100644 --- a/ui/tests/acceptance/task-detail-test.js +++ b/ui/tests/acceptance/task-detail-test.js @@ -2,7 +2,6 @@ import { click, findAll, currentURL, find, visit } from 'ember-native-dom-helper import { test } from 'qunit'; import moduleForAcceptance from 'nomad-ui/tests/helpers/module-for-acceptance'; import moment from 'moment'; -import ipParts from 'nomad-ui/utils/ip-parts'; let allocation; let task; @@ -120,10 +119,10 @@ test('the addresses table lists all reserved and dynamic ports', function(assert }); test('each address row shows the label and value of the address', function(assert) { - const node = server.db.nodes.find(allocation.nodeId); const taskResources = allocation.taskResourcesIds .map(id => server.db.taskResources.find(id)) .findBy('name', task.name); + const networkAddress = taskResources.resources.Networks[0].IP; const reservedPorts = taskResources.resources.Networks[0].ReservedPorts; const dynamicPorts = taskResources.resources.Networks[0].DynamicPorts; const address = reservedPorts.concat(dynamicPorts).sortBy('Label')[0]; @@ -141,7 +140,7 @@ test('each address row shows the label and value of the address', function(asser ); assert.equal( addressRow.querySelector('[data-test-task-address-address]').textContent.trim(), - `${ipParts(node.httpAddr).address}:${address.Value}`, + `${networkAddress}:${address.Value}`, 'Value' ); }); From 002d2fb8eb3820665886413b5c83bb36a396066b Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Mon, 4 Jun 2018 16:30:34 -0700 Subject: [PATCH 2/2] Remove test for removed behavior --- ui/tests/acceptance/allocation-detail-test.js | 48 +------------------ 1 file changed, 1 insertion(+), 47 deletions(-) diff --git a/ui/tests/acceptance/allocation-detail-test.js b/ui/tests/acceptance/allocation-detail-test.js index bfb8821fdbd3..d612eb68838c 100644 --- a/ui/tests/acceptance/allocation-detail-test.js +++ b/ui/tests/acceptance/allocation-detail-test.js @@ -1,6 +1,6 @@ import $ from 'jquery'; import { assign } from '@ember/polyfills'; -import { click, findAll, currentURL, find, visit, waitFor } from 'ember-native-dom-helpers'; +import { click, findAll, currentURL, find, visit } from 'ember-native-dom-helpers'; import { test } from 'qunit'; import moduleForAcceptance from 'nomad-ui/tests/helpers/module-for-acceptance'; import moment from 'moment'; @@ -164,52 +164,6 @@ test('when the allocation is not found, an error message is shown, but the URL p }); }); -moduleForAcceptance('Acceptance | allocation detail (loading states)', { - beforeEach() { - server.create('agent'); - - node = server.create('node'); - job = server.create('job', { groupCount: 0 }); - allocation = server.create('allocation', 'withTaskWithPorts'); - }, -}); - -test('when the node the allocation is on has yet to load, address links are in a loading state', function(assert) { - server.get('/node/:id', { timing: true }); - - visit(`/allocations/${allocation.id}`); - - waitFor('[data-test-port]').then(() => { - assert.ok( - find('[data-test-port]') - .textContent.trim() - .endsWith('...'), - 'The address is in a loading state' - ); - assert.notOk( - find('[data-test-port]').querySelector('a'), - 'While in the loading state, there is no link to the address' - ); - - server.pretender.requestReferences.forEach(({ request }) => { - server.pretender.resolve(request); - }); - - andThen(() => { - const taskResources = allocation.taskResourcesIds - .map(id => server.db.taskResources.find(id)) - .sortBy('name')[0]; - const port = taskResources.resources.Networks[0].ReservedPorts[0]; - const addressText = find('[data-test-port]').textContent.trim(); - - assert.ok(addressText.includes(port.Label), `Found label ${port.Label}`); - assert.ok(addressText.includes(port.Value), `Found value ${port.Value}`); - assert.ok(addressText.includes(node.httpAddr.match(/(.+):.+$/)[1]), 'Found the node address'); - assert.ok(find('[data-test-port]').querySelector('a'), 'Link to address found'); - }); - }); -}); - moduleForAcceptance('Acceptance | allocation detail (rescheduled)', { beforeEach() { server.create('agent');