From 0753dd39231270150d61e051175dcdbd106836b5 Mon Sep 17 00:00:00 2001 From: Peter Portante Date: Mon, 2 Jun 2014 13:36:21 -0400 Subject: [PATCH] Handle func tests of swift cluster that hide /info If a swift cluster configures the proxy server to not accept /info requests, just do the best we can, skipping tests as necessary. To that end, if cors mode is not known we also skip the test. Change-Id: I34f296c8717e0baf24ae552a7e38f9354ee91974 --- test/functional/__init__.py | 8 +++++++- test/functional/test_object.py | 10 +++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/test/functional/__init__.py b/test/functional/__init__.py index fb9f42124c..c7f7711ad8 100644 --- a/test/functional/__init__.py +++ b/test/functional/__init__.py @@ -347,7 +347,13 @@ def get_cluster_info(): # test.conf data pass else: - eff_constraints.update(cluster_info.get('swift', {})) + try: + eff_constraints.update(cluster_info['swift']) + except KeyError: + # Most likely the swift cluster has "expose_info = false" set + # in its proxy-server.conf file, so we'll just do the best we + # can. + print >>sys.stderr, "** Swift Cluster not exposing /info **" # Finally, we'll allow any constraint present in the swift-constraints # section of test.conf to override everything. Note that only those diff --git a/test/functional/test_object.py b/test/functional/test_object.py index cbdca86e49..6b29800515 100755 --- a/test/functional/test_object.py +++ b/test/functional/test_object.py @@ -916,6 +916,11 @@ class TestObject(unittest.TestCase): if tf.skip: raise SkipTest + try: + strict_cors = tf.cluster_info['swift']['strict_cors_mode'] + except KeyError: + raise SkipTest("cors mode is unknown") + def put_cors_cont(url, token, parsed, conn, orig): conn.request( 'PUT', '%s/%s' % (parsed.path, self.container), @@ -989,11 +994,6 @@ class TestObject(unittest.TestCase): resp.read() self.assertEquals(resp.status, 401) - try: - strict_cors = tf.cluster_info['swift']['strict_cors_mode'] - except KeyError: - strict_cors = False - if strict_cors: resp = retry(check_cors, 'GET', 'cat', {'Origin': 'http://m.com'})