]> git.proxmox.com Git - pve-manager.git/commitdiff
tests: mock PVE::Cluster::get_members and adapt fail test
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Tue, 27 Jun 2017 13:47:24 +0000 (15:47 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 28 Jun 2017 04:05:44 +0000 (06:05 +0200)
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.

bin/test/ReplicationTestEnv.pm
bin/test/replication_test4.log

index 5f67f10eff40016cfda5a34abc3beb54df461f43..ab27f6684e435e83010c650386a476b6c7a84043 100755 (executable)
@@ -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; });
 };
 
index 58df7591630bb18ba93b43e4d0e7e08c7a613616..cedd6e560933a051c47e49ea297f027a811289d5 100644 (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