Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: Show allocation associations in the topo viz more often (and fix a bug) #9906

Merged
merged 2 commits into from
Jan 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions ui/app/components/topo-viz.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ export default class TopoViz extends Component {
});
}

// Only show the lines if the selected allocations are sparse (low count relative to the client count).
if (newAllocations.length < this.args.nodes.length * 0.75) {
// Only show the lines if the selected allocations are sparse (low count relative to the client count or low count generally).
if (newAllocations.length < 10 || newAllocations.length < this.args.nodes.length * 0.75) {
this.computedActiveEdges();
} else {
this.activeEdges = [];
Expand All @@ -237,6 +237,13 @@ export default class TopoViz extends Component {
this.viewportColumns = this.element.clientWidth < 900 ? 1 : 2;
}

@action
resizeEdges() {
if (this.activeEdges.length > 0) {
this.computedActiveEdges();
}
}

@action
computedActiveEdges() {
// Wait a render cycle
Expand Down
2 changes: 1 addition & 1 deletion ui/app/templates/components/topo-viz.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
</div>

{{#if this.activeAllocation}}
<svg data-test-allocation-associations class="chart topo-viz-edges" {{window-resize this.computedActiveEdges}}>
<svg data-test-allocation-associations class="chart topo-viz-edges" {{window-resize this.resizeEdges}}>
<g transform="translate({{this.edgeOffset.x}},{{this.edgeOffset.y}})">
{{#each this.activeEdges as |edge|}}
<path data-test-allocation-association class="edge" d={{edge}} />
Expand Down
18 changes: 18 additions & 0 deletions ui/tests/integration/components/topo-viz-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { module, test } from 'qunit';
import { triggerEvent } from '@ember/test-helpers';
import { setupRenderingTest } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
import { componentA11yAudit } from 'nomad-ui/tests/helpers/a11y-audit';
Expand Down Expand Up @@ -144,6 +145,10 @@ module('Integration | Component | TopoViz', function(hooks) {
assert.ok(TopoViz.allocationAssociationsArePresent);
assert.equal(TopoViz.allocationAssociations.length, selectedAllocations.length * 2);

// Lines get redrawn when the window resizes; make sure the lines persist.
await triggerEvent(window, 'resize');
assert.equal(TopoViz.allocationAssociations.length, selectedAllocations.length * 2);

await TopoViz.datacenters[0].nodes[0].memoryRects[0].select();
assert.notOk(TopoViz.allocationAssociationsArePresent);
});
Expand All @@ -152,10 +157,19 @@ module('Integration | Component | TopoViz', function(hooks) {
this.setProperties({
nodes: [node('dc1', 'node0', 1000, 500), node('dc1', 'node1', 1000, 500)],
allocations: [
// There need to be at least 10 sibling allocations to trigger this behavior
alloc('node0', 'job1', 'group', 100, 100),
alloc('node0', 'job1', 'group', 100, 100),
alloc('node0', 'job1', 'group', 100, 100),
alloc('node0', 'job1', 'group', 100, 100),
alloc('node0', 'job1', 'group', 100, 100),
alloc('node0', 'job1', 'group', 100, 100),
alloc('node1', 'job1', 'group', 100, 100),
alloc('node1', 'job1', 'group', 100, 100),
alloc('node1', 'job1', 'group', 100, 100),
alloc('node1', 'job1', 'group', 100, 100),
alloc('node1', 'job1', 'group', 100, 100),
alloc('node1', 'job1', 'group', 100, 100),
alloc('node0', 'job1', 'groupTwo', 100, 100),
],
onNodeSelect: sinon.spy(),
Expand All @@ -167,6 +181,10 @@ module('Integration | Component | TopoViz', function(hooks) {

await TopoViz.datacenters[0].nodes[0].memoryRects[0].select();
assert.equal(TopoViz.allocationAssociations.length, 0);

// Lines get redrawn when the window resizes; make sure that doesn't make the lines show up again
await triggerEvent(window, 'resize');
assert.equal(TopoViz.allocationAssociations.length, 0);
});

test('when one or more nodes are missing the resources property, those nodes are filtered out of the topology view and onDataError is called', async function(assert) {
Expand Down