Add cluster test config file.
One can modify the test iterations directly here.
Allow for minimum heap size configuration with 'M' or megabyte suffix for onos jvm heap.
Change-Id: I9da9c3a3799c4543512a9cf3ea3f309496df7e80
diff --git a/src/test/cluster/clusterTest.json b/src/test/cluster/clusterTest.json
new file mode 100644
index 0000000..4780b62
--- /dev/null
+++ b/src/test/cluster/clusterTest.json
@@ -0,0 +1,5 @@
+{
+ "V_INF1" : "veth0",
+ "TLS_TIMEOUT" : 100,
+ "ITERATIONS" : 10
+}
diff --git a/src/test/cluster/clusterTest.py b/src/test/cluster/clusterTest.py
index af05873..6d27955 100644
--- a/src/test/cluster/clusterTest.py
+++ b/src/test/cluster/clusterTest.py
@@ -34,6 +34,7 @@
from ACL import ACLTest
from OnosLog import OnosLog
from CordLogger import CordLogger
+from CordTestConfig import setup_module
import os
import json
import random
@@ -63,7 +64,7 @@
subscriber = cluster_subscriber()
testcaseLoggers = ('test_cluster_controller_restarts', 'test_cluster_graceful_controller_restarts',
'test_cluster_single_controller_restarts', 'test_cluster_restarts')
- iterations = int(os.getenv('ITERATIONS', 10))
+ ITERATIONS = int(os.getenv('ITERATIONS', 10))
def setUp(self):
if self._testMethodName not in self.testcaseLoggers:
@@ -402,7 +403,7 @@
return controller
next_controller = None
- tries = self.iterations
+ tries = self.ITERATIONS
for num in range(tries):
index = num % ctlr_len
#index = random.randrange(0, ctlr_len)
@@ -491,7 +492,7 @@
return controller
- tries = self.iterations
+ tries = self.ITERATIONS
#chose a random controller for shutdown/restarts
controller = controllers[random.randrange(0, ctlr_len)]
controller_name = onos_map[controller]
@@ -570,7 +571,7 @@
iteration = 'FAILED')
assert_equal(len(ips), len(controllers))
- tries = self.iterations
+ tries = self.ITERATIONS
for num in range(tries):
log.info('ITERATION: %d. Restarting cluster with controllers at %s' %(num+1, controllers))
try:
diff --git a/src/test/utils/CordContainer.py b/src/test/utils/CordContainer.py
index 81df366..0c30833 100644
--- a/src/test/utils/CordContainer.py
+++ b/src/test/utils/CordContainer.py
@@ -265,6 +265,9 @@
suffix = heap_size[-1]
if suffix == 'M':
heap_size_i /= 1024 #convert to gigs
+ #allow to specific minimum heap size
+ if heap_size_i == 0:
+ return heap_size
except:
##invalid suffix length probably. Fall back to default
heap_size = None
diff --git a/src/test/utils/CordTestConfig.py b/src/test/utils/CordTestConfig.py
index 0e369d9..fc4aafe 100644
--- a/src/test/utils/CordTestConfig.py
+++ b/src/test/utils/CordTestConfig.py
@@ -5,25 +5,21 @@
from nose.tools import assert_not_equal
def setup_module(module):
- class_found = None
+ class_test = None
for name, obj in inspect.getmembers(module):
if inspect.isclass(obj) and issubclass(obj, unittest.TestCase):
if obj.__name__.endswith('exchange'):
- class_found = obj
+ class_test = obj
break
else:
- class_found = obj
+ class_test = obj
- assert_not_equal(class_found, None)
- try:
- module_name = module.__name__.split('.')[-1]
- except:
- module_name = module.__name__
-
+ assert_not_equal(class_test, None)
+ module_name = module.__name__.split('.')[-1]
cfg = '{}.json'.format(module_name)
module_config = os.path.join(os.path.dirname(module.__file__), cfg)
if os.access(module_config, os.F_OK):
with open(module_config) as f:
json_data = json.load(f)
for k, v in json_data.iteritems():
- setattr(class_found, k, v)
+ setattr(class_test, k, v)