import os
import collections
import functools
+import time
ATTRIBUTE_PATTERN_BASE = re.compile(r"\{#\[(?P<label>[-a-zA-Z0-9._]*)\](?P<expr>(?P<component>\.addr\[[0-9]+\]|\.route\[[0-9]+\]|\.trace\[[0-9]+\])?.\[(?P<attribute>[-a-zA-Z0-9._]*)\])#}")
ATTRIBUTE_PATTERN_GUID_SUB = r"{#[%(guid)s]%(expr)s#}"
self._netreffed_testbeds = set()
self._guids_in_testbed_cache = dict()
self._failed_testbeds = set()
+ self._started_time = None
+ self._stopped_time = None
if experiment_xml is None and root_dir is not None:
# Recover
def experiment_execute_xml(self):
return self._experiment_execute_xml
+ @property
+ def started_time(self):
+ return self._started_time
+
+ @property
+ def stopped_time(self):
+ return self._stopped_time
+
@property
def guids(self):
guids = list()
raise eTyp, eVal, eLoc
def start(self):
+ self._started_time = time.time()
self._start()
def _start(self, recover = False):
for testbed in self._testbeds.values():
testbed.stop()
self._unpersist_testbed_proxies()
+ self._stopped_time = time.time()
def recover(self):
# reload perviously persisted testbed access configurations
TRACES_INFO = 41
EXEC_XML = 42
TESTBED_STATUS = 43
+STARTED_TIME = 44
+STOPPED_TIME = 45
instruction_text = dict({
OK: "OK",
TESTBED_ID: "TESTBED_ID",
TESTBED_VERSION: "TESTBED_VERSION",
TRACES_INFO: "TRACES_INFO",
+ STARTED_TIME: "STARTED_TIME",
+ STOPPED_TIME: "STOPPED_TIME",
+
})
def log_msg(server, params):
@staticmethod
def nullint(sdata):
return None if sdata == "None" else int(sdata)
-
+
@staticmethod
def bool(sdata):
return sdata == 'True'
def guids(self):
return self._experiment.guids
+ @Marshalling.handles(STARTED_TIME)
+ @Marshalling.args()
+ @Marshalling.retval( Marshalling.pickled_data )
+ def started_time(self):
+ return self._experiment.started_time
+
+ @Marshalling.handles(STOPPED_TIME)
+ @Marshalling.args()
+ @Marshalling.retval( Marshalling.pickled_data )
+ def stopped_time(self):
+ return self._experiment.stopped_time
+
@Marshalling.handles(XML)
@Marshalling.args()
@Marshalling.retval()
controller = proxy.create_experiment_controller(xml, access_config)
controller.start()
+ started_time = controller.started_time
+ self.assertTrue(started_time < time.time())
while not controller.is_finished(app.guid):
time.sleep(0.5)
fake_result = controller.trace(app.guid, "fake")
self.assertEquals(controller.get_factory_id(node1.guid), "Node")
controller.stop()
+ stopped_time = controller.stopped_time
+ self.assertTrue(stopped_time < time.time())
controller.shutdown()
def test_daemonized_controller_integration(self):
controller = proxy.create_experiment_controller(xml, access_config)
controller.start()
+ started_time = controller.started_time
+ self.assertTrue(started_time < time.time())
while not controller.is_finished(app.guid):
time.sleep(0.5)
fake_result = controller.trace(app.guid, "fake")
self.assertEquals(controller.get_factory_id(node1.guid), "Node")
controller.stop()
+ stopped_time = controller.stopped_time
+ self.assertTrue(stopped_time < time.time())
controller.shutdown()
def test_daemonized_testbed_integration(self):