2018-07-09 19:59:40 +00:00
|
|
|
import config from 'nomad-ui/config/environment';
|
2020-08-24 16:59:55 +00:00
|
|
|
import * as topoScenarios from './topo';
|
2021-10-07 21:11:38 +00:00
|
|
|
import * as sysbatchScenarios from './sysbatch';
|
2020-03-25 12:51:26 +00:00
|
|
|
import { pickOne } from '../utils';
|
2022-09-14 15:27:48 +00:00
|
|
|
import faker from 'nomad-ui/mirage/faker';
|
2018-07-09 19:59:40 +00:00
|
|
|
|
|
|
|
const withNamespaces = getConfigValue('mirageWithNamespaces', false);
|
|
|
|
const withTokens = getConfigValue('mirageWithTokens', true);
|
2018-08-10 02:57:21 +00:00
|
|
|
const withRegions = getConfigValue('mirageWithRegions', false);
|
2018-07-09 19:59:40 +00:00
|
|
|
|
2022-08-09 17:17:55 +00:00
|
|
|
export const allScenarios = {
|
2018-07-09 19:59:40 +00:00
|
|
|
smallCluster,
|
|
|
|
mediumCluster,
|
|
|
|
largeCluster,
|
|
|
|
massiveCluster,
|
|
|
|
allJobTypes,
|
|
|
|
allNodeTypes,
|
2019-06-13 18:15:42 +00:00
|
|
|
everyFeature,
|
2018-07-09 19:59:40 +00:00
|
|
|
emptyCluster,
|
2022-08-09 17:17:55 +00:00
|
|
|
variableTestCluster,
|
2022-08-29 18:04:55 +00:00
|
|
|
servicesTestCluster,
|
2022-12-06 17:45:36 +00:00
|
|
|
policiesTestCluster,
|
2020-08-24 16:59:55 +00:00
|
|
|
...topoScenarios,
|
2021-10-07 21:11:38 +00:00
|
|
|
...sysbatchScenarios,
|
2018-07-09 19:59:40 +00:00
|
|
|
};
|
|
|
|
|
2022-04-27 16:11:24 +00:00
|
|
|
const scenario =
|
|
|
|
getScenarioQueryParameter() ||
|
|
|
|
getConfigValue('mirageScenario', 'emptyCluster');
|
2018-07-09 19:59:40 +00:00
|
|
|
|
2022-04-27 16:11:24 +00:00
|
|
|
export default function (server) {
|
2018-07-09 19:59:40 +00:00
|
|
|
const activeScenario = allScenarios[scenario];
|
|
|
|
if (!activeScenario) {
|
|
|
|
throw new Error(
|
|
|
|
`Selected Mirage scenario does not exist.\n\n${scenario} not in list: \n\n\t${Object.keys(
|
|
|
|
allScenarios
|
|
|
|
).join('\n\t')}`
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (withNamespaces) createNamespaces(server);
|
|
|
|
if (withTokens) createTokens(server);
|
2018-08-10 02:57:21 +00:00
|
|
|
if (withRegions) createRegions(server);
|
2018-07-09 19:59:40 +00:00
|
|
|
activeScenario(server);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Scenarios
|
|
|
|
|
|
|
|
function smallCluster(server) {
|
2022-09-14 15:27:48 +00:00
|
|
|
faker.seed(1);
|
2021-04-29 20:00:59 +00:00
|
|
|
server.create('feature', { name: 'Dynamic Application Sizing' });
|
2021-12-08 00:51:17 +00:00
|
|
|
server.createList('agent', 3, 'withConsulLink', 'withVaultLink');
|
2018-07-09 19:59:40 +00:00
|
|
|
server.createList('node', 5);
|
2022-04-27 16:11:24 +00:00
|
|
|
server.createList('job', 1, { createRecommendations: true });
|
2022-08-29 18:04:55 +00:00
|
|
|
server.create('job', {
|
|
|
|
withGroupServices: true,
|
|
|
|
withTaskServices: true,
|
|
|
|
name: 'Service-haver',
|
|
|
|
id: 'service-haver',
|
|
|
|
namespaceId: 'default',
|
|
|
|
});
|
2019-07-31 00:21:42 +00:00
|
|
|
server.createList('allocFile', 5);
|
|
|
|
server.create('allocFile', 'dir', { depth: 2 });
|
2020-03-25 12:51:26 +00:00
|
|
|
server.createList('csi-plugin', 2);
|
2022-05-30 17:10:44 +00:00
|
|
|
server.createList('variable', 3);
|
2022-07-08 14:08:02 +00:00
|
|
|
|
|
|
|
const variableLinkedJob = server.db.jobs[0];
|
|
|
|
const variableLinkedGroup = server.db.taskGroups.findBy({
|
|
|
|
jobId: variableLinkedJob.id,
|
|
|
|
});
|
|
|
|
const variableLinkedTask = server.db.tasks.findBy({
|
|
|
|
taskGroupId: variableLinkedGroup.id,
|
|
|
|
});
|
2022-06-07 01:42:23 +00:00
|
|
|
[
|
|
|
|
'a/b/c/foo0',
|
|
|
|
'a/b/c/bar1',
|
|
|
|
'a/b/c/d/e/foo2',
|
|
|
|
'a/b/c/d/e/bar3',
|
|
|
|
'a/b/c/d/e/f/foo4',
|
|
|
|
'a/b/c/d/e/f/g/foo5',
|
|
|
|
'a/b/c/x/y/z/foo6',
|
|
|
|
'a/b/c/x/y/z/bar7',
|
|
|
|
'a/b/c/x/y/z/baz8',
|
|
|
|
'w/x/y/foo9',
|
|
|
|
'w/x/y/z/foo10',
|
|
|
|
'w/x/y/z/bar11',
|
|
|
|
'just some arbitrary file',
|
|
|
|
'another arbitrary file',
|
|
|
|
'another arbitrary file again',
|
2022-06-10 14:05:34 +00:00
|
|
|
].forEach((path) => server.create('variable', { id: path }));
|
2020-03-25 12:51:26 +00:00
|
|
|
|
2022-08-09 17:17:55 +00:00
|
|
|
server.create('variable', {
|
|
|
|
id: `nomad/jobs/${variableLinkedJob.id}/${variableLinkedGroup.name}/${variableLinkedTask.name}`,
|
2022-08-15 15:56:09 +00:00
|
|
|
namespace: variableLinkedJob.namespace,
|
2022-08-09 17:17:55 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
server.create('variable', {
|
|
|
|
id: `nomad/jobs/${variableLinkedJob.id}/${variableLinkedGroup.name}`,
|
2022-08-15 15:56:09 +00:00
|
|
|
namespace: variableLinkedJob.namespace,
|
2022-08-09 17:17:55 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
server.create('variable', {
|
|
|
|
id: `nomad/jobs/${variableLinkedJob.id}`,
|
2022-08-15 15:56:09 +00:00
|
|
|
namespace: variableLinkedJob.namespace,
|
2022-08-09 17:17:55 +00:00
|
|
|
});
|
|
|
|
|
2022-08-15 21:24:34 +00:00
|
|
|
server.create('variable', {
|
|
|
|
id: 'Auto-conflicting Variable',
|
|
|
|
namespace: 'default',
|
|
|
|
});
|
|
|
|
|
2022-04-27 16:11:24 +00:00
|
|
|
// #region evaluations
|
|
|
|
|
|
|
|
// Branching: a single eval that relates to N-1 mutually-unrelated evals
|
|
|
|
const NUM_BRANCHING_EVALUATIONS = 3;
|
|
|
|
Array(NUM_BRANCHING_EVALUATIONS)
|
|
|
|
.fill()
|
|
|
|
.map((_, i) => {
|
|
|
|
return {
|
|
|
|
evaluation: server.create('evaluation', {
|
|
|
|
id: `branching_${i}`,
|
|
|
|
previousEval: i > 0 ? `branching_0` : '',
|
|
|
|
jobID: pickOne(server.db.jobs).id,
|
|
|
|
}),
|
|
|
|
|
|
|
|
evaluationStub: server.create('evaluation-stub', {
|
|
|
|
id: `branching_${i}`,
|
|
|
|
previousEval: i > 0 ? `branching_0` : '',
|
|
|
|
status: 'failed',
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
})
|
|
|
|
.map((x, i, all) => {
|
|
|
|
x.evaluation.update({
|
|
|
|
relatedEvals:
|
|
|
|
i === 0
|
|
|
|
? all.filter((_, j) => j !== 0).map((e) => e.evaluation)
|
|
|
|
: all.filter((_, j) => j !== i).map((e) => e.evaluation),
|
|
|
|
});
|
|
|
|
return x;
|
|
|
|
});
|
|
|
|
|
|
|
|
// Linear: a long line of N related evaluations
|
|
|
|
const NUM_LINEAR_EVALUATIONS = 20;
|
|
|
|
Array(NUM_LINEAR_EVALUATIONS)
|
|
|
|
.fill()
|
|
|
|
.map((_, i) => {
|
|
|
|
return {
|
|
|
|
evaluation: server.create('evaluation', {
|
|
|
|
id: `linear_${i}`,
|
|
|
|
previousEval: i > 0 ? `linear_${i - 1}` : '',
|
|
|
|
jobID: pickOne(server.db.jobs).id,
|
|
|
|
}),
|
|
|
|
|
|
|
|
evaluationStub: server.create('evaluation-stub', {
|
|
|
|
id: `linear_${i}`,
|
|
|
|
previousEval: i > 0 ? `linear_${i - 1}` : '',
|
|
|
|
nextEval: `linear_${i + 1}`,
|
|
|
|
status: 'failed',
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
})
|
|
|
|
.map((x, i, all) => {
|
|
|
|
x.evaluation.update({
|
|
|
|
relatedEvals: all.filter((_, j) => i !== j).map((e) => e.evaluation),
|
|
|
|
});
|
|
|
|
return x;
|
|
|
|
});
|
|
|
|
|
|
|
|
// #endregion evaluations
|
|
|
|
|
2020-03-25 12:51:26 +00:00
|
|
|
const csiAllocations = server.createList('allocation', 5);
|
|
|
|
const volumes = server.schema.csiVolumes.all().models;
|
2022-04-27 16:11:24 +00:00
|
|
|
csiAllocations.forEach((alloc) => {
|
2020-03-25 12:51:26 +00:00
|
|
|
const volume = pickOne(volumes);
|
|
|
|
volume.writeAllocs.add(alloc);
|
|
|
|
volume.readAllocs.add(alloc);
|
|
|
|
volume.save();
|
|
|
|
});
|
2022-11-28 15:44:52 +00:00
|
|
|
|
|
|
|
server.create('auth-method', {name: 'vault'});
|
|
|
|
server.create('auth-method', {name: 'auth0'});
|
|
|
|
server.create('auth-method', {name: 'cognito'});
|
|
|
|
|
2018-07-09 19:59:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function mediumCluster(server) {
|
2021-12-09 00:13:22 +00:00
|
|
|
server.createList('agent', 3, 'withConsulLink', 'withVaultLink');
|
2017-09-19 14:47:10 +00:00
|
|
|
server.createList('node', 50);
|
2018-07-09 19:59:40 +00:00
|
|
|
server.createList('job', 25);
|
|
|
|
}
|
2017-10-07 01:27:36 +00:00
|
|
|
|
2022-08-09 17:17:55 +00:00
|
|
|
function variableTestCluster(server) {
|
2022-09-14 15:27:48 +00:00
|
|
|
faker.seed(1);
|
2022-08-09 17:17:55 +00:00
|
|
|
createTokens(server);
|
|
|
|
createNamespaces(server);
|
|
|
|
server.createList('agent', 3, 'withConsulLink', 'withVaultLink');
|
|
|
|
server.createList('node', 5);
|
|
|
|
server.createList('job', 3);
|
|
|
|
server.createList('variable', 3);
|
|
|
|
// server.createList('allocFile', 5);
|
|
|
|
// server.create('allocFile', 'dir', { depth: 2 });
|
|
|
|
// server.createList('csi-plugin', 2);
|
|
|
|
|
|
|
|
const variableLinkedJob = server.db.jobs[0];
|
|
|
|
const variableLinkedGroup = server.db.taskGroups.findBy({
|
|
|
|
jobId: variableLinkedJob.id,
|
|
|
|
});
|
|
|
|
const variableLinkedTask = server.db.tasks.findBy({
|
|
|
|
taskGroupId: variableLinkedGroup.id,
|
|
|
|
});
|
|
|
|
[
|
|
|
|
'a/b/c/foo0',
|
|
|
|
'a/b/c/bar1',
|
|
|
|
'a/b/c/d/e/foo2',
|
|
|
|
'a/b/c/d/e/bar3',
|
|
|
|
'a/b/c/d/e/f/foo4',
|
|
|
|
'a/b/c/d/e/f/g/foo5',
|
|
|
|
'a/b/c/x/y/z/foo6',
|
|
|
|
'a/b/c/x/y/z/bar7',
|
|
|
|
'a/b/c/x/y/z/baz8',
|
|
|
|
'w/x/y/foo9',
|
|
|
|
'w/x/y/z/foo10',
|
|
|
|
'w/x/y/z/bar11',
|
|
|
|
].forEach((path) => server.create('variable', { id: path }));
|
|
|
|
|
|
|
|
server.create('variable', {
|
|
|
|
id: `nomad/jobs/${variableLinkedJob.id}/${variableLinkedGroup.name}/${variableLinkedTask.name}`,
|
2022-08-15 15:56:09 +00:00
|
|
|
namespace: variableLinkedJob.namespace,
|
2022-08-09 17:17:55 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
server.create('variable', {
|
|
|
|
id: `nomad/jobs/${variableLinkedJob.id}/${variableLinkedGroup.name}`,
|
2022-08-15 15:56:09 +00:00
|
|
|
namespace: variableLinkedJob.namespace,
|
2022-08-09 17:17:55 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
server.create('variable', {
|
|
|
|
id: `nomad/jobs/${variableLinkedJob.id}`,
|
2022-08-15 15:56:09 +00:00
|
|
|
namespace: variableLinkedJob.namespace,
|
|
|
|
});
|
|
|
|
|
|
|
|
server.create('variable', {
|
|
|
|
id: 'just some arbitrary file',
|
|
|
|
namespace: 'namespace-2',
|
|
|
|
});
|
|
|
|
|
|
|
|
server.create('variable', {
|
|
|
|
id: 'another arbitrary file',
|
|
|
|
namespace: 'namespace-2',
|
|
|
|
});
|
|
|
|
|
|
|
|
server.create('variable', {
|
|
|
|
id: 'another arbitrary file again',
|
|
|
|
namespace: 'namespace-2',
|
2022-08-09 17:17:55 +00:00
|
|
|
});
|
2022-08-15 21:24:34 +00:00
|
|
|
|
|
|
|
server.create('variable', {
|
|
|
|
id: 'Auto-conflicting Variable',
|
|
|
|
namespace: 'default',
|
|
|
|
});
|
2022-08-09 17:17:55 +00:00
|
|
|
}
|
|
|
|
|
2022-12-06 17:45:36 +00:00
|
|
|
function policiesTestCluster(server) {
|
|
|
|
faker.seed(1);
|
|
|
|
createTokens(server);
|
|
|
|
server.createList('agent', 3, 'withConsulLink', 'withVaultLink');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-29 18:04:55 +00:00
|
|
|
function servicesTestCluster(server) {
|
2022-09-14 15:27:48 +00:00
|
|
|
faker.seed(1);
|
2022-08-29 18:04:55 +00:00
|
|
|
server.create('feature', { name: 'Dynamic Application Sizing' });
|
|
|
|
server.createList('agent', 3, 'withConsulLink', 'withVaultLink');
|
|
|
|
server.createList('node', 5);
|
|
|
|
server.createList('job', 1, { createRecommendations: true });
|
|
|
|
server.create('job', {
|
|
|
|
withGroupServices: true,
|
|
|
|
withTaskServices: true,
|
|
|
|
name: 'Service-haver',
|
|
|
|
id: 'service-haver',
|
|
|
|
namespaceId: 'default',
|
|
|
|
});
|
|
|
|
server.createList('allocFile', 5);
|
|
|
|
server.create('allocFile', 'dir', { depth: 2 });
|
|
|
|
server.createList('csi-plugin', 2);
|
|
|
|
server.createList('variable', 3);
|
|
|
|
|
|
|
|
const variableLinkedJob = server.db.jobs[0];
|
|
|
|
const variableLinkedGroup = server.db.taskGroups.findBy({
|
|
|
|
jobId: variableLinkedJob.id,
|
|
|
|
});
|
|
|
|
const variableLinkedTask = server.db.tasks.findBy({
|
|
|
|
taskGroupId: variableLinkedGroup.id,
|
|
|
|
});
|
|
|
|
[
|
|
|
|
'a/b/c/foo0',
|
|
|
|
'a/b/c/bar1',
|
|
|
|
'a/b/c/d/e/foo2',
|
|
|
|
'a/b/c/d/e/bar3',
|
|
|
|
'a/b/c/d/e/f/foo4',
|
|
|
|
'a/b/c/d/e/f/g/foo5',
|
|
|
|
'a/b/c/x/y/z/foo6',
|
|
|
|
'a/b/c/x/y/z/bar7',
|
|
|
|
'a/b/c/x/y/z/baz8',
|
|
|
|
'w/x/y/foo9',
|
|
|
|
'w/x/y/z/foo10',
|
|
|
|
'w/x/y/z/bar11',
|
|
|
|
'just some arbitrary file',
|
|
|
|
'another arbitrary file',
|
|
|
|
'another arbitrary file again',
|
|
|
|
].forEach((path) => server.create('variable', { id: path }));
|
|
|
|
|
|
|
|
server.create('variable', {
|
|
|
|
id: `nomad/jobs/${variableLinkedJob.id}/${variableLinkedGroup.name}/${variableLinkedTask.name}`,
|
|
|
|
namespace: variableLinkedJob.namespace,
|
|
|
|
});
|
|
|
|
|
|
|
|
server.create('variable', {
|
|
|
|
id: `nomad/jobs/${variableLinkedJob.id}/${variableLinkedGroup.name}`,
|
|
|
|
namespace: variableLinkedJob.namespace,
|
|
|
|
});
|
|
|
|
|
|
|
|
server.create('variable', {
|
|
|
|
id: `nomad/jobs/${variableLinkedJob.id}`,
|
|
|
|
namespace: variableLinkedJob.namespace,
|
|
|
|
});
|
|
|
|
|
|
|
|
server.create('variable', {
|
|
|
|
id: 'Auto-conflicting Variable',
|
|
|
|
namespace: 'default',
|
|
|
|
});
|
|
|
|
|
|
|
|
// #region evaluations
|
|
|
|
|
|
|
|
// Branching: a single eval that relates to N-1 mutually-unrelated evals
|
|
|
|
const NUM_BRANCHING_EVALUATIONS = 3;
|
|
|
|
Array(NUM_BRANCHING_EVALUATIONS)
|
|
|
|
.fill()
|
|
|
|
.map((_, i) => {
|
|
|
|
return {
|
|
|
|
evaluation: server.create('evaluation', {
|
|
|
|
id: `branching_${i}`,
|
|
|
|
previousEval: i > 0 ? `branching_0` : '',
|
|
|
|
jobID: pickOne(server.db.jobs).id,
|
|
|
|
}),
|
|
|
|
|
|
|
|
evaluationStub: server.create('evaluation-stub', {
|
|
|
|
id: `branching_${i}`,
|
|
|
|
previousEval: i > 0 ? `branching_0` : '',
|
|
|
|
status: 'failed',
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
})
|
|
|
|
.map((x, i, all) => {
|
|
|
|
x.evaluation.update({
|
|
|
|
relatedEvals:
|
|
|
|
i === 0
|
|
|
|
? all.filter((_, j) => j !== 0).map((e) => e.evaluation)
|
|
|
|
: all.filter((_, j) => j !== i).map((e) => e.evaluation),
|
|
|
|
});
|
|
|
|
return x;
|
|
|
|
});
|
|
|
|
|
|
|
|
// Linear: a long line of N related evaluations
|
|
|
|
const NUM_LINEAR_EVALUATIONS = 20;
|
|
|
|
Array(NUM_LINEAR_EVALUATIONS)
|
|
|
|
.fill()
|
|
|
|
.map((_, i) => {
|
|
|
|
return {
|
|
|
|
evaluation: server.create('evaluation', {
|
|
|
|
id: `linear_${i}`,
|
|
|
|
previousEval: i > 0 ? `linear_${i - 1}` : '',
|
|
|
|
jobID: pickOne(server.db.jobs).id,
|
|
|
|
}),
|
|
|
|
|
|
|
|
evaluationStub: server.create('evaluation-stub', {
|
|
|
|
id: `linear_${i}`,
|
|
|
|
previousEval: i > 0 ? `linear_${i - 1}` : '',
|
|
|
|
nextEval: `linear_${i + 1}`,
|
|
|
|
status: 'failed',
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
})
|
|
|
|
.map((x, i, all) => {
|
|
|
|
x.evaluation.update({
|
|
|
|
relatedEvals: all.filter((_, j) => i !== j).map((e) => e.evaluation),
|
|
|
|
});
|
|
|
|
return x;
|
|
|
|
});
|
|
|
|
|
|
|
|
// #endregion evaluations
|
|
|
|
|
|
|
|
const csiAllocations = server.createList('allocation', 5);
|
|
|
|
const volumes = server.schema.csiVolumes.all().models;
|
|
|
|
csiAllocations.forEach((alloc) => {
|
|
|
|
const volume = pickOne(volumes);
|
|
|
|
volume.writeAllocs.add(alloc);
|
|
|
|
volume.readAllocs.add(alloc);
|
|
|
|
volume.save();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-07-09 19:59:40 +00:00
|
|
|
// Due to Mirage performance, large cluster scenarios will be slow
|
|
|
|
function largeCluster(server) {
|
|
|
|
server.createList('agent', 5);
|
|
|
|
server.createList('node', 1000);
|
|
|
|
server.createList('job', 100);
|
|
|
|
}
|
|
|
|
|
|
|
|
function massiveCluster(server) {
|
|
|
|
server.createList('agent', 7);
|
|
|
|
server.createList('node', 5000);
|
|
|
|
server.createList('job', 2000);
|
|
|
|
}
|
2017-10-07 01:27:36 +00:00
|
|
|
|
2018-07-09 19:59:40 +00:00
|
|
|
function allJobTypes(server) {
|
2021-12-09 00:13:22 +00:00
|
|
|
server.createList('agent', 3, 'withConsulLink', 'withVaultLink');
|
2018-07-09 19:59:40 +00:00
|
|
|
server.createList('node', 5);
|
2017-10-14 18:01:28 +00:00
|
|
|
|
2018-07-09 19:59:40 +00:00
|
|
|
server.create('job', { type: 'service' });
|
|
|
|
server.create('job', { type: 'batch' });
|
|
|
|
server.create('job', { type: 'system' });
|
|
|
|
server.create('job', 'periodic');
|
|
|
|
server.create('job', 'parameterized');
|
2021-10-07 21:11:38 +00:00
|
|
|
server.create('job', 'periodicSysbatch');
|
|
|
|
server.create('job', 'parameterizedSysbatch');
|
2018-07-09 19:59:40 +00:00
|
|
|
server.create('job', { failedPlacements: true });
|
|
|
|
}
|
|
|
|
|
|
|
|
function allNodeTypes(server) {
|
2021-12-09 00:13:22 +00:00
|
|
|
server.createList('agent', 3, 'withConsulLink', 'withVaultLink');
|
2018-07-09 19:59:40 +00:00
|
|
|
|
|
|
|
server.create('node');
|
|
|
|
server.create('node', 'forceIPv4');
|
|
|
|
server.create('node', 'draining');
|
|
|
|
server.create('node', 'forcedDraining');
|
|
|
|
server.create('node', 'noDeadlineDraining');
|
|
|
|
server.create('node', 'withMeta');
|
|
|
|
|
|
|
|
server.createList('job', 3);
|
|
|
|
}
|
|
|
|
|
2019-06-13 18:15:42 +00:00
|
|
|
function everyFeature(server) {
|
2021-12-09 00:13:22 +00:00
|
|
|
server.createList('agent', 3, 'withConsulLink', 'withVaultLink');
|
2019-06-13 00:40:37 +00:00
|
|
|
|
|
|
|
server.create('node', 'forceIPv4');
|
|
|
|
server.create('node', 'draining');
|
|
|
|
server.create('node', 'forcedDraining');
|
|
|
|
server.create('node', 'noDeadlineDraining');
|
|
|
|
server.create('node', 'withMeta');
|
|
|
|
|
|
|
|
const job1 = server.create('job', {
|
|
|
|
type: 'service',
|
|
|
|
activeDeployment: true,
|
|
|
|
namespaceId: 'default',
|
|
|
|
createAllocations: false,
|
|
|
|
});
|
2022-04-27 16:11:24 +00:00
|
|
|
server.create('job', {
|
|
|
|
type: 'batch',
|
|
|
|
failedPlacements: true,
|
|
|
|
namespaceId: 'default',
|
|
|
|
});
|
2019-06-13 00:40:37 +00:00
|
|
|
server.create('job', { type: 'system', namespaceId: 'default' });
|
|
|
|
server.create('job', 'periodic', { namespaceId: 'default' });
|
|
|
|
server.create('job', 'parameterized', { namespaceId: 'default' });
|
|
|
|
|
|
|
|
server.create('allocation', 'rescheduled', { jobId: job1.id });
|
|
|
|
server.create('allocation', 'preempter', { jobId: job1.id });
|
|
|
|
server.create('allocation', 'preempted', { jobId: job1.id });
|
|
|
|
}
|
|
|
|
|
2018-07-09 19:59:40 +00:00
|
|
|
function emptyCluster(server) {
|
|
|
|
server.create('agent');
|
|
|
|
server.create('node');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Behaviors
|
|
|
|
|
|
|
|
function createTokens(server) {
|
2017-10-14 18:01:28 +00:00
|
|
|
server.createList('token', 3);
|
2022-05-17 18:52:14 +00:00
|
|
|
server.create('token', {
|
|
|
|
name: 'Secure McVariables',
|
|
|
|
id: '53cur3-v4r14bl35',
|
|
|
|
});
|
2022-08-09 17:17:55 +00:00
|
|
|
server.create('token', {
|
|
|
|
name: "Safe O'Constants",
|
|
|
|
id: 'f3w3r-53cur3-v4r14bl35',
|
|
|
|
});
|
2022-11-28 15:44:52 +00:00
|
|
|
server.create('token', {
|
|
|
|
name: 'Lazarus MacMarbh',
|
|
|
|
id: '3XP1R35-1N-3L3V3N-M1NU735',
|
|
|
|
});
|
2017-10-14 18:01:28 +00:00
|
|
|
logTokens(server);
|
|
|
|
}
|
|
|
|
|
2018-07-09 19:59:40 +00:00
|
|
|
function createNamespaces(server) {
|
|
|
|
server.createList('namespace', 3);
|
|
|
|
}
|
|
|
|
|
2018-08-10 02:57:21 +00:00
|
|
|
function createRegions(server) {
|
2022-04-27 16:11:24 +00:00
|
|
|
['americas', 'europe', 'asia', 'some-long-name-just-to-test'].forEach(
|
|
|
|
(id) => {
|
|
|
|
server.create('region', { id });
|
|
|
|
}
|
|
|
|
);
|
2018-08-10 02:57:21 +00:00
|
|
|
}
|
|
|
|
|
2017-10-14 18:01:28 +00:00
|
|
|
/* eslint-disable */
|
|
|
|
function logTokens(server) {
|
|
|
|
console.log('TOKENS:');
|
2022-04-27 16:11:24 +00:00
|
|
|
server.db.tokens.forEach((token) => {
|
2017-10-14 18:01:28 +00:00
|
|
|
console.log(`
|
|
|
|
Name: ${token.name}
|
|
|
|
Secret: ${token.secretId}
|
|
|
|
Accessor: ${token.accessorId}
|
|
|
|
|
|
|
|
`);
|
|
|
|
});
|
2017-09-19 14:47:10 +00:00
|
|
|
}
|
2018-07-09 19:59:40 +00:00
|
|
|
|
|
|
|
function getConfigValue(variableName, defaultValue) {
|
|
|
|
const value = config.APP[variableName];
|
|
|
|
if (value !== undefined) return value;
|
|
|
|
|
|
|
|
console.warn(
|
|
|
|
`No ENV.APP value set for "${variableName}". Defaulting to "${defaultValue}". To set a custom value, modify config/environment.js`
|
|
|
|
);
|
|
|
|
return defaultValue;
|
|
|
|
}
|
2020-11-30 14:12:15 +00:00
|
|
|
|
|
|
|
function getScenarioQueryParameter() {
|
|
|
|
const params = new URLSearchParams(window.location.search);
|
|
|
|
return params.get('mirage-scenario');
|
|
|
|
}
|
2017-10-14 18:01:28 +00:00
|
|
|
/* eslint-enable */
|