[MediaWiki-commits] [Gerrit] Add testreduce module and role - change (operations/puppet)

2016-01-06 Thread Ori.livneh (Code Review)
Ori.livneh has submitted this change and it was merged.

Change subject: Add testreduce module and role
..


Add testreduce module and role

testreduce is Parsoid's round-trip test result aggregator and web UI. It
comprises a test coordination server that hands out test requests to
testing clients, accepts test results from them, and records the results
in a database, as well as a web interface for examining the test
results.

This patch adds a testreduce module and a minimal role. It hews closely
to how testreduce is currently configured on ruthenium.

Bug: T118778
Change-Id: Icd39e880ea4d0fec3e68c45d39521fb07f9dff7e
---
A manifests/role/testreduce.pp
M manifests/site.pp
A modules/testreduce/files/testreduce.upstart.conf
A modules/testreduce/manifests/init.pp
A modules/testreduce/templates/settings.js.erb
5 files changed, 198 insertions(+), 1 deletion(-)

Approvals:
  Ori.livneh: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/manifests/role/testreduce.pp b/manifests/role/testreduce.pp
new file mode 100644
index 000..05c7be3
--- /dev/null
+++ b/manifests/role/testreduce.pp
@@ -0,0 +1,11 @@
+# == Class: role::testreduce
+#
+# Parsoid round-trip test result aggregator.
+#
+class role::testreduce {
+class { '::testreduce':
+db_name => 'testreduce_0715',
+db_user => 'testreduce',
+db_pass => '',  # FIXME
+}
+}
diff --git a/manifests/site.pp b/manifests/site.pp
index b90dc46..ef4cc32 100644
--- a/manifests/site.pp
+++ b/manifests/site.pp
@@ -2317,7 +2317,7 @@
 # ruthenium is a parsoid regression test server
 # https://www.mediawiki.org/wiki/Parsoid/Round-trip_testing
 node 'ruthenium.eqiad.wmnet' {
-role testsystem
+role testsystem, testreduce
 }
 
 # T95046 install/deploy scandium as zuul merger (ci) server
diff --git a/modules/testreduce/files/testreduce.upstart.conf 
b/modules/testreduce/files/testreduce.upstart.conf
new file mode 100644
index 000..543788b
--- /dev/null
+++ b/modules/testreduce/files/testreduce.upstart.conf
@@ -0,0 +1,34 @@
+# vim: set ft=upstart:
+
+description "testreduce HTTP service"
+
+start on (local-filesystem and net-device-up IFACE!=lo)
+stop on runlevel [!2345]
+
+# up ulimit -n a bit
+limit nofile 1 1
+
+setuid "testreduce"
+setgid "testreduce"
+
+env DEFAULTFILE=/etc/default/testreduce
+
+# Basic built-in defaults. Overridden by whatever
+# is defined in the DEFAULTFILE defined above.
+env NODE_PATH="/srv/testreduce/node_modules"
+env BASE_PATH="/srv/testreduce/server"
+env LOG_FILE="/dev/null"
+env SETTINGS_FILE="/etc/testreduce/settings.js"
+env DAEMON_ARGS="--config $SETTINGS_FILE"
+env PORT="8001"
+
+respawn
+
+script
+if [ -f "$DEFAULTFILE" ] ; then
+. "$DEFAULTFILE"
+fi
+chdir "$BASE_PATH"
+   echo "Starting testreduce on port $PORT"
+exec /usr/bin/nodejs server.js $DAEMON_ARGS < /dev/null >> "$LOG_FILE" 2>&1
+end script
diff --git a/modules/testreduce/manifests/init.pp 
b/modules/testreduce/manifests/init.pp
new file mode 100644
index 000..f045fdb
--- /dev/null
+++ b/modules/testreduce/manifests/init.pp
@@ -0,0 +1,85 @@
+# == Class: testreduce
+#
+# Parsoid round-trip test result aggregator.
+#
+# === Parameters
+#
+# [*db_name*]
+#   Database name for storing results.
+#
+# [*db_user*]
+#   Database user.
+#
+# [*db_host*]
+#   MySQL host. Default: 'localhost'.
+#
+# [*db_port*]
+#   MySQL port. Default: 3306.
+#
+# [*coord_port*]
+#   The result aggregator will listen on this port. Default: 8002.
+#
+# [*webapp_port*]
+#   The user-facing webapp that displays test results will listen on
+#   this port. Default: 8003.
+#
+class testreduce(
+$db_name,
+$db_user,
+$db_pass,
+$db_host = 'localhost',
+$db_port = 3306,
+$coord_port  = 8002,
+$webapp_port = 8003,
+) {
+require_package('nodejs')
+require_package('npm')
+
+group { 'testreduce':
+ensure => present,
+system => true,
+}
+
+user { 'testreduce':
+gid=> 'testreduce',
+home   => '/srv/testreduce',
+managehome => false,
+system => true,
+}
+
+file { '/etc/testreduce':
+ensure => directory,
+owner  => 'root',
+group  => 'root',
+mode   => '0755',
+}
+
+file { '/etc/testreduce/settings.js':
+content => template('testreduce/settings.js.erb'),
+owner   => 'root',
+group   => 'root',
+mode=> '0444',
+notify  => Service['testreduce'],
+}
+
+file { '/etc/init/testreduce.conf':
+source => 'puppet:///modules/testreduce/testreduce.upstart.conf',
+owner  => 'root',
+group  => 'root',
+mode   => '0444',
+notify => Service['testreduce'],
+}
+
+git::clone { 'mediawiki/services/parsoid/testreduce':
+ensure=> latest,
+owner => 'root',
+group => 'wikidev',
+d

[MediaWiki-commits] [Gerrit] Add testreduce module and role - change (operations/puppet)

2016-01-06 Thread Ori.livneh (Code Review)
Ori.livneh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/262846

Change subject: Add testreduce module and role
..

Add testreduce module and role

testreduce is Parsoid's round-trip test result aggregator and web UI. It
comprises a test coordination server that hands out test requests to
testing clients, accepts test results from them, and records the results
in a database, as well as a web interface for examining the test
results.

This patch adds a testreduce module and a minimal role. It hews closely
to how testreduce is currently configured on ruthenium.

Bug: T118778
Change-Id: Icd39e880ea4d0fec3e68c45d39521fb07f9dff7e
---
A manifests/role/testreduce.pp
M manifests/site.pp
A modules/testreduce/files/testreduce.upstart.conf
A modules/testreduce/manifests/init.pp
A modules/testreduce/templates/settings.js.erb
5 files changed, 197 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/46/262846/1

diff --git a/manifests/role/testreduce.pp b/manifests/role/testreduce.pp
new file mode 100644
index 000..12974c6
--- /dev/null
+++ b/manifests/role/testreduce.pp
@@ -0,0 +1,11 @@
+# == Class: role::testreduce
+#
+# Parsoid round-trip test result aggregator.
+#
+class role::testreduce {
+class { 'testreduce':
+db_name => 'testreduce_0715',
+db_user => 'testreduce',
+db_pass => '',  # FIXME
+}
+}
diff --git a/manifests/site.pp b/manifests/site.pp
index b90dc46..ef4cc32 100644
--- a/manifests/site.pp
+++ b/manifests/site.pp
@@ -2317,7 +2317,7 @@
 # ruthenium is a parsoid regression test server
 # https://www.mediawiki.org/wiki/Parsoid/Round-trip_testing
 node 'ruthenium.eqiad.wmnet' {
-role testsystem
+role testsystem, testreduce
 }
 
 # T95046 install/deploy scandium as zuul merger (ci) server
diff --git a/modules/testreduce/files/testreduce.upstart.conf 
b/modules/testreduce/files/testreduce.upstart.conf
new file mode 100644
index 000..543788b
--- /dev/null
+++ b/modules/testreduce/files/testreduce.upstart.conf
@@ -0,0 +1,34 @@
+# vim: set ft=upstart:
+
+description "testreduce HTTP service"
+
+start on (local-filesystem and net-device-up IFACE!=lo)
+stop on runlevel [!2345]
+
+# up ulimit -n a bit
+limit nofile 1 1
+
+setuid "testreduce"
+setgid "testreduce"
+
+env DEFAULTFILE=/etc/default/testreduce
+
+# Basic built-in defaults. Overridden by whatever
+# is defined in the DEFAULTFILE defined above.
+env NODE_PATH="/srv/testreduce/node_modules"
+env BASE_PATH="/srv/testreduce/server"
+env LOG_FILE="/dev/null"
+env SETTINGS_FILE="/etc/testreduce/settings.js"
+env DAEMON_ARGS="--config $SETTINGS_FILE"
+env PORT="8001"
+
+respawn
+
+script
+if [ -f "$DEFAULTFILE" ] ; then
+. "$DEFAULTFILE"
+fi
+chdir "$BASE_PATH"
+   echo "Starting testreduce on port $PORT"
+exec /usr/bin/nodejs server.js $DAEMON_ARGS < /dev/null >> "$LOG_FILE" 2>&1
+end script
diff --git a/modules/testreduce/manifests/init.pp 
b/modules/testreduce/manifests/init.pp
new file mode 100644
index 000..a645d2d
--- /dev/null
+++ b/modules/testreduce/manifests/init.pp
@@ -0,0 +1,84 @@
+# == Class: testreduce
+#
+# Parsoid round-trip test result aggregator.
+#
+# === Parameters
+#
+# [*db_name*]
+#   Database name for storing results.
+#
+# [*db_user*]
+#   Database user.
+#
+# [*db_host*]
+#   MySQL host. Default: 'localhost'.
+#
+# [*db_port*]
+#   MySQL port. Default: 3306.
+#
+# [*coord_port*]
+#   The result aggregator will listen on this port. Default: 8002.
+#
+# [*webapp_port*]
+#   The user-facing webapp that displays test results will listen on
+#   this port. Default: 8003.
+#
+class testreduce(
+$db_name,
+$db_user,
+$db_pass,
+$db_host = 'localhost',
+$db_port = 3306,
+$coord_port  = 8002,
+$webapp_port = 8003,
+) {
+require_package('nodejs')
+require_package('npm')
+
+group { 'testreduce':
+ensure => present,
+system => true,
+}
+
+user { 'testreduce':
+gid=> 'testreduce',
+home   => '/srv/testreduce',
+managehome => false,
+system => true,
+}
+
+file { '/etc/testreduce':
+ensure => directory,
+owner  => 'root',
+group  => 'root',
+mode   => '0755',
+}
+
+file { '/etc/testreduce/settings.js':
+content => template('testreduce/settings.js.erb'),
+owner   => 'root',
+group   => 'root',
+mode=> '0444',
+notify  => Service['testreduce'],
+}
+
+file { '/etc/init/testreduce.conf':
+source => 'puppet:///modules/testreduce/testreduce.upstart.conf',
+owner  => 'root',
+group  => 'root',
+mode   => '0444',
+notify => Service['testreduce'],
+}
+
+service { 'testreduce':
+ensure   => running,
+provider => upstart,
+}
+
+git::clone { 'med