xref: /openbmc/docs/testing/run-test-docker.md (revision 3851536d)
1# Run OpenBMC Test Automation Using Docker
2
3Running OpenBMC automation using Docker involves creating a Docker image and
4then running automation tests inside the Docker container.
5
6## Build Docker Image
7
8`Note: Prerequisite is to have Docker installed.`
9
101. Create a workspace directory.
11
12   `mkdir ${HOME}/OpenBMC_Automation`
13
142. Change directory to workspace created.
15
16   `cd ${HOME}/OpenBMC_Automation`
17
183. Clone openbmc-build-scripts repository.
19
20   `git clone https://github.com/openbmc/openbmc-build-scripts`
21
224. Change directory to openbmc-build-scripts.
23
24   `cd openbmc-build-scripts`
25
265. Build the Docker image required to execute the robot tests (it may take close
27   to 15 mins for the first time). The default Docker image name is
28   "openbmc/ubuntu-robot-qemu". You can check images using "docker images"
29   command.
30
31   `./scripts/build-qemu-robot-docker.sh`
32
33   ###### _Note: When your Docker is behind a proxy, add the following parameters to the build command (use proper IP and PORT values.)_
34
35   ```
36   --build-arg http_proxy=<IP>:<PORT> --build-arg https_proxy=<IP>:<PORT>
37   ```
38
39## Code update process using robot test code
40
411. Change directory to HOME workspace.
42
43   `cd ${HOME}/OpenBMC_Automation`
44
452. Clone openbmc-test-automation repository.
46
47   `git clone https://github.com/openbmc/openbmc-test-automation`
48
493. Execute docker run to initiate BMC code update.
50
51   ###### _Note: Download BMC fw image file (_.all.tar) before executing this. BMC_IMG_PATH below points to this downloaded file.
52
53   ```
54   docker run --user root \
55              --env HOME=${HOME} \
56              --workdir ${HOME} \
57              --volume ${HOME}/OpenBMC_Automation:${HOME} \
58              --tty openbmc/ubuntu-robot-qemu python -m robot \
59                  -v OPENBMC_HOST:<BMC IP> \
60                  -v FILE_PATH:<BMC_IMG_PATH> \
61                  -i Initiate_Code_Update_BMC \
62                  ${HOME}/openbmc-test-automation/extended/code_update/update_bmc.robot
63   ```
64
65   Example to run BMC code update using witherspoon-20170614071422.all.tar image
66   file from HOME directory of the system where docker run command is executed:
67
68   ```
69   docker run --user root \
70              --env HOME=${HOME} \
71              --workdir ${HOME} \
72              --volume ${HOME}/OpenBMC_Automation:${HOME} \
73              --tty openbmc/ubuntu-robot-qemu python -m robot \
74                  -v OPENBMC_HOST:1.11.222.333 \
75                  -v FILE_PATH:/home/witherspoon-20170614071422.all.tar \
76                  -i Initiate_Code_Update_BMC \
77                  ${HOME}/openbmc-test-automation/extended/code_update/update_bmc.robot
78   ```
79
804. On code update completion, logs generated from robot framework execution will
81   be available in the following location:
82
83   ```
84   ${HOME}/OpenBMC_Automation/log.html
85   ${HOME}/OpenBMC_Automation/report.html
86   ${HOME}/OpenBMC_Automation/output.xml
87   ```
88
89## Executing Automation Test
90
911. Execute docker run to execute OpenBMC automation test cases.
92
93   ###### _Note: This runs a Docker container using openbmc/ubuntu-robot-qemu image._
94
95   ###### _Robot test code is extracted and ran on this container using run-robot.sh script._
96
97   ```
98   docker run --user root \
99              --env HOME=${HOME} \
100              --env IP_ADDR=<BMC IP> \
101              --env SSH_PORT=22 \
102              --env HTTPS_PORT=443 \
103              --env ROBOT_TEST_CMD="tox -e <System Type> -- <Robot Cmd>" \
104              --workdir ${HOME} \
105              --volume ${WORKSPACE}:${HOME} \
106              --tty openbmc/ubuntu-robot-qemu \
107                  ${HOME}/openbmc-build-scripts/scripts/run-robot.sh
108   ```
109
110   Example to run entire test suite:
111
112   ```
113   docker run --user root \
114              --env HOME=${HOME} \
115              --env IP_ADDR=1.11.222.333 \
116              --env SSH_PORT=22 \
117              --env HTTPS_PORT=443 \
118              --env ROBOT_TEST_CMD="tox -e witherspoon -- tests" \
119              --workdir ${HOME} \
120              --volume ${HOME}/OpenBMC_Automation:${HOME} \
121              --tty openbmc/ubuntu-robot-qemu \
122                  ${HOME}/openbmc-build-scripts/scripts/run-robot.sh
123   ```
124
1252. After the execution, test results will be available in below files.
126
127   ```
128   ${HOME}/OpenBMC_Automation/log.html
129   ${HOME}/OpenBMC_Automation/report.html
130   ${HOME}/OpenBMC_Automation/output.xml`
131   ```
132