alexfernandez / loadtest

Runs a load test on the selected URL. Fast and easy to use. Can be integrated in your own workflow using the API.
MIT License
2.55k stars 204 forks source link

Configuration result is immutable #233

Open ruud00000 opened 4 months ago

ruud00000 commented 4 months ago

I would like to run [loadtest][1] (command npx loadtest http://localhost:3000/endpoint) on production server with configuration file .loadtestrc:

{
    I would like to run loadtest (command  npx loadtest http://localhost:3000/endpoint ) on production server with configuration file .loadtestrc:

 
{
    "method": "POST",
    "body": {
        "to": "example@hotmail.com",
        "subject": "Loadtest",
        "text": "Loadtest text"
    },
    "headers": {
        "Content-Type": "application/json",
        "Accept": "application/json"
    },
    "maxRequests": 1,
    "concurrency": 1
   }

but that gives error "Configuration result is immutable".

How can I solve that?

Also tried running this from the command line:

loadtest https://localhost:3000/endpoint -c 1 -n 1 -H Accept:application/json -T application/json -P '{ "to": "example@hotmail.com", "subject": "Loadtest", "text": "Loadtest text" }' -m POST

but that gives the same error.

Also tried running node request-generator.js with content:

import {loadTest} from 'loadtest'

const options = {
    url: 'http://localhost:3000',
    concurrency: 1,
    method: 'POST',
    body:'',
    requestsPerSecond:1,
    maxSeconds:30,
    requestGenerator: (params, options, client, callback) => {
        const message = '{ "to": "example@hotmail.com", "subject": "Loadtest", "text": "Loadtest text" }';
        options.headers['Content-Length'] = message.length;
        options.headers['Content-Type'] = 'application/json';
        options.headers['Accept'] = 'application/json';
        options.body = message;
        options.path = '/send-email';
        const request = client(options, callback);
        request.write(message);
        return request;
    }
};

loadTest(options, (error, result) => {
    if (error) {
        return console.error('Got an error: %s', error);
    }
    console.log(result);
    console.log('Tests run successfully');
});

That also gives the same result.

On the server Ubuntu is running with NGINX.

BTW is this the place for asking for help using loadtest or is there a better place for that?

alexfernandez commented 4 months ago

Hi @ruud00000 ! Sorry for the delay. Yes, this is the right place.

I have tried creating the file .loadtestrc and it's failing for me too. I will fix it. Meanwhile please remove it and configure loadtest using the other options.

alexfernandez commented 4 months ago

Hi again! I just pushed a fix and published as 8.0.9, can you please try and see if it's working for you now? Otherwise I still suggest you remove .loadtestrc and try again.