{"id":8403,"date":"2015-03-04T02:20:00","date_gmt":"2015-03-04T02:20:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/visualstudioalm\/2015\/03\/04\/initiate-a-load-test-from-hosted-build-work-around\/"},"modified":"2022-07-28T00:55:22","modified_gmt":"2022-07-28T08:55:22","slug":"initiate-a-load-test-from-hosted-build-work-around","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/devops\/initiate-a-load-test-from-hosted-build-work-around\/","title":{"rendered":"Initiate a Load Test from Hosted Build work-around"},"content":{"rendered":"<p>\u00a0<\/p>\n<p>Please note there are now much easier ways of doing this.\u00a0 Please see:<\/p>\n<p><a href=\"http:\/\/blogs.msdn.com\/b\/visualstudioalm\/archive\/2015\/11\/23\/scheduling-load-test-execution.aspx\">http:\/\/blogs.msdn.com\/b\/visualstudioalm\/archive\/2015\/11\/23\/scheduling-load-test-execution.aspx<\/a><\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>We are gathered this week in a \u201cHackfest\u201d, 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.<\/p>\n<h2>Using post build script was close, but <span style=\"text-decoration: underline\">not<\/span> a work-around for the hosted build<\/h2>\n<p>We started by triggering the following post-build script:<\/p>\n<p><span style=\"font-size: x-small;font-family: courier new;color: #646b86\">&#8220;%VS120COMNTOOLS%..IDEmstest.exe&#8221; \/testcontainer:&#8221;%TF_BUILD_SOURCESDIRECTORY%HackathonLoadTestExperimentationWebAndLoadTestProjectHackathonloadtest1.loadtest&#8221;<\/span><\/p>\n<p>Unfortunately the build agent running with the service account fails to launch the load test as shown:<\/p>\n<p><img decoding=\"async\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px\" title=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2015\/03\/1854.image_thumb_0FDAEE54.png\" alt=\"image\" width=\"690\" height=\"284\" border=\"0\" \/><\/p>\n<h2>The work-around, using the post build script and the Rest Api<\/h2>\n<p>The statement <span style=\"font-family: Segoe Print\"><em>\u201c<span style=\"font-size: x-small\">there is no way to do that currently<\/span>\u201d<\/em><\/span>\u00a0 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.<\/p>\n<p><strong>Prerequisites:<\/strong><\/p>\n<ul>\n<li>Visual Studio Online account.<\/li>\n<li>Enable Alternate credentials in Visual Studio Account<\/li>\n<\/ul>\n<p style=\"padding-left: 60px\">\n  <a href=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2015\/03\/5086.alternate.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2015\/03\/5086.alternate.png\" alt=\"\" width=\"291\" height=\"185\" border=\"0\" \/><\/a>\n<\/p>\n<ul>\n<li>Visual Studio Ultimate 2013 (you need to be able create a load test)<\/li>\n<\/ul>\n<p>\u00a0<\/p>\n<p><strong>10 step work-around<\/strong> if you cannot wait for the build.vNext task:<\/p>\n<ol>\n<li><strong>Download<\/strong> the REST <strong>sample<\/strong> <a href=\"https:\/\/code.msdn.microsoft.com\/windowsdesktop\/Cloud-Load-Testing-API-b333e778\">https:\/\/code.msdn.microsoft.com\/windowsdesktop\/Cloud-Load-Testing-API-b333e778<\/a>, 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 \u201cBuild Action\u201d as <strong>None<\/strong> and \u201cCopy to Output Directory\u201d as <strong>true<\/strong>.\u00a0 Another caveat we discovered of this sample was the fact the <strong>\/starttestrun **switch took the path and the file name **AS TWO DIFFERENT parameters!!!!!<\/strong><br \/>\n<img decoding=\"async\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px\" title=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2015\/03\/0880.image_thumb_2F89C81C.png\" alt=\"image\" width=\"277\" height=\"358\" border=\"0\" \/>\u00a0 <img decoding=\"async\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px\" title=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2015\/03\/6574.image_thumb_1D41015A.png\" alt=\"image\" width=\"320\" height=\"98\" border=\"0\" \/><\/li>\n<li><strong>Create<\/strong> an empty <strong>script<\/strong> 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 \u201cBuild Action\u201d and \u201cCopy to Output Directory\u201d as above.<\/li>\n<li><strong>Create<\/strong> a new <strong>build<\/strong>, and define your <strong>Working folders<\/strong>.<br \/>\n<img decoding=\"async\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px\" title=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2015\/03\/6180.image_thumb_18CA8093.png\" alt=\"image\" width=\"704\" height=\"214\" border=\"0\" \/><\/li>\n<li>Select <strong>Hosted Build Controller<\/strong>.<br \/>\n<img decoding=\"async\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px\" title=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2015\/03\/0636.image_thumb_74C740A7.png\" alt=\"image\" width=\"800\" height=\"246\" border=\"0\" \/><\/li>\n<li><strong>Select<\/strong> the <strong>TfvcTemplate.12.xaml<\/strong> build process template, browse for and <strong>select<\/strong> the <strong>script<\/strong> you created in step <strong>2<\/strong>, as the <strong>Post-build script path<\/strong>.<br \/>\n<img decoding=\"async\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px\" title=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2015\/03\/5023.image_thumb_3739E2DE.png\" alt=\"image\" width=\"800\" height=\"452\" border=\"0\" \/><\/li>\n<li><strong>Edit<\/strong> the <strong>script<\/strong> file and define the sample program to be launched. We use the <strong>%TF_BUILD_SOURCESDIRECTORY%<\/strong> variable to point us to the source directory, which correlates to the working folders you configured as part of the build, and specify the <strong>\/starttestrun<\/strong> argument.<br \/>\n<span style=\"font-family: courier new;color: #646b86\"><strong>&#8220;%TF_BUILD_SOURCESDIRECTORY%PartsunlimitedClientCloudLoadTestingClient.exe&#8221;<\/strong> <strong>\/starttestrun<\/strong><\/span><\/li>\n<li><strong>Append<\/strong> two more **arguments **as mentioned as a caveat in step 1. \n<ul>\n<li>The first defines the folder in which the loadtest configuration file is stored.<br \/>\n<span style=\"font-family: courier new;color: #646b86\">&#8220;%TF_BUILD_SOURCESDIRECTORY%PartsunlimitedClientCloudLoadTestingClient.exe&#8221; \/starttestrun <\/span><span style=\"font-family: courier new;color: #646b86\"><strong>&#8220;%TF_BUILD_SOURCESDIRECTORY%Partsunlimited&#8221;<\/strong><\/span><\/li>\n<li>The second defines the load test config file.<br \/>\n<span style=\"font-family: courier new;color: #646b86\">&#8220;%TF_BUILD_SOURCESDIRECTORY%PartsunlimitedClientCloudLoadTestingClient.exe&#8221; \/starttestrun <\/span><span style=\"font-family: courier new;color: #646b86\"><strong>&#8220;%<\/strong>TF_BUILD_SOURCESDIRECTORY%Partsunlimited&#8221;<strong> parts.loadtest<\/strong><\/span><\/li>\n<\/ul>\n<\/li>\n<li><span style=\"font-family: courier new\"><span style=\"font-family: calibri;color: #000000\"><strong>Save<\/strong> all changes, <strong>Queue New Build <\/strong>and monitor the build in the <strong>Build Explorer.<\/strong>\u00a0\u00a0 <br \/><\/span><\/span><img decoding=\"async\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border: 0px\" title=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2015\/03\/8510.image_thumb_090C0BFB.png\" alt=\"image\" width=\"804\" height=\"304\" border=\"0\" \/><\/li>\n<li><span style=\"font-family: courier new\"><span style=\"font-family: calibri;color: #000000\"><strong>Monitor<\/strong> the load test in the <strong>Load Test Explorer.<\/strong>\u00a0<\/span><\/span><\/li>\n<li><span style=\"font-family: courier new\"><span style=\"font-family: calibri;color: #000000\"><strong>Open<\/strong> and <strong>review<\/strong> the load test when complete. <br \/><\/span><\/span><img decoding=\"async\" style=\"padding-top: 0px;padding-left: 0px;padding-right: 0px;border-width: 0px\" title=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2015\/03\/2185.image_thumb_046C6D1B.png\" alt=\"image\" width=\"800\" height=\"489\" border=\"0\" \/><\/li>\n<\/ol>\n<p>At this point we all loved Chuck\u2019s response: <strong><em><span style=\"font-family: Segoe Print\">YEAH we got it working!!!!!!!!!!<\/span><\/em><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0 Please note there are now much easier ways of doing this.\u00a0 Please see: http:\/\/blogs.msdn.com\/b\/visualstudioalm\/archive\/2015\/11\/23\/scheduling-load-test-execution.aspx \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 We are gathered this week in a \u201cHackfest\u201d, defined as a time [&hellip;]<\/p>\n","protected":false},"author":64,"featured_media":45953,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[226,1,252],"tags":[],"class_list":["post-8403","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ci","category-devops","category-testing"],"acf":[],"blog_post_summary":"<p>\u00a0 Please note there are now much easier ways of doing this.\u00a0 Please see: http:\/\/blogs.msdn.com\/b\/visualstudioalm\/archive\/2015\/11\/23\/scheduling-load-test-execution.aspx \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 We are gathered this week in a \u201cHackfest\u201d, defined as a time [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/8403","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/users\/64"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/comments?post=8403"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/8403\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media\/45953"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media?parent=8403"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/categories?post=8403"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/tags?post=8403"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}