You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ja...@apache.org on 2015/09/18 20:19:17 UTC
trafficserver git commit: flake8 cleanup of tests
Repository: trafficserver
Updated Branches:
refs/heads/master dc4e52e5e -> 4a3389306
flake8 cleanup of tests
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/4a338930
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/4a338930
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/4a338930
Branch: refs/heads/master
Commit: 4a3389306f48fafc68fb5a8f2c215a516b848d57
Parents: dc4e52e
Author: Thomas Jackson <ja...@apache.org>
Authored: Fri Sep 18 11:18:29 2015 -0700
Committer: Thomas Jackson <ja...@apache.org>
Committed: Fri Sep 18 11:19:08 2015 -0700
----------------------------------------------------------------------
ci/tsqa/tests/test_body_factory.py | 11 +++--------
ci/tsqa/tests/test_custom_log.py | 8 ++++----
ci/tsqa/tests/test_headrequest.py | 5 -----
ci/tsqa/tests/test_http2_spec.py | 2 ++
ci/tsqa/tests/test_origin_min_keep_alive_connection.py | 11 ++++++-----
5 files changed, 15 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4a338930/ci/tsqa/tests/test_body_factory.py
----------------------------------------------------------------------
diff --git a/ci/tsqa/tests/test_body_factory.py b/ci/tsqa/tests/test_body_factory.py
index 6d123a2..2842a6f 100644
--- a/ci/tsqa/tests/test_body_factory.py
+++ b/ci/tsqa/tests/test_body_factory.py
@@ -21,14 +21,13 @@ Test body_factory
import os
import requests
import logging
-import SocketServer
import random
import tsqa.test_cases
import helpers
-import json
log = logging.getLogger(__name__)
+
class TestDomainSpecificBodyFactory(helpers.EnvironmentCase):
'''
Tests for how body factory works with requests of different domains
@@ -64,15 +63,11 @@ class TestDomainSpecificBodyFactory(helpers.EnvironmentCase):
url = 'http://127.1.0.1:{0}'.format(self.configs['records.config']['CONFIG']['proxy.config.http.server_ports'])
for i in xrange(times):
domain = random.choice(self.domain_directory)
- headers = {'Host' : domain}
- r = requests.get(url, headers = headers)
+ headers = {'Host': domain}
+ r = requests.get(url, headers=headers)
domain_in_response = no_dir_domain
for domain_item in self.domain_directory:
if domain_item in r.text:
domain_in_response = domain_item
break
self.assertEqual(domain, domain_in_response)
-
-
-
-
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4a338930/ci/tsqa/tests/test_custom_log.py
----------------------------------------------------------------------
diff --git a/ci/tsqa/tests/test_custom_log.py b/ci/tsqa/tests/test_custom_log.py
index 417af18..15cb418 100644
--- a/ci/tsqa/tests/test_custom_log.py
+++ b/ci/tsqa/tests/test_custom_log.py
@@ -25,10 +25,10 @@ import logging
import random
import tsqa.test_cases
import helpers
-import json
log = logging.getLogger(__name__)
+
class TestCustomLogField(helpers.EnvironmentCase):
'''
Tests for a customed log field called hii
@@ -41,7 +41,7 @@ class TestCustomLogField(helpers.EnvironmentCase):
)
cls.log_file_name = 'test_log_field'
cls.configs['records.config']['CONFIG'].update({
- 'proxy.config.log.custom_logs_enabled': 1,
+ 'proxy.config.log.custom_logs_enabled': 1,
})
cls.log_file_path = os.path.join(cls.environment.layout.prefix, 'var/log/test_log_field.log')
@@ -60,8 +60,8 @@ class TestCustomLogField(helpers.EnvironmentCase):
for i in xrange(times):
request_ip = "127.%d.%d.%d" % (random.randint(1, 255), random.randint(1, 255), random.randint(1, 255))
url = 'http://%s:%s' % (request_ip, self.configs['records.config']['CONFIG']['proxy.config.http.server_ports'])
- r = requests.get(url)
- #get the last line of the log file
+ requests.get(url)
+ # get the last line of the log file
time.sleep(10)
with open(self.log_file_path) as f:
for line in f:
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4a338930/ci/tsqa/tests/test_headrequest.py
----------------------------------------------------------------------
diff --git a/ci/tsqa/tests/test_headrequest.py b/ci/tsqa/tests/test_headrequest.py
index 73736a5..e19312a 100644
--- a/ci/tsqa/tests/test_headrequest.py
+++ b/ci/tsqa/tests/test_headrequest.py
@@ -18,15 +18,11 @@ Test Head Request
# See the License for the specific language governing permissions and
# limitations under the License.
-import requests
import time
import logging
import SocketServer
-import random
import tsqa.test_cases
import helpers
-import json
-import select
import socket
log = logging.getLogger(__name__)
@@ -71,7 +67,6 @@ class HeadRequestServerHandler(SocketServer.BaseRequestHandler):
self.request.sendall(resp)
-
class TestHeadRequestWithoutTimeout(helpers.EnvironmentCase):
'''
Tests for ATS handling head requests correctly without waiting for the http body
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4a338930/ci/tsqa/tests/test_http2_spec.py
----------------------------------------------------------------------
diff --git a/ci/tsqa/tests/test_http2_spec.py b/ci/tsqa/tests/test_http2_spec.py
index 40a829e..6c53126 100644
--- a/ci/tsqa/tests/test_http2_spec.py
+++ b/ci/tsqa/tests/test_http2_spec.py
@@ -31,6 +31,7 @@ import tsqa.utils
log = logging.getLogger(__name__)
+
# helper function to get h2spec path
def which(program):
def is_exe(fpath):
@@ -47,6 +48,7 @@ def which(program):
return exe_file
return None
+
class TestH2Spec(helpers.EnvironmentCase, tsqa.test_cases.HTTPBinCase):
@classmethod
def setUpEnv(cls, env):
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4a338930/ci/tsqa/tests/test_origin_min_keep_alive_connection.py
----------------------------------------------------------------------
diff --git a/ci/tsqa/tests/test_origin_min_keep_alive_connection.py b/ci/tsqa/tests/test_origin_min_keep_alive_connection.py
index 706c719..4d7e8b4 100644
--- a/ci/tsqa/tests/test_origin_min_keep_alive_connection.py
+++ b/ci/tsqa/tests/test_origin_min_keep_alive_connection.py
@@ -18,10 +18,8 @@ Test the configure entry : proxy.config.http.origin_min_keep_alive_connections
# See the License for the specific language governing permissions and
# limitations under the License.
-import requests
import time
import logging
-import SocketServer
import uuid
import socket
import tsqa.test_cases
@@ -30,6 +28,7 @@ import thread
log = logging.getLogger(__name__)
+
def simple_socket_server(host, port):
log.info("starting the socket server")
serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@@ -37,13 +36,16 @@ def simple_socket_server(host, port):
serv.setblocking(1)
serv.listen(3)
conn_id = uuid.uuid4().hex
+ start = None
while True:
conn, addr = serv.accept()
+ if start is None:
+ start = time.time()
data = conn.recv(4096).strip()
if data:
log.info('Sending data back to the client: {uid}'.format(uid=conn_id))
else:
- log.info('Client disconnected: {timeout}seconds'.format(timeout=now))
+ log.info('Client disconnected: {timeout}seconds'.format(timeout=time.time() - start))
break
body = conn_id
resp = ('HTTP/1.1 200 OK\r\n'
@@ -85,7 +87,7 @@ class TestKeepAlive_Origin_Min_connections(helpers.EnvironmentCase):
resp = conn.recv(4096)
resp = resp.split('\r\n\r\n')[1]
log.info(resp)
- if first_resp == None:
+ if first_resp is None:
first_resp = resp
else:
second_resp = resp
@@ -99,4 +101,3 @@ class TestKeepAlive_Origin_Min_connections(helpers.EnvironmentCase):
conn.shutdown(socket.SHUT_RDWR)
conn.close()
self.assertEqual(first_resp, second_resp)
-