-
Notifications
You must be signed in to change notification settings - Fork 5
/
t.pl
156 lines (143 loc) · 4.69 KB
/
t.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/usr/bin/perl
use feature 'say';
say '# ack';
say((
'ack 123 message:message' =~ '^ack (\d+)\s+(.*)$'
) ? "ok -- $1 .. $2" : 'not ok');
say((
'ack host:"service name" message:message' =~ '^ack ([^: ]+):"([^"]+)"\s+(.*)\s*$'
) ? "ok -- $1 .. $2 .. $3" : 'not ok');
say((
'ack host:"service name"' =~ '^ack ([^: ]+):"([^"]+)"\s*$'
) ? "ok -- $1 .. $2" : 'not ok');
say((
'ack host:service name' =~ '^ack ([^: ]+):([^:]+)\s*$'
) ? "ok -- $1 .. $2" : 'not ok');
say((
'ack host message:message' =~ '^ack ([^: ]+)\s(.*)$'
) ? "ok -- $1 .. $2" : 'not ok');
say((
'ack 123' =~ '^ack \S+\s*$'
) ? "ok" : 'not ok');
say '# unack';
say((
'unack 123' =~ '^unack (\d+)\s*$'
) ? "ok -- $1" : 'not ok');
say((
'unack host:"service name"' =~ '^unack ([^: ]+):"([^"]+)"\s*$'
) ? "ok -- $1 $2" : 'not ok');
say((
'unack host:service name' =~ '^unack ([^: ]+):(.+)$'
) ? "ok -- $1 $2" : 'not ok');
say((
'unack host' =~ '^unack ([^: ]+)\s*$'
) ? "ok -- $1" : 'not ok');
say '# recheck';
say((
'recheck 123' =~ '^recheck (\d+)\s*$'
) ? "ok -- $1" : 'not ok');
say((
'recheck host:service name' =~ '^recheck ([^: ]+):.*$'
) ? "ok -- $1" : 'not ok');
say((
'recheck host' =~ '^recheck ([^: ]+)\s*$'
) ? "ok -- $1" : 'not ok');
say '# status';
say((
'status 123' =~ '^status (\d+)\s*$'
) ? "ok -- $1" : 'not ok');
say((
'status host:"service name"' =~ '^status ([^: ]+):"([^"]+)"\s*$'
) ? "ok -- $1 .. $2" : 'not ok');
say((
'status host:service name' =~ '^status ([^: ]+):(.+)$'
) ? "ok -- $1 .. $2" : 'not ok');
say((
'status host' =~ '^status ([^: ]+)\s*$'
) ? "ok -- $1" : 'not ok');
say((
'^status$'
) ? "ok" : 'not ok');
say '# validate';
say((
'validate host' =~ '^validate ([^: ]+)\s*$'
) ? "ok -- $1" : 'not ok');
say '# downtime';
say((
'downtime 123 4d message:message' =~ '^downtime\s+(\d+)\s+(\d+[ydhms])\s+(.*)\s*$'
) ? "ok -- $1 .. $2 .. $3" : 'not ok');
say((
'downtime host:"service name" 4d message:message' =~ '^downtime\s+([^: ]+):"([^"]+)"\s+(\d+[ydhms])\s+(.*)\s*$'
) ? "ok -- $1 .. $2 .. $3 .. $4" : 'not ok');
say((
'downtime host:service name 4d message:message' =~ '^downtime\s+([^: ]+):(.+?)\s+(\d+[ydhms])\s+(.*)\s*$'
) ? "ok -- $1 .. $2 .. $3 .. $4" : 'not ok');
say((
'downtime host 4d message:message' =~ '^downtime\s+([^: ]+)\s+(\d+[ydhms])\s+(.*)\s*$'
) ? "ok -- $1 .. $2 .. $3" : 'not ok');
say '# undowntime';
say((
'undowntime host' =~ '^undowntime ([^: ]+)\s*$'
) ? "ok -- $1" : 'not ok');
say((
'undowntime host:"service name"' =~ '^undowntime ([^: ]+):"([^"]+)"\s*$'
) ? "ok -- $1 .. $2" : 'not ok');
say((
'undowntime host:service name' =~ '^undowntime ([^: ]+):(.+)$'
) ? "ok -- $1 .. $2" : 'not ok');
say '# mute';
say((
'mute' =~ '^mute\s*$'
) ? "ok" : 'not ok');
say '# unmute';
say((
'unmute' =~ '^unmute\s*$'
) ? "ok" : 'not ok');
say '# oncall';
say((
'oncall list' =~ '^(?:oncall|whoisoncall)\s+(list)\s*$'
) ? "ok -- $1" : 'not ok');
say((
'oncall all' =~ '^(?:oncall|whoisoncall)\s+(all)\s*$'
) ? "ok -- $1" : 'not ok');
say((
'oncall name' =~ '^(?:oncall|whoisoncall)\s+(.*)$'
) ? "ok -- $1" : 'not ok');
say((
'oncall' =~ '^(?:oncall|whoisoncall)$'
) ? "ok" : 'not ok');
say '# inventory';
say((
'inv 1234' =~ '^inv(?:entory)?\s+(?:for\s+)?(\d+)\s*$'
) ? "ok -- $1" : 'not ok');
say((
'inv for 1234' =~ '^inv(?:entory)?\s+(?:for\s+)?(\d+)\s*$'
) ? "ok -- $1" : 'not ok');
say((
'inventory 1234' =~ '^inv(?:entory)?\s+(?:for\s+)?(\d+)\s*$'
) ? "ok -- $1" : 'not ok');
say((
'inventory for 1234' =~ '^inv(?:entory)?\s+(?:for\s+)?(\d+)\s*$'
) ? "ok -- $1" : 'not ok');
say((
'inv f.q.d.n' =~ '^inv(?:entory)?\s+(?:for\s+)?(.*)\s*$'
) ? "ok -- $1" : 'not ok');
say((
'inv for f.q.d.n' =~ '^inv(?:entory)?\s+(?:for\s+)?(.*)\s*$'
) ? "ok -- $1" : 'not ok');
say((
'inventory f.q.d.n' =~ '^inv(?:entory)?\s+(?:for\s+)?(.*)\s*$'
) ? "ok -- $1" : 'not ok');
say((
'inventory for f.q.d.n' =~ '^inv(?:entory)?\s+(?:for\s+)?(.*)\s*$'
) ? "ok -- $1" : 'not ok');
say '# edge cases';
say((
'downtime host:service name 4d downtime host for 4d :)' =~ '^downtime\s+([^: ]+):(.+?)\s+(\d+[ydhms])\s+(.*)\s*$'
) ? "ok -- $1 .. $2 .. $3 .. $4" : 'not ok');
say((
'ack host "message message message"' =~ '^ack ([^: ]+)\s(.*)$'
) ? "ok -- $1 .. $2" : 'not ok');
say((
'ack host message message message' =~ '^ack ([^: ]+)\s(.*)$'
) ? "ok -- $1 .. $2" : 'not ok');