Skip to content

Commit

Permalink
Add reset route, add details to status, add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
binarymist committed Oct 20, 2021
1 parent 9a8cb87 commit 5aaec7d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/api/orchestration/models/orchestrate.app.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ const reset = async () => {
const { testerConfig: { url, resetTesterRoute } } = internals;
internals.jobTestSessions = [];
await Wreck.post(`${url}${resetTesterRoute}`, { headers: { 'content-type': 'application/vnd.api+json' }, payload: '{}' });
log.info('Reset command has been sent to Tester.', { tags: ['orchestrate.app'] });
};

module.exports = {
Expand Down
4 changes: 4 additions & 0 deletions src/api/orchestration/models/orchestrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ class Orchestrate {
return { dataMap, allTestSessionsOfAllTestersFinished };
}

status() {
return !this.#initTesterResponsesForCli ? 'orchestrator is ready to take orders.' : 'Test Run is in progress.';
}

// Could potentially be exposed as part of the API for CLI to invoke if the back-end gets messed up.
async resetTesters({ level = 'soft' }) {
const { cleanUpAfterTestRun: cleanUpTesterWatcherAfterTestRun } = this.#testerWatcher;
Expand Down
1 change: 1 addition & 0 deletions src/api/orchestration/models/orchestrate.tls.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const reset = async () => {
const { testerConfig: { url, resetTesterRoute } } = internals;
internals.jobTestSessions = [];
await Wreck.post(`${url}${resetTesterRoute}`, { headers: { 'content-type': 'application/vnd.api+json' }, payload: '{}' });
log.info('Reset command has been sent to Tester.', { tags: ['orchestrate.tls'] });
};

module.exports = {
Expand Down
15 changes: 14 additions & 1 deletion src/api/orchestration/routes/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

const Boom = require('@hapi/boom'); // eslint-disable-line
const { validateTesterNameSessionId } = require('src/api/orchestration/schemas/testers');
const config = require('config/config');

const internals = {
validateTesterFeedback: {
Expand Down Expand Up @@ -85,5 +86,17 @@ module.exports = [{
}, {
method: 'GET',
path: '/status',
handler: () => 'orchestrator is up'
handler: (request) => {
const { server: { app: { model } } } = request;
return model.status();
}
}, {
// Only to be invoked when Testers are finished.
method: 'GET',
path: '/reset',
handler: async (request) => {
const { server: { app: { model } } } = request;
await model.resetTesters({ level: 'hard' });
return `Reset initiated. Please wait at least ${config.get('coolDown.timeout') / 1000} seconds before starting a Test Run.`;
}
}];

0 comments on commit 5aaec7d

Please sign in to comment.