|
3 | 3 | use Test::Nginx::Socket::Lua; |
4 | 4 |
|
5 | 5 | #worker_connections(1014); |
6 | | -#master_on(); |
| 6 | +master_on(); |
7 | 7 | #workers(2); |
8 | 8 | #log_level('warn'); |
9 | 9 |
|
10 | 10 | repeat_each(1); |
11 | 11 |
|
12 | | -plan tests => repeat_each() * (blocks() * 4); |
| 12 | +plan tests => repeat_each() * (blocks() * 4 + 4); |
13 | 13 |
|
14 | 14 | $ENV{TEST_NGINX_MEMCACHED_PORT} ||= 11211; |
15 | 15 | $ENV{TEST_NGINX_RESOLVER} ||= '8.8.8.8'; |
@@ -756,3 +756,183 @@ GET /t |
756 | 756 | ok |
757 | 757 | --- no_error_log |
758 | 758 | [error] |
| 759 | +
|
| 760 | +
|
| 761 | +
|
| 762 | +=== TEST 20: destory Lua VM in cache processes (without privileged agent or shdict) |
| 763 | +--- http_config |
| 764 | + lua_package_path "../lua-resty-core/lib/?.lua;../lua-resty-lrucache/lib/?.lua;;"; |
| 765 | +
|
| 766 | + proxy_cache_path /tmp/cache levels=1:2 keys_zone=cache:1m; |
| 767 | +
|
| 768 | + #lua_shared_dict dummy 500k; |
| 769 | +
|
| 770 | + init_by_lua_block { |
| 771 | + -- require "resty.core.regex" |
| 772 | + -- assert(ngx.re.match("hello, world", [[hello, \w+]], "joi")) |
| 773 | + } |
| 774 | +
|
| 775 | +--- config |
| 776 | + location = /t { |
| 777 | + return 200; |
| 778 | + } |
| 779 | +--- request |
| 780 | + GET /t |
| 781 | +--- grep_error_log eval: qr/lua close the global Lua VM \S+ in the cache helper process \d+|lua close the global Lua VM \S+$/ |
| 782 | +--- grep_error_log_out eval |
| 783 | +qr/\Alua close the global Lua VM ([0-9A-F]+) in the cache helper process \d+ |
| 784 | +lua close the global Lua VM \1 |
| 785 | +lua close the global Lua VM \1 in the cache helper process \d+ |
| 786 | +lua close the global Lua VM \1 |
| 787 | +(?:lua close the global Lua VM [0-9A-F]+ |
| 788 | +)*\z/ |
| 789 | +--- no_error_log |
| 790 | +[error] |
| 791 | +start privileged agent process |
| 792 | +
|
| 793 | +
|
| 794 | +
|
| 795 | +=== TEST 21: destory Lua VM in cache processes (without privileged agent but with shdict) |
| 796 | +--- http_config |
| 797 | + lua_package_path "../lua-resty-core/lib/?.lua;../lua-resty-lrucache/lib/?.lua;;"; |
| 798 | +
|
| 799 | + proxy_cache_path /tmp/cache levels=1:2 keys_zone=cache:1m; |
| 800 | +
|
| 801 | + lua_shared_dict dummy 500k; |
| 802 | +
|
| 803 | + init_by_lua_block { |
| 804 | + -- require "resty.core.regex" |
| 805 | + -- assert(ngx.re.match("hello, world", [[hello, \w+]], "joi")) |
| 806 | + } |
| 807 | +
|
| 808 | +--- config |
| 809 | + location = /t { |
| 810 | + return 200; |
| 811 | + } |
| 812 | +--- request |
| 813 | + GET /t |
| 814 | +--- grep_error_log eval: qr/lua close the global Lua VM \S+ in the cache helper process \d+|lua close the global Lua VM \S+$/ |
| 815 | +--- grep_error_log_out eval |
| 816 | +qr/\Alua close the global Lua VM ([0-9A-F]+) in the cache helper process \d+ |
| 817 | +lua close the global Lua VM \1 |
| 818 | +lua close the global Lua VM \1 in the cache helper process \d+ |
| 819 | +lua close the global Lua VM \1 |
| 820 | +(?:lua close the global Lua VM [0-9A-F]+ |
| 821 | +)*\z/ |
| 822 | +--- no_error_log |
| 823 | +[error] |
| 824 | +start privileged agent process |
| 825 | +
|
| 826 | +
|
| 827 | +
|
| 828 | +=== TEST 22: destory Lua VM in cache processes (with privileged agent) |
| 829 | +--- http_config |
| 830 | + lua_package_path "../lua-resty-core/lib/?.lua;../lua-resty-lrucache/lib/?.lua;;"; |
| 831 | +
|
| 832 | + #lua_shared_dict dogs 1m; |
| 833 | +
|
| 834 | + proxy_cache_path /tmp/cache levels=1:2 keys_zone=cache:1m; |
| 835 | +
|
| 836 | + init_by_lua_block { |
| 837 | + assert(require "ngx.process".enable_privileged_agent()) |
| 838 | + -- require "resty.core.regex" |
| 839 | + -- assert(ngx.re.match("hello, world", [[hello, \w+]], "joi")) |
| 840 | + } |
| 841 | +
|
| 842 | +--- config |
| 843 | + location = /t { |
| 844 | + return 200; |
| 845 | + } |
| 846 | +--- request |
| 847 | + GET /t |
| 848 | +--- grep_error_log eval: qr/lua close the global Lua VM \S+ in the cache helper process \d+|lua close the global Lua VM \S+$/ |
| 849 | +--- grep_error_log_out eval |
| 850 | +qr/\Alua close the global Lua VM ([0-9A-F]+) in the cache helper process \d+ |
| 851 | +lua close the global Lua VM \1 |
| 852 | +lua close the global Lua VM \1 in the cache helper process \d+ |
| 853 | +lua close the global Lua VM \1 |
| 854 | +(?:lua close the global Lua VM [0-9A-F]+ |
| 855 | +)*\z/ |
| 856 | +--- error_log eval |
| 857 | +qr/start privileged agent process \d+/ |
| 858 | +--- no_error_log |
| 859 | +[error] |
| 860 | +
|
| 861 | +
|
| 862 | +
|
| 863 | +=== TEST 23: destory Lua VM in cache processes (with init worker and privileged agent) |
| 864 | +--- http_config |
| 865 | + lua_package_path "../lua-resty-core/lib/?.lua;../lua-resty-lrucache/lib/?.lua;;"; |
| 866 | +
|
| 867 | + #lua_shared_dict dogs 1m; |
| 868 | +
|
| 869 | + proxy_cache_path /tmp/cache levels=1:2 keys_zone=cache:1m; |
| 870 | +
|
| 871 | + init_by_lua_block { |
| 872 | + assert(require "ngx.process".enable_privileged_agent()) |
| 873 | + -- require "resty.core.regex" |
| 874 | + -- assert(ngx.re.match("hello, world", [[hello, \w+]], "joi")) |
| 875 | + } |
| 876 | +
|
| 877 | + init_worker_by_lua_block { |
| 878 | + ngx.log(ngx.WARN, "hello from init worker by lua") |
| 879 | + } |
| 880 | +
|
| 881 | +--- config |
| 882 | + location = /t { |
| 883 | + return 200; |
| 884 | + } |
| 885 | +--- request |
| 886 | + GET /t |
| 887 | +--- grep_error_log eval: qr/hello from init worker by lua/ |
| 888 | +--- grep_error_log_out |
| 889 | +hello from init worker by lua |
| 890 | +hello from init worker by lua |
| 891 | +
|
| 892 | +--- error_log eval |
| 893 | +[ |
| 894 | +qr/start privileged agent process \d+$/, |
| 895 | +qr/lua close the global Lua VM ([0-9A-F]+) in the cache helper process \d+$/, |
| 896 | +qr/lua close the global Lua VM ([0-9A-F]+)$/, |
| 897 | +] |
| 898 | +--- no_error_log |
| 899 | +[error] |
| 900 | +
|
| 901 | +
|
| 902 | +
|
| 903 | +=== TEST 24: destory Lua VM in cache processes (with init worker but without privileged agent) |
| 904 | +--- http_config |
| 905 | + lua_package_path "../lua-resty-core/lib/?.lua;../lua-resty-lrucache/lib/?.lua;;"; |
| 906 | +
|
| 907 | + #lua_shared_dict dogs 1m; |
| 908 | +
|
| 909 | + proxy_cache_path /tmp/cache levels=1:2 keys_zone=cache:1m; |
| 910 | +
|
| 911 | + init_by_lua_block { |
| 912 | + -- require "resty.core.regex" |
| 913 | + -- assert(ngx.re.match("hello, world", [[hello, \w+]], "joi")) |
| 914 | + } |
| 915 | +
|
| 916 | + init_worker_by_lua_block { |
| 917 | + ngx.log(ngx.WARN, "hello from init worker by lua") |
| 918 | + } |
| 919 | +
|
| 920 | +--- config |
| 921 | + location = /t { |
| 922 | + return 200; |
| 923 | + } |
| 924 | +--- request |
| 925 | + GET /t |
| 926 | +
|
| 927 | +--- grep_error_log eval: qr/hello from init worker by lua/ |
| 928 | +--- grep_error_log_out |
| 929 | +hello from init worker by lua |
| 930 | +
|
| 931 | +--- error_log eval |
| 932 | +[ |
| 933 | +qr/lua close the global Lua VM ([0-9A-F]+) in the cache helper process \d+$/, |
| 934 | +qr/lua close the global Lua VM ([0-9A-F]+)$/, |
| 935 | +] |
| 936 | +--- no_error_log |
| 937 | +[error] |
| 938 | +start privileged agent process |
0 commit comments