Add num iterations of test to manifest file that can be used by the test from ITERATIONS environment if required
Change-Id: Ie6193d0b750f59f2674e0659eeef1ffda94831ef
diff --git a/src/test/cluster/clusterTest.py b/src/test/cluster/clusterTest.py
index 2260612..a0281db 100644
--- a/src/test/cluster/clusterTest.py
+++ b/src/test/cluster/clusterTest.py
@@ -63,6 +63,7 @@
subscriber = cluster_subscriber()
testcaseLoggers = ('test_cluster_controller_restarts', 'test_cluster_graceful_controller_restarts',
'test_cluster_single_controller_restarts', 'test_cluster_restarts')
+ iterations = os.getenv('ITERATIONS', 10)
def setUp(self):
if self._testMethodName not in self.testcaseLoggers:
@@ -401,7 +402,7 @@
return controller
next_controller = None
- tries = 10
+ tries = self.iterations
for num in range(tries):
index = num % ctlr_len
#index = random.randrange(0, ctlr_len)
@@ -490,7 +491,7 @@
return controller
- tries = 10
+ tries = self.iterations
#chose a random controller for shutdown/restarts
controller = controllers[random.randrange(0, ctlr_len)]
controller_name = onos_map[controller]
@@ -569,7 +570,7 @@
iteration = 'FAILED')
assert_equal(len(ips), len(controllers))
- tries = 10
+ 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/setup/cord-test.py b/src/test/setup/cord-test.py
index bb261ad..b0b2f2f 100755
--- a/src/test/setup/cord-test.py
+++ b/src/test/setup/cord-test.py
@@ -396,6 +396,7 @@
onos_ip = test_manifest.onos_ip
radius_ip = test_manifest.radius_ip
head_node = test_manifest.head_node
+ iterations = test_manifest.iterations
#don't spawn onos if the user has specified external test controller with test interface config
if args.test_controller:
@@ -519,6 +520,9 @@
olt_conf_test_loc = os.path.join(CordTester.sandbox_setup, 'olt_config.json')
test_cnt_env['OLT_CONFIG'] = olt_conf_test_loc
+ if iterations is not None:
+ test_cnt_env['ITERATIONS'] = iterations
+
if args.num_containers > 1 and args.container:
print('Cannot specify number of containers with container option')
sys.exit(1)
@@ -633,6 +637,8 @@
onos_ip = test_manifest.onos_ip
radius_ip = test_manifest.radius_ip
head_node = test_manifest.head_node
+ iterations = test_manifest.iterations
+
##If onos/radius was already started
if args.test_controller:
ips = args.test_controller.split('/')
@@ -768,7 +774,8 @@
if test_manifest.olt:
olt_conf_test_loc = os.path.join(CordTester.sandbox_setup, 'olt_config.json')
test_cnt_env['OLT_CONFIG'] = olt_conf_test_loc
-
+ if test_manifest.iterations is not None:
+ test_cnt_env['ITERATIONS'] = iterations
test_cnt = CordTester((),
ctlr_ip = ctlr_addr,
image = nose_cnt['image'],
diff --git a/src/test/utils/TestManifest.py b/src/test/utils/TestManifest.py
index b8ca881..b56300d 100644
--- a/src/test/utils/TestManifest.py
+++ b/src/test/utils/TestManifest.py
@@ -35,6 +35,7 @@
self.start_switch = args.start_switch
self.image_prefix = args.prefix
self.onos_image = args.onos
+ self.iterations = None
self.server = '{}:{}'.format(CORD_TEST_HOST, CORD_TEST_PORT)
else:
with open(self.manifest, 'r') as fd:
@@ -51,3 +52,4 @@
self.image_prefix = data.get('image_prefix', '')
self.onos_image = data.get('onos_image', 'onosproject/onos:latest')
self.server = data.get('test_server', '{}:{}'.format(CORD_TEST_HOST, CORD_TEST_PORT))
+ self.iterations = data.get('iterations', None)