annotate memcached_keepalive.t @ 491:d5bf5942a8b2

Tests: disambiguated parsing of the status code.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 07 Nov 2014 13:05:07 +0300
parents 6cbcfb4ef7ee
children 1a73389a19c4
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/)
6cbcfb4ef7ee Tests: correct has() checks for upstream keepalive tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 250
diff changeset
28 ->has_daemon('memcached')->plan(16)
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 {
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
42 server 127.0.0.1:8081;
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 {
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
47 server 127.0.0.1:8081;
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
48 server 127.0.0.1:8082;
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 {
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
53 server 127.0.0.1:8081;
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
54 server 127.0.0.1:8082;
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 {
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
59 listen 127.0.0.1:8080;
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
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
95 push @memopts1, '-X', '8091';
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
96 push @memopts2, '-X', '8092';
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 }
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
104
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
105 $t->run_daemon('memcached', '-l', '127.0.0.1', '-p', '8081', @memopts1);
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
106 $t->run_daemon('memcached', '-l', '127.0.0.1', '-p', '8082', @memopts2);
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
107
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
108 $t->run();
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
109
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
110 $t->waitforsocket('127.0.0.1:8081')
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
111 or die "Unable to start memcached";
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
112 $t->waitforsocket('127.0.0.1:8082')
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
113 or die "Unable to start second memcached";
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
114
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
115 ###############################################################################
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
116
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
117 my $memd1 = Cache::Memcached->new(servers => [ '127.0.0.1:8081' ]);
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
118 my $memd2 = Cache::Memcached->new(servers => [ '127.0.0.1:8082' ]);
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
119
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
120 $memd1->set('/', 'SEE-THIS');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
121 $memd2->set('/', 'SEE-THIS');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
122 $memd1->set('/big', 'X' x 1000000);
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
123
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
124 my $total = $memd1->stats()->{total}->{total_connections};
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
125
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
126 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
127 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
128 like(http_get('/next'), qr/ 404 /,
250
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
129 'keepalive not found with memcached_next_upstream');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
130 like(http_get('/'), qr/SEE-THIS/, 'keepalive memcached request again');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
131 like(http_get('/'), qr/SEE-THIS/, 'keepalive memcached request again');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
132 like(http_get('/'), qr/SEE-THIS/, 'keepalive memcached request again');
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 is($memd1->stats()->{total}->{total_connections}, $total + 1,
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
135 'only one connection used');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
136
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
137 # 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
138 # 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
139 # connections. Check if we really do close them.
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
140
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
141 $total = $memd1->stats()->{total}->{total_connections};
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
142
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
143 unlike(http_head('/'), qr/SEE-THIS/, 'head request');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
144 like(http_get('/'), qr/SEE-THIS/, 'get after head');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
145
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
146 is($memd1->stats()->{total}->{total_connections}, $total + 1,
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
147 'head request closes connection');
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('/big'), qr/XXX/, 'big head');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
152 like(http_get('/'), qr/SEE-THIS/, 'get after big 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 'big 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 # 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
158 # should establish new connection on each request
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
159
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
160 $total = $memd1->stats()->{total}->{total_connections} +
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
161 $memd2->stats()->{total}->{total_connections};
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
162
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
163 http_get('/memd3');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
164 http_get('/memd3');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
165 http_get('/memd3');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
166
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
167 is($memd1->stats()->{total}->{total_connections} +
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
168 $memd2->stats()->{total}->{total_connections}, $total + 3,
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
169 '3 connections should be established');
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 # 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
172 # should establish only two connections (1 per backend)
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
173
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
174 $total = $memd1->stats()->{total}->{total_connections} +
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
175 $memd2->stats()->{total}->{total_connections};
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
176
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
177 http_get('/memd4');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
178 http_get('/memd4');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
179 http_get('/memd4');
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
180
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
181 is($memd1->stats()->{total}->{total_connections} +
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
182 $memd2->stats()->{total}->{total_connections}, $total + 2,
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
183 'connection per backend');
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 $t->stop();
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
186
0c9f15938545 Tests: upstream keepalive tests imported.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
187 like(`grep -F '[alert]' ${\($t->testdir())}/error.log`, qr/^$/s, 'no alerts');
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 ###############################################################################