Installing an Autotest server (including web frontend and scheduler)
- You must have Python2.4 and Apache2 installed
- Install necessary packages
sudo apt-get install mysql-server mysql-common libapache2-mod-python python-mysqldb gnuplot
Install Java if necessary (be sure that you're using Sun's JVM, not gcj). Directions for Ubuntu are at https://help.ubuntu.com/community/Java.
- Create an autotest user and a directory for autotest install
sudo adduser autotest cd /usr/local/ sudo mkdir autotest sudo chown autotest:autotest autotest su autotest
Note: it's assumed that the autotest user will be able to do a password-less ssh as root into any machines under test. For more info, try Google.
- checkout the full Autotest repository
svn co svn://test.kernel.org/autotest/trunk /usr/local/autotest
- Set up MySQL
mysql -u root -p mysql> create database autotest_web; mysql> grant all privileges on autotest_web.* TO 'autotest'@'localhost' identified by 'mypassword'; mysql> grant SELECT on autotest_web.* TO 'nobody'@'%'; mysql> grant all privileges on test_autotest_web.* to 'autotest'@'localhost' identified by 'mypassword'; mysql> create database tko; mysql> grant all privileges on tko.* TO 'autotest'@'localhost' identified by 'mypassword'; mysql> grant SELECT on tko.* TO 'nobody'@'%'; mysql> grant all privileges on test_tko.* to 'autotest'@'localhost' identified by 'mypassword';
If you want mysql available to hosts other than the localhost, you'll then want to comment out the bind-address = 127.0.0.1 line in the /etc/mysql/my.cnf. In addition, you may want to increase the set-variable = max_connections to something like 500, if you're running on a substantial server.
Install Django 0.96. The full instructions are here, but here's the abbreviated version:
wget http://www.djangoproject.com/download/0.96.2/tarball/ tar xzf Django-0.96.2.tar.gz cd Django-0.96.2 sudo python setup.py install
Install Google Web Toolkit. You'll need version 1.5. Full instructions are here, the short version is:
wget http://google-web-toolkit.googlecode.com/files/gwt-linux-1.5.0.tar.bz2 tar xjf gwt-linux-1.5.0.tar.bz2 sudo mv gwt-linux-1.5.0/ /usr/local/lib/gwt sudo chown -R nobody /usr/local/lib/gwt
- Setup Apache config files. If the only thing you want to do with Apache is run Autotest, you can use the premade Apache conf:
sudo rm /etc/apache2/sites-enabled/000-default sudo ln -s /usr/local/autotest/apache/conf/apache-conf /etc/apache2/sites-enabled/001-autotest
If you want to do other things on the Apache server as well, you'll need to insert the following line into your Apache conf, under the appropriate VirtualHost section:
Include "/usr/local/autotest/apache/conf/all-directives"
Note: You will have to enable mod_env on SuSE based distro's for the all-directives to load properly when apache is started.You'll also need to comment out the following in your /etc/apache2/apache2.conf or /etc/apache2/mod_autoindex-defaults.conf for SuSE based systems (because there's no way to override it in subpaths - it's just a broken "feature" of Apache):
IndexIgnore .??* *~ *# HEADER* RCS CVS *,t
And uncomment the following line:AddHandler cgi-script .cgi
- Edit/create various settings files. This includes
global_config.ini - edit database settings for frontend DB.
shadow_config.ini - useful if running a server and want to restrict write access to the DB. In this case should chmod 600 this file.
[TKO] host: localhost database: tko db_type: mysql user: nobody password: [AUTOTEST_WEB] host: localhost database: autotest_web db_type: mysql user: nobody password: [SCHEDULER] notify_email:admin@yourbox.com
- Run DB migrations to set up DB schemas and initial data:
cd /usr/local/autotest/frontend && ../migrate/migrate.py --database=AUTOTEST_WEB sync cd /usr/local/autotest/tko && ../migrate/migrate.py --database=TKO sync
If you have an existing database with data in it, you may want to use "safesync" instead of "sync". This will copy your data to a fresh DB and run the migration on that first, to ensure no errors occur during migration that could leave your database in an inconsistent state. - Compile the Autotest web client:
/usr/local/autotest/frontend/client/AfeClient-compile
You will need to re-compile after any changes/syncs of the frontend/client pages. - Run Django's syncdb. You'll need to run it *twice* the first time - this is just a quirk of the way syncdb works which we haven't quite worked around yet.
/usr/local/autotest/frontend/manage.py syncdb /usr/local/autotest/frontend/manage.py syncdb
Make everything in the /usr/local/autotest directory world-readable, for Apache's sake:
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
- You may have to also ensure the Django source directory is all world-readable. This is a bit of a mystery, but it happens.
chmod -R o+r /usr/lib/python2.4/site-packages/django
- If you update your installation, make sure you re-run these commands. For example, any new .py files that were added may not have o+r permission, which will show up as import errors when trying to access these files.
- You may have to also ensure the Django source directory is all world-readable. This is a bit of a mystery, but it happens.
- Restart apache
sudo apache2ctl restart
Check that the web frontend is working by browsing to http://localhost/afe/server/rpc/. If you see an error or exception traceback, you need to go back and fix something.
Once that works, you should be able to access the web frontend at http://localhost/afe/.
- To start the scheduler, you can run something like this (as user autotest):
/usr/local/autotest/scheduler/monitor_db.py /usr/local/autotest/results
Adding some initial frontend objects
Once you've got the frontend working, you'll want to add some objects so you can schedule some jobs.
- Click the "Admin interface" link at the upper-right corner of the frontend.
- Click "Labels" and then "Add label".
- Type a name for the label, and check the "Platform" box, then click "Save".
- Click "Home" at the upper-left corner, and click "Hosts" and then "Add host".
Type in a hostname, add your platform to the "chosen labels", and click "Save". If you want your job to succeed, you'll need to set things up so that the autotest user can ssh to the hostname you provide without needing a password.
- Click "Home", and click "Tests" and then "Add test".
- Fill in the following information:
Name: sleeptest
Test class: Kernel
Test type: Client
Path: client/tests/sleeptest/control
- Now click "Go to Frontend" at the upper-right corner.
You should now be able to create a job on the "Create Job" tab, submit it, and see it in the "Job List" and "View Job" tabs. You can also see the status of your host on the "Hosts" tab.
Updating after code upgrades
To ensure proper behavior, after upgrading the web frontend code (from svn up, etc.), you should sync the database, recompile the client, and restart Apache and the scheduler:
cd /usr/local/autotest/frontend && ../migrate/migrate.py --database=AUTOTEST_WEB sync /usr/local/autotest/frontend/client/ClientMain-compile sudo apache2ctl restart
If you've got existing Firefox sessions with the frontend open, it's a good idea to shift-refresh them. If you're running a scheduler, you should also restart it after upgrading:
killall monitor_db /usr/local/autotest/scheduler/monitor_db --notify=myemail@mydomain.com /usr/local/autotest/results
Additional Tips
Some really old distributions have similarly ancient SSH implementations. If so, it can take hours for a SSH connection to timeout if a machine dies. You can modify your /etc/sysctl.conf to contain the line net.ipv4.tcp_keepalive_time = 60 to reduce this time to around 10 minutes. This is typically unnecessary, though.
Most autotest installations are going to be using SSH Keys and not passwords, as such "PasswordAuthentication no" should be added to your autotest user's .ssh/config for quicker failure of jobs due to authentication
- You'll probably want to back up your results filesystem and mysql db on a regular basis. A cron job is a simple way to accomplish this.
See also:
Parse is used to import results into TKO
WebFrontendHowTo talks about using the frontend
WebFrontendDevelopment talks about setting up for frontend development work - you do not want to develop through Apache!
