all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH pve-network] tests: mocking cfs_lock_file to pass subnet tests
@ 2023-11-24 13:16 Stefan Lendl
  2023-11-29 14:09 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Lendl @ 2023-11-24 13:16 UTC (permalink / raw)
  To: pve-devel

IPAM tries to lock file in clusterfs which it can't when testing as
non-root.

Mocking cfs_lock_file to emulate locking behavior.

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
---
 src/test/run_test_subnets.pl | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/test/run_test_subnets.pl b/src/test/run_test_subnets.pl
index 49b4205..7d57e99 100755
--- a/src/test/run_test_subnets.pl
+++ b/src/test/run_test_subnets.pl
@@ -18,6 +18,23 @@ use JSON;
 use Data::Dumper qw(Dumper);
 $Data::Dumper::Sortkeys = 1;
 
+
+my $locks = {};
+
+my $mocked_cfs_lock_file = sub {
+    my ($filename, $timeout, $code, @param) = @_;
+
+    die "$filename already locked\n" if ($locks->{$filename});
+
+    $locks->{$filename} = 1;
+
+    my $res = eval { $code->(@param); };
+
+    delete $locks->{$filename};
+
+    return $res;
+};
+
 sub read_sdn_config {
     my ($file) = @_;
     # Read structure back in again
@@ -98,7 +115,8 @@ foreach my $path (@plugins) {
 	    write_db => sub {
 		my ($cfg) = @_;
 		$ipamdb = $cfg;
-	    }
+	    },
+	    cfs_lock_file => $mocked_cfs_lock_file,
 	);
     }
 
-- 
2.42.0





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-11-29 14:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-24 13:16 [pve-devel] [PATCH pve-network] tests: mocking cfs_lock_file to pass subnet tests Stefan Lendl
2023-11-29 14:09 ` [pve-devel] applied: " Thomas Lamprecht

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal