lbtest CLI
This lbtest tool is a simple command line interface for loadbooster services. It allows you to load test web applications in terminal or integrate loadbooster into your continuous development.
Installation
[sudo] npm install -g lbtest
lbtest configure
Enter your LoadBooster credentials
User Email: <YOUR_ACCOUNT_EMAIL>
API Token: <YOUR_API_TOKEN>
You need NodeJS and NPM to do that. And, you can find your api token in account page
Usage
The usage options are simple:
Usage: lbtest [options] [command]
Commands:
configure [options] Configure and validate your API token
run [options] Run a load test based on a CasperJs Script or a single URL
run-test-config [options] <string> Run a load test based on a test config
run-scenario [options] <id> Run a load test based on an user scenario
validate [options] Validate CasperJs Script or a user Scenario
test-config [options] Retrieve your test configs
scenario [options] Retrieve your scenarios
account Show information about your account
help [command] Output help information for this command
Options:
-h, --help output usage information
-V, --version output the version number
How to run a load test?
There are three sub commands to start a load test.
1. Run a load test based on a CasperJs Test Script or a single URL
lbtest run -p 1-100:1 -s ~/sample.js
lbtest run -r ireland -p 1-100:1,100:1 --url http://www.example.com
-p,--pattern: Ramp from s(start) to e(end) users in d minutes (s-e:d). i.e. -p 1-100:1,100:2, -p 100:2
-r,--region: california|oregon|virginia|ireland|singapore|tokyo|sydney|saopaulo
If the test status is finished, exit code is 0, failed, exit code is 1, SLA failed, exit code is 3.
Currently, lbtest only supports CasperJs Test Script. The following is a simple CasperJs Test Script sample:
var vuSn=casper.lbParams?casper.lbParams.vuSn:"1";
if (!casper.addMetricsData)
casper.addMetricsData=function(metrics,value) {console.log(metrics+":"+ value)};
if (casper.lbParams){
casper.lbParams.userDefinedMetrics= {
"Access homePage Count":{color:"blue"},
}
}
var accountEmail="test"+vuSn+"@loadbooster.com";
var x = require('casper').selectXPath;
casper.test.begin('step1: open todos demo', function(test) {
casper.start('https://loadbooster.com/todosdemo');
casper.addMetricsData("Access homePage Count",1, "your data 1", "your data 2");
casper.run(function() {test.done();});
});
2. Run a load test based on a existing test config
lbtest run-test-config -p 1-100:1 'YOUR-TEST-CONFIG-ID'
3. Run a load test based on an existing user scenario
lbtest run-scenario -p 1-100:1 'YOUR-SCENARIO-ID'
how to validate a test script?
Use 'lbtest validate' command to validate a test script file or an existing user scenario.
Usage: validate [options]
i.e. lbtest validate -s ~/sample.js
lbtest validate -u 'YOUR-SCENARIO-ID'
Options:
-h, --help output usage information
-s, --script <string> CasperJs Test Script to validate
-u, --user-scenario <string> Scenario Id to validate
-v, --verbose Enable Verbose Mode
A sample validate output result:
[INFO] initialing
[INFO] +5s running
[ERROR] +25s failed
*****The following is the validation result*****
Test file: /home/ubuntu/loadbooster/lib/runscript.js
****************** first time *******************
Access homePage Count:1
Access homePage Count:1
[ERROR] [phantom] casper.page.onResourceError:{"errorCode":404,"errorString":"Not Found","id":23,
"url":"http://loadbooster.com:18000/code/404"}
currentStep:{"type":"MainScript","stepNo":2,"name":"step2: random error"}
License
(The MIT License)
Copyright (c) 2014 qinghai qinghai@loadbooster.com
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.