{"id":5288,"date":"2015-04-13T11:00:51","date_gmt":"2015-04-13T15:00:51","guid":{"rendered":"http:\/\/www.webperformance.com\/load-testing-tools\/blog\/?p=5288"},"modified":"2017-05-18T16:26:18","modified_gmt":"2017-05-18T20:26:18","slug":"web-services-load-testing","status":"publish","type":"post","link":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/2015\/04\/web-services-load-testing\/","title":{"rendered":"REST\/Web Services and API Load Testing"},"content":{"rendered":"<p style=\"text-align: left;\" align=\"CENTER\">In this post, I&#8217;ll discuss why web servers and API testing is important, a typical situation that a tester might experience, and how to perform web servers and API\u00a0testing with Web Performance Tester.<\/p>\n<p>Thorough web services\u00a0testing is necessary because it:<\/p>\n<ul>\n<li style=\"text-align: left;\">allows for identification of problems not revealed by GUI testing<\/li>\n<li style=\"text-align: left;\">reduces likelihood of unexpected breakages<\/li>\n<li style=\"text-align: left;\">improves ease of interaction with other applications<\/li>\n<li style=\"text-align: left;\">improves ease of future expansion<\/li>\n<\/ul>\n<p>API testing can be performed in several ways:<\/p>\n<ul>\n<li>Developers can create a webpage that generates a specific API call and displays results<\/li>\n<li>Testers can use a plugin like <a href=\"https:\/\/www.getpostman.com\">POSTMAN<\/a>, reducing the amount of code they personally write<\/li>\n<\/ul>\n<p>Applications such as Web Performance Tester generally perform either load testing or API testing but not both, and we often receive calls from users wondering why Web Performance doesn&#8217;t contain this function. However, Web Performance Tester can be configured to test the whether or not each call works (Functional &amp; QA Testing), as well as\u00a0the call&#8217;s speed (Load Testing with Web Performance Load Tester).<\/p>\n<h2 align=\"LEFT\"><strong>Sample Situation<\/strong><\/h2>\n<p>Testers often test calls with a large number of variables.\u00a0Rather than generate a call for each individual variable, the tester can use Web Performance Tester to automate the process by creating a dataset and running a custom load test that generates calls for a sequence of values.<\/p>\n<h2 align=\"LEFT\"><b>Testing API in Web Performance Tester<\/b><\/h2>\n<p>The following section contains four parts: 1) recording an API call, 2) creating a dataset, 3) editing the datasource, and 4) generating a sequence of calls using a custom dataset.<\/p>\n<p>For this example, we&#8217;ll test a link to a particular customer:<\/p>\n<p><a href=\"http:\/\/thomas-bayer.com\/sqlrest\/CUSTOMER\/35\">http:\/\/thomas-bayer.com\/sqlrest\/CUSTOMER\/35<\/a><\/p>\n<p>using the list of customers returned by:<\/p>\n<p><a href=\"http:\/\/thomas-bayer.com\/sqlrest\/CUSTOMER\/?sortBy=age&amp;country=US\">http:\/\/thomas-bayer.com\/sqlrest\/CUSTOMER\/?sortBy=age&amp;country=US<\/a><\/p>\n<p><em><span style=\"color: #000000;\"><b>NOTE: The following method is only applicable to \u201cVirtual Browser\u201d recordings.<\/b><\/span><\/em><\/p>\n<h3>Recording an API Call<\/h3>\n<p>Virtual browser recordings capture network connections. To capture API calls:<\/p>\n<p><strong>1.<\/strong> Click the &#8220;Record&#8221; button <img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5603 size-full\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2015\/04\/Recording-an-API-call-1-1.jpg\" alt=\"\" width=\"300\" height=\"90\" \/>and select a virtual browser.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5607 size-full\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2015\/04\/Recording-an-API-call-2-1.jpg\" alt=\"\" width=\"471\" height=\"198\" \/><\/p>\n<p><strong>2.<\/strong> Once your virtual browser loads, open your plugin of choice (I&#8217;ve used <a href=\"https:\/\/chrome.google.com\/webstore\/detail\/postman-rest-client\/fdmmgilgnpjigdojojpjoooidkmcomcm?hl=en\">POSTMAN<\/a>) and generate an HTTP request to\u00a0<a href=\"http:\/\/www.thomas-bayer.com\/sqlrest\/CUSTOMER\/35\">http:\/\/www.thomas-bayer.com\/sqlrest\/CUSTOMER\/35<\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5309 size-full\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2015\/04\/Recording-an-API-call-3.jpg\" alt=\"\" width=\"545\" height=\"141\" \/><\/p>\n<p><b>3.\u00a0<\/b>After\u00a0generating the request, stop the recording.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5609 size-full\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2015\/04\/Recording-an-API-call-4.jpg\" alt=\"\" width=\"229\" height=\"157\" \/><\/p>\n<ul>\n<li>To view information about recorded API calls, select the call.<\/li>\n<li>Then, in the inspection pane located in the lower half of the Web Performance application, select the \u201cHeaders\u201d Tab.<\/li>\n<\/ul>\n<p><em><strong>NOTE:<\/strong><\/em> While recording a virtual browser, Web Performance Tester records all network communications. As a result, you may find that Web Performance Tester recorded requests other than those generated by your plugin. You may remove the additional communications by narrowing the parameters in the \u201cConfigure Testcase New Recording\u201d popup, as shown below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5610\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2015\/04\/Recording-an-API-call-5.jpg\" alt=\"\" width=\"600\" height=\"385\" \/><\/p>\n<h3>Creating a New Dataset<\/h3>\n<p>Creating a custom dataset will allow you to replace a value in the recorded call with a sequence of values.<\/p>\n<p>To create a new dataset:<\/p>\n<p><strong>1.<\/strong> In the navigator pane located on the left side of the Web Performance application, click &#8220;New&#8221; -&gt; &#8220;Dataset.&#8221;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5611 size-full\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2015\/04\/Creating-a-Dataset-1.jpg\" alt=\"\" width=\"181\" height=\"223\" \/><\/p>\n<ul>\n<li>If you have multiple repositories open, click the name of the repository for which you&#8217;d like to add a new dataset, then follow the step above. Alternatively,\u00a0right click the &#8220;Dataset&#8221; folder for the active repository and select \u201cNew\u201d -&gt; \u201cNew Dataset.<\/li>\n<\/ul>\n<p><span style=\"color: #000000;\"><span style=\"font-family: arial, sans-serif;\"><span style=\"font-size: small;\"><strong>2.<\/strong> In the editor pane<\/span><\/span><\/span><b> <\/b><span style=\"color: #000000;\"><span style=\"font-family: arial, sans-serif;\"><span style=\"font-size: small;\">located in the top half of the Web Performance application, click the \u201cplus\u201d icon to \u201cAdd Dataset Field,\u201d\u00a0<\/span><\/span><\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5612\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2015\/04\/Creating-a-Dataset-2.jpg\" alt=\"\" width=\"600\" height=\"95\" \/><\/p>\n<p>and enter a name for the new field when prompted.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5613 size-full\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2015\/04\/Creating-a-Dataset-3.jpg\" alt=\"\" width=\"480\" height=\"170\" \/><\/p>\n<p><span style=\"color: #000000;\"><span style=\"font-family: arial, sans-serif;\"><span style=\"font-size: small;\"><strong>3.<\/strong> After adding a new field, select the column header<\/span><\/span><\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5614\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2015\/04\/Creating-a-Dataset-4.jpg\" alt=\"\" width=\"600\" height=\"38\" \/><\/p>\n<p>and click the \u201cFill&#8230;\u201d button located at the bottom left corner of the editor pane.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5615 size-full\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2015\/04\/Creating-a-Dataset-5.jpg\" alt=\"\" width=\"294\" height=\"60\" \/><\/p>\n<p><strong>4.<\/strong>\u00a0Modify the &#8220;Start&#8221; and &#8220;End&#8221; values in the &#8220;Fill Dataset Field&#8221; popup as needed, then click &#8220;Generate Values.&#8221;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5616 size-full\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2015\/04\/Creating-a-Dataset-6.jpg\" alt=\"\" width=\"346\" height=\"326\" \/><\/p>\n<ul>\n<li>I&#8217;ve changed the start and end values to 1 and 35 respectively, since that range encompasses the values returned by\u00a0http:\/\/thomas-bayer.com\/sqlrest\/CUSTOMER\/?sortBy=age&amp;country=US<\/li>\n<\/ul>\n<p><span style=\"color: #000000;\"><span style=\"font-family: arial, sans-serif;\"><span style=\"font-size: small;\"><strong>5.<\/strong>\u00a0After setting the values for this new dataset, click \u201cOK.\u201d\u00a0<\/span><\/span><\/span>You may now generate new calls with this values in this dataset.<\/p>\n<h3>Editing the Datasource<\/h3>\n<p>The custom dataset will be used to replace the recorded variable to be tested (here, the customer ID).<\/p>\n<p>To edit the datasource:<\/p>\n<p><span style=\"color: #000000;\"><span style=\"font-family: arial, sans-serif;\"><span style=\"font-size: small;\"><strong>1.<\/strong> Open the load test in which the API call was originally recorded and select the recorded call.<br \/>\n<\/span><\/span><\/span><\/p>\n<p><a href=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2015\/04\/Editing-the-Datasource-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5318\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2015\/04\/Editing-the-Datasource-1.jpg\" alt=\"Editing the Datasource - 1\" width=\"600\" height=\"79\" \/><\/a><\/p>\n<p><span style=\"color: #000000;\"><span style=\"font-family: arial, sans-serif;\"><span style=\"font-size: small;\"><strong>2.<\/strong> In the inspection pane located in the lower half of the Web Performance application, select the \u201cHeaders\u201d Tab.<\/span><\/span><\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5618\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2015\/04\/Editing-the-Datasource-2.jpg\" alt=\"\" width=\"600\" height=\"49\" \/><\/p>\n<p><span style=\"color: #000000;\"><span style=\"font-family: arial, sans-serif;\"><span style=\"font-size: small;\"><strong>3.<\/strong> Expand the \u201cPATH\u201d header to view all values in the call.<\/span><\/span><\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5619 size-full\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2015\/04\/Editing-the-Datasource-3.jpg\" alt=\"\" width=\"297\" height=\"91\" \/><\/p>\n<p><span style=\"color: #000000;\"><span style=\"font-family: arial, sans-serif;\"><span style=\"font-size: small;\"><strong>4.<\/strong> After expanding the \u201cPATH\u201d header, right click the \u201cpath segment\u201d that will be replaced by the values in the new dataset and click \u201cEdit.\u201d<\/span><\/span><\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5620 size-full\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2015\/04\/Editing-the-Datasource-4.jpg\" alt=\"\" width=\"504\" height=\"94\" \/><\/p>\n<ul>\n<li>I&#8217;m editing &#8220;Path Segment [2]&#8221; because it contains the customer ID, and I want to test all other customer IDs.<\/li>\n<\/ul>\n<p><span style=\"color: #000000;\"><span style=\"font-family: arial, sans-serif;\"><span style=\"font-size: small;\"><strong>5.<\/strong> From the \u201cEdit Field\u201d popup menu, expand the drop down menu beside \u201cDatasource\u201d and select the \u201cDataset\u201d option.<\/span><\/span><\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5621 size-full\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2015\/04\/Editing-the-Datasource-5.jpg\" alt=\"\" width=\"251\" height=\"143\" \/><\/p>\n<p><strong>6.<\/strong> After selecting the \u201cDataset\u201d option, choose the dataset you&#8217;d like to use in the \u201cDataSet\u201d field. Then, choose the \u201cField\u201d you&#8217;d like this new dataset to populate and click &#8220;OK.&#8221;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5622 size-full\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2015\/04\/Editing-the-Datasource-6.jpg\" alt=\"\" width=\"499\" height=\"106\" \/><\/p>\n<h3>Running a New Load Test<\/h3>\n<p>After editing the datasource, the call can be used to test the new values in the custom dataset.<\/p>\n<p>To run a new load test:<\/p>\n<p><strong>1.<\/strong> In the navigator pane located on the left side of the Web Performance application,\u00a0click &#8220;New&#8221; -&gt; &#8220;Load Configuration.&#8221;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5624 size-full\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2015\/04\/Running-a-New-Load-Test-1.jpg\" alt=\"\" width=\"187\" height=\"231\" \/><\/p>\n<p align=\"LEFT\"><span style=\"color: #000000;\"><span style=\"font-family: arial, sans-serif;\"><span style=\"font-size: small;\"><strong>2.<\/strong> In the resulting popup menu, select the option \u201cStop after &#8216;n&#8217; repeats,\u201d set the &#8220;Test Plan&#8221; to &#8220;Constant (Flat),&#8221; and click &#8220;OK.&#8221;<\/span><\/span><\/span><\/p>\n<p align=\"LEFT\"><a href=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2015\/04\/Running-a-New-Load-Test-2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5325\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2015\/04\/Running-a-New-Load-Test-2.jpg\" alt=\"Running a New Load Test - 2\" width=\"600\" height=\"399\" \/><\/a><\/p>\n<p align=\"LEFT\"><span style=\"color: #000000;\"><span style=\"font-family: arial, sans-serif;\"><span style=\"font-size: small;\"><strong>3.<\/strong> In the editor pane <\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"font-family: arial, sans-serif;\"><span style=\"font-size: small;\">located in the top half of the Web Performance application, select the testcase you&#8217;d like to replay, and run the test with the custom dataset.<\/span><\/span><\/span><\/p>\n<p align=\"LEFT\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5625\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2015\/04\/Running-a-New-Load-Test-3.jpg\" alt=\"\" width=\"600\" height=\"61\" \/><\/p>\n<p align=\"LEFT\"><strong>4.<\/strong>\u00a0After choosing the testcase, double-click the corresponding &#8220;Repeats&#8221; box and set the number of repeats equal to the number of customer ID values.<\/p>\n<p align=\"LEFT\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5626\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2015\/04\/Running-a-New-Load-Test-4.jpg\" alt=\"\" width=\"600\" height=\"75\" \/><\/p>\n<p align=\"LEFT\"><strong>5.<\/strong> Run the custom Load Configuration to test whether or not each call works, as well as its speed.<\/p>\n<p align=\"LEFT\"><strong><em>NOTE:\u00a0<\/em>To test the API call with load, set the number of users &gt; 1. <\/strong><\/p>\n<p align=\"LEFT\"><strong>You can edit the number of users for an open load configuration by <\/strong><\/p>\n<p align=\"LEFT\"><strong>1. clicking &#8220;Edit&#8221; at the top of the editor pane.<\/strong><\/p>\n<p align=\"LEFT\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5627 size-full\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2015\/04\/API-Test-with-Load-1.jpg\" alt=\"\" width=\"284\" height=\"46\" \/><\/p>\n<p align=\"LEFT\"><strong>2. In the resulting popup menu, increase the number of users.<\/strong><\/p>\n<p align=\"LEFT\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-5628\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2015\/04\/API-Test-with-Load-2.jpg\" alt=\"\" width=\"600\" height=\"462\" \/><\/p>\n<h2>\u00a0<b>Troubleshooting<\/b><\/h2>\n","protected":false},"excerpt":{"rendered":"<p>In this post, I&#8217;ll discuss why API testing is important, a typical situation that a tester might experience, and how to perform API testing with Web Performance Tester.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,204,42],"tags":[218,219,237,217,30],"class_list":["post-5288","post","type-post","status-publish","format-standard","hentry","category-load-testing","category-qa-and-functional-testing","category-load-tester-software","tag-api","tag-api-testing","tag-load-testing","tag-qa-testing","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/posts\/5288","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/comments?post=5288"}],"version-history":[{"count":24,"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/posts\/5288\/revisions"}],"predecessor-version":[{"id":5772,"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/posts\/5288\/revisions\/5772"}],"wp:attachment":[{"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/media?parent=5288"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/categories?post=5288"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/tags?post=5288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}