Bicep is the latest declarative IaC tool from Microsoft for Azure, which is built on top of Azure Resource Manager (ARM) templates. Bicep offers you the ability to deploy even preview resources on Azure as it is always will be the most up to date IaC declarative tool Azur. Bicep convertors to into ARM JSON for execution. We have seen how to setup development environment for Bicep in windows in the post here. In this post let's get started with developing Bicep code to deploy infrastructure to Azure.
Saturday, 15 May 2021
Wednesday, 12 September 2018
Using Unified Agent for Executing Automated Tests Without Installing Visual Studio in Test Client–Azure DevOps/VSTS
As described in the post “Running UI Tests with Unified Agent” you can setup unified agent (same agent used for build/deployment in Azure DevOps/VSTS), in an application pool or in a deployment group to execute functional UI tests. The unified agent is really useful as it does not require to setup separate test agent using winRM based Deploy Test Agent task which is required if Run Functional Tests task is used for automated test execution.With unified agent you can use Visual Studio Test task, which is capable of running Selenium based UI tests as well, in addition to Coded UI tests. There was a dependency that you needed to have Visual Studio installed in the test client machine to get the Visual Studio Test task as it is packaged with Visual Studio. However, thanks to the NuGet package “Microsoft Test Platform” you no longer need to install full Visual Studio in your test client machine to execute automated tests, with unified agent using Visual Studio Test task. Let’s look at how to use “Microsoft Test Platform” and Visual Studio Test task in a test client using Azure DevOps Release Management.
Monday, 10 October 2016
Setup Test Farm and Test Clients for Test Execution
- Create Virtual Network in Azure
- Create Virtual Machines in Azure for the Test Farm.
- Setup release agents in the admin machine in Azure, to use with each test client following instructions in here.
- Enable PowerShell remoting in each test client and verify access from the test farm admin VM in Azure.
Setup to start and stop Resource Group
Use a blob in azure to keep the status of the test client. Once test client done create a text file as done to notify the farm stop environment. This is required since TFS 2015 is not yet able to wait for multiple environments in release management to start its execution. (have a look at Release Management - Deploy based on conditions in multiple environments in here).
Script to do this
param( [Parameter(mandatory=$true)] [string]$storageAccountName, [Parameter(mandatory=$true)] [string]$ResourceGroupName, [Parameter(mandatory=$true)] [string]$releaseContainerName ) #Add-AzureRmAccount $releaseContainerName = $releaseContainerName.ToLower(); $StorageAccount = Get-AzureRmStorageAccount -StorageAccountName $storageAccountName -ResourceGroupName $ResourceGroupName #-StorageAccountKey $storageKey Write-Host "Storage Account obtained" $StorageAccount $NewReleaseContainer = New-AzureStorageContainer -Name $releaseContainerName -Context $StorageAccount.Context -Permission Blob Write-Host ("Release container:{0} created in storage account:{1}" -f $releaseContainerName, $storageAccountName) $NewReleaseContainer
Wait script
param( [Parameter(mandatory=$true)] [string]$storageAccountName, [Parameter(mandatory=$true)] [string]$ResourceGroupName, [Parameter(mandatory=$true)] [string]$releaseContainerName, [Parameter(mandatory=$true)] [string]$releaseEnvName ) #Add-AzureRmAccount $releaseContainerName = $releaseContainerName.ToLower(); $StorageAccount = Get-AzureRmStorageAccount -StorageAccountName $storageAccountName -ResourceGroupName $ResourceGroupName #-StorageAccountKey $storageKey Write-Host "Storage Account obtained" $StorageAccount $releaseContainer = Get-AzureStorageContainer -Name $releaseContainerName -Context $StorageAccount.Context Write-Host ("Release container:{0} obtaned in storage account:{1}" -f $releaseContainerName, $storageAccountName) $BlobContainer = $releaseContainer.CloudBlobContainer; Write-Host "Blob Container obtained" $BlobContainer $releaseEnvBlob = $BlobContainer.GetBlockBlobReference($releaseEnvName) Write-Host ("Release env:{0} blob reference obtained." -f $releaseEnvName) $releaseEnvBlob.UploadText("Done"); Write-Host ("Release env:{0} done flag set." -f $releaseEnvName)
param( [Parameter(mandatory=$true)] [string]$storageAccountName, [Parameter(mandatory=$true)] [string]$ResourceGroupName, [Parameter(mandatory=$true)] [string]$releaseContainerName ) #Add-AzureRmAccount $releaseContainerName = $releaseContainerName.ToLower(); $StorageAccount = Get-AzureRmStorageAccount -StorageAccountName $storageAccountName -ResourceGroupName $ResourceGroupName #-StorageAccountKey $storageKey Write-Host "Storage Account obtained" $StorageAccount Remove-AzureStorageContainer -Name $releaseContainerName -Context $StorageAccount.Context -Force Write-Host ("Release container:{0} removed in storage account:{1}" -f $releaseContainerName, $storageAccountName)
http://chamindac.blogspot.com/2016/06/deploying-to-untrusted-domaintfs-2015.html
Machines created with same virtual network, enable file and printer sharing.. since same workgroup all will be accessible Same username password as administrator user.(Even different user would work.). All of the machines are in same workgroup in Azure (refer Create Virtual Machines in Azure for the Test Farm).
Setup the test agent deployment task and test execution task.
Windows file copy task to copy the test binaries to the test execution folder.
Test Run task to run the tests.
Once a test client is done it will be creating a text file in blob container to notify the waiting task monitoring the blob container.
Set environment done script.
param( [Parameter(mandatory=$true)] [string]$storageAccountName, [Parameter(mandatory=$true)] [string]$ResourceGroupName, [Parameter(mandatory=$true)] [string]$releaseContainerName, [Parameter(mandatory=$true)] [string]$releaseEnvName ) #Add-AzureRmAccount $releaseContainerName = $releaseContainerName.ToLower(); $StorageAccount = Get-AzureRmStorageAccount -StorageAccountName $storageAccountName -ResourceGroupName $ResourceGroupName #-StorageAccountKey $storageKey Write-Host "Storage Account obtained" $StorageAccount $releaseContainer = Get-AzureStorageContainer -Name $releaseContainerName -Context $StorageAccount.Context Write-Host ("Release container:{0} obtaned in storage account:{1}" -f $releaseContainerName, $storageAccountName) $BlobContainer = $releaseContainer.CloudBlobContainer; Write-Host "Blob Container obtained" $BlobContainer $releaseEnvBlob = $BlobContainer.GetBlockBlobReference($releaseEnvName) Write-Host ("Release env:{0} blob reference obtained." -f $releaseEnvName) $releaseEnvBlob.UploadText("Done"); Write-Host ("Release env:{0} done flag set." -f $releaseEnvName)
##[warning]DistributedTests: Task 'DownloadTestAgent' for machine do-tf-tc01:5985's Error : System.Management.Automation.Remoting.PSRemotingTransportException: Connecting to remote server do-tf-tc01 failed with the following error message : The WinRM client cannot process the request. If the authentication scheme is different
from Kerberos, or if the client computer is not joined to a domain, then HTTPS transport
must be used or the destination machine must be added to the TrustedHosts configuration
setting. Use winrm.cmd to configure TrustedHosts. Note that computers in the TrustedHosts
list might not be authenticated. You can get more information about that by running the
following command: winrm help config. For more information, see the
about_Remote_Troubleshooting Help topic.
This is because PowerShell remoting is not setup for test agent machine. Follow instructions in Enable PowerShell remoting in each test client and verify access from the test farm admin VM in Azure. to setup PowerShell remoting. Create directory in the test client from admin machine to verify.
Still you may run into below issue if you have more than one test client machine.
Unable to resolve path $env:SystemDrive\TestAgent. Connecting to remote server do-tf-tc01
failed with the following error message : The WinRM client cannot process the request. If
the authentication scheme is different from Kerberos, or if the client computer is not joined
to a domain, then HTTPS transport must be used or the destination machine must be added to the
TrustedHosts configuration setting. Use winrm.cmd to configure TrustedHosts. Note that
computers in the TrustedHosts list might not be authenticated. You can get more information
about that by running the following command: winrm help config. For more information, see the
about_Remote_Troubleshooting Help topic. ---> System.AggregateException: One or more errors
occurred. ---> System.Management.Automation.Remoting.PSRemotingTransportException:
Connecting to remote server do-tf-tc01 failed with the following error message : The WinRM
client cannot process the request. If the authentication scheme is different from Kerberos,
or if the client computer is not joined to a domain, then HTTPS transport must be used or the
destination machine must be added to the TrustedHosts configuration setting. Use winrm.cmd to
configure TrustedHosts. Note that computers in the TrustedHosts list might not be
authenticated. You can get more information about that by running the following command:
winrm help config. For more information, see the about_Remote_Troubleshooting Help topic.
to verify from the admin machine execute below command
Get-Item WSMan:\localhost\Client\TrustedHosts
Only last machine added to trusted hosts available.
To fix Add all machines (http://stackoverflow.com/questions/21548566/how-to-add-more-than-one-machine-to-the-trusted-hosts-list-using-winrm)
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "do-tf-tc01,do-tf-tc02,do-tf-tc03"
Test agent deployment cannot copy files error
System.AggregateException: Failed to execute the powershell script. Consult the logs below for details of the error.
2016-09-09T06:25:55.6714118Z ##[warning]Failed to connect to the path \\do-tf-tc03 with the user do-tf-tc03\doadmin for copying.System error 53 has occurred.
2016-09-09T06:25:55.6714118Z ##[warning] The network path was not found.
2016-09-09T06:25:55.6714118Z ##[warning]
2016-09-09T06:25:55.6714118Z ##[warning] ---> System.Management.Automation.RuntimeException: Failed to connect to the path \\do-tf-tc03 with the user do-tf-tc03\doadmin for copying.System error 53 has occurred.
Fix by allowing file and printer sharing in test client machine firewall.
Once test agent machine restart this is causing issues.
[Window Title]
DTAExecutionHost.exe
[Main Instruction]
DTAExecutionHost.exe has stopped working
[Content]
A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available.
[Close program]
Disable to resolve – Not a good fix at all.
Another problem asking for login while trying to execute tests
To resolve
Setup a local account in Test Client and in TFS AT say tfstestsvcshadow. (This is used as the service account for Test Agent.
Add this user to team project collection test service account.
This resolves DTAExecution startup error as well. Enable the disabled DTAExecution in startup.
With this you will be able to execute the tests.
![[image%255B41%255D.png]](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXtAZBZPsPAWEoxymzTD3gbUT8A6tyGHNVV8UTNn_XZ-tdKt0telBrfFcA15Yyt0i7BP42cqNz0vk4z6LGhLExwu2aWJV4A2NiJECputwCK7Uv_-6Pjqi2b4-xEk5hS9jqp4FpKBv4UhdK/s1600/image%25255B41%25255D.png)
Look at Test Farm as Azure VMs–For TFS2015 Release Management to see how this is running.
Sunday, 28 August 2016
Setup Test Farm as Azure VMs–For TFS2015 Release Management
A test farm which can run test parallel, using more than one test client can improve the time taken to execute the automation test plan. To use resources only on demand setting this up in Azure Virtual machines would be a great option. Let’s look at how we can setup, a test farm, to use with TFS 2015 (TFS 2015 on-premise, update 2.1 onwards).
A fully setup test farm with release management would look like below.(Deployment environments in the release pipeline not shown here for brevity)
Test Farm – Start This environment runs on release agent locally (in corporate network). Expand Variables allows usage of a variable with another configuration variable in release management. Download Artifacts is used to limit the output getting downloaded, to scripts required for starting the test farm in Azure. CreateReleaseRunBlobContainer is used to setup a temporary blob container in azure to allow monitoring of all parallel test machines completion of assigned test execution. Azure resource group deployment step will start the test farm virtual machines, and the wait poweshell script will wait specified number of seconds, after machines started for them to be fully ready. Each of above will be discussed in detail later.
Run Test These environments will run tests parallel in azure VMs. To achieve this, one admin VM is setup in azure with multiple release agents, which deploys test agent to test client. Each test client VM will run a test agent.
Test Farm – Stop This will monitor the blob on azure to determine, if all test environments done with test executions and then shutdown the Azure VMs.
When create release with definition a message popup to say that agents not available for Run Test, this is because Azure machine containing the agent is not started. But this will be OK since the first environment starts Azure VMs.
Once setup fully The test farm can be started on demand and execute tests and shutdown once the test execution done.
In above Test Farm Started, and Tests executed and the Farm Stopped. The Test run steps show as rejected, but actually they are executed fine, only some tests failed marked it as a failed environment (partially succeeded for environment, feature available in VSTS is not yet available for on premise TFS). But this is expected in test run and continue on error for test execution, will enable to run all the tests and after test steps in the given environment (This will e discussed in detail in a later post).
Let’s look at how this can be setup in detail in following posts.
- Create Virtual Network in Azure
- Create Virtual Machines in Azure for the Test Farm. A machine to run release agents (admin machine) and any number of test client machines need to run parallel. All the machines should belong to same workgroup.
- Setup release agents in the admin machine in Azure, to use with each test client following instructions in here.
- Enable PowerShell remoting in each test client and verify access from the test farm admin VM in Azure.
- Setup Test Farm, Start and Stop, and Test Clients for Test Execution.
Tuesday, 20 October 2015
Send Test Result Email After Running Automated Tests with Release Management
Resolve Common Errors - Run Automated Tests with VS Release Management 2013
Disable Lock Screen on Windows 8.1 to Prevent - Automation engine is unable to playback the test because it is not able to interact with the desktop
Increase Default Timeout of Copying Test Binaries to Test Client – Allow Release Management to Run Tests with Increased Timeout
Once everything in place, with a customized TcmExec.ps1, tests get executed with RM.
![[image%255B87%255D.png]](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrXE7niM1hGn6LrqDQDHGkSGdtNTGtyGoAbHkheppHVfLSWa51zvlsWO1V5vf5uh__y066VM3BCtDVbEFMOXHNuZr5USZMY1Ujl5gtjzkZmK9ryQjIBE89ff7iznVkskfthA_aOcmoNr9j/s1600/image%25255B87%25255D.png)
Wouldn’t it be nice to have an email delivered to the team with the test results like shown below?
To do this it is possible to modify the TcmExec.ps1 (How to get the TcmExec.ps1 is described here), to read the details of the test result file (.trx) and create a formatted email message to sent to the defined recipients. As the first step script is introduced with few more parameters.
Extract the build number from the build location path given that the build path contains it.This is to make Test result email look nicer if the build number is not supplied by build TM server.
Extract test result details into a temp table to format it for the email.
Send email and print result in output log of RM action.
Avoid failing the Release Management Action, even if failing tests found when the email send option is set to true. This will make sure deployment completes and the required team members are informed of the Test Results. and give them the option of proceeding or stopping the release pipeline to next steps, after evaluating test results.
Setup a custom tool in RM using the PowerShell script TcmExec.ps1.
If components are already created with the tool they need to be updated with new parameters manually.
Set up the release template to use the test runner with new parameters. All other common issues mentioned at the linked post in the beginning of this post.
Tests are getting executed in TFS lab environment with RM.
Release management action output log has the details of the test printed.
Email with the test results sent to the defined recipients.
You can download the enhanced TcmExec.ps1 from TechNet Gallery.
https://gallery.technet.microsoft.com/Send-Test-Result-Email-5b4f0d5e
Popular Posts
-
As we discusssed in " Setup Redis Cluster with JSON and Search Modules on AKS with Binami Redis Using Custom Image " the cluster...
-
Let’s look at how we can specify the artifact version to download based on the resource CI build linked to the CD pipeline and check on how ...
-
The hosts file in /etc/hosts is allowing the WSL distros to map IP addresses to domain names before going to domain name servers, similar...
-
Can a Coded UI test executed with a Console Application? Yes it is possible. I am going to explain how it can be done. I am going to exec...
-
Pull Request are the controlled way to bring in the changes to your stable branches in your Azure Git repos, or for that matter all Git prov...