1
- use Test ::Nginx::Socket::Lua ' no_plan ' ;
1
+ use Test ::Nginx::Socket::Lua;
2
2
3
- log_level(' warn ' );
3
+ log_level(' info ' );
4
4
no_long_string();
5
- repeat_each(2 );
5
+ repeat_each(1 );
6
+
7
+ my $ etcd_version = `etcd -- version`;
8
+ if ($ etcd_version =~ /^ etcd Version : 2 / || $ etcd_version =~ /^ etcd Version : 3.1 ./ ) {
9
+ plan (skip_all => " etcd is too old, skip v3 protocol" );
10
+ } else {
11
+ plan ' no_plan' ;
12
+ }
6
13
7
14
our $ HttpConfig = <<'_EOC_';
8
15
lua_socket_log_errors off;
@@ -13,6 +20,7 @@ our $HttpConfig = <<'_EOC_';
13
20
function check_res(data, err, val, status)
14
21
if err then
15
22
ngx.say("err: ", err)
23
+ ngx.exit(200)
16
24
end
17
25
18
26
if val then
@@ -23,6 +31,7 @@ our $HttpConfig = <<'_EOC_';
23
31
ngx.say("failed to check value")
24
32
ngx.log(ngx.ERR, "failed to check value, got: ", data.body.kvs[1].value,
25
33
", expect: ", val)
34
+ ngx.exit(200)
26
35
else
27
36
ngx.say("checked val as expect: ", val)
28
37
end
@@ -53,9 +62,6 @@ __DATA__
53
62
check_res(etcd, err)
54
63
55
64
local res
56
- res, err = etcd:set("/dir/v3/a", 111)
57
- check_res(res, err)
58
-
59
65
res, err = etcd:set("/dir/v3/b", '"foo"')
60
66
check_res(res, err)
61
67
@@ -74,17 +80,20 @@ __DATA__
74
80
75
81
res, err = etcd:get("/dir/v3/d")
76
82
check_res(res, err, "", 200)
83
+
84
+ res, err = etcd:set("/dir/v3/a", 111)
85
+ check_res(res, err)
77
86
}
78
87
}
79
88
--- request
80
89
GET /t
81
90
--- no_error_log
82
91
[error]
83
92
--- response_body
84
- err: unsupported type for number
85
93
checked val as expect: "foo"
86
94
checked val as expect: {"a":1}
87
95
checked val as expect:
96
+ err: unsupported type for number
88
97
89
98
90
99
=== TEST 2: json serializer
0 commit comments