Skip to content

Commit

Permalink
Merge pull request #3967 from wasmerio/flaky-caching-test
Browse files Browse the repository at this point in the history
Use logs instead of timing to determine if the package cache was hit
  • Loading branch information
Michael-F-Bryan committed Jun 7, 2023
2 parents fe1b440 + 2993892 commit c2867bb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/wasi/src/runtime/package_loader/builtin_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl BuiltinPackageLoader {

if let Some(cached) = self.fs.lookup(hash).await? {
// Note: We want to propagate it to the in-memory cache, too
tracing::debug!("Copying from the filesystem cache to the in-memory cache",);
tracing::debug!("Copying from the filesystem cache to the in-memory cache");
self.in_memory.save(&cached, *hash);
return Ok(Some(cached));
}
Expand Down
21 changes: 13 additions & 8 deletions tests/integration/cli/tests/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,19 +497,24 @@ fn run_test_caching_works_for_packages_with_versions() {

assert.stdout("hello\n");

let time = std::time::Instant::now();

let assert = Command::new(get_wasmer_path())
.arg("python/python@0.1.0")
.arg(format!("--mapdir=/app:{}", ASSET_PATH))
.arg("/app/test.py")
.assert()
.success();

assert.stdout("hello\n");
.env(
"RUST_LOG",
"wasmer_wasix::runtime::package_loader::builtin_loader=debug",
)
.assert();

// package should be cached
assert!(std::time::Instant::now() - time < std::time::Duration::from_secs(1));
assert
.success()
// it should have ran like normal
.stdout("hello\n")
// we hit the cache while fetching the package
.stderr(contains(
"builtin_loader: Cache hit! pkg.name=\"python\" pkg.version=0.1.0",
));
}

// FIXME: Re-enable. See https://github.com/wasmerio/wasmer/issues/3717
Expand Down

0 comments on commit c2867bb

Please sign in to comment.