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