- Notifications
You must be signed in to change notification settings - Fork 58
/
Copy patherrors.t
176 lines (137 loc) · 3.48 KB
/
errors.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# vi:filetype=
use lib 'lib';
use Test::Nginx::Socket;
repeat_each(2);
plan tests => repeat_each() * (blocks() + 1);
$ENV{TEST_NGINX_MYSQL_PORT} ||= 3306;
$ENV{TEST_NGINX_MYSQL_HOST} ||= '127.0.0.1';
our $http_config = <<'_EOC_';
upstream foo {
drizzle_server $TEST_NGINX_MYSQL_HOST:$TEST_NGINX_MYSQL_PORT protocol=mysql
dbname=ngx_test user=ngx_test password=ngx_test;
}
_EOC_
worker_connections(128);
run_tests();
no_diff();
__DATA__
=== TEST 1: bad query
little-endian systems only
--- http_config eval: $::http_config
--- config
location /mysql {
set $backend foo;
drizzle_pass $backend;
drizzle_module_header off;
drizzle_query "update table_that_doesnt_exist set name='bob'";
}
--- request
GET /mysql
--- error_code: 410
--- response_body_like: 410 Gone
--- timeout: 5
=== TEST 2: wrong credentials
little-endian systems only
--- timeout: 5
--- http_config
upstream foo {
drizzle_server 127.0.0.1:$TEST_NGINX_MYSQL_PORT dbname=test
password=wrong_pass user=monty protocol=mysql;
drizzle_keepalive mode=single max=2 overflow=reject;
}
--- config
location /mysql {
set $backend foo;
drizzle_pass $backend;
drizzle_module_header off;
drizzle_query "update cats set name='bob' where name='bob'";
}
--- request
GET /mysql
--- error_code: 502
=== TEST 3: no database
little-endian systems only
--- http_config
upstream foo {
drizzle_server 127.0.0.1:1 dbname=test
password=some_pass user=monty protocol=mysql;
drizzle_keepalive mode=single max=2 overflow=reject;
}
--- config
location /mysql {
set $backend foo;
drizzle_pass $backend;
drizzle_module_header off;
drizzle_query "update cats set name='bob' where name='bob'";
}
--- request
GET /mysql
--- error_code: 502
--- timeout: 1
=== TEST 4: multiple queries
little-endian systems only
--- timeout: 5
--- http_config eval: $::http_config
--- config
location /mysql {
set $backend foo;
drizzle_pass $backend;
drizzle_module_header off;
drizzle_query "select * from cats; select * from cats";
}
--- request
GET /mysql
--- error_code: 500
=== TEST 5: missing query
little-endian systems only
--- http_config eval: $::http_config
--- config
location /mysql {
set $backend foo;
drizzle_pass $backend;
drizzle_module_header off;
}
--- request
GET /mysql
--- error_code: 500
=== TEST 6: empty query
little-endian systems only
--- http_config eval: $::http_config
--- config
location /mysql {
set $backend foo;
drizzle_pass $backend;
drizzle_module_header off;
set $query "";
drizzle_query $query;
}
--- request
GET /mysql
--- error_code: 500
--- timeout: 5
=== TEST 7: empty pass
little-endian systems only
--- http_config eval: $::http_config
--- config
location /mysql {
set $backend "";
drizzle_pass $backend;
drizzle_module_header off;
drizzle_query "update cats set name='bob' where name='bob'";
}
--- request
GET /mysql
--- error_code: 500
=== TEST 8: empty pass
little-endian systems only
--- http_config eval: $::http_config
--- config
location /mysql {
set $backend "not-exist";
drizzle_pass $backend;
drizzle_module_header off;
drizzle_query "update cats set name='bob' where name='bob'";
}
--- request
GET /mysql
--- error_code: 500