annotate http_block.t @ 606:530a3152753b

Tests: simple http proxy test with multiple http blocks.
author Sergey Kandaurov <pluknet@nginx.com>
date Mon, 15 Jun 2015 19:59:59 +0300
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
606
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3 # (C) Sergey Kandaurov
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
4 # (C) Nginx, Inc.
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
5
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
6 # Tests for http proxy module with multiple http configuration blocks.
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
7
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
8 ###############################################################################
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
9
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
10 use warnings;
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
11 use strict;
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
12
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
13 use Test::More;
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
14
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
15 BEGIN { use FindBin; chdir($FindBin::Bin); }
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
16
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
17 use lib 'lib';
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
18 use Test::Nginx;
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
19
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
20 ###############################################################################
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
21
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
22 select STDERR; $| = 1;
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
23 select STDOUT; $| = 1;
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
24
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
25 my $t = Test::Nginx->new()->has(qw/http proxy/)->plan(1);
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
26
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
27 $t->write_file_expand('nginx.conf', <<'EOF');
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
28
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
29 %%TEST_GLOBALS%%
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
30
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
31 daemon off;
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
32
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
33 events {
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
34 }
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
36 http {
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
37 %%TEST_GLOBALS_HTTP%%
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
38
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
39 server {
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
40 listen 127.0.0.1:8080;
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
41 server_name localhost;
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
42
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
43 location / {
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
44 proxy_pass http://127.0.0.1:8081;
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
45 proxy_read_timeout 1s;
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
46 }
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
47 }
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
48 }
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
49
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
50 http {
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
51 %%TEST_GLOBALS_HTTP%%
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
52
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
53 server {
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
54 listen 127.0.0.1:8081;
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
55 server_name localhost;
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
56
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
57 location / {}
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
58 }
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
59 }
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
60
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
61 EOF
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
62
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
63 $t->write_file('t', 'SEE-THIS');
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
64 $t->run();
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
65
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
66 ###############################################################################
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
67
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
68 like(http_get('/t'), qr/SEE-THIS/, 'proxy request');
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
69
530a3152753b Tests: simple http proxy test with multiple http blocks.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
70 ###############################################################################