| 1 | package Test::Server; | ||||||||||||
| 2 | |||||||||||||
| 3 | =head1 NAME | ||||||||||||
| 4 | |||||||||||||
| 5 | Test::Server - what about test driven administration? | ||||||||||||
| 6 | |||||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||||
| 8 | |||||||||||||
| 9 | cp -r examples /etc/t | ||||||||||||
| 10 | cd /etc/t | ||||||||||||
| 11 | vim test-server.yaml | ||||||||||||
| 12 | prove /etc/t | ||||||||||||
| 13 | |||||||||||||
| 14 | use Test::Server; | ||||||||||||
| 15 | Test::Server->run(); | ||||||||||||
| 16 | |||||||||||||
| 17 | =head1 DESCRIPTION | ||||||||||||
| 18 | |||||||||||||
| 19 | Ever heard of test driven development? What about test driven administration? | ||||||||||||
| 20 | Take a look around F<examples/> folder for example tests that you can run | ||||||||||||
| 21 | agains your server. | ||||||||||||
| 22 | |||||||||||||
| 23 | The general configuration should be done through the F<test-server.yaml> and should | ||||||||||||
| 24 | be managable by any non Perl awear admin (are there any?). Of course you are free to | ||||||||||||
| 25 | put any other test that make sence for your server. | ||||||||||||
| 26 | |||||||||||||
| 27 | The idea behind this is following: You run C<prove /etc/t> and everything is | ||||||||||||
| 28 | fine. Server is up and running. Life is nice. Then somebody calls you at 3am... | ||||||||||||
| 29 | Oups! What went wrong? You login to the server (if possible of course) and run | ||||||||||||
| 30 | the C<prove /etc/t> friend. Something failed? => fix it. Nothing failed? | ||||||||||||
| 31 | => write a test that will reveal that something is wrong && fix the problem | ||||||||||||
| 32 | of course ;). And then at 6am go happily to sleep again... | ||||||||||||
| 33 | |||||||||||||
| 34 | To be the administration really test drive ;) you should be writing your tests | ||||||||||||
| 35 | before you install the server... | ||||||||||||
| 36 | |||||||||||||
| 37 | Any other benefits? What about migration || reinstalation of the server? Do you | ||||||||||||
| 38 | always remember what services || purpouses is the server used for? You just | ||||||||||||
| 39 | C<scp> the F</etc/t> folder to the new machine and C<prove /etc/t> will tell | ||||||||||||
| 40 | you. If not you'll write a test ;). | ||||||||||||
| 41 | |||||||||||||
| 42 | Or are you writing firewall rules and need to check if you didn't close some | ||||||||||||
| 43 | ports that you should not? Check out the F<03_open-ports.t>. | ||||||||||||
| 44 | |||||||||||||
| 45 | I hope you'll enjoy the idea as I do. (until I find that there are 30 other | ||||||||||||
| 46 | similar solutions like this...) | ||||||||||||
| 47 | |||||||||||||
| 48 | =cut | ||||||||||||
| 49 | |||||||||||||
| 50 | 2 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 51 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 52 | |||||||||||||
| 53 | 2 | our $VERSION = '0.06'; | |||||||||||
| 54 | |||||||||||||
| 55 | =head1 METHODS | ||||||||||||
| 56 | |||||||||||||
| 57 | =head2 run() | ||||||||||||
| 58 | |||||||||||||
| 59 | For the moment just runs C<prove /etc/t>. Any other better idea? | ||||||||||||
| 60 | |||||||||||||
| 61 | =cut | ||||||||||||
| 62 | |||||||||||||
| 63 | 0 | ▶ | sub run { | ||||||||||
|
Subroutine
run: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 64 | 0 | my $class = shift; | |||||||||||
| 65 | |||||||||||||
| 66 | 0 | ▶ | system('prove', shift || '/etc/t'); | ||||||||||
|
Condition0%0/2
shift() || '/etc/t'
MC/DC0%0/1
shift() || '/etc/t'
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||
| 67 | } | ||||||||||||
| 68 | |||||||||||||
| 69 | 2 | 1; | |||||||||||
| 70 | |||||||||||||
| 71 | |||||||||||||
| 72 | __END__ | ||||||||||||