elem_cross_data[attr_name] = _undefer(attr_value)
return cross_data
- """
+
class ExperimentSuite(object):
def __init__(self, experiment_xml, access_config, repetitions,
duration, wait_guids):
self._experiment_xml = experiment_xml
self._access_config = access_config
- self._experiments = dict()
+ self._controllers = dict()
+ self._access_configs = dict()
self._repetitions = repetitions
self._duration = duration
self._wait_guids = wait_guids
self._status = TS.STATUS_ZERO
self._thread = None
+ @property
+ def current(self):
+ return self._current
+
+ @property
+ def status(self):
+ return self._status
+
+ @property
+ def is_finished(self):
+ return self._status == TS.STATUS_FINISHED
+
+ @property
+ def access_configurations(self):
+ return self._access_configs.values()
+
def start(self):
self._status = TS.STATUS_STARTED
self._thread = threading.Thread(target = self._run_experiment_suite)
if self._thread:
self._thread.join()
self._thread = None
+ for controller in self._controllers.values:
+ controller.shutdown()
+
+ def get_current_access_config(self):
+ return self._access_configs[self._current]
def _run_experiment_suite(self):
for i in xrange[0, self.repetitions]:
self._current = i
self._run_one_experiment()
+ self._status = TS.STATUS_FINISHED
def _run_one_experiment(self):
access_config = proxy.AccessConfiguration()
access_config.set_attribute_value(DC.ROOT_DIRECTORY, root_dir)
controller = proxy.create_experiment_controller(self._experiment_xml,
access_config)
- self._experiments[self._current] = controller
+ self._access_configs[self._current] = access_config
+ self._controllers[self._current] = controller
controller.start()
started_at = time.time()
# wait until all specified guids have finished execution
if self._wait_guids:
- while all(itertools.imap(controller.is_finished, self._wait_guids):
+ while all(itertools.imap(controller.is_finished, self._wait_guids)):
time.sleep(0.5)
# wait until the minimum experiment duration time has elapsed
if self._duration:
while (time.time() - started_at) < self._duration:
time.sleep(0.5)
controller.stop()
- #download results!!
- controller.shutdown()
- """
-
-
-
-
-
-
finally:
controller.stop()
controller.shutdown()
-
+
+ def ptest_experiment_suite(self):
+ exp_desc, desc, app, node1, node2, iface1, iface2 = self.make_test_experiment()
+
+ desc.set_attribute_value(DC.DEPLOYMENT_MODE, DC.MODE_DAEMON)
+ desc.set_attribute_value(DC.ROOT_DIRECTORY, self.root_dir)
+ desc.set_attribute_value(DC.DEPLOYMENT_ENVIRONMENT_SETUP,
+ "export PYTHONPATH=%r:%r:$PYTHONPATH "
+ "export NEPI_TESTBEDS='mock:mock mock2:mock2' " % (
+ os.path.dirname(os.path.dirname(mock.__file__)),
+ os.path.dirname(os.path.dirname(mock2.__file__)),))
+
+ xml = exp_desc.to_xml()
+
+ access_config = proxy.AccessConfiguration()
+ access_config.set_attribute_value(DC.DEPLOYMENT_MODE, DC.MODE_DAEMON)
+ access_config.set_attribute_value(DC.ROOT_DIRECTORY, self.root_dir)
+ access_config.set_attribute_value(DC.DEPLOYMENT_ENVIRONMENT_SETUP,
+ "export PYTHONPATH=%r:%r:$PYTHONPATH "
+ "export NEPI_TESTBEDS='mock:mock mock2:mock2' " % (
+ os.path.dirname(os.path.dirname(mock.__file__)),
+ os.path.dirname(os.path.dirname(mock2.__file__)),))
+
+ exp_suite = proxy.create_experiment_suite(xml, access_config)
+ exp_suite.start()
+ while not exp_suite.is_finished:
+ time.sleep(0.5)
+
+ for access_config in exp_suite.access_configurations:
+ access_config.set_attribute_value(DC.RECOVER, True)
+ controller = proxy.create_experiment_controller(None, access_config)
+
+ fake_result = controller.trace(app.guid, "fake")
+ comp_result = """PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
+
+--- 10.0.0.2 ping statistics ---
+1 packets transmitted, 1 received, 0% packet loss, time 0ms
+"""
+ self.assertTrue(fake_result.startswith(comp_result))
+
+ self.assertEquals(controller.get_testbed_id(node1.guid), "mock")
+ self.assertEquals(controller.get_testbed_version(node1.guid), "0.1")
+ self.assertEquals(controller.get_factory_id(node1.guid), "Node")
+
+ exp_suite.shutdown()
+
if __name__ == '__main__':
unittest.main()