[pve-devel] [PATCH pve-manager 08/18] replication_test4.pl: Test replication job failure

Dietmar Maurer dietmar at proxmox.com
Tue May 23 09:08:47 CEST 2017


Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
 bin/test/replication_test4.log |  7 +++++
 bin/test/replication_test4.pl  | 68 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 100644 bin/test/replication_test4.log
 create mode 100755 bin/test/replication_test4.pl

diff --git a/bin/test/replication_test4.log b/bin/test/replication_test4.log
new file mode 100644
index 00000000..3e269748
--- /dev/null
+++ b/bin/test/replication_test4.log
@@ -0,0 +1,7 @@
+1000 job_900_to_node2: new job next_sync => 900
+1000 job_900_to_node2: changed config next_sync => 1300
+1000 job_900_to_node2: changed state last_try => 1000, fail_count => 1, error => faked replication error
+1300 job_900_to_node2: changed config next_sync => 1900
+1300 job_900_to_node2: changed state last_try => 1300, fail_count => 2
+1900 job_900_to_node2: changed config next_sync => 0
+1900 job_900_to_node2: changed state last_try => 1900, fail_count => 3
diff --git a/bin/test/replication_test4.pl b/bin/test/replication_test4.pl
new file mode 100755
index 00000000..2a8b339b
--- /dev/null
+++ b/bin/test/replication_test4.pl
@@ -0,0 +1,68 @@
+#!/usr/bin/perl
+
+# Note: Test replication job failure
+
+use strict;
+use warnings;
+use JSON;
+
+use lib ('.', '../..');
+
+use Data::Dumper;
+
+use Test::MockModule;
+use ReplicationTestEnv;
+
+use PVE::Tools;
+
+$ReplicationTestEnv::mocked_nodename = 'node1';
+
+my $pve_replication_module = Test::MockModule->new('PVE::Replication');
+$pve_replication_module->mock(
+    replicate => sub { die "faked replication error\n"; });
+
+my $testjob = {
+    'type'  => 'local',
+    'target' => 'node1',
+    'guest' => 900,
+};
+
+$ReplicationTestEnv::mocked_replication_jobs = {
+    job_900_to_node2 => {
+	'type'  => 'local',
+	'target' => 'node2',
+	'guest' => 900,
+    },
+    job_900_to_node1 => {
+	'type'  => 'local',
+	'target' => 'node1', # local node, job should be skipped
+	'guest' => 900,
+    },
+};
+
+$ReplicationTestEnv::mocked_vm_configs = {
+    900 => {
+	node => 'node1',
+	snapshots => {},
+	ide0 => 'local-lvm:vm-900-disk-1,size=4G',
+	memory => 512,
+	ide2 => 'none,media=cdrom',
+    },
+};
+
+ReplicationTestEnv::setup();
+
+my $ctime = 1000;
+
+my $status;
+
+ReplicationTestEnv::openlog();
+
+for (my $i = 0; $i < 120; $i++) {
+    ReplicationTestEnv::track_jobs($ctime);
+    $ctime += 60;
+}
+
+ReplicationTestEnv::commit_log();
+
+exit(0);
-- 
2.11.0




More information about the pve-devel mailing list