Skip to content

Commit

Permalink
Merge pull request #3611 from mulkieran/expand-fs-size-limit-test
Browse files Browse the repository at this point in the history
Expand fs size limit test
  • Loading branch information
mulkieran authored May 8, 2024
2 parents bca4df0 + e29cb3b commit e97781c
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions src/engine/strat_engine/thinpool/thinpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2590,14 +2590,14 @@ mod tests {
pool_name,
pool_uuid,
"stratis_test_filesystem",
Sectors::from(1200 * IEC::Ki),
// 700 * IEC::Mi
Some(Sectors(1400 * IEC::Ki)),
Sectors::from(2400 * IEC::Ki),
// 1400 * IEC::Mi
Some(Sectors(2800 * IEC::Ki)),
)
.unwrap();
let devnode = {
let (_, fs) = pool.get_mut_filesystem_by_uuid(fs_uuid).unwrap();
assert_eq!(fs.size_limit(), Some(Sectors(1400 * IEC::Ki)));
assert_eq!(fs.size_limit(), Some(Sectors(2800 * IEC::Ki)));
fs.devnode()
};

Expand All @@ -2621,8 +2621,8 @@ mod tests {
.open(new_file)
.unwrap();
let mut bytes_written = Bytes(0);
// Write 400 * IEC::Mi
while bytes_written < Bytes::from(400 * IEC::Mi) {
// Write 800 * IEC::Mi
while bytes_written < Bytes::from(800 * IEC::Mi) {
file.write_all(&[1; 4096]).unwrap();
bytes_written += Bytes(4096);
}
Expand All @@ -2634,13 +2634,20 @@ mod tests {
assert_eq!(fs.size_limit(), Some(fs.size().sectors()));
}

// 800 * IEC::Mi
pool.set_fs_size_limit(fs_uuid, Some(Sectors(1600 * IEC::Ki)))
// 1600 * IEC::Mi
pool.set_fs_size_limit(fs_uuid, Some(Sectors(3200 * IEC::Ki)))
.unwrap();
{
let (_, fs) = pool.get_mut_filesystem_by_uuid(fs_uuid).unwrap();
assert_eq!(fs.size_limit(), Some(Sectors(1600 * IEC::Ki)));
assert_eq!(fs.size_limit(), Some(Sectors(3200 * IEC::Ki)));
}
let mut bytes_written = Bytes(0);
// Write 200 * IEC::Mi
while bytes_written < Bytes::from(200 * IEC::Mi) {
file.write_all(&[1; 4096]).unwrap();
bytes_written += Bytes(4096);
}
file.sync_all().unwrap();
pool.check_fs(pool_uuid, &backstore).unwrap();

{
Expand All @@ -2652,7 +2659,7 @@ mod tests {
let (_, fs) = pool
.snapshot_filesystem(pool_name, pool_uuid, fs_uuid, "snapshot")
.unwrap();
assert_eq!(fs.size_limit(), Some(Sectors(1600 * IEC::Ki)));
assert_eq!(fs.size_limit(), Some(Sectors(3200 * IEC::Ki)));
}

pool.set_fs_size_limit(fs_uuid, None).unwrap();
Expand All @@ -2661,8 +2668,8 @@ mod tests {
assert_eq!(fs.size_limit(), None);
}
let mut bytes_written = Bytes(0);
// Write 200 * IEC::Mi
while bytes_written < Bytes::from(200 * IEC::Mi) {
// Write 400 * IEC::Mi
while bytes_written < Bytes::from(400 * IEC::Mi) {
file.write_all(&[1; 4096]).unwrap();
bytes_written += Bytes(4096);
}
Expand All @@ -2671,7 +2678,7 @@ mod tests {

{
let (_, fs) = pool.get_mut_filesystem_by_uuid(fs_uuid).unwrap();
assert_eq!(fs.size().sectors(), Sectors(3200 * IEC::Ki));
assert_eq!(fs.size().sectors(), Sectors(6400 * IEC::Ki));
}

assert!(pool.set_fs_size_limit(fs_uuid, Some(Sectors(50))).is_err());
Expand Down

0 comments on commit e97781c

Please sign in to comment.