Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/garethr/puppetdb-expect
Experiment writing tests against data in PuppetDB
https://github.com/garethr/puppetdb-expect
Last synced: 2 months ago
JSON representation
Experiment writing tests against data in PuppetDB
- Host: GitHub
- URL: https://github.com/garethr/puppetdb-expect
- Owner: garethr
- License: epl-1.0
- Created: 2014-08-12T20:21:42.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-08-30T11:54:28.000Z (over 10 years ago)
- Last Synced: 2024-10-04T19:59:24.871Z (3 months ago)
- Language: Clojure
- Size: 168 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## What
[PuppetDB](https://docs.puppetlabs.com/puppetdb/) stores an awful lot of
data about your infrastructure. Better than just storing it though it
provides a powerful API for querying that information. This repository
shows a very simple example of writing tests against PuppetDB data.## Why
Why might you want to do such a think I hear you asking:
* Monitoring - Checks for nodes that haven't reported in?
* Test driven infrastructure - Maybe you want to assert that you have at
least 10 haproxy nodes, or no instances older than a weekThe advantage of querying the information in PuppetDB is that it's
incredibly fast. The obvious disadvantage is that it's second hand data,
although see
[serverspec-puppetdb](https://github.com/garethr/serverspec-puppetdb)
that could help with nerves there.## How
The tests are just clojure, although you could implement the same idea
in any language with a PuppetDB client. The syntax uses
[expectations](http://jayfields.com/expectations/) which leads to some
pretty expressive code:```clojure
(expect 2 (count nodes))
```Or:
```clojure
(expect (installed? "master" "wget"))
```The current [full test
suite](https://github.com/garethr/puppetdb-expect/blob/master/test/puppetdb_expect/test.clj)
is available in the repository.## Running
In order to run the tests yourself you'll need to have a PuppetDB
instance running on HTTP (this is a simple experiement, but the
underlying driver supports HTTPS so it would just need a bit more code)
and to set a `PUPPETDB_ADDRESS` environment variable. Alternatively you
can use `.lein-env` if you know what you're doing.You can run the tests with the following. Note that the specific tests
here are unlikely to pass with anything but the small test dataset I
was using.lein expectations
Much more fun is running the tests everytime you make a change to the
test file.lein autoexpect
## Thanks
Thanks to [clj-puppetdb](https://github.com/holguinj/clj-puppetdb) for
dealing with the PuppetDB interface so I could get on with the job.