Integrate web API performance monitoring in SoapUI

Overview

Server-side applications provide web-based APIs that allow other clients (like mobile or AppMon Clients) to use their functionality. Functional testing of those APIs is typically performed using tools like JMeter or SoapUI. With the Web API Test Category, the performance of those API can also be monitored continuously.

Requirements

Goal

This tutorial shows how to:

  • Create a SoapUI project that tests a web service.
  • Register the functional test with AppMon to retrieve performance metrics.

The tutorial accesses an easyTravel URI (/services/JourneyService/findJourneys) where you can find journeys filtered by start date, end date, and location, and get a list of journeys in XML. If you have easyTravel running on your machine you can try to access http://localhost:8080/services/JourneyService/findJourneys?destination=New%20York&fromDate=1406282400000&toDate=1437818400000 for a list of journeys to New York. If this call fails, make sure you have easyTravel started and running on port 8080.

Create a SoapUI project that tests the functionality of a web service

  1. Create a SoapUI project for the easyTravel findJourneys Service. Once this is done, click Submit request to specified endpoint URL to verify that the request and the response are correct.

  2. Add a request to a new Test suite and a Test case, as shown in the following:

  3. Add an assertion for this test case, such as one where the response contains the string New York.

  4. Run the test and verify the assertion works.

Monitor the functional test with AppMon

This example uses the system profile supplied with easyTravel. If you prefer to use your own system profile, make sure you have the Servlet sensor enabled:

Add a service end point for the AppMon REST service testrun http://<server>:8020/rest/management/profiles/<profilename>/testruns into the project. When registering the test run, you can pass in additional metadata such as build number. See REST Interfaces for Test Automation for more information.

Change the method used to POST to register a new test run. You can specify the body of this request either as XML or JSON, This example shows XML used to register a test run for Web API tests, running on platform Linux 64-bits and for version 5.1.1500.1234:

<testRun category="webapi" platform="Windows" versionMajor="5" versionMinor="1" versionRevision="1500" versionBuild="1234" />

Do not forget to set up the authentication details (AppMon Server user - per default admin/admin). Click Submit request to specified endpoint URL to verify that you are getting a correct response from the AppMon Server.

Create a new Custom Property into the Test Case FindJourneys to store the unique test run ID sent by the AppMon Server.

In the test case, insert a new step (REST Test Request) at the beginning to register the test run to the AppMon Server.

Add a step Property Transfer to extract the test run ID (xml attribute) from the request's response and save it into the previously defined property testRunId.
  

Finally, add a last step (Groovy Script) to set the right header tag for AppMon:

import com.eviware.soapui.support.types.StringToStringMap
def headers = new StringToStringMap()
headers.put("X-dynaTrace","NA=Find journeys;TR=" + testRunner.testCase.getPropertyValue("testRunId") + ";RC=200")
testRunner.testCase.getTestStepByName("FindJourneys - Request 1").testRequest.setRequestHeaders(headers)

Run the test a few times to have more data in the Test Automation Dashlet.

You can see request results in the Test Automation Dashlet. Open the AppMon Client and open the Test Automation Dashlet from the Cockpit.

Adjust the time filter to the last 30 minutes to make it easier to find the requests you just executed. Your requests display with a list of metrics and a historic chart of metric values:

Download

Sample SoapUI Project