[pve-devel] [PATCH manager] tests: mock PVE::Cluster::get_members and adapt fail test

Wolfgang Bumiller w.bumiller at proxmox.com
Tue Jun 27 15:47:24 CEST 2017


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 | 11 ++++++++++-
 bin/test/replication_test4.log | 14 +++++++++++++-
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/bin/test/ReplicationTestEnv.pm b/bin/test/ReplicationTestEnv.pm
index 5f67f10e..ab27f668 100755
--- a/bin/test/ReplicationTestEnv.pm
+++ b/bin/test/ReplicationTestEnv.pm
@@ -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; });
 };
 
diff --git a/bin/test/replication_test4.log b/bin/test/replication_test4.log
index 58df7591..cedd6e56 100644
--- a/bin/test/replication_test4.log
+++ b/bin/test/replication_test4.log
@@ -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
-- 
2.11.0





More information about the pve-devel mailing list