Initiate a Load Test from Hosted Build work-around

 

Please note there are now much easier ways of doing this.  Please see:

http://blogs.msdn.com/b/visualstudioalm/archive/2015/11/23/scheduling-load-test-execution.aspx

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

We are gathered this week in a “Hackfest”, defined as a time constrained, joint coding effort that focused on solving a technical challenge based around a specific topic and can involve one or more external partners. Our first challenge was to automate Load Testing, triggered by the hosted build on VSO.

Using post build script was close, but not a work-around for the hosted build

We started by triggering the following post-build script:

“%VS120COMNTOOLS%..\IDE\mstest.exe” /testcontainer:”%TF_BUILD_SOURCESDIRECTORY%\Hackathon\LoadTestExperimentation\WebAndLoadTestProjectHackathon\loadtest1.loadtest”

Unfortunately the build agent running with the service account fails to launch the load test as shown:

image

The work-around, using the post build script and the Rest Api

The statement there is no way to do that currently  really inspired us to create a work-around, not best practice, with the knowledge that the load testing team is working on a task for build.vNext for running a cloud load test.

Prerequisites:

  • Visual Studio Online account.
  • Enable Alternate credentials in Visual Studio Account

  • Visual Studio Ultimate 2013 (you need to be able create a load test)

 

10 step work-around if you cannot wait for the build.vNext task:

  1. Download the REST sample https://code.msdn.microsoft.com/windowsdesktop/Cloud-Load-Testing-API-b333e778, which allows you to pass credentials that have permissions to initiate a load test. Package the binaries as part of your solution, ensure you set the property “Build Action” as None and “Copy to Output Directory” as true.  Another caveat we discovered of this sample was the fact the /starttestrun switch took the path and the file name AS TWO DIFFERENT parameters!!!!!
    image  image
  2. Create an empty script file that will launch the rest api sample to launch the load test. Package the script as part of your solution, and again set the “Build Action” and “Copy to Output Directory” as above.
  3. Create a new build, and define your Working folders.
    image
  4. Select Hosted Build Controller.
    image
  5. Select the TfvcTemplate.12.xaml build process template, browse for and select the script you created in step 2, as the Post-build script path.
    image
  6. Edit the script file and define the sample program to be launched. We use the %TF_BUILD_SOURCESDIRECTORY% variable to point us to the source directory, which correlates to the working folders you configured as part of the build, and specify the /starttestrun argument.
    “%TF_BUILD_SOURCESDIRECTORY%\Partsunlimited\Client\CloudLoadTestingClient.exe” /starttestrun
  7. Append two more arguments as mentioned as a caveat in step 1.
    • The first defines the folder in which the loadtest configuration file is stored.
      “%TF_BUILD_SOURCESDIRECTORY%\Partsunlimited\Client\CloudLoadTestingClient.exe” /starttestrun “%TF_BUILD_SOURCESDIRECTORY%\Partsunlimited”
    • The second defines the load test config file.
      “%TF_BUILD_SOURCESDIRECTORY%\Partsunlimited\Client\CloudLoadTestingClient.exe” /starttestrun “%TF_BUILD_SOURCESDIRECTORY%\Partsunlimited” parts.loadtest
  8. Save all changes, Queue New Build and monitor the build in the Build Explorer.  
    image
  9. Monitor the load test in the Load Test Explorer. 
  10. Open and review the load test when complete.
    image

At this point we all loved Chuck’s response: YEAH we got it working!!!!!!!!!!

Author: Willy-P. Schaub

I’m a senior program manager with the Visual Studio Team Services group. I’m responsible for the ALM Ranger program and other interesting workstreams. We provide professional guidance and gap-filling solutions to the developer community for Visual Studio. Come directly to me if you need help with missing guidance or features for Visual Studio Team Services. Since the mid-’80s, I’ve been striving for simplicity and maintainability in software engineering. Reach me at aka.ms/vsarblog, aka.ms/willyblog, or Twitter at @wpschaub.

1