Remove Swift container-sync test skipping
The skipping reason was bug #1093743 that
is currently marked as invalid in Swift bugtracker.
This patch remove the skip and propose some
refactoring to the test code.
The test is marked as slow as it can take long
to run as it depends on container-sync process run
internal which is 300 seconds by default.
Change-Id: I939a014646b42cb2a461f874a5ad0edfc79c5561
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index f306d8e..727c6c3 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -529,11 +529,11 @@
# (string value)
#region=
-# Number of seconds to time on waiting for a containerto
+# Number of seconds to time on waiting for a container to
# container synchronization complete. (integer value)
#container_sync_timeout=120
-# Number of seconds to wait while looping to check thestatus
+# Number of seconds to wait while looping to check the status
# of a container to container synchronization (integer value)
#container_sync_interval=5
diff --git a/tempest/api/object_storage/test_container_sync.py b/tempest/api/object_storage/test_container_sync.py
index dcfe219..ec78774 100644
--- a/tempest/api/object_storage/test_container_sync.py
+++ b/tempest/api/object_storage/test_container_sync.py
@@ -16,25 +16,38 @@
# under the License.
import time
+import urlparse
from tempest.api.object_storage import base
from tempest.common.utils import data_utils
from tempest.test import attr
-from tempest.test import skip_because
+from tempest.test import HTTP_SUCCESS
+
+# This test can be quite long to run due to its
+# dependency on container-sync process running interval.
+# You can obviously reduce the container-sync interval in the
+# container-server configuration.
class ContainerSyncTest(base.BaseObjectTest):
+
@classmethod
def setUpClass(cls):
super(ContainerSyncTest, cls).setUpClass()
cls.containers = []
cls.objects = []
+
+ # Default container-server config only allows localhost
+ cls.local_ip = '127.0.0.1'
+
+ # Must be configure according to container-sync interval
container_sync_timeout = \
int(cls.config.object_storage.container_sync_timeout)
cls.container_sync_interval = \
int(cls.config.object_storage.container_sync_interval)
cls.attempts = \
int(container_sync_timeout / cls.container_sync_interval)
+
# define container and object clients
cls.clients = {}
cls.clients[data_utils.rand_name(name='TestContainerSync')] = \
@@ -51,8 +64,7 @@
cls.delete_containers(cls.containers, client[0], client[1])
super(ContainerSyncTest, cls).tearDownClass()
- @skip_because(bug="1093743")
- @attr(type='gate')
+ @attr(type='slow')
def test_container_synchronization(self):
# container to container synchronization
# to allow/accept sync requests to/from other accounts
@@ -62,51 +74,53 @@
cont_client = [self.clients[c][0] for c in cont]
obj_client = [self.clients[c][1] for c in cont]
# tell first container to synchronize to a second
+ client_proxy_ip = \
+ urlparse.urlparse(cont_client[1].base_url).netloc.split(':')[0]
+ client_base_url = \
+ cont_client[1].base_url.replace(client_proxy_ip,
+ self.local_ip)
headers = {'X-Container-Sync-Key': 'sync_key',
'X-Container-Sync-To': "%s/%s" %
- (cont_client[1].base_url, str(cont[1]))}
+ (client_base_url, str(cont[1]))}
resp, body = \
cont_client[0].put(str(cont[0]), body=None, headers=headers)
- self.assertIn(resp['status'], ('202', '201'),
- 'Error installing X-Container-Sync-To '
- 'for the container "%s"' % (cont[0]))
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
# create object in container
object_name = data_utils.rand_name(name='TestSyncObject')
data = object_name[::-1] # data_utils.arbitrary_string()
resp, _ = obj_client[0].create_object(cont[0], object_name, data)
- self.assertEqual(resp['status'], '201',
- 'Error creating the object "%s" in'
- 'the container "%s"'
- % (object_name, cont[0]))
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
self.objects.append(object_name)
# wait until container contents list is not empty
cont_client = [self.clients[c][0] for c in self.containers]
params = {'format': 'json'}
while self.attempts > 0:
- # get first container content
- resp, object_list_0 = \
- cont_client[0].\
- list_container_contents(self.containers[0], params=params)
- self.assertEqual(resp['status'], '200',
- 'Error listing the destination container`s'
- ' "%s" contents' % (self.containers[0]))
- object_list_0 = dict((obj['name'], obj) for obj in object_list_0)
- # get second container content
- resp, object_list_1 = \
- cont_client[1].\
- list_container_contents(self.containers[1], params=params)
- self.assertEqual(resp['status'], '200',
- 'Error listing the destination container`s'
- ' "%s" contents' % (self.containers[1]))
- object_list_1 = dict((obj['name'], obj) for obj in object_list_1)
+ object_lists = []
+ for client_index in (0, 1):
+ resp, object_list = \
+ cont_client[client_index].\
+ list_container_contents(self.containers[client_index],
+ params=params)
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ object_lists.append(dict(
+ (obj['name'], obj) for obj in object_list))
# check that containers are not empty and have equal keys()
# or wait for next attempt
- if not object_list_0 or not object_list_1 or \
- set(object_list_0.keys()) != set(object_list_1.keys()):
+ if not object_lists[0] or not object_lists[1] or \
+ set(object_lists[0].keys()) != set(object_lists[1].keys()):
time.sleep(self.container_sync_interval)
self.attempts -= 1
else:
break
- self.assertEqual(object_list_0, object_list_1,
+
+ self.assertEqual(object_lists[0], object_lists[1],
'Different object lists in containers.')
+
+ # Verify object content
+ obj_clients = [(self.clients[c][1], c) for c in self.containers]
+ for obj_client, cont in obj_clients:
+ for obj_name in object_lists[0]:
+ resp, object_content = obj_client.get_object(cont, obj_name)
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertEqual(object_content, obj_name[::-1])
diff --git a/tempest/config.py b/tempest/config.py
index d42edc9..3bec70f 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -398,11 +398,11 @@
"one is used."),
cfg.IntOpt('container_sync_timeout',
default=120,
- help="Number of seconds to time on waiting for a container"
+ help="Number of seconds to time on waiting for a container "
"to container synchronization complete."),
cfg.IntOpt('container_sync_interval',
default=5,
- help="Number of seconds to wait while looping to check the"
+ help="Number of seconds to wait while looping to check the "
"status of a container to container synchronization"),
cfg.StrOpt('operator_role',
default='Member',