summaryrefslogtreecommitdiff
path: root/echo-nginx-module-0.63/t/blocking-sleep.t
blob: 0bdc6cc16493ba7b50f96e13fdc2ab008a385f96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# vi:filetype=

use lib 'lib';
use Test::Nginx::Socket;

plan tests => 2 * blocks();

#$Test::Nginx::LWP::LogLevel = 'debug';

run_tests();

__DATA__

=== TEST 1: sanity
--- config
    location /echo {
        echo_blocking_sleep 1;
    }
--- request
    GET /echo
--- response_body



=== TEST 2: fractional delay
--- config
    location /echo {
        echo_blocking_sleep 0.01;
    }
--- request
    GET /echo
--- response_body



=== TEST 3: leading echo
--- config
    location /echo {
        echo before...;
        echo_blocking_sleep 0.01;
    }
--- request
    GET /echo
--- response_body
before...



=== TEST 4: trailing echo
--- config
    location /echo {
        echo_blocking_sleep 0.01;
        echo after...;
    }
--- request
    GET /echo
--- response_body
after...



=== TEST 5: two echos around sleep
--- config
    location /echo {
        echo before...;
        echo_blocking_sleep 0.01;
        echo after...;
    }
--- request
    GET /echo
--- response_body
before...
after...



=== TEST 6: interleaving sleep and echo
--- config
    location /echo {
        echo 1;
        echo_blocking_sleep 0.01;
        echo 2;
        echo_blocking_sleep 0.01;
    }
--- request
    GET /echo
--- response_body
1
2



=== TEST 7: interleaving sleep and echo with echo at the end...
--- config
    location /echo {
        echo 1;
        echo_blocking_sleep 0.01;
        echo 2;
        echo_blocking_sleep 0.01;
        echo 3;
    }
--- request
    GET /echo
--- response_body
1
2
3



=== TEST 8: flush before sleep
we didn't really test the actual effect of "echo_flush" here...
merely checks if it croaks if appears.
--- config
    location /flush {
        echo hi;
        echo_flush;
        echo_blocking_sleep 0.01;
        echo trees;
    }
--- request
    GET /flush
--- response_body
hi
trees



=== TEST 9: flush does not increment opcode pointer itself
--- config
    location /flush {
        echo hi;
        echo_flush;
        echo trees;
    }
--- request
    GET /flush
--- response_body
hi
trees



=== TEST 10: blocking sleep by variable
--- config
    location ~ ^/sleep/(.+) {
        echo before...;
        echo_blocking_sleep $1;
        echo after...;
    }
--- request
    GET /sleep/0.01
--- response_body
before...
after...