From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [RFC PATCH proxmox-backup 2/2] tape/inventory: fix the tape tests as user by mocking the lock
Date: Fri, 3 Sep 2021 09:17:52 +0200 [thread overview]
Message-ID: <20210903071752.1225271-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20210903071752.1225271-1-d.csapak@proxmox.com>
locking during the tests as regular user failed because we try to
chown to the backup user (which is not always possible).
Instead, do not lock at all, by mocking the 'open_backup_lockfile' with
an empty struct that implements the locking trait
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
src/tape/inventory.rs | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/src/tape/inventory.rs b/src/tape/inventory.rs
index d56b2144..f45cec71 100644
--- a/src/tape/inventory.rs
+++ b/src/tape/inventory.rs
@@ -40,7 +40,28 @@ use proxmox::tools::{
};
use pbs_systemd::time::compute_next_event;
-use pbs_config::{open_backup_lockfile, BackupLockGuard};
+use pbs_config::BackupLockGuard;
+
+#[cfg(not(test))]
+use pbs_config::open_backup_lockfile;
+
+#[cfg(test)]
+mod lock_mocking {
+ struct MockedLock;
+
+ impl pbs_config::BackupLockGuardTrait for MockedLock {}
+
+ pub fn open_backup_lockfile<P: AsRef<std::path::Path>>(
+ _path: P,
+ _timeout: Option<std::time::Duration>,
+ _exclusive: bool,
+ ) -> Result<pbs_config::BackupLockGuard, anyhow::Error> {
+ Ok(Box::new(MockedLock))
+ }
+}
+
+#[cfg(test)]
+use lock_mocking::*;
use crate::{
api2::types::{
--
2.30.2
next prev parent reply other threads:[~2021-09-03 7:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-03 7:17 [pbs-devel] [RFC PATCH proxmox-backup 1/2] pbs-config: use trait object for the backup lock guard Dominik Csapak
2021-09-03 7:17 ` Dominik Csapak [this message]
2021-09-06 10:25 ` Wolfgang Bumiller
2021-09-06 10:41 ` Dominik Csapak
2021-09-06 10:47 ` Dominik Csapak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210903071752.1225271-2-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox