Mercurial > hg > nginx-tests
annotate stream_access_log_none.t @ 1427:eb1d883305ea
Tests: avoid edge cases in upstream random two test.
Unavailable servers contribute to the number of attempts, if selected,
before the balancer would fall back to the default round-robin method.
This means that it's quite possible to get server with more connections.
To facilitate with selecting two alive servers, down server was removed
from the upstream configuration at the cost of slightly worse coverage.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 10 Jan 2019 17:42:34 +0300 |
parents | 97c8280de681 |
children | f3ba4c74de31 |
rev | line source |
---|---|
1296
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Stream tests for access_log with escape parameter. |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 ############################################################################### |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
1381
97c8280de681
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1296
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/stream stream_map stream_return/)->plan(1) |
1296
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 ->write_file_expand('nginx.conf', <<'EOF'); |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 %%TEST_GLOBALS%% |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 daemon off; |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 events { |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 } |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 stream { |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 map $pid $a { |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 default '" \ "'; |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 } |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 map $pid $b { |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 default "foo"; |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 } |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 log_format none escape=none $a$b$upstream_addr; |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 server { |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 listen 127.0.0.1:8080; |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 return ok; |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 access_log %%TESTDIR%%/none.log none; |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 } |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 } |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 EOF |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 |
1381
97c8280de681
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1296
diff
changeset
|
55 $t->run(); |
1296
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 ############################################################################### |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 http_get('/'); |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 $t->stop(); |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 is($t->read_file('none.log'), '" \\ "foo' . "\n", 'none'); |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 |
5d75938b2622
Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 ############################################################################### |