96b4d54273af2835174af3bd006c74f02ba15fc7
[kai/samba-autobuild/.git] / ctdb / tests / eventd / eventd_032.sh
1 #!/bin/sh
2
3 . "${TEST_SCRIPTS_DIR}/unit.sh"
4
5 define_test "failures with multiple scripts"
6
7 cat > "$eventd_scriptdir/01.test.script" <<EOF
8 #!/bin/sh
9
10 case "\$1" in
11 startup)
12         exit 1
13         ;;
14 monitor|ipreallocated)
15         exit 0
16         ;;
17 esac
18
19 EOF
20 chmod +x "$eventd_scriptdir/01.test.script"
21
22 cat > "$eventd_scriptdir/02.test.script" <<EOF
23 #!/bin/sh
24
25 case "\$1" in
26 monitor)
27         exit 2
28         ;;
29 startup|ipreallocated)
30         exit 0
31         ;;
32 esac
33
34 EOF
35 chmod +x "$eventd_scriptdir/02.test.script"
36
37 cat > "$eventd_scriptdir/03.test.script" <<EOF
38 #!/bin/sh
39
40 case "\$1" in
41 ipreallocated)
42         exit 3
43         ;;
44 startup|monitor)
45         exit 0
46         ;;
47 esac
48
49 EOF
50 chmod +x "$eventd_scriptdir/03.test.script"
51
52 setup_eventd
53
54 required_result 1 <<EOF
55 Failed to run event startup, result=1
56 EOF
57 simple_test run startup 30
58
59 required_result 1 <<EOF
60 01.test              ERROR      DURATION DATETIME
61   OUTPUT: 
62 EOF
63 simple_test status startup
64
65 required_result 0 <<EOF
66 Event startup has never passed
67 EOF
68 simple_test status startup lastpass
69
70 required_result 1 <<EOF
71 01.test              ERROR      DURATION DATETIME
72   OUTPUT: 
73 EOF
74 simple_test status startup lastfail
75
76 required_result 2 <<EOF
77 Failed to run event monitor, result=2
78 EOF
79 simple_test run monitor 30
80
81 required_result 2 <<EOF
82 01.test              OK         DURATION DATETIME
83 02.test              ERROR      DURATION DATETIME
84   OUTPUT: 
85 EOF
86 simple_test status monitor
87
88 required_result 0 <<EOF
89 Event monitor has never passed
90 EOF
91 simple_test status monitor lastpass
92
93 required_result 2 <<EOF
94 01.test              OK         DURATION DATETIME
95 02.test              ERROR      DURATION DATETIME
96   OUTPUT: 
97 EOF
98 simple_test status monitor lastfail
99
100 required_result 3 <<EOF
101 Failed to run event ipreallocated, result=3
102 EOF
103 simple_test run ipreallocated 30
104
105 required_result 3 <<EOF
106 01.test              OK         DURATION DATETIME
107 02.test              OK         DURATION DATETIME
108 03.test              ERROR      DURATION DATETIME
109   OUTPUT: 
110 EOF
111 simple_test status ipreallocated
112
113 required_result 0 <<EOF
114 Event ipreallocated has never passed
115 EOF
116 simple_test status ipreallocated lastpass
117
118 required_result 3 <<EOF
119 01.test              OK         DURATION DATETIME
120 02.test              OK         DURATION DATETIME
121 03.test              ERROR      DURATION DATETIME
122   OUTPUT: 
123 EOF
124 simple_test status ipreallocated lastfail