forked from lix-project/hydra
ef619eca99
We've seen many fails on ofborg, at lot of them ultimately appear to come down to a timeout being hit, resulting in something like this: Failure executing slapadd -F /<path>/slap.d -b dc=example -l /<path>/load.ldif. Hopefully this resolves it for most cases. I've done some endurance testing and this helps a lot. some other commands also regularly time-out with high load: - hydra-init - hydra-create-user - nix-store --delete This should address most issues with tests randomly failing. Used the following script for endurance testing: ``` import os import subprocess run_counter = 0 fail_counter = 0 while True: try: run_counter += 1 print(f"Starting run {run_counter}") env = os.environ env["YATH_JOB_COUNT"] = "20" result = subprocess.run(["perl", "t/test.pl"], env=env) if (result.returncode != 0): fail_counter += 1 print(f"Finish run {run_counter}, total fail count: {fail_counter}") except KeyboardInterrupt: print(f"Finished {run_counter} runs with {fail_counter} fails") break ``` In case someone else wants to do it on their system :). Note that YATH_JOB_COUNT may need to be changed loosely based on your cores. I only have 4 cores (8 threads), so for others higher numbers might yield better results in hashing out unstable tests.
71 lines
2.6 KiB
Perl
71 lines
2.6 KiB
Perl
use feature 'unicode_strings';
|
|
use strict;
|
|
use warnings;
|
|
use Setup;
|
|
use Hydra::Helper::Exec;
|
|
|
|
my %ctx = test_init();
|
|
|
|
require Hydra::Schema;
|
|
require Hydra::Model::DB;
|
|
|
|
use Test2::V0;
|
|
|
|
my $db = Hydra::Model::DB->new;
|
|
hydra_setup($db);
|
|
|
|
subtest "hydra-init upgrades user's password hashes from sha1 to sha1 inside Argon2" => sub {
|
|
my $alice = $db->resultset('Users')->create({
|
|
"username" => "alice",
|
|
"emailaddress" => 'alice@nixos.org',
|
|
"password" => "8843d7f92416211de9ebb963ff4ce28125932878" # SHA1 of "foobar"
|
|
});
|
|
my $janet = $db->resultset('Users')->create({
|
|
"username" => "janet",
|
|
"emailaddress" => 'janet@nixos.org',
|
|
"password" => "!"
|
|
});
|
|
$janet->setPassword("foobar");
|
|
|
|
is($alice->password, "8843d7f92416211de9ebb963ff4ce28125932878", "Alices's sha1 is stored in the database");
|
|
my ($res, $stdout, $stderr) = captureStdoutStderr(30, ("hydra-init"));
|
|
if ($res != 0) {
|
|
is($stdout, "");
|
|
is($stderr, "");
|
|
}
|
|
is($res, 0, "hydra-init should exit zero");
|
|
|
|
subtest "Alice had their password updated in place" => sub {
|
|
my $updatedAlice = $db->resultset('Users')->find({ username => "alice" });
|
|
isnt($updatedAlice, undef);
|
|
isnt($updatedAlice->password, "8843d7f92416211de9ebb963ff4ce28125932878", "The password was updated in place.");
|
|
|
|
my $storedPassword = $updatedAlice->password;
|
|
ok($updatedAlice->check_password("foobar"), "Their password validates");
|
|
isnt($storedPassword, $updatedAlice->password, "The password is upgraded in place.");
|
|
};
|
|
|
|
subtest "Janet did not have their password change" => sub {
|
|
my $updatedJanet = $db->resultset('Users')->find({ username => "janet" });
|
|
isnt($updatedJanet, undef);
|
|
is($updatedJanet->password, $janet->password, "The password was not updated in place.");
|
|
|
|
ok($updatedJanet->check_password("foobar"), "Their password validates");
|
|
is($updatedJanet->password, $janet->password, "The password is not upgraded in place.");
|
|
};
|
|
|
|
subtest "Running hydra-init don't break Alice or Janet's passwords" => sub {
|
|
my ($res, $stdout, $stderr) = captureStdoutStderr(30, ("hydra-init"));
|
|
is($res, 0, "hydra-init should exit zero");
|
|
|
|
my $updatedAlice = $db->resultset('Users')->find({ username => "alice" });
|
|
ok($updatedAlice->check_password("foobar"), "Alice's password validates");
|
|
|
|
my $updatedJanet = $db->resultset('Users')->find({ username => "janet" });
|
|
ok($updatedJanet->check_password("foobar"), "Janet's password validates");
|
|
};
|
|
|
|
};
|
|
|
|
done_testing;
|