Skip to content

Commit

Permalink
Use the fallback method for finding Stratis block devices
Browse files Browse the repository at this point in the history
Do not expect udev to catch up in time.

Signed-off-by: mulhern <[email protected]>
  • Loading branch information
mulkieran committed Feb 11, 2020
1 parent 6e4a088 commit 4e68ddc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
12 changes: 9 additions & 3 deletions src/engine/strat_engine/backstore/backstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,9 @@ mod tests {
use devicemapper::{CacheDevStatus, DataBlocks, IEC};

use crate::engine::strat_engine::{
backstore::{identify::find_all, metadata::device_identifiers},
backstore::{
identify::find_all_block_devices_with_stratis_signatures, metadata::device_identifiers,
},
cmd,
tests::{loopbacked, real},
};
Expand Down Expand Up @@ -803,6 +805,10 @@ mod tests {
/// Setup the same backstore again.
/// Verify blockdev metadata again.
/// Destroy all.
// This method uses the fallback method for finding all Stratis devices,
// since udev sometimes can not catch up to the changes made in this test
// in the time the test allows. The fallback method has the long name
// "find_all_block_devices_with_stratis_signatures".
fn test_setup(paths: &[&Path]) {
assert!(paths.len() > 1);

Expand Down Expand Up @@ -852,7 +858,7 @@ mod tests {

cmd::udev_settle().unwrap();

let map = find_all().unwrap();
let map = find_all_block_devices_with_stratis_signatures().unwrap();
assert_eq!(
map.keys().collect::<HashSet<&PoolUuid>>(),
vec![pool_uuid].iter().collect::<HashSet<&PoolUuid>>()
Expand All @@ -870,7 +876,7 @@ mod tests {

cmd::udev_settle().unwrap();

let map = find_all().unwrap();
let map = find_all_block_devices_with_stratis_signatures().unwrap();
assert_eq!(
map.keys().collect::<HashSet<&PoolUuid>>(),
vec![pool_uuid].iter().collect::<HashSet<&PoolUuid>>()
Expand Down
13 changes: 10 additions & 3 deletions src/engine/strat_engine/backstore/devices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,10 @@ mod tests {
use uuid::Uuid;

use crate::engine::strat_engine::{
backstore::{identify::find_all, metadata::device_identifiers, setup::get_metadata},
backstore::{
identify::find_all_block_devices_with_stratis_signatures, metadata::device_identifiers,
setup::get_metadata,
},
cmd,
tests::{loopbacked, real},
};
Expand Down Expand Up @@ -441,6 +444,10 @@ mod tests {
/// 5. Run find_all() again and verify that both sets of devices are found.
/// 6. Verify that get_metadata() return an error. initialize() only
/// initializes block devices, it does not write metadata.
// This method uses the fallback method for finding all Stratis devices,
// since udev sometimes can not catch up to the changes made in this test
// in the time the test allows. The fallback method has the long name
// "find_all_block_devices_with_stratis_signatures".
fn test_initialize(paths: &[&Path]) {
assert!(paths.len() > 1);

Expand Down Expand Up @@ -468,7 +475,7 @@ mod tests {
cmd::udev_settle().unwrap();

{
let pools = find_all().unwrap();
let pools = find_all_block_devices_with_stratis_signatures().unwrap();

assert_eq!(pools.len(), 1);
assert!(pools.contains_key(&uuid1));
Expand Down Expand Up @@ -501,7 +508,7 @@ mod tests {
cmd::udev_settle().unwrap();

{
let pools = find_all().unwrap();
let pools = find_all_block_devices_with_stratis_signatures().unwrap();

assert_eq!(pools.len(), 2);
assert!(pools.contains_key(&uuid1));
Expand Down
2 changes: 1 addition & 1 deletion src/engine/strat_engine/backstore/identify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ fn process_unowned_device(dev: &libudev::Device) -> Option<(PoolUuid, DevUuid, D

// Use udev to identify all block devices and return the subset of those
// that have Stratis signatures.
fn find_all_block_devices_with_stratis_signatures(
pub fn find_all_block_devices_with_stratis_signatures(
) -> libudev::Result<HashMap<PoolUuid, HashMap<Device, PathBuf>>> {
let context = libudev::Context::new()?;
let mut enumerator = block_enumerator(&context)?;
Expand Down

0 comments on commit 4e68ddc

Please sign in to comment.