blob: 0f4f314788177228abd3f8dfa706013cb97a4469 [file] [log] [blame]
George Keishing0fff68a2017-04-27 22:25:49 -05001*** Settings ***
2Documentation Keywords for system related test. This is a subset of the
3... utils.robot. This resource file keywords is specifically
4... define for system test use cases.
5
George Keishing91c852f2017-05-03 02:48:21 -05006Library ../lib/gen_robot_keyword.py
George Keishingcff7aa02017-05-16 08:05:10 -05007Library OperatingSystem
George Keishing91c852f2017-05-03 02:48:21 -05008Resource ../extended/obmc_boot_test_resource.robot
George Keishing0fff68a2017-04-27 22:25:49 -05009Resource ../lib/utils.robot
George Keishing91c852f2017-05-03 02:48:21 -050010Resource ../lib/state_manager.robot
George Keishingcff7aa02017-05-16 08:05:10 -050011Resource ../lib/rest_client.robot
George Keishing0fff68a2017-04-27 22:25:49 -050012
George Keishing4ef29082017-05-13 05:01:23 -050013Library OperatingSystem
14Library DateTime
15
George Keishing0fff68a2017-04-27 22:25:49 -050016*** Variables ***
17
George Keishing4ef29082017-05-13 05:01:23 -050018${htx_log_dir_path} ${EXECDIR}${/}logs${/}
19
20
George Keishing0fff68a2017-04-27 22:25:49 -050021*** Keywords ***
22
23Execute Command On OS
24 [Documentation] Execute given command on OS and return output.
25 [Arguments] ${command}
George Keishing91c852f2017-05-03 02:48:21 -050026 # Description of argument(s):
27 # command Shell command to be executed on OS.
George Keishing0fff68a2017-04-27 22:25:49 -050028 ${stdout} ${stderr}= Execute Command ${command} return_stderr=True
29 Should Be Empty ${stderr}
30 [Return] ${stdout}
31
George Keishing0fff68a2017-04-27 22:25:49 -050032Login To OS
33 [Documentation] Login to OS Host.
34 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
35 ... ${os_password}=${OS_PASSWORD}
George Keishingcff7aa02017-05-16 08:05:10 -050036 ... ${alias_name}=os_connection
George Keishing91c852f2017-05-03 02:48:21 -050037 # Description of argument(s):
38 # os_host IP address of the OS Host.
39 # os_username OS Host Login user name.
40 # os_password OS Host Login passwrd.
George Keishingcff7aa02017-05-16 08:05:10 -050041 # alias_name Default OS SSH session connection alias name.
42 # TODO: Generalize alias naming using openbmc/openbmc-test-automation#633
George Keishing0fff68a2017-04-27 22:25:49 -050043
George Keishing91c852f2017-05-03 02:48:21 -050044 Ping Host ${os_host}
George Keishingcff7aa02017-05-16 08:05:10 -050045 Open Connection ${os_host} alias=${alias_name}
George Keishing91c852f2017-05-03 02:48:21 -050046 Login ${os_username} ${os_password}
47
48
George Keishing88366b32017-05-12 13:50:48 -050049Tool Exist
50 [Documentation] Check whether given tool is installed on OS.
51 [Arguments] ${tool_name}
52 # Description of argument(s):
53 # tool_name Tool name whose existence is to be checked.
George Keishing91c852f2017-05-03 02:48:21 -050054 Login To OS
George Keishing88366b32017-05-12 13:50:48 -050055 ${output}= Execute Command On OS which ${tool_name}
56 Should Contain ${output} ${tool_name}
57 ... msg=Please install ${tool_name} tool.
George Keishing91c852f2017-05-03 02:48:21 -050058
59
60Boot To OS
61 [Documentation] Boot host OS.
62 Run Key OBMC Boot Test \ REST Power On
63
64
65Power Off Host
66 [Documentation] Power off host.
67 Run Key OBMC Boot Test \ REST Power Off
George Keishing0fff68a2017-04-27 22:25:49 -050068
George Keishing6fec3ab2017-05-05 10:45:08 -050069
70File Exist On OS
71 [Documentation] Check if the given file path exist on OS.
72 [Arguments] ${file_path}
73 # Description of argument(s):
74 # file_path Absolute file path.
75
76 Login To OS
77 ${out}= Execute Command On OS ls ${file_path}
78 Log To Console \n File Exist: ${out}
79
George Keishing8740a0c2017-05-13 07:19:16 -050080
81Is HTX Running
82 [Documentation] Check if the HTX exerciser is currently running.
83
84 ${status}= Execute Command On OS htxcmdline -status
85 Should Not Contain ${status} Daemon state is <IDLE>
George Keishing4ef29082017-05-13 05:01:23 -050086
87
88Write Log Data To File
89 [Documentation] Write log data to the logs directory.
90 [Arguments] ${data}= ${log_file_path}=
91 # Description of argument(s):
92 # data String buffer.
93 # log_file_path The log file path.
94
95 Create File ${log_file_path} ${data}
96
97
98Collect HTX Log Files
99 [Documentation] Collect status and error log files.
100 # Collects the following files:
101 # HTX error log file /tmp/htxerr
102 # HTX status log file /tmp/htxstats
103
104 # Create logs directory and get current datetime.
105 Create Directory ${htx_log_dir_path}
106 ${cur_datetime}= Get Current Date result_format=%Y%m%d%H%M%S%f
107
108 File Exist On OS /tmp/htxerr
109 ${htx_err}= Execute Command On BMC cat /tmp/htxerr
110 Write Log Data To File
111 ... ${htx_err} ${htx_log_dir_path}/${OS_HOST}${cur_datetime}.htxerr
112
113 File Exist On OS /tmp/htxstats
114 ${htx_stats}= Execute Command On BMC cat /tmp/htxstats
115 Write Log Data To File
116 ... ${htx_stats} ${htx_log_dir_path}/${OS_HOST}_${cur_datetime}.htxstats
117
George Keishingcff7aa02017-05-16 08:05:10 -0500118
119REST Upload File To BMC
120 [Documentation] Upload a file via REST to BMC.
121
122 # Generate 32 MB file size
123 Run dd if=/dev/zero of=dummyfile bs=1 count=0 seek=32MB
124 OperatingSystem.File Should Exist dummyfile
125
126 # Get the content of the file and upload to BMC
127 ${image_data}= OperatingSystem.Get Binary File dummyfile
128
129 # Get REST session to BMC
130 Initialize OpenBMC
131
132 # Create the REST payload headers and data
133 ${data}= Create Dictionary data ${image_data}
134 ${headers}= Create Dictionary Content-Type=application/octet-stream
135 ... Accept=application/octet-stream
136 Set To Dictionary ${data} headers ${headers}
137
138 ${resp}= Post Request openbmc /upload/image &{data}
139 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
140
141 # Delete uploaded image file.
142 # TODO: Delete via REST openbmc/openbmc#1550
143 # Take SSH connection to BMC and switch to BMC connection to perform
144 # the task.
145 &{bmc_connection_args}= Create Dictionary alias=bmc_connection
146 Open Connection And Log In &{bmc_connection_args}
147
148 # Currently OS SSH session is active, switch to BMC connection.
149 Switch Connection bmc_connection
150 Execute Command On BMC rm -f /tmp/images/*
151
152 # Switch back to OS SSH connection.
153 Switch Connection os_connection
154