tape: fix MediaPool regression tests
This commit is contained in:
parent
8b1289f3e4
commit
c046739461
@ -763,6 +763,11 @@ pub fn lock_media_pool(base_path: &Path, name: &str) -> Result<File, Error> {
|
|||||||
let timeout = std::time::Duration::new(10, 0);
|
let timeout = std::time::Duration::new(10, 0);
|
||||||
let lock = proxmox::tools::fs::open_file_locked(&path, timeout, true)?;
|
let lock = proxmox::tools::fs::open_file_locked(&path, timeout, true)?;
|
||||||
|
|
||||||
|
if cfg!(test) {
|
||||||
|
// We cannot use chown inside test environment (no permissions)
|
||||||
|
return Ok(lock);
|
||||||
|
}
|
||||||
|
|
||||||
let backup_user = crate::backup::backup_user()?;
|
let backup_user = crate::backup::backup_user()?;
|
||||||
fchown(lock.as_raw_fd(), Some(backup_user.uid), Some(backup_user.gid))?;
|
fchown(lock.as_raw_fd(), Some(backup_user.uid), Some(backup_user.gid))?;
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ fn test_alloc_writable_media_1() -> Result<(), Error> {
|
|||||||
RetentionPolicy::KeepForever,
|
RetentionPolicy::KeepForever,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
false,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
ctime += 10;
|
ctime += 10;
|
||||||
@ -71,6 +72,7 @@ fn test_alloc_writable_media_2() -> Result<(), Error> {
|
|||||||
RetentionPolicy::KeepForever,
|
RetentionPolicy::KeepForever,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
false,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let ctime = 10;
|
let ctime = 10;
|
||||||
@ -110,6 +112,7 @@ fn test_alloc_writable_media_3() -> Result<(), Error> {
|
|||||||
RetentionPolicy::KeepForever,
|
RetentionPolicy::KeepForever,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
false,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let mut ctime = 10;
|
let mut ctime = 10;
|
||||||
@ -156,6 +159,7 @@ fn test_alloc_writable_media_4() -> Result<(), Error> {
|
|||||||
RetentionPolicy::ProtectFor(parse_time_span("12s")?),
|
RetentionPolicy::ProtectFor(parse_time_span("12s")?),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
false,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let start_time = 10;
|
let start_time = 10;
|
||||||
|
@ -69,6 +69,7 @@ fn test_compute_media_state() -> Result<(), Error> {
|
|||||||
RetentionPolicy::KeepForever,
|
RetentionPolicy::KeepForever,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
false,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// tape1 is free
|
// tape1 is free
|
||||||
@ -116,6 +117,7 @@ fn test_media_expire_time() -> Result<(), Error> {
|
|||||||
RetentionPolicy::ProtectFor(span),
|
RetentionPolicy::ProtectFor(span),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
false,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
assert_eq!(pool.lookup_media(&tape0_uuid)?.status(), &MediaStatus::Full);
|
assert_eq!(pool.lookup_media(&tape0_uuid)?.status(), &MediaStatus::Full);
|
||||||
|
@ -49,6 +49,7 @@ fn test_current_set_usable_1() -> Result<(), Error> {
|
|||||||
RetentionPolicy::KeepForever,
|
RetentionPolicy::KeepForever,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
false,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
assert_eq!(pool.current_set_usable()?, false);
|
assert_eq!(pool.current_set_usable()?, false);
|
||||||
@ -75,6 +76,7 @@ fn test_current_set_usable_2() -> Result<(), Error> {
|
|||||||
RetentionPolicy::KeepForever,
|
RetentionPolicy::KeepForever,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
false,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
assert_eq!(pool.current_set_usable()?, false);
|
assert_eq!(pool.current_set_usable()?, false);
|
||||||
@ -103,6 +105,7 @@ fn test_current_set_usable_3() -> Result<(), Error> {
|
|||||||
RetentionPolicy::KeepForever,
|
RetentionPolicy::KeepForever,
|
||||||
Some(String::from("changer1")),
|
Some(String::from("changer1")),
|
||||||
None,
|
None,
|
||||||
|
false,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
assert_eq!(pool.current_set_usable()?, false);
|
assert_eq!(pool.current_set_usable()?, false);
|
||||||
@ -131,6 +134,7 @@ fn test_current_set_usable_4() -> Result<(), Error> {
|
|||||||
RetentionPolicy::KeepForever,
|
RetentionPolicy::KeepForever,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
false,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
assert_eq!(pool.current_set_usable()?, true);
|
assert_eq!(pool.current_set_usable()?, true);
|
||||||
@ -161,6 +165,7 @@ fn test_current_set_usable_5() -> Result<(), Error> {
|
|||||||
RetentionPolicy::KeepForever,
|
RetentionPolicy::KeepForever,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
false,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
assert_eq!(pool.current_set_usable()?, true);
|
assert_eq!(pool.current_set_usable()?, true);
|
||||||
@ -189,6 +194,7 @@ fn test_current_set_usable_6() -> Result<(), Error> {
|
|||||||
RetentionPolicy::KeepForever,
|
RetentionPolicy::KeepForever,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
false,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
assert!(pool.current_set_usable().is_err());
|
assert!(pool.current_set_usable().is_err());
|
||||||
@ -223,6 +229,7 @@ fn test_current_set_usable_7() -> Result<(), Error> {
|
|||||||
RetentionPolicy::KeepForever,
|
RetentionPolicy::KeepForever,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
false,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
assert!(pool.current_set_usable().is_err());
|
assert!(pool.current_set_usable().is_err());
|
||||||
|
Loading…
Reference in New Issue
Block a user