]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
pytests: clean up docstrings
authorTomas Krizek <tomas.krizek@nic.cz>
Tue, 20 Nov 2018 11:53:09 +0000 (12:53 +0100)
committerTomas Krizek <tomas.krizek@nic.cz>
Tue, 4 Dec 2018 16:13:42 +0000 (17:13 +0100)
tests/pytests/test_conn_mgmt.py
tests/pytests/test_prefix.py [moved from tests/pytests/test_tcp_prefix.py with 90% similarity]

index b9762bee6b66a85edfcbe2bd5c091a3f5fbe5535..8c21f5e3291a50b6bf451357713833c5c73fa111 100644 (file)
@@ -10,12 +10,7 @@ import utils
 
 
 def test_ignore_garbage(kresd_sock):
-    """
-    Send chunk of garbage, correctly prefixed by garbage length. Then, send
-    correct DNS query.
-
-    Expected: garbage must be ignored and the second query must be answered
-    """
+    """Send chunk of garbage, prefixed by garbage length. It should be ignored."""
     msg_buff, msgid = utils.get_msgbuff()
     garbage_buff = utils.get_prefixed_garbage(1024)
     kresd_sock.sendall(garbage_buff + msg_buff)
@@ -25,11 +20,7 @@ def test_ignore_garbage(kresd_sock):
 
 
 def test_pipelining(kresd_sock):
-    """
-    Test sends two queries to kresd - 1000.delay.getdnsapi.net and 1.delay.getdnsapi.net.
-
-    Expected: answer to the second query must come first.
-    """
+    """First query takes longer to resolve - answer to second query should arrive sooner."""
     buff1, msgid1 = utils.get_msgbuff('1000.delay.getdnsapi.net.', msgid=1)
     buff2, msgid2 = utils.get_msgbuff('1.delay.getdnsapi.net.', msgid=2)
     buff = buff1 + buff2
@@ -43,12 +34,7 @@ def test_pipelining(kresd_sock):
 
 
 def test_long_lived(kresd_sock):
-    """
-    Test establishes a TCP connection a sends several queries over it. They are sent
-    seqeuntially, each with a delay, which in total exceeds maximum timeout.
-
-    Expected: kresd must not close the connection
-    """
+    """Establish and keep connection alive for longer than maximum timeout."""
     utils.ping_alive(kresd_sock)
     end_time = time.time() + utils.MAX_TIMEOUT
 
@@ -62,12 +48,7 @@ def test_long_lived(kresd_sock):
     False  # test closing established connection after handshake
 ])
 def test_close(kresd_sock, query_before):
-    """
-    Test establishes a TCP connection, optionally sends a query and waits for response,
-    and then pauses (MAX_TIMEOUT). Afterwards, another query is sent.
-
-    Expected: kresd closes the connection
-    """
+    """Establish a connection and wait for timeout from kresd."""
     if query_before:
         utils.ping_alive(kresd_sock)
     time.sleep(utils.MAX_TIMEOUT)
@@ -81,11 +62,7 @@ def test_close(kresd_sock, query_before):
     False  # test slow-lorris right after handshake
 ])
 def test_slow_lorris(kresd_sock, query_before):
-    """
-    Test simulates slow-lorris attack by sending byte after byte with a delay in between.
-
-    Expected: kresd closes the connection
-    """
+    """Simulate slow-lorris attack by sending byte after byte with delays in between."""
     if query_before:
         utils.ping_alive(kresd_sock)
 
@@ -102,11 +79,7 @@ def test_slow_lorris(kresd_sock, query_before):
 
 
 def test_ignore_jumbo_message(kresd_sock):
-    """
-    Test if kresd correcty ignores bigger queries than 4096 (current maximum size in kresd).
-
-    Expected: jumbo message must be ignored, other queries answered
-    """
+    """Queries bigger than 4096 bytes should be ignored."""
     buff1, msgid1 = utils.get_msgbuff(msgid=1)
     gbuff = utils.get_prefixed_garbage(65533)
     kresd_sock.sendall(buff1 + gbuff)
@@ -157,11 +130,7 @@ def flood_buffer(msgcount):
 
 
 def test_query_flood_close(make_kresd_sock):
-    """
-    Test floods resolver with queries and closes the connection.
-
-    Expected: resolver must not crash
-    """
+    """Flood resolver with queries and close the connection."""
     buff = flood_buffer(10000)
     sock1 = make_kresd_sock()
     sock1.sendall(buff)
@@ -195,7 +164,7 @@ def test_query_flood_no_recv(make_kresd_sock):
 
 
 def test_query_flood_garbage(make_kresd_sock):
-    """Flood resolver with correctly prefixed garbage of maximum size."""
+    """Flood resolver with prefixed garbage of maximum size."""
     # TODO - despite the fact that kresd closes TCP connection, it seems to be
     # error in TCP stream parsing. Kresd closes TCP connection because of
     # message length in TCP prefix is lesser then length of the fixed message
similarity index 90%
rename from tests/pytests/test_tcp_prefix.py
rename to tests/pytests/test_prefix.py
index 03e0eaf1c40d52e4cffce08b91de5b36035269a3..ce19e2745840ed419737a5b75a5e1d8727dc6f77 100644 (file)
@@ -35,7 +35,7 @@ def send_incorrect_repeatedly(sock, buff, delay=1):
             time.sleep(delay)
 
 
-def test_less_than_header(kresd_sock):
+def test_prefix_less_than_header(kresd_sock):
     """Prefix is less than the length of the DNS message header."""
     wire, _ = utils.prepare_wire()
     datalen = 11  # DNS header size minus 1
@@ -43,7 +43,7 @@ def test_less_than_header(kresd_sock):
     send_incorrect_repeatedly(kresd_sock, buff)
 
 
-def test_greater_than_message(kresd_sock):
+def test_prefix_greater_than_message(kresd_sock):
     """Prefix is greater than the length of the entire DNS message."""
     wire, _ = utils.prepare_wire()
     datalen = len(wire) + 16
@@ -51,7 +51,7 @@ def test_greater_than_message(kresd_sock):
     send_incorrect_repeatedly(kresd_sock, buff)
 
 
-def test_cuts_message(kresd_sock):
+def test_prefix_cuts_message(kresd_sock):
     """Prefix is greater than the length of the DNS message header, but shorter than
     the entire DNS message."""
     wire, _ = utils.prepare_wire()
@@ -61,7 +61,7 @@ def test_cuts_message(kresd_sock):
     send_incorrect_repeatedly(kresd_sock, buff)
 
 
-def test_cuts_message_after_ok(kresd_sock):
+def test_prefix_cuts_message_after_ok(kresd_sock):
     """First, normal DNS message is sent. Afterwards, message with incorrect prefix
     (greater than header, less than entire message) is sent. First message must be
     answered, then the connection should be closed after timeout."""
@@ -83,8 +83,7 @@ def test_cuts_message_after_ok(kresd_sock):
 
 
 def test_trailing_garbage(kresd_sock):
-    """Prefix is correct, but the message has trailing garbage. The connection must
-    stay open until all message have been sent and answered."""
+    """Send messages with trailing garbage (its length included in prefix)."""
     for _ in range(10):
         wire, msgid = utils.prepare_wire()
         wire += utils.get_garbage(8)