0

I want to run artillery command from gulp file based on argument passed from gulp command.

Command to run:

gulp runner --serviceName employeeServices --scenario create-employee-details --env staging

This should execute a command as below which is formed in gulp task (gulpfile.js)

artillery run -o report.json ./services/employeeServices/scenarios/create-employee-details.yml --config ./services/employeeServices/config.yml --overrides "$(cat ./services/employeeServices/overrides.slos.json)" -e staging

I am getting below error. Though JSON is valid for overrides.slos.json

The values of --overrides does not seem to be valid JSON

Code for gulpfile.js:

const gulp = require('gulp');
const yargs = require('yargs');
const path = require('path');
const cp= require('child_process');

gulp.task('runner', async (done) => {
    let execute;
    if (argv.serviceName === undefined) {
        console.log('<------FAILED: Mandatory to specify Service name for performance testing------>');
    } else {
        let scenarioPath = './services/' + argv.serviceName + '/scenarios/' + argv.scenario + '.yml';
        let configPath = ' --config ./services/' + argv.serviceName + '/config.yml';
        let overridesPath = ' --overrides "$(cat ./services/' + argv.serviceName + '/overrides.slos.json)"';
        let env = ' -e ' + argv.env;
        execute = 'artillery run -o report.json ' + scenarioPath + configPath + overridesPath + env;
    }

    cp.execSync(execute,{shell:true}, (error, stdout, stderr) => {
        console.log(`stdout: ${stdout}`);
        console.log(`stderr: ${stderr}`);
        if (error !== null) {
            console.log(`exec error: ${error}`);
        }
    })

    await done();
})

Desired Output: It should run the command as specified above

p2018
  • 125
  • 1
  • 12
  • try "./services/employeeServices/overrides.slos.json" instead of "$(cat ./services/employeeServices/overrides.slos.json)" – Sudhakar Ramasamy Oct 10 '19 at 12:03
  • @SudhakarRS - Got the same error: – p2018 Oct 10 '19 at 12:11
  • $ gulp runner --serviceName employeeServices --scenario create-employee-details --env staging [13:09:23] Using gulpfile C:\QE_Enablers\PerfTest\artillery-tests\demo-project-2\gulpfile.js [13:09:23] Starting 'runner'... [13:09:23] Finished 'runner' after 28 ms stdout: Error: The values of --overrides does not seem to be valid JSON. stderr: exec error: Error: Command failed: artillery run -o report.json ./services/employeeServices/scenarios/create-employee-details.yml --config ./services/employeeServices/config.yml --overrides "./services/employeeServices/overrides.slos.json" -e staging – p2018 Oct 10 '19 at 12:12
  • remove the quotes around overrides.slos.json and try ("./services/employeeServices/overrides.slos.json") – Sudhakar Ramasamy Oct 10 '19 at 12:17
  • @SudhakarRS, This time i got below error ````stderr: -e was unexpected at this time. exec error: Error: Command failed: artillery run -o report.json ./services/employeeServices/scenarios/create-employee-details.yml --config ./services/employeeServices/config.yml --overrides ("./services/employeeServices/overrides.slos.json") -e staging -e was unexpected at this time.```` – p2018 Oct 10 '19 at 12:33

1 Answers1

1

Try replacing your 'overridesPath' with this

 let overridesPath = ' --overrides ./services/' + argv.serviceName + '/overrides.slos.json';
Sudhakar Ramasamy
  • 1,736
  • 1
  • 8
  • 19
  • Same Error: ````[14:09:04] Finished 'runner' after 24 ms stdout: Error: The values of --overrides does not seem to be valid JSON. stderr: exec error: Error: Command failed: artillery run -o report.json ./services/employeeServices/scenarios/create-employee-details.yml --config ./services/employeeServices/config.yml --overrides ./services/employeeServices/overrides.slos.json -e staging```` – p2018 Oct 10 '19 at 13:12
  • @p2018 did you try running the same in terminal? – Sudhakar Ramasamy Oct 10 '19 at 13:37
  • @p2018 try giving the --overrides like this --overrides '{"config": {"phases": [{"duration": 10, "arrivalRate": 1}]}}' – Sudhakar Ramasamy Oct 10 '19 at 14:01
  • @p2018 Refer https://artillery.io/docs/cli-reference/#-overrides (Not sure if it supports JSON file input) – Sudhakar Ramasamy Oct 10 '19 at 14:03
  • It supports JSON...So if you paste this command directly in terminal , it will start running with out error..only when running through gulpfile by forming same path it fails. This will run directly ```artillery run -o report.json ./services/employeeServices/scenarios/create-employee-details.yml --config ./services/employeeServices/config.yml --overrides "$(cat ./services/employeeServices/overrides.slos.json)" -e staging ```` – p2018 Oct 10 '19 at 14:25