1## Features of OpenBMC Test Automation ##
2
3**Interface Feature List**
4* REST
5* Out-of-band IPMI
6* SSH to BMC and Host OS
7
8**Key Feature List**
9* Power on/off
10* Reboot Host
11* Reset BMC
12* Code update BMC and host
13* Power management
14* Fan controller
15* HTX bootme
16* XCAT execution
17* Network
18* IPMI support (generic and DCMI compliant)
19* Factory reset
20* RAS (Reliability, availability and serviceability)
21* Web UI testing
22* IO storage and EEH (Enhanced Error Handling) testing
23
24**Debugging Supported List**
25* SOL collection
26* FFDC collection
27* Error injection from host
28
29## Installation Setup Guide ##
30* [Robot Framework Install Instruction](https://github.com/robotframework/robotframework/blob/master/INSTALL.rst)
31
32* Miscelleneous
33Packages required to be installed for OpenBmc Automation.
34Install the packages and it's dependencies via `pip`
35
36    REST base packages:
37    ```
38    $ pip install -U requests
39    $ pip install -U robotframework-requests
40    ```
41    SSH and SCP base packages:
42    For more detailed installation instructions see [robotframework-sshlibrary](https://pypi.python.org/pypi/robotframework-sshlibrary)
43    ```
44    $ pip install robotframework-sshlibrary
45    $ pip install robotframework-scplibrary
46    ```
47
48## OpenBMC Test Development ##
49
50These documents contain details on developing OpenBMC test code and debugging.
51
52 - [MAINTAINERS](https://github.com/openbmc/docs/blob/master/MAINTAINERS): OpenBMC code maintainers information.
53 - [CONTRIBUTING.md](CONTRIBUTING.md): Coding guidelines.
54 - [REST-cheatsheet.md](https://github.com/openbmc/docs/blob/master/REST-cheatsheet.md): Quick reference for some common
55   curl commands required for testing.
56 - [README.md](https://github.com/openbmc/phosphor-webui/blob/master/README.md): Web UI setup reference.
57 - [Tools.md](Tools.md): Reference information for helper tools.
58
59## Testing Setup Steps ##
60
61To verify the installation setup is completed and ready to execute.
62
63* Download the openbmc-test-automation repository:
64    ```
65    $ git clone https://github.com/openbmc/openbmc-test-automation
66    $ cd openbmc-test-automation
67    ```
68* Execute basic setup test run:
69    ```
70    $ robot -v OPENBMC_HOST:xx.xx.xx.xx templates/test_openbmc_setup.robot
71    ```
72    where xx.xx.xx.xx is the BMC hostname or IP.
73
74## Test Layout ##
75
76There are several sub-directories within the openbmc-test-automation base which
77contain test suites, tools, templates, etc. These sub-directories are
78classified as follows:
79
80`tests/`: Contains the general test cases for OpenBMC stack functional
81          verification.
82
83`extended/`: Contains test cases for boot testing, network testing,
84             code update testing etc.
85
86`systest/`: Contains test cases for HTX bootme, IO storage and EEH testing.
87
88`xcat/`: Contains test cases for XCAT automation.
89
90`ras/`: Contains test cases for RAS (Reliability, availability and
91        serviceability).
92
93`gui/`: Contains test cases for web UI and security scanning tool automation.
94
95`mnfg/`: Contains test cases for factory reset (DHCP mode) and PGOOD testing.
96
97`tools/`: Contains various tools.
98
99`templates/`: Contains sample code examples and setup testing.
100`
101
102## Quickstart ##
103To run openbmc-automation first you need to install the prerequisite Python
104packages which will help to invoke tests through tox (Note that tox
105version 2.3.1 or greater is required) or via Robot CLI command.
106
107**Robot Command Line**
108
109* Execute all test suites for `tests/`:
110    ```
111    $ robot -v OPENBMC_HOST:xx.xx.xx.xx  tests
112    ```
113* Execute a test suite:
114    ```
115    $ robot -v OPENBMC_HOST:xx.xx.xx.xx  tests/test_basic_poweron.robot
116    ```
117**Tox Command Line**
118
119* Install the python dependencies for tox:
120    ```
121    $ easy_install tox
122    $ easy_install pip
123    ```
124
125* Initialize the following environment variables which will be used during testing:
126    ```
127    $ export OPENBMC_HOST=<openbmc machine ip address>
128    $ export OPENBMC_PASSWORD=<openbmc password>
129    $ export OPENBMC_USERNAME=<openbmc username>
130    $ export OPENBMC_MODEL=[./data/Barreleye.py, ./data/Palmetto.py, etc]
131    $ export IPMI_COMMAND=<Dbus/External>
132    $ export IPMI_PASSWORD=<External IPMI password>
133    ```
134* For tests requiring PDU, set the following environment variables as well:
135    ```
136    $ export PDU_IP=<PDU IP address>
137    $ export PDU_USERNAME=<PDU username>
138    $ export PDU_PASSWORD=<PDU password>
139    $ export PDU_TYPE=<PDU type>
140    $ export PDU_SLOT_NO=<SLOT number>
141    ```
142    Note: For PDU_TYPE we support only synaccess at the moment.
143
144* For QEMU tests, set the following environment variables as well:
145    ```
146    $ export SSH_PORT=<ssh port number>
147    $ export HTTPS_PORT=<https port number>
148    ```
149* For BIOS tests, set the following environment variables as well:
150    ```
151    $ export PNOR_IMAGE_PATH=<path to>/<machine>.pnor
152    ```
153
154* Run tests:
155    ```
156    $ tox -e tests
157    ```
158
159* How to run individual test:
160
161    One specific test:
162    ```
163    $ tox -e default -- --include Power_On_Test  tests/test_basic_poweron.robot
164    ```
165    No preset environment variables, default configuration for all supported
166    systems:
167    ```
168    $ OPENBMC_HOST=x.x.x.x tox -e default -- tests
169    ```
170    No preset environment variables, one test case from a test suite:
171    ```
172    $ OPENBMC_HOST=x.x.x.x tox -e default -- --include Power_On_Test tests/test_basic_poweron.robot
173    ```
174    No preset environment variables, the entire test suite:
175    ```
176    $ OPENBMC_HOST=x.x.x.x tox -e default -- tests
177    ```
178
179    No preset environment variables, the entire test suite excluding test
180    cases using argument file:
181    ```
182    $ OPENBMC_HOST=x.x.x.x tox -e default -- --argumentfile test_lists/skip_test tests
183    ```
184
185    Exclude test list for supported systems:
186    ```
187    Barrleye:  test_lists/skip_test_barreleye
188    Palmetto:  test_lists/skip_test_palmetto
189    Witherspoon:  test_lists/skip_test_witherspoon
190    ```
191
192* How to run CI and CT bucket test:
193
194    Default CI test bucket list:
195    ```
196    $ OPENBMC_HOST=x.x.x.x tox -e default -- --argumentfile test_lists/HW_CI tests
197    ```
198
199    Default CI smoke test bucket list:
200    ```
201    $ OPENBMC_HOST=x.x.x.x tox -e default -- --argumentfile test_lists/CT_basic_run tests
202    ```
203
204* Code update test:
205
206    For BMC code update, download the system type *.ubi.mdt.tar image from
207    https://openpower.xyz/job/openbmc-build/ and run as follows:
208
209    For Witherspoon system:
210    ```
211    $ cd extended/code_update/
212    $ robot -v OPENBMC_HOST:x.x.x.x -v IMAGE_FILE_PATH:<image path>/obmc-phosphor-image-witherspoon.ubi.mtd.tar --include REST_BMC_Code_Update  bmc_code_update.robot
213    ```
214
215    For host code update, download the system type *.pnor.squashfs.tar image
216    from https://openpower.xyz/job/openpower-op-build/ and run as follows:
217
218    For Witherspoon system:
219    ```
220    $ cd extended/code_update/
221    $ robot -v OPENBMC_HOST:x.x.x.x -v IMAGE_FILE_PATH:<image path>/witherspoon.pnor.squashfs.tar --include REST_Host_Code_Update  host_code_update.robot
222    ```
223
224    For manual code update information please refer to [code-update.md](https://github.com/openbmc/docs/blob/master/code-update/code-update.md)
225
226* Run extended tests:
227
228    For loop test (default iteration is 10):
229    ```
230    $ robot -v OPENBMC_HOST:x.x.x.x -v OPENBMC_SYSTEMMODEL:xxxxxx -v ITERATION:n -v LOOP_TEST_COMMAND:xxxxxx extended/full_suite_regression.robot
231    ```
232    Example using tox testing a test suite for 5 times:
233    ```
234    OPENBMC_HOST=x.x.x.x  LOOP_TEST_COMMAND="--argumentfile test_lists/skip_test tests/test_fw_version.robot" ITERATION=5  OPENBMC_SYSTEMMODEL=barreleye tox -e barreleye -- ./extended/full_suite_regression.robot
235    ```
236
237**Jenkins jobs tox commands**
238* HW CI tox command:
239    ```
240    $ OPENBMC_HOST=x.x.x.x tox -e default -- --argumentfile test_lists/HW_CI tests
241    ```
242