Testing Your CI Procedures with ElectricCommander

Medical Compliance

As more and more of our customers are moving from a waterfall process to a lean, agile one, the common question I get is “How do I test my ElectricCommander changes so I can reduce my errors and therefore downtime on my production server?”

As a matter of fact, a lot of companies are using the ElectricCommander platform to ensure that what their developers build is thoroughly tested across multiple environments before being deployed in production.

But how do you ensure the same precautions are taken so a bad change made to an ElectricCommander procedure does not result in the downtime of your internal development pipeline. After all, breaking the build CI workflow has a cost in term of lost development time, even if it does not necessarily impact your external customers.

Our Services team runs into this request often, and so we are making available our own internal test framework for your usage. You can find it in our community GitHub repository. While the projects we publish on GitHub are not officially supported, we will do our best to fix any problems you encounter.

The framework is composed of the following parts:

  1. The “ntest” Perl script that will read and execute your tests. It is compatible with ec-perl 5.8.8 provided with ElectricCommander.
  2. An “Assert.pm” module that makes it easy to test different assertions
  3. A helper module named ECTest.pm to make it easier to write tests.
  4. A directory with some examples. Additional real life example can be found in the EC-Admin repository under src/systemtest

How to write a test:

The README.md will give you detailed information on how to run and write tests but here is a very short example to show you how easy it is to write a simple test.

In this example I have a factory procedure that is used to create a project and ensure naming conventions. So my test will reflect if the procedure “createSafeProject” does it job correctly:

  1. Create the project as requested
  2. Reject projects whose name start with a number
  3. Reject projects whose name contains spaces

So here are some excerpts from the createSafeProject.ntest.

The first test simply verifies the procedure has been created as expected by using the factory procedure called “createSafeProject”:

The second test is to verify that a project whose name starts with number is not created:

The third example is to check that the project does not contain spaces

To invoke ntest, use the “–target” option to point to your commander server and simply add the directory containing your *.ntest files (or a list of files)

It should produce something like:

So now you can get to it :) Hit me up if you have any questions or comments!


Want to see more cool things you can do with ElectricCommander?

does-laurenCheck out my talk at the recent DevOps Enterprise Summit for best practices for achieving Continuous Delivery with ElectricCommander.

Laurent Rochette

Laurent Rochette is a Professional Service Engineer with Electric Cloud. He trains customers on our products and help them with deployments and consulting to enable them to use our products effectively. Prior to joining Electric Cloud, Laurent served as an IT Architect at Mentor Graphics. Laurent holds a Master degree in Computer Science from the Grenoble Polytechnic Institute (INPG) in France.

Share this:

Leave a Reply

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

Subscribe

Subscribe via RSS
Click here to subscribe to the Electric Cloud Blog via RSS

Subscribe to Blog via Email
Enter your email address to subscribe to this blog and receive notifications of new posts by email.