Make probe tests tolerate deprecated policies
A deprecated policy in swift.conf causes errors in probe tests that may attempt to use that policy. This patch introduces a list ENABLED_POLICIES in test/probe/common.py and changes probe tests to only use policies contained in that list. Change-Id: Ie65477c15d631fcfc3a4a5772fbe6d7d171b22b0
This commit is contained in:
@@ -26,6 +26,8 @@ from swift.common.http import HTTP_NOT_FOUND
|
|||||||
|
|
||||||
from swiftclient import client, get_auth, ClientException
|
from swiftclient import client, get_auth, ClientException
|
||||||
|
|
||||||
|
from test.probe.common import ENABLED_POLICIES
|
||||||
|
|
||||||
TIMEOUT = 60
|
TIMEOUT = 60
|
||||||
|
|
||||||
|
|
||||||
@@ -73,7 +75,7 @@ class BrainSplitter(object):
|
|||||||
self.object_name = object_name
|
self.object_name = object_name
|
||||||
server_list = ['%s-server' % server_type] if server_type else ['all']
|
server_list = ['%s-server' % server_type] if server_type else ['all']
|
||||||
self.servers = Manager(server_list)
|
self.servers = Manager(server_list)
|
||||||
policies = list(POLICIES)
|
policies = list(ENABLED_POLICIES)
|
||||||
random.shuffle(policies)
|
random.shuffle(policies)
|
||||||
self.policies = itertools.cycle(policies)
|
self.policies = itertools.cycle(policies)
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ from swift.common.storage_policy import POLICIES
|
|||||||
from test.probe import CHECK_SERVER_TIMEOUT, VALIDATE_RSYNC
|
from test.probe import CHECK_SERVER_TIMEOUT, VALIDATE_RSYNC
|
||||||
|
|
||||||
|
|
||||||
|
ENABLED_POLICIES = [p for p in POLICIES if not p.is_deprecated]
|
||||||
|
|
||||||
|
|
||||||
def get_server_number(port, port2server):
|
def get_server_number(port, port2server):
|
||||||
server_number = port2server[port]
|
server_number = port2server[port]
|
||||||
server, number = server_number[:-1], server_number[-1:]
|
server, number = server_number[:-1], server_number[-1:]
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ from swift.common.manager import Manager
|
|||||||
from swift.common.direct_client import direct_delete_account, \
|
from swift.common.direct_client import direct_delete_account, \
|
||||||
direct_get_object, direct_head_container, ClientException
|
direct_get_object, direct_head_container, ClientException
|
||||||
from test.probe.common import kill_servers, reset_environment, \
|
from test.probe.common import kill_servers, reset_environment, \
|
||||||
get_to_final_state
|
get_to_final_state, ENABLED_POLICIES
|
||||||
|
|
||||||
|
|
||||||
class TestAccountReaper(unittest.TestCase):
|
class TestAccountReaper(unittest.TestCase):
|
||||||
@@ -38,7 +38,7 @@ class TestAccountReaper(unittest.TestCase):
|
|||||||
def test_sync(self):
|
def test_sync(self):
|
||||||
all_objects = []
|
all_objects = []
|
||||||
# upload some containers
|
# upload some containers
|
||||||
for policy in POLICIES:
|
for policy in ENABLED_POLICIES:
|
||||||
container = 'container-%s-%s' % (policy.name, uuid.uuid4())
|
container = 'container-%s-%s' % (policy.name, uuid.uuid4())
|
||||||
client.put_container(self.url, self.token, container,
|
client.put_container(self.url, self.token, container,
|
||||||
headers={'X-Storage-Policy': policy.name})
|
headers={'X-Storage-Policy': policy.name})
|
||||||
@@ -52,11 +52,11 @@ class TestAccountReaper(unittest.TestCase):
|
|||||||
headers = client.head_account(self.url, self.token)
|
headers = client.head_account(self.url, self.token)
|
||||||
|
|
||||||
self.assertEqual(int(headers['x-account-container-count']),
|
self.assertEqual(int(headers['x-account-container-count']),
|
||||||
len(POLICIES))
|
len(ENABLED_POLICIES))
|
||||||
self.assertEqual(int(headers['x-account-object-count']),
|
self.assertEqual(int(headers['x-account-object-count']),
|
||||||
len(POLICIES))
|
len(ENABLED_POLICIES))
|
||||||
self.assertEqual(int(headers['x-account-bytes-used']),
|
self.assertEqual(int(headers['x-account-bytes-used']),
|
||||||
len(POLICIES) * len(body))
|
len(ENABLED_POLICIES) * len(body))
|
||||||
|
|
||||||
part, nodes = self.account_ring.get_nodes(self.account)
|
part, nodes = self.account_ring.get_nodes(self.account)
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ from swift.common import utils, direct_client
|
|||||||
from swift.common.storage_policy import POLICIES
|
from swift.common.storage_policy import POLICIES
|
||||||
from swift.common.http import HTTP_NOT_FOUND
|
from swift.common.http import HTTP_NOT_FOUND
|
||||||
from test.probe.brain import BrainSplitter
|
from test.probe.brain import BrainSplitter
|
||||||
from test.probe.common import reset_environment, get_to_final_state
|
from test.probe.common import reset_environment, get_to_final_state, \
|
||||||
|
ENABLED_POLICIES
|
||||||
|
|
||||||
from swiftclient import client, ClientException
|
from swiftclient import client, ClientException
|
||||||
|
|
||||||
@@ -36,7 +37,7 @@ TIMEOUT = 60
|
|||||||
class TestContainerMergePolicyIndex(unittest.TestCase):
|
class TestContainerMergePolicyIndex(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
if len(POLICIES) < 2:
|
if len(ENABLED_POLICIES) < 2:
|
||||||
raise SkipTest()
|
raise SkipTest()
|
||||||
(self.pids, self.port2server, self.account_ring, self.container_ring,
|
(self.pids, self.port2server, self.account_ring, self.container_ring,
|
||||||
self.object_ring, self.policy, self.url, self.token,
|
self.object_ring, self.policy, self.url, self.token,
|
||||||
@@ -252,7 +253,7 @@ class TestContainerMergePolicyIndex(unittest.TestCase):
|
|||||||
|
|
||||||
# get an old container stashed
|
# get an old container stashed
|
||||||
self.brain.stop_primary_half()
|
self.brain.stop_primary_half()
|
||||||
policy = random.choice(list(POLICIES))
|
policy = random.choice(ENABLED_POLICIES)
|
||||||
self.brain.put_container(policy.idx)
|
self.brain.put_container(policy.idx)
|
||||||
self.brain.start_primary_half()
|
self.brain.start_primary_half()
|
||||||
# write some parts
|
# write some parts
|
||||||
@@ -260,7 +261,8 @@ class TestContainerMergePolicyIndex(unittest.TestCase):
|
|||||||
write_part(i)
|
write_part(i)
|
||||||
|
|
||||||
self.brain.stop_handoff_half()
|
self.brain.stop_handoff_half()
|
||||||
wrong_policy = random.choice([p for p in POLICIES if p is not policy])
|
wrong_policy = random.choice([p for p in ENABLED_POLICIES
|
||||||
|
if p is not policy])
|
||||||
self.brain.put_container(wrong_policy.idx)
|
self.brain.put_container(wrong_policy.idx)
|
||||||
# write some more parts
|
# write some more parts
|
||||||
for i in range(10, 20):
|
for i in range(10, 20):
|
||||||
@@ -347,8 +349,9 @@ class TestContainerMergePolicyIndex(unittest.TestCase):
|
|||||||
|
|
||||||
def test_reconciler_move_object_twice(self):
|
def test_reconciler_move_object_twice(self):
|
||||||
# select some policies
|
# select some policies
|
||||||
old_policy = random.choice(list(POLICIES))
|
old_policy = random.choice(ENABLED_POLICIES)
|
||||||
new_policy = random.choice([p for p in POLICIES if p != old_policy])
|
new_policy = random.choice([p for p in ENABLED_POLICIES
|
||||||
|
if p != old_policy])
|
||||||
|
|
||||||
# setup a split brain
|
# setup a split brain
|
||||||
self.brain.stop_handoff_half()
|
self.brain.stop_handoff_half()
|
||||||
|
|||||||
@@ -20,9 +20,8 @@ from nose import SkipTest
|
|||||||
|
|
||||||
from swiftclient import client
|
from swiftclient import client
|
||||||
|
|
||||||
from swift.common.storage_policy import POLICIES
|
|
||||||
from swift.common.manager import Manager
|
from swift.common.manager import Manager
|
||||||
from test.probe.common import kill_servers, reset_environment
|
from test.probe.common import kill_servers, reset_environment, ENABLED_POLICIES
|
||||||
|
|
||||||
|
|
||||||
def get_current_realm_cluster(url):
|
def get_current_realm_cluster(url):
|
||||||
@@ -62,8 +61,8 @@ class TestContainerSync(unittest.TestCase):
|
|||||||
dest_container = 'dest-container-%s' % uuid.uuid4()
|
dest_container = 'dest-container-%s' % uuid.uuid4()
|
||||||
dest_headers = base_headers.copy()
|
dest_headers = base_headers.copy()
|
||||||
dest_policy = None
|
dest_policy = None
|
||||||
if len(POLICIES) > 1:
|
if len(ENABLED_POLICIES) > 1:
|
||||||
dest_policy = random.choice(list(POLICIES))
|
dest_policy = random.choice(ENABLED_POLICIES)
|
||||||
dest_headers['X-Storage-Policy'] = dest_policy.name
|
dest_headers['X-Storage-Policy'] = dest_policy.name
|
||||||
client.put_container(self.url, self.token, dest_container,
|
client.put_container(self.url, self.token, dest_container,
|
||||||
headers=dest_headers)
|
headers=dest_headers)
|
||||||
@@ -75,7 +74,7 @@ class TestContainerSync(unittest.TestCase):
|
|||||||
dest_container)
|
dest_container)
|
||||||
source_headers['X-Container-Sync-To'] = sync_to
|
source_headers['X-Container-Sync-To'] = sync_to
|
||||||
if dest_policy:
|
if dest_policy:
|
||||||
source_policy = random.choice([p for p in POLICIES
|
source_policy = random.choice([p for p in ENABLED_POLICIES
|
||||||
if p is not dest_policy])
|
if p is not dest_policy])
|
||||||
source_headers['X-Storage-Policy'] = source_policy.name
|
source_headers['X-Storage-Policy'] = source_policy.name
|
||||||
client.put_container(self.url, self.token, source_container,
|
client.put_container(self.url, self.token, source_container,
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ from nose import SkipTest
|
|||||||
|
|
||||||
from swift.common.internal_client import InternalClient
|
from swift.common.internal_client import InternalClient
|
||||||
from swift.common.manager import Manager
|
from swift.common.manager import Manager
|
||||||
from swift.common.storage_policy import POLICIES
|
|
||||||
from swift.common.utils import Timestamp
|
from swift.common.utils import Timestamp
|
||||||
|
|
||||||
from test.probe.common import reset_environment, get_to_final_state
|
from test.probe.common import reset_environment, get_to_final_state, \
|
||||||
|
ENABLED_POLICIES
|
||||||
from test.probe.test_container_merge_policy_index import BrainSplitter
|
from test.probe.test_container_merge_policy_index import BrainSplitter
|
||||||
|
|
||||||
from swiftclient import client
|
from swiftclient import client
|
||||||
@@ -32,7 +32,7 @@ from swiftclient import client
|
|||||||
class TestObjectExpirer(unittest.TestCase):
|
class TestObjectExpirer(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
if len(POLICIES) < 2:
|
if len(ENABLED_POLICIES) < 2:
|
||||||
raise SkipTest('Need more than one policy')
|
raise SkipTest('Need more than one policy')
|
||||||
|
|
||||||
self.expirer = Manager(['object-expirer'])
|
self.expirer = Manager(['object-expirer'])
|
||||||
@@ -56,8 +56,9 @@ class TestObjectExpirer(unittest.TestCase):
|
|||||||
self.object_name)
|
self.object_name)
|
||||||
|
|
||||||
def test_expirer_object_split_brain(self):
|
def test_expirer_object_split_brain(self):
|
||||||
old_policy = random.choice(list(POLICIES))
|
old_policy = random.choice(ENABLED_POLICIES)
|
||||||
wrong_policy = random.choice([p for p in POLICIES if p != old_policy])
|
wrong_policy = random.choice([p for p in ENABLED_POLICIES
|
||||||
|
if p != old_policy])
|
||||||
# create an expiring object and a container with the wrong policy
|
# create an expiring object and a container with the wrong policy
|
||||||
self.brain.stop_primary_half()
|
self.brain.stop_primary_half()
|
||||||
self.brain.put_container(int(old_policy))
|
self.brain.put_container(int(old_policy))
|
||||||
@@ -114,7 +115,7 @@ class TestObjectExpirer(unittest.TestCase):
|
|||||||
|
|
||||||
# and validate object is tombstoned
|
# and validate object is tombstoned
|
||||||
found_in_policy = None
|
found_in_policy = None
|
||||||
for policy in POLICIES:
|
for policy in ENABLED_POLICIES:
|
||||||
metadata = self.client.get_object_metadata(
|
metadata = self.client.get_object_metadata(
|
||||||
self.account, self.container_name, self.object_name,
|
self.account, self.container_name, self.object_name,
|
||||||
acceptable_statuses=(4,),
|
acceptable_statuses=(4,),
|
||||||
|
|||||||
Reference in New Issue
Block a user