LINXD-1312: Update simulator to use setting.testing_period if the option exists in config.settings

This commit is contained in:
2020-04-09 17:02:44 +03:00
parent fec3bd2f48
commit b2cd8ae36b
168 changed files with 5892 additions and 279 deletions

View File

@ -288,10 +288,10 @@ class Asset {
console.log(chalk.green(`Check to see if a record was created for the unit id: ${this.id} | name: ${this.assetProps.name}`));
let startDate = parseInt(this.startTime) - 5000;
let stopDate = parseInt(+new Date() + 30 * 1000);
setTimeout(() => { this._getRecord(startDate, stopDate); }, 3000);
setTimeout(() => { this._getRecord(startDate, stopDate, this.configs); }, 3000);
}
_getRecord(startDate, stopDate) {
_getRecord(startDate, stopDate, configs) {
console.log(`${this.apiEndpoint}/asset-history/${this.id}/call-history/${startDate}/${stopDate}/10`);
@ -328,19 +328,16 @@ class Asset {
utils.writeErrorLog(`ERROR_RECORDER`);
}
// DEBUG
// console.log('this.id', this.id)
// console.log('Math.max(...this.configs.assets.ids', Math.max(...this.configs.assets.ids))
// console.log('this.id === Math.max(...this.configs.assets.ids', this.id === Math.max(...this.configs.assets.ids))
if(this.id === Math.max(...this.configs.assets.ids)) {
setTimeout(() => {
utils.writeLog('STOP')
.then(() => {
process.exit(0);
});
}, 15000);
}
const settings = configs.settings;
let testing_period = 1000;
if(settings.hasOwnProperty('testing_period')) { testing_period = parseInt(settings.testing_period, 10); }
const exit_time = 13000 + testing_period;
setTimeout(() => {
utils.writeLog('STOP')
.then(() => {
process.exit(0);
});
}, exit_time);
}
);

View File

@ -105,7 +105,7 @@ class Mumble {
// n = current number of reconnect
// delay = delay used before reconnect
console.log('------ Server reconnect...');
utils.writeErrorLog(`ERROR_MUMBLE_RECONNECT`);
// utils.writeErrorLog(`ERROR_MUMBLE_RECONNECT`);
// utils.exitWriteErrorLog(`ERROR_MUMBLE_RECONNECT`);
})
.on('disconnect', function (err) {

View File

@ -34,9 +34,19 @@ class Simulator {
}
_start() {
const settings = this.configs.settings;
this.assetIds.forEach(id => {
new Asset(id, this.configs, this.token);
});
let testing_period = 1000;
if(settings.hasOwnProperty('testing_period')) {
testing_period = parseInt(settings.testing_period, 10);
}
testing_period = this._getRandomInt(testing_period);
setTimeout(() => { new Asset(id, this.configs, this.token); }, testing_period);
})
}
_getRandomInt(max) {
return Math.floor(Math.random() * Math.floor(max))
}
_manageLogs(callback) {