From 628fef86a554f627528edcafd96abb0f20f00844 Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Thu, 29 Oct 2020 11:28:41 -0700 Subject: [PATCH] Add namespace and task states query params to the topo viz route --- ui/app/routes/topology.js | 6 +++++- ui/tests/acceptance/topology-test.js | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/ui/app/routes/topology.js b/ui/app/routes/topology.js index 84875ceae..d97c85644 100644 --- a/ui/app/routes/topology.js +++ b/ui/app/routes/topology.js @@ -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)); } diff --git a/ui/tests/acceptance/topology-test.js b/ui/tests/acceptance/topology-test.js index 79ca675a8..0dae1269b 100644 --- a/ui/tests/acceptance/topology-test.js +++ b/ui/tests/acceptance/topology-test.js @@ -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);