From a1f1079cfd133e1f14bea2e35ffa0968792fa141 Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Wed, 17 Jun 2020 18:07:53 -0700 Subject: [PATCH] Mirage updates for task group scaling and scaling post endpoint --- ui/mirage/config.js | 4 ++++ ui/mirage/factories/task-group.js | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/ui/mirage/config.js b/ui/mirage/config.js index 8d5e30c9e..80c521791 100644 --- a/ui/mirage/config.js +++ b/ui/mirage/config.js @@ -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' }); diff --git a/ui/mirage/factories/task-group.js b/ui/mirage/factories/task-group.js index 8d443c133..92a031944 100644 --- a/ui/mirage/factories/task-group.js +++ b/ui/mirage/factories/task-group.js @@ -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