Commit fecb5bc4 authored by Reto Da Forno's avatar Reto Da Forno
Browse files

limit for the amount of collected power profiling data added to test config...

limit for the amount of collected power profiling data added to test config validation and duration for test stop script is now logged in dispatcher
parent 2619ff7d
......@@ -19,6 +19,7 @@ setuptime = 120
cleanuptime = 120 ;Seconds needed for test cleanup
pidfolder = /tmp/flocklab/ ;Folder for pid files
allowparalleltests = 0 ;Allow parallel test execution on the same observer if resource conflicts avoided
powerprofilinglimit = 1000000 ;Max number of samples per test (sum accross all observers)
; Observer config
[observer]
......
......@@ -15,6 +15,7 @@ abort = False
#
##############################################################################
def sigterm_handler(signum, frame):
global abort
logger.info("Process received SIGTERM signal.")
abort = True
### END sigterm_handler
......@@ -40,6 +41,7 @@ class StopTestThread(threading.Thread):
try:
logger.debug("Start StopTestThread for observer ID %d" % (self._obsdict_key[self._obskey][1]))
errors = []
starttime = time.time()
# First test if the observer is online and if the SD card is mounted:
cmd = ['ssh', '%s' % (self._obsdict_key[self._obskey][2]), "mount | grep /dev/mmcblk0p1"]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
......@@ -77,7 +79,7 @@ class StopTestThread(threading.Thread):
out, err = p.communicate()
rs = p.returncode
if (rs == flocklab.SUCCESS):
logger.debug("Test stop script on observer ID %s succeeded." %(self._obsdict_key[self._obskey][1]))
logger.debug("Test stop script on observer ID %s succeeded (took %us)." % (self._obsdict_key[self._obskey][1], int(time.time() - starttime)))
elif (rs == 255):
msg = "Observer ID %s is not reachable, thus not able to stop test. Dataloss occurred possibly for this observer." % (self._obsdict_key[self._obskey][1])
errors.append((msg, errno.EHOSTUNREACH, self._obsdict_key[self._obskey][1]))
......
......@@ -48,6 +48,26 @@ def check_obsids(tree, xpathExpr, namespace, obsidlist=None):
### END check_obsids()
##############################################################################
#
# get_sampling_rate
# Extract sampling rate from a powerProfilingConf element
#
##############################################################################
def get_sampling_rate(elem=None, ns=""):
if elem is None:
return None
res = elem.findtext('d:samplingRate', namespaces=ns)
if res:
return int(res)
res = elem.findtext('d:samplingDivider', namespaces=ns)
if res:
return int(64000/int(res))
return 1000 # default sampling rate
### END get_sampling_rate()
##############################################################################
#
# Usage
......@@ -612,6 +632,7 @@ def main(argv):
errcnt = errcnt + 1
# Check simple offset tag
rs = tree.xpath('//d:powerProfilingConf/d:profConf/d:offset', namespaces=ns)
total_samples = 0
for elem in rs:
ppStart = int(elem.text)
elem2 = elem.getparent().find('d:durationMillisecs', namespaces=ns)
......@@ -620,6 +641,7 @@ def main(argv):
else:
elem2 = elem.getparent().find('d:duration', namespaces=ns)
ppDuration = int(elem2.text)
total_samples = total_samples + ppDuration * get_sampling_rate(elem.getparent(), ns)
if (ppStart > testDuration):
if not quiet:
print(("Line %d: element offset: The offset is bigger than the test duration, thus the action will never take place." % (elem.sourceline)))
......@@ -642,6 +664,7 @@ def main(argv):
else:
elem2 = elem.getparent().getparent().find('d:duration', namespaces=ns)
ppDuration = int(elem2.text)
total_samples = total_samples + ppDuration * get_sampling_rate(elem.getparent().getparent(), ns)
if (ppStart > testDuration):
if not quiet:
print(("Line %d: element offsetSecs: The offset is bigger than the test duration, thus the action will never take place." % (elem.sourceline)))
......@@ -670,6 +693,7 @@ def main(argv):
else:
elem2 = elem.getparent().getparent().find('d:duration', namespaces=ns)
ppDuration = int(elem2.text)
total_samples = total_samples + ppDuration * get_sampling_rate(elem.getparent().getparent(), ns)
if (ppStart > testEnd):
if not quiet:
print(("Line %d: element absoluteDateTime: The action is scheduled after the test ends, thus the action will never take place." %(elem.sourceline)))
......@@ -683,6 +707,12 @@ def main(argv):
print(("Line %d: element duration/durationMillisecs: Profiling lasts longer than test." % (elem2.sourceline)))
errcnt = errcnt + 1
# check total number of samples (for now, just multiply the total by the number of observers)
total_samples = total_samples * len(ids)
if total_samples > flocklab.config.getint('tests', 'powerprofilinglimit'):
print(("Invalid combination of power profiling duration and sampling rate: the total amount of data to collect is too large (%d samples requested, limit is %d)." % (total_samples, flocklab.config.getint('tests', 'powerprofilinglimit'))))
errcnt = errcnt + 1
#===========================================================================
# All additional tests finished. Clean up and exit.
#===========================================================================
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment