Merge branch 'feature/Vagrant-testing-software-4219'

This commit is contained in:
Marius Hein 2013-06-11 11:46:17 +02:00
commit 2c5f9e7c14
8 changed files with 326 additions and 0 deletions

View File

@ -0,0 +1 @@
export PATH="$PATH:/usr/local/bin"

View File

@ -240,3 +240,75 @@ exec { 'populate-openldap':
require => [Service['slapd'], File['openldap/db.ldif'],
File['openldap/dit.ldif'], File['openldap/users.ldif']]
}
class { 'phantomjs':
url => 'https://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-x86_64.tar.bz2',
output => 'phantomjs-1.9.1-linux-x86_64.tar.bz2',
creates => '/usr/local/phantomjs'
}
class { 'casperjs':
url => 'https://github.com/n1k0/casperjs/tarball/1.0.2',
output => 'casperjs-1.0.2.tar.gz',
creates => '/usr/local/casperjs'
}
file { '/etc/profile.d/env.sh':
source => 'puppet:////vagrant/.vagrant-puppet/files/etc/profile.d/env.sh'
}
include epel
exec { 'install PHPUnit':
command => 'yum -d 0 -e 0 -y --enablerepo=epel install php-phpunit-PHPUnit',
unless => 'rpm -qa | grep php-phpunit-PHPUnit',
require => Class['epel']
}
exec { 'install PHP CodeSniffer':
command => 'yum -d 0 -e 0 -y --enablerepo=epel install php-pear-PHP-CodeSniffer',
unless => 'rpm -qa | grep php-pear-PHP-CodeSniffer',
require => Class['epel']
}
exec { 'install nodejs':
command => 'yum -d 0 -e 0 -y --enablerepo=epel install npm',
unless => 'rpm -qa | grep ^npm',
require => Class['epel']
}
exec { 'install npm/mocha':
command => 'npm install -g mocha',
creates => '/usr/lib/node_modules/mocha',
require => Exec['install nodejs']
}
exec { 'install npm/mocha-cobertura-reporter':
command => 'npm install -g mocha-cobertura-reporter',
creates => '/usr/lib/node_modules/cobertura',
require => Exec['install npm/mocha']
}
exec { 'install npm/jshint':
command => 'npm install -g jshint',
creates => '/usr/lib/node_modules/jshint',
require => Exec['install nodejs']
}
exec { 'install npm/expect':
command => 'npm install -g expect',
creates => '/usr/lib/node_modules/expect',
require => Exec['install nodejs']
}
exec { 'install npm/should':
command => 'npm install -g should',
creates => '/usr/lib/node_modules/should',
require => Exec['install nodejs']
}
exec { 'install ZendFramework':
command => 'yum -d 0 -e 0 -y --enablerepo=epel install php-ZendFramework',
unless => 'rpm -qa | grep php-ZendFramework',
require => Class['epel']
}

View File

@ -0,0 +1,66 @@
# Class: casperjs
#
# This module downloads, extracts, and installs casperjs tar.gz archives
# using wget and tar.
#
# Parameters:
# [*url*] - fetch archive via wget from this url.
# [*output*] - filename to fetch the archive into.
# [*creates*] - target directory the software will install to.
#
# Actions:
#
# Requires:
#
# Sample Usage:
#
# class {'casperjs':
# url => 'https://github.com/n1k0/casperjs/tarball/1.0.2',
# output => 'casperjs-1.0.2.tar.gz',
# creates => '/usr/local/casperjs'
# }
#
class casperjs(
$url,
$output,
$creates
) {
Exec { path => '/usr/bin:/bin' }
$cwd = '/usr/local/src'
include wget
exec { 'download-casperjs':
cwd => $cwd,
command => "wget -q ${url} -O ${output}",
creates => "${cwd}/${output}",
timeout => 120,
require => Class['wget']
}
$tld = inline_template('<%= File.basename(output, ".tar.bz2") %>')
$src = "${cwd}/casperjs"
exec { 'extract-casperjs':
cwd => $cwd,
command => "mkdir -p casperjs && tar --no-same-owner \
--no-same-permissions -xzf ${output} -C ${src} \
--strip-components 1",
creates => $src,
require => Exec['download-casperjs']
}
file { 'install-casperjs':
path => $creates,
source => $src,
recurse => true,
require => Exec['extract-casperjs']
}
file { 'link-casperjs-bin':
ensure => "${creates}/bin/casperjs",
path => '/usr/local/bin/casperjs'
}
}

View File

@ -0,0 +1,24 @@
# Class: epel
#
# Configure EPEL repository.
#
# Parameters:
#
# Actions:
#
# Requires:
#
# Sample Usage:
#
# include epel
#
class epel {
yumrepo { 'epel':
mirrorlist => "http://mirrors.fedoraproject.org/mirrorlist?repo=epel-6&arch=${::architecture}",
enabled => '0',
gpgcheck => '0',
descr => "Extra Packages for Enterprise Linux 6 - ${::architecture}"
}
}

View File

@ -0,0 +1,43 @@
# Class: pear
#
# This class installs pear.
#
# Parameters:
#
# Actions:
#
# Requires:
#
# php
#
# Sample Usage:
#
# include pear
#
class pear {
Exec { path => '/usr/bin:/bin' }
include php
package { 'php-pear':
ensure => installed,
require => Class['php']
}
exec { 'pear upgrade':
command => 'pear upgrade',
require => Package['php-pear']
}
exec { 'pear update-channels':
command => 'pear update-channels',
require => Package['php-pear']
}
exec { 'pear auto discover channels':
command => 'pear config-set auto_discover 1',
unless => 'pear config-get auto_discover | grep 1',
require => Package['php-pear']
}
}

View File

@ -0,0 +1,41 @@
# Define: pear::package
#
# Install additional PEAR packages
#
# Parameters:
#
# Actions:
#
# Requires:
#
# pear
#
# Sample Usage:
#
# pear::package { 'phpunit': }
#
define pear::package(
$channel
) {
Exec { path => '/usr/bin' }
include pear
if $::require {
$require_ = [Class['pear'], $::require]
} else {
$require_ = Class['pear']
}
exec { "pear install ${name}":
command => "pear install --alldeps ${channel}",
creates => "/usr/bin/${name}",
require => $require_
}
exec { "pear upgrade ${name}":
command => "pear upgrade ${channel}",
require => Exec["pear install ${name}"]
}
}

View File

@ -0,0 +1,65 @@
# Class: phantomjs
#
# This module downloads, extracts, and installs phantomjs tar.bz2 archives
# using wget and tar.
#
# Parameters:
# [*url*] - fetch archive via wget from this url.
# [*output*] - filename to fetch the archive into.
# [*creates*] - target directory the software will install to.
#
# Actions:
#
# Requires:
#
# Sample Usage:
#
# class {'phantomjs':
# url => 'https://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-x86_64.tar.bz2',
# output => 'phantomjs-1.9.1-linux-x86_64.tar.bz2',
# creates => '/usr/local/phantomjs'
# }
#
class phantomjs(
$url,
$output,
$creates
) {
Exec { path => '/usr/bin:/bin' }
$cwd = '/usr/local/src'
include wget
exec { 'download-phantomjs':
cwd => $cwd,
command => "wget -q ${url} -O ${output}",
creates => "${cwd}/${output}",
timeout => 120,
require => Class['wget']
}
$src = "${cwd}/phantomjs"
exec { 'extract-phantomjs':
cwd => $cwd,
command => "mkdir -p phantomjs && tar --no-same-owner \
--no-same-permissions -xjf ${output} -C ${src} \
--strip-components 1",
creates => $src,
require => Exec['download-phantomjs']
}
file { 'install-phantomjs':
path => $creates,
source => $src,
recurse => true,
require => Exec['extract-phantomjs']
}
file { 'link-phantomjs-bin':
ensure => "${creates}/bin/phantomjs",
path => '/usr/local/bin/phantomjs'
}
}

View File

@ -162,3 +162,17 @@ This is what the **dc=icinga,dc=org** *DIT* looks like:
> uid: rroe
All users share the password `password`.
#### Testing the code
All software required to run tests is installed in the virtual machine.
In order to run all tests you have to execute the following commands:
vagrant ssh -c /vagrant/test/php/runtests
vagrant ssh -c /vagrant/test/php/checkswag
vagrant ssh -c /vagrant/test/js/runtests
vagrant ssh -c /vagrant/test/js/checkswag
vagrant ssh -c /vagrant/test/frontend/runtests
`runtests` will execute unit and regression tests and `checkswag` will report
code style issues.