Mercurial > hg > nginx-tests
annotate http_location_win32.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 | 882267679006 |
children |
rev | line source |
---|---|
261 | 1 #!/usr/bin/env perl |
2 | |
3 # (C) Maxim Dounin | |
4 | |
5 # Tests for location selection on win32. | |
6 | |
7 ############################################################################### | |
8 | |
9 use warnings; | |
10 use strict; | |
11 | |
12 use Test::More; | |
13 | |
14 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
15 | |
16 use lib 'lib'; | |
17 use Test::Nginx; | |
18 | |
19 ############################################################################### | |
20 | |
21 select STDERR; $| = 1; | |
22 select STDOUT; $| = 1; | |
23 | |
24 plan(skip_all => 'not win32') | |
25 if $^O ne 'MSWin32' && $^O ne 'msys'; | |
26 | |
27 my $t = Test::Nginx->new()->has(qw/http rewrite/)->plan(19) | |
28 ->write_file_expand('nginx.conf', <<'EOF'); | |
29 | |
30 %%TEST_GLOBALS%% | |
31 | |
32 daemon off; | |
33 | |
34 events { | |
35 } | |
36 | |
37 http { | |
38 %%TEST_GLOBALS_HTTP%% | |
39 | |
40 server { | |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
41 listen 127.0.0.1:8080; |
261 | 42 server_name localhost; |
43 | |
44 location / { | |
45 add_header X-Location root; | |
46 return 204; | |
47 } | |
48 | |
49 location /directory/ { | |
50 add_header X-Location directory; | |
51 return 204; | |
52 } | |
53 | |
54 location /direct~1 { | |
55 } | |
56 | |
57 location = /file { | |
58 add_header X-Location file; | |
59 return 204; | |
60 } | |
61 } | |
62 } | |
63 | |
64 EOF | |
65 | |
66 $t->run(); | |
67 | |
68 my $d = $t->testdir(); | |
69 mkdir("$d/directory"); | |
70 | |
71 $t->write_file('directory/file', 'SEE-THIS'); | |
72 | |
73 ############################################################################### | |
74 | |
75 like(http_get('/x'), qr/X-Location: root/, 'root'); | |
76 | |
77 # these all are mapped to "/directory/" | |
78 | |
79 like(http_get('/directory/'), qr/X-Location: directory/, 'directory'); | |
80 like(http_get('/Directory/'), qr/X-Location: directory/, 'directory caseless'); | |
81 like(http_get('/directory./'), qr/X-Location: directory/, 'directory dot'); | |
82 like(http_get('/directory.%2ffile'), qr/X-Location: directory/, | |
83 'directory dot encoded slash'); | |
84 like(http_get('/directory::$index_allocation/'), | |
85 qr/X-Location: directory|400 Bad/, | |
86 'directory stream'); | |
87 like(http_get('/directory::$index_allocation./'), | |
88 qr/X-Location: directory|400 Bad/, | |
89 'directory stream dot'); | |
90 like(http_get('/directory:$i30:$index_allocation./'), | |
91 qr/X-Location: directory|400 Bad/, | |
92 'directory i30 stream dot'); | |
93 | |
94 # these looks similar, but shouldn't be mapped to "/directory/" | |
95 | |
96 like(http_get('/directory../'), qr/X-Location: root/, 'directory dot dot'); | |
97 like(http_get('/directory.::$index_allocation/'), qr/X-Location: root|400 Bad/, | |
98 'directory dot stream'); | |
99 | |
100 # short name, should be rejected | |
101 | |
102 unlike(http_get('/direct~1/file'), qr/SEE-THIS/, 'short name'); | |
103 unlike(http_get('/direct~1./file'), qr/SEE-THIS/, 'short name dot'); | |
104 unlike(http_get('/direct~1::$index_allocation./file'), qr/SEE-THIS/, | |
105 'short name stream dot'); | |
106 unlike(http_get('/direct~1.::$index_allocation/file'), qr/SEE-THIS/, | |
107 'short name dot stream'); | |
108 | |
109 # these should be mapped to /file | |
110 | |
111 like(http_get('/file'), qr/X-Location: file/, 'file'); | |
112 like(http_get('/file.'), qr/X-Location: file/, 'file dot'); | |
113 like(http_get('/file..'), qr/X-Location: file/, 'file dot dot'); | |
114 like(http_get('/file%20.%20.'), qr/X-Location: file/, 'file dots and spaces'); | |
115 like(http_get('/file::$data..'), qr/X-Location: file|400 Bad/, | |
116 'file stream dot dot'); | |
117 | |
118 ############################################################################### |