diff --git a/examples/integration_test/it.py b/examples/integration_test/it.py
index ca7e63faf86814c96d5285c9ec6ca53bce9c5f10..6e93890e5162695062ddb9b4bb7b039236519e24 100644
--- a/examples/integration_test/it.py
+++ b/examples/integration_test/it.py
@@ -27,6 +27,7 @@ interfaces/APIs that are supported.
import argparse
import logging
+import json
import sys
import time
import traceback
@@ -109,7 +110,7 @@ def run(oidc_username, storage_username):
# running array of test case results, unfortunately we have to hardcode the number of
# test cases because the indeterminate progress bar is not helpful for the tester
- NUM_TEST_CASES = 29
+ NUM_TEST_CASES = 31
results = TestCases(NUM_TEST_CASES)
try:
@@ -142,13 +143,35 @@ def run(oidc_username, storage_username):
# ensure the desired IT experiment is cloned and is available in the storage server. Clone
# the experiment first if not.
- results.start('Checking for Empty Template Husky Experiment in the Storage Server')
- if 'template_husky_0' not in vc._VirtualCoach__get_experiment_list(cloned=True):
- if 'ExDTemplateHusky' not in [s[0] for s in server_info.iteritems()]:
- raise TestCaseError('Husky Template Experiment is not available on the server to be'
- ' cloned.')
- else:
- vc.clone_experiment_to_storage('ExDTemplateHusky')
+ results.start('Cloning a new Empty Template Husky Experiment from the Storage Server')
+
+ if 'ExDTemplateHusky' not in [s[0] for s in server_info.iteritems()]:
+ raise TestCaseError('Husky Template Experiment is not available on the server to be'
+ ' cloned.')
+ experiment_id = vc.clone_experiment_to_storage('ExDTemplateHusky')
+ stored_experiments = vc._VirtualCoach__get_experiment_list(cloned=True)
+ if experiment_id not in stored_experiments:
+ raise TestCaseError('Template Husky Experiment was not cloned to the storage.')
+ results.done(True)
+
+ ##
+ ## Clone a Cloned Experiment
+ ##
+
+ results.start('Cloning a cloned experiment')
+ new_experiment_id = json.loads(vc.clone_cloned_experiment(experiment_id))['clonedExp']
+ if new_experiment_id not in vc._VirtualCoach__get_experiment_list(cloned=True):
+ raise TestCaseError('Cloning the cloned Template Husky Experiment failed')
+ results.done(True)
+
+ ##
+ ## Delete a Cloned Experiment
+ ##
+
+ results.start('Deleting a cloned experiment')
+ vc.delete_cloned_experiment(new_experiment_id)
+ if new_experiment_id in vc._VirtualCoach__get_experiment_list(cloned=True):
+ raise TestCaseError('Deleting a cloned Experiment failed')
results.done(True)
##
@@ -157,7 +180,7 @@ def run(oidc_username, storage_username):
# launch an experiment
results.start('Launching Empty Template Husky Experiment')
- sim = vc.launch_experiment('template_husky_0')
+ sim = vc.launch_experiment(experiment_id)
results.done(True)
# status handlers for simulation status events, simply write to our global status message
@@ -421,13 +444,14 @@ def tf(t):
results.done(True)
##
- ## Shutdown and Cleanup
+ ## Shutdown, Cleanup and Delete the cloned experiment used in the tests
##
# shutdown the experiment cleanly
results.start('Stopping Simulation')
sim.stop()
wait_condition(5, 'Waiting for simulation to stop.', lambda x: x['state'] == 'stopped')
+ vc.delete_cloned_experiment(experiment_id)
results.done(True)
# handle test case or unexpected failures, attempt to cleanup and terminate
diff --git a/hbp_nrp_virtual_coach/hbp_nrp_virtual_coach/tests/test_virtual_coach.py b/hbp_nrp_virtual_coach/hbp_nrp_virtual_coach/tests/test_virtual_coach.py
index 364f3cf8d72b13710441e5052bc69f4b09fd1242..5da507d918af4a37cea05a0040003de5391abf04 100644
--- a/hbp_nrp_virtual_coach/hbp_nrp_virtual_coach/tests/test_virtual_coach.py
+++ b/hbp_nrp_virtual_coach/hbp_nrp_virtual_coach/tests/test_virtual_coach.py
@@ -446,6 +446,7 @@ mock-server-5
class Request(object):
status_code = 200
+ content = 'experiment_id'
request.return_value = Request()
self._vc._VirtualCoach__storage_username = 'username'
@@ -496,6 +497,7 @@ mock-server-5
class Request(object):
status_code = 200
+ content = None
request.return_value = Request()
self._vc._VirtualCoach__storage_username = 'token'
diff --git a/hbp_nrp_virtual_coach/hbp_nrp_virtual_coach/virtual_coach.py b/hbp_nrp_virtual_coach/hbp_nrp_virtual_coach/virtual_coach.py
index 230191e91cfbafb51419ac82d6d801a65ee3ed97..bedf6a3cb09b788cb46de83dcb2f24e216fb8c4a 100644
--- a/hbp_nrp_virtual_coach/hbp_nrp_virtual_coach/virtual_coach.py
+++ b/hbp_nrp_virtual_coach/hbp_nrp_virtual_coach/virtual_coach.py
@@ -281,6 +281,7 @@ class VirtualCoach(object):
instantiated with Storage Server support, i.e. Storage Server credentials
:param exp_id: The id of the experiment to be cloned
+ :returns: The ID of the cloned experiment
"""
assert isinstance(exp_id, str)
@@ -297,6 +298,7 @@ class VirtualCoach(object):
raise Exception('Cloning Experiment failed, Status Code: %s' % res.status_code)
else:
logger.info('Experiment "%s" cloned successfully', exp_id)
+ return res.content
def delete_cloned_experiment(self, exp_id):
"""
@@ -318,6 +320,8 @@ class VirtualCoach(object):
Attempts to clone a cloned experiment to the Storage Server.
:param experiment_id: The id of the cloned experiment to be cloned. E.g. benchmark_p3dx_1
+ :returns: A dict containing the ID of the cloned experiment and the ID of the original
+ experiment. Dict Keys are: 'clonedExp' and 'originalExp'
"""
assert isinstance(experiment_id, str)
@@ -341,6 +345,7 @@ class VirtualCoach(object):
raise Exception('Cloning Experiment failed, Status Code: %s' % res.status_code)
else:
logger.info('Experiment "%s" cloned successfully', experiment_id)
+ return res.content
def print_cloned_experiments(self):
"""