Skip to content

Commit 1278ee5

Browse files
committed
#28 - done. Updates comments & Makefile & test;
1 parent 47d2fe5 commit 1278ee5

File tree

5 files changed

+77
-64
lines changed

5 files changed

+77
-64
lines changed

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ configure-debug:
6060
cp -f $(CUR_PATH)/test/ngx_confs/tnt_server_test.conf $(PREFIX_PATH)/conf/tnt_server_test.conf
6161
cp -f $(CUR_PATH)/test/ngx_confs/nginx.dev.conf $(PREFIX_PATH)/conf/nginx.conf
6262

63+
configure-for-testing:
64+
cd $(NGX_PATH) && $(NGX_CONFIGURE) \
65+
--with-cc-opt='$(INC_FLAGS)'\
66+
--prefix=$(PREFIX_PATH) \
67+
--add-module=$(MODULE_PATH)
68+
mkdir -p $(PREFIX_PATH)/conf $(PREFIX_PATH)/logs
69+
cp -Rf $(NGX_PATH)/conf/* $(PREFIX_PATH)/conf
70+
cp -f $(CUR_PATH)/test/ngx_confs/tnt_server_test.conf $(PREFIX_PATH)/conf/tnt_server_test.conf
71+
cp -f $(CUR_PATH)/test/ngx_confs/nginx.dev.conf $(PREFIX_PATH)/conf/nginx.conf
72+
6373
configure-as-dynamic-debug:
6474
cd $(NGX_PATH) && \
6575
CFLAGS=" -DMY_DEBUG $(DEV_CFLAGS)" $(NGX_CONFIGURE) \

src/ngx_http_tnt_handlers.h

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,18 @@ typedef struct {
5252

5353
/** Preset method name
5454
*
55-
* if method is set then tp_transcode use only this method name
55+
* if method is set then tp_transcode use only this method name and
56+
* ignore method name from json and uri
5657
*/
5758
ngx_str_t method;
5859

59-
/** Max allowed query and headers size in bytes
60+
/** Max allowed size of query + headers in bytes
6061
*/
6162
size_t pass_http_request_buffer_size;
6263

6364
/** Pass query/headers to tarantool
6465
*
65-
* If set Tarantool get query args as lua table, e.g.
66+
* If this is set, then Tarantool recv. query args as lua table, e.g.
6667
* /tnt_method?arg1=X&arg2=123
6768
*
6869
* Tarantool
@@ -74,27 +75,40 @@ typedef struct {
7475
*/
7576
ngx_uint_t pass_http_request;
7677

77-
/** Set of http REST methods[default GET|PUT]
78+
/** Http REST methods[default GET|PUT]
7879
*
79-
* if method in http_rest_methods then tp_transcode expecting method name in
80-
* url part, i.e. HOST/METHOD_NAME/TAIL?ARGS
80+
* if method in http_rest_methods, then tp_transcode expecting method name
81+
* in url part, i.e. HOST/METHOD_NAME/TAIL?ARGS
8182
*
8283
* XXX Also see method
8384
*/
8485
ngx_uint_t http_rest_methods;
8586

8687
/** Set of http methods[default POST|DELETE]
8788
*
88-
* If method in http_methods then tp_transcode expecting method name in
89+
* If method in http_methods, then tp_transcode expecting method name in
8990
* json protocol, i.e. {"method":STR}
9091
*
9192
* XXX Also see method
9293
*/
9394
ngx_uint_t http_methods;
9495

96+
/** If is set to 'On', then the client will recv. pure result set, e.g.
97+
* {}
98+
* Otherwise
99+
* {"result":[], "id": NUM}
100+
*/
95101
ngx_uint_t pure_result;
102+
103+
/** Tarantool returns array of array as the result set of call,
104+
* this option helps to avoid this behavior.
105+
* For instance. If this option set to 2 then result will look
106+
* alike result:{} instead of result:[[{}]]
107+
*/
96108
ngx_uint_t multireturn_skip_count;
97109

110+
ngx_array_t *headers_source;
111+
98112
} ngx_http_tnt_loc_conf_t;
99113

100114

src/ngx_http_tnt_module.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <ngx_config.h>
3434

3535
#include <debug.h>
36+
#include <ngx_http_tnt_version.h>
3637
#include <ngx_http_tnt_handlers.h>
3738

3839

@@ -67,6 +68,7 @@ static ngx_int_t ngx_http_tnt_filter(void *data, ssize_t bytes);
6768

6869
/** Confs
6970
*/
71+
static ngx_int_t ngx_http_tnt_preconfiguration(ngx_conf_t *cf);
7072
static void *ngx_http_tnt_create_loc_conf(ngx_conf_t *cf);
7173
static char *ngx_http_tnt_merge_loc_conf(
7274
ngx_conf_t *cf,
@@ -246,7 +248,7 @@ static ngx_command_t ngx_http_tnt_commands[] = {
246248

247249

248250
static ngx_http_module_t ngx_http_tnt_module_ctx = {
249-
NULL, /* preconfiguration */
251+
ngx_http_tnt_preconfiguration, /* preconfiguration */
250252
NULL, /* postconfiguration */
251253

252254
NULL, /* create main configuration */
@@ -386,6 +388,16 @@ ngx_http_tnt_filter(void *data, ssize_t bytes)
386388
}
387389

388390

391+
static ngx_int_t
392+
ngx_http_tnt_preconfiguration(ngx_conf_t *cf)
393+
{
394+
ngx_conf_log_error(NGX_LOG_NOTICE, cf, 0,
395+
"Tarantool upstream module, version: '%s'",
396+
NGX_HTTP_TNT_MODULE_VERSION_STRING);
397+
return NGX_OK;
398+
}
399+
400+
389401
static void *
390402
ngx_http_tnt_create_loc_conf(ngx_conf_t *cf)
391403
{

test/auto.sh

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,40 @@
11
#!/bin/bash
22

3-
set -e -x
3+
set -x -e
44

5-
TNT_PID=
6-
NGX_MASTER_PID=
5+
for ver_tag in `cat test/ngx_versions_list`; do
76

8-
tear_up()
9-
{
10-
echo
11-
}
7+
# Checkout nginx version via tag
8+
cd nginx
9+
git checkout $ver_tag
10+
cd -
1211

13-
tear_down()
14-
{
15-
echo
16-
}
12+
for build_type in configure-for-testing configure; do
1713

18-
run_tests()
19-
{
20-
echo
21-
}
14+
# Build two configuration
15+
make $build_type
16+
make -j2
2217

23-
tear_up && run_tests && tear_down
18+
19+
# Test debug configuration
20+
if [ $build_type = "configure-for-testing" ]; then
21+
echo "[+] Start testing $ver_tag"
22+
./nginx/objs/nginx 2> /dev/null &
23+
nginx_pid=$!
24+
tarantool test/test.lua 2> /dev/null &
25+
tnt_pid=$!
26+
./test/run_all.sh
27+
for pid in $nginx_pid $tnt_pid; do
28+
echo "[+] Terminating $pid"
29+
kill -s TERM $pid
30+
wait $pid
31+
done
32+
fi
33+
34+
# Clean an old build
35+
make clean
36+
echo "[+] Test - OK"
37+
done
38+
done
39+
40+
echo "[+] All tests - OK"

test/ngx_versions.sh

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)