From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup v2 2/2] tape/inventory: fix the tape tests as user, by mocking the lock
Date: Mon, 6 Sep 2021 17:00:26 +0200 [thread overview]
Message-ID: <20210906150026.1551456-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20210906150026.1551456-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 implementing 'open_backup_lockfile' with
'create_mocked_lock'
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
changes from v1:
* put unsafe block around 'create_mocked_lock'
src/tape/inventory.rs | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/src/tape/inventory.rs b/src/tape/inventory.rs
index d56b2144..93d72057 100644
--- a/src/tape/inventory.rs
+++ b/src/tape/inventory.rs
@@ -40,7 +40,20 @@ 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)]
+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(unsafe { pbs_config::create_mocked_lock() })
+}
+
use crate::{
api2::types::{
--
2.30.2
next prev parent reply other threads:[~2021-09-06 15:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-06 15:00 [pbs-devel] [PATCH proxmox-backup v2 1/2] pbs-config: add 'create_mocked_lock' helper Dominik Csapak
2021-09-06 15:00 ` Dominik Csapak [this message]
2021-09-07 7:05 ` [pbs-devel] applied: " Wolfgang Bumiller
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=20210906150026.1551456-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