Mercurial > hg > nginx-tests
annotate upstream_hash_memcached.t @ 1571:1b4ceab9cb1c
Tests: fixed ssl_certificate.t with LibreSSL client.
Net::SSLeay::connect() that manages TLS handshake could return unexpected
error when receiving server alert, as seen in server certificate tests if
it could not been selected. Typically, it returns the expected error -1,
but with certain libssl implementations it can be 0, as explained below.
The error is propagated from libssl's SSL_connect(), which is usually -1.
In modern OpenSSL versions, it is the default error code used in the state
machine returned when something went wrong with parsing TLS message header.
In versions up to OpenSSL 1.0.2, with SSLv23_method() used by default, -1
is the only error code in the ssl_connect() method implementation which is
used as well if receiving alert while parsing ServerHello. BoringSSL also
seems to return -1. But it is not so with LibreSSL that returns zero.
Previously, tests failed with client built with LibreSSL with SSLv3 removed.
Here, the error is propagated directly from ssl_read_bytes() method, which
is always implemented as ssl3_read_bytes() in all TLS methods. It could be
also seen with OpenSSL up to 1.0.2 with non-default methods explicitly set.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Fri, 29 May 2020 23:10:20 +0300 |
parents | b708848eb49a |
children |
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 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 BEGIN { use FindBin; chdir($FindBin::Bin); } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use lib 'lib'; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use Test::Nginx; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 ############################################################################### |
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 select STDERR; $| = 1; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 eval { require Cache::Memcached; }; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 plan(skip_all => 'Cache::Memcached not installed') if $@; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 eval { require Cache::Memcached::Fast; }; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 plan(skip_all => 'Cache::Memcached::Fast not installed') if $@; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 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
|
32 ->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
|
33 |
907e89fba9c3
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
415
diff
changeset
|
34 $t->write_file_expand('nginx.conf', <<'EOF'); |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 %%TEST_GLOBALS%% |
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 daemon off; |
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 events { |
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 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 http { |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 %%TEST_GLOBALS_HTTP%% |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 upstream memd { |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 hash $arg_a; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
48 server 127.0.0.1:8081; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
49 server 127.0.0.1:8082; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
50 server 127.0.0.1:8083; |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 upstream memd_c { |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 hash $arg_a consistent; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
55 server 127.0.0.1:8081; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
56 server 127.0.0.1:8082; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
57 server 127.0.0.1:8083; |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 upstream memd_w { |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 hash $arg_a; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
62 server 127.0.0.1:8081 weight=2; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
63 server 127.0.0.1:8082 weight=3; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
64 server 127.0.0.1:8083; |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 upstream memd_cw { |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 hash $arg_a consistent; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
69 server 127.0.0.1:8081 weight=2; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
70 server 127.0.0.1:8082 weight=3; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
71 server 127.0.0.1:8083; |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
75 listen 127.0.0.1:8080; |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 server_name localhost; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 set $memcached_key $arg_a; |
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 location / { |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 memcached_pass memd; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 location /c { |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 memcached_pass memd_c; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 location /w { |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 memcached_pass memd_w; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 location /cw { |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 memcached_pass memd_cw; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 } |
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 EOF |
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 my $memhelp = `memcached -h`; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 my @memopts = (); |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 if ($memhelp =~ /repcached/) { |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 # repcached patch adds additional listen socket |
412
995f3476202e
Tests: unbreak upsream hash tests with repcached.
Maxim Dounin <mdounin@mdounin.ru>
parents:
411
diff
changeset
|
102 push @memopts, '-X', '0'; |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 if ($memhelp =~ /-U/) { |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 # UDP port is on by default in memcached 1.2.7+ |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 push @memopts, '-U', '0'; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
109 $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
|
110 $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
|
111 $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
|
112 $t->run(); |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
114 $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
|
115 $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
|
116 $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
|
117 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 ############################################################################### |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
120 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
|
121 connect_timeout => 1.0); |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
122 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
|
123 connect_timeout => 1.0); |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
124 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
|
125 connect_timeout => 1.0); |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 for my $i (1 .. 20) { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
128 $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
|
129 $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
|
130 $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
|
131 } |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
614
diff
changeset
|
133 my $memd = new Cache::Memcached(servers => [ |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
134 '127.0.0.1:' . port(8081), |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
135 '127.0.0.1:' . port(8082), |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
136 '127.0.0.1:' . port(8083) ]); |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
138 is_deeply(ngx('/'), mem($memd), 'cache::memcached'); |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
614
diff
changeset
|
140 $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
|
141 '127.0.0.1:' . port(8081), |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
142 '127.0.0.1:' . port(8082), |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
143 '127.0.0.1:' . port(8083)] }); |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 |
1250
b708848eb49a
Tests: handled Cache::Memcached::Fast brokenness.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1249
diff
changeset
|
145 # Cache::Memcached::Fast may be incompatible with recent Perl, |
b708848eb49a
Tests: handled Cache::Memcached::Fast brokenness.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1249
diff
changeset
|
146 # see https://github.com/JRaspass/Cache-Memcached-Fast/issues/12 |
b708848eb49a
Tests: handled Cache::Memcached::Fast brokenness.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1249
diff
changeset
|
147 |
b708848eb49a
Tests: handled Cache::Memcached::Fast brokenness.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1249
diff
changeset
|
148 my $cmf_bug = ! keys %{$memd->server_versions}; |
b708848eb49a
Tests: handled Cache::Memcached::Fast brokenness.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1249
diff
changeset
|
149 |
b708848eb49a
Tests: handled Cache::Memcached::Fast brokenness.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1249
diff
changeset
|
150 SKIP: { |
b708848eb49a
Tests: handled Cache::Memcached::Fast brokenness.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1249
diff
changeset
|
151 skip 'Cache::Memcached::Fast bug', 1 if $cmf_bug; |
b708848eb49a
Tests: handled Cache::Memcached::Fast brokenness.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1249
diff
changeset
|
152 |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
153 is_deeply(ngx('/c'), mem($memd), 'cache::memcached::fast'); |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
154 |
1250
b708848eb49a
Tests: handled Cache::Memcached::Fast brokenness.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1249
diff
changeset
|
155 } |
b708848eb49a
Tests: handled Cache::Memcached::Fast brokenness.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1249
diff
changeset
|
156 |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
157 $memd = new Cache::Memcached(servers => [ |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
158 [ '127.0.0.1:' . port(8081), 2 ], |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
159 [ '127.0.0.1:' . port(8082), 3 ], |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
160 [ '127.0.0.1:' . port(8083), 1 ]]); |
411
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 is_deeply(ngx('/w'), mem($memd), 'cache::memcached weight'); |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
163 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
164 $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
|
165 { 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
|
166 { 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
|
167 { address => '127.0.0.1:' . port(8083), weight => 1 }] }); |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
168 |
1250
b708848eb49a
Tests: handled Cache::Memcached::Fast brokenness.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1249
diff
changeset
|
169 SKIP: { |
b708848eb49a
Tests: handled Cache::Memcached::Fast brokenness.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1249
diff
changeset
|
170 skip 'Cache::Memcached::Fast bug', 1 if $cmf_bug; |
b708848eb49a
Tests: handled Cache::Memcached::Fast brokenness.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1249
diff
changeset
|
171 |
411
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
172 is_deeply(ngx('/cw'), mem($memd), 'cache::memcached::fast weight'); |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
173 |
1250
b708848eb49a
Tests: handled Cache::Memcached::Fast brokenness.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1249
diff
changeset
|
174 } |
b708848eb49a
Tests: handled Cache::Memcached::Fast brokenness.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1249
diff
changeset
|
175 |
411
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 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
178 sub ngx { |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
179 my ($uri) = @_; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
180 [ map { http_get("/$uri?a=$_") =~ /^(\d+)/ms && $1; } (1 .. 20) ]; |
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 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
183 sub mem { |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
184 my ($memd) = @_; |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
185 [ map { $memd->get($_); } (1 .. 20) ]; |
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 |
17c5a1cc8757
Tests: upstream hash tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
188 ############################################################################### |