pids in probe is no longer used

Change-Id: I1fd76004257a8c05ce8bb1f3ca0e45000509f833
This commit is contained in:
Kota Tsuyuzaki 2016-06-01 23:53:35 -07:00
parent 3f00170825
commit e56a1a550a
6 changed files with 39 additions and 63 deletions

View File

@ -58,18 +58,18 @@ def get_server_number(ipport, ipport2server):
return server, number return server, number
def start_server(ipport, ipport2server, pids, check=True): def start_server(ipport, ipport2server, check=True):
server, number = get_server_number(ipport, ipport2server) server, number = get_server_number(ipport, ipport2server)
err = Manager([server]).start(number=number, wait=False) err = Manager([server]).start(number=number, wait=False)
if err: if err:
raise Exception('unable to start %s' % ( raise Exception('unable to start %s' % (
server if not number else '%s%s' % (server, number))) server if not number else '%s%s' % (server, number)))
if check: if check:
return check_server(ipport, ipport2server, pids) return check_server(ipport, ipport2server)
return None return None
def check_server(ipport, ipport2server, pids, timeout=CHECK_SERVER_TIMEOUT): def check_server(ipport, ipport2server, timeout=CHECK_SERVER_TIMEOUT):
server = ipport2server[ipport] server = ipport2server[ipport]
if server[:-1] in ('account', 'container', 'object'): if server[:-1] in ('account', 'container', 'object'):
if int(server[-1]) > 4: if int(server[-1]) > 4:
@ -116,7 +116,7 @@ def check_server(ipport, ipport2server, pids, timeout=CHECK_SERVER_TIMEOUT):
return None return None
def kill_server(ipport, ipport2server, pids): def kill_server(ipport, ipport2server):
server, number = get_server_number(ipport, ipport2server) server, number = get_server_number(ipport, ipport2server)
err = Manager([server]).kill(number=number) err = Manager([server]).kill(number=number)
if err: if err:
@ -136,7 +136,7 @@ def kill_server(ipport, ipport2server, pids):
sleep(0.1) sleep(0.1)
def kill_nonprimary_server(primary_nodes, ipport2server, pids): def kill_nonprimary_server(primary_nodes, ipport2server):
primary_ipports = [(n['ip'], n['port']) for n in primary_nodes] primary_ipports = [(n['ip'], n['port']) for n in primary_nodes]
for ipport, server in ipport2server.items(): for ipport, server in ipport2server.items():
if ipport in primary_ipports: if ipport in primary_ipports:
@ -146,7 +146,7 @@ def kill_nonprimary_server(primary_nodes, ipport2server, pids):
raise Exception('Cannot figure out server type for %r' % primary_nodes) raise Exception('Cannot figure out server type for %r' % primary_nodes)
for ipport, server in list(ipport2server.items()): for ipport, server in list(ipport2server.items()):
if server[:-1] == server_type and ipport not in primary_ipports: if server[:-1] == server_type and ipport not in primary_ipports:
kill_server(ipport, ipport2server, pids) kill_server(ipport, ipport2server)
return ipport return ipport
@ -322,7 +322,6 @@ class ProbeTest(unittest.TestCase):
def setUp(self): def setUp(self):
resetswift() resetswift()
self.pids = {}
try: try:
self.ipport2server = {} self.ipport2server = {}
self.configs = defaultdict(dict) self.configs = defaultdict(dict)
@ -354,11 +353,11 @@ class ProbeTest(unittest.TestCase):
Manager(['main']).start(wait=False) Manager(['main']).start(wait=False)
for ipport in self.ipport2server: for ipport in self.ipport2server:
check_server(ipport, self.ipport2server, self.pids) check_server(ipport, self.ipport2server)
proxy_ipport = ('127.0.0.1', 8080) proxy_ipport = ('127.0.0.1', 8080)
self.ipport2server[proxy_ipport] = 'proxy' self.ipport2server[proxy_ipport] = 'proxy'
self.url, self.token, self.account = check_server( self.url, self.token, self.account = check_server(
proxy_ipport, self.ipport2server, self.pids) proxy_ipport, self.ipport2server)
self.replicators = Manager( self.replicators = Manager(
['account-replicator', 'container-replicator', ['account-replicator', 'container-replicator',
'object-replicator']) 'object-replicator'])

View File

@ -97,9 +97,8 @@ class TestAccountFailures(ReplProbeTest):
self.assertTrue(found2) self.assertTrue(found2)
apart, anodes = self.account_ring.get_nodes(self.account) apart, anodes = self.account_ring.get_nodes(self.account)
kill_nonprimary_server(anodes, self.ipport2server, self.pids) kill_nonprimary_server(anodes, self.ipport2server)
kill_server((anodes[0]['ip'], anodes[0]['port']), kill_server((anodes[0]['ip'], anodes[0]['port']), self.ipport2server)
self.ipport2server, self.pids)
# Kill account servers excepting two of the primaries # Kill account servers excepting two of the primaries
# Delete container1 # Delete container1
@ -147,8 +146,7 @@ class TestAccountFailures(ReplProbeTest):
self.assertTrue(found2) self.assertTrue(found2)
# Restart other primary account server # Restart other primary account server
start_server((anodes[0]['ip'], anodes[0]['port']), start_server((anodes[0]['ip'], anodes[0]['port']), self.ipport2server)
self.ipport2server, self.pids)
# Assert that server doesn't know about container1's deletion or the # Assert that server doesn't know about container1's deletion or the
# new container2/object2 yet # new container2/object2 yet

View File

@ -49,16 +49,14 @@ class TestContainerFailures(ReplProbeTest):
client.put_container(self.url, self.token, container1) client.put_container(self.url, self.token, container1)
# Kill container1 servers excepting two of the primaries # Kill container1 servers excepting two of the primaries
kill_nonprimary_server(cnodes, self.ipport2server, self.pids) kill_nonprimary_server(cnodes, self.ipport2server)
kill_server((cnodes[0]['ip'], cnodes[0]['port']), kill_server((cnodes[0]['ip'], cnodes[0]['port']), self.ipport2server)
self.ipport2server, self.pids)
# Delete container1 # Delete container1
client.delete_container(self.url, self.token, container1) client.delete_container(self.url, self.token, container1)
# Restart other container1 primary server # Restart other container1 primary server
start_server((cnodes[0]['ip'], cnodes[0]['port']), start_server((cnodes[0]['ip'], cnodes[0]['port']), self.ipport2server)
self.ipport2server, self.pids)
# Create container1/object1 (allowed because at least server thinks the # Create container1/object1 (allowed because at least server thinks the
# container exists) # container exists)
@ -89,12 +87,11 @@ class TestContainerFailures(ReplProbeTest):
client.put_container(self.url, self.token, container1) client.put_container(self.url, self.token, container1)
# Kill container1 servers excepting one of the primaries # Kill container1 servers excepting one of the primaries
cnp_ipport = kill_nonprimary_server(cnodes, self.ipport2server, cnp_ipport = kill_nonprimary_server(cnodes, self.ipport2server)
self.pids)
kill_server((cnodes[0]['ip'], cnodes[0]['port']), kill_server((cnodes[0]['ip'], cnodes[0]['port']),
self.ipport2server, self.pids) self.ipport2server)
kill_server((cnodes[1]['ip'], cnodes[1]['port']), kill_server((cnodes[1]['ip'], cnodes[1]['port']),
self.ipport2server, self.pids) self.ipport2server)
# Delete container1 directly to the one primary still up # Delete container1 directly to the one primary still up
direct_client.direct_delete_container(cnodes[2], cpart, self.account, direct_client.direct_delete_container(cnodes[2], cpart, self.account,
@ -102,10 +99,10 @@ class TestContainerFailures(ReplProbeTest):
# Restart other container1 servers # Restart other container1 servers
start_server((cnodes[0]['ip'], cnodes[0]['port']), start_server((cnodes[0]['ip'], cnodes[0]['port']),
self.ipport2server, self.pids) self.ipport2server)
start_server((cnodes[1]['ip'], cnodes[1]['port']), start_server((cnodes[1]['ip'], cnodes[1]['port']),
self.ipport2server, self.pids) self.ipport2server)
start_server(cnp_ipport, self.ipport2server, self.pids) start_server(cnp_ipport, self.ipport2server)
# Get to a final state # Get to a final state
self.get_to_final_state() self.get_to_final_state()

View File

@ -58,8 +58,7 @@ class TestEmptyDevice(ReplProbeTest):
onode = onodes[0] onode = onodes[0]
# Kill one container/obj primary server # Kill one container/obj primary server
kill_server((onode['ip'], onode['port']), kill_server((onode['ip'], onode['port']), self.ipport2server)
self.ipport2server, self.pids)
# Delete the default data directory for objects on the primary server # Delete the default data directory for objects on the primary server
obj_dir = '%s/%s' % (self._get_objects_dir(onode), obj_dir = '%s/%s' % (self._get_objects_dir(onode),
@ -77,8 +76,7 @@ class TestEmptyDevice(ReplProbeTest):
# Kill other two container/obj primary servers # Kill other two container/obj primary servers
# to ensure GET handoff works # to ensure GET handoff works
for node in onodes[1:]: for node in onodes[1:]:
kill_server((node['ip'], node['port']), kill_server((node['ip'], node['port']), self.ipport2server)
self.ipport2server, self.pids)
# Indirectly through proxy assert we can get container/obj # Indirectly through proxy assert we can get container/obj
odata = client.get_object(self.url, self.token, container, obj)[-1] odata = client.get_object(self.url, self.token, container, obj)[-1]
@ -87,8 +85,7 @@ class TestEmptyDevice(ReplProbeTest):
'returned: %s' % repr(odata)) 'returned: %s' % repr(odata))
# Restart those other two container/obj primary servers # Restart those other two container/obj primary servers
for node in onodes[1:]: for node in onodes[1:]:
start_server((node['ip'], node['port']), start_server((node['ip'], node['port']), self.ipport2server)
self.ipport2server, self.pids)
self.assertFalse(os.path.exists(obj_dir)) self.assertFalse(os.path.exists(obj_dir))
# We've indirectly verified the handoff node has the object, but # We've indirectly verified the handoff node has the object, but
# let's directly verify it. # let's directly verify it.
@ -127,8 +124,7 @@ class TestEmptyDevice(ReplProbeTest):
missing) missing)
# Bring the first container/obj primary server back up # Bring the first container/obj primary server back up
start_server((onode['ip'], onode['port']), start_server((onode['ip'], onode['port']), self.ipport2server)
self.ipport2server, self.pids)
# Assert that it doesn't have container/obj yet # Assert that it doesn't have container/obj yet
self.assertFalse(os.path.exists(obj_dir)) self.assertFalse(os.path.exists(obj_dir))

View File

@ -36,17 +36,15 @@ class TestObjectAsyncUpdate(ReplProbeTest):
# Kill container servers excepting two of the primaries # Kill container servers excepting two of the primaries
cpart, cnodes = self.container_ring.get_nodes(self.account, container) cpart, cnodes = self.container_ring.get_nodes(self.account, container)
cnode = cnodes[0] cnode = cnodes[0]
kill_nonprimary_server(cnodes, self.ipport2server, self.pids) kill_nonprimary_server(cnodes, self.ipport2server)
kill_server((cnode['ip'], cnode['port']), kill_server((cnode['ip'], cnode['port']), self.ipport2server)
self.ipport2server, self.pids)
# Create container/obj # Create container/obj
obj = 'object-%s' % uuid4() obj = 'object-%s' % uuid4()
client.put_object(self.url, self.token, container, obj, '') client.put_object(self.url, self.token, container, obj, '')
# Restart other primary server # Restart other primary server
start_server((cnode['ip'], cnode['port']), start_server((cnode['ip'], cnode['port']), self.ipport2server)
self.ipport2server, self.pids)
# Assert it does not know about container/obj # Assert it does not know about container/obj
self.assertFalse(direct_client.direct_get_container( self.assertFalse(direct_client.direct_get_container(
@ -117,16 +115,14 @@ class TestUpdateOverridesEC(ECProbeTest):
# put an object while one container server is stopped so that we force # put an object while one container server is stopped so that we force
# an async update to it # an async update to it
kill_server((cnodes[0]['ip'], cnodes[0]['port']), kill_server((cnodes[0]['ip'], cnodes[0]['port']), self.ipport2server)
self.ipport2server, self.pids)
content = u'stuff' content = u'stuff'
client.put_object(self.url, self.token, 'c1', 'o1', contents=content) client.put_object(self.url, self.token, 'c1', 'o1', contents=content)
meta = client.head_object(self.url, self.token, 'c1', 'o1') meta = client.head_object(self.url, self.token, 'c1', 'o1')
# re-start the container server and assert that it does not yet know # re-start the container server and assert that it does not yet know
# about the object # about the object
start_server((cnodes[0]['ip'], cnodes[0]['port']), start_server((cnodes[0]['ip'], cnodes[0]['port']), self.ipport2server)
self.ipport2server, self.pids)
self.assertFalse(direct_client.direct_get_container( self.assertFalse(direct_client.direct_get_container(
cnodes[0], cpart, self.account, 'c1')[1]) cnodes[0], cpart, self.account, 'c1')[1])
@ -149,16 +145,14 @@ class TestUpdateOverridesEC(ECProbeTest):
# put an object while one container server is stopped so that we force # put an object while one container server is stopped so that we force
# an async update to it # an async update to it
kill_server((cnodes[0]['ip'], cnodes[0]['port']), kill_server((cnodes[0]['ip'], cnodes[0]['port']), self.ipport2server)
self.ipport2server, self.pids)
content = u'stuff' content = u'stuff'
client.put_object(self.url, self.token, 'c1', 'o1', contents=content) client.put_object(self.url, self.token, 'c1', 'o1', contents=content)
meta = client.head_object(self.url, self.token, 'c1', 'o1') meta = client.head_object(self.url, self.token, 'c1', 'o1')
# re-start the container server and assert that it does not yet know # re-start the container server and assert that it does not yet know
# about the object # about the object
start_server((cnodes[0]['ip'], cnodes[0]['port']), start_server((cnodes[0]['ip'], cnodes[0]['port']), self.ipport2server)
self.ipport2server, self.pids)
self.assertFalse(direct_client.direct_get_container( self.assertFalse(direct_client.direct_get_container(
cnodes[0], cpart, self.account, 'c1')[1]) cnodes[0], cpart, self.account, 'c1')[1])
@ -196,8 +190,7 @@ class TestUpdateOverridesEC(ECProbeTest):
# PUT and POST to object while one container server is stopped so that # PUT and POST to object while one container server is stopped so that
# we force async updates to it # we force async updates to it
kill_server((cnodes[0]['ip'], cnodes[0]['port']), kill_server((cnodes[0]['ip'], cnodes[0]['port']), self.ipport2server)
self.ipport2server, self.pids)
content = u'stuff' content = u'stuff'
client.put_object(self.url, self.token, 'c1', 'o1', contents=content) client.put_object(self.url, self.token, 'c1', 'o1', contents=content)
meta = client.head_object(self.url, self.token, 'c1', 'o1') meta = client.head_object(self.url, self.token, 'c1', 'o1')
@ -213,8 +206,7 @@ class TestUpdateOverridesEC(ECProbeTest):
# re-start the container server and assert that it does not yet know # re-start the container server and assert that it does not yet know
# about the object # about the object
start_server((cnodes[0]['ip'], cnodes[0]['port']), start_server((cnodes[0]['ip'], cnodes[0]['port']), self.ipport2server)
self.ipport2server, self.pids)
self.assertFalse(direct_client.direct_get_container( self.assertFalse(direct_client.direct_get_container(
cnodes[0], cpart, self.account, 'c1')[1]) cnodes[0], cpart, self.account, 'c1')[1])

View File

@ -46,8 +46,7 @@ class TestObjectHandoff(ReplProbeTest):
opart, onodes = self.object_ring.get_nodes( opart, onodes = self.object_ring.get_nodes(
self.account, container, obj) self.account, container, obj)
onode = onodes[0] onode = onodes[0]
kill_server((onode['ip'], onode['port']), kill_server((onode['ip'], onode['port']), self.ipport2server)
self.ipport2server, self.pids)
# Create container/obj (goes to two primary servers and one handoff) # Create container/obj (goes to two primary servers and one handoff)
client.put_object(self.url, self.token, container, obj, 'VERIFY') client.put_object(self.url, self.token, container, obj, 'VERIFY')
@ -59,8 +58,7 @@ class TestObjectHandoff(ReplProbeTest):
# Kill other two container/obj primary servers # Kill other two container/obj primary servers
# to ensure GET handoff works # to ensure GET handoff works
for node in onodes[1:]: for node in onodes[1:]:
kill_server((node['ip'], node['port']), kill_server((node['ip'], node['port']), self.ipport2server)
self.ipport2server, self.pids)
# Indirectly through proxy assert we can get container/obj # Indirectly through proxy assert we can get container/obj
odata = client.get_object(self.url, self.token, container, obj)[-1] odata = client.get_object(self.url, self.token, container, obj)[-1]
@ -70,8 +68,7 @@ class TestObjectHandoff(ReplProbeTest):
# Restart those other two container/obj primary servers # Restart those other two container/obj primary servers
for node in onodes[1:]: for node in onodes[1:]:
start_server((node['ip'], node['port']), start_server((node['ip'], node['port']), self.ipport2server)
self.ipport2server, self.pids)
# We've indirectly verified the handoff node has the container/object, # We've indirectly verified the handoff node has the container/object,
# but let's directly verify it. # but let's directly verify it.
@ -114,8 +111,7 @@ class TestObjectHandoff(ReplProbeTest):
(cnode['ip'], cnode['port'])) (cnode['ip'], cnode['port']))
# Bring the first container/obj primary server back up # Bring the first container/obj primary server back up
start_server((onode['ip'], onode['port']), start_server((onode['ip'], onode['port']), self.ipport2server)
self.ipport2server, self.pids)
# Assert that it doesn't have container/obj yet # Assert that it doesn't have container/obj yet
try: try:
@ -177,8 +173,7 @@ class TestObjectHandoff(ReplProbeTest):
# Kill the first container/obj primary server again (we have two # Kill the first container/obj primary server again (we have two
# primaries and the handoff up now) # primaries and the handoff up now)
kill_server((onode['ip'], onode['port']), kill_server((onode['ip'], onode['port']), self.ipport2server)
self.ipport2server, self.pids)
# Delete container/obj # Delete container/obj
try: try:
@ -215,8 +210,7 @@ class TestObjectHandoff(ReplProbeTest):
(cnode['ip'], cnode['port'])) (cnode['ip'], cnode['port']))
# Restart the first container/obj primary server again # Restart the first container/obj primary server again
start_server((onode['ip'], onode['port']), start_server((onode['ip'], onode['port']), self.ipport2server)
self.ipport2server, self.pids)
# Assert it still has container/obj # Assert it still has container/obj
direct_client.direct_get_object( direct_client.direct_get_object(