line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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 folder for example tests that you can run |
21
|
|
|
|
|
|
|
agains your server. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
The general configuration should be done through the F 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 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 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 the F folder to the new machine and C 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
|
1
|
|
|
1
|
|
40346
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
51
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
86
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 METHODS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 run() |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
For the moment just runs C. Any other better idea? |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub run { |
64
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
0
|
|
|
|
system('prove', shift || '/etc/t'); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |