* Another distributed test example: Bittorrent.

svn path=/nixos/trunk/; revision=21926
This commit is contained in:
Eelco Dolstra 2010-05-20 14:56:04 +00:00
parent ad8ed39285
commit 85bd5bad32
2 changed files with 54 additions and 0 deletions

53
tests/bittorrent.nix Normal file
View File

@ -0,0 +1,53 @@
{ pkgs, ... }:
let
# Some random file to serve.
file = pkgs.nixUnstable.src;
in
{
nodes =
{ tracker =
{ config, pkgs, ... }:
{ environment.systemPackages = [ pkgs.transmission pkgs.bittorrent ];
# We need Apache on the tracker to serve the torrents.
services.httpd.enable = true;
services.httpd.adminAddr = "foo@example.org";
services.httpd.documentRoot = "/tmp";
};
client =
{ config, pkgs, ... }:
{ environment.systemPackages = [ pkgs.transmission ];
};
};
testScript =
''
startAll;
# Create the torrent.
$tracker->mustSucceed("mkdir /tmp/data");
$tracker->mustSucceed("cp ${file} /tmp/data/test.tar.bz2");
$tracker->mustSucceed("transmissioncli -n /tmp/data/test.tar.bz2 -a http://tracker:6969/announce /tmp/test.torrent");
$tracker->mustSucceed("chmod 644 /tmp/test.torrent");
# Start the tracker. !!! use a less crappy tracker
$tracker->mustSucceed("bittorrent-tracker --port 6969 --dfile /tmp/dstate >&2 &");
$tracker->waitForOpenPort(6969);
# Start the initial seeder.
$tracker->mustSucceed("transmissioncli /tmp/test.torrent -M -w /tmp/data >&2 &");
# Now we should be able to download from the client.
$tracker->waitForJob("httpd");
$client->mustSucceed("transmissioncli http://tracker/test.torrent -M -w /tmp >&2 &");
$client->waitForFile("/tmp/test.tar.bz2");
$client->mustSucceed("cmp /tmp/test.tar.bz2 ${file}");
'';
}

View File

@ -6,6 +6,7 @@
with import ../lib/testing.nix { inherit nixpkgs services system; }; with import ../lib/testing.nix { inherit nixpkgs services system; };
{ {
bittorrent = apply (import ./bittorrent.nix);
firefox = apply (import ./firefox.nix); firefox = apply (import ./firefox.nix);
installer = pkgs.lib.mapAttrs (name: complete) (call (import ./installer.nix)); installer = pkgs.lib.mapAttrs (name: complete) (call (import ./installer.nix));
kde4 = apply (import ./kde4.nix); kde4 = apply (import ./kde4.nix);