Skip to content

Commit

Permalink
tests(cluster) add test for get_peers() with no peers
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaultcha committed Sep 28, 2016
1 parent 69e5bc0 commit d7195a4
Showing 1 changed file with 40 additions and 10 deletions.
50 changes: 40 additions & 10 deletions t/06-cluster.t
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,37 @@ corrupted shm
=== TEST 14: set_peer_down()/set_peer_up()/can_try_peer() set shm booleans for nodes status
=== TEST 14: get_peers() returns nil if no peers
--- http_config eval: $::HttpConfig
--- config
location /t {
content_by_lua_block {
local Cluster = require 'resty.cassandra.cluster'
local cluster, err = Cluster.new()
if not cluster then
ngx.log(ngx.ERR, err)
return
end
local peers, err = cluster:get_peers()
if err then
ngx.log(ngx.ERR, err)
return
end
ngx.say('is nil: ', peers == nil)
}
}
--- request
GET /t
--- response_body
is nil: true
--- no_error_log
[error]
=== TEST 15: set_peer_down()/set_peer_up()/can_try_peer() set shm booleans for nodes status
--- http_config eval: $::HttpConfig
--- config
location /t {
Expand Down Expand Up @@ -562,7 +592,7 @@ GET /t
=== TEST 15: set_peer_down()/set_peer_up() use existing host details if exists
=== TEST 16: set_peer_down()/set_peer_up() use existing host details if exists
--- http_config eval: $::HttpConfig
--- config
location /t {
Expand Down Expand Up @@ -631,7 +661,7 @@ GET /t
=== TEST 16: set_peer_down()/set_peer_up() defaults hosts details if not exists
=== TEST 17: set_peer_down()/set_peer_up() defaults hosts details if not exists
--- http_config eval: $::HttpConfig
--- config
location /t {
Expand Down Expand Up @@ -690,7 +720,7 @@ GET /t
=== TEST 17: set_peer_down()/set_peer_up() use reconnection policy (update peer_rec delays)
=== TEST 18: set_peer_down()/set_peer_up() use reconnection policy (update peer_rec delays)
--- http_config eval: $::HttpConfig
--- config
location /t {
Expand Down Expand Up @@ -776,7 +806,7 @@ reconn_delay: true
=== TEST 18: can_try_peer() use reconnection policy to decide when node is down
=== TEST 19: can_try_peer() use reconnection policy to decide when node is down
--- http_config eval: $::HttpConfig
--- config
location /t {
Expand Down Expand Up @@ -840,7 +870,7 @@ after delay: true true
=== TEST 19: next_coordinator() uses load balancing policy
=== TEST 20: next_coordinator() uses load balancing policy
--- http_config eval: $::HttpConfig
--- config
location /t {
Expand Down Expand Up @@ -877,7 +907,7 @@ coordinator 3: 127.0.0.1
=== TEST 20: next_coordinator() returns no host available errors
=== TEST 21: next_coordinator() returns no host available errors
--- http_config eval: $::HttpConfig
--- config
location /t {
Expand Down Expand Up @@ -921,7 +951,7 @@ all hosts tried for query failed. 127.0.0.2: host still considered down. 127.0.0
=== TEST 21: next_coordinator() avoids down hosts
=== TEST 22: next_coordinator() avoids down hosts
--- http_config eval: $::HttpConfig
--- config
location /t {
Expand Down Expand Up @@ -965,7 +995,7 @@ GET /t
=== TEST 22: next_coordinator() marks nodes as down
=== TEST 23: next_coordinator() marks nodes as down
--- http_config eval: $::HttpConfig
--- config
location /t {
Expand Down Expand Up @@ -1029,7 +1059,7 @@ can try peer 255.255.255.253: false
=== TEST 23: next_coordinator() retries down host as per reconnection policy and ups them back
=== TEST 24: next_coordinator() retries down host as per reconnection policy and ups them back
--- http_config eval: $::HttpConfig
--- config
location /t {
Expand Down

0 comments on commit d7195a4

Please sign in to comment.