File tree 5 files changed +90
-8
lines changed
5 files changed +90
-8
lines changed Original file line number Diff line number Diff line change @@ -37,14 +37,10 @@ test: check-required-vars
37
37
nginx -c /etc/nginx/nginx-$(flavor ) .conf" \
38
38
39
39
$(DOCKER) cp ./test/nginx-$(flavor).conf test-tsuru-nginx-$(flavor)-$(nginx_version):/etc/nginx/
40
+ $(DOCKER) cp ./test/nginx-$(flavor).bash test-tsuru-nginx-$(flavor)-$(nginx_version):/bin/test-nginx
41
+
40
42
$(DOCKER) cp $$PWD/test/GeoIP2-Country-Test.mmdb test-tsuru-nginx-$(flavor)-$(nginx_version):/etc/nginx; \
41
43
42
44
$(DOCKER) start test-tsuru-nginx-$(flavor)-$(nginx_version) && sleep 3
43
45
44
- @if [ "$$($(DOCKER) exec test-tsuru-nginx-$(flavor)-$(nginx_version) curl -fsSL http://localhost:8080)" != "nginx config check ok" ]; then \
45
- echo 'FAIL' >&2; \
46
- $(DOCKER) logs test-tsuru-nginx-$(flavor)-$(nginx_version); \
47
- exit 1; \
48
- else \
49
- echo 'SUCCESS'; \
50
- fi
46
+ $(DOCKER) exec test-tsuru-nginx-$(flavor)-$(nginx_version) sh -c '/bin/test-nginx; exit $$?' || $(DOCKER) logs test-tsuru-nginx-$(flavor)-$(nginx_version)
Original file line number Diff line number Diff line change 17
17
" https://github.com/wandenberg/nginx-sorted-querystring-module.git"
18
18
],
19
19
"lua_modules" : [
20
- " tsuru-rpaasv2 INOTIFY_INCDIR=/usr/include/linux-gnu"
20
+ " tsuru-rpaasv2 INOTIFY_INCDIR=/usr/include/linux-gnu" ,
21
+ " lua-resty-http 0.17.2-0"
21
22
]
22
23
},
23
24
{
Original file line number Diff line number Diff line change
1
+ #! /bin/bash -e
2
+
3
+ assert () {
4
+ local expected=" $1 "
5
+ local actual=" $2 "
6
+ local message=" $3 "
7
+
8
+ if [[ " $expected " == " $actual " ]]; then
9
+ echo " ✅ SUCESS: $message "
10
+ else
11
+ echo " ❌ FAIL: $message "
12
+ echo " ➡ Expected: '$expected ', Obtained: '$actual '"
13
+ exit 1
14
+ fi
15
+ }
16
+
17
+ test_nginx_serving_request () {
18
+ response=$( curl --fail --silent --show-error http://localhost:8080/)
19
+ assert " nginx config check ok" " $response " " / with expected response"
20
+ }
21
+
22
+ echo " Running tests"
23
+
24
+ test_nginx_serving_request
25
+
26
+ echo " ✅ SUCESS: All tests passed"
Original file line number Diff line number Diff line change
1
+ #! /bin/bash -e
2
+
3
+ assert () {
4
+ local expected=" $1 "
5
+ local actual=" $2 "
6
+ local message=" $3 "
7
+
8
+ if [[ " $expected " == " $actual " ]]; then
9
+ echo " ✅ SUCESS: $message "
10
+ else
11
+ echo " ❌ FAIL: $message "
12
+ echo " ➡ Expected: '$expected ', Obtained: '$actual '"
13
+ exit 1
14
+ fi
15
+ }
16
+
17
+ test_nginx_serving_request () {
18
+ response=$( curl --fail --silent --show-error http://localhost:8080/)
19
+ assert " nginx config check ok" " $response " " / with expected response"
20
+ }
21
+
22
+ test_lua_content () {
23
+ response=$( curl --fail --silent --show-error http://localhost:8080/lua_content)
24
+ assert " Hello,world!" " $response " " /lua_content with expected response"
25
+ }
26
+
27
+ test_lua_http_resty () {
28
+ response=$( curl --fail --silent --show-error http://localhost:8080/lua_http_resty)
29
+ assert " Proxyied response: nginx config check ok" " $response " " /lua_http_resty with expected response"
30
+ }
31
+
32
+ echo " Running tests"
33
+
34
+ test_nginx_serving_request
35
+ test_lua_content
36
+ test_lua_http_resty
37
+
38
+ echo " ✅ SUCESS: All tests passed"
Original file line number Diff line number Diff line change @@ -57,6 +57,27 @@ http {
57
57
}
58
58
}
59
59
60
+ location /lua_http_resty {
61
+ # MIME type determined by default_type:
62
+ default_type 'text/plain';
63
+
64
+ content_by_lua_block {
65
+ local httpc = require("resty.http").new();
66
+
67
+ local res, err = httpc:request_uri("http://127.0.0.1:8080/", {
68
+ method = "GET",
69
+ })
70
+ if not res then
71
+ ngx.log(ngx.ERR, "request failed: ", err)
72
+ ngx.status = 500
73
+ return
74
+ end
75
+
76
+ ngx.say('Proxyied response: ' .. res.body)
77
+
78
+ }
79
+ }
80
+
60
81
location ~ ^/purge/(.+) {
61
82
proxy_cache_purge cache_zone $1$is_args$args;
62
83
}
You can’t perform that action at this time.
0 commit comments