: Undefined index: mts_posttop_adcode in /home1/jccrosby/public_html/admin.crsby.com/wp-content/themes/playbook/single.php
on line 19
Testing service APIs is a big pain. More so when you are using a format that isn’t widely supported by testing tools. Load testing AMF services…ugh.
Recently I was tasked with finding a way to load test some AMF services built using PHP. In the past I had used jMeter for load testing. So, that is where I started. jMeter is a good tool, but not for AMF. A few extensions for jMeter have been built for AMF, but they are a PIA to setup.
I found a couple of tools that have made load testing AMF serivices a snap. Both of the tools are from SmartBear, and both are open source and free to use. Bonus!
- Tool one: soapUI
- Tool two: loadUI
The following are the basic steps to get a simple load test set up:
Setting up the project
- Download and install soapUI (you’ll need Java too).
- Start up soapUI.
- Create a new soapUI project – File -> ‘New soapUI Project’
- Name your project and click ‘OK’.
- Add a new TestSuite – right-click your new project -> ‘New TestSuite’
- Name your TestSuite and click ‘OK’
- Create a new TestCase – right-click the new TestSuite -> ‘New TestCase’
- Name your TestCase and click ‘OK’
- Expand the Test Case
- Right-click ‘Test Steps’, select ‘Add Step’ -> AMF Request.
- Your project is set up and ready-to-roll. Save it.
Configuring the AMF Request
Now that we have a request set up we need to specify the arguments for the call. The is where I had troubles with jMeter – setting up the data required proxies and additional tools. There was no where to easily create & edit AMF object to pass along in the AMF request.
Enter soapUI. Lets say we have an API method called getMonkeys(). getMonkeys() requires an array of ids that specifies what monkeys we want in the list. The name of this parameter is ‘monkeyIds’.
- In soapUI, right-click the AMF Request object and select ‘Open Editor’. You should see a window similar to the following:
- In the text field for ‘Endpoint’ enter your service end point. For example: http://www.thekuroko.com/Monkey/amfphp/gateway.php
- Enter the name of your call in the text field for the AMF Call setting: For example Monkey.getMonkeys
- Just under the entry for Endpoint add property to the property list for the call by clicking the ‘Add Property’ button.
- Enter ‘monkeyIds’ as the name of the property. If the value for this property were a simple value we could enter it into the value column. We need an array though.
- To set the value for the property we’ll use the script window just under the property list.
- In the script window, enter the following to create an Array that contains the id values 1,2 & 3 and assigns that Array to the monkeyIds parameter.
parameters[“monkeyIds”] = [1,2,3];
- That is it. The call for getMonkeys() is set up.
- To test the call click the little green arrow in the top left of the AMF Request editor.
- If your paths and data are set up correctly, you should see an XML formatted response in the window to the right of the Script editor.
Creating and Running a Load Test
So now we have a test for a service, but we wanted to get some load testing done. If you’re looking for quick and simple load testing, you don’t have to go much further than soapUI itself. To create a load test in soapUI:
- Right-click the ‘Load Tests’ node under ‘Test Steps’ -> ‘New Load Test’
- Name the new load test and click ‘OK’
- 2 steps. That’s it, the load test is set up. You can run the test “as-is”.
Now, this is a very simple load test and there are a ton of things you can add to the test to improve it to build more useful load tests within soapUI.
Running Load Test with loadUI
The other tool I mentioned, loadUI, is built to integrate with soapUI and make load testing “easier and more efficient”.
Once loadUI is installed can you execute the test case that you set up in soapUI in loadUI.
- Right-click the test case, then select ‘Run with loadUI’.
- You will be prompted to save the project, do so.
- Select ‘Fixed Rate for the ‘Default Generator’ selection – this will determine how “clients” are generated for the load test.
- Select ‘Statistics’ for the ‘Default Statistics’ selection – this will display a graph for the load test metrics.
- Click ‘OK’.
- loadUI will launch.
- Click the ‘Play/Stop’ button to start the load test.
You can play around with the Generator settings to change the rate at which clients are created to see changes in the load test results while the load test is running.
To view a report of the results you can click the ‘Summary Report’ button in the top right of the loadUI interface.
This is just a simple load test and there are plenty of additional settings, assertions and analysis tools that can be added, adjusted and tweaked to improve the validity of the load tests.
Our next step is to integrate the tests into our Continuous Integration (CI) system. We use Jenkins and I saw this post about Automating loadUI and Jenkins (formerly Hudson). So, in theory it can be done. I’ll let you know what we get worked out on that end when we get there.
So far, I’m pretty excited about the two tools. They are very useful, and free to boot. Hey SmartBear – you really are smart, thank you – you rule.
: Undefined variable: defaults in /home1/jccrosby/public_html/admin.crsby.com/wp-content/themes/playbook/functions.php
on line 340
: Undefined index: mts_postend_adcode in /home1/jccrosby/public_html/admin.crsby.com/wp-content/themes/playbook/single.php
on line 28