@@ -60,113 +60,101 @@ if is_CI; then
60
60
export TIMEOUT=30
61
61
fi
62
62
63
- echo " testing socket ordering result consistency"
63
+ echo " testing socket ordering result consistency: "
64
64
echo
65
65
66
- check_output " yahoo.com" ./find_active_server.py $opts --num-threads 1 --port 80 yahoo.com google.com
66
+ run_grep " ^ yahoo.com$ " ./find_active_server.py $opts --num-threads 1 --port 80 yahoo.com google.com
67
67
68
- hr
69
- echo " testing socket returns only functional server"
68
+ echo " testing socket returns only functional server:"
70
69
echo
71
70
72
- check_output " google.com" ./find_active_server.py $opts --port 80 0.0.0.1 google.com
71
+ run_grep " ^ google.com$ " ./find_active_server.py $opts --port 80 0.0.0.1 google.com
73
72
74
- hr
75
- echo " testing socket ordering result consistency with individual port overrides"
73
+ echo " testing socket ordering result consistency with individual port overrides:"
76
74
echo
77
75
78
- check_output " yahoo.com:80" ./find_active_server.py $opts --port 1 yahoo.com:80 google.com
76
+ run_grep " ^ yahoo.com:80$ " ./find_active_server.py $opts --port 1 yahoo.com:80 google.com
79
77
80
- check_output " google.com:80" ./find_active_server.py $opts --port 1 yahoo.com google.com:80
78
+ run_grep " ^ google.com:80$ " ./find_active_server.py $opts --port 1 yahoo.com google.com:80
81
79
82
80
# ============================================================================ #
83
- hr
84
- echo " checking --ping and --port switch conflict fails"
85
- echo
86
- ./find_active_server.py $opts --ping --port 1 yahoo.com google.com
87
- check_exit_code 3
88
- echo
89
81
90
- hr
91
- echo " checking --ping and --http switch conflict fails"
82
+ echo " checking --ping and --port switch conflict fails:"
92
83
echo
93
- ./find_active_server.py $opts --ping --http yahoo.com google.com
94
- check_exit_code 3
84
+ run_fail 3 ./find_active_server.py $opts --ping --port 1 yahoo.com google.com
85
+
86
+ echo " checking --ping and --http switch conflict fails:"
95
87
echo
88
+ run_fail 3 ./find_active_server.py $opts --ping --http yahoo.com google.com
96
89
97
90
# ============================================================================ #
98
- hr
99
- echo " testing ping returns only functional server"
91
+
92
+ echo " testing ping returns only functional server: "
100
93
echo
101
- check_output " google.com" ./find_active_server.py $opts --ping 0.0.0.1 4.4.4.4 google.com
94
+ run_grep " ^ google.com$ " ./find_active_server.py $opts --ping 0.0.0.1 4.4.4.4 google.com
102
95
103
- hr
104
- echo " testing ping returns only functional server, ignoring port override"
96
+ echo " testing ping returns only functional server, ignoring port override:"
105
97
echo
106
98
107
- check_output " google.com" ./find_active_server.py $opts -n1 --ping 0.0.0.1 4.4.4.4 google.com:80
99
+ run_grep " ^ google.com$ " ./find_active_server.py $opts -n1 --ping 0.0.0.1 4.4.4.4 google.com:80
108
100
109
101
# ============================================================================ #
110
- hr
111
- echo " testing http ordering result consistency"
102
+
103
+ echo " testing http ordering result consistency: "
112
104
echo
113
105
114
106
# Google's server latency is so much less than yahoo's that giving -n2 will allow google.com to overtake yahoo.com, limit to 1 so that yahoo gets the next available slot
115
- check_output " yahoo.com" ./find_active_server.py $opts -n1 --http 0.0.0.1 yahoo.com google.com
107
+ run_grep " ^ yahoo.com$ " ./find_active_server.py $opts -n1 --http 0.0.0.1 yahoo.com google.com
116
108
117
- hr
118
- echo " testing https ordering result consistency"
109
+ echo " testing https ordering result consistency:"
119
110
echo
120
111
121
- check_output " yahoo.com" ./find_active_server.py $opts -n1 --https yahoo.com google.com
112
+ run_grep " ^ yahoo.com$ " ./find_active_server.py $opts -n1 --https yahoo.com google.com
122
113
123
114
# there is an bug somewhere in Alpine Linux's libraries where only --https doesn't limit concurrency and the yahoo result is often faster on https, breaking this test
124
115
# works fine on normal Linux distributions like Centos, Debian and Ubuntu
125
- check_output " google.com" ./find_active_server.py $opts -n1 --https 0.0.0.1 google.com yahoo.com
116
+ run_grep " ^ google.com$ " ./find_active_server.py $opts -n1 --https 0.0.0.1 google.com yahoo.com
126
117
118
+ echo " testing blank result for localhost 9999:"
127
119
echo
128
- echo " testing blank result for localhost 9999"
129
- echo
130
- DEBUG=" " check_output " " ./find_active_server.py --https localhost --port 9999 -q
120
+ DEBUG=" " ERRCODE=1 run_grep " ^$" ./find_active_server.py --https localhost --port 9999 -q
131
121
122
+ echo " testing NO_AVAILABLE_SERVER for localhost 9999 verbose:"
132
123
echo
133
- echo " testing NO_AVAILABLE_SERVER for localhost 9999 verbose"
134
- echo
135
- check_output " NO_AVAILABLE_SERVER" ./find_active_server.py --https localhost --port 9999
124
+ ERRCODE=1 run_grep " ^NO_AVAILABLE_SERVER$" ./find_active_server.py --https localhost --port 9999
136
125
137
126
# echo
138
127
# echo "testing http returns no results when using wrong port 25"
139
128
# echo
140
129
141
130
# DEBUG=1 breaks this to return NO_AVAILABLE_SERVER
142
- # DEBUG="" check_output " " ./find_active_server.py $opts mail.google.com --http --port 25
131
+ # DEBUG="" ERRCODE=1 run_grep "^$ " ./find_active_server.py $opts mail.google.com --http --port 25
143
132
144
133
# hangs a bit
145
- # check_output " NO_AVAILABLE_SERVER" ./find_active_server.py $opts mail.google.com --https --port 25
134
+ # ERRCODE=1 run_grep "^ NO_AVAILABLE_SERVER$ " ./find_active_server.py $opts mail.google.com --https --port 25
146
135
147
- echo
148
- echo " testing https with url path and regex matching"
136
+ echo " testing https with url path and regex matching:"
149
137
echo
150
138
151
- check_output " github.com" ./find_active_server.py $opts --https google.com github.com -u /harisekhon --regex ' pytools'
139
+ run_grep " ^ github.com$ " ./find_active_server.py $opts --https google.com github.com -u /harisekhon --regex ' pytools'
152
140
153
141
# ============================================================================ #
154
- hr
155
- echo " testing HTTP regex filtering"
142
+
143
+ echo " testing HTTP regex filtering: "
156
144
echo
157
145
158
- check_output " yahoo.com" ./find_active_server.py $opts --http --regex ' yahoo' google.com yahoo.com
146
+ run_grep " ^ yahoo.com$ " ./find_active_server.py $opts --http --regex ' yahoo' google.com yahoo.com
159
147
160
148
# ============================================================================ #
161
- hr
162
- echo " testing HTTPS regex filtering"
149
+
150
+ echo " testing HTTPS regex filtering: "
163
151
echo
164
152
165
- check_output " yahoo.com" ./find_active_server.py $opts --https --regex ' (?:yahoo)' google.com yahoo.com
153
+ run_grep " ^ yahoo.com$ " ./find_active_server.py $opts --https --regex ' (?:yahoo)' google.com yahoo.com
166
154
167
155
# ============================================================================ #
168
- hr
169
- echo " testing random socket select 10 times contains both google and yahoo results"
156
+
157
+ echo " testing random socket select 10 times contains both google and yahoo results: "
170
158
echo
171
159
172
160
# Google's servers are consistenly so much faster / lower latency that I end up with all 10 as google here, must restrict to single threaded random to allow yahoo to succeed
@@ -196,10 +184,11 @@ else
196
184
die " Failed to return both google.com and yahoo.com in results from $count_socket_attempts --random runs"
197
185
fi
198
186
echo
187
+ hr
199
188
200
189
# ============================================================================ #
201
- hr
202
- echo " testing random http select 10 times contains both google and yahoo results"
190
+
191
+ echo " testing random http select 10 times contains both google and yahoo results: "
203
192
echo
204
193
205
194
# output="$(for x in {1..10}; do ./find_active_server.py -n1 --http --random google.com yahoo.com; done)"
@@ -229,6 +218,7 @@ if [ $found_google_http -eq 1 -a $found_yahoo_http -eq 1 ]; then
229
218
else
230
219
die " Failed to return both google.com and yahoo.com in results from $count_http_attempts --random runs"
231
220
fi
221
+ hr
232
222
233
223
echo
234
224
echo " SUCCEEDED - all tests passed for find_active_server.py"
0 commit comments