Getting started with Lab Management – VS2010 RC (Part 1)

We had a previous walkthro that shows lab management in action with VS2010 Beta2. This walk thru is an update of the same walkthru but using the RC bits. Between Beta2 and RC, the lab management product has had a lot of improvements, especially in the getting started path. This post is an attempt to showcase these changes. I have also repeated the content of the 4 part series again, to keep the post readable in isolation. Folks who have had a chance to read the previous walkthru, please excuse the repetition.

Lab management is a new addition to the Visual Studio family with VS2010. The product uses virtualization to build and manage labs in the dev / test environment. The promise of the product is three fold.

  1. Using virtualization, machine utilization and hardware costs of managing labs will be much better than building out and maintaining physical labs.
  2. Increased productivity of the dev/test team – various surveys indicate that test members spend 30 – 50% of their time in setting up their test bed and getting it ready for testing. The product leverages the virtualization to vastly reduce the cost of this bootstrap. Leveraging the rich snapshot / restore models, it allows you to set up a pristine base environment (group of VMs) and then start your testing from there. When you consider the permutations of configurations typical test teams need to test, this will be a huge productivity enhancer. 
  3. Consistent feedback on the quality of the builds – the lab management solution allows you to configure your daily build system to build the product, deploy the application on an environment and execute tests on them. Effectively, this completely automates the daily BVT (Build Verification Tests) setup and provides a strong feedback on the state of quality of the daily builds.

Lab management also nicely plays along with the other VS2010 value propositions like rich data collection for bugs (snapshot the environment). For a developer, it is easy to debug a bug reported on a particular build (restore to the snapshot of the environment for that build) or to do smoke testing of his changes across various test configurations. For a tester, the environment is also a good starting point for exploratory testing, easily venturing into various corners of the product with the knowledge that a tester could always reach back a well known state.

Enough intro. This blog post series will walk you through the automation of the end-to-end workflow using a simple calculator web service and unit tests for the same. At the end of the post, we would see the automated workflow where triggering a build will build an app, deploy it to a VM, run tests on it and report results.

While this example does not use multiple VMs in an environment, the same experience is applicable for multi-tier app testing as well. We can extend the application under test to cover various topologies (from traditional backend / frontend to software NLB to VMs spanning multiple trust boundaries)

Prereqs:

  1. One x64 hypervisor enabled machine with 4GB RAM that can act as hosts for the test VMs, as well as the SCVMM server. Note that SCVMM requires to be installed on a machine joined to domain and needs live connection to the domain for authentication. So this cannot be your roaming laptop.
    1. Note that the server should be running x64 OS
    2. Hardware-assisted virtualization and hardware-assisted data execution protection are enabled in the BIOS (if you changed them now, turn off the power of the machine and restart them). This post explains how to verify these settings in bios.
    3. Hypervisor server role is installed
  2. One x86/x64 machine (2GB RAM) that can run TFS, VS and the build and test controllers for managing distributed build and test.
  3. New for RC, a service account credentials (domain account name and password). We use this credential for the agent when it communicates with the test controller, TFS and the build drop location.

Representing the host configurations pictorially, you can configure your systems to be in either of the configurations below.

image_thumb1

Picture2 

Software downloads:

  1. Visual Studio 2010 Team Foundation Server: here
  2. Visual Studio 2010 Team Agents RC: here
  3. Visual Studio 2010 Ultimate: here
  4. System Center Virtual Machine Manager 2008 R2 RTM: here
  5. VM creator tool: here
  6. Windows Server 2008 R2 vhd: here (only needed if you do not have a server VM for OS VMs)

As part of the walk through we will

  1. Configure SCVMM which is the management hub for virtual machines and the test VM (this post) 
  2. Install and configure TFS, the controllers to manage build / test and lab (Part 2)
  3. Build the application under test in VS (Part 3)
  4. Use the virtual lab we built out to automate the build / deploy and test experience (Part 4)

Install and configure SCVMM Server:

On the hypervisor machine (in my case varadademo.fareast.corp.microsoft.com), install both the SCVMM server and the Administrator console. The lab product uses SCVMM as the hub for driving all the VM related operations.

I have done the default installation. As part of the install, I had VMM install SQL Server Express.

scvmm_2

VMM installs a SQL server that requires to be updated with some security patches. Use Windows Update to pick up the latest patches for VMM and SQL Server and reboot the machine after the updates are installed.

Launch the admin console, pair to localhost:8100

image

Select Add host and add the host machine (the same machine where I am running SCVMM)

image 

Add test VM to the host:

Copy the Win2k8 R2 vhd you downloaded before to the library share and create a VM (Remember to set the VM memory to be 1GB). Join the VMs to domain, giving it right computer names, and any other typical setup you might want on the VM. (Windows update to pick up the latest patches).

In a single host setup (with 8GB configuration), you can host the test VM and the TFS VM on the same host. In this case, make two copies of the VHD and deploy them to the same host. A future post explains how to build out the test VM (and TFS VM as well if you are configuring in a 8GB setup)

Configure the Test VM:

In our example, we will use the test VM as a web server to host our app and test it via unit tests. So let us make sure that ASP.NET is configured. To keep the walk through simple, we will just install all the web server components. Logon to the test VM, and from a elevated command prompt,

 C:\Users\lmtstlab> servermanagercmd -install Web-Server -aServermanagercmd.exe is deprecated, and is not guaranteed to be supportedin future releases of Windows. We recommend that you use the Windows PowerShell cmdlets that are available for Server Manager.Start Installation...[Installation] Succeeded: [Web Server (IIS)] IIS Hostable Web Core.[Installation] Succeeded: [Web Server (IIS)] IIS Management Scripts and Tools.[Installation] Succeeded: [Web Server (IIS)] IIS Management Console.[Installation] Succeeded: [Web Server (IIS)] Management Service.[Installation] Succeeded: [Web Server (IIS)] FTP Service.[Installation] Succeeded: [Web Server (IIS)] Custom Logging.[Installation] Succeeded: [Web Server (IIS)] IIS 6 Metabase Compatibility.[Installation] Succeeded: [Web Server (IIS)] Static Content.[Installation] Succeeded: [Web Server (IIS)] Logging Tools.[Installation] Succeeded: [Web Server (IIS)] Tracing.[Installation] Succeeded: [Web Server (IIS)] Request Monitor.[Installation] Succeeded: [Web Server (IIS)] IP and Domain Restrictions.[Installation] Succeeded: [Web Server (IIS)] Request Filtering.[Installation] Succeeded: [Web Server (IIS)] URL Authorization.[Installation] Succeeded: [Web Server (IIS)] IIS 6 WMI Compatibility.[Installation] Succeeded: [Web Server (IIS)] Dynamic Content Compression.[Installation] Succeeded: [Web Server (IIS)] Static Content Compression.[Installation] Succeeded: [Web Server (IIS)] Windows Authentication.[Installation] Succeeded: [Web Server (IIS)] Basic Authentication.[Installation] Succeeded: [Web Server (IIS)] ODBC Logging.[Installation] Succeeded: [Web Server (IIS)] IIS Client Certificate Mapping Authentication.[Installation] Succeeded: [Web Server (IIS)] Client Certificate Mapping Authentication.[Installation] Succeeded: [Web Server (IIS)] Digest Authentication.[Installation] Succeeded: [Web Server (IIS)] Default Document.[Installation] Succeeded: [Web Server (IIS)] Directory Browsing.[Installation] Succeeded: [Web Server (IIS)] ISAPI Filters.[Installation] Succeeded: [Web Server (IIS)] HTTP Errors.[Installation] Succeeded: [Web Server (IIS)] HTTP Redirection.[Installation] Succeeded: [Web Server (IIS)] HTTP Logging.[Installation] Succeeded: [Web Server (IIS)] ISAPI Extensions.[Installation] Succeeded: [Web Server (IIS)] Server Side Includes.[Installation] Succeeded: [Web Server (IIS)] CGI.[Installation] Succeeded: [Web Server (IIS)] FTP Extensibility.[Installation] Succeeded: [Web Server (IIS)] IIS 6 Management Console.[Installation] Succeeded: [Web Server (IIS)] .NET Extensibility.[Installation] Succeeded: [Web Server (IIS)] WebDAV Publishing.[Installation] Succeeded: [Web Server (IIS)] IIS 6 Scripting Tools.[Installation] Succeeded: [Web Server (IIS)] ASP.[Installation] Succeeded: [Web Server (IIS)] ASP.NET.<100/100>Success: Installation succeeded.

The above might take a few minutes.

The following is new for RC. In this step, we provision the VM to be lab ready from with in the virtual machine. As part of the process, the new VMPrep  (click here for more documentation ) tool installs the build / test and lab agent on the VM. We first start with a share that has the downloaded isos expanded. So inside the AgentInstaller directory, we have the files from the agent install iso (not the iso, but the flat file hierarchy inside the iso) and the same is the case with the TFSInstaller directory.

 c:\Windows\System32>dir \\msl-2324785\install\ Volume in drive \\msl-2324785\install has no label. Volume Serial Number is F82E-CAF7 Directory of \\msl-2324785\install02/13/2010  11:02 AM    <DIR>          .02/13/2010  11:02 AM    <DIR>          ..02/11/2010  03:13 PM    <DIR>          AgentInstaller02/09/2010  08:12 PM        72,357,888 LabMgmt.iso02/11/2010  05:09 PM    <DIR>          TFSInstaller02/13/2010  11:02 AM    <DIR>          VMPrepTool

Now from an elevated command prompt inside the VM run,

 C:\Windows\system32>  \\msl-2324785\install\VMPrepTool\VMPrepTool.exe         SelfService          /CurrentUserPassword:<password of the current user>          /AgentInstaller:\\msl-2324785\install\AgentInstaller          /TFSInstaller:\\msl-2324785\install\TFSInstaller

This process takes a while as it installs latest .NET framework, reboots, installs the agents and such. The command takes the current user password to allow for re-logon again.

We now have a active VM that can be used by the lab software to create test environments. At this point, you could also do any other prerequisite that your system under test might have. In this case, we wanted a web server, and thus we ended up doing nothing more than configuring the web server.

In the next blog in this series, we will work on configuring the VM that will act as the TFS server, the build and test controllers and VS machine.