Acceptance tests for task group scaling
This commit is contained in:
parent
1cadcf90b8
commit
02fd45f02b
|
@ -11,6 +11,7 @@
|
|||
<Exec::OpenButton @job={{model.job}} @taskGroup={{model}} />
|
||||
{{#if model.scaling}}
|
||||
<StepperInput
|
||||
data-test-task-group-count-stepper
|
||||
@min={{model.scaling.min}}
|
||||
@max={{model.scaling.max}}
|
||||
@value={{model.count}}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { currentURL } from '@ember/test-helpers';
|
||||
import { currentURL, settled } from '@ember/test-helpers';
|
||||
import { module, test } from 'qunit';
|
||||
import { setupApplicationTest } from 'ember-qunit';
|
||||
import { setupMirage } from 'ember-cli-mirage/test-support';
|
||||
|
@ -11,6 +11,7 @@ let job;
|
|||
let taskGroup;
|
||||
let tasks;
|
||||
let allocations;
|
||||
let managementToken;
|
||||
|
||||
const sum = (total, n) => total + n;
|
||||
|
||||
|
@ -61,6 +62,8 @@ module('Acceptance | task group detail', function(hooks) {
|
|||
previousAllocation: allocations[0].id,
|
||||
});
|
||||
|
||||
managementToken = server.create('token');
|
||||
|
||||
window.localStorage.clear();
|
||||
});
|
||||
|
||||
|
@ -297,6 +300,59 @@ module('Acceptance | task group detail', function(hooks) {
|
|||
});
|
||||
});
|
||||
|
||||
test('the count stepper sends the appropriate POST request', async function(assert) {
|
||||
window.localStorage.nomadTokenSecret = managementToken.secretId;
|
||||
|
||||
job = server.create('job', {
|
||||
groupCount: 0,
|
||||
createAllocations: false,
|
||||
shallow: true,
|
||||
noActiveDeployment: true,
|
||||
});
|
||||
const scalingGroup = server.create('task-group', {
|
||||
job,
|
||||
name: 'scaling',
|
||||
count: 1,
|
||||
shallow: true,
|
||||
withScaling: true,
|
||||
});
|
||||
job.update({ taskGroupIds: [scalingGroup.id] });
|
||||
|
||||
await TaskGroup.visit({ id: job.id, name: scalingGroup.name });
|
||||
await TaskGroup.countStepper.increment.click();
|
||||
await settled();
|
||||
|
||||
const scaleRequest = server.pretender.handledRequests.find(req => req.url.endsWith('/scale'));
|
||||
const requestBody = JSON.parse(scaleRequest.requestBody);
|
||||
assert.equal(requestBody.Target.Group, scalingGroup.name);
|
||||
assert.equal(requestBody.Count, scalingGroup.count + 1);
|
||||
});
|
||||
|
||||
test('the count stepper is disabled when a deployment is running', async function(assert) {
|
||||
window.localStorage.nomadTokenSecret = managementToken.secretId;
|
||||
|
||||
job = server.create('job', {
|
||||
groupCount: 0,
|
||||
createAllocations: false,
|
||||
shallow: true,
|
||||
activeDeployment: true,
|
||||
});
|
||||
const scalingGroup = server.create('task-group', {
|
||||
job,
|
||||
name: 'scaling',
|
||||
count: 1,
|
||||
shallow: true,
|
||||
withScaling: true,
|
||||
});
|
||||
job.update({ taskGroupIds: [scalingGroup.id] });
|
||||
|
||||
await TaskGroup.visit({ id: job.id, name: scalingGroup.name });
|
||||
|
||||
assert.ok(TaskGroup.countStepper.input.isDisabled);
|
||||
assert.ok(TaskGroup.countStepper.increment.isDisabled);
|
||||
assert.ok(TaskGroup.countStepper.decrement.isDisabled);
|
||||
});
|
||||
|
||||
test('when the job for the task group is not found, an error message is shown, but the URL persists', async function(assert) {
|
||||
await TaskGroup.visit({ id: 'not-a-real-job', name: 'not-a-real-task-group' });
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ export default scope => ({
|
|||
blur: blurrable(),
|
||||
value: value(),
|
||||
esc: triggerable('keydown', '', { eventProperties: { keyCode: 27 } }),
|
||||
isDisabled: attribute('disabled'),
|
||||
},
|
||||
|
||||
decrement: {
|
||||
|
|
|
@ -12,6 +12,7 @@ import {
|
|||
import allocations from 'nomad-ui/tests/pages/components/allocations';
|
||||
import error from 'nomad-ui/tests/pages/components/error';
|
||||
import pageSizeSelect from 'nomad-ui/tests/pages/components/page-size-select';
|
||||
import stepperInput from 'nomad-ui/tests/pages/components/stepper-input';
|
||||
import LifecycleChart from 'nomad-ui/tests/pages/components/lifecycle-chart';
|
||||
|
||||
export default create({
|
||||
|
@ -21,6 +22,8 @@ export default create({
|
|||
|
||||
search: fillable('.search-box input'),
|
||||
|
||||
countStepper: stepperInput('[data-test-task-group-count-stepper]'),
|
||||
|
||||
tasksCount: text('[data-test-task-group-tasks]'),
|
||||
cpu: text('[data-test-task-group-cpu]'),
|
||||
mem: text('[data-test-task-group-mem]'),
|
||||
|
|
Loading…
Reference in a new issue