annotate memcached_keepalive.t @ 1585:bff287fbf347

Tests: added proxy_cookie_domain/path tests with "off" parameter.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 23 Jul 2020 12:17:39 +0300
parents 882267679006
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
250
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
1 #!/usr/bin/perl
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
2
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
3 # (C) Maxim Dounin
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
4
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
5 # Test for memcached with keepalive.
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
6
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
7 ###############################################################################
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
8
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
9 use warnings;
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
10 use strict;
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
11
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
12 use Test::More;
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
13
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
14 BEGIN { use FindBin; chdir($FindBin::Bin); }
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
15
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
16 use lib 'lib';
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
17 use Test::Nginx;
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
18
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
19 ###############################################################################
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
20
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
21 select STDERR; $| = 1;
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
22 select STDOUT; $| = 1;
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
23
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
24 eval { require Cache::Memcached; };
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
25 plan(skip_all => 'Cache::Memcached not installed') if $@;
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
26
275
6cbcfb4ef7ee Tests: correct has() checks for upstream keepalive tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 250
diff changeset
27 my $t = Test::Nginx->new()->has(qw/http memcached upstream_keepalive rewrite/)
593
6c0a5903d0ae Tests: cleanup now duplicating tests for no alerts.
Sergey Kandaurov <pluknet@nginx.com>
parents: 587
diff changeset
28 ->has_daemon('memcached')->plan(15)
250
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
29 ->write_file_expand('nginx.conf', <<'EOF');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
30
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
31 %%TEST_GLOBALS%%
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
32
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
33 daemon off;
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
34
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
35 events {
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
36 }
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
37
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
38 http {
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
39 %%TEST_GLOBALS_HTTP%%
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
40
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
41 upstream memd {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
42 server 127.0.0.1:8081;
250
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
43 keepalive 1;
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
44 }
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
45
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
46 upstream memd3 {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
47 server 127.0.0.1:8081;
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
48 server 127.0.0.1:8082;
250
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
49 keepalive 1;
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
50 }
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
51
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
52 upstream memd4 {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
53 server 127.0.0.1:8081;
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
54 server 127.0.0.1:8082;
250
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
55 keepalive 10;
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
56 }
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
57
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
58 server {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
59 listen 127.0.0.1:8080;
250
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
60 server_name localhost;
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
61
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
62 location / {
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
63 set $memcached_key $uri;
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
64 memcached_pass memd;
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
65 }
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
66
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
67 location /next {
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
68 set $memcached_key $uri;
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
69 memcached_next_upstream not_found;
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
70 memcached_pass memd;
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
71 }
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
72
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
73 location /memd3 {
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
74 set $memcached_key "/";
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
75 memcached_pass memd3;
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
76 }
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
77
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
78 location /memd4 {
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
79 set $memcached_key "/";
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
80 memcached_pass memd4;
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
81 }
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
82 }
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
83 }
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
84
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
85 EOF
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
86
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
87 my $memhelp = `memcached -h`;
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
88 my @memopts1 = ();
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
89 my @memopts2 = ();
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
90
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
91 if ($memhelp =~ /repcached/) {
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
92 # repcached patches adds additional listen socket memcached
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
93 # that should be different too
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
94
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
95 push @memopts1, '-X', port(8083);
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
96 push @memopts2, '-X', port(8084);
250
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
97 }
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
98 if ($memhelp =~ /-U/) {
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
99 # UDP ports no longer off by default in memcached 1.2.7+
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
100
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
101 push @memopts1, '-U', '0';
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
102 push @memopts2, '-U', '0';
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
103 }
513
1a73389a19c4 Tests: fixed tests with multi-threaded memcached.
Sergey Kandaurov <pluknet@nginx.com>
parents: 491
diff changeset
104 if ($memhelp =~ /-t/) {
1a73389a19c4 Tests: fixed tests with multi-threaded memcached.
Sergey Kandaurov <pluknet@nginx.com>
parents: 491
diff changeset
105 # for connection stats consistency in threaded memcached 1.3+
1a73389a19c4 Tests: fixed tests with multi-threaded memcached.
Sergey Kandaurov <pluknet@nginx.com>
parents: 491
diff changeset
106
1a73389a19c4 Tests: fixed tests with multi-threaded memcached.
Sergey Kandaurov <pluknet@nginx.com>
parents: 491
diff changeset
107 push @memopts1, '-t', '1';
1a73389a19c4 Tests: fixed tests with multi-threaded memcached.
Sergey Kandaurov <pluknet@nginx.com>
parents: 491
diff changeset
108 push @memopts2, '-t', '1';
1a73389a19c4 Tests: fixed tests with multi-threaded memcached.
Sergey Kandaurov <pluknet@nginx.com>
parents: 491
diff changeset
109 }
250
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
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), @memopts1);
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), @memopts2);
250
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
113
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
114 $t->run();
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
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))
250
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
117 or die "Unable to start memcached";
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
118 $t->waitforsocket('127.0.0.1:' . port(8082))
250
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
119 or die "Unable to start second memcached";
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
120
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
121 ###############################################################################
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
122
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
123 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: 513
diff changeset
124 connect_timeout => 1.0);
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
125 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: 513
diff changeset
126 connect_timeout => 1.0);
250
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
127
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
128 $memd1->set('/', 'SEE-THIS');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
129 $memd2->set('/', 'SEE-THIS');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
130 $memd1->set('/big', 'X' x 1000000);
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
131
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
132 my $total = $memd1->stats()->{total}->{total_connections};
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
133
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
134 like(http_get('/'), qr/SEE-THIS/, 'keepalive memcached request');
491
d5bf5942a8b2 Tests: disambiguated parsing of the status code.
Sergey Kandaurov <pluknet@nginx.com>
parents: 275
diff changeset
135 like(http_get('/notfound'), qr/ 404 /, 'keepalive memcached not found');
d5bf5942a8b2 Tests: disambiguated parsing of the status code.
Sergey Kandaurov <pluknet@nginx.com>
parents: 275
diff changeset
136 like(http_get('/next'), qr/ 404 /,
250
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
137 'keepalive not found with memcached_next_upstream');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
138 like(http_get('/'), qr/SEE-THIS/, 'keepalive memcached request again');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
139 like(http_get('/'), qr/SEE-THIS/, 'keepalive memcached request again');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
140 like(http_get('/'), qr/SEE-THIS/, 'keepalive memcached request again');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
141
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
142 is($memd1->stats()->{total}->{total_connections}, $total + 1,
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
143 'only one connection used');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
144
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
145 # Since nginx doesn't read all data from connection in some situations (head
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
146 # requests, post_action, errors writing to client) we have to close such
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
147 # connections. Check if we really do close them.
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
148
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
149 $total = $memd1->stats()->{total}->{total_connections};
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
150
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
151 unlike(http_head('/'), qr/SEE-THIS/, 'head request');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
152 like(http_get('/'), qr/SEE-THIS/, 'get after head');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
153
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
154 is($memd1->stats()->{total}->{total_connections}, $total + 1,
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
155 'head request closes connection');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
156
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
157 $total = $memd1->stats()->{total}->{total_connections};
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
158
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
159 unlike(http_head('/big'), qr/XXX/, 'big head');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
160 like(http_get('/'), qr/SEE-THIS/, 'get after big head');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
161
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
162 is($memd1->stats()->{total}->{total_connections}, $total + 1,
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
163 'big head request closes connection');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
164
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
165 # two backends with maximum number of cached connections set to 1,
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
166 # should establish new connection on each request
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
167
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
168 $total = $memd1->stats()->{total}->{total_connections} +
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
169 $memd2->stats()->{total}->{total_connections};
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
170
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
171 http_get('/memd3');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
172 http_get('/memd3');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
173 http_get('/memd3');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
174
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
175 is($memd1->stats()->{total}->{total_connections} +
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
176 $memd2->stats()->{total}->{total_connections}, $total + 3,
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
177 '3 connections should be established');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
178
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
179 # two backends with maximum number of cached connections set to 10,
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
180 # should establish only two connections (1 per backend)
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
181
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
182 $total = $memd1->stats()->{total}->{total_connections} +
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
183 $memd2->stats()->{total}->{total_connections};
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
184
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
185 http_get('/memd4');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
186 http_get('/memd4');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
187 http_get('/memd4');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
188
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
189 is($memd1->stats()->{total}->{total_connections} +
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
190 $memd2->stats()->{total}->{total_connections}, $total + 2,
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
191 'connection per backend');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
192
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
193 ###############################################################################