Add namespace and task states query params to the topo viz route

This commit is contained in:
Michael Lange 2020-10-29 11:28:41 -07:00
parent dc8e20206d
commit 628fef86a5
2 changed files with 25 additions and 1 deletions

View File

@ -20,7 +20,11 @@ export default class TopologyRoute extends Route.extend(WithForbiddenState) {
model() {
return RSVP.hash({
jobs: this.store.findAll('job'),
allocations: this.store.query('allocation', { resources: true }),
allocations: this.store.query('allocation', {
resources: true,
task_states: false,
namespace: '*',
}),
nodes: this.store.query('node', { resources: true }),
}).catch(notifyForbidden(this));
}

View File

@ -3,6 +3,7 @@ import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
import Topology from 'nomad-ui/tests/pages/topology';
import queryString from 'query-string';
// TODO: Once we settle on the contents of the info panel, the contents
// should also get acceptance tests.
@ -30,6 +31,25 @@ module('Acceptance | topology', function(hooks) {
assert.equal(Topology.infoPanelTitle, 'Cluster Details');
});
test('all allocations for all namespaces and all clients are queried on load', async function(assert) {
server.createList('node', 3);
server.createList('allocation', 5);
await Topology.visit();
const requests = this.server.pretender.handledRequests;
assert.ok(requests.findBy('url', '/v1/nodes?resources=true'));
const allocationsRequest = requests.find(req => req.url.startsWith('/v1/allocations'));
assert.ok(allocationsRequest);
const allocationRequestParams = queryString.parse(allocationsRequest.url.split('?')[1]);
assert.deepEqual(allocationRequestParams, {
namespace: '*',
task_states: 'false',
resources: 'true',
});
});
test('when an allocation is selected, the info panel shows information on the allocation', async function(assert) {
server.createList('node', 1);
server.createList('allocation', 5);