From 05d3f21eaf0834d44b6f32a49ae3276ebcb6571c Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Wed, 27 Mar 2024 12:26:06 +0100 Subject: [PATCH] refactor(tvix/store): drop proto/tests/{utils,grpc_pathinfoservice}.rs As for grpc_pathinfoservice, we test this in the rstest-based tests, with more implementations. tests/utils.rs is unused now. Change-Id: I62b192170d181e4fb432bf7dfff2057cb048b52c Reviewed-on: https://cl.tvl.fyi/c/depot/+/11279 Reviewed-by: Connor Brewster Tested-by: BuildkiteCI --- .../src/proto/tests/grpc_pathinfoservice.rs | 75 ------------------- tvix/store/src/proto/tests/mod.rs | 1 - tvix/store/src/tests/mod.rs | 1 - tvix/store/src/tests/utils.rs | 16 ---- 4 files changed, 93 deletions(-) delete mode 100644 tvix/store/src/proto/tests/grpc_pathinfoservice.rs delete mode 100644 tvix/store/src/tests/utils.rs diff --git a/tvix/store/src/proto/tests/grpc_pathinfoservice.rs b/tvix/store/src/proto/tests/grpc_pathinfoservice.rs deleted file mode 100644 index df74861bc..000000000 --- a/tvix/store/src/proto/tests/grpc_pathinfoservice.rs +++ /dev/null @@ -1,75 +0,0 @@ -use crate::proto::get_path_info_request::ByWhat::ByOutputHash; -use crate::proto::path_info_service_server::PathInfoService as GRPCPathInfoService; -use crate::proto::GRPCPathInfoServiceWrapper; -use crate::proto::GetPathInfoRequest; -use crate::proto::PathInfo; -use crate::tests::fixtures::DUMMY_OUTPUT_HASH; -use crate::tests::utils::gen_blob_service; -use crate::tests::utils::gen_directory_service; -use crate::tests::utils::gen_pathinfo_service; -use bytes::Bytes; -use futures::stream::BoxStream; -use std::sync::Arc; -use tonic::Request; -use tvix_castore::proto as castorepb; - -/// generates a GRPCPathInfoService out of blob, directory and pathinfo services. -/// -/// We only interact with it via the PathInfo GRPC interface. -/// It uses the NonCachingNARCalculationService NARCalculationService to -/// calculate NARs. -fn gen_grpc_service( -) -> Arc>>> -{ - let blob_service = gen_blob_service(); - let directory_service = gen_directory_service(); - Arc::new(GRPCPathInfoServiceWrapper::new(gen_pathinfo_service( - blob_service, - directory_service, - ))) -} - -/// Trying to get a non-existent PathInfo should return a not found error. -#[tokio::test] -async fn not_found() { - let service = gen_grpc_service(); - - let resp = service - .get(Request::new(GetPathInfoRequest { - by_what: Some(ByOutputHash(Bytes::from(DUMMY_OUTPUT_HASH.to_vec()))), - })) - .await; - - let resp = resp.expect_err("must fail"); - assert_eq!(resp.code(), tonic::Code::NotFound); -} - -/// Put a PathInfo into the store, get it back. -#[tokio::test] -async fn put_get() { - let service = gen_grpc_service(); - - let path_info = PathInfo { - node: Some(castorepb::Node { - node: Some(castorepb::node::Node::Symlink(castorepb::SymlinkNode { - name: "00000000000000000000000000000000-foo".into(), - target: "doesntmatter".into(), - })), - }), - ..Default::default() - }; - - let resp = service.put(Request::new(path_info.clone())).await; - - assert!(resp.is_ok()); - assert_eq!(resp.expect("must succeed").into_inner(), path_info); - - let resp = service - .get(Request::new(GetPathInfoRequest { - by_what: Some(ByOutputHash(Bytes::from(DUMMY_OUTPUT_HASH.to_vec()))), - })) - .await; - - assert!(resp.is_ok()); - assert_eq!(resp.expect("must succeed").into_inner(), path_info); -} diff --git a/tvix/store/src/proto/tests/mod.rs b/tvix/store/src/proto/tests/mod.rs index bff885624..c9c670202 100644 --- a/tvix/store/src/proto/tests/mod.rs +++ b/tvix/store/src/proto/tests/mod.rs @@ -1,2 +1 @@ -mod grpc_pathinfoservice; mod pathinfo; diff --git a/tvix/store/src/tests/mod.rs b/tvix/store/src/tests/mod.rs index daea048de..1e7fc3f6b 100644 --- a/tvix/store/src/tests/mod.rs +++ b/tvix/store/src/tests/mod.rs @@ -1,3 +1,2 @@ pub mod fixtures; mod nar_renderer; -pub mod utils; diff --git a/tvix/store/src/tests/utils.rs b/tvix/store/src/tests/utils.rs deleted file mode 100644 index 040b7ee7f..000000000 --- a/tvix/store/src/tests/utils.rs +++ /dev/null @@ -1,16 +0,0 @@ -use crate::pathinfoservice::{MemoryPathInfoService, PathInfoService}; -use std::sync::Arc; -use tvix_castore::{blobservice::BlobService, directoryservice::DirectoryService}; - -pub use tvix_castore::utils::*; - -pub fn gen_pathinfo_service( - blob_service: BS, - directory_service: DS, -) -> Arc -where - BS: AsRef + Send + Sync + 'static, - DS: AsRef + Send + Sync + 'static, -{ - Arc::new(MemoryPathInfoService::new(blob_service, directory_service)) -}