Skip to content

Commit 37cbafe

Browse files
committed
tests: minor tweaks for the http2 test mode.
1 parent 9a81a68 commit 37cbafe

File tree

3 files changed

+44
-38
lines changed

3 files changed

+44
-38
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ install:
8484
- git clone https://github.com/openresty/redis2-nginx-module.git ../redis2-nginx-module
8585
- git clone https://github.com/openresty/lua-resty-core.git ../lua-resty-core
8686
- git clone https://github.com/openresty/lua-resty-lrucache.git ../lua-resty-lrucache
87+
- git clone https://github.com/openresty/lua-resty-mysql.git ../lua-resty-mysql
8788
- git clone -b v2.1-agentzh https://github.com/openresty/luajit2.git
8889

8990
before_script:

t/000--init.t

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use Test::Nginx::Socket::Lua;
44

55
repeat_each(1);
66

7-
plan tests => repeat_each() * (blocks() * 2 + 1);
7+
plan tests => repeat_each() * (blocks() * 3);
88

99
$ENV{TEST_NGINX_MEMCACHED_PORT} ||= 11211;
1010
$ENV{TEST_NGINX_MYSQL_PORT} ||= 3306;
@@ -14,9 +14,13 @@ our $http_config = <<'_EOC_';
1414
drizzle_server 127.0.0.1:$TEST_NGINX_MYSQL_PORT protocol=mysql
1515
dbname=ngx_test user=ngx_test password=ngx_test;
1616
}
17+
18+
lua_package_path "../lua-resty-mysql/lib/?.lua;;";
1719
_EOC_
1820

1921
no_shuffle();
22+
no_long_string();
23+
2024
run_tests();
2125

2226
__DATA__
@@ -25,51 +29,46 @@ __DATA__
2529
--- http_config eval: $::http_config
2630
--- config
2731
location = /init {
28-
drizzle_pass database;
29-
drizzle_query "DROP TABLE IF EXISTS conv_uid";
30-
}
31-
--- request
32-
GET /init
33-
--- error_code: 200
34-
--- timeout: 10
35-
--- no_error_log
36-
[error]
37-
38-
39-
40-
=== TEST 2: conv_uid - create table
41-
--- http_config eval: $::http_config
42-
--- config
43-
location = /init {
44-
drizzle_pass database;
45-
drizzle_query "CREATE TABLE conv_uid(id serial primary key, new_uid integer, old_uid integer)";
32+
content_by_lua_block {
33+
local mysql = require "resty.mysql"
34+
local db = assert(mysql:new())
35+
local ok, err, errcode, sqlstate = db:connect{
36+
host = "127.0.0.1",
37+
port = $TEST_NGINX_MYSQL_PORT,
38+
database = "ngx_test",
39+
user = "ngx_test",
40+
password = "ngx_test",
41+
charset = "utf8",
42+
}
43+
44+
local queries = {
45+
"DROP TABLE IF EXISTS conv_uid",
46+
"CREATE TABLE conv_uid(id serial primary key, new_uid integer, old_uid integer)",
47+
"INSERT INTO conv_uid(old_uid,new_uid) VALUES(32,56),(35,78)",
48+
}
49+
50+
for _, query in ipairs(queries) do
51+
local ok, err = db:query(query)
52+
if not ok then
53+
ngx.say("failed to run mysql query \"", query, "\": ", err)
54+
return
55+
end
56+
end
57+
58+
ngx.say("done!")
59+
}
4660
}
4761
--- request
4862
GET /init
49-
--- error_code: 200
50-
--- timeout: 10
51-
--- no_error_log
52-
[error]
53-
54-
55-
56-
=== TEST 3: conv_uid - insert value
57-
--- http_config eval: $::http_config
58-
--- config
59-
location = /init {
60-
drizzle_pass database;
61-
drizzle_query "INSERT INTO conv_uid(old_uid,new_uid) VALUES(32,56),(35,78)";
62-
}
63-
--- request
64-
GET /init
65-
--- error_code: 200
63+
--- response_body
64+
done!
6665
--- timeout: 10
6766
--- no_error_log
6867
[error]
6968
7069
7170
72-
=== TEST 4: flush data from memcached
71+
=== TEST 2: flush data from memcached
7372
--- config
7473
location /flush {
7574
set $memc_cmd flush_all;

t/002-content.t

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use Test::Nginx::Socket::Lua;
1010
repeat_each(2);
1111
#repeat_each(1);
1212

13-
plan tests => repeat_each() * (blocks() * 2 + 19);
13+
plan tests => repeat_each() * (blocks() * 2 + 23);
1414

1515
#no_diff();
1616
#no_long_string();
@@ -539,6 +539,9 @@ GET /main
539539
Content-Length: 12
540540
--- response_body chop
541541
hello, world
542+
--- no_error_log
543+
[error]
544+
[alert]
542545

543546

544547

@@ -761,6 +764,9 @@ Content-Length: 13
761764
hello,
762765
world
763766
--- timeout: 5
767+
--- no_error_log
768+
[error]
769+
[alert]
764770

765771

766772

0 commit comments

Comments
 (0)