Sunday, November 30, 2014

Performance & Load testing - Part 2

Performance & Load testing a WCF service using Visual Studio (Part 2)

In the previous blog, I explained how to create a web test for your service and parametrize the request xml. Next step is to use this web test in our performance and load testing.

In the same project where your web test is present, right click and select load test. A load test wizard will open. 
















Click Next and enter the name of the scenario and select whether you want think times between execution or not.


Click Next and enter the load under wish you wish to test your endpoint. It could be constant load or increasing load















Click Next and select the model of your test. When I say model I mean, how you wish to run your test as shown below:-















Click Next and add your web test for execution.















Click Next and select the network type for you test. If you are not sure, leave it with LAN. 


Click next and select the browser you wish to run this test in. Since we are just testing our service endpoint. Browser really doesn't make any difference.















Click next and select the computer which you wish to monitor during test execution. The system will be monitored for CPU & memory etc















Click next and finally enter the load test duration and test iterations you wish for your performance test and click Finish















Now your load test is configured for execution and right click and click run load test. You should see screen as below with the current status of the test. I took the screen shot when it was finished so don't be afraid if it looks a bit different :)





















Once the test is finished, you will have all the stats with you clearly defining the response time, response at 90th percentile and 95th percentile etc.

Hope you enjoyed doing some performance testing :)

Saturday, November 29, 2014

Performance & Load testing - Part 1

Performance & Load testing a WCF service using Visual Studio (Part 1)

In this blog, we will be discussing how we can performance & load test WCF service using Visual Studio. 

Performance of any service is a critical factor and if a service is not responding within specified time then the response is as good as none. Hence it is absolutely imperative to not only make sure the service is responding but responding quickly.

There are couple of ways to performance test a service. Since we work on Visual Studio for development, that is the most handy and available tool for this. Below are the pre-requisites:-
  1. Visual Studio Ultimate
  2. One service endpoint to test
  3. Credentials if the service is secured via some security
So let's start, we will achieve this in two parts. First, we are going to write a web test which will call our endpoint. Second, we will use this test in our load test to add the desired load we want for our performance test.

1. Writing a web performance test:-

Open your WCF project in Visual Studio and right click on the solution and click add new project. On new project dialogue, click on test on the left hand side and select web performance and Load Test project. Please note, this option will only be available in Visual Studio Ultimate edition. 




Once the project is created, right click and add new web performance test. As soon as you click that, the browser will open for recording and just click Stop Recording. Now you have an empty web test. Right click on the webtest and click add Web Service Request. This will add a service call in your webtest with http://localhost/ url. Right click on the web service test and click properties and in the properties window, update the URL of the test with the one you wish to test.



Now the url is pointing to your service, it is time to add the payload. I will give you a tip here, if you are dealing with services, I would recommend to use SoapUI for testing them. It is a fantastic tool to add your service and it auto creates the request object for you as well which you can fill and test the service. 

I do have my service configured in SoapUI and I am going to use the same xml in request. If you are not using SoapUI then I would suggest to manually generate the xml request and add to the test. For this, right click on String body under web service test and click properties. Under String body property, add the request xml. Mine is shown below:-



Everything else in above xml is usual apart from Authorization header. My service is secured and the only way to successfully call it is either passing a basic Auth or SAML token in the request header. I am using Basic Auth above.

Now since the test is now loaded with request xml as well there is only one thing left to do. Specify the method of the endpoint. You might have noticed, we haven't mentioned which method of the endpoint to call. This information will go in header. Right click on the web service test and click add header. This will add a new header in the test.
Right click on the header and click properties. In Name add "SOAPAction" and in value add the fully qualified method name. 



This is important as without the SOAPAction header, your request will be lost. Now your test is ready to run. Right click on webtest1 and select Run Test. This will run you test and display the results.  

You can run this test as many number of times you want and it will give you the same results. Same results??? Yes, because currently our request is only invoked with the same request parameter. Check the username in the request screen shot above, "TestUser1". This is a hard coded value and will always be the same. Obviously when we wish to run our performance test, we would prefer to use different values in our requests so as to cover all testing scenarios and for this we would have to parametrize the request xml. 

Parametrization of web test:-

In order to parametrize a web test, you need to add a data source to it. Data source could be of three formats. Database, CSV file or an XML file. For our demonstration, I am going to use the simplest one. A CSV file.

First, let's create a file with our data. Create a CSV file on your desktop and in the first row, put the names of your parameters separated by comma and from the second row, the value of those parameters again separated by comma. Since in my request there is only one parameter, the content of my CSV file are given below:-

Usernames
TestUser1
TestUser2
TestUser3

Usernames is the name of the column and rest three are the values which my test will be using while running.

Now, let's add this CSV file as a data source in our web test. Right click on web test and click add data source. A dialogue will open showing three options of data source. Click on the CSV file and click next, now select the CSV file you just created. If the format of your CSV file is correct then the dialogue will display the contents of the CSV file. Press Finish.

The CSV file is now added in your web test as data source. All you have to do is to remove the hard coded value in the request and use it from data source. Below is the parametrized version of our request. 




Naming the parameter is simple. Name of your data source then name of your CSV file and name of the column to pick the value from. Now save the test and run again. You should see the results of the test using the new parametrized values.

This is it, we have successfully created a web test for our service and parametrized the request as well. In the next part, we will add this test in our load test configuration and will add load as per our requirements.

Stay tuned !!!

Thursday, November 13, 2014

Microsoft Decode 2014

Just sharing few of the really exciting announcements made in Microsoft Decode Tech day 2014 yesterday. But first, I can’t really resist without bragging how good the event was and some of the best sessions from few great people like Brian Cox etc. People missed who registered with me but didn’t attend. Their loss!
Right, anyways, back to the real world. It was announced in the morning itself that there will be few very important announcements from Microsoft in the evening so please don’t leave J  and turned out to be worth waiting for.  (Stretching a little bit right?)

Ok…so first announcement:-

 Microsoft has open-sourced the full server side .net core stack for developer community. This means, people can contribute to it now and the open source will be expanded to non-Microsoft operating systems as well like Linux & Mac. Cool right.. .net code running on Linux & Mac J

Second one, (this is going to please expense managers of projects as few less licenses)

A full fletched version of Visual Studio called Visual Studio Community 2013 has been launched for free. There is a huge difference between Visual Studio Express and this community version. It is basically a full version of Visual Studio with no restriction or a very few I may add. Well Microsoft never gives anything for free but the idea behind this move is they want to make Visual Studio as a gateway to other products and technologies of Microsoft. Good move but right now I am only looking at free version of Visual Studio J

Third one…..although this was bit of a surprise!

A preview version of Visual Studio 2015 and .Net has been launched. Well you might wonder the same thing I am doing which is what happened to Visual Studio 2014 beta which was released few months back. No idea…may be it is another thing like Windows 10 after 8 :D

And last but not the least…..

Visual Studio online Release management has been launched as a service (although currently in preview). Not sure how many of you are aware of this tool but this tool was launched by Microsoft after acquiring one company called InRelease. This is one of the products from Microsoft for managing your different release environments and automating the entire process with pre-defined workflows.
Although like any other release management tool, it wasn’t easy to configure. I was following the configuration manual and in the end realized that the current version of VSRM can’t connect to VSO but only TFS server. Disappointments!!!
But not for long, now this feature is available as a service which means no hassle, they will manage everything for you and you can only pay the subscription. That always reminds me of my postpaid connection J Easy
.
That was all for announcements. I also attended the DevOps technical sessions completely. (Before you think, let me clear this out that I am still into Development and has no plans to move into operations team but has attended this as this is the area we need to improve on for the client I am currently working for). Learned some great deal of information there and will try to share that soon as well. But as a tip, learn Powershell if you haven’t started yet J

That is for now….hopefully I will get some time soon to share more with you.