about summary refs log tree commit diff
path: root/tvix/store/src/blobreader.rs
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-03-01T17·55+0100
committerflokli <flokli@flokli.de>2023-03-10T10·58+0000
commita4f6c4181aa7f975b1c3aad8d3fb30021388e014 (patch)
treeee2f0a3911503ccb66f29d5b47dbdd763c02b026 /tvix/store/src/blobreader.rs
parent535e1b15ab457c9015baebf14bd7b50a38edadb4 (diff)
feat(tvix/store): add new_temporary for all Sled services r/5934
This provides a service using /dev/shm, that's deleted once the
reference is dropped.

Refactor all tests to use these, which allows getting rid of most
TempDir usage in the tests.

The only place where we still use TempDir is in the importer tests,
which work on a filesystem path.

Change-Id: I08a950aa774bf9b46d9f5c92edf5efba36053242
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8193
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/store/src/blobreader.rs')
-rw-r--r--tvix/store/src/blobreader.rs19
1 files changed, 6 insertions, 13 deletions
diff --git a/tvix/store/src/blobreader.rs b/tvix/store/src/blobreader.rs
index b4e56d909b26..4da0f9593a58 100644
--- a/tvix/store/src/blobreader.rs
+++ b/tvix/store/src/blobreader.rs
@@ -141,13 +141,11 @@ mod tests {
     use std::io::Cursor;
     use std::io::Read;
     use std::io::Write;
-    use tempfile::TempDir;
 
     #[test]
     /// reading from a blobmeta with zero chunks should produce zero bytes.
     fn empty_blobmeta() -> anyhow::Result<()> {
-        let tmpdir = TempDir::new()?;
-        let chunk_service = gen_chunk_service(tmpdir.path());
+        let chunk_service = gen_chunk_service();
 
         let blobmeta = proto::BlobMeta {
             chunks: vec![],
@@ -167,8 +165,7 @@ mod tests {
     #[test]
     /// trying to read something where the chunk doesn't exist should fail
     fn missing_chunk_fail() -> anyhow::Result<()> {
-        let tmpdir = TempDir::new()?;
-        let chunk_service = gen_chunk_service(tmpdir.path());
+        let chunk_service = gen_chunk_service();
 
         let blobmeta = proto::BlobMeta {
             chunks: vec![proto::blob_meta::ChunkMeta {
@@ -191,8 +188,7 @@ mod tests {
     #[test]
     /// read something containing the single (empty) chunk
     fn empty_chunk() -> anyhow::Result<()> {
-        let tmpdir = TempDir::new()?;
-        let chunk_service = gen_chunk_service(tmpdir.path());
+        let chunk_service = gen_chunk_service();
 
         // insert a single chunk
         let dgst = chunk_service.put(vec![]).expect("must succeed");
@@ -222,8 +218,7 @@ mod tests {
     /// read something which contains a single chunk
     #[test]
     fn single_chunk() -> anyhow::Result<()> {
-        let tmpdir = TempDir::new()?;
-        let chunk_service = gen_chunk_service(tmpdir.path());
+        let chunk_service = gen_chunk_service();
 
         // insert a single chunk
         let dgst = chunk_service
@@ -255,8 +250,7 @@ mod tests {
     /// read something referring to a chunk, but with wrong size
     #[test]
     fn wrong_size_fail() -> anyhow::Result<()> {
-        let tmpdir = TempDir::new()?;
-        let chunk_service = gen_chunk_service(tmpdir.path());
+        let chunk_service = gen_chunk_service();
 
         // insert chunks
         let dgst_1 = chunk_service
@@ -286,8 +280,7 @@ mod tests {
     /// read something referring to multiple chunks
     #[test]
     fn multiple_chunks() -> anyhow::Result<()> {
-        let tmpdir = TempDir::new()?;
-        let chunk_service = gen_chunk_service(tmpdir.path());
+        let chunk_service = gen_chunk_service();
 
         // insert chunks
         let dgst_1 = chunk_service