You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by so...@apache.org on 2016/06/07 16:27:52 UTC

[trafficserver] 09/09: Add tests for TS-3959

This is an automated email from the ASF dual-hosted git repository.

sorber pushed a commit to branch 6.2.x
in repository https://git-dual.apache.org/repos/asf/trafficserver.git

commit 81faf97f4ce6eac9e538c58a6b0e5723251a5876
Author: Thomas Jackson <ja...@gmail.com>
AuthorDate: Tue May 24 08:17:19 2016 -0700

    Add tests for TS-3959
    
    Specifically, we want to test the race condition between KA resuse ATS side and the origin closing the connection
    
    (cherry picked from commit b67906d1a08cc543f5c768676cef606d152afe16)
---
 ci/tsqa/tests/test_connect_attempts.py | 42 ++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/ci/tsqa/tests/test_connect_attempts.py b/ci/tsqa/tests/test_connect_attempts.py
index 231f94d..d52f41e 100644
--- a/ci/tsqa/tests/test_connect_attempts.py
+++ b/ci/tsqa/tests/test_connect_attempts.py
@@ -111,6 +111,36 @@ def thread_slow_response(sock):
             sleep_time -= 1
 
 
+def thread_slow_close(sock):
+    '''
+    Thread to sleep a decreasing amount of time after the request, before closing
+
+    sleep times: 2 -> 1 -> 0
+    '''
+    sock.listen(0)
+    sleep_time = 2
+    num_requests = 0
+    # poll
+    while True:
+        select.select([sock], [], [])
+        try:
+            connection, addr = sock.accept()
+            connection.send((
+                'HTTP/1.1 200 OK\r\n'
+                'Content-Length: {body_len}\r\n'
+                'Content-Type: text/html; charset=UTF-8\r\n'
+                'Connection: close\r\n\r\n{body}'.format(body_len=len(str(num_requests)), body=num_requests)
+            ))
+            time.sleep(sleep_time)
+            connection.close()
+            num_requests += 1
+        except Exception as e:
+            print 'connection died!', e
+            pass
+        if sleep_time > 0:
+            sleep_time -= 1
+
+
 class TestOriginServerConnectAttempts(helpers.EnvironmentCase):
     @classmethod
     def setUpEnv(cls, env):
@@ -154,6 +184,11 @@ class TestOriginServerConnectAttempts(helpers.EnvironmentCase):
         t.daemon = True
         t.start()
 
+        sock = _add_sock('slow_close')
+        t = threading.Thread(target=thread_slow_close, args=(sock,))
+        t.daemon = True
+        t.start()
+
         # only add server headers when there weren't any
         cls.configs['records.config']['CONFIG']['proxy.config.http.response_server_enabled'] = 2
 
@@ -206,3 +241,10 @@ class TestOriginServerConnectAttempts(helpers.EnvironmentCase):
         ret = requests.get(url)
         # make sure it worked
         self.assertEqual(ret.status_code, 504)
+
+    def test_slow_close(self):
+        '''Verify that we retry connecting to an origin when there is a connection failure'''
+        url = 'http://127.0.0.1:{0}/slow_close/s'.format(self.configs['records.config']['CONFIG']['proxy.config.http.server_ports'])
+        ret = requests.get(url)
+        # make sure it worked
+        self.assertEqual(ret.status_code, 200)

-- 
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>.