How to perform Lab management operations in Build and Release.

As you are already aware, we announced the plan for deprecating XAML builds sometime back.

TFS 2018 RC1 is now available and with that XAML builds are no longer supported. Consequently,  Lab Management and automated testing capabilities in Microsoft Test Manager (MTM) are no longer supported starting from TFS 2018 RC1.

In TFS 2015, we shipped the new scriptable, cross-platform Build and Release Management. Since then, in the several updates to TFS 2015 and TFS 2017 we have continued to evolve the solution, plugging any gaps, addressing feedback and adding new capabilities. Specifically, we have an extensible and easy to use mechanism to manage environments in both public (including Azure and AWS) as well as private clouds (including SCVMM, VMWare, etc.).

This post focuses on how you can achieve Lab Management features using the Build/Release hub in Team Foundation Server and Visual Studio Team Services.

In the new flow, you need to install SCVMM extension on to your VSTS or TFS Server and connect to the SCVMM Server using SCVMM task to create and manage your Virtual Machines. The SCVMM task is available both in build and release.

Here are the list of functionalities supported in lab management which we will walk you through and explain how to achieve the same using Build/Release flow:

  1. Environment creation and Management
  2. Build-deploy-test automation
  3. Self-service creation of network isolated environments

Environment creation and Management

The Lab Center in Microsoft Test Manager supports the ability to manage a library of environment templates as well as provision environments on demand using SCVMM server. In the new flow, you can use SCVMM task to create VMs, service instances from templates or manage environments etc.

The following table summarizes the typical activities you used to perform in Lab Center, and how you can accomplish them through SCVMM extension.

Step Execution flow in Lab Center Recommended flow
Create a lab environment Select an environment template in the library and deploy it. Provide the necessary parameters to customize the virtual machine configurations. Using SCVMM task, you can create new virtual machines from templates.
Manage lab machines Open the lab environment, select the machine. You can choose any action and perform on the selected machine. Using SCVMM task, you can perform various actions like – Start, Stop, Create Virtual machines and Run custom scripts to perform more advanced operations on the machines.
Manage VM checkpoints Open the lab environment in Environment viewer. Select the option to take a checkpoint or to restore to a previous checkpoint. Using the SCVMM task, you can create, restore and delete a checkpoint.
Connect to machines. Open the lab environment in Environment viewer. If you need to connect to the machine physically, you can use SCVMM admin console or DNS/IP to connect remotely.

 

1.Creating SCVMM Environments

  1. Create a release definition and add SCVMM task.
  2. Select “Create VM from template” action and provide the comma separated list of VMs to be created. You can choose to deploy the VMs on a Host Group or Private Cloud.
  3. Trigger a Release to deploy the Virtual Machines.

If you have a complex setup to be created, you can extract the setup configuration from SCVMM as SCVMM PowerShell commandlets which can be executed using SCVMM task with “Run Custom PowerShell” action.

2. Manage VMs:

  1. Create a release definition and add SCVMM task.
  2. From the list of actions, you can select various actions “Start/Stop VM”, “Create VM from template”, “Create/Restore/Delete Checkpoint” actions.

You can use Variable groups to store your environment details like VM names, Host machines, Templates, Username, Passwords, Checkpoints etc. These Variables can be used in your SCVMM task. Variable groups can be used across build and release definitions in your projects.

3. Connect to the machines

  1. To connect to the machines physically you either need to view the machine from SCVMM Admin console or connect remotely using DNS/IP.
  2. However, you can also add the VMs/Machines into a Deployment Group in VSTS/TFS. You can monitor the health of the machines and run your app deployments/tests on them.

Build-deploy-test automation

MTM and Lab Management rely on a XAML build definition to automate build, deployment, and testing of your applications. The XAML build relies on various constructs created in MTM such as a lab environment, test suites, and testing settings, and on various infrastructure components such as a Build controller, Build agents, Test controller, and Test agents to achieve this goal. You can accomplish the same with fewer steps using Build or Release Management in TFS and Team Services.

Steps With XAML Build With Build or Release Management
Identify the machines to deploy build and run tests. Create a standard lab environment in MTM with those machines. Provide the list of VMs and deploy your build and run tests from a Release.
Identify the tests to be run. Create a test suite in MTM, create test cases, and associate automation with each test case. Create test settings in MTM identifying the role of machines in the lab environment in which tests should be run. Run tests directly from test binaries produced by your builds. There is no need to create test settings.
Automate deployment and testing. Create a XAML build definition using LabDefaultTemplate.*.xaml. Specify the build, test suites, and lab environment in the build definition. Create a build definition or a release definition with a single environment. Run the deployment script using the Command line task or first class deployment task and run automated tests.

1. Identify the machines to deploy your application

  • Select a task you want to use for your deployment. Build and Release provides out of the box tasks for various scenarios and you can also find huge list of tasks available in marketplace.
  • Provide the list of machines to deploy your application. This list can be SCVMM environments or standard environments.

 

2. Install your Test Agent

You can run Test Agent Deployment task on list of machines (VMs) using Build or Release.

 

3. Run your automated tests

You can Run Functional Tests and publish the test results.

You can find more details about continuous testing using Build or Release here. Running tests from a test plan in MTM is now replaced with running from the Test hub. We will have another blog post that explains about all the test scenarios.

Self-service creation of network isolated environments

A network isolated lab environment is a group of SCVMM virtual machines that can be cloned safely without causing network conflicts. This was done in MTM using a series of instructions that used a set of network interface cards to configure the virtual machines in a private network, and another set of network interface cards to configure the virtual machines in a public network.

We can achieve similar functionality using SCVMM Network Virtualization concepts. You can connect to the SCVMM server using TFS SCVMM extension and create Isolated Networks from Build and Release.

  1. You can create an Isolated Network of Virtual Machines that span across different hosts in a Host-Cluster or a Private cloud.
  2. You can have VMs from different networks residing in the same host machine and still be isolated from each other.
  3. You can define IP address from the any IP pool of your choice for a VM Network.

We will have another blog post with detailed instructions on how to achieve it.

2