Skip to content

Commit

Permalink
Use bool param for round_trip_test_compressed (#8252)
Browse files Browse the repository at this point in the history
As per @koivunej 's request in
#8238 (comment) ,
use a runtime param instead of monomorphizing the function based on the value.

Part of #5431
  • Loading branch information
arpad-m authored Jul 4, 2024
1 parent a462537 commit a004d27
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions pageserver/src/tenant/blob_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,11 +393,12 @@ mod tests {
use rand::{Rng, SeedableRng};

async fn round_trip_test<const BUFFERED: bool>(blobs: &[Vec<u8>]) -> Result<(), Error> {
round_trip_test_compressed::<BUFFERED, false>(blobs).await
round_trip_test_compressed::<BUFFERED>(blobs, false).await
}

async fn round_trip_test_compressed<const BUFFERED: bool, const COMPRESSION: bool>(
async fn round_trip_test_compressed<const BUFFERED: bool>(
blobs: &[Vec<u8>],
compression: bool,
) -> Result<(), Error> {
let temp_dir = camino_tempfile::tempdir()?;
let pathbuf = temp_dir.path().join("file");
Expand All @@ -409,7 +410,7 @@ mod tests {
let file = VirtualFile::create(pathbuf.as_path(), &ctx).await?;
let mut wtr = BlobWriter::<BUFFERED>::new(file, 0);
for blob in blobs.iter() {
let (_, res) = if COMPRESSION {
let (_, res) = if compression {
wtr.write_blob_maybe_compressed(
blob.clone(),
&ctx,
Expand All @@ -432,7 +433,7 @@ mod tests {

let file = VirtualFile::open(pathbuf.as_path(), &ctx).await?;
let rdr = BlockReaderRef::VirtualFile(&file);
let rdr = BlockCursor::new_with_compression(rdr, COMPRESSION);
let rdr = BlockCursor::new_with_compression(rdr, compression);
for (idx, (blob, offset)) in blobs.iter().zip(offsets.iter()).enumerate() {
let blob_read = rdr.read_blob(*offset, &ctx).await?;
assert_eq!(
Expand Down Expand Up @@ -466,8 +467,8 @@ mod tests {
];
round_trip_test::<false>(blobs).await?;
round_trip_test::<true>(blobs).await?;
round_trip_test_compressed::<false, true>(blobs).await?;
round_trip_test_compressed::<true, true>(blobs).await?;
round_trip_test_compressed::<false>(blobs, true).await?;
round_trip_test_compressed::<true>(blobs, true).await?;
Ok(())
}

Expand All @@ -483,8 +484,8 @@ mod tests {
];
round_trip_test::<false>(blobs).await?;
round_trip_test::<true>(blobs).await?;
round_trip_test_compressed::<false, true>(blobs).await?;
round_trip_test_compressed::<true, true>(blobs).await?;
round_trip_test_compressed::<false>(blobs, true).await?;
round_trip_test_compressed::<true>(blobs, true).await?;
Ok(())
}

Expand Down

1 comment on commit a004d27

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3093 tests run: 2964 passed, 2 failed, 127 skipped (full report)


Failures on Postgres 14

  • test_sharding_autosplit[github-actions-selfhosted]: release
  • test_storage_controller_many_tenants[github-actions-selfhosted]: release
# Run all failed tests locally:
scripts/pytest -vv -n $(nproc) -k "test_sharding_autosplit[release-pg14-github-actions-selfhosted] or test_storage_controller_many_tenants[release-pg14-github-actions-selfhosted]"
Flaky tests (2)

Postgres 16

  • test_ondemand_wal_download_in_replication_slot_funcs: release

Postgres 15

  • test_secondary_background_downloads: debug

Code coverage* (full report)

  • functions: 32.7% (6932 of 21219 functions)
  • lines: 50.1% (54439 of 108708 lines)

* collected from Rust tests only


The comment gets automatically updated with the latest test results
a004d27 at 2024-07-04T14:52:41.045Z :recycle:

Please sign in to comment.