]>
git.proxmox.com Git - pve-manager.git/blob - test/replication_test2.pl
3 # Note: Test replication scheduler
9 use lib
('.', '../..');
14 use ReplicationTestEnv
;
15 use Test
::More tests
=> 1;
17 use PVE
::API2
::Replication
;
19 $ReplicationTestEnv::mocked_nodename
= 'node1';
23 my $mocked_replicate = sub {
24 my ($guest_class, $jobcfg, $state, $start_time, $logfunc) = @_;
28 guest
=> $jobcfg->{guest
},
29 vmtype
=> $jobcfg->{vmtype
},
30 guest_class
=> $guest_class,
31 last_sync
=> $state->{last_sync
},
36 my $pve_replication_module = Test
::MockModule-
>new('PVE::Replication');
37 $pve_replication_module->mock(replicate
=> $mocked_replicate);
39 $ReplicationTestEnv::mocked_replication_jobs
= {
47 'target' => 'node1', # local node, job should be skipped
52 $ReplicationTestEnv::mocked_vm_configs
= {
56 ide0
=> 'local-lvm:vm-900-disk-1,size=4G',
58 ide2
=> 'none,media=cdrom',
62 ReplicationTestEnv
::setup
();
64 for (my $i = 0; $i < 61; $i++) {
65 PVE
::API2
::Replication
::run_jobs
($i*60);
68 #print Dumper($schedule);
70 my $exptected_schedule = [
75 guest_class
=> 'PVE::QemuConfig',
76 id
=> '900-1_to_node2',
83 guest_class
=> 'PVE::QemuConfig',
84 id
=> '900-1_to_node2',
91 guest_class
=> 'PVE::QemuConfig',
92 id
=> '900-1_to_node2',
99 guest_class
=> 'PVE::QemuConfig',
100 id
=> '900-1_to_node2',
105 is_deeply
($schedule, $exptected_schedule);