[icinga-checkins] icinga.org: icinga2/feature/vagrant-test-4635: Add test script for Jenkins.

git at icinga.org git at icinga.org
Thu Nov 14 14:52:31 CET 2013


Module: icinga2
Branch: feature/vagrant-test-4635
Commit: 0575f833d6330add66971bfee72239a103773a8a
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=0575f833d6330add66971bfee72239a103773a8a

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Thu Nov 14 13:20:15 2013 +0100

Add test script for Jenkins.

---

 test/jenkins/README          |    1 +
 test/jenkins/bootstrap-vm.sh |   14 ++++++++++++++
 test/jenkins/run-tests.py    |   34 ++++++++++++++++++++++++++++++++++
 test/jenkins/v1.test         |    3 +++
 4 files changed, 52 insertions(+)

diff --git a/test/jenkins/README b/test/jenkins/README
new file mode 100644
index 0000000..23495e8
--- /dev/null
+++ b/test/jenkins/README
@@ -0,0 +1 @@
+These scripts are used by build.icinga.org to set up a test VM.
diff --git a/test/jenkins/bootstrap-vm.sh b/test/jenkins/bootstrap-vm.sh
new file mode 100755
index 0000000..30d8f5d
--- /dev/null
+++ b/test/jenkins/bootstrap-vm.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+if [ "$1" != "run-by-jenkins" ]; then
+	echo "This script should not be run manually."
+	exit 1
+fi
+
+echo "10.10.27.1 packages.icinga.org" >> /etc/hosts
+
+groupadd vagrant
+
+rmdir /vagrant && ln -s /root/icinga2 /vagrant
+puppet apply --modulepath=/vagrant/.vagrant-puppet/modules /vagrant/.vagrant-puppet/manifests/default.pp
+
+exit 0
diff --git a/test/jenkins/run-tests.py b/test/jenkins/run-tests.py
new file mode 100755
index 0000000..e963955
--- /dev/null
+++ b/test/jenkins/run-tests.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+import sys
+from xml.dom.minidom import getDOMImplementation
+from subprocess import Popen, PIPE
+
+impl = getDOMImplementation()
+result = impl.createDocument(None, "testsuite", None)
+testsuite = result.documentElement
+
+for fn in sys.argv[1:]:
+  process = Popen(["./" + fn], stdout=PIPE, stderr=PIPE)
+  (stdoutdata, stderrdata) = process.communicate()
+
+  testcase = result.createElement("testcase")
+  testcase.setAttribute("classname", "vm")
+  testcase.setAttribute("name", fn)
+
+  systemout = result.createElement("system-out")
+  systemout.appendChild(result.createTextNode(stdoutdata))
+  testcase.appendChild(systemout)
+
+  systemerr = result.createElement("system-err")
+  systemerr.appendChild(result.createTextNode(stderrdata))
+  testcase.appendChild(systemerr)
+
+  if process.returncode != 0:
+    failure = result.createElement("failure")
+    failure.setAttribute("type", "returncode")
+    failure.appendChild(result.createTextNode("code: " + str(process.returncode)))
+    testcase.appendChild(failure)
+
+  testsuite.appendChild(testcase)
+
+print result.toxml()
diff --git a/test/jenkins/v1.test b/test/jenkins/v1.test
new file mode 100755
index 0000000..f0c0fcd
--- /dev/null
+++ b/test/jenkins/v1.test
@@ -0,0 +1,3 @@
+#!/bin/sh
+echo "Hello World!"
+exit 1





More information about the icinga-checkins mailing list