Enable basic infrastructure for clock testing
What infrastructure support is enabled
- Added keywords to set time owner and mode.
- Added basic test cases to set valid/invalid time owner
- Added basic test cases to set valid/invalid time mode
- Sets default value after test case execution
Resolves openbmc/openbmc-test-automation#58
Change-Id: Ia7ec2ea84a7457248a36c23a129537d87bd18bf5
Signed-off-by: Rahul Maheshwari <rahulmaheshwari@in.ibm.com>
diff --git a/tests/test_time.robot b/tests/test_time.robot
index fe90337..126aee0 100755
--- a/tests/test_time.robot
+++ b/tests/test_time.robot
@@ -1,6 +1,7 @@
*** Settings ***
Documentation This suite is for testing System time in Open BMC.
+Resource ../lib/rest_client.robot
Resource ../lib/ipmi_client.robot
Resource ../lib/openbmc_ffdc.robot
@@ -9,7 +10,7 @@
Suite Setup Open Connection And Log In
Suite Teardown Close All Connections
-Test Teardown FFDC On Test Case Fail
+Test Teardown Post Test Execution
*** Variables ***
${SYSTEM_TIME_INVALID} 01/01/1969 00:00:00
@@ -62,11 +63,118 @@
${msg}= Run Keyword And Expect Error * Run IPMI Standard Command sel time set ""
Should Start With ${msg} Specified time could not be parsed
+Set NTP Time Mode
+ [Documentation] ***GOOD PATH***
+ ... This testcase is to set time mode as NTP using REST
+ ... URI and then verify using REST API.\n
+ [Tags] Set_NTP_Time_Mode
+
+ Set Time Mode NTP
+
+ ${boot} = Read Attribute /org/openbmc/settings/host0 time_mode
+ Should Be Equal ${boot} NTP
+
+Set Manual Time Mode
+ [Documentation] ***GOOD PATH***
+ ... This testcase is to set time mode as manual using REST
+ ... URI and then verify using REST API.\n
+ [Tags] Set_Manual_Time_Mode
+
+ Set Time Mode Manual
+
+ ${boot} = Read Attribute /org/openbmc/settings/host0 time_mode
+ Should Be Equal ${boot} Manual
+
+Set Time Owner as BMC
+ [Documentation] ***GOOD PATH***
+ ... This testcase is to set time owner as BMC using REST
+ ... URI and then verify using REST API.\n
+ [Tags] Set_Time_Owner_as_BMC
+
+ Set Time Owner BMC
+
+ ${boot} = Read Attribute /org/openbmc/settings/host0 time_owner
+ Should Be Equal ${boot} BMC
+
+Set Time Owner as Host
+ [Documentation] ***GOOD PATH***
+ ... This testcase is to set time owner as Host using REST
+ ... URI and then verify using REST API.\n
+ [Tags] Set_Time_Owner_as_Host
+
+ Set Time Owner Host
+
+ ${boot} = Read Attribute /org/openbmc/settings/host0 time_owner
+ Should Be Equal ${boot} Host
+
+Set Invalid Time Mode
+ [Documentation] ***BAD PATH***
+ ... This testcase is to verify that invalid value for time
+ ... mode can not be set and proper error is thrown by
+ ... REST API for the same.
+ [Tags] Set_Invalid_Time_Mode
+
+ ${resp} = Set Time Mode abc
+ Should Be Equal ${resp} error
+
+ ${boot} = Read Attribute /org/openbmc/settings/host0 time_mode
+ Should Not Be Equal ${boot} abc
+
+Set Invalid Time Owner
+ [Documentation] ***BAD PATH***
+ ... This testcase is to verify that invalid value for time
+ ... owner can not be set and proper error is thrown by
+ ... REST API for the same.
+ [Tags] Set_Invalid_Time_Owner
+
+ ${resp} = Set Time Owner xyz
+ Should Be Equal ${resp} error
+
+ ${boot} = Read Attribute /org/openbmc/settings/host0 time_owner
+ Should Not Be Equal ${boot} xyz
+
+
*** Keywords ***
Get BMC Time And Date
- ${stdout} ${stderr} ${output}= Execute Command date "+%m/%d/%Y %H:%M:%S" return_stdout=True return_stderr= True return_rc=True
+ ${stdout} ${stderr} ${output}=
+ ... Execute Command date "+%m/%d/%Y %H:%M:%S"
+ ... return_stdout=True return_stderr= True return_rc=True
Should Be Equal ${output} ${0} msg=${stderr}
- ${resp}= Convert Date ${stdout} date_format=%m/%d/%Y %H:%M:%S exclude_millis=yes
+
+ ${resp}= Convert Date ${stdout} date_format=%m/%d/%Y %H:%M:%S
+ ... exclude_millis=yes
Should Not Be Empty ${resp}
[return] ${resp}
+
+Set Time Owner
+ [Arguments] ${args}
+ ${timeowner} = Set Variable ${args}
+ ${valueDict} = create dictionary data=${timeowner}
+
+ ${resp} = OpenBMC Put Request
+ ... /org/openbmc/settings/host0/attr/time_owner data=${valueDict}
+ ${jsondata} = to json ${resp.content}
+ [return] ${jsondata['status']}
+
+Set Time Mode
+ [Arguments] ${args}
+ ${timemode} = Set Variable ${args}
+ ${valueDict} = create dictionary data=${timemode}
+
+ ${resp} = OpenBMC Put Request
+ ... /org/openbmc/settings/host0/attr/time_mode data=${valueDict}
+ ${jsondata} = to json ${resp.content}
+ [return] ${jsondata['status']}
+
+
+Post Test Execution
+ [Documentation] Perform operations after test execution. It first try to
+ ... capture FFDC in case of test case failure. Later it sets
+ ... default values for time mode and owner.
+
+ Run Keyword If Test Failed FFDC On Test Case Fail
+
+ Set Time Mode NTP
+
+ Set Time Owner BMC