Author: sandervanderburg
Date: Fri Oct 29 19:54:39 2010
New Revision: 24536
URL: https://svn.nixos.org/websvn/nix/?rev=24536&sc=1
Log:
Added testcases for the process, wrapper and apache-webapplication types
Added:
disnix/disnix-activation-scripts/trunk/tests/deployment/apache-webapplication.nix
disnix/disnix-activation-scripts/trunk/tests/deployment/process.nix
disnix/disnix-activation-scripts/trunk/tests/deployment/wrapper.nix
disnix/disnix-activation-scripts/trunk/tests/services/apache-webapplication/
disnix/disnix-activation-scripts/trunk/tests/services/apache-webapplication/index.html
disnix/disnix-activation-scripts/trunk/tests/services/process/
disnix/disnix-activation-scripts/trunk/tests/services/process/loop
disnix/disnix-activation-scripts/trunk/tests/services/wrapper/
disnix/disnix-activation-scripts/trunk/tests/services/wrapper/loop
disnix/disnix-activation-scripts/trunk/tests/services/wrapper/wrapper.in
Modified:
disnix/disnix-activation-scripts/trunk/release.nix
disnix/disnix-activation-scripts/trunk/tests/services/tomcat-webapplication/index.jsp
Modified: disnix/disnix-activation-scripts/trunk/release.nix
==============================================================================
--- disnix/disnix-activation-scripts/trunk/release.nix Fri Oct 29 19:52:15
2010 (r24535)
+++ disnix/disnix-activation-scripts/trunk/release.nix Fri Oct 29 19:54:39
2010 (r24536)
@@ -64,8 +64,27 @@
enableTomcatWebApplication = true;
};
- testdb = import ./tests/deployment/mysql-database.nix { inherit
stdenv; };
- tomcat_webapplication = import
./tests/deployment/tomcat-webapplication.nix { inherit stdenv jdk; };
+ # Test services
+
+ testdb = import ./tests/deployment/mysql-database.nix {
+ inherit stdenv;
+ };
+
+ tomcat_webapplication = import
./tests/deployment/tomcat-webapplication.nix {
+ inherit stdenv jdk;
+ };
+
+ apache_webapplication = import
./tests/deployment/apache-webapplication.nix {
+ inherit stdenv;
+ };
+
+ wrapper = import ./tests/deployment/wrapper.nix {
+ inherit stdenv;
+ };
+
+ process = import ./tests/deployment/process.nix {
+ inherit stdenv;
+ };
in
with import "${nixos}/lib/testing.nix" { inherit nixpkgs; system =
"x86_64-linux"; services = null; };
@@ -84,6 +103,7 @@
services.httpd = {
enable = true;
adminAddr = "[email protected]";
+ documentRoot = "/var/www";
};
services.tomcat.enable = true;
services.tomcat.axis2.enable = true;
@@ -98,7 +118,40 @@
# Test echo activation script. Here we just invoke the activate
# and deactivation steps. This test should succeed.
$machine->mustSucceed("${disnix_activation_scripts}/libexec/disnix/activation-scripts/echo
activate hello");
-
$machine->mustSucceed("${disnix_activation_scripts}/libexec/disnix/activation-scripts/echo
deactivate hello");
+
$machine->mustSucceed("${disnix_activation_scripts}/libexec/disnix/activation-scripts/echo
deactivate hello");
+
+ # Test wrapper activation script. Here we invoke the wrapper
+ # of a certain service. This service spawns a process which
+ # loops. We checks whether it is activated.
+ # After a while we deactivate it and we check if it is indeed
+ # deactivated. This test should succeed.
+
+
$machine->mustSucceed("${disnix_activation_scripts}/libexec/disnix/activation-scripts/wrapper
activate ${wrapper}");
+ $machine->mustSucceed("[ \"\$(pgrep -f ${wrapper}/bin/loop)\"
!= \"\" ]");
+
$machine->mustSucceed("${disnix_activation_scripts}/libexec/disnix/activation-scripts/wrapper
deactivate ${wrapper}");
+ $machine->mustSucceed("[ \"\$(pgrep -f ${wrapper}/bin/loop)\" =
\"\" ]");
+
+ # Test process activation script. Here we start a process which
+ # loops forever. We check whether it has been started and
+ # then we deactivate it again and verify whether it has been
+ # stopped. This test should succeed.
+
+
$machine->mustSucceed("${disnix_activation_scripts}/libexec/disnix/activation-scripts/process
activate ${process}");
+ $machine->mustSucceed("[ \"\$(pgrep -f ${process}/bin/loop)\"
!= \"\" ]");
+
$machine->mustSucceed("${disnix_activation_scripts}/libexec/disnix/activation-scripts/process
deactivate ${process}");
+ $machine->mustSucceed("[ \"\$(pgrep -f ${process}/bin/loop)\" =
\"\" ]");
+
+ # Test Apache web application script. Here, we activate a small
+ # static HTML website in the document root of Apache, then we
+ # check whether it is available. Finally, we deactivate it again
+ # and see whether is has become unavailable.
+ # This test should succeed.
+
+ $machine->waitForJob("httpd");
+ $machine->mustSucceed("documentRoot=/var/www
${disnix_activation_scripts}/libexec/disnix/activation-scripts/apache-webapplication
activate ${apache_webapplication}");
+ $machine->mustSucceed("curl --fail http://localhost/test");
+ $machine->mustSucceed("documentRoot=/var/www
${disnix_activation_scripts}/libexec/disnix/activation-scripts/apache-webapplication
deactivate ${apache_webapplication}");
+ $machine->mustFail("curl --fail http://localhost/test");
# Test MySQL activation script. Here we activate a database and
# we check whether it is created. This test should succeed.
Added:
disnix/disnix-activation-scripts/trunk/tests/deployment/apache-webapplication.nix
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++
disnix/disnix-activation-scripts/trunk/tests/deployment/apache-webapplication.nix
Fri Oct 29 19:54:39 2010 (r24536)
@@ -0,0 +1,10 @@
+{stdenv}:
+
+stdenv.mkDerivation {
+ name = "apache-webapplication";
+ src = ../services/apache-webapplication;
+ buildCommand = ''
+ ensureDir $out/webapps/test
+ cp $src/* $out/webapps/test
+ '';
+}
Added: disnix/disnix-activation-scripts/trunk/tests/deployment/process.nix
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ disnix/disnix-activation-scripts/trunk/tests/deployment/process.nix Fri Oct
29 19:54:39 2010 (r24536)
@@ -0,0 +1,11 @@
+{stdenv}:
+
+stdenv.mkDerivation {
+ name = "process";
+ src = ../services/process;
+ installPhase = ''
+ ensureDir $out/bin
+ cp $src/* $out/bin
+ chmod +x $out/bin/*
+ '';
+}
Added: disnix/disnix-activation-scripts/trunk/tests/deployment/wrapper.nix
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ disnix/disnix-activation-scripts/trunk/tests/deployment/wrapper.nix Fri Oct
29 19:54:39 2010 (r24536)
@@ -0,0 +1,12 @@
+{stdenv}:
+
+stdenv.mkDerivation {
+ name = "wrapper";
+ src = ../services/wrapper;
+ installPhase = ''
+ ensureDir $out/bin
+ cp $src/loop $out/bin
+ sed -e "s|@loop@|$out/bin/loop|" $src/wrapper.in > $out/bin/wrapper
+ chmod +x $out/bin/*
+ '';
+}
Added:
disnix/disnix-activation-scripts/trunk/tests/services/apache-webapplication/index.html
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++
disnix/disnix-activation-scripts/trunk/tests/services/apache-webapplication/index.html
Fri Oct 29 19:54:39 2010 (r24536)
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
+
+<html>
+ <head>
+ <title>Hello World!</title>
+ </head>
+
+ <body>
+ <h1>Hello World!</h1>
+
+ <p>Hello World!</p>
+ </body>
+</html>
Added: disnix/disnix-activation-scripts/trunk/tests/services/process/loop
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ disnix/disnix-activation-scripts/trunk/tests/services/process/loop Fri Oct
29 19:54:39 2010 (r24536)
@@ -0,0 +1,7 @@
+#!/bin/bash -e
+
+while true
+do
+ echo "Loop forever..."
+ sleep 1
+done
Modified:
disnix/disnix-activation-scripts/trunk/tests/services/tomcat-webapplication/index.jsp
==============================================================================
---
disnix/disnix-activation-scripts/trunk/tests/services/tomcat-webapplication/index.jsp
Fri Oct 29 19:52:15 2010 (r24535)
+++
disnix/disnix-activation-scripts/trunk/tests/services/tomcat-webapplication/index.jsp
Fri Oct 29 19:54:39 2010 (r24536)
@@ -6,7 +6,7 @@
</head>
<body>
- <title>Hello World!</title>
+ <h1>Hello World!</h1>
<p><% out.println("Hello World!"); %></p>
</body>
Added: disnix/disnix-activation-scripts/trunk/tests/services/wrapper/loop
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ disnix/disnix-activation-scripts/trunk/tests/services/wrapper/loop Fri Oct
29 19:54:39 2010 (r24536)
@@ -0,0 +1,7 @@
+#!/bin/bash -e
+
+while true
+do
+ echo "Loop forever..."
+ sleep 1
+done
Added: disnix/disnix-activation-scripts/trunk/tests/services/wrapper/wrapper.in
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ disnix/disnix-activation-scripts/trunk/tests/services/wrapper/wrapper.in
Fri Oct 29 19:54:39 2010 (r24536)
@@ -0,0 +1,10 @@
+#!/bin/bash -e
+
+case "$1" in
+ activate)
+ nohup @loop@ &
+ ;;
+ deactivate)
+ pkill -f @loop@
+ ;;
+esac
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits