]>
git.proxmox.com Git - pve-manager-legacy.git/blob - test/replication_test2.pl
ff5fbaff9d5a8d217b0696bb4592f02ec5aa4eec
3 # Note: Test replication scheduler
9 use lib
('.', '../..');
12 use Test
::More tests
=> 1;
14 use ReplicationTestEnv
;
15 use PVE
::API2
::Replication
;
17 $ReplicationTestEnv::mocked_nodename
= 'node1';
21 my $mocked_replicate = sub {
22 my ($guest_class, $jobcfg, $state, $start_time, $logfunc) = @_;
26 guest
=> $jobcfg->{guest
},
27 vmtype
=> $jobcfg->{vmtype
},
28 guest_class
=> $guest_class,
29 last_sync
=> $state->{last_sync
},
34 my $pve_replication_module = Test
::MockModule-
>new('PVE::Replication');
35 $pve_replication_module->mock(replicate
=> $mocked_replicate);
37 $ReplicationTestEnv::mocked_replication_jobs
= {
45 'target' => 'node1', # local node, job should be skipped
50 $ReplicationTestEnv::mocked_vm_configs
= {
54 ide0
=> 'local-lvm:vm-900-disk-1,size=4G',
56 ide2
=> 'none,media=cdrom',
60 ReplicationTestEnv
::setup
();
62 for (my $i = 0; $i < 61; $i++) {
63 PVE
::API2
::Replication
::run_jobs
($i*60);
66 my $exptected_schedule = [
71 guest_class
=> 'PVE::QemuConfig',
72 id
=> '900-1_to_node2',
79 guest_class
=> 'PVE::QemuConfig',
80 id
=> '900-1_to_node2',
87 guest_class
=> 'PVE::QemuConfig',
88 id
=> '900-1_to_node2',
95 guest_class
=> 'PVE::QemuConfig',
96 id
=> '900-1_to_node2',
101 is_deeply
($schedule, $exptected_schedule);