1725525eaSNan Zhou# OpenBMC Webserver Testing 2725525eaSNan Zhou 3725525eaSNan ZhouThis doc describes what type of functional testing, which contributors should 4725525eaSNan Zhouperform before requesting code reviews, and tips for each type. Contributors 5725525eaSNan Zhoushould add types of testing they performed and their results as "Tested" footers 6725525eaSNan Zhouin commit messages. 7725525eaSNan Zhou 8725525eaSNan Zhou## General Methodology 9725525eaSNan Zhou 10dfa3fdc3SPatrick WilliamsThere are a variety of ways to develop and test bmcweb software changes. Here 11dfa3fdc3SPatrick Williamsare the steps for using the SDK and QEMU. 12dfa3fdc3SPatrick Williams 13dfa3fdc3SPatrick Williams- Follow all 14dfa3fdc3SPatrick Williams [development environment setup](https://github.com/openbmc/docs/blob/master/development/dev-environment.md) 15dfa3fdc3SPatrick Williams directions in the development environment setup document. This will get QEMU 16dfa3fdc3SPatrick Williams started up and you in the SDK environment. 17dfa3fdc3SPatrick Williams- Follow all of the 18dfa3fdc3SPatrick Williams [gerrit setup](https://github.com/openbmc/docs/blob/master/development/gerrit-setup.md) 19725525eaSNan Zhou directions in the gerrit setup document. 20725525eaSNan Zhou- Clone bmcweb from gerrit 21dfa3fdc3SPatrick Williams 22f4f2643aSPatrick Williams ```sh 23725525eaSNan Zhou git clone ssh://openbmc.gerrit/openbmc/bmcweb/ 24725525eaSNan Zhou ``` 25725525eaSNan Zhou 26dfa3fdc3SPatrick Williams- Follow directions in 27dfa3fdc3SPatrick Williams [README.md](https://github.com/openbmc/bmcweb#configuration) to compile 28725525eaSNan Zhou 29725525eaSNan Zhou- Reduce binary size by stripping it when ready for testing 30dfa3fdc3SPatrick Williams 31f4f2643aSPatrick Williams ```sh 32bd1299b7SAushim Nagarkatti arm-openbmc-linux-gnueabi-strip bmcwebd 33725525eaSNan Zhou ``` 34dfa3fdc3SPatrick Williams 35725525eaSNan Zhou **Note:** Stripping is not required and having the debug symbols could be 36dfa3fdc3SPatrick Williams useful depending on your testing. Leaving them will drastically increase your 37dfa3fdc3SPatrick Williams transfer time to the BMC. 38725525eaSNan Zhou 39bd1299b7SAushim Nagarkatti- Copy your bmcweb daemon you want to test to /tmp/ in QEMU 40dfa3fdc3SPatrick Williams 41f4f2643aSPatrick Williams ```sh 42bd1299b7SAushim Nagarkatti scp -P 2222 bmcwebd root@127.0.0.1:/tmp/ 43725525eaSNan Zhou ``` 44dfa3fdc3SPatrick Williams 45dfa3fdc3SPatrick Williams **Special Notes:** The address and port shown here (127.0.0.1 and 2222) 46dfa3fdc3SPatrick Williams reaches the QEMU session you set up in your development environment as 47dfa3fdc3SPatrick Williams described above. 48725525eaSNan Zhou 49725525eaSNan Zhou- Stop bmcweb service within your QEMU session 50dfa3fdc3SPatrick Williams 51f4f2643aSPatrick Williams ```sh 52725525eaSNan Zhou systemctl stop bmcweb 53725525eaSNan Zhou ``` 54dfa3fdc3SPatrick Williams 55bd1299b7SAushim Nagarkatti **Note:** bmcweb daemon supports being started directly in parallel with the 56bd1299b7SAushim Nagarkatti bmcweb running as a service. The standalone bmcweb daemon will be available on 57bd1299b7SAushim Nagarkatti port 18080. An advantage of this is you can compare between the two easily for 58bd1299b7SAushim Nagarkatti testing. In QEMU you would need to open up port 18080 when starting QEMU. Your 59bd1299b7SAushim Nagarkatti curl commands would need to use 18080 to communicate. 60725525eaSNan Zhou 61dfa3fdc3SPatrick Williams- If running within a system that has read-only /usr/ filesystem, issue the 628ece0e45SEd Tanous following commands one time per QEMU boot to make the filesystem writable 63dfa3fdc3SPatrick Williams 64f4f2643aSPatrick Williams ```sh 65725525eaSNan Zhou mkdir -p /var/persist/usr 66725525eaSNan Zhou mkdir -p /var/persist/work/usr 67725525eaSNan Zhou mount -t overlay -o lowerdir=/usr,upperdir=/var/persist/usr,workdir=/var/persist/work/usr overlay /usr 68725525eaSNan Zhou ``` 69725525eaSNan Zhou 70bd1299b7SAushim Nagarkatti- Remove the existing bmcweb daemon from the filesystem in QEMU 71dfa3fdc3SPatrick Williams 72f4f2643aSPatrick Williams ```sh 73bd1299b7SAushim Nagarkatti rm /usr/libexec/bmcwebd 74725525eaSNan Zhou ``` 75725525eaSNan Zhou 76bd1299b7SAushim Nagarkatti- Link to your new bmcweb daemon in /tmp/ 77dfa3fdc3SPatrick Williams 78f4f2643aSPatrick Williams ```sh 79bd1299b7SAushim Nagarkatti ln -sf /tmp/bmcwebd /usr/libexec/bmcwebd 80725525eaSNan Zhou ``` 81725525eaSNan Zhou 82dfa3fdc3SPatrick Williams- Test your changes. bmcweb will be started automatically upon your first REST 83dfa3fdc3SPatrick Williams or Redfish command 84dfa3fdc3SPatrick Williams 85f4f2643aSPatrick Williams ```sh 862f3d9bd0SGunnar Mills curl -c cjar -b cjar -k -H "Content-Type: application/json" -X POST https://127.0.0.1:2443/login -d "{\"data\": [ \"root\", \"0penBmc\" ] }" 87725525eaSNan Zhou curl -c cjar -b cjar -k -X GET https://127.0.0.1:2443/xyz/openbmc_project/state/bmc0 88725525eaSNan Zhou ``` 89725525eaSNan Zhou 90dfa3fdc3SPatrick Williams- Stop the bmcweb service and scp new file over to /tmp/ each time you want to 91dfa3fdc3SPatrick Williams retest a change. 92725525eaSNan Zhou 93725525eaSNan Zhou See the [REST](https://github.com/openbmc/docs/blob/master/REST-cheatsheet.md) 94dfa3fdc3SPatrick Williams and 95dfa3fdc3SPatrick Williams [Redfish](https://github.com/openbmc/docs/blob/master/REDFISH-cheatsheet.md) 96dfa3fdc3SPatrick Williams cheatsheets for valid commands. 97725525eaSNan Zhou 98725525eaSNan Zhou## Types of Changes to Run 99dfa3fdc3SPatrick Williams 100dfa3fdc3SPatrick WilliamsA committer should run tests that exercise all paths changed in the patchset. If 101dfa3fdc3SPatrick Williamsmaking changes to the http core, that are expected to effect all types of 102725525eaSNan Zhouroutes, testing one route of each class (websocket, HTTP get, HTTP post) is 103725525eaSNan Zhourequired. 104725525eaSNan Zhou 105725525eaSNan Zhou## Typical Types of Changes 106725525eaSNan Zhou 107725525eaSNan Zhou### Basic Redfish Robot Test on QEMU 108725525eaSNan Zhou 109dfa3fdc3SPatrick WilliamsRun the 110dfa3fdc3SPatrick Williams[upstream Robot QEMU test](https://github.com/openbmc/openbmc-build-scripts/blob/master/run-qemu-robot-test.sh). 111725525eaSNan ZhouThis test is performed automatically when bumping SRCREV. Ensuring this test 112725525eaSNan Zhoupassing makes your CL less likely to be rolled back while bumping SRCREV of 113725525eaSNan Zhoubmcweb. 114725525eaSNan Zhou 115725525eaSNan Zhou### Websocket 116725525eaSNan Zhou 117725525eaSNan ZhouTurn on the `rest` meson option which provides a websocket route. 118725525eaSNan Zhou 119725525eaSNan Zhou```bash 120725525eaSNan Zhou# run the websocket testing script and verify results 121725525eaSNan Zhou$ python scripts/websocket_test.py --host 1.2.3.4:443 --ssl 122725525eaSNan Zhou``` 123725525eaSNan Zhou 124725525eaSNan Zhou### Redfish Validator 125725525eaSNan Zhou 1268ece0e45SEd TanousCommitters are required to run the 127dfa3fdc3SPatrick Williams[Redfish Validator](https://github.com/DMTF/Redfish-Service-Validator.git) 128725525eaSNan Zhouanytime they make a change to the GET behavior of the redfish tree. The test 129725525eaSNan Zhoumust run on real hardware since the resource tree will be more complete. 130725525eaSNan Zhou 131725525eaSNan Zhou```bash 132*29d7ca98SEd Tanoussudo pip3 install redfish_service_validator 133725525eaSNan Zhou 134725525eaSNan Zhou# run validator and inspect the report for failures 135*29d7ca98SEd Tanousrf_service_validator \ 136725525eaSNan Zhou --auth Session -i https://1.2.3.4:443 \ 137725525eaSNan Zhou -u root -p 0penBmc 138725525eaSNan Zhou``` 139725525eaSNan Zhou 140725525eaSNan ZhouYour change should not introduce any new validator errors. Please include 141725525eaSNan Zhousomething to the effect of "Redfish service validator passing" in your commit 142725525eaSNan Zhoumessage. 143725525eaSNan Zhou 144725525eaSNan Zhou### Error Status 145725525eaSNan Zhou 146725525eaSNan ZhouTest error status for your newly added resources or core codes, e.g., 4xx client 147725525eaSNan Zhouerrors, 5xx server errors. 148