refactor(tvix/castore): add RootNode impl for BTreeMap, mv fs tests
cl/10378 did already move store/fs to castore/fs, but we kept the tests in tvix-store, as they were populating a PathInfoService to make nodes appear in the mount root. Update these tests to now just insert root nodes into a BTreeMap, and ensure we can use that as a RootNodes too. Change-Id: Iad7d1ee4f9423eb6e3a1da33f433842c9ae0de1f Reviewed-on: https://cl.tvl.fyi/c/depot/+/10410 Reviewed-by: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de>
This commit is contained in:
parent
6af17545bf
commit
8d86d2f409
7 changed files with 305 additions and 306 deletions
1
tvix/Cargo.lock
generated
1
tvix/Cargo.lock
generated
|
|
@ -3244,7 +3244,6 @@ dependencies = [
|
||||||
"data-encoding",
|
"data-encoding",
|
||||||
"futures",
|
"futures",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"libc",
|
|
||||||
"nix-compat",
|
"nix-compat",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"prost",
|
"prost",
|
||||||
|
|
|
||||||
|
|
@ -10267,10 +10267,6 @@ rec {
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
devDependencies = [
|
devDependencies = [
|
||||||
{
|
|
||||||
name = "libc";
|
|
||||||
packageId = "libc";
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
name = "tempfile";
|
name = "tempfile";
|
||||||
packageId = "tempfile";
|
packageId = "tempfile";
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,9 @@ pub mod fuse;
|
||||||
#[cfg(feature = "virtiofs")]
|
#[cfg(feature = "virtiofs")]
|
||||||
pub mod virtiofs;
|
pub mod virtiofs;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests;
|
||||||
|
|
||||||
use crate::proto as castorepb;
|
use crate::proto as castorepb;
|
||||||
use crate::{
|
use crate::{
|
||||||
blobservice::{BlobReader, BlobService},
|
blobservice::{BlobReader, BlobService},
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
use std::pin::Pin;
|
use std::{collections::BTreeMap, ops::Deref, pin::Pin};
|
||||||
|
|
||||||
use crate::{proto::node::Node, Error};
|
use crate::{proto::node::Node, Error};
|
||||||
|
use bytes::Bytes;
|
||||||
use futures::Stream;
|
use futures::Stream;
|
||||||
use tonic::async_trait;
|
use tonic::async_trait;
|
||||||
|
|
||||||
|
|
@ -14,5 +15,21 @@ pub trait RootNodes: Send + Sync {
|
||||||
|
|
||||||
/// Lists all root CA nodes in the filesystem. An error can be returned
|
/// Lists all root CA nodes in the filesystem. An error can be returned
|
||||||
/// in case listing is not allowed
|
/// in case listing is not allowed
|
||||||
fn list(&self) -> Pin<Box<dyn Stream<Item = Result<Node, Error>> + Send>>;
|
fn list(&self) -> Pin<Box<dyn Stream<Item = Result<Node, Error>> + Send + '_>>;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
/// Implements RootNodes for something deref'ing to a BTreeMap of Nodes, where
|
||||||
|
/// the key is the node name.
|
||||||
|
impl<T> RootNodes for T
|
||||||
|
where
|
||||||
|
T: Deref<Target = BTreeMap<Bytes, Node>> + Send + Sync,
|
||||||
|
{
|
||||||
|
async fn get_by_basename(&self, name: &[u8]) -> Result<Option<Node>, Error> {
|
||||||
|
Ok(self.get(name).cloned())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn list(&self) -> Pin<Box<dyn Stream<Item = Result<Node, Error>> + Send + '_>> {
|
||||||
|
Box::pin(tokio_stream::iter(self.iter().map(|(_, v)| Ok(v.clone()))))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -47,9 +47,6 @@ test-case = "2.2.2"
|
||||||
tempfile = "3.3.0"
|
tempfile = "3.3.0"
|
||||||
tokio-retry = "0.3.0"
|
tokio-retry = "0.3.0"
|
||||||
|
|
||||||
[dev-dependencies.libc]
|
|
||||||
version = "0.2.144"
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["fuse", "tonic-reflection"]
|
default = ["fuse", "tonic-reflection"]
|
||||||
fuse = ["tvix-castore/fuse"]
|
fuse = ["tvix-castore/fuse"]
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,6 @@ use tvix_castore::{blobservice::BlobService, directoryservice::DirectoryService}
|
||||||
|
|
||||||
use super::PathInfoService;
|
use super::PathInfoService;
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests;
|
|
||||||
|
|
||||||
/// Helper to construct a [TvixStoreFs] from a [BlobService], [DirectoryService]
|
/// Helper to construct a [TvixStoreFs] from a [BlobService], [DirectoryService]
|
||||||
/// and [PathInfoService].
|
/// and [PathInfoService].
|
||||||
/// This avoids users to have to interact with the wrapper struct directly, as
|
/// This avoids users to have to interact with the wrapper struct directly, as
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue