Mercurial > hg > nginx-tests
annotate upstream_hash_memcached.t @ 997:3c5d3b384d3f
Tests: adjusted TODOs for HTTP/2 fixes committed in 1.11.3.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 26 Jul 2016 21:00:41 +0300 |
parents | 882267679006 |
children | 196d33c2bb45 |
rev | line source |
---|---|
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for upstream hash balancer module distribution consistency |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 # with Cache::Memcached and Cache::Memcached::Fast. |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 ############################################################################### |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use warnings; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 use strict; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 use Test::More; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 |
582
dc97097100a5
Tests: upstream_hash_memcached.t TODOs on big-endian.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
16 use Config; |
dc97097100a5
Tests: upstream_hash_memcached.t TODOs on big-endian.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
17 |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 BEGIN { use FindBin; chdir($FindBin::Bin); } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 use lib 'lib'; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 use Test::Nginx; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 ############################################################################### |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 select STDERR; $| = 1; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 select STDOUT; $| = 1; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 eval { require Cache::Memcached; }; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 plan(skip_all => 'Cache::Memcached not installed') if $@; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 eval { require Cache::Memcached::Fast; }; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 plan(skip_all => 'Cache::Memcached::Fast not installed') if $@; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 my $t = Test::Nginx->new()->has(qw/http rewrite memcached upstream_hash/) |
568
907e89fba9c3
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
415
diff
changeset
|
34 ->has_daemon('memcached')->plan(4); |
907e89fba9c3
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
415
diff
changeset
|
35 |
907e89fba9c3
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
415
diff
changeset
|
36 $t->write_file_expand('nginx.conf', <<'EOF'); |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 %%TEST_GLOBALS%% |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 daemon off; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 events { |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 http { |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 %%TEST_GLOBALS_HTTP%% |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 upstream memd { |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 hash $arg_a; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
50 server 127.0.0.1:8081; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
51 server 127.0.0.1:8082; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
52 server 127.0.0.1:8083; |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 upstream memd_c { |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 hash $arg_a consistent; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
57 server 127.0.0.1:8081; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
58 server 127.0.0.1:8082; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
59 server 127.0.0.1:8083; |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 upstream memd_w { |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 hash $arg_a; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
64 server 127.0.0.1:8081 weight=2; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
65 server 127.0.0.1:8082 weight=3; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
66 server 127.0.0.1:8083; |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 upstream memd_cw { |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 hash $arg_a consistent; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
71 server 127.0.0.1:8081 weight=2; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
72 server 127.0.0.1:8082 weight=3; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
73 server 127.0.0.1:8083; |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
77 listen 127.0.0.1:8080; |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 server_name localhost; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 set $memcached_key $arg_a; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 location / { |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 memcached_pass memd; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 location /c { |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 memcached_pass memd_c; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 location /w { |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 memcached_pass memd_w; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 location /cw { |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 memcached_pass memd_cw; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 EOF |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 my $memhelp = `memcached -h`; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 my @memopts = (); |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 if ($memhelp =~ /repcached/) { |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 # repcached patch adds additional listen socket |
412
995f3476202e
Tests: unbreak upsream hash tests with repcached.
Maxim Dounin <mdounin@mdounin.ru>
parents:
411
diff
changeset
|
104 push @memopts, '-X', '0'; |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 if ($memhelp =~ /-U/) { |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 # UDP port is on by default in memcached 1.2.7+ |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 push @memopts, '-U', '0'; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
111 $t->run_daemon('memcached', '-l', '127.0.0.1', '-p', port(8081), @memopts); |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
112 $t->run_daemon('memcached', '-l', '127.0.0.1', '-p', port(8082), @memopts); |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
113 $t->run_daemon('memcached', '-l', '127.0.0.1', '-p', port(8083), @memopts); |
568
907e89fba9c3
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
415
diff
changeset
|
114 $t->run(); |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
116 $t->waitforsocket('127.0.0.1:' . port(8081)) or die "Can't start memcached"; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
117 $t->waitforsocket('127.0.0.1:' . port(8082)) or die "Can't start memcached"; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
118 $t->waitforsocket('127.0.0.1:' . port(8083)) or die "Can't start memcached"; |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 ############################################################################### |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
122 my $memd1 = Cache::Memcached->new(servers => [ '127.0.0.1:' . port(8081) ], |
587
c0b4ae82fd9d
Tests: adjusted memcached test timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
582
diff
changeset
|
123 connect_timeout => 1.0); |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
124 my $memd2 = Cache::Memcached->new(servers => [ '127.0.0.1:' . port(8082) ], |
587
c0b4ae82fd9d
Tests: adjusted memcached test timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
582
diff
changeset
|
125 connect_timeout => 1.0); |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
126 my $memd3 = Cache::Memcached->new(servers => [ '127.0.0.1:' . port(8083) ], |
587
c0b4ae82fd9d
Tests: adjusted memcached test timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
582
diff
changeset
|
127 connect_timeout => 1.0); |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 for my $i (1 .. 20) { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
130 $memd1->set($i, port(8081)) or die "can't put value into memcached: $!"; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
131 $memd2->set($i, port(8082)) or die "can't put value into memcached: $!"; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
132 $memd3->set($i, port(8083)) or die "can't put value into memcached: $!"; |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
614
diff
changeset
|
135 my $memd = new Cache::Memcached(servers => [ |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
136 '127.0.0.1:' . port(8081), |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
137 '127.0.0.1:' . port(8082), |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
138 '127.0.0.1:' . port(8083) ]); |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 is_deeply(ngx('/'), mem($memd), 'cache::memcached'); |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
614
diff
changeset
|
142 $memd = new Cache::Memcached::Fast({ ketama_points => 160, servers => [ |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
143 '127.0.0.1:' . port(8081), |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
144 '127.0.0.1:' . port(8082), |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
145 '127.0.0.1:' . port(8083)] }); |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
146 |
582
dc97097100a5
Tests: upstream_hash_memcached.t TODOs on big-endian.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
147 TODO: { |
614
0597ca82c26a
Tests: respected byteorder value on longsize=4 but USE_64_BIT_INT.
Sergey Kandaurov <pluknet@nginx.com>
parents:
587
diff
changeset
|
148 local $TODO = 'not yet' unless $Config{byteorder} =~ '1234' |
582
dc97097100a5
Tests: upstream_hash_memcached.t TODOs on big-endian.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
149 or $t->has_version('1.9.1'); |
dc97097100a5
Tests: upstream_hash_memcached.t TODOs on big-endian.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
150 |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
151 is_deeply(ngx('/c'), mem($memd), 'cache::memcached::fast'); |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
152 |
582
dc97097100a5
Tests: upstream_hash_memcached.t TODOs on big-endian.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
153 } |
dc97097100a5
Tests: upstream_hash_memcached.t TODOs on big-endian.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
154 |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
155 $memd = new Cache::Memcached(servers => [ |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
156 [ '127.0.0.1:' . port(8081), 2 ], |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
157 [ '127.0.0.1:' . port(8082), 3 ], |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
158 [ '127.0.0.1:' . port(8083), 1 ]]); |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
159 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
160 is_deeply(ngx('/w'), mem($memd), 'cache::memcached weight'); |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
161 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
162 $memd = new Cache::Memcached::Fast({ ketama_points => 160, servers => [ |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
163 { address => '127.0.0.1:' . port(8081), weight => 2 }, |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
164 { address => '127.0.0.1:' . port(8082), weight => 3 }, |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
165 { address => '127.0.0.1:' . port(8083), weight => 1 }] }); |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
166 |
582
dc97097100a5
Tests: upstream_hash_memcached.t TODOs on big-endian.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
167 TODO: { |
614
0597ca82c26a
Tests: respected byteorder value on longsize=4 but USE_64_BIT_INT.
Sergey Kandaurov <pluknet@nginx.com>
parents:
587
diff
changeset
|
168 local $TODO = 'not yet' unless $Config{byteorder} =~ '1234' |
582
dc97097100a5
Tests: upstream_hash_memcached.t TODOs on big-endian.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
169 or $t->has_version('1.9.1'); |
dc97097100a5
Tests: upstream_hash_memcached.t TODOs on big-endian.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
170 |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
171 is_deeply(ngx('/cw'), mem($memd), 'cache::memcached::fast weight'); |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
172 |
582
dc97097100a5
Tests: upstream_hash_memcached.t TODOs on big-endian.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
173 } |
dc97097100a5
Tests: upstream_hash_memcached.t TODOs on big-endian.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
174 |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
175 ############################################################################### |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
176 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
177 sub ngx { |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
178 my ($uri) = @_; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
179 [ map { http_get("/$uri?a=$_") =~ /^(\d+)/ms && $1; } (1 .. 20) ]; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
180 } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
181 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
182 sub mem { |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
183 my ($memd) = @_; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
184 [ map { $memd->get($_); } (1 .. 20) ]; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
185 } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
186 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
187 ############################################################################### |