Tuesday, March 19, 2019

Azure @ Enterprise - Downloading all the VSOnline / Azure DevOps load test .har files together

Background

After performing a load test via Azure Test Plans or Visual Studio Online, it produce the http archive  files with .har extension. Those .har files are available in the Azure DevOps portal as part of test results and we can download to analyze the nature of load test. But the problem is that we need to download files one by one. Its tedious to do via portal.

Solution

As everyone knows, the Azure is built around ReSTful Web APIs. The Portal UI itself is a wrapper around those APIs. Lets see how can we download those files easily using the same API layer.

Figuring out Url

Below Url gives the details of WebAPI which we can invoke to interact with the load tests.


In short, the url format is below
https://<organization name>.vsclt.visualstudio.com/_apis/clt/testRuns/<Run GUID>/results?api-version=5.0

The GUID of test run can be obtained from the portal URL, when we are in the individual test run page. If we try with the integer sequence number what we are seeing the test runs list, it will not work.

Security

The MSDN documentation says Personal Access Token and type Basic.  That means, when we put the PAT, we have to use base64 encoding. The best way to make sure its working, is via Postman. Below are the steps.
  • In Postman, make sure the http method is GET and enter the intended URL by replacing the organization name and Run GUID.
  • Go to Authorization tab and select TYPE as "Basic Auth".
  • Enter any user name or leave it empty and inside the password text box, put the Personal Access Token.
  • Press on 'Send' buttong to send the API request to Azure DevOps, and we should get data in JSON format.

What is the role of storage account and how to access files

The WebAPI call /testRuns/<GUID>/results gives a JSON as explained above not the .har files which we need. Instead of .har files or har data, it has a link to Azure Blob Storage. Notice that the link has some query string which have the SAS token details. 

Azure developers already knows how to download files from an Azure blob storage, if they get a URL with SAS token suffixed to it.

But for the benefit of testers and automation guys the below link has been given which explains, how to download files from Azure blob storage using a tool called Azure Storage Explorer. It is free as of now.


Once the connection is established in Azure Storage Explorer to storage account using the SAS token, we can navigate to the correct GUID folder of test run. Then to /TestResult/Diagnostics folder to download .har files.

Another way is to use another command line tool called AzCopy.exehttps://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy which download the files from Azure Storage Account in higher speeds. AzCopy.exe needs the SAS token to be passed into it via command line switches. Since that is not in the scope of this post, letting it to learners.

Tuesday, March 12, 2019

Azure DevOps formerly VSOnline load testing - The load test cannot be run since the number of URLs...

The Azure DevOps or old VS Online or Azure dev test labs is a nicer option to do load testing. They have hosted agents or we can bring our own agents. Agents means the distributed load generator machines.
Below is one error message we may encounter when we load test enormous applications.

The load test cannot be run since the number of URLs to be reported for run duration under '01:00:00' exceeds the maximum supported value of '1000'. Reduce the ‘Maximum Request URLs Reported’ property or increase the run duration and try again.



The best way to fix is to follow what the error message says.

https://stackoverflow.com/questions/24250153/web-load-test-with-mvc-route-parameters-creates-many-instance-urls
https://social.msdn.microsoft.com/Forums/en-US/ffc16064-c6fc-4ef7-93b0-4decbd72167e/maximum-number-of-unique-web-test-requests-exceeded?forum=vstswebtest

Below is the URL to the error codes Azure DevOps / VS Online load test may produce. This is another way to tackle the issue.

https://devblogs.microsoft.com/devops/visual-studio-cloud-load-testing-error-codes/

If it didn't solve with above steps, try the old school techniques such as restarting Visual Studio instance which used to submit job to VSO, restart machine itself or resubmit multiple times.

It is really wired, but this is what it is.

Tuesday, March 5, 2019

Azure @ Enterprise - Write-Host v/s Write-Output in Kudu console

Recently we were troubleshooting in one Azure WebAppBot application. It needs certificates to access some secrets from Azure KeyVault. After some debugging, we reached to a place where we suspect that the certificates added are not getting accessed by the WebApp. So we decided to test the availability of certificates using Kudu PowerShell console.

Get-childitem Cert:\CurrentUser\My -recurse | %{ write-host $_.Subject }

Unfortunately we got some other issue.

PS D:\home> Get-childitem Cert:\CurrentUser\My -recurse | %{ write-host $_.Subject ; }
Get-childitem Cert:\CurrentUser\My -recurse | %{ write-host $_.Subject ; }
write-host : The Win32 internal error "The handle is invalid" 0x6 occurred
PS D:\home>
while setting character attributes for the console output buffer. Contact Microsoft Customer Support Services. At line:1 char:50 + ... hilditem Cert:\CurrentUser\My -recurse | %{ write-host $_.Subject ; } + ~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ResourceUnavailable: (:) [Write-Host], HostExcep tion + FullyQualifiedErrorId : SetConsoleTextAttribute,Microsoft.PowerShell.Com mands.WriteHostCommand

It seems the PowerShell capabilities what we have in VMs is not the same what we have in WebApp's Kudu console. Even a simple Write-Host "Hi" also failed.

So tried to use Write-Output instead of Write-Host which writes to stream than to the host.

It worked!!!

Happy debugging.