Skip to Content
Technical Articles

Automated Performance Testing of SAP Public OData APIs – Part I

Hello Knowledge Enthusiasts,

This blog is my attempt to walk you through on the usage of how SAP API HUB can be used for Automated Performance testing of OData.

Problem Statement : Can we Automate Performance Testing of (Whitelisted) Public OData API’s?

To further elaborate is there an E2E Automation with a simplified and unified solution approach where User(s) can select API’s/ Runs/Target System and which offers flexibility to execute anywhere , anytime and with no external tool dependency (Postman or Advanced REST Client)

Introduction

Many of us know these and use them daily its only a refresher ..

Application-programming interface (API) is a set of programming instructions and standards for accessing a Web-based software application or Web tool.

API is a software-to-software interface & not an UI. With APIs, applications talk to each other without any user knowledge or intervention.

JSON (JavaScript Object Notation) is a lightweight, text-based, language-independent data exchange format that is easy for humans and machines to read and write.

JSON represents two structured types:

  • Objects : An object is an unordered collection of zero or more name/value pairs.
  • Arrays :   An array is an ordered sequence of zero or more values.

The values can be strings, numbers, Boolean, null, and these two structured types.

Now let’s understand OData itself for which i would like to use an existing blog where it is structurally explained on the necessary information:

https://blogs.sap.com/2013/10/03/lets-talk-odata-shall-we/

Next , let’s look at SAP API Hub itself and what it offers

https://api.sap.com/package/SAPS4HANACloud?section=Artifacts

 

Here i have selected SAP S/4 HANA Cloud

 

Our scope is limited to only OData : we know OData is ideal for creating own Fiori apps and mashups

After the user logs in into API HUB and having selecting an OData API , User can perform for e.g: a GET request on Sandbox by clicking on Try out (as shown in the screenshot below)

 

 

 

Results of this operation:

Yes, it was successful but no details on the count of result set , how long it took to process (performance) nor can we iterate it more than once

 

Count is for a different example(other than the one shown above)

 

Metadata Structure (for the count displayed above)

 

Isn’t the above a manual approach where user has to select , click on try out, what if the user wanted to run iterations and select their own target system (as shown below) ,

Well API Hub isn’t specifically designed to perform this/carry out this functionality easily

 

Now , lets proceed to the technical details , our scope is limited to only GET requests

As we already know GET does the following:

Resource GET
http://example.com/api/resource/ Lists a details and perhaps URIs of the resources in this collection.
http://example.com/api/resource/123/ Retrieves a specific item in the collection.

 

Additionally for the user its not easy/intelligent to keep selecting every single/required OData manually as shown below :

Screenshot below shows the entities for our illustration (Total of 5)

1 /A_SalesOrderWithoutCharge indicates API end point without parameters (volume of the result set is high)

2 /A_SalesOrderWithoutCharge(‘{SalesOrderWithoutCharge}’) indicates API end point with parameters ( can retrieve top1)

 

Available API Endpoints
https://{host}:{port}/sap/opu/odata/sap/API_SALES_ORDER_WITHOUT_CHARGE_SRV

On the browser it would be displayed as below :

Below is the OData Service details of API_CUSTOMER_MATERIAL_SRV on sandbox :

 

On a Target system you’ll specify the host and port :

 

Now let us move onto the Performance aspect

Quick info on Performance Statistics

You can request the performance statistics from the SAP NetWeaver Gateway framework for each Odata request without activating the Performance Trace tool.

To do this, you have to add the URL parameter “?sap-statistics=true” at the end of your URL independent of whether it is an HTTP method GET, POST, PUT, MERGE, PATCH or DELETE.

The SAP NetWeaver Gateway framework will provide the performance statistics to the consumer in the HTTP response header in following format:

HTTP Header Name:   sapgw-statistics
HTTP Header Value:   gwtotal=152,gwhub=106,gwrfcoh=10,gwbe=30,gwapp=6

Description:

gwtotal    Total processing time of the current OData request
gwhub     Processing time in SAP NetWeaver Gateway hub system
gwrfcoh   RFC & network overhead for the communication between the hub and the backend system
gwbe       Processing time in SAP NetWeaver Gateway framework in backend system(without application time)
gwapp     Processing time in application (Data Provider)

To Manually test the OData Service :

For a simple check if the service was activated and can be accessed, enter /n/IWFND/MAINT_SERVICE as OK code, hit RETURN, click on search and input API_SALES_ORDER_WITHOUT_CHARGE_SRV

 

Select service API_SALES_ORDER_WITHOUT_CHARGE_SRV from the remaining services in column Technical Service Name of the Service Catalog list, and choose SAP Gateway Client.

Choose Execute to check if you get any response from the service (using HTTP Method GET).

The result should look like the screenshot below.

To check if any sample data was successfully generated, choose EntitySets, and in the pop-up an entity set from the list,

After choosing your entity set, click on Execute. A bigger payload should be displayed with product data in the HTTP response.

 

 

The same HTTP response is displayed as output which is seen when using the SAP Gateway Client for testing.

 

sap-statistics=true

 

Please click on Part-II which will walk you through on the solution and implementation

Thanks,

Dilip Mamidela

SAP Labs India

Be the first to leave a comment
You must be Logged on to comment or reply to a post.