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/03/24 01:10:26 UTC

trafficserver git commit: Add some initial teests for hostdb

Repository: trafficserver
Updated Branches:
  refs/heads/master bc6acc0b8 -> ee87aecbd


Add some initial teests for hostdb


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/ee87aecb
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/ee87aecb
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/ee87aecb

Branch: refs/heads/master
Commit: ee87aecbd08abaac4b5fa7b50ac120fdf17553c2
Parents: bc6acc0
Author: Thomas Jackson <ja...@apache.org>
Authored: Mon Mar 23 17:09:04 2015 -0700
Committer: Thomas Jackson <ja...@apache.org>
Committed: Mon Mar 23 17:09:04 2015 -0700

----------------------------------------------------------------------
 ci/new_tsqa/tests/test_hostdb.py | 58 +++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ee87aecb/ci/new_tsqa/tests/test_hostdb.py
----------------------------------------------------------------------
diff --git a/ci/new_tsqa/tests/test_hostdb.py b/ci/new_tsqa/tests/test_hostdb.py
new file mode 100644
index 0000000..31b3705
--- /dev/null
+++ b/ci/new_tsqa/tests/test_hostdb.py
@@ -0,0 +1,58 @@
+'''
+Test hostdb
+'''
+
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+import os
+import requests
+import time
+
+import helpers
+
+import tsqa.test_cases
+
+
+class TestHostDBFailedDNS(tsqa.test_cases.DynamicHTTPEndpointCase, helpers.EnvironmentCase):
+    '''
+    Tests for how hostdb handles when there is no reachable resolver
+    '''
+    @classmethod
+    def setUpEnv(cls, env):
+        cls.configs['remap.config'].add_line('map / http://some_nonexistant_domain:{0}/'.format(cls.http_endpoint.address[1]))
+
+        resolv_conf_path = os.path.join(env.layout.prefix, 'resolv.conf')
+
+        cls.configs['records.config']['CONFIG'].update({
+            'proxy.config.http.response_server_enabled': 2,  # only add server headers when there weren't any
+            'proxy.config.hostdb.lookup_timeout': 1,
+            'proxy.config.dns.resolv_conf': resolv_conf_path,
+
+        })
+
+        with open(resolv_conf_path, 'w') as fh:
+            fh.write('nameserver 1.1.1.1\n')  # some non-existant nameserver
+
+    def test_lookup_timeout(self):
+        start = time.time()
+        ret = requests.get(self.endpoint_url('/test'),
+                           proxies=self.proxies,
+                           )
+        self.assertGreater(time.time() - start, self.configs['records.config']['CONFIG']['proxy.config.hostdb.lookup_timeout'])
+        self.assertEqual(ret.status_code, 502)
+        self.assertIn('ATS', ret.headers['server'])
+