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 lbtestlbtest configureEnter your LoadBooster credentialsUser 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
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, Selenium HTML Script or a single URL
lbtest run -p 1-100:1 -s ~/casperjs_sample.jslbtest run -p 1-100:1 -e ~/selenium_html_sample.htmllbtest 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 supports Selenium HTML Script and CasperJs Test Script. The following is a simple CasperJs Test Script sample:
var vuSn=casperlbParams?casperlbParamsvuSn:"1";if !casperaddMetricsData casper {console}; //sumType: "sum"|"min"|"max"|"avg" //default Value: {sumType:"sum", group:"", drawChart:true, color: undefined} //usage: casper.addMetricsData(metrics,metricsValue, yourValue1, yourValue2 ...); //metricsValue must be a number, your value can be any type.if casperlbParams casperlbParamsuserDefinedMetrics= "Access homePage Count":color:"blue" var accountEmail="test"+vuSn+"@loadbooster.com";//casper.options.stepTimeout = 3 * 60 * 1000; //default stepTimeout is 3 minutes. var x = selectXPath; caspertest;
2. Run a load test based on an 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 ~/casperjs-sample.js lbtest validate -e ~/selenium-sample.html lbtest validate -u 'YOUR-SCENARIO-ID' Options: -h, --help output usage information -s, --script <string> CasperJs Test Script to validate -e, --selenium-script <string> Selenium test
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/run_casper.js ****************** first time *******************# step1: open home page Access homePage Count:1# step2: random error 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.