]> git.proxmox.com Git - pve-container.git/blobdiff - src/test/snapshot-test.pm
add vm_stop helper
[pve-container.git] / src / test / snapshot-test.pm
index 95f34987fdc8fb0aa19df751f003e7e2ed0f4d89..796b6b477c80fe1fc0fe6de215faf149d4c65bae 100644 (file)
@@ -10,6 +10,7 @@ use PVE::Storage::Plugin;
 use PVE::LXC;
 use PVE::LXC::Config;
 use PVE::Tools;
+use PVE::ReplicationConfig;
 
 use Test::MockModule;
 use Test::More;
@@ -111,6 +112,15 @@ sub mocked_volume_rollback_is_possible {
     die "volume_rollback_is_possible failed\n";
 }
 
+sub mocked_vm_stop {
+    if ($kill_possible) {
+       $running = 0;
+       return 1;
+    } else {
+       return 0;
+    }
+}
+
 sub mocked_run_command {
     my ($cmd, %param) = @_;
     my $cmdstring;
@@ -121,12 +131,7 @@ sub mocked_run_command {
            die "lxc-[un]freeze disabled\n";
        }
        if ($cmdstring =~ m/.*\/lxc-stop.*--kill.*/) {
-           if ($kill_possible) {
-               $running = 0;
-               return 1;
-           } else {
-               return 0;
-           }
+           mocked_vm_stop();
        }
     }
     die "unexpected run_command call: '$cmdstring', aborting\n";
@@ -241,7 +246,7 @@ sub mocked_load_config {
 
     my $raw = PVE::Tools::file_get_contents($filename);
 
-    my $conf = PVE::LXC::parse_pct_config($filename, $raw);
+    my $conf = PVE::LXC::Config::parse_pct_config($filename, $raw);
     return $conf;
 }
 
@@ -257,7 +262,7 @@ sub mocked_write_config {
        }
     }
 
-    my $raw = PVE::LXC::write_pct_config($filename, $conf);
+    my $raw = PVE::LXC::Config::write_pct_config($filename, $conf);
 
     PVE::Tools::file_set_contents($filename, $raw);
 }
@@ -273,6 +278,7 @@ printf("Setting up Mocking for PVE::LXC and PVE::LXC::Config\n");
 my $lxc_module = new Test::MockModule('PVE::LXC');
 $lxc_module->mock('sync_container_namespace', sub { return; });
 $lxc_module->mock('check_running', \&mocked_check_running);
+$lxc_module->mock('vm_stop', \&mocked_vm_stop);
 
 my $lxc_config_module = new Test::MockModule('PVE::LXC::Config');
 $lxc_config_module->mock('config_file_lock', sub { return "snapshot-working/pve-test.lock"; });
@@ -281,6 +287,10 @@ $lxc_config_module->mock('load_config', \&mocked_load_config);
 $lxc_config_module->mock('write_config', \&mocked_write_config);
 $lxc_config_module->mock('has_feature', \&mocked_has_feature);
 
+# ignore existing replication config
+my $repl_config_module = new Test::MockModule('PVE::ReplicationConfig');
+$repl_config_module->mock('check_for_existing_jobs' => sub { return undef });
+
 $running = 1;
 $freeze_possible = 1;