Enable Qemu test execution
This change addresses the following
- user input SSH and HTTPS port
- consolidate SSH connections in lib
- fix obsolete codes
- update README instructions
Resolves openbmc/openbmc-test-automation#41
Change-Id: I06dd132fb745ebbf035cb0fc583b46542448d126
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/README.md b/README.md
index 9f36c01..0032eec 100755
--- a/README.md
+++ b/README.md
@@ -41,6 +41,11 @@
$ export SYSLOG_IP_ADDRESS=<remote syslog system ip>
$ export SYSLOG_PORT=<remote syslog system port>
+Use the following variables for Qemu test run
+==========================================================
+ $ export SSH_PORT=<ssh port number>
+ $ export HTTPS_PORT=<https port number>
+
```
Run tests
diff --git a/lib/connection_client.robot b/lib/connection_client.robot
new file mode 100755
index 0000000..1e74357
--- /dev/null
+++ b/lib/connection_client.robot
@@ -0,0 +1,26 @@
+*** Settings ***
+Documentation This module is for SSH connection override to QEMU
+... based openbmc systems.
+
+Library SSHLibrary
+Library OperatingSystem
+
+*** Variables ***
+
+*** Keywords ***
+Open Connection And Log In
+ Run Keyword If '${SSH_PORT}' != '${EMPTY}' and '${HTTPS_PORT}' != '${EMPTY}'
+ ... User input SSH and HTTPs Ports
+
+ Run Keyword If '${SSH_PORT}' == '${EMPTY}' Open connection ${OPENBMC_HOST}
+ ... ELSE Run Keyword Open connection ${OPENBMC_HOST} port=${SSH_PORT}
+
+ Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
+
+User input SSH and HTTPs Ports
+ [Documentation] Update the global SSH and HTTPs port variable for QEMU
+ ${port_num}= Convert To Integer ${SSH_PORT}
+ ${SSH_PORT}= Replace Variables ${port_num}
+
+ ${https_num}= Convert To Integer ${HTTPS_PORT}
+ ${AUTH_URI}= Replace Variables https://${OPENBMC_HOST}:${https_num}
diff --git a/lib/ipmi_client.robot b/lib/ipmi_client.robot
index e7d96b4..e043a9e 100755
--- a/lib/ipmi_client.robot
+++ b/lib/ipmi_client.robot
@@ -1,26 +1,21 @@
*** Settings ***
-Documentation This module is for IPMI client for copying ipmitool to
-... openbmc box and execute ipmitool commands.
+Documentation This module is for IPMI client for copying ipmitool to
+... openbmc box and execute ipmitool commands.
Resource ../lib/resource.txt
-
-Library SSHLibrary
-Library OperatingSystem
+Resource ../lib/connection_client.robot
*** Keywords ***
-Open Connection And Log In
- Open connection ${OPENBMC_HOST}
- Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
- Copy ipmitool
-
Run IPMI Command
[arguments] ${args}
+ Copy ipmitool
${output} ${stderr}= Execute Command /tmp/ipmitool -I dbus raw ${args} return_stderr=True
Should Be Empty ${stderr}
set test variable ${OUTPUT} "${output}"
Run IPMI Standard Command
[arguments] ${args}
+ Copy ipmitool
${stdout} ${stderr} ${output}= Execute Command /tmp/ipmitool -I dbus ${args} return_stdout=True return_stderr= True return_rc=True
Should Be Equal ${output} ${0} msg=${stderr}
[return] ${stdout}
diff --git a/lib/resource.txt b/lib/resource.txt
index 2800581..6940d22 100755
--- a/lib/resource.txt
+++ b/lib/resource.txt
@@ -23,6 +23,10 @@
${PDU_PASSWORD} ${EMPTY}
${PDU_SLOT_NO} ${EMPTY}
+# User define input SSH and HTTPS related parameters
+${SSH_PORT} ${EMPTY}
+${HTTPS_PORT} ${EMPTY}
+
*** Keywords ***
Get Inventory Schema
[Arguments] ${machine}
diff --git a/tests/test_ac_cycles.robot b/tests/test_ac_cycles.robot
index 927a354..9cb7251 100644
--- a/tests/test_ac_cycles.robot
+++ b/tests/test_ac_cycles.robot
@@ -2,24 +2,24 @@
Documentation This testsuite is for testing file corruption on hard power cycle
-Resource ../lib/pdu/pdu.robot
-Resource ../lib/utils.robot
+Resource ../lib/pdu/pdu.robot
+Resource ../lib/utils.robot
+Resource ../lib/connection_client.robot
-Library SSHLibrary
+Suite Setup Open Connection And Log In
+Suite Teardown Close All Connections
*** Test Cases ***
Test openbmc buster
[Tags] reboot_tests
- Open Connection And Log In
${output}= Execute Command find /var/lib -type f |xargs -n 1 touch
PDU Power Cycle
Wait For Host To Ping ${OPENBMC_HOST}
Sleep 1min
+
+ # Need to re connect the session
Open Connection And Log In
${stdout} ${stderr} ${rc}= Execute Command echo "hello world" return_stderr=True return_rc=True
Should Be Equal As Integers ${rc} ${0}
*** Keywords ***
-Open Connection And Log In
- Open connection ${OPENBMC_HOST}
- Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
diff --git a/tests/test_association.robot b/tests/test_association.robot
index 5931afe..88e90d0 100755
--- a/tests/test_association.robot
+++ b/tests/test_association.robot
@@ -1,11 +1,14 @@
*** Settings ***
-Documentation This suite is used for testing eventlog association.
+Documentation This suite is used for testing eventlog association.
-Resource ../lib/rest_client.robot
-Resource ../lib/utils.robot
+Resource ../lib/rest_client.robot
+Resource ../lib/utils.robot
+Resource ../lib/connection_client.robot
-Library Collections
-Library SSHLibrary
+Library Collections
+
+Suite Setup Open Connection And Log In
+Suite Teardown Close All Connections
*** Variables ***
@@ -38,7 +41,6 @@
Clear all logs
- Open Connection And Log In
${output}= Execute Command ${CREATE_ERROR_SINGLE_FRU}
${log_list} = Get EventList
@@ -118,12 +120,11 @@
Association with invalid FRU
[Documentation] ***BAD PATH***
- ... Create an error log on invalid FRU and verify
+ ... Create an error log on invalid FRU and verify
... that its does not have any association.\n
Clear all logs
- Open Connection And Log In
${output}= Execute Command ${CREATE_ERROR_INVALID_FRU}
${log_list} = Get EventList
${association_uri} = catenate SEPARATOR= ${log_list[0]} /fru
@@ -140,7 +141,6 @@
Clear all logs
- Open Connection And Log In
${output}= Execute Command ${CREATE_ERROR_NO_FRU}
${log_list} = Get EventList
${association_uri} = catenate SEPARATOR= ${log_list[0]} /fru
@@ -157,7 +157,6 @@
Clear all logs
- Open Connection And Log In
${output}= Execute Command ${CREATE_ERROR_VIRTUAL_SENSOR}
${log_list} = Get EventList
${association_uri} = catenate SEPARATOR= ${log_list[0]} /fru
@@ -174,7 +173,6 @@
${association_uri} = catenate SEPARATOR= ${pre_reboot_log_uri} /fru
${pre_reboot_association_content} = Read Attribute ${association_uri} endpoints
- Open Connection And Log In
${output}= Execute Command /sbin/reboot
Sleep ${SYSTEM_SHUTDOWN_TIME}
Wait For Host To Ping ${OPENBMC_HOST}
@@ -206,10 +204,6 @@
${uri}= catenate SEPARATOR= /org/openbmc/records/events/ ${LOGID}
[return] ${uri}
-Open Connection And Log In
- Open connection ${OPENBMC_HOST}
- Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
-
Clear all logs
${resp} = openbmc post request /org/openbmc/records/events/action/clear data=${NIL}
should be equal as strings ${resp.status_code} ${HTTP_OK}
diff --git a/tests/test_bootpolicy.robot b/tests/test_bootpolicy.robot
index 19637eb..621179d 100644
--- a/tests/test_bootpolicy.robot
+++ b/tests/test_bootpolicy.robot
@@ -2,13 +2,12 @@
Documentation This testsuite is for testing boot policy function.
-Resource ../lib/rest_client.robot
-Resource ../lib/ipmi_client.robot
-Resource ../lib/utils.robot
+Resource ../lib/rest_client.robot
+Resource ../lib/ipmi_client.robot
+Resource ../lib/utils.robot
-Suite Setup Open Connection And Log In
-Suite Teardown Close All Connections
-
+Suite Setup Open Connection And Log In
+Suite Teardown Close All Connections
*** Variables ***
diff --git a/tests/test_eventlog.robot b/tests/test_eventlog.robot
index c294ae5..b71e330 100644
--- a/tests/test_eventlog.robot
+++ b/tests/test_eventlog.robot
@@ -1,14 +1,15 @@
*** Settings ***
-Documentation This suite is used for testing the error logging
-... capability from the host
+Documentation This suite is used for testing the error logging
+... capability from the host
-Resource ../lib/rest_client.robot
-Resource ../lib/utils.robot
+Resource ../lib/rest_client.robot
+Resource ../lib/utils.robot
+Resource ../lib/connection_client.robot
+Library Collections
-Library BuiltIn
-Library Collections
-Library SSHLibrary
+Suite Setup Open Connection And Log In
+Suite Teardown Close All Connections
*** Variables ***
&{NIL} data=@{EMPTY}
@@ -105,7 +106,6 @@
${json} = to json ${resp.content}
${logs_pre_restart}= set variable ${json['data']}
- Open Connection And Log In
${uptime}= Execute Command systemctl restart obmc-phosphor-event.service
Sleep ${10}
@@ -120,7 +120,6 @@
[Tags] CI
${uri}= create a test log
- Open Connection And Log In
${uptime}= Execute Command systemctl restart obmc-phosphor-event.service
Sleep ${10}
@@ -132,7 +131,6 @@
[Documentation] This is for testing event creation after the
... event service is restarted.
[Tags] CI
- Open Connection And Log In
${uptime}= Execute Command systemctl restart obmc-phosphor-event.service
Sleep ${10}
@@ -142,7 +140,6 @@
[Documentation] This testcase is for testing deleted newly created event
... after event service is restarted.
[Tags] CI
- Open Connection And Log In
${uptime}= Execute Command systemctl restart obmc-phosphor-event.service
Sleep ${10}
@@ -163,7 +160,6 @@
[Tags] reboot_tests
${pre_reboot_event}= create a test log
- Open Connection And Log In
${output}= Execute Command /sbin/reboot
Sleep ${SYSTEM_SHUTDOWN_TIME}
Wait For Host To Ping ${OPENBMC_HOST}
@@ -204,7 +200,3 @@
${LOGID} = convert to integer ${json['data']}
${uri}= catenate SEPARATOR= /org/openbmc/records/events/ ${LOGID}
[return] ${uri}
-
-Open Connection And Log In
- Open connection ${OPENBMC_HOST}
- Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
diff --git a/tests/test_networkd.robot b/tests/test_networkd.robot
index 74b2cd3..d4076f5 100755
--- a/tests/test_networkd.robot
+++ b/tests/test_networkd.robot
@@ -3,14 +3,15 @@
... Details of valid interfaces can be found here...
... https://github.com/openbmc/docs/blob/master/rest-api.md
-Resource ../lib/rest_client.robot
-Resource ../lib/ipmi_client.robot
-Resource ../lib/utils.robot
-Library ../lib/pythonutil.py
+Resource ../lib/rest_client.robot
+Resource ../lib/connection_client.robot
+Resource ../lib/utils.robot
+Library ../lib/pythonutil.py
+Suite Setup Open Connection And Log In
+Suite Teardown Close All Connections
-
-*** Test Cases ***
+*** Test Cases ***
Get the Mac address
diff --git a/tests/test_openbmc_service_restart_policy.robot b/tests/test_openbmc_service_restart_policy.robot
index 93b9c44..845958f 100644
--- a/tests/test_openbmc_service_restart_policy.robot
+++ b/tests/test_openbmc_service_restart_policy.robot
@@ -1,12 +1,12 @@
*** Settings ***
-Documentation This testsuites tests the autorestart policy for
-... OpenBMC project
+Documentation This testsuites tests the autorestart policy for
+... OpenBMC project
-Resource ../lib/resource.txt
+Resource ../lib/resource.txt
+Resource ../lib/connection_client.robot
-Library SSHLibrary
-Suite Setup Open Connection And Log In
-Suite Teardown Close All Connections
+Suite Setup Open Connection And Log In
+Suite Teardown Close All Connections
*** Test Cases ***
Test OpenBMC Services Autorestart Policy
@@ -54,7 +54,3 @@
[arguments] ${command}
${stdout} ${stderr} ${rc}= Execute Command ${command} return_stderr=True return_rc=True
[Return] ${stdout} ${stderr} ${rc}
-
-Open Connection And Log In
- Open connection ${OPENBMC_HOST}
- Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
diff --git a/tests/test_syslog.robot b/tests/test_syslog.robot
index 92a5260..3b9a409 100755
--- a/tests/test_syslog.robot
+++ b/tests/test_syslog.robot
@@ -4,10 +4,11 @@
Resource ../lib/rest_client.robot
Resource ../lib/utils.robot
-Resource ../lib/ipmi_client.robot
+Resource ../lib/connection_client.robot
-Library OperatingSystem
-Library SSHLibrary
+Suite Setup Open Connection And Log In
+Suite Teardown Close All Connections
+
*** Variables ***
${INVALID_SYSLOG_IP_ADDRESS} a.ab.c.d
@@ -111,7 +112,6 @@
${old_port}= Read Attribute /org/openbmc/LogManager/rsyslog port
${old_status} = Read Attribute /org/openbmc/LogManager/rsyslog status
- Open Connection And Log In
${output}= Execute Command /sbin/reboot
Sleep ${SYSTEM_SHUTDOWN_TIME}
Wait For Host To Ping ${OPENBMC_HOST}
diff --git a/tests/test_time.robot b/tests/test_time.robot
index f3a061b..f0c0fb3 100755
--- a/tests/test_time.robot
+++ b/tests/test_time.robot
@@ -1,14 +1,13 @@
*** Settings ***
Documentation This suite is for testing System time in Open BMC.
-Resource ../lib/ipmi_client.robot
+Resource ../lib/ipmi_client.robot
-Library OperatingSystem
-Library SSHLibrary
-Library DateTime
+Library OperatingSystem
+Library DateTime
-Suite Setup Open Connection And Log In
-Suite Teardown Close All Connections
+Suite Setup Open Connection And Log In
+Suite Teardown Close All Connections
*** Variables ***
${SYSTEM_TIME_INVALID} 01/01/1969 00:00:00
diff --git a/tests/test_warmreset.robot b/tests/test_warmreset.robot
index 6706410..a1e0ffa 100644
--- a/tests/test_warmreset.robot
+++ b/tests/test_warmreset.robot
@@ -3,10 +3,10 @@
Resource ../lib/rest_client.robot
Resource ../lib/utils.robot
+Resource ../lib/connection_client.robot
-
-Library OperatingSystem
-Library SSHLibrary
+Suite Setup Open Connection And Log In
+Suite Teardown Close All Connections
*** Variables ***
${SYSTEM_SHUTDOWN_TIME} ${5}
@@ -46,7 +46,3 @@
\ log ${ELEMENT}
\ ${found}= Get Lines Matching Pattern ${ELEMENT} *control/bmc*
\ Return From Keyword If '${found}' != '' ${found}
-
-Open Connection And Log In
- Open connection ${OPENBMC_HOST}
- Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
diff --git a/tools/generate_argumentfile.sh b/tools/generate_argumentfile.sh
index ab808de..b888a80 100755
--- a/tools/generate_argumentfile.sh
+++ b/tools/generate_argumentfile.sh
@@ -11,3 +11,5 @@
echo "--variable PDU_SLOT_NO:$PDU_SLOT_NO" >> $ARG_FILE
echo "--variable SYSLOG_IP_ADDRESS:$SYSLOG_IP_ADDRESS" >> $ARG_FILE
echo "--variable SYSLOG_PORT:$SYSLOG_PORT" >> $ARG_FILE
+echo "--variable SSH_PORT:$SSH_PORT" >> $ARG_FILE
+echo "--variable HTTPS_PORT:$HTTPS_PORT" >> $ARG_FILE