comparison stream_geo_binary.t @ 1044:1fe8d33f75ad

Tests: split out geo tests with binary base and skip by default. These tests require configuration with a large number of geo entries, which may cause long configuration parsing and enrage waitforfile().
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 30 Sep 2016 20:31:09 +0300
parents
children 3fc6817cd84a
comparison
equal deleted inserted replaced
1043:b82f54728e14 1044:1fe8d33f75ad
1 #!/usr/bin/perl
2
3 # (C) Andrey Zelenkov
4 # (C) Nginx, Inc.
5
6 # Tests for stream geo module with binary base.
7
8 ###############################################################################
9
10 use warnings;
11 use strict;
12
13 use Test::More;
14
15 BEGIN { use FindBin; chdir($FindBin::Bin); }
16
17 use lib 'lib';
18 use Test::Nginx;
19 use Test::Nginx::Stream qw/ stream /;
20
21 ###############################################################################
22
23 select STDERR; $| = 1;
24 select STDOUT; $| = 1;
25
26 plan(skip_all => 'long configuration parsing') unless $ENV{TEST_NGINX_UNSAFE};
27
28 my $t = Test::Nginx->new()->has(qw/stream stream_return stream_geo/);
29
30 $t->write_file_expand('nginx.conf', <<'EOF');
31
32 %%TEST_GLOBALS%%
33
34 daemon off;
35
36 events {
37 }
38
39 stream {
40 geo $geo_base_create {
41 ranges;
42 include base.conf;
43 }
44
45 geo $geo_base_include {
46 ranges;
47 include base.conf;
48 }
49
50 server {
51 listen 127.0.0.1:8080;
52 return "geo_base_create:$geo_base_create
53 geo_base_include:$geo_base_include";
54 }
55 }
56
57 EOF
58
59 $t->write_file('base.conf', join('', map {
60 "127." . $_/256/256 % 256 . "." . $_/256 % 256 . "." . $_ % 256 .
61 "-127." . $_/256/256 % 256 . "." . $_/256 % 256 . "." .$_ % 256 . " " .
62 ($_ == 1 ? "loopback" : "range$_") . ";" } (0 .. 100000)));
63
64 $t->try_run('no stream geo')->plan(2);
65
66 ###############################################################################
67
68 my %data = stream()->read() =~ /(\w+):(\w+)/g;
69 is($data{geo_base_create}, 'loopback', 'geo binary base create');
70 is($data{geo_base_include}, 'loopback', 'geo binary base include');
71
72 ###############################################################################