1. What is pylot?
Pylot is a free open-source tool used to test the performance and scalability of Web Services. It runs HTTP load tests, which are useful for capacity planning, benchmarking, analysis, and system adjustment.
Pylot generates concurrent loads (HTTP requests), verifies server responses, and generates report measurements. Test Suite execution and monitoring, from a GUI or shell/console.
Pylot is developed based on python. Like the famous Apache stress testing tool AB, it runs on the command line by default. You can also use parameters to trigger the GUI, provided that wxpython is installed.
2. How does pylot work?
You start to define your test cases in an XML file (testcases. XML. Test Cases are used to verify the specified request (URL, method, body, etc ). It can verify the content matched by the regular expression of the server response and the HTTP status code. You can adjust the workload control GUI or command line settings of the load, and then start the test run (number of proxies, request interval, increase time, test time ). These settings allow you to experiment with models under different loads. When loading is run, it is passed to the load generation engine. Send HTTP requests to your web service at the same time. It generates real-time statistics and error reports during execution. This report can be easily monitored.
3. pylot application scenarios
Developers, testers, and performance engineers need to test and adjust the performance and scalability of their web services. Python programmers can also be integrated into larger test suites. Using this tool makes you more familiar with HTTP, XML, and performance testing.
4. Product Features
- HTTP and HTTPS (SSL) Support
- Multi-thread load generator
- Automatic cookie Processing
- Response verification and Regular Expression
- Execution/monitoring Console
- Real-time statistics
- Results reports and graphics
- Customized Timer
- Gui Mode
- Shell/Console mode
- Cross-platform
5. Getting Started Guide Platform: console and Blocking Mode
Python 2.5 + running on all platforms in the console and isolation mode can be installed. Windows XP, Vista, UBUNTU 8.04/8.10, Asus Eee PC, Mac OS testing.
Gui Mode
Pylot, Gui will run on all platforms supporting Python and wxWidgets. Most of the GUI tests are developed on windows, but Linux and Mac seem decent. The application code is pure Python and uses a cross-platform toolkit.
Step 4: Download and decompress the latest pylot release
Get the latest version: Download pylot
Step 2: Install Python 2nd +
Get setup starts from here: http://www.python.org/download
Step 2: Install wxpython (optional-for GUI Mode)
Get Installer: http://www.wxpython.org/download.php from here
Step 2: Install numpy (optional-for reporting to charts)
Get Installer: http://sourceforge.net/projects/numpy from here
Step 2: Install matplotlib (optional-used for reporting as a chart)
Get Installer: http://sourceforge.net/projects/matplotlib from here
Step 2: run the pylotgui mode:
> python run.py -G
Console and blocking mode-command line options:
Usage: Run. PY [Option] ARGs-a,-agent = num_agents agent Count-D,-Duration: when the test time is in seconds-R,-slope rise = slope rise: -I,-interval = interval: interval (in milliseconds)-X-xmlfile = test_case_xml: XML file-o, -output_dir = path: output directory-N,-= testname stands for: Name test-L,-log_msgs: Log message-B,-blocking: Blocking Mode-G,-Gui: start Gui-P,-Port port: XML-RPC listening port
Remotely start pylot:
, Pylot contains a XML-RPC server that can be started so that you can start testing with remote clients.
Configuration Options:
The file/CORE/config. py contains some global configuration options. You can set some defauls and change some behaviors. If these options are specified on the command line, they are overwritten.
AGENTS = 1DURATION = 60 # secsRAMPUP = 0 # secsINTERVAL = 0 # millisecsTC_XML_FILENAME = 'testcases.xml'OUTPUT_DIR = NoneTEST_NAME = NoneLOG_MSGS = FalseGENERATE_RESULTS = TrueSHUFFLE_TESTCASES = False # randomize order of testcases per agentWAITFOR_AGENT_FINISH = True # wait for last requests to complete before stoppingSMOOTH_TP_GRAPH = 1 # secs. smooth/dampen throughput graph based on an intervalSOCKET_TIMEOUT = 300 # secsCOOKIES_ENABLED = TrueHTTP_DEBUG = False # only useful when combined with blocking mode BLOCKING = False # stdout blocked until test finishes, then result is returned as XMLGUI = False
Use pylot
Step 1: Create a test case
In the test case named "testcases. xml", or specify a different XML file on the command line to declare an XML file. This is understandable by the format test engine.
Use the following syntax to define a test example. Only URL elements are required.
<case> <url>URL</url> <method>HTTP METHOD</method> <body>REQUEST BODY CONTENT</body> <add_header>ADDITIONAL HTTP HEADER</add_header> <verify>STRING OR REGULAR EXPRESSION</verify> <verify_negative>STRING OR REGULAR EXPRESSION</verify_negative> <timer_group>TIMER GROUP NAME</timer_group></case>
The following is an example of the simplest possible test case file. It contains a test case that will be executed continuously during the trial run. The test case contains the service tested under a URL. Because the body does not have a method or definition, it will send an http get to this resource by default. Because there is no authentication definition, it will pass/failure test case based on the HTTP status code (pass if the status is <400 ).
<testcases> <case> <url>http://www.example.com/foo</url> </case></testcases>
We can add both positive and negative verification. A positive validation is that the response body must contain a string or regular expression. Negative verification is a string or regular expression and must not be included in the response body.
<case> <url>http://www.goldb.org/foo</url> <verify>Copyright.*Corey Goldberg</verify> <verify_negative>Error</verify_negative><case>
Cookies:
Cookies are automatically processed. If you receive a response with the "set cookie" header, the cookie will be set in the header for subsequent requests and sent back.
Example: Yahoo search Web Service (rest API)
Yahoo provides various rest web services to access search results. In this example, I will show you how to create a pylot rest API for interactive test cases.
The following is a simple GET request for the service:
http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=YahooDemo&query=foo
Applying for a pylot test case is as follows:
<case> <url>http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=YahooDemo&query=foo</url></case>
Note the escape code of the symbol (&) URL: "&"
Some characters ("<" and "&") of becasue are invalid XML files. Since we are in a definig test case in an XML document, we must avoid these symbolic codes or place them in a CDATA section.
Yahoo also allows post data blocks to pass query parameters. In this case, we must also change the "content type" HTTP header: "application/X-WWW form, which is subject to urlencoded ". (Pylot is text/XML by default)
The following is a POST request to the service:
<case> <url>http://search.yahooapis.com/WebSearchService/V1/webSearch</url> <method>POST</method> <body><![CDATA[appid=YahooDemo&query=webinject]]></body> <add_header>Content-type: application/x-www-form-urlencoded</add_header></case>
Now, we know how to create a separate test case file, which contains several such files. In this example, in our test, the file contains Yahoo and other search queries: "rich", "bar", "Baz"
<testcases> <case> <url>http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=YahooDemo&query=foo</url> </case> <case> <url>http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=YahooDemo&query=bar</url> </case> <case> <url>http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=YahooDemo&query=baz</url> </case></testcases>
Example: Soap API
When talking about any http api, we can simulate our test cases. This example shows how to send requests to a soap service. The SOAP envelope we need to send will be encapsulated in the http post body.
<case> <url>http://www.example.org/StockPrice</url> <method>POST</method> <add_header>Content-Type: application/soap+xml; charset=utf-8</add_header> <body><! [CDATA[ <!-- This is the SOAP Envelope --> <?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Body xmlns:m="http://www.example.org/stock"> <m:GetStockPrice> <m:StockName>IBM</m:StockName> </m:GetStockPrice> </soap:Body> </soap:Envelope> ]]> </body></case>
For example, set static variables/parameters
You can define global parameters in your test case file. This is very useful. If you have a value shared between some tests, you often change. In the following example, we define a "http_server" parameter and then use this token in a test case.
<testcases> <param name="http_server" value="http://www.example.com" /> <case> <url>${http_server}/foo</url> </case></testcases>
For example, file-based HTTP payload
You may want to store post data in an external file instead of directly declaring it in your test case XML file. This is very useful if you have a very large post body or binary data to be sent cannot be embedded into XML. Use the following syntax to post data from a file at run.
<case> <url>http://www.example.com/foo</url> <method>POST</method> <body file="./myfile.dat"></body></case>
Step 2: Model workload Solution
Defines the controls used by the workload on the user interface. Use the following options. You can create a steady state or add load test.
- Proxy: Run as a proxy (virtual user)
- Slope risingThe time span proxy starts. They will be evenly distributed throughout this period. (See the notes below)
- TheInterval: Interval. Requests by each user proxy have a uniform interval of time (unless the response is made, the natural time interval defined in the document for analyzing slow response times)
- Playback time: Time Span Test
Step 2: execution and monitoring
Running Mode
- Console mode: During the test, you can view Real-time statistics on the user interface (UI)
- Blocking Mode: Stdout is blocked until the test ends. The returned result is XML.
- Gui Mode: GUI for managing and running tests
When the test ends, an HTML report is automatically generated, indicating the test results and charts.
Step 2: view the result
After the test is complete, the results directory is created and a report is generated automatically to summarize the test results. It includes various statistics and charts, response time and throughput. The sample of the result report can be seen here:
Report sample
Pylot results are written to CSV text files, so you can import them to your favorite workbook to process numbers, generate statistics, and create charts.