mirror of
https://github.com/kemko/nomad.git
synced 2026-01-10 12:25:42 +03:00
Merge pull request #4369 from hashicorp/b-ui-use-network-ip
UI: Use the network ip for the task address instead of the node ip
This commit is contained in:
@@ -72,26 +72,20 @@
|
||||
<td data-test-time>{{moment-format row.model.events.lastObject.time "MM/DD/YY HH:mm:ss"}}</td>
|
||||
<td data-test-ports>
|
||||
<ul>
|
||||
{{#each row.model.resources.networks.firstObject.reservedPorts as |port|}}
|
||||
<li data-test-port>
|
||||
<strong>{{port.Label}}:</strong>
|
||||
{{#if row.model.allocation.node.address}}
|
||||
<a href="http://{{row.model.allocation.node.address}}:{{port.Value}}" target="_blank">{{row.model.allocation.node.address}}:{{port.Value}}</a>
|
||||
{{else}}
|
||||
...
|
||||
{{/if}}
|
||||
</li>
|
||||
{{/each}}
|
||||
{{#each row.model.resources.networks.firstObject.dynamicPorts as |port|}}
|
||||
<li>
|
||||
<strong>{{port.Label}}:</strong>
|
||||
{{#if row.model.allocation.node.address}}
|
||||
<a href="http://{{row.model.allocation.node.address}}:{{port.Value}}" target="_blank">{{row.model.allocation.node.address}}:{{port.Value}}</a>
|
||||
{{else}}
|
||||
...
|
||||
{{/if}}
|
||||
</li>
|
||||
{{/each}}
|
||||
{{#with row.model.resources.networks.firstObject as |network|}}
|
||||
{{#each network.reservedPorts as |port|}}
|
||||
<li data-test-port>
|
||||
<strong>{{port.Label}}:</strong>
|
||||
<a href="http://{{network.ip}}:{{port.Value}}" target="_blank">{{network.ip}}:{{port.Value}}</a>
|
||||
</li>
|
||||
{{/each}}
|
||||
{{#each network.dynamicPorts as |port|}}
|
||||
<li>
|
||||
<strong>{{port.Label}}:</strong>
|
||||
<a href="http://{{network.ip}}:{{port.Value}}" target="_blank">{{network.ip}}:{{port.Value}}</a>
|
||||
</li>
|
||||
{{/each}}
|
||||
{{/with}}
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -54,8 +54,8 @@
|
||||
<td data-test-task-address-is-dynamic>{{if row.model.isDynamic "Yes" "No"}}</td>
|
||||
<td data-test-task-address-name>{{row.model.name}}</td>
|
||||
<td data-test-task-address-address>
|
||||
<a href="http://{{model.allocation.node.address}}:{{row.model.port}}" target="_blank">
|
||||
{{model.allocation.node.address}}:{{row.model.port}}
|
||||
<a href="http://{{network.ip}}:{{row.model.port}}" target="_blank">
|
||||
{{network.ip}}:{{row.model.port}}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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'
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user