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 7## Build Docker Image 8 9`Note: Prerequisite is to have Docker installed.` 10 111. Create a workspace directory. 12 13 `mkdir ${HOME}/OpenBMC_Automation` 14 152. Change directory to workspace created. 16 17 `cd ${HOME}/OpenBMC_Automation` 18 193. Clone openbmc-build-scripts repository. 20 21 `git clone https://github.com/openbmc/openbmc-build-scripts` 22 234. Change directory to openbmc-build-scripts. 24 25 `cd openbmc-build-scripts` 26 275. Build the Docker image required to execute the robot tests (it may take 28 close to 15 mins for the first time). The default Docker image name is 29 "openbmc/ubuntu-robot-qemu". You can check images using "docker images" 30 command. 31 32 `./scripts/build-qemu-robot-docker.sh` 33 34 ###### *Note: When your Docker is behind a proxy, add the following parameters to the build command (use proper IP and PORT values.)* 35 36 ``` 37 --build-arg http_proxy=<IP>:<PORT> --build-arg https_proxy=<IP>:<PORT> 38 ``` 39 40## Code update process using robot test code 41 421. Change directory to HOME workspace. 43 44 `cd ${HOME}/OpenBMC_Automation` 45 462. Clone openbmc-test-automation repository. 47 48 `git clone https://github.com/openbmc/openbmc-test-automation` 49 503. Execute docker run to initiate BMC code update. 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 66 image file from HOME directory of the system where docker run command 67 is executed: 68 69 ``` 70 docker run --user root \ 71 --env HOME=${HOME} \ 72 --workdir ${HOME} \ 73 --volume ${HOME}/OpenBMC_Automation:${HOME} \ 74 --tty openbmc/ubuntu-robot-qemu python -m robot \ 75 -v OPENBMC_HOST:1.11.222.333 \ 76 -v FILE_PATH:/home/witherspoon-20170614071422.all.tar \ 77 -i Initiate_Code_Update_BMC \ 78 ${HOME}/openbmc-test-automation/extended/code_update/update_bmc.robot 79 ``` 80 814. On code update completion, logs generated from robot framework execution 82 will be available in the following location: 83 84 ``` 85 ${HOME}/OpenBMC_Automation/log.html 86 ${HOME}/OpenBMC_Automation/report.html 87 ${HOME}/OpenBMC_Automation/output.xml 88 ``` 89 90 91## Executing Automation Test 92 931. Execute docker run to execute OpenBMC automation test cases. 94 ###### *Note: This runs a Docker container using openbmc/ubuntu-robot-qemu image.* 95 ###### *Robot test code is extracted and ran on this container using run-robot.sh script.* 96 ``` 97 docker run --user root \ 98 --env HOME=${HOME} \ 99 --env IP_ADDR=<BMC IP> \ 100 --env SSH_PORT=22 \ 101 --env HTTPS_PORT=443 \ 102 --env ROBOT_TEST_CMD="tox -e <System Type> -- <Robot Cmd>" \ 103 --workdir ${HOME} \ 104 --volume ${WORKSPACE}:${HOME} \ 105 --tty openbmc/ubuntu-robot-qemu \ 106 ${HOME}/openbmc-build-scripts/scripts/run-robot.sh 107 ``` 108 109 Example to run entire test suite: 110 111 ``` 112 docker run --user root \ 113 --env HOME=${HOME} \ 114 --env IP_ADDR=1.11.222.333 \ 115 --env SSH_PORT=22 \ 116 --env HTTPS_PORT=443 \ 117 --env ROBOT_TEST_CMD="tox -e witherspoon -- tests" \ 118 --workdir ${HOME} \ 119 --volume ${HOME}/OpenBMC_Automation:${HOME} \ 120 --tty openbmc/ubuntu-robot-qemu \ 121 ${HOME}/openbmc-build-scripts/scripts/run-robot.sh 122 ``` 123 1242. After the execution, test results will be available in below files. 125 126 ``` 127 ${HOME}/OpenBMC_Automation/log.html 128 ${HOME}/OpenBMC_Automation/report.html 129 ${HOME}/OpenBMC_Automation/output.xml` 130 ``` 131