python: Fix build issues when using "make build_cached"
[omd.git] / t / 10-omd_testsite.t
blob2343fa3bd4013d417e247318386262a41d4623d6
1 #!/usr/bin/env perl
3 use warnings;
4 use strict;
5 use Test::More;
7 BEGIN {
8 use lib('t');
9 require TestUtils;
10 import TestUtils;
11 use FindBin;
12 use lib "$FindBin::Bin/lib/lib/perl5";
15 plan( tests => 159 );
17 my $omd_bin = TestUtils::get_omd_bin();
19 # print omd version
20 my $vtest = { cmd => $omd_bin." version", "exit" => undef };
21 TestUtils::test_command($vtest) or TestUtils::bail_out_clean("no further testing without working omd");
22 diag($vtest->{'stdout'});
24 ########################################
25 # execute some commands
26 my $site = 'testsite';
27 my $site2 = 'testsite2';
28 my $site3 = 'testsite3';
29 my $tests = [
30 { cmd => $omd_bin." versions", like => '/^\d+\.\d+( \(default\))?/' },
31 { cmd => $omd_bin." rm $site", stdin => "yes\n", 'exit' => undef, errlike => undef },
32 { cmd => $omd_bin." rm $site2", stdin => "yes\n", 'exit' => undef, errlike => undef },
33 { cmd => $omd_bin." rm $site2", stdin => "yes\n", 'exit' => undef, errlike => undef },
34 { cmd => $omd_bin." create $site", like => '/Created new site '.$site.'./' },
35 { cmd => $omd_bin." sites", like => '/^'.$site.'\s+\d+\.\d+( \(default\))?/m' },
36 { cmd => "/bin/df -k /omd/sites/$site/tmp/.", like => '/tmpfs/m' },
37 { cmd => $omd_bin." start $site", like => '/Starting nagios/' },
38 { cmd => $omd_bin." status $site", like => [
39 '/apache:\s*running/',
40 '/rrdcached:\s*running/',
41 '/npcd:\s*running/',
42 '/nagios:\s*running/',
43 '/Overall state:\s*running/',
46 { cmd => $omd_bin." stop $site", like => '/Stopping nagios/' },
47 { cmd => $omd_bin." cp $site $site2", like => '/Copying site '.$site.' to '.$site2.'.../',
48 errlike => '/Apache port \d+ is in use\. I\'ve choosen \d+ instead\./' },
49 { cmd => "/usr/bin/find /omd/sites/$site2/ -not -user $site2 -ls", like => '/^\s*$/' },
50 { cmd => "/bin/df -k /omd/sites/$site2/tmp/.", like => '/tmpfs/m' },
51 { cmd => $omd_bin." mv $site2 $site3", like => '/Moving site '.$site2.' to '.$site3.'.../' },
52 { cmd => "/usr/bin/find /omd/sites/$site3/ -not -user $site3 -ls", like => '/^\s*$/' },
53 { cmd => "/bin/df -k /omd/sites/$site3/tmp/.", like => '/tmpfs/m' },
54 { cmd => $omd_bin." rm $site3", like => '/Restarting Apache...\s*OK/', stdin => "yes\n" },
55 { cmd => $omd_bin." rm $site", like => '/Restarting Apache...\s*OK/', stdin => "yes\n" },
56 { cmd => $omd_bin." create -u 7017 -g 7018 $site",
57 like => '/Created new site '.$site.'./' },
58 { cmd => "/usr/bin/id -u $site", like => '/7017/' },
59 { cmd => "/usr/bin/id -g $site", like => '/7018/' },
60 { cmd => $omd_bin." cp -u 7019 -g 7020 $site $site2",
61 like => '/Copying site '.$site.' to '.$site2.'.../',
62 errlike => '/Apache port \d+ is in use\. I\'ve choosen \d+ instead\./' },
63 { cmd => "/usr/bin/id -u $site2", like => '/7019/' },
64 { cmd => "/usr/bin/id -g $site2", like => '/7020/' },
65 { cmd => $omd_bin." mv -u 7021 -g 7022 $site2 $site3", like => '/Moving site '.$site2.' to '.$site3.'.../' },
66 { cmd => "/usr/bin/id -u $site3", like => '/7021/' },
67 { cmd => "/usr/bin/id -g $site3", like => '/7022/' },
68 { cmd => $omd_bin." rm $site", like => '/Restarting Apache...\s*OK/', stdin => "yes\n" },
69 { cmd => $omd_bin." rm $site3", like => '/Restarting Apache...\s*OK/', stdin => "yes\n" },
71 # --reuse
72 { cmd => $omd_bin." create $site", like => '/Created new site '.$site.'./' },
73 { cmd => $omd_bin." rm --reuse $site", stdin => "yes\n" },
74 { cmd => "/usr/bin/id -u $site", like => '/\d+/' },
75 { cmd => "/usr/bin/id -g $site", like => '/\d+/' },
76 { cmd => $omd_bin." create $site2", like => '/Created new site '.$site2.'./', errlike => '/ERROR: Failed to read config of site testsite./' },
77 { cmd => $omd_bin." mv --reuse $site2 $site", like => '/Moving site '.$site2.' to '.$site.'.../' , errlike => '/ERROR: Failed to read config of site testsite./' },
78 { cmd => "/usr/bin/id -u $site2", like => '/\d+/' },
79 { cmd => "/usr/bin/id -g $site2", like => '/\d+/' },
80 { cmd => $omd_bin." cp --reuse $site $site2", like => '/Copying site '.$site.' to '.$site2.'.../',
81 errlike => '/Apache port \d+ is in use\. I\'ve choosen \d+ instead\./' },
82 { cmd => $omd_bin." cp --reuse $site $site2", errlike => '/must be empty/', exit => 1 },
83 { cmd => $omd_bin." rm $site", like => '/Restarting Apache...\s*OK/', stdin => "yes\n" },
84 { cmd => $omd_bin." rm $site2", like => '/Restarting Apache...\s*OK/', stdin => "yes\n" },
87 # run tests
88 for my $test (@{$tests}) {
89 TestUtils::test_command($test) or TestUtils::bail_out_clean("no further testing without working omd");