* [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
* [pve-devel] applied: [PATCH pve-network] tests: mocking cfs_lock_file to pass subnet tests
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 ` Thomas Lamprecht
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2023-11-29 14:09 UTC (permalink / raw)
To: Proxmox VE development discussion, Stefan Lendl
Am 24/11/2023 um 14:16 schrieb Stefan Lendl:
> 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(-)
>
>
applied, many thanks, we now can build as non-root which is a big
step forward.
But building in contained environments like the one from sbuild
still fails, I now added a few commits to improve the error reporting
situation in some tests, and found that it's basically the reading
of /etc/network/interfaces inside PVE::Network::SDN::Controllers's
generate_controller_config. Here we could move out getting the file
location ($current_config_file) to a extra sub and mock that then
in the test system, if you'd like to check that out.
As ideally, no files outside the test directories would be parsed or
written.
^ 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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox