about summary refs log tree commit diff
path: root/tvix/castore/src/proto/tests/grpc_blobservice.rs
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-03-20T20·36+0200
committerflokli <flokli@flokli.de>2024-03-28T07·58+0000
commit74023a07a4b3d8e99645217b04683c0e54e23be8 (patch)
treee5c7f42540efe6dc94666e2694031b14ccd6715b /tvix/castore/src/proto/tests/grpc_blobservice.rs
parent05d3f21eaf0834d44b6f32a49ae3276ebcb6571c (diff)
refactor(tvix/castore/*): drop utils.rs and grpc directorysvc tests r/7795
This drops pretty much all of castore/utils.rs.

There were only two things left in there, both a bit messy and only used
for tests:

Some `gen_*_service()` helper functions. These can be expressed by
`from_addr("memory://")`.

The other thing was some plumbing code to test the gRPC layer, by
exposing a in-memory implementation via gRPC, and then connecting to
that channel via a gRPC client again.

Previous CLs moved the connection setup code to
{directory,blob}service::tests::utils, close to where we exercise them,
the new rstest-based tests.

The tests interacting directly on the gRPC types are removed, all
scenarios that were in there show now be covered through the rstest ones
on the trait level.

Change-Id: I450ccccf983b4c62145a25d81c36a40846664814
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11223
Reviewed-by: Connor Brewster <cbrewster@hey.com>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/castore/src/proto/tests/grpc_blobservice.rs')
-rw-r--r--tvix/castore/src/proto/tests/grpc_blobservice.rs94
1 files changed, 0 insertions, 94 deletions
diff --git a/tvix/castore/src/proto/tests/grpc_blobservice.rs b/tvix/castore/src/proto/tests/grpc_blobservice.rs
deleted file mode 100644
index fb202b7d8a..0000000000
--- a/tvix/castore/src/proto/tests/grpc_blobservice.rs
+++ /dev/null
@@ -1,94 +0,0 @@
-use crate::fixtures::{BLOB_A, BLOB_A_DIGEST};
-use crate::proto::{BlobChunk, ReadBlobRequest, StatBlobRequest};
-use crate::utils::gen_blobsvc_grpc_client;
-use tokio_stream::StreamExt;
-
-/// Trying to read a non-existent blob should return a not found error.
-#[tokio::test]
-async fn not_found_read() {
-    let mut grpc_client = gen_blobsvc_grpc_client().await;
-
-    let resp = grpc_client
-        .read(ReadBlobRequest {
-            digest: BLOB_A_DIGEST.clone().into(),
-        })
-        .await;
-
-    // We can't use unwrap_err here, because the Ok value doesn't implement
-    // debug.
-    if let Err(e) = resp {
-        assert_eq!(e.code(), tonic::Code::NotFound);
-    } else {
-        panic!("resp is not err")
-    }
-}
-
-/// Trying to stat a non-existent blob should return a not found error.
-#[tokio::test]
-async fn not_found_stat() {
-    let mut grpc_client = gen_blobsvc_grpc_client().await;
-
-    let resp = grpc_client
-        .stat(StatBlobRequest {
-            digest: BLOB_A_DIGEST.clone().into(),
-            ..Default::default()
-        })
-        .await
-        .expect_err("must fail");
-
-    // The resp should be a status with Code::NotFound
-    assert_eq!(resp.code(), tonic::Code::NotFound);
-}
-
-/// Put a blob in the store, get it back.
-#[tokio::test]
-async fn put_read_stat() {
-    let mut grpc_client = gen_blobsvc_grpc_client().await;
-
-    // Send blob A.
-    let put_resp = grpc_client
-        .put(tokio_stream::once(BlobChunk {
-            data: BLOB_A.clone(),
-        }))
-        .await
-        .expect("must succeed")
-        .into_inner();
-
-    assert_eq!(BLOB_A_DIGEST.as_slice(), put_resp.digest);
-
-    // Stat for the digest of A.
-    // We currently don't ask for more granular chunking data, as we don't
-    // expose it yet.
-    let _resp = grpc_client
-        .stat(StatBlobRequest {
-            digest: BLOB_A_DIGEST.clone().into(),
-            ..Default::default()
-        })
-        .await
-        .expect("must succeed")
-        .into_inner();
-
-    // Read the blob. It should return the same data.
-    let resp = grpc_client
-        .read(ReadBlobRequest {
-            digest: BLOB_A_DIGEST.clone().into(),
-        })
-        .await;
-
-    let mut rx = resp.ok().unwrap().into_inner();
-
-    // the stream should contain one element, a BlobChunk with the same contents as BLOB_A.
-    let item = rx
-        .next()
-        .await
-        .expect("must be some")
-        .expect("must succeed");
-
-    assert_eq!(BLOB_A.clone(), item.data);
-
-    // … and no more elements
-    assert!(rx.next().await.is_none());
-
-    // TODO: we rely here on the blob being small enough to not get broken up into multiple chunks.
-    // Test with some bigger blob too
-}