Smoke test for batches

The trend is to create applications which are based on all little services working together, have real time processing and rely on communication between them trough some kind of service bus. Never the less there are many organisations that struggle with big monolithic applications and rely heavily on batch  driven processing every night for several hours. Given that people aren’t very thrilled to monitor the batches during the night and when a problem arises what should they do, can it wait for tomorrow should I call a developer in the middle of the night. Organisations develop some kind of release schedule with stand by roosters and only call the release a success after the entire batch schedule has run.

To improve the release time, stand by hours and feedback cycle there must be an understanding of what already happens during development:

  • Run a huge amount of unit test every time the code is checked in to the repository
  • Deploy to an environment every time the CI build succeeds
  • Run automated UI tests to cover the parts that can’t be hit by unit tests
  • Manually test the requested changes
  • Deploy to a production like environment
  • Run regression test + validate the performance
  • Deploy to production

Leaving you to only test the parts that change between the different environments like your configuration files. Those tests are called Smoke Testing and are a set of basic cheap tests to verify that the deployment was successful and that all the aspects to run real tests are available and set up before proceeding with the actual testing.

I am not a big fan of writing code inside a program with the sole purpose is to test and not add any value to the product. But in perspective to the scenario above it’s a small price to pay to reduce the overhead on releases. To validate the settings inside your config file without your batch to run for hours, you must run the application with a command line parameter like “-smoke” and route it to your test framework instead of running your batch activities. The generic test of visual studio enables you to do so just create a new UnitTestProject and add a Generic test.

During the smoke test you can create your own summary result file to add to your build deployment pipeline you can do this by running the xsd.exe commmand.

From your application you can use the SummaryResult.cs to give feedback to your pipeline run the Visual Studio Test and publish your testresults.

However this will only work when you have Visual Studio Enterprise. In any other On Premise situation you have to find a another way.

Instead of using the SummaryResults.cs you need vstst.cs so we can use the publish test results directly.

To get the vstst.cs working in your program you need to remove the public override object[] Items.

Now to make your file work with the Publish Testresult task you have to do the following at runtime.

To run it for you can use a direct command shell or use a remote powershell session to get your credentials in line with your tested application.

The file you make can now be used in the Publish Testresult task and the results will be added to your pipeline for each environment you choose.

In this zip you will find the modified vstst.cs with a base class to generate the desired resultfile and a example of a config being tested.

I hope this post will give some new insights in how to overcome long lingering releases and provide the evidence that after all your unit, component testing also your environment variables are correct.

 

 

Leave a Reply

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