1

I need to run a CasperJS script many times at different moments to simulate simultaneous connections on my website. The script is connecting to my website and do some others actions and I want to see if the server can handle it. I know it is possible to do that using NodeJS (CasperJS, parallel browsing WITH the testing framework check the response) and his child_process module, but I couldn't succeed to do it from now. I want to launch a couple of process every 5 secs until I have X process launch at the same time. I would like an example of doing this using this pseudo code logic.

var deth = 8;
var factor = 2;

var spawn = require('child_process').spawn;

function launchXProcess(nb_process)
{
    for (var i = 1; i <= nb_process; i++) {
        // spawn a new process 'casperjs scritp.js'
        // log the process outputs
        // keep going
    }
}

function newPoolOfProcess(i)
{
    // First time
    if (i === 1) {
        launchXProcess(i);
        i++;
        // wait 5 sec and launch the next one
        setTimeout(newPoolOfProcess(i), 5000);
    }

    // Reach the last pool, launch it and exit
    if (i === deth) {
        launchXProcess(i);
        process.exit(code = 0);
    } else {
        launchXProcess(i);
        i *= factor
        // wait 5 sec and launch the next one
        setTimeout(newPoolOfProcess(i), 5000);
    }
}

// start
newPoolOfProcess(1);

Following this logic at a T moment I will have many process connected to my website. The CasperJS script is taking more than a minute to be completed to make sure I will have many process connected before its done. I have tried to use the spawn method from the chil_process but without success. Please show me how to complete that, thanks

Community
  • 1
  • 1
TuZ
  • 83
  • 1
  • 4
  • Just throw your site on Reddit, it's the best stress test around. – Etheryte Aug 06 '14 at 09:26
  • If you only have one server where your caspers are running, this will likely not stress test your website, because there are multiple (headless) browsers running. Compared to a lightweight website, you will not get any meaningful results besides a high memory and CPU consumption because of your caspers. – Artjom B. Aug 06 '14 at 09:45
  • So what can I do to simulate that? – TuZ Aug 06 '14 at 09:57

0 Answers0