BM-Bloggers

The blogs of Black Marble staff

Useful links from The ART of Modern Azure Deployments

Within a few days of each other I spoke about Azure Resource Templates at both DDDNorth 2015 and Integration Mondays run by the Integration User Group. I’d like to thank all of you who attended both and have been very kind in your feedback afterwards.

As promised, this post contains the useful links from my final slide.

I’ve already written posts on much of the content covered in my talk. However, since I’m currently sat on a transatlantic flight you can expect a series of posts to follow this on topics such as objects in templates, outputs and references.

If you missed my Integration Monday session, the organisers recorded it and you can watch it online.

Azure PowerShell 1.0 Preview
https://azure.Microsoft.com/en-us/blog/azps-1-0-pre/

Azure QuickStart Templates
https://github.com/Azure/azure-quickstart-templates
http://azure.microsoft.com/en-us/documentation/templates/

ARM Template Documentation
https://msdn.microsoft.com/en-us/library/azure/dn835138.aspx

Azure Resource Explorer
https://resources.azure.com/

“Azure Resource Manager DevOps Jumpstart”
https://www.microsoftvirtualacademy.com/en-US/training-courses/azure-resource-manager-devops-jump-start-8413

My DDDNorth session on Technical Debt and SonarQube

Thanks to everyone who came to my session at DDDNorth on SonarQube, hope you found it useful. The links to resources for my session are

And you can find my slides on my GitHub repo https://github.com/rfennell/Presentations

Patterns & Practices Architecture Track at Future Decoded

In case you had not noticed, our MD and Connected Systems MVP Robert Hogg posted about the new Patterns & Practices Architecture Track he is hosting on Day 1 of the Microsoft Future Decoded event  next month in London.

This track is an additional track to the now full Future Decoded. If you are interested in attending then get in touch with enquiries@blackmarble.com, for the attention of Linda, and she can help you out with a special code (if there are still any left). This code will not only give you access to the excellent p&p track on Day One, but also the Keynotes, so please select Day One when you register!

Wraps are off - patterns & practices Architecture Track at Future Decoded!

I am delighted to announce that I am hosting the Azure patterns&practices team in a dedicated invite-only track on Day One of Future Decoded!

I've been pushing to bring the patterns&practices team to the UK for a few years now, and it's excellent that it's finally happening at the Premier UK Microsoft event this November.

We have Christopher Bennage and Masashi Narumoto travelling in from the patterns&practices team in Corp especially for the event.  The p&p team demonstrate how to bring together architecture best practices for the diverse Microsoft technologies into a unified and holistic solution.  They are passionate about discovering, collecting and encouraging best practices, delighting in software craftmanship, helping developers be successful on Microsoft platforms and bringing joy to engineering software!

I know what you're thinking now, Future Decoded is full, how do I get to attend?  Well, if you're interested (and if you're reading this blog it's safe to say you are!), then get in touch with enquiries@blackmarble.com, for the attention of Linda, and she can help you out with a special code (if there are any left!!) - this code will not only give you access to the excellent p&p track on Day One, but also the Keynotes, so please select Day One when you register!

Release Manager - New deployment is not allowed as an another deployment is in progress

Whilst working with a vNext Release Management pipeline I started seeing the error

Microsoft.TeamFoundation.Release.Common.Helpers.OperationFailedException:
New deployment is not allowed as an another deployment is in progress.
Retry the deployment after sometime.

Problem was I could not see any blocked or paused deployment releases. All Internet searches mentioned multiple pipelines that share components, but this was not the issue.

Eventually I found the issue, my release pipeline included a step that ran CodedUI tests via TCM, hence a previous running of this template had triggered the test via TCM, but they had stalled. I found this by looking in MTM.

image

Release Management was just saying the release was rejected with the above error message, no clue about the unfinished test run. Not that helpful.

You might have expect Release Management to return only after the test had timed out, but that is only down to whether you set the release pipeline to wait or not, I had set mine not to wait.

Once I stopped this test run via MTM all was OK.

Running nUnit and Jasmine.JS unit tests in TFS/VSO vNext build

This article was first published on the Microsoft’s UK Developers site as Running nUnit and Jasmine.JS unit tests in TFS/VSO vNext build

With the advent of vNext build in TFS 2015 and Visual Studio Online running unit tests that are not MSTest based within your build process is far more straightforward than it used to be. No longer do you have to use custom XAML build activities or tell all your TFS build controllers where the test runner assemblies are. The ‘out the box’ vNext build Visual Studio Test task will automatically load any test adaptors it finds in the path specified for test runners in its advanced properties, a path that can be populated via NuGet.

Running nUnit tests

All this means that to find and run MSTest and nUnit tests as part of your build all you have to do is as follows

  1. Create a solution that contains a project with MStest and nUnit tests, in my sample this is a MVC web application project with its automatically created MSTest unit tests project.
  2. In the test project add some nUnit tests. Use NuGet to add the references to nUnit to the test project so it compiles.
  3. Historically in your local Visual Studio instance you needed to install the nUnit Test Runner VSIX package from Visual Studio Gallery – this allows Visual Studio to discover your nUnit tests, as well as any MSTest ones, and run them via the built in Test Explorer

    image

    IMPORTANT Change –
    However installing this VSIX package is no longer required. If you use Nuget to add the nUnit Test Runner to the solution, as well as the nUnit package itself, then Visual Studio can find the nUnit tests without the VSIX package. This is useful but not world changing on your development PC, but when on the build box it means the NuGet restore will make sure the nUnit test adapter assemblies are pulled down onto the local build boxes file system and used to find tests with no extra work.

    Note
    : If you still want to install the VSIX package on your local Visual Studio instance you can, it is just you don’t have to.
  4. Check in your solution into TFS/VSO source control. It does not matter if it is TFVC or Git based
  5. Create a new vNext build using the Visual Studio template
  6. You can leave most of the parameters on default setting. But you do need to edit the Visual Studio Test task’s advanced settings to point at the NuGet packages folder for your solution (which will be populated via NuGet restore) so the custom nUnit test adaptor can be found i.e. usually setting it to  $(Build.SourcesDirectory)\packages

    image
  7. The build should run and find your tests, the MStest ones because they are built in and the nUnit ones because it found the custom test adaptor due to the NuGet restore being done prior to the build. The test results can be found on the build summary page

    image

 

But what if you want run Jasmine.JS test?

If you want to run Jasmine JavaScript unit tests the process is basically the same. The only major difference is that you do still need to install the Chutzpah Test runner on your local Visual Studio as a VSIX package to run the tests locally. There is a NuGet package for the Chutzpah test runner so you can avoid having to manually unpack the VSIX and get it into source control to deploy it to the build host (unless you really want to follow this process), but this package does not currently enable Visual Studio to find the Jasmine tests without the VSIX extension being installed, or at least it didn’t for me.

Using the solution I used before

  1. Use NuGet to add Jasmine.JS to the test project
  2. Add a test file to the test project e.g. mycode.tests.js (adding any JavaScript references needed to find any script code under test in the main WebApp project)
  3. Install the Chutzpah Test runner in your local Visual Studio as a VSIX extension, restart Visual Studio
  4. You should now be able to see and run the Jasmine test run in the test runner as well as the MSTest and nUnit tests.

    image
  5. Add the NuGet package for the Chutzpah test runner to your solution, this is a solution level package, so does not need to be associated with any project.
  6. Check the revised code into source control
  7. In your vNext build add another Visual Studio Test task, set the test assembly to match your javascript test naming convention e.g. **\*.tests.js and the path to the custom test adaptor to $(Build.SourcesDirectory)\packages (as before)

    image
  8. Run the revised build.

    image
  9. You should see the two test tasks run and a pair of test results in the summary for the build.

So now hopefully you should find this a more straight forward way to added testing to your vNext builds. Allowing easy use of both your own build boxes and the hosted build service for VSO with testing frameworks they do not support ‘out the box’

Powershell to help plot graphs of how long TFS upgrades take

When doing TFS upgrades it is useful to know roughly how long they will take. The upgrade programs give a number of steps, but not all steps are equal. Some are quick, some are slow. I have found it useful to graph past updates so I can get a feel of how long an update will take given it got to ‘step x in y minutes’. You can do this by hand, noting down time as specific steps are reached. However for a long upgrade it usually means pulling data out of the TFS TPC upgrade logs.

To make this process easier I put together this script to find the step completion rows in the log file and format them out such that they are easy to graph in Excel

param
(
    $logfile = "TPC_ApplyPatch.log",
    $outfile = "out.csv"
)


# A function to covert the start and end times to a number of minutes
# Can't use simple timespan as we only have the time portion not the whole datetime
# Hence the hacky added a day-1 second
function CalcDuration
{
    param
    (
        $startTime,
        $endTime
    )

    $diff = [dateTime]$endTime - $startTime
    if ([dateTime]$endTime -lt $startTime)
    {
       $diff += "23:59" # add a day as we past midnight
    }

    [int]$diff.Hours *60 + $diff.Minutes
}

Write-Host "Importing $logfile for processing"
# pull out the lines we are interested in using a regular expression to extract the columns
# the (.{8} handle the fixed width, exact matches are used for the test
$lines = Get-Content -Path $logfile | Select-String "  Executing step:"  | Where{$_ -match "^(.)(.{8})(.{8})(Executing step:)(.{2})(.*)(')(.*)([(])(.*)([ ])([of])(.*)"} | ForEach{
    [PSCustomObject]@{
        'Step' = $Matches[10]
        'TimeStamp' = $Matches[2]
        'Action' = $Matches[6]
    }
}
 
# We assume the upgrade started at the timestamp of the 0th step
# Not true but very close
[DateTime]$start = $lines[0].TimeStamp

Write-Host "Writing results to $outfile"
# Work out the duration
$steps = $lines | ForEach{
    [PSCustomObject]@{
        'Step' = $_.Step
        'TimeStamp' = $_.TimeStamp
        'EplasedTime' = CalcDuration -startTime $start -endTime $_.TimeStamp
        'Action' = $_.Action
       
    }
}
$steps | export-csv $outfile -NoTypeInformation

# and list to screen
$steps

Is the Microsoft Band any good for Triathlon? Training Yes, racing No

The title says it all, I have been using a Microsoft Band for a few months now and have found it a great tool for running and cycling as long as you are going out for less than about 5 hours. I tried to use for the first time Triathlon race at at the Leeds Triathlon over the weekend.

As it it not water proof it was not an option for the swim (unlike my old Polar HR monitor), so I put it on in T1 (swim to bike), don’t think it wasted too much time! This is where I hit the first issue (or second if you count that it is not waterproof) that my finger was too wet to operate the touch screen. I have seen this issue on runs on rainy days. So I did not manage to switch it to cycle mode, and did not bother to try again whilst cycling after I had dried out – a had other things on my mind like being a in good aero position and get moving faster.

I did however manage to switch to run mode as I ran out of T2 (bike to run) and it worked OK there.

So my wish list

  • Make it water proof, enough for open water swimming
  • Add a way to sequence different activities (swim, bike, run) and have a simple button what works with wet fingers to switch between them – maybe a de project for myself
  • And of course better battery life

So I still think it is a good product, just not 100% perfect for me as yet