Skip to content

Commit

Permalink
tests(*) removed tests that are not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
locao committed Jan 7, 2021
1 parent 6e58722 commit fef5a18
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 99 deletions.
47 changes: 0 additions & 47 deletions t/01-start-stop.t
Original file line number Diff line number Diff line change
Expand Up @@ -43,49 +43,15 @@ __DATA__
ngx.sleep(0.2) -- wait twice the interval
local ok, err = checker:start()
ngx.say(ok)
ngx.say(checker.timer_count)
}
}
--- request
GET /t
--- response_body
true
2
--- no_error_log
[error]

=== TEST 2: start() cannot start a second time using active health checks
--- http_config eval: $::HttpConfig
--- config
location = /t {
content_by_lua_block {
local we = require "resty.worker.events"
assert(we.configure{ shm = "my_worker_events", interval = 0.1 })
local healthcheck = require("resty.healthcheck")
local checker = healthcheck.new({
name = "testing",
shm_name = "test_shm",
checks = {
active = {
healthy = {
interval = 0.1
},
unhealthy = {
interval = 0.1
}
}
}
})
local ok, err = checker:start()
ngx.say(err)
}
}
--- request
GET /t
--- response_body
cannot start, 2 (of 2) timers are still running
--- no_error_log
[error]

=== TEST 3: start() is a no-op if active intervals are 0
--- http_config eval: $::HttpConfig
Expand Down Expand Up @@ -115,7 +81,6 @@ cannot start, 2 (of 2) timers are still running
ngx.say(ok)
local ok, err = checker:start()
ngx.say(ok)
ngx.say(checker.timer_count)
}
}
--- request
Expand All @@ -124,7 +89,6 @@ GET /t
true
true
true
0
--- no_error_log
[error]

Expand Down Expand Up @@ -152,17 +116,12 @@ true
})
local ok, err = checker:stop()
ngx.say(ok)
ngx.say(checker.timer_count)
ngx.sleep(0.2) -- wait twice the interval
ngx.say(checker.timer_count)
}
}
--- request
GET /t
--- response_body
true
2
0
--- no_error_log
[error]
checking
Expand Down Expand Up @@ -191,22 +150,16 @@ checking
})
local ok, err = checker:stop()
ngx.say(ok)
ngx.say(checker.timer_count)
ngx.sleep(0.2) -- wait twice the interval
ngx.say(checker.timer_count)
local ok, err = checker:start()
ngx.say(ok)
ngx.say(checker.timer_count)
ngx.sleep(0.2) -- wait twice the interval
}
}
--- request
GET /t
--- response_body
true
2
0
true
2
--- error_log
checking
5 changes: 1 addition & 4 deletions t/03-get_target_status.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use Cwd qw(cwd);

workers(1);

plan tests => repeat_each() * (blocks() * 4) + 2;
plan tests => repeat_each() * (blocks() * 4);

my $pwd = cwd();

Expand Down Expand Up @@ -77,9 +77,6 @@ GET /t
true
false
true
--- error_log
checking healthy targets: nothing to do
checking unhealthy targets: nothing to do
--- no_error_log
checking healthy targets: #1
checking unhealthy targets: #1
6 changes: 1 addition & 5 deletions t/04-report_success.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use Cwd qw(cwd);

workers(1);

plan tests => repeat_each() * 32;
plan tests => repeat_each() * 28;

my $pwd = cwd();

Expand Down Expand Up @@ -84,8 +84,6 @@ GET /t
true
true
--- error_log
checking healthy targets: nothing to do
checking unhealthy targets: nothing to do
healthy SUCCESS increment (1/3) for '(127.0.0.1:2116)'
healthy SUCCESS increment (2/3) for '(127.0.0.1:2116)'
healthy SUCCESS increment (3/3) for '(127.0.0.1:2116)'
Expand Down Expand Up @@ -161,8 +159,6 @@ GET /t
true
true
--- error_log
checking healthy targets: nothing to do
checking unhealthy targets: nothing to do
healthy SUCCESS increment (1/3) for '(127.0.0.1:2116)'
healthy SUCCESS increment (2/3) for '(127.0.0.1:2116)'
healthy SUCCESS increment (3/3) for '(127.0.0.1:2116)'
Expand Down
9 changes: 1 addition & 8 deletions t/05-report_failure.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use Cwd qw(cwd);

workers(1);

plan tests => repeat_each() * (blocks() * 11) - 1;
plan tests => repeat_each() * 26;

my $pwd = cwd();

Expand Down Expand Up @@ -84,8 +84,6 @@ GET /t
false
false
--- error_log
checking healthy targets: nothing to do
checking unhealthy targets: nothing to do
unhealthy HTTP increment (1/3) for '(127.0.0.1:2117)'
unhealthy HTTP increment (2/3) for '(127.0.0.1:2117)'
unhealthy HTTP increment (3/3) for '(127.0.0.1:2117)'
Expand Down Expand Up @@ -161,8 +159,6 @@ GET /t
false
false
--- error_log
checking healthy targets: nothing to do
checking unhealthy targets: nothing to do
unhealthy TCP increment (1/2) for '(127.0.0.1:2117)'
unhealthy TCP increment (2/2) for '(127.0.0.1:2117)'
event: target status '(127.0.0.1:2117)' from 'true' to 'false'
Expand Down Expand Up @@ -235,9 +231,6 @@ GET /t
--- response_body
true
true
--- error_log
checking healthy targets: nothing to do
checking unhealthy targets: nothing to do
--- no_error_log
unhealthy TCP increment (1/2) for '(127.0.0.1:2117)'
unhealthy TCP increment (2/2) for '(127.0.0.1:2117)'
Expand Down
18 changes: 1 addition & 17 deletions t/06-report_http_status.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use Cwd qw(cwd);

workers(1);

plan tests => repeat_each() * 53;
plan tests => repeat_each() * 41;

my $pwd = cwd();

Expand Down Expand Up @@ -84,8 +84,6 @@ GET /t
false
false
--- error_log
checking healthy targets: nothing to do
checking unhealthy targets: nothing to do
unhealthy HTTP increment (1/3) for '(127.0.0.1:2119)'
unhealthy HTTP increment (2/3) for '(127.0.0.1:2119)'
unhealthy HTTP increment (3/3) for '(127.0.0.1:2119)'
Expand Down Expand Up @@ -164,8 +162,6 @@ GET /t
true
true
--- error_log
checking healthy targets: nothing to do
checking unhealthy targets: nothing to do
healthy SUCCESS increment (1/4) for '(127.0.0.1:2119)'
healthy SUCCESS increment (2/4) for '(127.0.0.1:2119)'
healthy SUCCESS increment (3/4) for '(127.0.0.1:2119)'
Expand Down Expand Up @@ -237,9 +233,6 @@ qq{
GET /t
--- response_body
false
--- error_log
checking healthy targets: nothing to do
checking unhealthy targets: nothing to do
--- no_error_log
healthy SUCCESS increment
event: target status '127.0.0.1 (127.0.0.1:2119)' from 'false' to 'true'
Expand Down Expand Up @@ -304,9 +297,6 @@ qq{
GET /t
--- response_body
false
--- error_log
checking healthy targets: nothing to do
checking unhealthy targets: nothing to do
--- no_error_log
healthy SUCCESS increment
event: target status '127.0.0.1 (127.0.0.1:2119)' from 'false' to 'true'
Expand Down Expand Up @@ -371,9 +361,6 @@ qq{
GET /t
--- response_body
true
--- error_log
checking healthy targets: nothing to do
checking unhealthy targets: nothing to do
--- no_error_log
unhealthy HTTP increment
event: target status '127.0.0.1 (127.0.0.1:2119)' from 'true' to 'false'
Expand Down Expand Up @@ -438,9 +425,6 @@ qq{
GET /t
--- response_body
true
--- error_log
checking healthy targets: nothing to do
checking unhealthy targets: nothing to do
--- no_error_log
unhealthy HTTP increment
event: target status '(127.0.0.1:2119)' from 'true' to 'false'
Expand Down
10 changes: 1 addition & 9 deletions t/07-report_tcp_failure.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use Cwd qw(cwd);

workers(1);

plan tests => repeat_each() * 24;
plan tests => repeat_each() * 18;

my $pwd = cwd();

Expand Down Expand Up @@ -84,8 +84,6 @@ GET /t
false
false
--- error_log
checking healthy targets: nothing to do
checking unhealthy targets: nothing to do
unhealthy TCP increment (1/3) for '(127.0.0.1:2120)'
unhealthy TCP increment (2/3) for '(127.0.0.1:2120)'
unhealthy TCP increment (3/3) for '(127.0.0.1:2120)'
Expand Down Expand Up @@ -154,9 +152,6 @@ qq{
GET /t
--- response_body
true
--- error_log
checking healthy targets: nothing to do
checking unhealthy targets: nothing to do
--- no_error_log
unhealthy TCP increment
event: target status '(127.0.0.1:2120)' from 'true' to 'false'
Expand Down Expand Up @@ -221,9 +216,6 @@ qq{
GET /t
--- response_body
true
--- error_log
checking healthy targets: nothing to do
checking unhealthy targets: nothing to do
--- no_error_log
unhealthy TCP increment
event: target status '(127.0.0.1:2120)' from 'true' to 'false'
10 changes: 1 addition & 9 deletions t/08-report_timeout.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use Cwd qw(cwd);

workers(1);

plan tests => repeat_each() * 22;
plan tests => repeat_each() * 16;

my $pwd = cwd();

Expand Down Expand Up @@ -84,8 +84,6 @@ GET /t
false
false
--- error_log
checking healthy targets: nothing to do
checking unhealthy targets: nothing to do
unhealthy TIMEOUT increment (1/2) for '(127.0.0.1:2122)'
unhealthy TIMEOUT increment (2/2) for '(127.0.0.1:2122)'
event: target status '(127.0.0.1:2122)' from 'true' to 'false'
Expand Down Expand Up @@ -154,9 +152,6 @@ qq{
GET /t
--- response_body
true
--- error_log
checking healthy targets: nothing to do
checking unhealthy targets: nothing to do
--- no_error_log
unhealthy TCP increment
event: target status '(127.0.0.1:2122)' from 'true' to 'false'
Expand Down Expand Up @@ -223,9 +218,6 @@ qq{
GET /t
--- response_body
true
--- error_log
checking healthy targets: nothing to do
checking unhealthy targets: nothing to do
--- no_error_log
unhealthy TCP increment
event: target status '(127.0.0.1:2122)' from 'true' to 'false'

0 comments on commit fef5a18

Please sign in to comment.