VST08 – End to end build demo

Facebooktwitterlinkedin

 

In this demo, I performed what I called what I called an end to end build demo

This build performed the following steps

  • Build a Visual Studio Solution (I’ve used Fabrikam Fiber as a sample (with minor changes)
  • Run unit tests (NUnit tests)
  • Deploy the web sites to a remote machine
  • Deploy a Visual Studio Test Agent to a remote machine
  • Run Coded UI tests on a remote agent (where we installed the agent) to make sure the application still runs (we just used if for a basic smoke test, but in a real scenario it would run a full battery of tests)

To make things simpler, I’ve choose not to deploy the database, but it could be done using the SQL Server DACPAC deployment task

The fabrikam fiber web sites and the visual studio test agent on the same machine to simplify things (and have less VMs running during the demo), on normal condition the deploy machine and the machine running the agent would be separated.

Pre requirements

The remote machine needs to have WinRM enabled  in order to run remote powerhell commands

  • If the machine is not part of the domain don’t forget to enable WinRM over HTTPS)
  • If you are using Azure stock VMs WinRm  and a certificate are already there, you just need to enable the winrm over HTTPS port in the management portal (or using the cmldets) (port 5986)

The machine already had IIS and MSdeploy pre installed, but I could have managed to provision those automatically using Powershell DSC (and use the Powershell on Target machine to execute it)

 

Configuring the remote machine

The remote machine, should be configured on the test Hub in the machines group (below you can see the list of machine groups configured)

image

Noticed that for the test-agent machine I have configured HTTPS (the machine is not part of the domain, so HTTPS is required)

image

Build definition

This is the build definition in it’s full glory.

image

Bellow you can see the parameters for all individual tasks, if parameter values are omitted it means default values are used.

 

1) Visual Studio Build

image

 

  • Solution $/FabrikamFiber/Dev/FabrikamFiber.CallCenter/FabrikamFiber.CallCenter.sln
  • MSBuildArguments /p:DeployOnBuild=True /p:DeployTarget=Package /p:PackageLocation="$(build.stagingDirectory)"

This task not only compiles the code, but it also create MSdeploy packages. Package creation is achieved with the extran MSBuild arguments

2) Visual Studio Test

image

  • Test Assembly **$(BuildConfiguration)*test*.dll;-:**obj**
  • Test Filter Criteria TestCategory!=UI

In order to only run unit tests, the Coded UI tests were all (well I only had oneSmile) marked with the UI category and then we excluded them with the TestCategory!=UI predicate in the Test Filter Criteria parameter

This is done, using the TestCategory attribute

image

 

3) Publish Build Artifacts

image

  • Contents **bin
  • Artifact Name drop
  • Artifact Type Server

Publish on the server the result on the build (the compiled sites and the MSDeploy packages).

This is mainly to keep on the server a version for the results of the build, for traceability purposes and for example to deploy with Release Management. For all practical purposes in our example we don’t really need this step.

4) Windows Machine File Copy

image

  • Source $(Build.StagingDirectory)
  • Machine Group Insert Your Machine Group name
  • Destination Folder c:deploy

Copy to c:deploy on the target machines the MSDeploy packages built on 1) (and also the fabrikam fiber websites/binaries)

5) Windows Machine File Copy

 

image

  • Source $/FabrikamFiber/Dev/deploy/deploy.ps1
  • Machine Group Insert Your Machine Group name
  • Destination Folder c:deploy

Copy the deploy script (this is the script that will be invoked on the remote machines to deploy fabrikam fiber).

 

6) Powershell on Target Machines

image

  • Machine Group Insert Your Machine Group name
  • Powershell Script c:deploydeploy.ps1

It’s a very simple script, that invokes the batch files generated along with the msdeploy packages

$VerbosePreference =’Continue’

&(Join-Path $PSScriptRoot FabrikamFiber.Extranet.Web.deploy.cmd) /Y
&(Join-Path $PSScriptRoot FabrikamFiber.Web.deploy.cmd) /Y

7) Windows Machine File Copy

image

  • Source $(Build.ArtifactStagingDirectory)dropFabrikamFiber.Web.UITestsbin$(BuildConfiguration)
  • Machine Group Insert Your Machine Group name
  • Destination Folder c:tests

Copies the Coded UI tests to the remote machine for local execution

8) Visual Studio Test Agent Deployment

 

image

 

  • Test Machine Group/ Azure Resource Group Insert Your Machine Group name
  • Username User account under which the test agent will be executed
  • Password Account’s password under which the test agent will be executed
  • Interactive Process Checked
  • Test Agent Location (optional) path to vstf_testagent.exe agent install (if not provided it will downloaded from the internet)
  • Update Test Agent If you enable this the build will take a little longer

Deploys the visual studio agent on the remote machine so we can remotely execute the tests.

9) Visual Studio Test using Test Agent

 

image

  • Test Machine Group/ Azure Resource Group Insert Your Machine Group name
  • Test Drop Location c:tests

And finally executes the coded UI tests

 

 

 

 

Facebooktwitterlinkedin

Leave a Reply

Your email address will not be published. Required fields are marked *