2010-01-05 11:18:43 +00:00
|
|
|
{ pkgs, ... }:
|
* Stuff for automatic and manual testing of NixOS VMs.
lib/build-vms.nix contains a function `buildVirtualNetwork' that
takes a specification of a network of machines (as an attribute set
of NixOS machine configurations) and builds a script that starts
each configuration in a separate QEMU/KVM VM and connects them
together in a virtual network. This script can be run manually to
test the VMs interactively. There is also a function `runTests'
that starts and runs the virtual network in a derivation, and
then executes a test specification that tells the VMs to do certain
things (i.e., letting one VM send an HTTP request to a webserver on
another VM). The tests are written in Perl (for now).
tests/subversion.nix shows a simple example, namely a network of two
machines: a webserver that runs the Subversion subservice, and a
client. Apache, Subversion and a few other packages are built with
coverage analysis instrumentation. For instance,
$ nix-build tests/subversion.nix -A vms
$ ./result/bin/run-vms
starts two QEMU/KVM instances. When they have finished booting, the
webserver can be accessed from the host through
http://localhost:8081/.
It also has a small test suite:
$ nix-build tests/subversion.nix -A report
This runs the VMs in a derivation, runs the tests, and then produces
a distributed code coverage analysis report (i.e. it shows the
combined coverage on both machines).
The Perl test driver program is in lib/test-driver. It executes
commands on the guest machines by connecting to a root shell running
on port 514 (provided by modules/testing/test-instrumentation.nix).
The VMs are connected together in a virtual network using QEMU's
multicast feature. This isn't very secure. At the very least,
other processes on the same machine can listen to or send packets on
the virtual network. On the plus side, we don't need to be root to
set up a multicast virtual network, so we can do it from a
derivation. Maybe we can use VDE instead.
(Moved from the vario repository.)
svn path=/nixos/trunk/; revision=16899
2009-08-31 14:25:12 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
# Build some packages with coverage instrumentation.
|
2010-01-03 17:57:38 +00:00
|
|
|
overrides = pkgs:
|
|
|
|
with pkgs.stdenvAdapters;
|
* Stuff for automatic and manual testing of NixOS VMs.
lib/build-vms.nix contains a function `buildVirtualNetwork' that
takes a specification of a network of machines (as an attribute set
of NixOS machine configurations) and builds a script that starts
each configuration in a separate QEMU/KVM VM and connects them
together in a virtual network. This script can be run manually to
test the VMs interactively. There is also a function `runTests'
that starts and runs the virtual network in a derivation, and
then executes a test specification that tells the VMs to do certain
things (i.e., letting one VM send an HTTP request to a webserver on
another VM). The tests are written in Perl (for now).
tests/subversion.nix shows a simple example, namely a network of two
machines: a webserver that runs the Subversion subservice, and a
client. Apache, Subversion and a few other packages are built with
coverage analysis instrumentation. For instance,
$ nix-build tests/subversion.nix -A vms
$ ./result/bin/run-vms
starts two QEMU/KVM instances. When they have finished booting, the
webserver can be accessed from the host through
http://localhost:8081/.
It also has a small test suite:
$ nix-build tests/subversion.nix -A report
This runs the VMs in a derivation, runs the tests, and then produces
a distributed code coverage analysis report (i.e. it shows the
combined coverage on both machines).
The Perl test driver program is in lib/test-driver. It executes
commands on the guest machines by connecting to a root shell running
on port 514 (provided by modules/testing/test-instrumentation.nix).
The VMs are connected together in a virtual network using QEMU's
multicast feature. This isn't very secure. At the very least,
other processes on the same machine can listen to or send packets on
the virtual network. On the plus side, we don't need to be root to
set up a multicast virtual network, so we can do it from a
derivation. Maybe we can use VDE instead.
(Moved from the vario repository.)
svn path=/nixos/trunk/; revision=16899
2009-08-31 14:25:12 +00:00
|
|
|
let
|
|
|
|
do = pkg: pkg.override (args: {
|
2010-01-03 17:57:38 +00:00
|
|
|
stdenv = addCoverageInstrumentation args.stdenv;
|
* Stuff for automatic and manual testing of NixOS VMs.
lib/build-vms.nix contains a function `buildVirtualNetwork' that
takes a specification of a network of machines (as an attribute set
of NixOS machine configurations) and builds a script that starts
each configuration in a separate QEMU/KVM VM and connects them
together in a virtual network. This script can be run manually to
test the VMs interactively. There is also a function `runTests'
that starts and runs the virtual network in a derivation, and
then executes a test specification that tells the VMs to do certain
things (i.e., letting one VM send an HTTP request to a webserver on
another VM). The tests are written in Perl (for now).
tests/subversion.nix shows a simple example, namely a network of two
machines: a webserver that runs the Subversion subservice, and a
client. Apache, Subversion and a few other packages are built with
coverage analysis instrumentation. For instance,
$ nix-build tests/subversion.nix -A vms
$ ./result/bin/run-vms
starts two QEMU/KVM instances. When they have finished booting, the
webserver can be accessed from the host through
http://localhost:8081/.
It also has a small test suite:
$ nix-build tests/subversion.nix -A report
This runs the VMs in a derivation, runs the tests, and then produces
a distributed code coverage analysis report (i.e. it shows the
combined coverage on both machines).
The Perl test driver program is in lib/test-driver. It executes
commands on the guest machines by connecting to a root shell running
on port 514 (provided by modules/testing/test-instrumentation.nix).
The VMs are connected together in a virtual network using QEMU's
multicast feature. This isn't very secure. At the very least,
other processes on the same machine can listen to or send packets on
the virtual network. On the plus side, we don't need to be root to
set up a multicast virtual network, so we can do it from a
derivation. Maybe we can use VDE instead.
(Moved from the vario repository.)
svn path=/nixos/trunk/; revision=16899
2009-08-31 14:25:12 +00:00
|
|
|
});
|
|
|
|
in
|
|
|
|
rec {
|
|
|
|
apr = do pkgs.apr;
|
|
|
|
aprutil = do pkgs.aprutil;
|
|
|
|
apacheHttpd = do pkgs.apacheHttpd;
|
|
|
|
mod_python = do pkgs.mod_python;
|
|
|
|
subversion = do pkgs.subversion;
|
2009-09-01 22:22:45 +00:00
|
|
|
|
|
|
|
# To build the kernel with coverage instrumentation, we need a
|
|
|
|
# special patch to make coverage data available under /proc.
|
2010-01-03 17:57:38 +00:00
|
|
|
kernel = pkgs.kernel.override (orig: {
|
|
|
|
stdenv = cleanupBuildTree (keepBuildTree orig.stdenv);
|
2010-01-04 13:22:43 +00:00
|
|
|
extraConfig =
|
|
|
|
''
|
|
|
|
GCOV_KERNEL y
|
|
|
|
GCOV_PROFILE_ALL y
|
|
|
|
'';
|
2009-09-01 22:22:45 +00:00
|
|
|
});
|
* Stuff for automatic and manual testing of NixOS VMs.
lib/build-vms.nix contains a function `buildVirtualNetwork' that
takes a specification of a network of machines (as an attribute set
of NixOS machine configurations) and builds a script that starts
each configuration in a separate QEMU/KVM VM and connects them
together in a virtual network. This script can be run manually to
test the VMs interactively. There is also a function `runTests'
that starts and runs the virtual network in a derivation, and
then executes a test specification that tells the VMs to do certain
things (i.e., letting one VM send an HTTP request to a webserver on
another VM). The tests are written in Perl (for now).
tests/subversion.nix shows a simple example, namely a network of two
machines: a webserver that runs the Subversion subservice, and a
client. Apache, Subversion and a few other packages are built with
coverage analysis instrumentation. For instance,
$ nix-build tests/subversion.nix -A vms
$ ./result/bin/run-vms
starts two QEMU/KVM instances. When they have finished booting, the
webserver can be accessed from the host through
http://localhost:8081/.
It also has a small test suite:
$ nix-build tests/subversion.nix -A report
This runs the VMs in a derivation, runs the tests, and then produces
a distributed code coverage analysis report (i.e. it shows the
combined coverage on both machines).
The Perl test driver program is in lib/test-driver. It executes
commands on the guest machines by connecting to a root shell running
on port 514 (provided by modules/testing/test-instrumentation.nix).
The VMs are connected together in a virtual network using QEMU's
multicast feature. This isn't very secure. At the very least,
other processes on the same machine can listen to or send packets on
the virtual network. On the plus side, we don't need to be root to
set up a multicast virtual network, so we can do it from a
derivation. Maybe we can use VDE instead.
(Moved from the vario repository.)
svn path=/nixos/trunk/; revision=16899
2009-08-31 14:25:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
2010-01-05 11:18:43 +00:00
|
|
|
{
|
* Stuff for automatic and manual testing of NixOS VMs.
lib/build-vms.nix contains a function `buildVirtualNetwork' that
takes a specification of a network of machines (as an attribute set
of NixOS machine configurations) and builds a script that starts
each configuration in a separate QEMU/KVM VM and connects them
together in a virtual network. This script can be run manually to
test the VMs interactively. There is also a function `runTests'
that starts and runs the virtual network in a derivation, and
then executes a test specification that tells the VMs to do certain
things (i.e., letting one VM send an HTTP request to a webserver on
another VM). The tests are written in Perl (for now).
tests/subversion.nix shows a simple example, namely a network of two
machines: a webserver that runs the Subversion subservice, and a
client. Apache, Subversion and a few other packages are built with
coverage analysis instrumentation. For instance,
$ nix-build tests/subversion.nix -A vms
$ ./result/bin/run-vms
starts two QEMU/KVM instances. When they have finished booting, the
webserver can be accessed from the host through
http://localhost:8081/.
It also has a small test suite:
$ nix-build tests/subversion.nix -A report
This runs the VMs in a derivation, runs the tests, and then produces
a distributed code coverage analysis report (i.e. it shows the
combined coverage on both machines).
The Perl test driver program is in lib/test-driver. It executes
commands on the guest machines by connecting to a root shell running
on port 514 (provided by modules/testing/test-instrumentation.nix).
The VMs are connected together in a virtual network using QEMU's
multicast feature. This isn't very secure. At the very least,
other processes on the same machine can listen to or send packets on
the virtual network. On the plus side, we don't need to be root to
set up a multicast virtual network, so we can do it from a
derivation. Maybe we can use VDE instead.
(Moved from the vario repository.)
svn path=/nixos/trunk/; revision=16899
2009-08-31 14:25:12 +00:00
|
|
|
|
|
|
|
nodes =
|
|
|
|
{ webserver =
|
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
{
|
|
|
|
services.httpd.enable = true;
|
|
|
|
services.httpd.adminAddr = "e.dolstra@tudelft.nl";
|
|
|
|
services.httpd.extraSubservices =
|
|
|
|
[ { serviceType = "subversion";
|
2009-11-06 16:23:25 +00:00
|
|
|
urlPrefix = "";
|
|
|
|
dataDir = "/data/subversion";
|
|
|
|
userCreationDomain = "192.168.0.0/16";
|
* Stuff for automatic and manual testing of NixOS VMs.
lib/build-vms.nix contains a function `buildVirtualNetwork' that
takes a specification of a network of machines (as an attribute set
of NixOS machine configurations) and builds a script that starts
each configuration in a separate QEMU/KVM VM and connects them
together in a virtual network. This script can be run manually to
test the VMs interactively. There is also a function `runTests'
that starts and runs the virtual network in a derivation, and
then executes a test specification that tells the VMs to do certain
things (i.e., letting one VM send an HTTP request to a webserver on
another VM). The tests are written in Perl (for now).
tests/subversion.nix shows a simple example, namely a network of two
machines: a webserver that runs the Subversion subservice, and a
client. Apache, Subversion and a few other packages are built with
coverage analysis instrumentation. For instance,
$ nix-build tests/subversion.nix -A vms
$ ./result/bin/run-vms
starts two QEMU/KVM instances. When they have finished booting, the
webserver can be accessed from the host through
http://localhost:8081/.
It also has a small test suite:
$ nix-build tests/subversion.nix -A report
This runs the VMs in a derivation, runs the tests, and then produces
a distributed code coverage analysis report (i.e. it shows the
combined coverage on both machines).
The Perl test driver program is in lib/test-driver. It executes
commands on the guest machines by connecting to a root shell running
on port 514 (provided by modules/testing/test-instrumentation.nix).
The VMs are connected together in a virtual network using QEMU's
multicast feature. This isn't very secure. At the very least,
other processes on the same machine can listen to or send packets on
the virtual network. On the plus side, we don't need to be root to
set up a multicast virtual network, so we can do it from a
derivation. Maybe we can use VDE instead.
(Moved from the vario repository.)
svn path=/nixos/trunk/; revision=16899
2009-08-31 14:25:12 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
nixpkgs.config.packageOverrides = overrides;
|
|
|
|
};
|
|
|
|
|
|
|
|
client =
|
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
{
|
|
|
|
environment.systemPackages = [ pkgs.subversion ];
|
|
|
|
nixpkgs.config.packageOverrides = overrides;
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2010-01-05 11:18:43 +00:00
|
|
|
testScript =
|
* Stuff for automatic and manual testing of NixOS VMs.
lib/build-vms.nix contains a function `buildVirtualNetwork' that
takes a specification of a network of machines (as an attribute set
of NixOS machine configurations) and builds a script that starts
each configuration in a separate QEMU/KVM VM and connects them
together in a virtual network. This script can be run manually to
test the VMs interactively. There is also a function `runTests'
that starts and runs the virtual network in a derivation, and
then executes a test specification that tells the VMs to do certain
things (i.e., letting one VM send an HTTP request to a webserver on
another VM). The tests are written in Perl (for now).
tests/subversion.nix shows a simple example, namely a network of two
machines: a webserver that runs the Subversion subservice, and a
client. Apache, Subversion and a few other packages are built with
coverage analysis instrumentation. For instance,
$ nix-build tests/subversion.nix -A vms
$ ./result/bin/run-vms
starts two QEMU/KVM instances. When they have finished booting, the
webserver can be accessed from the host through
http://localhost:8081/.
It also has a small test suite:
$ nix-build tests/subversion.nix -A report
This runs the VMs in a derivation, runs the tests, and then produces
a distributed code coverage analysis report (i.e. it shows the
combined coverage on both machines).
The Perl test driver program is in lib/test-driver. It executes
commands on the guest machines by connecting to a root shell running
on port 514 (provided by modules/testing/test-instrumentation.nix).
The VMs are connected together in a virtual network using QEMU's
multicast feature. This isn't very secure. At the very least,
other processes on the same machine can listen to or send packets on
the virtual network. On the plus side, we don't need to be root to
set up a multicast virtual network, so we can do it from a
derivation. Maybe we can use VDE instead.
(Moved from the vario repository.)
svn path=/nixos/trunk/; revision=16899
2009-08-31 14:25:12 +00:00
|
|
|
''
|
|
|
|
startAll;
|
|
|
|
|
|
|
|
$webserver->waitForOpenPort(80);
|
|
|
|
|
|
|
|
my $out = $client->mustSucceed("svn --version");
|
|
|
|
print STDERR "GOT: $out";
|
|
|
|
|
|
|
|
my $out = $client->mustSucceed("curl --fail http://webserver/");
|
|
|
|
print STDERR "GOT: $out";
|
|
|
|
|
|
|
|
# Create a new user through the web interface.
|
|
|
|
$client->mustSucceed("curl --fail -F username=alice -F fullname='Alice Lastname' -F address=alice\@example.org -F password=foobar -F password_again=foobar http://webserver/repoman/adduser");
|
|
|
|
|
|
|
|
# Let Alice create a new repository.
|
|
|
|
$client->mustSucceed("curl --fail -u alice:foobar --form repo=xyzzy --form description=Xyzzy http://webserver/repoman/create");
|
|
|
|
|
|
|
|
$client->mustSucceed("curl --fail http://webserver/") =~ /alice/ or die;
|
|
|
|
|
|
|
|
# Let Alice do a checkout.
|
|
|
|
my $svnFlags = "--non-interactive --username alice --password foobar";
|
|
|
|
$client->mustSucceed("svn co $svnFlags http://webserver/repos/xyzzy wc");
|
|
|
|
$client->mustSucceed("echo hello > wc/world");
|
|
|
|
$client->mustSucceed("svn add wc/world");
|
|
|
|
$client->mustSucceed("svn ci $svnFlags -m 'Added world.' wc/world");
|
|
|
|
|
|
|
|
# Create a new user on the server through the create-user.pl script.
|
|
|
|
$webserver->execute("svn-server-create-user.pl bob bob\@example.org Bob");
|
|
|
|
$webserver->mustSucceed("svn-server-resetpw.pl bob fnord");
|
|
|
|
$client->mustSucceed("curl --fail http://webserver/") =~ /bob/ or die;
|
|
|
|
|
|
|
|
# Bob should not have access to the repo.
|
|
|
|
my $svnFlagsBob = "--non-interactive --username bob --password fnord";
|
|
|
|
$client->mustFail("svn co $svnFlagsBob http://webserver/repos/xyzzy wc2");
|
|
|
|
|
|
|
|
# Bob should not be able change the ACLs of the repo.
|
|
|
|
# !!! Repoman should really return a 403 here.
|
|
|
|
$client->execute("curl --fail -u bob:fnord -F description=Xyzzy -F readers=alice,bob -F writers=alice -F watchers= -F tardirs= http://webserver/repoman/update/xyzzy")
|
|
|
|
=~ /not authorised/ or die;
|
|
|
|
|
|
|
|
# Give Bob access.
|
|
|
|
$client->mustSucceed("curl --fail -u alice:foobar -F description=Xyzzy -F readers=alice,bob -F writers=alice -F watchers= -F tardirs= http://webserver/repoman/update/xyzzy");
|
|
|
|
|
|
|
|
# So now his checkout should succeed.
|
|
|
|
$client->mustSucceed("svn co $svnFlagsBob http://webserver/repos/xyzzy wc2");
|
|
|
|
|
|
|
|
# Test ViewVC and WebSVN
|
|
|
|
$client->mustSucceed("curl --fail -u alice:foobar http://webserver/viewvc/xyzzy");
|
|
|
|
$client->mustSucceed("curl --fail -u alice:foobar http://webserver/websvn/xyzzy");
|
|
|
|
$client->mustSucceed("curl --fail -u alice:foobar http://webserver/repos-xml/xyzzy");
|
|
|
|
|
|
|
|
# Stop Apache to gather all the coverage data.
|
|
|
|
$webserver->stopJob("httpd");
|
|
|
|
'';
|
|
|
|
|
|
|
|
}
|