]>
Commit | Line | Data |
---|---|---|
6e572d46 DM |
1 | #!/usr/bin/perl |
2 | ||
3 | # Note: Test replication job failure | |
4 | ||
5 | use strict; | |
6 | use warnings; | |
7 | use JSON; | |
8 | ||
9 | use lib ('.', '../..'); | |
10 | ||
11 | use Data::Dumper; | |
12 | ||
13 | use Test::MockModule; | |
14 | use ReplicationTestEnv; | |
15 | ||
16 | use PVE::Tools; | |
17 | ||
18 | $ReplicationTestEnv::mocked_nodename = 'node1'; | |
19 | ||
20 | my $pve_replication_module = Test::MockModule->new('PVE::Replication'); | |
21 | $pve_replication_module->mock( | |
22 | replicate => sub { die "faked replication error\n"; }); | |
23 | ||
24 | my $testjob = { | |
25 | 'type' => 'local', | |
26 | 'target' => 'node1', | |
27 | 'guest' => 900, | |
28 | }; | |
29 | ||
30 | $ReplicationTestEnv::mocked_replication_jobs = { | |
31 | job_900_to_node2 => { | |
32 | 'type' => 'local', | |
33 | 'target' => 'node2', | |
34 | 'guest' => 900, | |
35 | }, | |
36 | job_900_to_node1 => { | |
37 | 'type' => 'local', | |
38 | 'target' => 'node1', # local node, job should be skipped | |
39 | 'guest' => 900, | |
40 | }, | |
41 | }; | |
42 | ||
43 | $ReplicationTestEnv::mocked_vm_configs = { | |
44 | 900 => { | |
45 | node => 'node1', | |
46 | snapshots => {}, | |
47 | ide0 => 'local-lvm:vm-900-disk-1,size=4G', | |
48 | memory => 512, | |
49 | ide2 => 'none,media=cdrom', | |
50 | }, | |
51 | }; | |
52 | ||
53 | ReplicationTestEnv::setup(); | |
54 | ||
55 | my $ctime = 1000; | |
56 | ||
57 | my $status; | |
58 | ||
59 | ReplicationTestEnv::openlog(); | |
60 | ||
61 | for (my $i = 0; $i < 120; $i++) { | |
62 | ReplicationTestEnv::track_jobs($ctime); | |
63 | $ctime += 60; | |
64 | } | |
65 | ||
66 | ReplicationTestEnv::commit_log(); | |
67 | ||
68 | exit(0); |