comparison memcached.t @ 952:e9064d691790

Tests: converted tests to run in parallel.
author Andrey Zelenkov <zelenkov@nginx.com>
date Tue, 21 Jun 2016 16:39:13 +0300
parents c0b4ae82fd9d
children 882267679006
comparison
equal deleted inserted replaced
951:9361c7eddfc1 952:e9064d691790
37 37
38 http { 38 http {
39 %%TEST_GLOBALS_HTTP%% 39 %%TEST_GLOBALS_HTTP%%
40 40
41 server { 41 server {
42 listen 127.0.0.1:8080; 42 listen 127.0.0.1:%%PORT_0%%;
43 server_name localhost; 43 server_name localhost;
44 44
45 location / { 45 location / {
46 set $memcached_key $uri; 46 set $memcached_key $uri;
47 memcached_pass 127.0.0.1:8081; 47 memcached_pass 127.0.0.1:%%PORT_1%%;
48 } 48 }
49 49
50 location /next { 50 location /next {
51 set $memcached_key $uri; 51 set $memcached_key $uri;
52 memcached_next_upstream not_found; 52 memcached_next_upstream not_found;
53 memcached_pass 127.0.0.1:8081; 53 memcached_pass 127.0.0.1:%%PORT_1%%;
54 } 54 }
55 } 55 }
56 } 56 }
57 57
58 EOF 58 EOF
60 my $memhelp = `memcached -h`; 60 my $memhelp = `memcached -h`;
61 my @memopts = (); 61 my @memopts = ();
62 62
63 if ($memhelp =~ /repcached/) { 63 if ($memhelp =~ /repcached/) {
64 # repcached patch adds additional listen socket 64 # repcached patch adds additional listen socket
65 push @memopts, '-X', '8082'; 65 push @memopts, '-X', port(2);
66 } 66 }
67 if ($memhelp =~ /-U/) { 67 if ($memhelp =~ /-U/) {
68 # UDP port is on by default in memcached 1.2.7+ 68 # UDP port is on by default in memcached 1.2.7+
69 push @memopts, '-U', '0'; 69 push @memopts, '-U', '0';
70 } 70 }
71 71
72 $t->run_daemon('memcached', '-l', '127.0.0.1', '-p', '8081', @memopts); 72 $t->run_daemon('memcached', '-l', '127.0.0.1', '-p', port(1), @memopts);
73 $t->run(); 73 $t->run();
74 74
75 $t->waitforsocket('127.0.0.1:8081') 75 $t->waitforsocket('127.0.0.1:' . port(1))
76 or die "Can't start memcached"; 76 or die "Can't start memcached";
77 77
78 ############################################################################### 78 ###############################################################################
79 79
80 my $memd = Cache::Memcached->new(servers => [ '127.0.0.1:8081' ], 80 my $memd = Cache::Memcached->new(servers => [ '127.0.0.1:' . port(1) ],
81 connect_timeout => 1.0); 81 connect_timeout => 1.0);
82 $memd->set('/', 'SEE-THIS') 82 $memd->set('/', 'SEE-THIS')
83 or die "can't put value into memcached: $!"; 83 or die "can't put value into memcached: $!";
84 84
85 like(http_get('/'), qr/SEE-THIS/, 'memcached request'); 85 like(http_get('/'), qr/SEE-THIS/, 'memcached request');