Skip to content

Commit ae6b59a

Browse files
committed
refactored the test suite a bit.
1 parent aa4bd38 commit ae6b59a

File tree

3 files changed

+300
-280
lines changed

3 files changed

+300
-280
lines changed

t/058-tcp-socket.t

Lines changed: 0 additions & 194 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,197 +1750,3 @@ subrequest: 200, OK\r
17501750
--- no_error_log
17511751
[error]
17521752
1753-
1754-
1755-
=== TEST 30: read timer cleared in time
1756-
--- config
1757-
server_tokens off;
1758-
location /t {
1759-
#set $port 5000;
1760-
set $port $TEST_NGINX_MEMCACHED_PORT;
1761-
1762-
content_by_lua '
1763-
local sock = ngx.socket.tcp()
1764-
local port = ngx.var.port
1765-
1766-
sock:settimeout(400)
1767-
1768-
local ok, err = sock:connect("127.0.0.1", port)
1769-
if not ok then
1770-
ngx.say("failed to connect: ", err)
1771-
return
1772-
end
1773-
1774-
ngx.say("connected: ", ok)
1775-
1776-
local req = "flush_all\\r\\n"
1777-
1778-
local bytes, err = sock:send(req)
1779-
if not bytes then
1780-
ngx.say("failed to send request: ", err)
1781-
return
1782-
end
1783-
ngx.say("request sent: ", bytes)
1784-
1785-
local line, err, part = sock:receive()
1786-
if line then
1787-
ngx.say("received: ", line)
1788-
1789-
else
1790-
ngx.say("failed to receive a line: ", err, " [", part, "]")
1791-
end
1792-
1793-
ngx.location.capture("/sleep")
1794-
1795-
local bytes, err = sock:send(req)
1796-
if not bytes then
1797-
ngx.say("failed to send request: ", err)
1798-
return
1799-
end
1800-
ngx.say("request sent again: ", bytes)
1801-
1802-
ok, err = sock:close()
1803-
ngx.say("close: ", ok, " ", err)
1804-
';
1805-
}
1806-
1807-
location /sleep {
1808-
echo_sleep 0.5;
1809-
}
1810-
1811-
location /foo {
1812-
echo foo;
1813-
more_clear_headers Date;
1814-
}
1815-
--- request
1816-
GET /t
1817-
--- response_body
1818-
connected: 1
1819-
request sent: 11
1820-
received: OK
1821-
request sent again: 11
1822-
close: 1 nil
1823-
--- no_error_log
1824-
[error]
1825-
1826-
1827-
1828-
=== TEST 31: connect timer cleared in time
1829-
--- config
1830-
server_tokens off;
1831-
location /t {
1832-
#set $port 5000;
1833-
set $port $TEST_NGINX_MEMCACHED_PORT;
1834-
1835-
content_by_lua '
1836-
local sock = ngx.socket.tcp()
1837-
local port = ngx.var.port
1838-
1839-
sock:settimeout(300)
1840-
1841-
local ok, err = sock:connect("127.0.0.1", port)
1842-
if not ok then
1843-
ngx.say("failed to connect: ", err)
1844-
return
1845-
end
1846-
1847-
ngx.say("connected: ", ok)
1848-
1849-
ngx.location.capture("/sleep")
1850-
1851-
local req = "flush_all\\r\\n"
1852-
local bytes, err = sock:send(req)
1853-
if not bytes then
1854-
ngx.say("failed to send request: ", err)
1855-
return
1856-
end
1857-
ngx.say("request sent: ", bytes)
1858-
1859-
ok, err = sock:close()
1860-
ngx.say("close: ", ok, " ", err)
1861-
';
1862-
}
1863-
1864-
location /sleep {
1865-
echo_sleep 0.5;
1866-
}
1867-
1868-
location /foo {
1869-
echo foo;
1870-
more_clear_headers Date;
1871-
}
1872-
--- request
1873-
GET /t
1874-
--- response_body
1875-
connected: 1
1876-
request sent: 11
1877-
close: 1 nil
1878-
--- no_error_log
1879-
[error]
1880-
1881-
1882-
1883-
=== TEST 32: send timer cleared in time
1884-
--- config
1885-
server_tokens off;
1886-
location /t {
1887-
#set $port 5000;
1888-
set $port $TEST_NGINX_MEMCACHED_PORT;
1889-
1890-
content_by_lua '
1891-
local sock = ngx.socket.tcp()
1892-
local port = ngx.var.port
1893-
1894-
sock:settimeout(300)
1895-
1896-
local ok, err = sock:connect("127.0.0.1", port)
1897-
if not ok then
1898-
ngx.say("failed to connect: ", err)
1899-
return
1900-
end
1901-
1902-
ngx.say("connected: ", ok)
1903-
1904-
local req = "flush_all\\r\\n"
1905-
1906-
local bytes, err = sock:send(req)
1907-
if not bytes then
1908-
ngx.say("failed to send request: ", err)
1909-
return
1910-
end
1911-
ngx.say("request sent: ", bytes)
1912-
1913-
ngx.location.capture("/sleep")
1914-
1915-
local line, err, part = sock:receive()
1916-
if line then
1917-
ngx.say("received: ", line)
1918-
1919-
else
1920-
ngx.say("failed to receive a line: ", err, " [", part, "]")
1921-
return
1922-
end
1923-
1924-
ok, err = sock:close()
1925-
ngx.say("close: ", ok, " ", err)
1926-
';
1927-
}
1928-
1929-
location /sleep {
1930-
echo_sleep 0.5;
1931-
}
1932-
1933-
location /foo {
1934-
echo foo;
1935-
more_clear_headers Date;
1936-
}
1937-
--- request
1938-
GET /t
1939-
--- response_body
1940-
connected: 1
1941-
request sent: 11
1942-
received: OK
1943-
close: 1 nil
1944-
--- no_error_log
1945-
[error]
1946-

t/066-socket-receiveuntil.t

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -999,89 +999,3 @@ close: nil closed
999999
--- no_error_log
10001000
[error]
10011001

1002-
1003-
1004-
=== TEST 15: read events come when socket is idle
1005-
--- config
1006-
server_tokens off;
1007-
location /t {
1008-
set $port $TEST_NGINX_CLIENT_PORT;
1009-
1010-
content_by_lua '
1011-
local sock = ngx.socket.tcp()
1012-
local port = ngx.var.port
1013-
1014-
local ok, err = sock:connect("127.0.0.1", port)
1015-
if not ok then
1016-
ngx.say("failed to connect: ", err)
1017-
return
1018-
end
1019-
1020-
ngx.say("connected: ", ok)
1021-
1022-
local req = "GET /foo HTTP/1.1\\r\\nHost: localhost\\r\\nConnection: close\\r\\n\\r\\n"
1023-
1024-
local bytes, err = sock:send(req)
1025-
if not bytes then
1026-
ngx.say("failed to send request: ", err)
1027-
return
1028-
end
1029-
ngx.say("request sent: ", bytes)
1030-
1031-
local reader = sock:receiveuntil("foofoo\\r\\n")
1032-
local line, err, part = reader()
1033-
if line then
1034-
ngx.print("read: ", line)
1035-
1036-
else
1037-
ngx.say("failed to read a line: ", err, " [", part, "]")
1038-
end
1039-
1040-
ngx.location.capture("/sleep")
1041-
1042-
local data, err, part = sock:receive("*a")
1043-
if not data then
1044-
ngx.say("failed to read the 2nd part: ", err)
1045-
else
1046-
ngx.say("2nd part: [", data, "]")
1047-
end
1048-
1049-
ok, err = sock:close()
1050-
ngx.say("close: ", ok, " ", err)
1051-
';
1052-
}
1053-
1054-
location /sleep {
1055-
echo_sleep 0.5;
1056-
more_clear_headers Date;
1057-
}
1058-
1059-
location /foo {
1060-
echo -n foofoo;
1061-
echo_flush;
1062-
echo_sleep 0.3;
1063-
echo -n barbar;
1064-
more_clear_headers Date;
1065-
}
1066-
--- request
1067-
GET /t
1068-
--- response_body eval
1069-
qq{connected: 1
1070-
request sent: 57
1071-
read: HTTP/1.1 200 OK\r
1072-
Server: nginx\r
1073-
Content-Type: text/plain\r
1074-
Transfer-Encoding: chunked\r
1075-
Connection: close\r
1076-
\r
1077-
6\r
1078-
2nd part: [6\r
1079-
barbar\r
1080-
0\r
1081-
\r
1082-
]
1083-
close: nil closed
1084-
}
1085-
--- no_error_log
1086-
[error]
1087-

0 commit comments

Comments
 (0)