about summary refs log tree commit diff
path: root/tvix/castore/src/blobservice
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-03-19T09·46+0200
committerclbot <clbot@tvl.fyi>2024-03-20T12·17+0000
commit2798803f76687bdeceb10cdaf31ef3013d30acbc (patch)
treeb7a1bb37cbc7e3d35997a8183bb48c0f317a672c /tvix/castore/src/blobservice
parent591edf0d5b5e4910f0a4688028348e423d723253 (diff)
refactor(tvix/castore): introduce "cloud" feature flag r/7749
This controls whether tvix-castore has support for various cloud
backends or not.

Use this to control the set of feature flags for the object_store
backend, and only enable the aws, azure and gcp ones if it's set.
In the future this can be used to enable/disable other cloud backends
too.

Without feature flags, `object_store` already supports the `InMemory`
and `LocalFilesystem` backends, and we also want to unconditionally
enable the `http` one. Make sure at least the construction of these
services is covered in the tests.

Similarly, the tvix-store crate, which provides the tvix-store CLI has a
`cloud` feature flag too (defaulting to enabled).

Change-Id: I9fb9c87b740e7dc83f8ff7a0862905d036d513f2
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11204
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/castore/src/blobservice')
-rw-r--r--tvix/castore/src/blobservice/from_addr.rs22
1 files changed, 17 insertions, 5 deletions
diff --git a/tvix/castore/src/blobservice/from_addr.rs b/tvix/castore/src/blobservice/from_addr.rs
index 6925407552f6..1f37ef61edf6 100644
--- a/tvix/castore/src/blobservice/from_addr.rs
+++ b/tvix/castore/src/blobservice/from_addr.rs
@@ -131,17 +131,29 @@ mod tests {
     /// Correct scheme to connect to localhost over http, without specifying a port.
     #[test_case("grpc+https://localhost", true; "grpc valid https host without port")]
     /// Correct scheme to connect to localhost over http, but with additional path, which is invalid.
-    #[test_case("grpc+http://localhost/some-path", false; "grpc valid invalid host and path")]
-    /// An example for object store (Memory)
+    #[test_case("grpc+http://localhost/some-path", false; "grpc invalid has path")]
+    /// An example for object store (InMemory)
     #[test_case("objectstore+memory:///", true; "objectstore valid memory url")]
-    /// An example for object store (File)
-    #[test_case("objectstore+file:///foo/bar", true; "objectstore valid file url")] // ??
+    /// An example for object store (LocalFileSystem)
+    #[test_case("objectstore+file:///foo/bar", true; "objectstore valid file url")]
+    // An example for object store (HTTP / WebDAV)
+    #[test_case("objectstore+https://localhost:8080/some-path", true; "objectstore valid http url")]
+    #[tokio::test]
+    async fn test_from_addr_tokio(uri_str: &str, exp_succeed: bool) {
+        if exp_succeed {
+            from_addr(uri_str).await.expect("should succeed");
+        } else {
+            assert!(from_addr(uri_str).await.is_err(), "should fail");
+        }
+    }
+
+    #[cfg(feature = "cloud")]
     /// An example for object store (S3)
     #[test_case("objectstore+s3://bucket/path", true; "objectstore valid s3 url")]
     /// An example for object store (GCS)
     #[test_case("objectstore+gs://bucket/path", true; "objectstore valid gcs url")]
     #[tokio::test]
-    async fn test_from_addr_tokio(uri_str: &str, exp_succeed: bool) {
+    async fn test_from_addr_tokio_cloud(uri_str: &str, exp_succeed: bool) {
         if exp_succeed {
             from_addr(uri_str).await.expect("should succeed");
         } else {