To provide all the information needed about the current state of Enterprise autotest automation. Current coverage, location of tests, how to execute the tests, what machine to run the tests on, test breakdown, etc.
Calculating coverage could be tricky as there are many different ways it could be done. We were using two ways to do it:
Tests that automate user policies are located here.
Tests that automate device policies are located here.
Most of Enterprise tests start with policy_ but there are some that begin with enterprise_.
A test can be executed using this command from chroot: test_that --board=BOARD_NAME IP_ADDRESS FULL_TEST_NAME Example: /trunk/src/scripts $ test_that --board=hana 100.107.106.138 policy_DeviceServer.AllowBluetooth_true
--board - should be the board that you have setup locally. You only need to setup the board ones and you shouldn’t have to touch it again for a long time. The board that you setup on your workstation doesn’t have to match the DUT(device under test) board that you’re executing the test on. To set up the board please follow instructions here. You will also need to run the build_packages command.
IP_ADDRESS - IP of the DUT. If you have a device locally, it needs to be plugged into the test network and not corp network. You can also use a device in the lab. To reserve a device from the lab please follow these steps:
Full test name - test name can be grabbed from the control file. Example.
You can check other options for test_that by running: test_that --help.
To run a test on a local DUT you need to make sure the DUT has been properly setup with a test build. You can use this helpful tool. Execute from this dir: /chromiumos/src/platform/crostestutils/provingground$ Run this command to put the build on a USB stick: ./crosdl.py -c dev -t -b 12503.0.0 -p sarien --to_stick /dev/sda Or this command to update the DUT directly(flaky): ./crosdl.py -c dev -t -b 12105.54.0 -p sarien --to_ip 100.107.106.132
To find out the right build number, please use goldeneye and search for the right build for your board.
A typical dir for a user policy(client) test will consist of control files and a .py test file. A control file will contain basic description of the test as well as options such as these: '''python AUTHOR = 'name’ NAME = 'full_test_name' ATTRIBUTES = 'suite:ent-nightly, suite:policy' TIME = 'SHORT' TEST_CATEGORY = 'General' TEST_CLASS = 'enterprise' TEST_TYPE = 'client' '''
Example of a basic test. Class name of the test, policy_ShowHomeButton has to match the name of the .py file.
run_once - function that gets called first. setup_case - sets up DMS, logs in, verifies policies values and various other login arguments. Defined:enterprise_policy_base start_ui_root - needed if you’re planning on interacting with UI objects during your test. Defined:ui_utils. This CL describes what ui_utils is based off and the usefulness of it.
check_home_button - Function that verifies the presence of the Home button in this test. Depending on the policy setting, the test is using ui.item_present to verify the status of the Home button.
Every enterprise test will require a run_once function and will most likely require setup_case. You will need to pass in a dictionary with the policy name and value into setup_case.
This utils.py file which contains many useful functions that you’ll come across in tests.
Some examples: poll_for_condition - keeps checking for condition to be true until a time limit is reached at which point it fails. run - allows to run a VT2 command on the DUT.
On top of having a control file and a .py test file like you do for a user policy test you will also need another control file and another .py server file to kick off the client test. Example of the control file. Example of the .py server file.