The End to End (E2E) workflow of Visual Studio Lab Management 2010 helps you to automate the complete process of build generation, deploying generated build on a virtual environment and testing the build. I shall refer this scenario as Build-Deploy-Test scenario. Your Build-Deploy-Test scenario might have different requirements like picking test binaries from a location other than build location etc. To do this, you will have to customize E2E workflow template as per your requirements. Here are few tips/steps to customize E2E workflow template. I will use following two simple customizations to demonstrate this:
4. Add this new file to source control. Double clicking on this new file will open it in Visual Studio Workflow editor. Now it is ready for customization.
In E2E workflow template, test binaries location is assumed to be same as build drop location. You might have a scenario where test code is not built along with the product code and you may want to customize the template such that test binaries are picked up from a different location other than build drop Location.
This customization involves two simple steps:
2. Passing this argument value to ExecuteRemoteTestRun Activity. This activity creates a remote test run, waits till the test run completes and updates build information with test run statistics.
Now, check-in this customized “xaml” file and use it to create a new build definition. Below picture shows one such build definition. The new in-argument “TestBinariesLocation” shows up under “Misc” section and you can assign a value here.
In E2E workflow template, virtual environment is not restarted at the end of application deployment. You may want to customize the template to support applications, which might require a restart after deployment. Typically, only the virtual machine on which application is installed will be restarted. However, Visual Studio Lab Management 2010 doesn’t support operations on individual virtual machines of an environment. Hence, to achieve this entire virtual environment needs to be restarted.
NOTE: Please ensure that deployment scripts never reboot the virtual machine. If this happens build agent running deployment script will loose connection with controller and workflow might hang.
This customization involves adding three activities to the LabDefaultTemplate that accomplish the following sequence of actions:
In workflow editor, click on the Toolbox tab to see all the Team Foundation LabManagement Activities.
1. To stop the environment, drag the StopLabEnvironment activity and insert before an activity with display name “Application Deployment Succeeded”.
2. To start the lab environment, drag and drop StartLabEnvironment activity after StopLabEnvironment activity. Fill in-arguments( Similar to StopLabEnvironment activity )
3. Use Delay activity to add wait for virtual machines to boot up. This activity can be found under Primitives tab of Tool box. You have to fill the duration of wait time like 10 minutes etc. Duration can be specified as TimeSpan.FromMinutes(10).
Check-in this modified template and create a new build definition using this modified template to deploy applications that require restart after reboot.
NOTE: Another more elegant approach to handle restart after installation is to develop a new activity called "RestartLabEnvironment" activity. In my next post about writing custom activities, I will describe how to create this activity and use it.