2020-07-25 04:36:43 +00:00
|
|
|
import { Factory, trait } from 'ember-cli-mirage';
|
|
|
|
import faker from 'nomad-ui/mirage/faker';
|
|
|
|
|
|
|
|
const REF_TIME = new Date();
|
|
|
|
|
|
|
|
export default Factory.extend({
|
|
|
|
time: () => faker.date.past(2 / 365, REF_TIME) * 1000000,
|
|
|
|
count: () => faker.random.number(10),
|
|
|
|
previousCount: () => faker.random.number(10),
|
2020-07-28 04:29:22 +00:00
|
|
|
error: () => faker.random.number(10) > 8,
|
2020-07-25 04:36:43 +00:00
|
|
|
message: 'Sample message for a job scale event',
|
2020-07-28 04:29:22 +00:00
|
|
|
meta: () =>
|
|
|
|
faker.random.number(10) < 8
|
|
|
|
? {
|
|
|
|
'nomad_autoscaler.count.capped': true,
|
|
|
|
'nomad_autoscaler.count.original': 0,
|
|
|
|
'nomad_autoscaler.reason_history': ['scaling down because factor is 0.000000'],
|
|
|
|
}
|
|
|
|
: {},
|
2020-08-05 03:20:53 +00:00
|
|
|
|
|
|
|
afterCreate(scaleEvent) {
|
|
|
|
if (scaleEvent.error) {
|
|
|
|
scaleEvent.update({ count: null });
|
|
|
|
}
|
|
|
|
},
|
2020-07-25 04:36:43 +00:00
|
|
|
});
|