Skip to content

Commit

Permalink
Fix testcases to work with Nix 2.0/Nixpkgs 18.03 + disable substitute…
Browse files Browse the repository at this point in the history
…s to make tests run faster
  • Loading branch information
svanderburg committed Apr 25, 2018
1 parent b61ead9 commit 534da89
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 24 deletions.
2 changes: 1 addition & 1 deletion tests/datamigration.nix
Expand Up @@ -20,7 +20,7 @@ with import "${nixpkgs}/nixos/lib/testing.nix" { system = builtins.currentSystem
startAll;
# Initialise ssh stuff by creating a key pair for communication
my $key=`${pkgs.openssh}/bin/ssh-keygen -t dsa -f key -N ""`;
my $key=`${pkgs.openssh}/bin/ssh-keygen -t ecdsa -f key -N ""`;
$testtarget1->mustSucceed("mkdir -m 700 /root/.ssh");
$testtarget1->copyFileFromHost("key.pub", "/root/.ssh/authorized_keys");
Expand Down
16 changes: 8 additions & 8 deletions tests/dbus.nix
Expand Up @@ -28,12 +28,12 @@ with import "${nixpkgs}/nixos/lib/testing.nix" { system = builtins.currentSystem
# which should return the path we have given.
# This test should succeed.
my $result = $client->mustSucceed("disnix-client --print-invalid /nix/store/invalid");
my $result = $client->mustSucceed("disnix-client --print-invalid /nix/store/00000000000000000000000000000000-invalid");
if($result =~ /\/nix\/store\/invalid/) {
print "/nix/store/invalid is invalid\n";
if($result =~ /\/nix\/store\/00000000000000000000000000000000-invalid/) {
print "/nix/store/00000000000000000000000000000000-invalid is invalid\n";
} else {
die "/nix/store/invalid should be invalid\n";
die "/nix/store/00000000000000000000000000000000-invalid should be invalid\n";
}
# Check invalid path. We query a valid path from the service
Expand Down Expand Up @@ -134,19 +134,19 @@ with import "${nixpkgs}/nixos/lib/testing.nix" { system = builtins.currentSystem
# unprivileged user, which should fail. Then we try the same
# command by a privileged user, which should succeed.
$client->mustFail("su - unprivileged -c 'disnix-client --print-invalid /nix/store/invalid'");
$client->mustSucceed("su - privileged -c 'disnix-client --print-invalid /nix/store/invalid'");
$client->mustFail("su - unprivileged -c 'disnix-client --print-invalid /nix/store/00000000000000000000000000000000-invalid'");
$client->mustSucceed("su - privileged -c 'disnix-client --print-invalid /nix/store/00000000000000000000000000000000-invalid'");
# Logfiles test. We perform an operation and check the id of the
# logfile. Then we stop the Disnix service and start it again and perform
# another operation. It should create a logfile which id is one higher.
$client->mustSucceed("disnix-client --print-invalid /nix/store/invalid");
$client->mustSucceed("disnix-client --print-invalid /nix/store/00000000000000000000000000000000-invalid");
$result = $client->mustSucceed("ls /var/log/disnix | sort -n | tail -1");
$client->stopJob("disnix");
$client->startJob("disnix");
$client->waitForJob("disnix");
$client->mustSucceed("sleep 3; disnix-client --print-invalid /nix/store/invalid");
$client->mustSucceed("sleep 3; disnix-client --print-invalid /nix/store/00000000000000000000000000000000-invalid");
my $result2 = $client->mustSucceed("ls /var/log/disnix | sort -n | tail -1");
if((substr $result2, 0, -1) - (substr $result, 0, -1) == 1) {
Expand Down
2 changes: 1 addition & 1 deletion tests/deployment.nix
Expand Up @@ -20,7 +20,7 @@ with import "${nixpkgs}/nixos/lib/testing.nix" { system = builtins.currentSystem
startAll;
# Initialise ssh stuff by creating a key pair for communication
my $key=`${pkgs.openssh}/bin/ssh-keygen -t dsa -f key -N ""`;
my $key=`${pkgs.openssh}/bin/ssh-keygen -t ecdsa -f key -N ""`;
$testtarget1->mustSucceed("mkdir -m 700 /root/.ssh");
$testtarget1->copyFileFromHost("key.pub", "/root/.ssh/authorized_keys");
Expand Down
2 changes: 1 addition & 1 deletion tests/distbuild.nix
Expand Up @@ -20,7 +20,7 @@ with import "${nixpkgs}/nixos/lib/testing.nix" { system = builtins.currentSystem
startAll;
# Initialise ssh stuff by creating a key pair for communication
my $key=`${pkgs.openssh}/bin/ssh-keygen -t dsa -f key -N ""`;
my $key=`${pkgs.openssh}/bin/ssh-keygen -t ecdsa -f key -N ""`;
$testtarget1->mustSucceed("mkdir -m 700 /root/.ssh");
$testtarget1->copyFileFromHost("key.pub", "/root/.ssh/authorized_keys");
Expand Down
2 changes: 1 addition & 1 deletion tests/install.nix
Expand Up @@ -19,7 +19,7 @@ with import "${nixpkgs}/nixos/lib/testing.nix" { system = builtins.currentSystem
startAll;
# Initialise ssh stuff by creating a key pair for communication
my $key=`${pkgs.openssh}/bin/ssh-keygen -t dsa -f key -N ""`;
my $key=`${pkgs.openssh}/bin/ssh-keygen -t ecdsa -f key -N ""`;
$server->mustSucceed("mkdir -m 700 /root/.ssh");
$server->copyFileFromHost("key.pub", "/root/.ssh/authorized_keys");
Expand Down
2 changes: 1 addition & 1 deletion tests/locking.nix
Expand Up @@ -20,7 +20,7 @@ with import "${nixpkgs}/nixos/lib/testing.nix" { system = builtins.currentSystem
startAll;
# Initialise ssh stuff by creating a key pair for communication
my $key=`${pkgs.openssh}/bin/ssh-keygen -t dsa -f key -N ""`;
my $key=`${pkgs.openssh}/bin/ssh-keygen -t ecdsa -f key -N ""`;
$testtarget1->mustSucceed("mkdir -m 700 /root/.ssh");
$testtarget1->copyFileFromHost("key.pub", "/root/.ssh/authorized_keys");
Expand Down
7 changes: 7 additions & 0 deletions tests/machine.nix
Expand Up @@ -30,6 +30,13 @@
}
];

# We can't download any substitutes in a test environment. To make tests
# faster, we disable substitutes so that Nix does not waste any time by
# attempting to download them.
nix.extraOptions = ''
substitute = false
'';

environment.systemPackages = [ dysnomia ];

environment.etc."dysnomia/properties" = {
Expand Down
2 changes: 1 addition & 1 deletion tests/pkgs.nix
Expand Up @@ -20,7 +20,7 @@ with import "${nixpkgs}/nixos/lib/testing.nix" { system = builtins.currentSystem
startAll;
# Initialise ssh stuff by creating a key pair for communication
my $key=`${pkgs.openssh}/bin/ssh-keygen -t dsa -f key -N ""`;
my $key=`${pkgs.openssh}/bin/ssh-keygen -t ecdsa -f key -N ""`;
$testtarget1->mustSucceed("mkdir -m 700 /root/.ssh");
$testtarget1->copyFileFromHost("key.pub", "/root/.ssh/authorized_keys");
Expand Down
8 changes: 4 additions & 4 deletions tests/runactivities.nix
Expand Up @@ -27,12 +27,12 @@ with import "${nixpkgs}/nixos/lib/testing.nix" { system = builtins.currentSystem
# which should return the path we have given.
# This test should succeed.
my $result = $server->mustSucceed("disnix-run-activity --print-invalid /nix/store/invalid");
my $result = $server->mustSucceed("disnix-run-activity --print-invalid /nix/store/00000000000000000000000000000000-invalid");
if($result =~ /\/nix\/store\/invalid/) {
print "/nix/store/invalid is invalid\n";
if($result =~ /\/nix\/store\/00000000000000000000000000000000-invalid/) {
print "/nix/store/00000000000000000000000000000000-invalid is invalid\n";
} else {
die "/nix/store/invalid should be invalid\n";
die "/nix/store/00000000000000000000000000000000-invalid should be invalid\n";
}
# Check invalid path. We query a valid path from the service
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots.nix
Expand Up @@ -22,7 +22,7 @@ with import "${nixpkgs}/nixos/lib/testing.nix" { system = builtins.currentSystem
#### Test disnix-ssh-client's snapshot operations
# Initialise ssh stuff by creating a key pair for communication
my $key=`${pkgs.openssh}/bin/ssh-keygen -t dsa -f key -N ""`;
my $key=`${pkgs.openssh}/bin/ssh-keygen -t ecdsa -f key -N ""`;
$server->mustSucceed("mkdir -m 700 /root/.ssh");
$server->copyFileFromHost("key.pub", "/root/.ssh/authorized_keys");
Expand Down
10 changes: 5 additions & 5 deletions tests/ssh.nix
Expand Up @@ -23,7 +23,7 @@ with import "${nixpkgs}/nixos/lib/testing.nix" { system = builtins.currentSystem
#### Test disnix-ssh-client
# Initialise ssh stuff by creating a key pair for communication
my $key=`${pkgs.openssh}/bin/ssh-keygen -t dsa -f key -N ""`;
my $key=`${pkgs.openssh}/bin/ssh-keygen -t ecdsa -f key -N ""`;
$server->mustSucceed("mkdir -m 700 /root/.ssh");
$server->copyFileFromHost("key.pub", "/root/.ssh/authorized_keys");
Expand All @@ -36,12 +36,12 @@ with import "${nixpkgs}/nixos/lib/testing.nix" { system = builtins.currentSystem
# which should return the path we have given.
# This test should succeed.
my $result = $client->mustSucceed("${env} disnix-ssh-client --target server --print-invalid /nix/store/invalid");
my $result = $client->mustSucceed("${env} disnix-ssh-client --target server --print-invalid /nix/store/00000000000000000000000000000000-invalid");
if($result =~ /\/nix\/store\/invalid/) {
print "/nix/store/invalid is invalid\n";
if($result =~ /\/nix\/store\/00000000000000000000000000000000-invalid/) {
print "/nix/store/00000000000000000000000000000000-invalid is invalid\n";
} else {
die "/nix/store/invalid should be invalid\n";
die "/nix/store/00000000000000000000000000000000-invalid should be invalid\n";
}
# Check invalid path. We query a valid path from the service
Expand Down

0 comments on commit 534da89

Please sign in to comment.