refactor probe tests
* refactor probe tests to use probe.common.ProbeTest * move reset_environment functionality to ProbeTest.setUp() * choose rings and policies that meet the criteria - raise SkipTest if nothing matches * replace all AssertionErrors in setup with SkipTest Change-Id: Id56c497d58083f5fd55f5283cdd346840df039d3
This commit is contained in:
parent
ca90be414e
commit
2c1b5af062
@ -19,6 +19,7 @@ from subprocess import Popen, PIPE
|
|||||||
import sys
|
import sys
|
||||||
from time import sleep, time
|
from time import sleep, time
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
import unittest
|
||||||
from nose import SkipTest
|
from nose import SkipTest
|
||||||
|
|
||||||
from swiftclient import get_auth, head_account
|
from swiftclient import get_auth, head_account
|
||||||
@ -141,18 +142,20 @@ def kill_nonprimary_server(primary_nodes, port2server, pids):
|
|||||||
return port
|
return port
|
||||||
|
|
||||||
|
|
||||||
def get_ring(ring_name, server=None, force_validate=None):
|
def get_ring(ring_name, required_replicas, required_devices,
|
||||||
|
server=None, force_validate=None):
|
||||||
if not server:
|
if not server:
|
||||||
server = ring_name
|
server = ring_name
|
||||||
ring = Ring('/etc/swift', ring_name=ring_name)
|
ring = Ring('/etc/swift', ring_name=ring_name)
|
||||||
if not VALIDATE_RSYNC and not force_validate:
|
if not VALIDATE_RSYNC and not force_validate:
|
||||||
return ring
|
return ring
|
||||||
# easy sanity checks
|
# easy sanity checks
|
||||||
if ring.replica_count != 3:
|
if ring.replica_count != required_replicas:
|
||||||
print 'WARNING: %s has %s replicas instead of 3' % (
|
raise SkipTest('%s has %s replicas instead of %s' % (
|
||||||
ring.serialized_path, ring.replica_count)
|
ring.serialized_path, ring.replica_count, required_replicas))
|
||||||
assert 4 == len(ring.devs), '%s has %s devices instead of 4' % (
|
if len(ring.devs) != required_devices:
|
||||||
ring.serialized_path, len(ring.devs))
|
raise SkipTest('%s has %s devices instead of %s' % (
|
||||||
|
ring.serialized_path, len(ring.devs), required_devices))
|
||||||
# map server to config by port
|
# map server to config by port
|
||||||
port_to_config = {}
|
port_to_config = {}
|
||||||
for server_ in Manager([server]):
|
for server_ in Manager([server]):
|
||||||
@ -167,12 +170,13 @@ def get_ring(ring_name, server=None, force_validate=None):
|
|||||||
if device == dev['device']:
|
if device == dev['device']:
|
||||||
dev_path = os.path.join(conf['devices'], device)
|
dev_path = os.path.join(conf['devices'], device)
|
||||||
full_path = os.path.realpath(dev_path)
|
full_path = os.path.realpath(dev_path)
|
||||||
assert os.path.exists(full_path), \
|
if not os.path.exists(full_path):
|
||||||
'device %s in %s was not found (%s)' % (
|
raise SkipTest(
|
||||||
device, conf['devices'], full_path)
|
'device %s in %s was not found (%s)' %
|
||||||
|
(device, conf['devices'], full_path))
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise AssertionError(
|
raise SkipTest(
|
||||||
"unable to find ring device %s under %s's devices (%s)" % (
|
"unable to find ring device %s under %s's devices (%s)" % (
|
||||||
dev['device'], server, conf['devices']))
|
dev['device'], server, conf['devices']))
|
||||||
# verify server is exposing rsync device
|
# verify server is exposing rsync device
|
||||||
@ -184,57 +188,33 @@ def get_ring(ring_name, server=None, force_validate=None):
|
|||||||
p = Popen(cmd, shell=True, stdout=PIPE)
|
p = Popen(cmd, shell=True, stdout=PIPE)
|
||||||
stdout, _stderr = p.communicate()
|
stdout, _stderr = p.communicate()
|
||||||
if p.returncode:
|
if p.returncode:
|
||||||
raise AssertionError('unable to connect to rsync '
|
raise SkipTest('unable to connect to rsync '
|
||||||
'export %s (%s)' % (rsync_export, cmd))
|
'export %s (%s)' % (rsync_export, cmd))
|
||||||
for line in stdout.splitlines():
|
for line in stdout.splitlines():
|
||||||
if line.rsplit(None, 1)[-1] == dev['device']:
|
if line.rsplit(None, 1)[-1] == dev['device']:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise AssertionError("unable to find ring device %s under rsync's "
|
raise SkipTest("unable to find ring device %s under rsync's "
|
||||||
"exported devices for %s (%s)" % (
|
"exported devices for %s (%s)" %
|
||||||
dev['device'], rsync_export, cmd))
|
(dev['device'], rsync_export, cmd))
|
||||||
return ring
|
return ring
|
||||||
|
|
||||||
|
|
||||||
def reset_environment():
|
def get_policy(**kwargs):
|
||||||
p = Popen("resetswift 2>&1", shell=True, stdout=PIPE)
|
kwargs.setdefault('is_deprecated', False)
|
||||||
stdout, _stderr = p.communicate()
|
# go thru the policies and make sure they match the requirements of kwargs
|
||||||
print stdout
|
for policy in POLICIES:
|
||||||
Manager(['all']).stop()
|
# TODO: for EC, pop policy type here and check it first
|
||||||
pids = {}
|
matches = True
|
||||||
|
for key, value in kwargs.items():
|
||||||
try:
|
try:
|
||||||
account_ring = get_ring('account')
|
if getattr(policy, key) != value:
|
||||||
container_ring = get_ring('container')
|
matches = False
|
||||||
policy = POLICIES.default
|
except AttributeError:
|
||||||
object_ring = get_ring(policy.ring_name, 'object')
|
matches = False
|
||||||
Manager(['main']).start(wait=False)
|
if matches:
|
||||||
port2server = {}
|
return policy
|
||||||
for server, port in [('account', 6002), ('container', 6001),
|
raise SkipTest('No policy matching %s' % kwargs)
|
||||||
('object', 6000)]:
|
|
||||||
for number in xrange(1, 9):
|
|
||||||
port2server[port + (number * 10)] = '%s%d' % (server, number)
|
|
||||||
for port in port2server:
|
|
||||||
check_server(port, port2server, pids)
|
|
||||||
port2server[8080] = 'proxy'
|
|
||||||
url, token, account = check_server(8080, port2server, pids)
|
|
||||||
config_dict = defaultdict(dict)
|
|
||||||
for name in ('account', 'container', 'object'):
|
|
||||||
for server_name in (name, '%s-replicator' % name):
|
|
||||||
for server in Manager([server_name]):
|
|
||||||
for i, conf in enumerate(server.conf_files(), 1):
|
|
||||||
config_dict[server.server][i] = conf
|
|
||||||
except BaseException:
|
|
||||||
try:
|
|
||||||
raise
|
|
||||||
except AssertionError as e:
|
|
||||||
raise SkipTest(e)
|
|
||||||
finally:
|
|
||||||
try:
|
|
||||||
kill_servers(port2server, pids)
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
return pids, port2server, account_ring, container_ring, object_ring, \
|
|
||||||
policy, url, token, account, config_dict
|
|
||||||
|
|
||||||
|
|
||||||
def get_to_final_state():
|
def get_to_final_state():
|
||||||
@ -249,16 +229,84 @@ def get_to_final_state():
|
|||||||
replicators.once()
|
replicators.once()
|
||||||
|
|
||||||
|
|
||||||
|
class ProbeTest(unittest.TestCase):
|
||||||
|
"""
|
||||||
|
Don't instantiate this directly, use a child class instead.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
p = Popen("resetswift 2>&1", shell=True, stdout=PIPE)
|
||||||
|
stdout, _stderr = p.communicate()
|
||||||
|
print stdout
|
||||||
|
Manager(['all']).stop()
|
||||||
|
self.pids = {}
|
||||||
|
try:
|
||||||
|
self.account_ring = get_ring(
|
||||||
|
'account',
|
||||||
|
self.acct_cont_required_replicas,
|
||||||
|
self.acct_cont_required_devices)
|
||||||
|
self.container_ring = get_ring(
|
||||||
|
'container',
|
||||||
|
self.acct_cont_required_replicas,
|
||||||
|
self.acct_cont_required_devices)
|
||||||
|
self.policy = get_policy(**self.policy_requirements)
|
||||||
|
self.object_ring = get_ring(
|
||||||
|
self.policy.ring_name,
|
||||||
|
self.obj_required_replicas,
|
||||||
|
self.obj_required_devices,
|
||||||
|
server='object')
|
||||||
|
Manager(['main']).start(wait=False)
|
||||||
|
self.port2server = {}
|
||||||
|
for server, port in [('account', 6002), ('container', 6001),
|
||||||
|
('object', 6000)]:
|
||||||
|
for number in xrange(1, 9):
|
||||||
|
self.port2server[port + (number * 10)] = \
|
||||||
|
'%s%d' % (server, number)
|
||||||
|
for port in self.port2server:
|
||||||
|
check_server(port, self.port2server, self.pids)
|
||||||
|
self.port2server[8080] = 'proxy'
|
||||||
|
self.url, self.token, self.account = \
|
||||||
|
check_server(8080, self.port2server, self.pids)
|
||||||
|
self.configs = defaultdict(dict)
|
||||||
|
for name in ('account', 'container', 'object'):
|
||||||
|
for server_name in (name, '%s-replicator' % name):
|
||||||
|
for server in Manager([server_name]):
|
||||||
|
for i, conf in enumerate(server.conf_files(), 1):
|
||||||
|
self.configs[server.server][i] = conf
|
||||||
|
except BaseException:
|
||||||
|
try:
|
||||||
|
raise
|
||||||
|
finally:
|
||||||
|
try:
|
||||||
|
kill_servers(self.port2server, self.pids)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
kill_servers(self.port2server, self.pids)
|
||||||
|
|
||||||
|
|
||||||
|
class ReplProbeTest(ProbeTest):
|
||||||
|
|
||||||
|
acct_cont_required_replicas = 3
|
||||||
|
acct_cont_required_devices = 4
|
||||||
|
obj_required_replicas = 3
|
||||||
|
obj_required_devices = 4
|
||||||
|
policy_requirements = {'is_default': True}
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
for server in ('account', 'container'):
|
for server in ('account', 'container'):
|
||||||
try:
|
try:
|
||||||
get_ring(server, force_validate=True)
|
get_ring(server, 3, 4,
|
||||||
except AssertionError as err:
|
force_validate=True)
|
||||||
|
except SkipTest as err:
|
||||||
sys.exit('%s ERROR: %s' % (server, err))
|
sys.exit('%s ERROR: %s' % (server, err))
|
||||||
print '%s OK' % server
|
print '%s OK' % server
|
||||||
for policy in POLICIES:
|
for policy in POLICIES:
|
||||||
try:
|
try:
|
||||||
get_ring(policy.ring_name, server='object', force_validate=True)
|
get_ring(policy.ring_name, 3, 4,
|
||||||
except AssertionError as err:
|
server='object', force_validate=True)
|
||||||
|
except SkipTest as err:
|
||||||
sys.exit('object ERROR (%s): %s' % (policy.name, err))
|
sys.exit('object ERROR (%s): %s' % (policy.name, err))
|
||||||
print 'object OK (%s)' % policy.name
|
print 'object OK (%s)' % policy.name
|
||||||
|
@ -14,25 +14,17 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from unittest import main, TestCase
|
from unittest import main
|
||||||
|
|
||||||
from swiftclient import client
|
from swiftclient import client
|
||||||
|
|
||||||
from swift.common import direct_client
|
from swift.common import direct_client
|
||||||
from swift.common.manager import Manager
|
from swift.common.manager import Manager
|
||||||
from test.probe.common import get_to_final_state, kill_nonprimary_server, \
|
from test.probe.common import get_to_final_state, kill_nonprimary_server, \
|
||||||
kill_server, kill_servers, reset_environment, start_server
|
kill_server, ReplProbeTest, start_server
|
||||||
|
|
||||||
|
|
||||||
class TestAccountFailures(TestCase):
|
class TestAccountFailures(ReplProbeTest):
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
(self.pids, self.port2server, self.account_ring, self.container_ring,
|
|
||||||
self.object_ring, self.policy, self.url, self.token,
|
|
||||||
self.account, self.configs) = reset_environment()
|
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
kill_servers(self.port2server, self.pids)
|
|
||||||
|
|
||||||
def test_main(self):
|
def test_main(self):
|
||||||
# Create container1 and container2
|
# Create container1 and container2
|
||||||
|
@ -19,22 +19,17 @@ import re
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from swiftclient import get_auth
|
from swiftclient import get_auth
|
||||||
from test.probe.common import kill_servers, reset_environment
|
from test.probe.common import ReplProbeTest
|
||||||
from urlparse import urlparse
|
from urlparse import urlparse
|
||||||
|
|
||||||
|
|
||||||
class TestAccountGetFakeResponsesMatch(unittest.TestCase):
|
class TestAccountGetFakeResponsesMatch(ReplProbeTest):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
(self.pids, self.port2server, self.account_ring, self.container_ring,
|
super(TestAccountGetFakeResponsesMatch, self).setUp()
|
||||||
self.object_ring, self.policy, self.url, self.token,
|
|
||||||
self.account, self.configs) = reset_environment()
|
|
||||||
self.url, self.token = get_auth(
|
self.url, self.token = get_auth(
|
||||||
'http://127.0.0.1:8080/auth/v1.0', 'admin:admin', 'admin')
|
'http://127.0.0.1:8080/auth/v1.0', 'admin:admin', 'admin')
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
kill_servers(self.port2server, self.pids)
|
|
||||||
|
|
||||||
def _account_path(self, account):
|
def _account_path(self, account):
|
||||||
_, _, path, _, _, _ = urlparse(self.url)
|
_, _, path, _, _, _ = urlparse(self.url)
|
||||||
|
|
||||||
|
@ -12,8 +12,8 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import unittest
|
|
||||||
import uuid
|
import uuid
|
||||||
|
import unittest
|
||||||
|
|
||||||
from swiftclient import client
|
from swiftclient import client
|
||||||
|
|
||||||
@ -21,19 +21,11 @@ from swift.common.storage_policy import POLICIES
|
|||||||
from swift.common.manager import Manager
|
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 ReplProbeTest, \
|
||||||
get_to_final_state, ENABLED_POLICIES
|
get_to_final_state, ENABLED_POLICIES
|
||||||
|
|
||||||
|
|
||||||
class TestAccountReaper(unittest.TestCase):
|
class TestAccountReaper(ReplProbeTest):
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
(self.pids, self.port2server, self.account_ring, self.container_ring,
|
|
||||||
self.object_ring, self.policy, self.url, self.token,
|
|
||||||
self.account, self.configs) = reset_environment()
|
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
kill_servers(self.port2server, self.pids)
|
|
||||||
|
|
||||||
def test_sync(self):
|
def test_sync(self):
|
||||||
all_objects = []
|
all_objects = []
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
from os import listdir
|
from os import listdir
|
||||||
from os.path import join as path_join
|
from os.path import join as path_join
|
||||||
from unittest import main, TestCase
|
from unittest import main
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
from eventlet import GreenPool, Timeout
|
from eventlet import GreenPool, Timeout
|
||||||
@ -28,7 +28,7 @@ from swift.common import direct_client
|
|||||||
from swift.common.exceptions import ClientException
|
from swift.common.exceptions import ClientException
|
||||||
from swift.common.utils import hash_path, readconf
|
from swift.common.utils import hash_path, readconf
|
||||||
from test.probe.common import get_to_final_state, kill_nonprimary_server, \
|
from test.probe.common import get_to_final_state, kill_nonprimary_server, \
|
||||||
kill_server, kill_servers, reset_environment, start_server
|
kill_server, ReplProbeTest, start_server
|
||||||
|
|
||||||
eventlet.monkey_patch(all=False, socket=True)
|
eventlet.monkey_patch(all=False, socket=True)
|
||||||
|
|
||||||
@ -40,15 +40,7 @@ def get_db_file_path(obj_dir):
|
|||||||
return path_join(obj_dir, filename)
|
return path_join(obj_dir, filename)
|
||||||
|
|
||||||
|
|
||||||
class TestContainerFailures(TestCase):
|
class TestContainerFailures(ReplProbeTest):
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
(self.pids, self.port2server, self.account_ring, self.container_ring,
|
|
||||||
self.object_ring, self.policy, self.url, self.token,
|
|
||||||
self.account, self.configs) = reset_environment()
|
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
kill_servers(self.port2server, self.pids)
|
|
||||||
|
|
||||||
def test_one_node_fails(self):
|
def test_one_node_fails(self):
|
||||||
# Create container1
|
# Create container1
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
|
|
||||||
from hashlib import md5
|
from hashlib import md5
|
||||||
import time
|
import time
|
||||||
import unittest
|
|
||||||
import uuid
|
import uuid
|
||||||
import random
|
import random
|
||||||
|
import unittest
|
||||||
|
|
||||||
from nose import SkipTest
|
from nose import SkipTest
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ 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 ReplProbeTest, get_to_final_state, \
|
||||||
ENABLED_POLICIES
|
ENABLED_POLICIES
|
||||||
|
|
||||||
from swiftclient import client, ClientException
|
from swiftclient import client, ClientException
|
||||||
@ -34,14 +34,12 @@ from swiftclient import client, ClientException
|
|||||||
TIMEOUT = 60
|
TIMEOUT = 60
|
||||||
|
|
||||||
|
|
||||||
class TestContainerMergePolicyIndex(unittest.TestCase):
|
class TestContainerMergePolicyIndex(ReplProbeTest):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
if len(ENABLED_POLICIES) < 2:
|
if len(ENABLED_POLICIES) < 2:
|
||||||
raise SkipTest()
|
raise SkipTest('Need more than one policy')
|
||||||
(self.pids, self.port2server, self.account_ring, self.container_ring,
|
super(TestContainerMergePolicyIndex, self).setUp()
|
||||||
self.object_ring, self.policy, self.url, self.token,
|
|
||||||
self.account, self.configs) = reset_environment()
|
|
||||||
self.container_name = 'container-%s' % uuid.uuid4()
|
self.container_name = 'container-%s' % uuid.uuid4()
|
||||||
self.object_name = 'object-%s' % uuid.uuid4()
|
self.object_name = 'object-%s' % uuid.uuid4()
|
||||||
self.brain = BrainSplitter(self.url, self.token, self.container_name,
|
self.brain = BrainSplitter(self.url, self.token, self.container_name,
|
||||||
|
@ -12,16 +12,16 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import unittest
|
|
||||||
import uuid
|
import uuid
|
||||||
from urlparse import urlparse
|
from urlparse import urlparse
|
||||||
import random
|
import random
|
||||||
from nose import SkipTest
|
from nose import SkipTest
|
||||||
|
import unittest
|
||||||
|
|
||||||
from swiftclient import client
|
from swiftclient import client
|
||||||
|
|
||||||
from swift.common.manager import Manager
|
from swift.common.manager import Manager
|
||||||
from test.probe.common import kill_servers, reset_environment, ENABLED_POLICIES
|
from test.probe.common import ReplProbeTest, ENABLED_POLICIES
|
||||||
|
|
||||||
|
|
||||||
def get_current_realm_cluster(url):
|
def get_current_realm_cluster(url):
|
||||||
@ -43,17 +43,12 @@ def get_current_realm_cluster(url):
|
|||||||
raise SkipTest('Unable find current realm cluster')
|
raise SkipTest('Unable find current realm cluster')
|
||||||
|
|
||||||
|
|
||||||
class TestContainerSync(unittest.TestCase):
|
class TestContainerSync(ReplProbeTest):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
(self.pids, self.port2server, self.account_ring, self.container_ring,
|
super(TestContainerSync, self).setUp()
|
||||||
self.object_ring, self.policy, self.url, self.token,
|
|
||||||
self.account, self.configs) = reset_environment()
|
|
||||||
self.realm, self.cluster = get_current_realm_cluster(self.url)
|
self.realm, self.cluster = get_current_realm_cluster(self.url)
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
kill_servers(self.port2server, self.pids)
|
|
||||||
|
|
||||||
def test_sync(self):
|
def test_sync(self):
|
||||||
base_headers = {'X-Container-Sync-Key': 'secret'}
|
base_headers = {'X-Container-Sync-Key': 'secret'}
|
||||||
|
|
||||||
@ -95,5 +90,4 @@ class TestContainerSync(unittest.TestCase):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
get_current_realm_cluster('http://localhost:8080')
|
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
@ -18,7 +18,7 @@ import os
|
|||||||
import shutil
|
import shutil
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from unittest import main, TestCase
|
from unittest import main
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
from swiftclient import client
|
from swiftclient import client
|
||||||
@ -26,21 +26,12 @@ from swiftclient import client
|
|||||||
from swift.common import direct_client
|
from swift.common import direct_client
|
||||||
from swift.obj.diskfile import get_data_dir
|
from swift.obj.diskfile import get_data_dir
|
||||||
from swift.common.exceptions import ClientException
|
from swift.common.exceptions import ClientException
|
||||||
from test.probe.common import kill_server, kill_servers, reset_environment,\
|
from test.probe.common import kill_server, ReplProbeTest, start_server
|
||||||
start_server
|
|
||||||
from swift.common.utils import readconf
|
from swift.common.utils import readconf
|
||||||
from swift.common.manager import Manager
|
from swift.common.manager import Manager
|
||||||
|
|
||||||
|
|
||||||
class TestEmptyDevice(TestCase):
|
class TestEmptyDevice(ReplProbeTest):
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
(self.pids, self.port2server, self.account_ring, self.container_ring,
|
|
||||||
self.object_ring, self.policy, self.url, self.token,
|
|
||||||
self.account, self.configs) = reset_environment()
|
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
kill_servers(self.port2server, self.pids)
|
|
||||||
|
|
||||||
def _get_objects_dir(self, onode):
|
def _get_objects_dir(self, onode):
|
||||||
device = onode['device']
|
device = onode['device']
|
||||||
|
@ -14,26 +14,18 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from unittest import main, TestCase
|
from unittest import main
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
from swiftclient import client
|
from swiftclient import client
|
||||||
|
|
||||||
from swift.common import direct_client
|
from swift.common import direct_client
|
||||||
from swift.common.manager import Manager
|
from swift.common.manager import Manager
|
||||||
from test.probe.common import kill_nonprimary_server, kill_server, \
|
from test.probe.common import kill_nonprimary_server, \
|
||||||
kill_servers, reset_environment, start_server
|
kill_server, ReplProbeTest, start_server
|
||||||
|
|
||||||
|
|
||||||
class TestObjectAsyncUpdate(TestCase):
|
class TestObjectAsyncUpdate(ReplProbeTest):
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
(self.pids, self.port2server, self.account_ring, self.container_ring,
|
|
||||||
self.object_ring, self.policy, self.url, self.token,
|
|
||||||
self.account, self.configs) = reset_environment()
|
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
kill_servers(self.port2server, self.pids)
|
|
||||||
|
|
||||||
def test_main(self):
|
def test_main(self):
|
||||||
# Create container
|
# Create container
|
||||||
|
@ -13,8 +13,8 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import random
|
import random
|
||||||
import unittest
|
|
||||||
import uuid
|
import uuid
|
||||||
|
import unittest
|
||||||
|
|
||||||
from nose import SkipTest
|
from nose import SkipTest
|
||||||
|
|
||||||
@ -22,14 +22,14 @@ from swift.common.internal_client import InternalClient
|
|||||||
from swift.common.manager import Manager
|
from swift.common.manager import Manager
|
||||||
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 ReplProbeTest, get_to_final_state, \
|
||||||
ENABLED_POLICIES
|
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
|
||||||
|
|
||||||
|
|
||||||
class TestObjectExpirer(unittest.TestCase):
|
class TestObjectExpirer(ReplProbeTest):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
if len(ENABLED_POLICIES) < 2:
|
if len(ENABLED_POLICIES) < 2:
|
||||||
@ -47,9 +47,7 @@ class TestObjectExpirer(unittest.TestCase):
|
|||||||
conf_file = conf_files[0]
|
conf_file = conf_files[0]
|
||||||
self.client = InternalClient(conf_file, 'probe-test', 3)
|
self.client = InternalClient(conf_file, 'probe-test', 3)
|
||||||
|
|
||||||
(self.pids, self.port2server, self.account_ring, self.container_ring,
|
super(TestObjectExpirer, self).setUp()
|
||||||
self.object_ring, self.policy, self.url, self.token,
|
|
||||||
self.account, self.configs) = reset_environment()
|
|
||||||
self.container_name = 'container-%s' % uuid.uuid4()
|
self.container_name = 'container-%s' % uuid.uuid4()
|
||||||
self.object_name = 'object-%s' % uuid.uuid4()
|
self.object_name = 'object-%s' % uuid.uuid4()
|
||||||
self.brain = BrainSplitter(self.url, self.token, self.container_name,
|
self.brain = BrainSplitter(self.url, self.token, self.container_name,
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
import time
|
import time
|
||||||
from os import listdir, unlink
|
from os import listdir, unlink
|
||||||
from os.path import join as path_join
|
from os.path import join as path_join
|
||||||
from unittest import main, TestCase
|
from unittest import main
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
from swiftclient import client
|
from swiftclient import client
|
||||||
@ -26,7 +26,7 @@ from swift.common import direct_client
|
|||||||
from swift.common.exceptions import ClientException
|
from swift.common.exceptions import ClientException
|
||||||
from swift.common.utils import hash_path, readconf
|
from swift.common.utils import hash_path, readconf
|
||||||
from swift.obj.diskfile import write_metadata, read_metadata, get_data_dir
|
from swift.obj.diskfile import write_metadata, read_metadata, get_data_dir
|
||||||
from test.probe.common import kill_servers, reset_environment
|
from test.probe.common import ReplProbeTest
|
||||||
|
|
||||||
|
|
||||||
RETRIES = 5
|
RETRIES = 5
|
||||||
@ -49,15 +49,7 @@ def get_data_file_path(obj_dir):
|
|||||||
return path_join(obj_dir, filename)
|
return path_join(obj_dir, filename)
|
||||||
|
|
||||||
|
|
||||||
class TestObjectFailures(TestCase):
|
class TestObjectFailures(ReplProbeTest):
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
(self.pids, self.port2server, self.account_ring, self.container_ring,
|
|
||||||
self.object_ring, self.policy, self.url, self.token,
|
|
||||||
self.account, self.configs) = reset_environment()
|
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
kill_servers(self.port2server, self.pids)
|
|
||||||
|
|
||||||
def _setup_data_file(self, container, obj, data):
|
def _setup_data_file(self, container, obj, data):
|
||||||
client.put_container(self.url, self.token, container)
|
client.put_container(self.url, self.token, container)
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from unittest import main, TestCase
|
from unittest import main
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
from swiftclient import client
|
from swiftclient import client
|
||||||
@ -22,19 +22,10 @@ from swiftclient import client
|
|||||||
from swift.common import direct_client
|
from swift.common import direct_client
|
||||||
from swift.common.exceptions import ClientException
|
from swift.common.exceptions import ClientException
|
||||||
from swift.common.manager import Manager
|
from swift.common.manager import Manager
|
||||||
from test.probe.common import kill_server, kill_servers, reset_environment, \
|
from test.probe.common import kill_server, ReplProbeTest, start_server
|
||||||
start_server
|
|
||||||
|
|
||||||
|
|
||||||
class TestObjectHandoff(TestCase):
|
class TestObjectHandoff(ReplProbeTest):
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
(self.pids, self.port2server, self.account_ring, self.container_ring,
|
|
||||||
self.object_ring, self.policy, self.url, self.token,
|
|
||||||
self.account, self.configs) = reset_environment()
|
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
kill_servers(self.port2server, self.pids)
|
|
||||||
|
|
||||||
def test_main(self):
|
def test_main(self):
|
||||||
# Create container
|
# Create container
|
||||||
|
@ -17,17 +17,16 @@ from io import StringIO
|
|||||||
from tempfile import mkdtemp
|
from tempfile import mkdtemp
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
import functools
|
import functools
|
||||||
|
import unittest
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import unittest
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from swift.common import internal_client, utils
|
from swift.common import internal_client, utils
|
||||||
|
|
||||||
from test.probe.brain import BrainSplitter
|
from test.probe.brain import BrainSplitter
|
||||||
from test.probe.common import kill_servers, reset_environment, \
|
from test.probe.common import ReplProbeTest, get_to_final_state
|
||||||
get_to_final_state
|
|
||||||
|
|
||||||
|
|
||||||
def _sync_methods(object_server_config_paths):
|
def _sync_methods(object_server_config_paths):
|
||||||
@ -65,14 +64,12 @@ def expected_failure_with_ssync(m):
|
|||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
class Test(unittest.TestCase):
|
class Test(ReplProbeTest):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""
|
"""
|
||||||
Reset all environment and start all servers.
|
Reset all environment and start all servers.
|
||||||
"""
|
"""
|
||||||
(self.pids, self.port2server, self.account_ring, self.container_ring,
|
super(Test, self).setUp()
|
||||||
self.object_ring, self.policy, self.url, self.token,
|
|
||||||
self.account, self.configs) = reset_environment()
|
|
||||||
self.container_name = 'container-%s' % uuid.uuid4()
|
self.container_name = 'container-%s' % uuid.uuid4()
|
||||||
self.object_name = 'object-%s' % uuid.uuid4()
|
self.object_name = 'object-%s' % uuid.uuid4()
|
||||||
self.brain = BrainSplitter(self.url, self.token, self.container_name,
|
self.brain = BrainSplitter(self.url, self.token, self.container_name,
|
||||||
@ -101,10 +98,7 @@ class Test(unittest.TestCase):
|
|||||||
self.int_client = internal_client.InternalClient(conf_path, 'test', 1)
|
self.int_client = internal_client.InternalClient(conf_path, 'test', 1)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
"""
|
super(Test, self).tearDown()
|
||||||
Stop all servers.
|
|
||||||
"""
|
|
||||||
kill_servers(self.port2server, self.pids)
|
|
||||||
shutil.rmtree(self.tempdir)
|
shutil.rmtree(self.tempdir)
|
||||||
|
|
||||||
def _put_object(self, headers=None):
|
def _put_object(self, headers=None):
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from unittest import main, TestCase
|
from unittest import main
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
@ -24,7 +24,7 @@ from swiftclient import client
|
|||||||
from swift.common.storage_policy import POLICIES
|
from swift.common.storage_policy import POLICIES
|
||||||
from swift.obj.diskfile import get_data_dir
|
from swift.obj.diskfile import get_data_dir
|
||||||
|
|
||||||
from test.probe.common import kill_servers, reset_environment
|
from test.probe.common import ReplProbeTest
|
||||||
from swift.common.utils import readconf
|
from swift.common.utils import readconf
|
||||||
from swift.common.manager import Manager
|
from swift.common.manager import Manager
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ def find_max_occupancy_node(dir_list):
|
|||||||
return number
|
return number
|
||||||
|
|
||||||
|
|
||||||
class TestReplicatorFunctions(TestCase):
|
class TestReplicatorFunctions(ReplProbeTest):
|
||||||
"""
|
"""
|
||||||
Class for testing replicators and replication servers.
|
Class for testing replicators and replication servers.
|
||||||
|
|
||||||
@ -77,19 +77,6 @@ class TestReplicatorFunctions(TestCase):
|
|||||||
ring's files using set_info command or new ring's files with
|
ring's files using set_info command or new ring's files with
|
||||||
different port values.
|
different port values.
|
||||||
"""
|
"""
|
||||||
def setUp(self):
|
|
||||||
"""
|
|
||||||
Reset all environment and start all servers.
|
|
||||||
"""
|
|
||||||
(self.pids, self.port2server, self.account_ring, self.container_ring,
|
|
||||||
self.object_ring, self.policy, self.url, self.token,
|
|
||||||
self.account, self.configs) = reset_environment()
|
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
"""
|
|
||||||
Stop all servers.
|
|
||||||
"""
|
|
||||||
kill_servers(self.port2server, self.pids)
|
|
||||||
|
|
||||||
def test_main(self):
|
def test_main(self):
|
||||||
# Create one account, container and object file.
|
# Create one account, container and object file.
|
||||||
|
Loading…
Reference in New Issue
Block a user