replication_test5.pl: add test for job removal
This commit is contained in:
parent
20698b5604
commit
f11e1a29a6
@ -48,3 +48,12 @@
|
||||
3640 job_900_to_node2: end replication job
|
||||
3640 job_900_to_node2: changed config next_sync => 4500
|
||||
3640 job_900_to_node2: changed state last_try => 3640, last_sync => 3640
|
||||
3700 job_900_to_node2: start replication job
|
||||
3700 job_900_to_node2: guest => 900, type => qemu, running => 0
|
||||
3700 job_900_to_node2: volumes => local-zfs:vm-900-disk-1,local-zfs:vm-900-disk-2
|
||||
3700 job_900_to_node2: start job removal - mode 'full'
|
||||
3700 job_900_to_node2: delete stale snapshot 'replicate_job_900_to_node2_3640_snap' on local-zfs:vm-900-disk-1
|
||||
3700 job_900_to_node2: delete stale snapshot 'replicate_job_900_to_node2_3640_snap' on local-zfs:vm-900-disk-2
|
||||
3700 job_900_to_node2: job removed
|
||||
3700 job_900_to_node2: end replication job
|
||||
3700 job_900_to_node2: vanished job
|
||||
|
@ -4,6 +4,7 @@
|
||||
# 1.) Start replication job with single disk
|
||||
# 2.) add non-existent disk (replication fails)
|
||||
# 3.) create disk (replication continues).
|
||||
# 4.) remove job
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
@ -31,7 +32,7 @@ use PVE::Storage;
|
||||
my $replicated_volume_status = {};
|
||||
|
||||
my $mocked_remote_prepare_local_job = sub {
|
||||
my ($ssh_info, $jobid, $vmid, $volumes, $last_sync) = @_;
|
||||
my ($ssh_info, $jobid, $vmid, $volumes, $last_sync, $force) = @_;
|
||||
|
||||
my $target = $ssh_info->{node};
|
||||
|
||||
@ -42,6 +43,10 @@ my $mocked_remote_prepare_local_job = sub {
|
||||
my $last_sync_snapname = PVE::Replication::replication_snapshot_name($jobid, $last_sync);
|
||||
|
||||
foreach my $volid (keys %{$replicated_volume_status->{$target}}) {
|
||||
if (!grep { $_ eq $volid } @$volumes) {
|
||||
delete $replicated_volume_status->{$target}->{$volid};
|
||||
next;
|
||||
}
|
||||
my $snapname = $replicated_volume_status->{$target}->{$volid};
|
||||
|
||||
$last_snapshots->{$volid} = 1 if $last_sync_snapname eq $snapname;
|
||||
@ -64,8 +69,15 @@ my $mocked_replicate_volume = sub {
|
||||
$replicated_volume_status->{$target}->{$volid} = $sync_snapname;
|
||||
};
|
||||
|
||||
my $mocked_delete_job = sub {
|
||||
my ($jobid) = @_;
|
||||
|
||||
delete $ReplicationTestEnv::mocked_replication_jobs->{$jobid};
|
||||
};
|
||||
|
||||
my $pve_replication_module = Test::MockModule->new('PVE::Replication');
|
||||
$pve_replication_module->mock(
|
||||
delete_job => $mocked_delete_job,
|
||||
remote_prepare_local_job => $mocked_remote_prepare_local_job,
|
||||
remote_finalize_local_job => $mocked_remote_finalize_local_job,
|
||||
replicate_volume => $mocked_replicate_volume);
|
||||
@ -123,6 +135,15 @@ for (my $i = 0; $i < 15; $i++) {
|
||||
$ctime += 60;
|
||||
}
|
||||
|
||||
# mark job for removal
|
||||
$ReplicationTestEnv::mocked_replication_jobs->{job_900_to_node2}->{remove_job} = 'full';
|
||||
for (my $i = 0; $i < 15; $i++) {
|
||||
ReplicationTestEnv::track_jobs($ctime);
|
||||
$ctime += 60;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ReplicationTestEnv::commit_log();
|
||||
|
||||
exit(0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user