From 117c8430be39a21b1daff6b4def817b31cdc4e0b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 6 Jun 2013 14:36:20 +0200 Subject: [PATCH 1/5] Vagrant: Add phantomjs and casperjs refs #4219 --- .vagrant-puppet/files/etc/profile.d/env.sh | 1 + .vagrant-puppet/manifests/default.pp | 16 +++++ .../modules/casperjs/manifests/init.pp | 66 +++++++++++++++++++ .../modules/phantomjs/manifests/init.pp | 65 ++++++++++++++++++ 4 files changed, 148 insertions(+) create mode 100644 .vagrant-puppet/files/etc/profile.d/env.sh create mode 100644 .vagrant-puppet/modules/casperjs/manifests/init.pp create mode 100644 .vagrant-puppet/modules/phantomjs/manifests/init.pp diff --git a/.vagrant-puppet/files/etc/profile.d/env.sh b/.vagrant-puppet/files/etc/profile.d/env.sh new file mode 100644 index 000000000..6e41e8f2d --- /dev/null +++ b/.vagrant-puppet/files/etc/profile.d/env.sh @@ -0,0 +1 @@ +export PATH="$PATH:/usr/local/bin" diff --git a/.vagrant-puppet/manifests/default.pp b/.vagrant-puppet/manifests/default.pp index b287d137b..591750fbb 100644 --- a/.vagrant-puppet/manifests/default.pp +++ b/.vagrant-puppet/manifests/default.pp @@ -240,3 +240,19 @@ 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' +} diff --git a/.vagrant-puppet/modules/casperjs/manifests/init.pp b/.vagrant-puppet/modules/casperjs/manifests/init.pp new file mode 100644 index 000000000..2b9bac3ca --- /dev/null +++ b/.vagrant-puppet/modules/casperjs/manifests/init.pp @@ -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' + } +} diff --git a/.vagrant-puppet/modules/phantomjs/manifests/init.pp b/.vagrant-puppet/modules/phantomjs/manifests/init.pp new file mode 100644 index 000000000..ea65b1f26 --- /dev/null +++ b/.vagrant-puppet/modules/phantomjs/manifests/init.pp @@ -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' + } +} From a4d5501de5cd73fac1c4c1f9859fc392e73913d3 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 6 Jun 2013 16:09:28 +0200 Subject: [PATCH 2/5] Vagrant: Add phpcs refs #4219 --- .vagrant-puppet/manifests/default.pp | 4 ++ .../modules/pear/manifests/init.pp | 43 +++++++++++++++++++ .../modules/pear/manifests/package.pp | 41 ++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 .vagrant-puppet/modules/pear/manifests/init.pp create mode 100644 .vagrant-puppet/modules/pear/manifests/package.pp diff --git a/.vagrant-puppet/manifests/default.pp b/.vagrant-puppet/manifests/default.pp index 591750fbb..5a3d59efa 100644 --- a/.vagrant-puppet/manifests/default.pp +++ b/.vagrant-puppet/manifests/default.pp @@ -256,3 +256,7 @@ class { 'casperjs': file { '/etc/profile.d/env.sh': source => 'puppet:////vagrant/.vagrant-puppet/files/etc/profile.d/env.sh' } + +pear::package { 'phpcs': + channel => 'PHP_CodeSniffer' +} diff --git a/.vagrant-puppet/modules/pear/manifests/init.pp b/.vagrant-puppet/modules/pear/manifests/init.pp new file mode 100644 index 000000000..0c748f2bc --- /dev/null +++ b/.vagrant-puppet/modules/pear/manifests/init.pp @@ -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'] + } +} diff --git a/.vagrant-puppet/modules/pear/manifests/package.pp b/.vagrant-puppet/modules/pear/manifests/package.pp new file mode 100644 index 000000000..ed004d139 --- /dev/null +++ b/.vagrant-puppet/modules/pear/manifests/package.pp @@ -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}"] + } +} From bf3c87ede4ed1f3a849ec9b55136681b2e291780 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 6 Jun 2013 16:48:15 +0200 Subject: [PATCH 3/5] Vagrant: Add nodejs and PHPUnit refs #4219 --- .vagrant-puppet/manifests/default.pp | 20 ++++++++++++++-- .../modules/epel/manifests/init.pp | 24 +++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 .vagrant-puppet/modules/epel/manifests/init.pp diff --git a/.vagrant-puppet/manifests/default.pp b/.vagrant-puppet/manifests/default.pp index 5a3d59efa..062a4242d 100644 --- a/.vagrant-puppet/manifests/default.pp +++ b/.vagrant-puppet/manifests/default.pp @@ -257,6 +257,22 @@ file { '/etc/profile.d/env.sh': source => 'puppet:////vagrant/.vagrant-puppet/files/etc/profile.d/env.sh' } -pear::package { 'phpcs': - channel => 'PHP_CodeSniffer' +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'] } diff --git a/.vagrant-puppet/modules/epel/manifests/init.pp b/.vagrant-puppet/modules/epel/manifests/init.pp new file mode 100644 index 000000000..65e0a2603 --- /dev/null +++ b/.vagrant-puppet/modules/epel/manifests/init.pp @@ -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}" + } +} + From e5df44dc6ac45aaab6431a0fed2a014efc5e8754 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 6 Jun 2013 17:01:05 +0200 Subject: [PATCH 4/5] Vagrant: Add mocha and jshint refs #4219 --- .vagrant-puppet/manifests/default.pp | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.vagrant-puppet/manifests/default.pp b/.vagrant-puppet/manifests/default.pp index 062a4242d..88abd68c9 100644 --- a/.vagrant-puppet/manifests/default.pp +++ b/.vagrant-puppet/manifests/default.pp @@ -276,3 +276,33 @@ exec { 'install nodejs': 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/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'] +} From 4c5c6f982c28776d9b1c1c0be4cd68d62f7a00bf Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 7 Jun 2013 10:40:13 +0200 Subject: [PATCH 5/5] Vagrant: Add testing the code section to README --- .vagrant-puppet/manifests/default.pp | 6 ++++++ README.md | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/.vagrant-puppet/manifests/default.pp b/.vagrant-puppet/manifests/default.pp index 88abd68c9..9bf4c8d84 100644 --- a/.vagrant-puppet/manifests/default.pp +++ b/.vagrant-puppet/manifests/default.pp @@ -283,6 +283,12 @@ exec { 'install npm/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', diff --git a/README.md b/README.md index 371d1b3da..911e69e51 100644 --- a/README.md +++ b/README.md @@ -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.