Skip to content

Commit 5431327

Browse files
committed
test(sentinel) integration test for getting master via connect
1 parent 2d2de77 commit 5431327

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

t/sentinel.t

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,33 @@ GET /t
4848
[error]
4949

5050

51+
=== TEST 1b: Get the master directly
52+
--- http_config eval: $::HttpConfig
53+
--- config
54+
location /t {
55+
content_by_lua_block {
56+
local rc = require("resty.redis.connector").new()
57+
58+
local master, err = rc:connect({
59+
url = "sentinel://mymaster:m/3",
60+
sentinels = {
61+
{ host = "127.0.0.1", port = 6381 }
62+
}
63+
})
64+
65+
assert(master and not err, "get_master should return the master")
66+
assert(master:set("foo", "bar"), "set should run without error")
67+
assert(master:get("foo") == "bar", "get(foo) should return bar")
68+
69+
master:close()
70+
}
71+
}
72+
--- request
73+
GET /t
74+
--- no_error_log
75+
[error]
76+
77+
5178
=== TEST 2: Get slaves
5279
--- http_config eval: $::HttpConfig
5380
--- config

0 commit comments

Comments
 (0)