Post navigation

Want CI Consul Love? OK! Run Consul in Travis-CI [example scripts]

If you are designing an application that uses microservice registration AND continuous integration then this post is for you! If not, get with the program, you are a fossil.

Sunday night, I posted about the Erlang Consul client I wrote for our Behavior Driven Development (BDD) testing infrastructure. That exposed a need to run a Consul service in the OpenCrowbar Travis-CI build automation that validates all of our pull requests. Basically, Travis spins up the full OpenCrowbar API and workers (we call it the annealer) which in turn registers services in Consul.

NOTE: This is pseudo instructions. In the actual code (here too), I created a script to install consul but this is more illustrative of the changes you need to make in your .travis.yml file.

In the first snippet, we download and unzip consul. It’s in GO so that’s about all we need for an install. I added a version check for logging validation.

After that, the BDD infrastructure can register the fake services that we expect (I created an erlang consul:reg_serv(“name”) routine that makes this super easy). Once the services are registered, OpenCrowbar will check for the services and continue without trying to instantiate them (which it cannot do in Travis).