diff --git a/Robot-Framework/config/variables.robot b/Robot-Framework/config/variables.robot
index 069b928..986b98c 100644
--- a/Robot-Framework/config/variables.robot
+++ b/Robot-Framework/config/variables.robot
@@ -44,7 +44,7 @@ Set Variables
Set Global Variable ${ADMIN_VM} admin-vm
Set Global Variable @{VMS} ${GUI_VM} ${CHROME_VM} ${GALA_VM} ${ZATHURA_VM} ${COMMS_VM} ${BUSINESS_VM} ${ADMIN_VM}
- Set Global Variable ${RPI_IP_ADDRESS} ${config['addresses']['measurement_agent']['device_ip_address']}
+ Run Keyword And Ignore Error Set Global Variable ${RPI_IP_ADDRESS} ${config['addresses']['measurement_agent']['device_ip_address']}
IF $BUILD_ID != '${EMPTY}'
${config}= Read Config ../config/${BUILD_ID}.json
diff --git a/Robot-Framework/resources/power_meas_keywords.resource b/Robot-Framework/resources/power_meas_keywords.resource
index 85b4fc5..b02c678 100644
--- a/Robot-Framework/resources/power_meas_keywords.resource
+++ b/Robot-Framework/resources/power_meas_keywords.resource
@@ -8,19 +8,37 @@ Library SSHLibrary
Library DateTime
*** Variables ***
-${ssh_measurement} ${EMPTY}
+${SSH_MEASUREMENT} ${EMPTY}
${start_timestamp} ${EMPTY}
-
*** Keywords ***
+Check variable availability ${variable}
+ ${value}= Get Variable Value ${variable}
+ IF """${value}""" != 'None'
+ RETURN ${True}
+ ELSE
+ RETURN ${False}
+ END
+
Start power measurement
[Documentation] Connect to the measurement agent and run script to start collecting measurement results
[Arguments] ${id}=power_data ${timeout}=200
- Connect to measurement agent
+ ${availability} Check variable availability ${RPI_IP_ADDRESS}
+ IF ${availability}==False
+ Log To Console Power measurement agent IP address not defined. Ignoring all power measurement related keywords.
+ Set Global Variable ${SSH_MEASUREMENT} ${EMPTY}
+ RETURN
+ END
+ ${status} ${connection} Run Keyword And Ignore Error Connect to measurement agent
+ IF $status!='PASS'
+ Set Global Variable ${SSH_MEASUREMENT} ${EMPTY}
+ Power measurement agent not found. Ignoring all power measurement related keywords.
+ RETURN
+ END
# Multiple logging processes not allowed (for now)
Stop recording power
- Start recording power ${id} ${timeout}
+ Start recording power ${id} ${timeout}
Connect to measurement agent
[Documentation] Set up SSH connection to the measurement agent
@@ -29,8 +47,8 @@ Connect to measurement agent
${connection}= Open Connection ${IP} port=${PORT} prompt=\$ timeout=15
${output}= Login username=${LOGIN_PI} password=${PASSWORD_PI}
Should Contain ${output} ${target_output}
- Set Global Variable ${ssh_measurement} ${connection}
- RETURN ${ssh_measurement}
+ Set Global Variable ${SSH_MEASUREMENT} ${connection}
+ RETURN ${SSH_MEASUREMENT}
Start recording power
[Arguments] ${file_name} ${timeout}
@@ -38,35 +56,51 @@ Start recording power
Run Keyword And Ignore Error Execute Command nohup python /home/ghaf/ghaf/ghaf-power-measurement/measure_power.py ${file_name}.csv ${timeout} > output.log 2>&1 & timeout=3
Stop recording power
+ IF ${SSH_MEASUREMENT} == ${EMPTY}
+ Log To Console No connection to power measurement device. Ignoring all power measurement related keywords.
+ RETURN
+ END
Log To Console Stopping power recording
Run Keyword And Ignore Error Execute Command pkill python timeout=3
Get power record
[Arguments] ${file_name}=power_data.csv
- Connect to measurement agent
- SSHLibrary.Get File /home/ghaf/ghaf/power_data/${file_name} ../../../power_measurements/
+ IF ${SSH_MEASUREMENT} == ${EMPTY}
+ Log To Console No connection to power measurement device. Ignoring all power measurement related keywords.
+ RETURN
+ END
+ Run Keyword And Ignore Error Connect to measurement agent
+ Run Keyword And Ignore Error SSHLibrary.Get File /home/ghaf/ghaf/power_data/${file_name} ../../../power_measurements/
Save power measurement interval
[Documentation] Extract measurement data within given time interval
[Arguments] ${file_name} ${start_time} ${end_time}
+ IF ${SSH_MEASUREMENT} == ${EMPTY}
+ Log To Console No connection to power measurement device. Ignoring all power measurement related keywords.
+ RETURN
+ END
Log To Console Extract power data from given time interval
${time_interval} DateTime.Subtract Date From Date ${end_time} ${start_time} exclude_millis=True
IF ${time_interval} < 0
Log To Console Invalid timestamp critera for extracting power data
RETURN
END
- Extract time interval ../../../power_measurements/${file_name} ${start_time} ${end_time}
+ Run Keyword And Ignore Error Extract time interval ../../../power_measurements/${file_name} ${start_time} ${end_time}
Generate power plot
[Documentation] Extract power data from start_timestamp to current time.
... Plot power vs time and save to png file.
[Arguments] ${id} ${test_name}
+ IF ${SSH_MEASUREMENT} == ${EMPTY}
+ Log To Console No connection to power measurement device. Ignoring all power measurement related keywords.
+ RETURN
+ END
${end_timestamp} Get current timestamp
- Switch Connection ${ssh_measurement}
- Get power record ${id}.csv
- Save power measurement interval ${id}.csv '${start_timestamp}' '${end_timestamp}'
- Generate graph power_interval.csv ${test_name}
- Log HTML
+ Switch Connection ${SSH_MEASUREMENT}
+ Run Keyword And Ignore Error Get power record ${id}.csv
+ Run Keyword And Ignore Error Save power measurement interval ${id}.csv '${start_timestamp}' '${end_timestamp}'
+ Run Keyword And Ignore Error Generate graph power_interval.csv ${test_name}
+ Run Keyword And Ignore Error Log HTML
Set start timestamp
${current_time} DateTime.Get Current Date exclude_millis=yes
@@ -79,5 +113,9 @@ Get current timestamp
Log average power
[Arguments] ${file_name}
- ${mean_P} Mean power ${file_name}
+ IF ${SSH_MEASUREMENT} == ${EMPTY}
+ Log To Console No connection to power measurement device. Ignoring all power measurement related keywords.
+ RETURN
+ END
+ ${keyword_status} ${mean_P} Run Keyword And Ignore Error Mean power ${file_name}
# TODO: With the statistics tools of performance testing also average power values could be plotted and monitored