Skip to content

Instantly share code, notes, and snippets.

@chobits
Last active December 20, 2018 11:23
Show Gist options
  • Save chobits/1c97d29e453dd17778e02166e479dfcb to your computer and use it in GitHub Desktop.
Save chobits/1c97d29e453dd17778e02166e479dfcb to your computer and use it in GitHub Desktop.
test case for updating nginx-1.15.1 modules

Test Case:

  • Case failure:

    • sub_filter_slice.t: current tengine has its slice module, so this case is not run for nginx module.
    • limit_conn_complex.t: limit_req module is not updated.
    • index2.t: current tengine does not merge http://hg.nginx.org/nginx/rev/d91a8c4ac6bb.
    • userid.t: tengine refactor 404 page. It outputs URI in response, the URI has "expires" string, which makes case failed.
  • Case fixed:

    • memcached_keepalive.t: fixed this case for Tengine via setting worker_processes 1;
  • Tested-by: Xiaochen Wang

  • pwd: /home/xiaochen.wxc/work/github/tengine-xiaochen

  • cases: tests/nginx-tests/nginx-tests/*memcached*.t tests/nginx-tests/nginx-tests/auth_*.t tests/nginx-tests/nginx-tests/access.t tests/nginx-tests/nginx-tests/autoindex*.t tests/nginx-tests/nginx-tests/charset*.t tests/nginx-tests/nginx-tests/limit_conn*.t tests/nginx-tests/nginx-tests/range_flv.t tests/nginx-tests/nginx-tests/gunzip*.t tests/nginx-tests/nginx-tests/charset_gzip_static.t tests/nginx-tests/nginx-tests/map*.t tests/nginx-tests/nginx-tests/not_modified*.t tests/nginx-tests/nginx-tests/xslt*.t tests/nginx-tests/nginx-tests/random_index.t tests/nginx-tests/nginx-tests/sub_filter*.t tests/nginx-tests/nginx-tests/mp4_ssi.t tests/nginx-tests/nginx-tests/mp4.t tests/nginx-tests/nginx-tests/range_mp4.t tests/nginx-tests/nginx-tests/referer.t tests/nginx-tests/nginx-tests/index2.t tests/nginx-tests/nginx-tests/geo*.t

  • git log:

commit 32c48a6473318aec2767b6cd5ab2da76b5ca9df0 (HEAD -> master, origin/master, origin/HEAD)
Merge: 769e2b88 56cd4eed
Author: Xiaochen Wang <wangxiaochen0@gmail.com>
Date:   Tue Oct 9 11:13:34 2018 +0800

    Merge branch 'bugfix'
  • case result:
$ TEST_NGINX_UNSAFE=yes TEST_NGINX_BINARY=/home/xiaochen.wxc/work/github/tengine-xiaochen/objs/nginx prove -I /home/xiaochen.wxc/work/github/tengine-xiaochen/tests/nginx-tests/nginx-tests/lib tests/nginx-tests/nginx-tests/gunzip_memcached.t tests/nginx-tests/nginx-tests/memcached_fake.t tests/nginx-tests/nginx-tests/memcached_keepalive_stale.t tests/nginx-tests/nginx-tests/memcached_keepalive.t tests/nginx-tests/nginx-tests/memcached.t tests/nginx-tests/nginx-tests/upstream_hash_memcached.t tests/nginx-tests/nginx-tests/auth_basic.t tests/nginx-tests/nginx-tests/auth_request_satisfy.t tests/nginx-tests/nginx-tests/auth_request_set.t tests/nginx-tests/nginx-tests/auth_request.t tests/nginx-tests/nginx-tests/access.t tests/nginx-tests/nginx-tests/autoindex_format.t tests/nginx-tests/nginx-tests/autoindex.t tests/nginx-tests/nginx-tests/charset_gzip_static.t tests/nginx-tests/nginx-tests/charset.t tests/nginx-tests/nginx-tests/limit_conn_complex.t tests/nginx-tests/nginx-tests/limit_conn.t tests/nginx-tests/nginx-tests/range_flv.t tests/nginx-tests/nginx-tests/gunzip_memcached.t tests/nginx-tests/nginx-tests/gunzip_perl.t tests/nginx-tests/nginx-tests/gunzip_ssi.t tests/nginx-tests/nginx-tests/gunzip_static.t tests/nginx-tests/nginx-tests/gunzip.t tests/nginx-tests/nginx-tests/charset_gzip_static.t tests/nginx-tests/nginx-tests/map_complex.t tests/nginx-tests/nginx-tests/map.t tests/nginx-tests/nginx-tests/map_volatile.t tests/nginx-tests/nginx-tests/not_modified_finalize.t tests/nginx-tests/nginx-tests/not_modified_proxy.t tests/nginx-tests/nginx-tests/not_modified.t tests/nginx-tests/nginx-tests/xslt_params.t tests/nginx-tests/nginx-tests/xslt.t tests/nginx-tests/nginx-tests/random_index.t tests/nginx-tests/nginx-tests/sub_filter_buffering.t tests/nginx-tests/nginx-tests/sub_filter_merge.t tests/nginx-tests/nginx-tests/sub_filter_multi2.t tests/nginx-tests/nginx-tests/sub_filter_multi.t tests/nginx-tests/nginx-tests/sub_filter_perl.t tests/nginx-tests/nginx-tests/sub_filter_slice.t tests/nginx-tests/nginx-tests/sub_filter_ssi.t tests/nginx-tests/nginx-tests/sub_filter.t tests/nginx-tests/nginx-tests/mp4_ssi.t tests/nginx-tests/nginx-tests/mp4.t tests/nginx-tests/nginx-tests/range_mp4.t tests/nginx-tests/nginx-tests/referer.t tests/nginx-tests/nginx-tests/index2.t tests/nginx-tests/nginx-tests/geo_binary.t tests/nginx-tests/nginx-tests/geoip.t tests/nginx-tests/nginx-tests/geo_ipv6.t tests/nginx-tests/nginx-tests/geo.t
tests/nginx-tests/nginx-tests/gunzip_memcached.t ........... ok
tests/nginx-tests/nginx-tests/memcached_fake.t ............. ok
tests/nginx-tests/nginx-tests/memcached_keepalive_stale.t .. ok
tests/nginx-tests/nginx-tests/memcached_keepalive.t ........ ok
tests/nginx-tests/nginx-tests/memcached.t .................. ok
tests/nginx-tests/nginx-tests/upstream_hash_memcached.t .... ok
tests/nginx-tests/nginx-tests/auth_basic.t ................. ok
tests/nginx-tests/nginx-tests/auth_request_satisfy.t ....... ok
tests/nginx-tests/nginx-tests/auth_request_set.t ........... ok
tests/nginx-tests/nginx-tests/auth_request.t ............... ok
tests/nginx-tests/nginx-tests/access.t ..................... ok
tests/nginx-tests/nginx-tests/autoindex_format.t ........... ok
tests/nginx-tests/nginx-tests/autoindex.t .................. ok
tests/nginx-tests/nginx-tests/charset_gzip_static.t ........ ok
tests/nginx-tests/nginx-tests/charset.t .................... ok
tests/nginx-tests/nginx-tests/limit_conn_complex.t ......... nginx: [emerg] unknown "binary_remote_addr$arg_r" variable
Can't start nginx at lib/Test/Nginx.pm line 356.
        (in cleanup) Can't open error.log: No such file or directory at lib/Test/Nginx.pm line 530.
# Looks like your test exited with 2 before it could output anything.
tests/nginx-tests/nginx-tests/limit_conn_complex.t ......... Dubious, test returned 2 (wstat 512, 0x200)
Failed 6/6 subtests
tests/nginx-tests/nginx-tests/limit_conn.t ................. ok
tests/nginx-tests/nginx-tests/range_flv.t .................. ok
tests/nginx-tests/nginx-tests/gunzip_perl.t ................ ok
tests/nginx-tests/nginx-tests/gunzip_ssi.t ................. ok
tests/nginx-tests/nginx-tests/gunzip_static.t .............. ok
tests/nginx-tests/nginx-tests/gunzip.t ..................... ok
tests/nginx-tests/nginx-tests/map_complex.t ................ ok
tests/nginx-tests/nginx-tests/map.t ........................ ok
tests/nginx-tests/nginx-tests/map_volatile.t ............... ok
tests/nginx-tests/nginx-tests/not_modified_finalize.t ...... ok
tests/nginx-tests/nginx-tests/not_modified_proxy.t ......... ok
tests/nginx-tests/nginx-tests/not_modified.t ............... ok
tests/nginx-tests/nginx-tests/xslt_params.t ................ 1/6 Use of uninitialized value $1 in split at lib/Test/Nginx.pm line 259.
tests/nginx-tests/nginx-tests/xslt_params.t ................ ok
tests/nginx-tests/nginx-tests/xslt.t ....................... ok
tests/nginx-tests/nginx-tests/random_index.t ............... ok
tests/nginx-tests/nginx-tests/sub_filter_buffering.t ....... ok
tests/nginx-tests/nginx-tests/sub_filter_merge.t ........... ok
tests/nginx-tests/nginx-tests/sub_filter_multi2.t .......... ok
tests/nginx-tests/nginx-tests/sub_filter_multi.t ........... ok
tests/nginx-tests/nginx-tests/sub_filter_perl.t ............ ok
tests/nginx-tests/nginx-tests/sub_filter_slice.t ........... nginx: [emerg] invalid number of arguments in "slice" directive in /tmp/nginx-test-33BRIZJ_EI/nginx.conf:30
Can't start nginx at lib/Test/Nginx.pm line 356.
        (in cleanup) Can't open error.log: No such file or directory at lib/Test/Nginx.pm line 530.
# Looks like your test exited with 2 before it could output anything.
tests/nginx-tests/nginx-tests/sub_filter_slice.t ........... Dubious, test returned 2 (wstat 512, 0x200)
Failed 5/5 subtests
tests/nginx-tests/nginx-tests/sub_filter_ssi.t ............. ok
tests/nginx-tests/nginx-tests/sub_filter.t ................. ok
tests/nginx-tests/nginx-tests/mp4_ssi.t .................... ok
tests/nginx-tests/nginx-tests/mp4.t ........................ ok
tests/nginx-tests/nginx-tests/range_mp4.t .................. ok
tests/nginx-tests/nginx-tests/referer.t .................... ok
tests/nginx-tests/nginx-tests/index2.t ..................... skipped: unsupported token
tests/nginx-tests/nginx-tests/geo_binary.t ................. ok
tests/nginx-tests/nginx-tests/geoip.t ...................... ok
tests/nginx-tests/nginx-tests/geo_ipv6.t ................... ok
tests/nginx-tests/nginx-tests/geo.t ........................ ok
tests/nginx-tests/nginx-tests/userid.t ..................... 1/35
#   Failed test 'redefine expires'
#   at tests/nginx-tests/nginx-tests/userid.t line 185.


  • Tengine configure script:
./configure --prefix=$(pwd)/output --with-ld-opt="-g -O0" --with-cc-opt="-g -O0" --with-debug \
  --with-http_addition_module  \
  --with-http_tfs_module \
  --with-http_auth_request_module \
  --with-ipv6 \
  --with-http_gzip_static_module \
  --with-http_dav_module \
  --with-http_flv_module \
  --with-http_geoip_module \
  --with-http_gzip_static_module \
  --with-http_gunzip_module \
  --with-http_xslt_module \
  --with-http_random_index_module \
  --with-http_sub_module \
  --with-http_mp4_module  \
  --with-http_slice_module \
  --with-http_perl_module
  • how to run testcase
$ sh runtest.sh
...
$ cat runtest.sh

usage () {
  echo "\
 Usage: sh dtest.sh [test case files or directories]
 Example:
      $ cd /path/to/tengine-source
      $ sh runtest.sh tests/nginx-tests/nginx-tests/h2.t
"
  exit 0
}

# path to tengine source
nginx_src=$(pwd)

# nginx binary
nginx_bin=$nginx_src/objs/nginx

# nginx test libs
# http://hg.nginx.org/nginx-tests/file/tip/lib
nginx_test_lib=$nginx_src/tests/nginx-tests/nginx-tests/lib

# prove command: -v, Print all test lines.
#nginx_verbose=-v

# test cases
nginx_case="
tests/nginx-tests/nginx-tests/*memcached*.t
tests/nginx-tests/nginx-tests/auth_*.t
tests/nginx-tests/nginx-tests/access.t
tests/nginx-tests/nginx-tests/autoindex*.t
tests/nginx-tests/nginx-tests/charset*.t
tests/nginx-tests/nginx-tests/limit_conn*.t
tests/nginx-tests/nginx-tests/range_flv.t
tests/nginx-tests/nginx-tests/gunzip*.t
tests/nginx-tests/nginx-tests/charset_gzip_static.t
tests/nginx-tests/nginx-tests/map*.t
tests/nginx-tests/nginx-tests/not_modified*.t
tests/nginx-tests/nginx-tests/xslt*.t
tests/nginx-tests/nginx-tests/random_index.t
tests/nginx-tests/nginx-tests/sub_filter*.t
tests/nginx-tests/nginx-tests/mp4_ssi.t
tests/nginx-tests/nginx-tests/mp4.t
tests/nginx-tests/nginx-tests/range_mp4.t
tests/nginx-tests/nginx-tests/referer.t
tests/nginx-tests/nginx-tests/index2.t
tests/nginx-tests/nginx-tests/geo*.t
tests/nginx-tests/nginx-tests/userid.t
"
#tests/nginx-tests/nginx-tests/geo*.t

if [ "$1" == "-h" ]; then
  usage
fi

if [ "$1" != "" ]; then
  nginx_case=$1
fi

echo "# Test Case: "
echo "* Tested-by: $(git config --get user.name) $(whoami)"
echo "* Date: $(date)"
echo "* hostname: $(hostname)"
echo "* pwd: $(pwd)"
echo "* cases: \`$nginx_case\`"

echo "* git log:"
echo
echo "\`\`\`"
git log -1 .
echo "\`\`\`"
echo

echo "* case result:"
echo
echo "\`\`\`"
echo $ TEST_NGINX_UNSAFE=yes TEST_NGINX_BINARY="$nginx_bin" prove $nginx_verbose -I $nginx_test_lib $nginx_case
# $(pwd) is /path/to/dyconf
# /path/to/dyconf is soft link to /path/to/mod_dyconf
TEST_NGINX_UNSAFE=yes TEST_NGINX_BINARY="$nginx_bin" prove $nginx_verbose -I $nginx_test_lib $nginx_case
echo "\`\`\`"
echo

echo "* Report-generated-by: http://github.com/chobits/tengine-script/runtest.sh"

diff with nginx-1.15.1

$ cat diff.sh
tdiff() {
  echo "try to diff -up $1.c  ../nginx-1.15.1/$1.c"
  diff -up $1.c  ../nginx-1.15.1/$1.c
}

tdiff src/http/modules/ngx_http_access_module
tdiff src/http/modules/ngx_http_auth_basic_module
tdiff src/http/modules/ngx_http_auth_request_module
tdiff src/http/modules/ngx_http_autoindex_module
tdiff src/http/modules/ngx_http_charset_filter_module
tdiff src/http/modules/ngx_http_index_module
tdiff src/http/modules/ngx_http_limit_conn_module
tdiff src/http/modules/ngx_http_flv_module
tdiff src/http/modules/ngx_http_geo_module
tdiff src/http/modules/ngx_http_map_module
tdiff src/http/modules/ngx_http_not_modified_filter_module
tdiff src/http/modules/ngx_http_xslt_filter_module
tdiff src/http/modules/ngx_http_random_index_module
tdiff src/http/modules/ngx_http_sub_filter_module
tdiff src/http/modules/ngx_http_mp4_module
tdiff src/http/modules/ngx_http_gzip_filter_module
tdiff src/http/modules/ngx_http_static_module
tdiff src/http/modules/ngx_http_referer_module
tdiff src/http/modules/ngx_http_userid_filter_module

$ sh diff.sh
try to diff -up src/http/modules/ngx_http_access_module.c  ../nginx-1.15.1/src/http/modules/ngx_http_access_module.c
try to diff -up src/http/modules/ngx_http_auth_basic_module.c  ../nginx-1.15.1/src/http/modules/ngx_http_auth_basic_module.c
try to diff -up src/http/modules/ngx_http_auth_request_module.c  ../nginx-1.15.1/src/http/modules/ngx_http_auth_request_module.c
try to diff -up src/http/modules/ngx_http_autoindex_module.c  ../nginx-1.15.1/src/http/modules/ngx_http_autoindex_module.c
try to diff -up src/http/modules/ngx_http_charset_filter_module.c  ../nginx-1.15.1/src/http/modules/ngx_http_charset_filter_module.c
try to diff -up src/http/modules/ngx_http_index_module.c  ../nginx-1.15.1/src/http/modules/ngx_http_index_module.c
try to diff -up src/http/modules/ngx_http_limit_conn_module.c  ../nginx-1.15.1/src/http/modules/ngx_http_limit_conn_module.c
try to diff -up src/http/modules/ngx_http_flv_module.c  ../nginx-1.15.1/src/http/modules/ngx_http_flv_module.c
try to diff -up src/http/modules/ngx_http_geo_module.c  ../nginx-1.15.1/src/http/modules/ngx_http_geo_module.c
try to diff -up src/http/modules/ngx_http_map_module.c  ../nginx-1.15.1/src/http/modules/ngx_http_map_module.c
try to diff -up src/http/modules/ngx_http_not_modified_filter_module.c  ../nginx-1.15.1/src/http/modules/ngx_http_not_modified_filter_module.c
try to diff -up src/http/modules/ngx_http_xslt_filter_module.c  ../nginx-1.15.1/src/http/modules/ngx_http_xslt_filter_module.c
try to diff -up src/http/modules/ngx_http_random_index_module.c  ../nginx-1.15.1/src/http/modules/ngx_http_random_index_module.c
try to diff -up src/http/modules/ngx_http_sub_filter_module.c  ../nginx-1.15.1/src/http/modules/ngx_http_sub_filter_module.c
try to diff -up src/http/modules/ngx_http_mp4_module.c  ../nginx-1.15.1/src/http/modules/ngx_http_mp4_module.c
try to diff -up src/http/modules/ngx_http_gzip_filter_module.c  ../nginx-1.15.1/src/http/modules/ngx_http_gzip_filter_module.c
--- src/http/modules/ngx_http_gzip_filter_module.c	2018-10-09 11:13:26.116979820 +0800
+++ ../nginx-1.15.1/src/http/modules/ngx_http_gzip_filter_module.c	2018-07-03 23:07:44.000000000 +0800
@@ -15,9 +15,6 @@
 typedef struct {
     ngx_flag_t           enable;
     ngx_flag_t           no_buffer;
-#if (T_NGX_GZIP_CLEAR_ETAG)
-    ngx_flag_t           clear_etag;
-#endif
 
     ngx_hash_t           types;
 
@@ -197,15 +194,6 @@ static ngx_command_t  ngx_http_gzip_filt
       offsetof(ngx_http_gzip_conf_t, min_length),
       NULL },
 
-#if (T_NGX_GZIP_CLEAR_ETAG)
-    { ngx_string("gzip_clear_etag"),
-      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
-      ngx_conf_set_flag_slot,
-      NGX_HTTP_LOC_CONF_OFFSET,
-      offsetof(ngx_http_gzip_conf_t, clear_etag),
-      NULL },
-#endif
-
       ngx_null_command
 };
 
@@ -321,11 +309,6 @@ ngx_http_gzip_header_filter(ngx_http_req
 
     ngx_http_clear_content_length(r);
     ngx_http_clear_accept_ranges(r);
-#if (T_NGX_GZIP_CLEAR_ETAG)
-    if (conf->clear_etag) {
-        ngx_http_clear_etag(r);
-    } else
-#endif
     ngx_http_weak_etag(r);
 
     return ngx_http_next_header_filter(r);
@@ -1186,9 +1169,6 @@ ngx_http_gzip_create_conf(ngx_conf_t *cf
 
     conf->enable = NGX_CONF_UNSET;
     conf->no_buffer = NGX_CONF_UNSET;
-#if (T_NGX_GZIP_CLEAR_ETAG)
-    conf->clear_etag = NGX_CONF_UNSET;
-#endif
 
     conf->postpone_gzipping = NGX_CONF_UNSET_SIZE;
     conf->level = NGX_CONF_UNSET;
@@ -1208,9 +1188,6 @@ ngx_http_gzip_merge_conf(ngx_conf_t *cf,
 
     ngx_conf_merge_value(conf->enable, prev->enable, 0);
     ngx_conf_merge_value(conf->no_buffer, prev->no_buffer, 0);
-#if (T_NGX_GZIP_CLEAR_ETAG)
-    ngx_conf_merge_value(conf->clear_etag, prev->clear_etag, 0);
-#endif
 
     ngx_conf_merge_bufs_value(conf->bufs, prev->bufs,
                               (128 * 1024) / ngx_pagesize, ngx_pagesize);
try to diff -up src/http/modules/ngx_http_static_module.c  ../nginx-1.15.1/src/http/modules/ngx_http_static_module.c
try to diff -up src/http/modules/ngx_http_referer_module.c  ../nginx-1.15.1/src/http/modules/ngx_http_referer_module.c
try to diff -up src/http/modules/ngx_http_userid_filter_module.c  ../nginx-1.15.1/src/http/modules/ngx_http_userid_filter_module.c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment