Saturday 12 May 2012

Team Foundation Server 2010: Build - Deploy - Test (Part 2)

Visual Studio Lab Management with Team Foundation Server 2010



What is it


Visual Studio Lab Management is an extension of Microsoft Test Manager that helps you to optimize the use of Microsoft Hyper-V technology to manage and use virtual machines in testing, building, and developing applications in Visual Studio 2010.

Visual Studio Lab Management is integrated with System Centre Virtual Machine Manager (VMM) to enable managing multiple physical computers that host virtual machines and to manage the storage of virtual machines, virtual machine templates, and other configuration files in VMM library servers.
Simply put, Lab Mangement will enable you to:
  • Easily create Virtual Environments
  • Build any given solution & deploy to a Virtual Envionment & take snapshots
  • Automate testing of a deployed application
You can read more about it in my earlier post: Team Foundation Server 2010: Build - Deploy - Test (Part 1)


Before you begin


Before you begin setting up Lab Management, it might be good to know different technologies are being used so that you can gather any installating files that you may need.
  1. Windows Server 2008 R2
  2. Visual Studio Ultimate (or Premium) with Service Pack 1
  3. Microsoft Test Manager 2010
  4. System Center Virtual Machine Manager
  5. Team Foundation Server 2010
A very important thing to remember is that Lab Management only works within a domain so all the machines you configure MUST be a part of a domain and attached to a domain controller.
You will also need a domain account that is able to administer Lab Management.
In this instance we use tfssetup@example.com.au as the account used to administer Lab Management (assume that the domain is example.com.au). For the rest of this tutorial, I will refer to this account as 'tfssetup'. This account does not need to be a domain admin.

Important Links/ Resources:



Setting it up


In this section I will explaing the various setps we need to take to configure Lab Management & integrate it with Team Foundation Server 2010. Once this setup process has been completed, we will be able to create the virtual environments that we require.
This process consists of the following Steps:Hyper V Hosts
  1. Setup Hyper-V Hosts Machines
  2. Setup Virtual Machine Manager
  3. Setup Library Server
  4. Link Team Foundation Server with the Virtual Machine Manager
  5. Setup Build Servers
  6. Setup Test Controllers
  7. Setup your Developer/Test Machines to use Lab Management
These Steps have been detailed below:

Setup Hyper-V Hosts


Hyper-V hosts are physical computers that can be used to run virtual machines. Various Hyper-V hosts will later be linked to a Virtual Machine Manager that will be able to control these hosts.
Quite simply, this is a host running Windows Server 2008 R2 (Standard, Enterprise or Datacenter Edition) with a Hyper-V Role enabled.
The minimum recommended specfication for a host machine has been listed below, however this machine will be running your virtual machines so try getting grunty host machines:
  • Processor: 64 - Bit
  • RAM (min): 2 GB
  • Hard disk (min): 200 GB
If you need help installing the OS, have a look at the following tutorial: http://technet.microsoft.com/en-us/library/dd379511(v=ws.10).aspx.
Once you have installed the OS, you must enable the Hyper-V server role. The following aritcles explain how to install the Hyper-V Role with Server Manager on Windows Server 2008 R2:
Once finished, you must also ensure that this machine has been added to the domain.
Additionally you must ensure that the tfssetup account has been added as an Administrator on the Host machine.
Also, based on your project you may need more than one Host.


Setup Virtual Machine Manager Server


A Virtual Machine Manager Server has the capability to manage one or more Hyper-V host machines. It enables centralized management of physical and virtual IT infrastructure, increased server utilization, and dynamic resource optimization across multiple virtualization platforms.
This can be a physical machine running Windows Server 2008 R2 (Standard, Enterprise or Datacenter Edition). Install the OS and once finished, you must also ensure that this machine has been added to the domain. Additionally you must ensure that the tfssetup account has been added as an Administrator on the Host machine.
The minimum recommended specfication for a vmm machine has been listed below, however this machine will also serve as your library server (I will later explain the purpose of a library server) so try getting a machine with adequate hard disk space:
  • Processor: 64 - Bit
  • RAM (min): 4 GB
  • Hard disk (min): 750 GB
This will need System Center Virtual Machine Manager 2008 R2, with Service Pack 1 (SP1) installed on it. The following articles explain how to install SCVMM:
Apart from the SCVMM server, you will also need to install the VMM Administrator Console.
To manage hosts, they are grouped into Host-Groups. These are a group of physical computers that are hosts that can be used to run virtual machines. Host groups optimize the deployment of virtual machines on the collection of hosts for you, so that you do not have to select the host on which a virtual machin is deployed. By default, all hosts are placed within a group called "All Hosts." I strongly recommend that within the "All Hosts" group you create another group called "Lab Hosts", which will contain your hosts for Lab Management.
After this you can add the hosts that you created earlier to the Virtual Machine Manager. The following youtube video shows you how to add hosts to VMM: http://www.youtube.com/embed/ahMVlTU5-pQ.

Setup Library Server


A library machine or a library server is a computer that is used by VMM to store virtual machines, templates and other resources. While installing SCVMM you have already created a library server on the VMM machine itself. If needed, you can add another library machine to VMM using the VMM Admin Console.

Configure Team Foundation Server


For the purpose of this tutorial I will assume that Team Foundation Server 2010 (TFS2010) has already been installed. If you do not have a TFS2010 installation, the following aritcle should help: http://msdn.microsoft.com/en-us/library/dd631902.aspx.
You must also install the Virtual Machine Manager Administrator Console on the Team Foundation Server.
You need to configre TFS as follows:
  • Ensure that you use the tfssetup as the admin accounts.
  • Connect TFS to VMM using the Team Foundation Server Adminintrator Console.
    • Under Application Tier click "Lab Management"
    • Click "Configure/Reconfigure Lab Management"
    • Specify the fully qualified domain name of the SCVMM server
      • Also ensure you Test it
    • Then under Application Tier click "Team Project Collections"
    • Select the collection you need and then click "Lab Management"
    • then you need to:
      • Configure Library Shares by clicking the "Configure Library Shares" link.
        • Click "Add and Verify" and it should add the default Library Share for you VMM Server.
        • Click "Host Groups" and select the hosts that you would like to deploy to. As per my earlier recommendation you should use the "LabHosts" host group.
        • Click "Service Account" and enter the details of the "tfssetup" account you have used earlier.

Setup Build Servers


A build machine is a computer on which you have installed and configured Team Foundation Build Service. This can be a physical machine running Windows Server 2008 R2 (Standard, Enterprise or Datacenter Edition). Install the OS and once finished, you must also ensure that this machine has been added to the domain. Additionally you must ensure that the tfssetup account has been added as an Administrator on the Host machine.
You must then setup a Build Controller and 1 or many Build Agents. The following tutorial would help set those up:
Also remember, that since this server will build your application, you also need to install other components that our application might need. Start by installing the .Net framework and Visual Studio followed by the other components you may need (example: MVC3 .. etc)

Setup Test Controller


A test controller machine is a computer on which you have installed and configured Team Foundation Build Service. This can be a physical machine running Windows Server 2008 R2 (Standard, Enterprise or Datacenter Edition). Install the OS and once finished, you must also ensure that this machine has been added to the domain. Additionally you must ensure that the tfssetup account has been added as an Administrator on the Host machine.
You must then setup a Test Controller. The following tutorial would help set that up: http://msdn.microsoft.com/en-us/library/dd648127.aspx
This controller runs as a service that manages a set of machines on which the test agent software is installed. You can create multiple environments that are run by the same test controller based on agent availability.

Setup your Developer/Test Machines to use Lab Management


Your developer machine must have:
  • Visual Studio 2010 Ultimate or Premium
  • Microsoft Test Manager 2010