tests: mock PVE::Cluster::get_members and adapt fail test

Commit 3385399339c94 ("replication: keep retrying every 30 minutes in
error state") changed the retry behavior to not stop after the 3rd error
and then stick to half-hour intervals. This needs to be reflected in the
tests. The numbers here match. (1900 + 30*60 = 3700).

Commit fd844180a7efa ("replication: don't sync to offline targets on
error states) changed the retry behavior to check whether the target
node is online. If this is not the case we fail right away. This
introduced a dependency on PVE::Cluster::get_members which we now need
to mock. Tests currently use node names "node{1,2,3}", so I just mock
those 3.
This commit is contained in:
Wolfgang Bumiller 2017-06-27 15:47:24 +02:00 committed by Dietmar Maurer
parent 6182161ad1
commit d0013cdb6b
2 changed files with 23 additions and 2 deletions

View File

@ -34,6 +34,14 @@ our $mocked_vm_configs = {};
our $mocked_ct_configs = {};
my $mocked_get_members = sub {
return {
node1 => { online => 1 },
node2 => { online => 1 },
node3 => { online => 1 },
};
};
my $mocked_vmlist = sub {
my $res = {};
@ -222,7 +230,8 @@ sub setup {
$pve_cluster_module->mock(
get_ssh_info => $mocked_get_ssh_info,
ssh_info_to_command => $mocked_ssh_info_to_command,
get_vmlist => sub { return $mocked_vmlist->(); });
get_vmlist => sub { return $mocked_vmlist->(); },
get_members => $mocked_get_members);
$pve_inotify_module->mock('nodename' => sub { return $mocked_nodename; });
};

View File

@ -9,5 +9,17 @@
1300 job_900_to_node2: changed state last_try => 1300, fail_count => 2
1900 job_900_to_node2: start replication job
1900 job_900_to_node2: end replication job with error: faked replication error
1900 job_900_to_node2: changed config next_sync => 0
1900 job_900_to_node2: changed config next_sync => 3700
1900 job_900_to_node2: changed state last_try => 1900, fail_count => 3
3700 job_900_to_node2: start replication job
3700 job_900_to_node2: end replication job with error: faked replication error
3700 job_900_to_node2: changed config next_sync => 5500
3700 job_900_to_node2: changed state last_try => 3700, fail_count => 4
5500 job_900_to_node2: start replication job
5500 job_900_to_node2: end replication job with error: faked replication error
5500 job_900_to_node2: changed config next_sync => 7300
5500 job_900_to_node2: changed state last_try => 5500, fail_count => 5
7300 job_900_to_node2: start replication job
7300 job_900_to_node2: end replication job with error: faked replication error
7300 job_900_to_node2: changed config next_sync => 9100
7300 job_900_to_node2: changed state last_try => 7300, fail_count => 6