Clark Boylan 254bb0f488 Add framework for selenium tests on test slaves.
Fixes bug #996190

Add framework to run selenium tests on the test slaves. This includes
installing the firefox and Xvfb packages, wrapping Horizon selenium
tests with a script that creates an Xvfb X server, and running the
Horizon selenium tests as check tests. The framework assumes selenium
tests will use the WebDriver API and not need any other pieces of
selenium (No selenium server etc).

Change-Id: I4f4cc502276890d617b5baaadf5f8a6eae1ba1ff
2012-07-24 10:08:11 -07:00

211 lines
5.9 KiB
Puppet

class jenkins_slave($ssh_key, $sudo = false, $bare = false, $user = true) {
include pip
if ($user == true) {
jenkinsuser { "jenkins":
ensure => present,
sudo => $sudo,
ssh_key => "${ssh_key}"
}
}
# Packages that all jenkins slaves need
$common_packages = [
"default-jdk", # jdk for building java jobs
"build-essential",
"autoconf",
"automake",
"ccache",
"devscripts",
]
# Packages that most jenkins slaves (eg, unit test runners) need
$standard_packages = [
"apache2",
"asciidoc", # for building gerrit/building openstack docs
"cdbs",
"curl",
"debootstrap",
"dnsmasq-base",
"docbook-xml", # for building openstack docs
"docbook5-xml", # for building openstack docs
"docbook-xsl", # for building openstack docs
"ebtables",
"firefox", # for selenium tests
"gawk",
"graphviz",
"iptables",
"kpartx",
"kvm",
"libapache2-mod-wsgi",
"libcurl4-gnutls-dev",
"libldap2-dev",
"libmysqlclient-dev",
"libsasl2-dev",
"libsqlite3-dev",
"libtool",
"libvirt-bin",
"libxml2-dev",
"libxslt1-dev",
"lxc",
"maven2",
"mercurial", # needed by pip bundle
"mysql-server",
"pandoc", #for docs, markdown->docbook, bug 924507
"parted",
"pep8",
"psmisc",
"pylint",
"python-cheetah",
"python-libvirt",
"python-libxml2",
"python-sphinx",
"python-unittest2",
"python-vm-builder",
"python-zmq", # zeromq unittests (not pip installable)
"python3-all-dev",
"screen",
"sgml-data",
"socat",
"sqlite3",
"swig",
"unzip",
"vlan",
"wget",
"xsltproc", # for building openstack docs
"xvfb", # for selenium tests
"pyflakes"]
if ($bare == false) {
$packages = [$common_packages, $standard_packages]
} else {
$packages = $common_packages
}
package { $packages:
ensure => present,
}
# Packages that need to be installed from pip
$pip_packages = [
"git-review",
"setuptools-git",
"tox"]
package { $pip_packages:
ensure => latest, # we want the latest from these
provider => pip,
require => Class[pip]
}
file { 'profilerubygems':
name => '/etc/profile.d/rubygems.sh',
owner => 'root',
group => 'root',
mode => 644,
ensure => 'present',
source => [
"puppet:///modules/jenkins_slave/rubygems.sh",
],
}
file { 'ccachegcc':
name => '/usr/local/bin/gcc',
ensure => link,
target => '/usr/bin/ccache',
require => Package['ccache'],
}
file { 'ccacheg++':
name => '/usr/local/bin/g++',
ensure => link,
target => '/usr/bin/ccache',
require => Package['ccache'],
}
file { 'ccachecc':
name => '/usr/local/bin/cc',
ensure => link,
target => '/usr/bin/ccache',
require => Package['ccache'],
}
file { 'ccachec++':
name => '/usr/local/bin/c++',
ensure => link,
target => '/usr/bin/ccache',
require => Package['ccache'],
}
if ($bare == false) {
exec { "jenins-slave-mysql":
creates => "/var/lib/mysql/openstack_citest/",
command => "/usr/bin/mysql --defaults-file=/etc/mysql/debian.cnf -e \"\
CREATE USER 'openstack_citest'@'localhost' IDENTIFIED BY 'openstack_citest';\
CREATE DATABASE openstack_citest;\
GRANT ALL ON openstack_citest.* TO 'openstack_citest'@'localhost';\
FLUSH PRIVILEGES;\"",
require => [
File["/etc/mysql/my.cnf"], # For myisam default tables
Package["mysql-server"],
Service["mysql"]
]
}
file { "/etc/mysql/my.cnf":
source => 'puppet:///modules/jenkins_slave/my.cnf',
owner => 'root',
group => 'root',
ensure => 'present',
replace => 'true',
mode => 444,
require => Package["mysql-server"],
}
service { "mysql":
name => "mysql",
ensure => running,
enable => true,
subscribe => File["/etc/mysql/my.cnf"],
require => [File["/etc/mysql/my.cnf"], Package["mysql-server"]]
}
}
file { '/usr/local/jenkins':
owner => 'root',
group => 'root',
mode => 755,
ensure => 'directory',
}
file { '/usr/local/jenkins/slave_scripts':
owner => 'root',
group => 'root',
mode => 755,
ensure => 'directory',
recurse => true,
require => File['/usr/local/jenkins'],
source => [
"puppet:///modules/jenkins_slave/slave_scripts",
],
}
# Temporary for debugging glance launch problem
# https://lists.launchpad.net/openstack/msg13381.html
file { '/etc/sysctl.d/10-ptrace.conf':
ensure => present,
source => "puppet:///modules/jenkins_slave/10-ptrace.conf",
owner => 'root',
group => 'root',
mode => 444,
}
exec { "ptrace sysctl":
subscribe => File['/etc/sysctl.d/10-ptrace.conf'],
refreshonly => true,
command => "/sbin/sysctl -p /etc/sysctl.d/10-ptrace.conf",
}
}