]> git-server-git.apps.pok.os.sepia.ceph.com Git - s3-tests.git/commitdiff
Add support for default_region
authorJoe Buck <jbbuck@gmail.com>
Wed, 21 Aug 2013 22:47:04 +0000 (15:47 -0700)
committerJoe Buck <jbbuck@gmail.com>
Wed, 28 Aug 2013 15:56:26 +0000 (08:56 -0700)
Changes to actually use the
'default_region' setting in the
S3TEST_CONF file.
Previously, the first connection set
was assumed to be the default.
This means that the parse order
of the S3TEST_CONF file was dictating
how the tests behaved, resulting in
failures in some cases.

Signed-off-by: Joe Buck <jbbuck@gmail.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
s3tests/functional/__init__.py

index a69a1757a5f09c0cb4c9db4fc4ac8ede8b1fe4ac..ce609a89f44591ee493cfcb14075129903c37650 100644 (file)
@@ -182,6 +182,9 @@ class RegionsConn:
     def iteritems(self):
         return self.m.iteritems()
 
+    def set_default(self, conn):
+        self.default = conn
+
     def add(self, name, conn):
         self.m[name] = conn
         if not self.default:
@@ -217,6 +220,12 @@ def setup():
         template = 'test-{random}-'
     prefix = choose_bucket_prefix(template=template)
 
+    # pull the default_region out, if it exists
+    try:
+        default_region = cfg.get('fixtures', 'default_region')
+    except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
+        default_region = None
+
     s3.clear()
     config.clear()
 
@@ -263,7 +272,18 @@ def setup():
                 # TODO test vhost calling format
                 calling_format=conf.calling_format,
                 )
-            targets[name].add(k, TargetConnection(conf, conn))
+
+            temp_targetConn = TargetConnection(conf, conn)
+            targets[name].add(k, temp_targetConn)
+
+            # Explicitly test for and set the default region, if specified.
+            # If it was not specified, use the 'is_master' flag to set it.
+            if default_region:
+                if default_region == name:
+                    targets[name].set_default(temp_targetConn)
+            elif conf.is_master:
+                targets[name].set_default(temp_targetConn)
+
         s3[name] = targets[name].default.connection
 
     # WARNING! we actively delete all buckets we see with the prefix