Skip to content

Commit 2f816a7

Browse files
committed
Allow socket path to propogate from Makefile
1 parent d4fb689 commit 2f816a7

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ TEST_SENTINEL_PROMOTION_TIME ?= 20
3232

3333
# Command line arguments for redis tests
3434
TEST_REDIS_VARS = PATH=$(OPENRESTY_PREFIX)/nginx/sbin:$(PATH) \
35-
TEST_REDIS_SOCKET=unix://$(TEST_REDIS_SOCKET) \
35+
TEST_NGINX_REDIS_SOCKET=unix://$(TEST_REDIS_SOCKET) \
3636
TEST_REDIS_DATABASE=$(TEST_REDIS_DATABASE) \
3737
TEST_NGINX_NO_SHUFFLE=1
3838

t/connector.t

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ init_by_lua_block {
1313

1414
$ENV{TEST_NGINX_RESOLVER} = '8.8.8.8';
1515
$ENV{TEST_NGINX_REDIS_PORT} ||= 6379;
16+
$ENV{TEST_NGINX_REDIS_SOCKET} ||= 'unix://tmp/redis/redis.sock';
1617

1718
no_long_string();
1819
run_tests();
@@ -213,14 +214,14 @@ GET /t
213214
ERR Client sent AUTH, but no password is set
214215

215216

216-
=== TEST 7: unix domain socket
217+
=== TEST 7: Bad unix domain socket path should fail
217218
--- http_config eval: $::HttpConfig
218219
--- config
219220
location /t {
220221
lua_socket_log_errors Off;
221222
content_by_lua_block {
222223
local redis, err = require("resty.redis.connector").new({
223-
path = "unix://tmp/redis.sock",
224+
path = "unix://GARBAGE_PATH_AKFDKAJSFKJSAFLKJSADFLKJSANCKAJSNCKJSANCLKAJS",
224225
}):connect()
225226

226227
assert(not redis and err == "no such file or directory",
@@ -233,6 +234,30 @@ GET /t
233234
[error]
234235

235236

237+
=== TEST 7.1: Good unix domain socket path should succeed
238+
--- http_config eval: $::HttpConfig
239+
--- config
240+
location /t {
241+
lua_socket_log_errors Off;
242+
content_by_lua_block {
243+
ngx.log (ngx.DEBUG, "$TEST_NGINX_REDIS_SOCKET")
244+
local redis, err = require("resty.redis.connector").new({
245+
path = "$TEST_NGINX_REDIS_SOCKET",
246+
}):connect()
247+
248+
assert (redis and not err,
249+
"connection should be valid")
250+
251+
252+
redis:close()
253+
}
254+
}
255+
--- request
256+
GET /t
257+
--- no_error_log
258+
[error]
259+
260+
236261
=== TEST 8: parse_dsn
237262
--- http_config eval: $::HttpConfig
238263
--- config

0 commit comments

Comments
 (0)