Mirage updates for task group scaling and scaling post endpoint

This commit is contained in:
Michael Lange
2020-06-17 18:07:53 -07:00
parent 9a344e468e
commit a1f1079cfd
2 changed files with 31 additions and 0 deletions

View File

@@ -172,6 +172,10 @@ export default function() {
return okEmpty();
});
this.post('/job/:id/scale', function({ jobs }, { params }) {
return this.serialize(jobs.find(params.id));
});
this.delete('/job/:id', function(schema, { params }) {
const job = schema.jobs.find(params.id);
job.update({ status: 'dead' });

View File

@@ -18,6 +18,8 @@ export default Factory.extend({
volumes: () => ({}),
}),
withScaling: faker.random.boolean,
volumes: makeHostVolumes(),
// Directive used to control whether or not allocations are automatically
@@ -38,6 +40,31 @@ export default Factory.extend({
let taskIds = [];
let volumes = Object.keys(group.volumes);
if (group.withScaling) {
group.update({
scaling: {
Min: 1,
Max: 5,
Policy: faker.random.boolean() && {
EvaluationInterval: '10s',
Cooldown: '2m',
Check: {
avg_conn: {
Source: 'prometheus',
Query:
'scalar(avg((haproxy_server_current_sessions{backend="http_back"}) and (haproxy_server_up{backend="http_back"} == 1)))',
Strategy: {
'target-value': {
target: 20,
},
},
},
},
},
},
});
}
if (!group.shallow) {
const tasks = provide(group.count, () => {
const mounts = faker.helpers