Use cloud load agents on your infrastructure

August 22nd, 2016

This blog talks about how you can configure your own machines (physical/VMs) with Cloud-based Load Testing service to do a load test run. This is primarily useful when you want to load test an application which is not publically accessible. To get more context around this, please refer ‘Load testing Applications behind Firewall using Cloud-based Load Testing Service‘ . If you wish to provision the rig in your Azure subscription you can refer the previous blog.

Following is the basic topology of load agents and CLT service. Once configured the load agents will get instructions from CLT to carry out the load test run.

Typical topology of having user’s own machines as load agents registered with CLT.

It is recommended to use clean machines with already having .net 4.6 (download link for .net 4.6 is here). You can download the powershell script through following link.

Download powershell script to configure user load agent

Once you down, please make sure you unblock the script by going into the properties of the file.

Script – ManageVSTSCloudLoadAgent.ps1

Mandatory parameters for the script:

TeamServicesAccountName: It is the name of the VSTS account with which you want to configure your machines. Use just need to pass the account name here e.g., please put ‘xyz’ if your VSTS account url is https://xyz.visualstudio.com PATToken: It is required for authentication. One has to first get the PAT token for the VSTS account. Follow this post to get it. The scope should be selected as ‘Load Test (read and write)’.

Parameters to configure an agent:

Agent group name- The machine will get registered under this agent group name. If the agent group doesn’t exist, it’ll get created first. This input is mandatory.

Example:

.ManageVSTSCloudLoadAgent.ps1 -TeamServicesAccountName https://xyz.visualstudio.com -PATToken olxpldk2xcdfp5bt2ruemetwrmv7xyzk23l4cnnewi3rbaq -ConfigureAgent -AgentGroupName ‘trial’

With the above command the current machine will be configured as VSTS cloud load agent for xyz.visualstudio.com under the agent group named as ‘trial. Once the powershell scripts completes, it would have installed and started a windows service on the machine named as ‘VSTSLoadAgentService‘. This may take around 5-10 mins.

At present we are treating all load agents same and if even though user has different machines as load agents we will get equal load generated from each machine. If you have some feedback around this, please reach out to us. Once configured these machines will be auto upgraded whenever needed.

Apart from configuring an agent the above mentioned powershell script is capable more operations that are listed below.

Managing self-provisioned agents

Get agent groups- It’ll list down all the registered agent groups with the VSTS account. Example is as follows:

.ManageVSTSCloudLoadAgent.ps1 -TeamServicesAccountName https://xyz.visualstudio.com -PATToken olxpldk2xcdfp5bt2ruemetwrmv7xyzk23l4cnnewi3rbaq -GetAgentGroups

Get agents- It’ll list down all the agents and their latest status of a particular agent group name. Example is as follows:

.ManageVSTSCloudLoadAgent.ps1 -TeamServicesAccountName https://xyz.visualstudio.com -PATToken olxpldk2xcdfp5bt2ruemetwrmv7xyzk23l4cnnewi3rbaq -AgentGroupName test -GetAgents

Delete an agent- It’ll delete the agent reference from service. The agent must be in the offline state before a user can delete it. Agent group name is mandatory. Refer the following for example:

.ManageVSTSCloudLoadAgent.ps1 -TeamServicesAccountName https://xyz.visualstudio.com -PATToken olxpldk2xcdfp5bt2ruemetwrmv7xyzk23l4cnnewi3rbaq -DeleteAgent -AgentGroupName test -AgentName dpk-param

You can find more details by doing get-help on the ManageVSTSCloudLoadAgent.ps1.

How to queue a run using load agents

Using VSTS portal

Now you can queue load test runs on self-provisioned agents through VSTS portal. As shown in below UI, you have a choice to select the type of agents in the settings tab.

Using Visual Studio Enterprise IDE

We are working on making it as first class experience in our product. Till then user can queue a run on these machines by having the following context parameter in Visual Studio Load Test file.

Context parameter name – UseStaticLoadAgents Context parameter value – true Context parameter name – StaticAgentsGroupName Context parameter value – <name of the agent group>

User can set the number of machines to be used for a load test run through Agent core count property present in Run Settings. In user’s own load agents scenario every core is treated as a single machine. As shown in below image, 5 machines will be used for the run.

The runs done on user’s own load agents machines are not charged. User should be able to confirm this by looking into the status messages of the run.

Before you do that, we would recommend you to go through the FAQs as well.

Frequently asked question –

How do the load agents communicate with CLT? The load agents will communicate with CLT using HTTPs protocol. Since these machines/VMs are inside user’s private network (Azure/on-prem), they can reach the Application under Test (AuT) easily. The results are published back to the CLT service so that the analysis can happen in similar manner as done for other type of load test runs in CLT. How I am being charged for this? At present this feature is in preview mode and you will not incur load testing VUM charges for the runs where you deploy load agents on your premises or in your Azure subscription. However, you will be charged the applicable Azure VM costs. Can I use these machines for some other purpose? These machines can be used other your other tasks as well but it is recommended to not have anything running while a load test run is in progress. Can I shut down the machines where I have configured load test agent? Yes, the machines can be shut down when not in use. The load agent service will automatically start to receive commands from CLT, once the machine is up. If you are using Azure ARM template to deploy these agents, you can start/stop the VMs based on your need. You can also do this using a powershell script. Refer following link to more on this.https://gallery.technet.microsoft.com/scriptcenter/Stop-All-VMs-in-Specified-40c8531eYou are also recommended to delete the Azure resource group once you are done with load testing. You should be able to re-create it anytime later if you need to.https://azure.microsoft.com/en-in/documentation/articles/resource-group-portal/ I have proxy settings on my machines, will this work? We support only default proxy scenario i.e., when the proxy settings are controlled through IE and it uses the current user’s credentials to connect to proxy server. In other cases, please reach out to us. From where I can collect the logs to debug some issue? The powershell script logs are stored in the logs folder which will be present in the same folder where the powershell script exists. These logs are displayed in the powershell window as well. Run execution logs reside in %windir%tempCloudLoadTest logs folder.

With all this, you should be able to go ahead and try out the load testing. Do reach out to us on vsoloadtest@microsoft.com, if you have any query.

Happy Load Testing!