Setup Autotest Server

This document will go over how to set up a local Autotest server for developing purposes.  

Note that there is a script which helps to automate this process: src/third_party/autotest/files/site_utils/setup_dev_autotest.sh

You will want to do this for changes that are not easily testable in the production server. Generally this will not be needed for test development. This is if you are changing RPCs, The Scheduler, Any of the frontend GUI or common library changes. 


Debian/Ubuntu

These instructions will only work with a Debian based installation. Most likely you can use the package names to set up Autotest for Fedora/Redhat.


Base deb packages to install

After installing all of the packages below you will end up with a server running MySQL, Apache, and have the supporting libraries need to bootstrap the Autotest installation. 

**Be sure to remember the password you set up for the root user in Mysql (If any)

 sudo apt-get install mysql-server mysql-common libapache2-mod-python python-mysqldb gnuplot apache2-mpm-prefork unzip python-imaging libpng12-dev libfreetype6-dev sqlite3 python-pysqlite2 git-core pbzip2 openjdk-6-jre openjdk-6-jdk python-crypto  python-dev subversion build-essential python-setuptools

*Note you will be prompted to enter a 'root' user password for MySQL this is reserved for administering the MySQL instance itself. You should not use this for the next section but do not forget it either.

Setup MySQL DBs

Autotest use MySQL for all of its result storing and queuing jobs for the scheduler to interface with. 

Setup the Autotest MYSQL user:

mysql -u root -p
create database chromeos_autotest_db;
grant all privileges on chromeos_autotest_db.* TO 'chromeosqa-admin'@'localhost' identified by 'some_password'; 
FLUSH PRIVILEGES;

*some_password can be whatever you want. Make note of it as you will need it later on.

Setup Autotest Directory on the server

NOTE: Do not try to make the autotest server run directly from your home directory and DO follow the "/usr/local/autotest" bind mount or checkout. Changing all the paths in the source and making it work at the same time seems downright impossible.

*Preferred way, if you have a Chromium OS checkout you should already have the Autotest soure.

CHECKOUT=/your/chromiumos/checkout
mkdir /usr/local/autotest
sudo mount --bind $CHECKOUT/src/third_party/autotest/files /usr/local/autotest


If you don't have a Chromium OS checkout and just want the Autotest bits:
mkdir /usr/local/autotest
git clone http://git.chromium.org/chromiumos/third_party/autotest.git /usr/local/autotest

Edit the global_config.ini, or better yet, create a shadow configuration (place it in shadow_config.ini) to update the following areas:

[AUTOTEST_WEB]
  • host, set it to localhost
  • user, chromeosqa-admin, as set above
  • password, set it to the password you set, in this doc that would be some_password
  • readonly_host, set it to localhost
  • readonly_user, set it to chromeosqa-admin
  • readonly_password, set this to the password you set, in this doc that would be some_password
[SERVER]
  • hostname, set it to localhost

Build external packages for use in Autotest


# Run this as the user you want to run the Autotest server as. 

/usr/local/autotest/utils/build_externals.py
/usr/local/autotest/utils/compile_gwt_clients.py -a


Setup Initial db

/usr/local/autotest/database/migrate.py sync
/usr/local/autotest/frontend/manage.py syncdb
# You may have to run this twice. 
/usr/local/autotest/frontend/manage.py syncdb

Setup Apache

If you ran the above package install command you should already have a running apache server. All we need to do is point that configuration at the Autotest configuration. 


sudo ln -s /usr/local/autotest/apache/apache-conf /etc/apache2/sites-available/autotest-server
# disable currently active default
sudo a2dissite default
# enable autotest server
sudo a2ensite autotest-server
# Enable rewrite module
sudo a2enmod rewrite
# Enable mod-python
sudo a2enmod python
# Setup permissions so that Apache web user can read the proper files. 
chmod -R o+r /usr/local/autotest
find /usr/local/autotest/ -type d | xargs chmod o+x
chmod o+x /usr/local/autotest/tko/*.cgi
# restart server
sudo /etc/init.d/apache2 restart


Import Tests Add Hosts and Start Scheduler

Import tests

/usr/local/autotest/utils/test_importer.py

***This is the end of what is done for you by setup_dev_autotest.sh.***

Add hosts

/usr/local/autotest/cli/atest host create hostname

Start the scheduler.

*You may want to run the scheduler in screen

/usr/local/autotest/scheduler/monitor_db.py /usr/local/autotest/results


SSH Keys for connecting to devices

The user that started the scheduler needs to have root access to the devices you are connecting to. All test images include a authorized key that developers have access to. 

You can get the key from the chromiumos checkout under chromiumos/src/scripts/mod_for_test_scripts/ssh_keys/testing_rsa 


If the user you are using is specifically for testing you can add this key in the default ssh key path under ~/.ssh/id_rsa and it will automatically get used when connections are tried to any computer with SSH.

If this is not an option you need to either set up an SSH agent (http://upc.lbl.gov/docs/user/sshagent.shtml) or configure your ~/.ssh/config file to use the testing_rsa key above when specific hosts are connected to.

Example host entry in ~/.ssh/config

Host 172.12.12.55
   User root
   IdentityFile %d/.ssh/testing_rsa

You can test any of these set ups by trying to connect to the system as root:

ssh root@172.12.12.55


Viewing test logs from jobs run via the scheduler

To view logs of a currently running job from the AFE click on the "Debug logs" link. From there you have a few different choices, you will most likely want to look at all the logs which are all in autoserv.DEBUG. Although this file does not automatically update when viewed in your browser if you refresh your view you will see the progress of the job.

All logs from jobs run via the scheduler are stored under: /usr/local/autotest/results. 

If you get 403 Forbidden when viewing the results, or if the AFE starts giving Error 500 and strugging to import code, then you either need to re-run

# Setup permissions so that Apache web user can read the proper files. 
chmod -R o+r /usr/local/autotest
find /usr/local/autotest/ -type d | xargs chmod o+x
chmod o+x /usr/local/autotest/tko/*.cgi

Or (recommended) edit /etc/apache2/envvars so that it reads

export APACHE_RUN_USER=<user>
export APACHE_RUN_GROUP=<group>

where <user> is what is returned by running |id -un| and <group> is the result of running |id -gn|

Comments