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

4

1 回答 1

1

Try replacing your 'overridesPath' with this

 let overridesPath = ' --overrides ./services/' + argv.serviceName + '/overrides.slos.json';
于 2019-10-10T12:52:17.180 回答