Skip to content
Snippets Groups Projects
Commit 2c22c7d9 authored by Simon Désaulniers's avatar Simon Désaulniers
Browse files

more code refactoring

parent 6c3c19c0
Branches
Tags
No related merge requests found
......@@ -462,12 +462,17 @@ class PersistenceTest(FeatureTest):
DhtNetwork.log("Values didn't reach new hosting nodes after shutdown.")
def run(self):
try:
if self._test == 'delete':
self._deleteTest()
elif self._test == 'replace':
self._resplaceClusterTest()
elif self._test == 'mult_time':
self._multTimeTest()
except Exception as e:
print(e)
finally:
bootstrap.resize(1)
#-----------
#- Tests -
......@@ -487,7 +492,6 @@ class PersistenceTest(FeatureTest):
ops_count = []
try:
bootstrap.resize(3)
consumer = bootstrap.get(1)
producer = bootstrap.get(2)
......@@ -547,11 +551,6 @@ class PersistenceTest(FeatureTest):
else:
DhtNetwork.log("[GET]: either couldn't fetch values or nodes hosting values...")
except Exception as e:
print(e)
finally:
bootstrap.resize(1)
def _resplaceClusterTest(self):
"""
It replaces all clusters one after the other.
......@@ -565,7 +564,6 @@ class PersistenceTest(FeatureTest):
bootstrap = self.bootstrap
try:
bootstrap.resize(3)
consumer = bootstrap.get(1)
producer = bootstrap.get(2)
......@@ -592,11 +590,6 @@ class PersistenceTest(FeatureTest):
self._result(local_values, new_nodes)
except Exception as e:
print(e)
finally:
bootstrap.resize(1)
def _multTimeTest(self):
"""
Multiple put() calls are made from multiple nodes to multiple hashes
......@@ -642,7 +635,6 @@ class PersistenceTest(FeatureTest):
str(self.bootstrap.port))
flood_nodes.append(n)
try:
bootstrap.resize(N_PRODUCERS+2)
consumer = bootstrap.get(1)
producers = (bootstrap.get(n) for n in range(2,N_PRODUCERS+2))
......@@ -679,11 +671,6 @@ class PersistenceTest(FeatureTest):
gottaGetThemAllPokeNodes(nodes=nodes_after_time)
self._result(values, nodes_after_time - nodes)
except Exception as e:
print(e)
finally:
bootstrap.resize(1)
class PerformanceTest(FeatureTest):
"""
Tests for general performance of dht operations.
......@@ -701,10 +688,16 @@ class PerformanceTest(FeatureTest):
super(PerformanceTest, self).__init__(test, workbench)
def run(self):
try:
if self._test == 'gets':
self._getsTimesTest()
elif self._test == 'delete':
self._delete()
except Exception as e:
print(e)
finally:
self.bootstrap.resize(1)
###########
# Tests #
......@@ -806,7 +799,6 @@ class PerformanceTest(FeatureTest):
bootstrap = self.bootstrap
try:
bootstrap.resize(3)
consumer = bootstrap.get(1)
producer = bootstrap.get(2)
......@@ -842,11 +834,6 @@ class PerformanceTest(FeatureTest):
FeatureTest.foreign_nodes
)
except Exception as e:
print(e)
finally:
bootstrap.resize(1)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Run, test and benchmark a '\
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment