BGP.guru

BGP.guru

Nerd blog.

04 Feb 2015

Does Everything Still Work?

Does everything still work? This is a question often asked after changes in your environment.

Whether its routing/switching changes, firewall rule set/policy changes, or software upgrades, having a pre-defined set of tests which should all pass makes it very easy to run whenever you need re-assurance that things are operating properly. It also makes it very easy to run before, after, or even during changes so the question of “but was it actually working before?” never comes up.

Inspired, and feeling very empowered by a blog post on Test Driven Infrastructure written by a Sean Walberg (a friend of mine from the local Manitoba Unix Users Group), I decided to make Bash Automated Testing System test cases for the various web sites and services I run and support. In about an hour I had 27 tests in place, ranging from basic sanity checks, to 301 and 302 redirects, and even some page content which has to be generated properly to be successful.

A sample test file which tests various components of this domain:

#!/usr/bin/env bats

@test "Ciscodude: root domain" {
  run curl -i http://ciscodude.net/
  [[ $output =~ "301 Moved" ]]
  [[ $output =~ "Location: https://ciscodude.net/" ]]
}

@test "Ciscodude: www" {
  run curl -i http://www.ciscodude.net/
  [[ $output =~ "301 Moved" ]]
  [[ $output =~ "Location: https://ciscodude.net/" ]]
}

@test "Ciscodude: blog" {
  run curl -i http://blog.ciscodude.net/
  [[ $output =~ "301 Moved" ]]
  [[ $output =~ "Location: https://ciscodude.net/" ]]
}

@test "Ciscodude: https" {
  run curl https://ciscodude.net/
  [[ $output =~ "CiscoDude.net" ]]
}

@test "Ciscodude: https ping" {
  run curl https://ciscodude.net/ping/
  [[ $output =~ "OK" ]]
}

A few more tests like this and I’ll have a pretty complete sanity check/test set for my services!


Theodore Baschak - Theo is a network engineer with experience operating core internet technologies like HTTP, HTTPS and DNS. He has extensive experience running service provider networks with OSPF, MPLS, and BGP.