Probably, you have thought to test HTTP results such like status code, response headers and body, or SQL query results by Serverspec. I have done too. But then you should have felt strangeness like “Is Serverspec responsible for such higher level state? Which resource type should I use? Execute curl command from target server to loopback interface? How about virtual hosts”? After a little thought about attribute of Serverspec, my questions were summarized as “Are HTTP responses and SQL results states of server? By analogizing from Serverspec’s current Resource Types, it tests STATES of servers”.
A day I was stumped about that, Gosuke Miyashita, a.k.a mizzy, a developer of Serverspec, advised me to check Infrataster out. It brought out my feeling of strangeness reasonable.
What Infrataster tests are not server’s states but behaviors. We can test, for instance, HTTP response headers like this:
They test whether some URIs are processed by PHP or not. And, because when executing the tests HTTP connections from local machine to remote server are established, they fail if firewall blocks port 80. It cannot be found by Serverspec’s `port(80) should be_listening` test because it tests remote server’s internal state.
One more example. With MySQL plugin, you may want to test that MySQL’s user for WordPress exists. Go to test code:
More conveniently, you can test the CURRENT values of MySQL settings.
This test is more valuable than ones to check MySQL configuration files because developers might change the settings online by `mysql` command and it is not reflected to files.
Yes, you can do the same thing by `mysqladmin variables` and some filter commands on remote server. But once we started Infrataster, we don’t need to write non-essential filter command hacks anymore and can keep test code simple.
I’m not saying you should stop to use Serverspec. You should use BOTH Serverspec and Infrataster together, the former for server states and the latter for behaviors. (Actually my chef-solo repo has “spec/internal” directory for Serverspec and “spec/behavior” directory for Infrataster.) As Miyashita says, they are in complementary relationship:
Request for readers
I’m not good at English and this article is a practice of it. I’m glad if you point out mistakes and/or badness of my English.