Skip to content

Commit 3565090

Browse files
Add VFS support for tiledb:// URIs. (#5631)
This PR adds support to VFS for `tiledb://` URIs. It reads the `rest.***` config options, and based on them, it sets up an S3 VFS that points to Carrara's S3-compatible `v4/files` endpoints. --- TYPE: FEATURE DESC: Add VFS support for `tiledb://` URIs.
1 parent 3f610d5 commit 3565090

File tree

14 files changed

+413
-273
lines changed

14 files changed

+413
-273
lines changed

test/src/unit-vfs.cc

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -389,19 +389,16 @@ TEST_CASE("VFS: copy_dir", "[vfs][copy_dir]") {
389389
}
390390
}
391391

392-
using AllBackends = std::tuple<LocalFsTest, GCSTest, GSTest, S3Test, AzureTest>;
392+
using AllBackends =
393+
std::tuple<LocalFsTest, GCSTest, GSTest, S3Test, AzureTest, TileDBFSTest>;
393394
TEMPLATE_LIST_TEST_CASE(
394-
"VFS: URI semantics and file management", "[vfs][uri]", AllBackends) {
395+
"VFS: URI semantics and file management", "[vfs][rest][uri]", AllBackends) {
395396
TestType fs({});
396397
if (!fs.is_supported()) {
397398
return;
398399
}
399400

400-
ThreadPool compute_tp(4);
401-
ThreadPool io_tp(4);
402-
Config config = set_config_params();
403-
VFS vfs{
404-
&g_helper_stats, g_helper_logger().get(), &compute_tp, &io_tp, config};
401+
auto& vfs = fs.vfs_;
405402

406403
URI path = fs.temp_dir_.add_trailing_slash();
407404

@@ -792,11 +789,11 @@ TEST_CASE("VFS: test ls_with_sizes", "[vfs][ls-with-sizes]") {
792789
}
793790

794791
// Currently only local, S3, Azure and GCS are supported for VFS::ls_recursive.
795-
using TestBackends = std::tuple<LocalFsTest, S3Test, AzureTest, GCSTest>;
792+
using LsRecursiveBackends = std::tuple<LocalFsTest, S3Test, AzureTest, GCSTest>;
796793
TEMPLATE_LIST_TEST_CASE(
797794
"VFS: ls_filtered recursion enabled",
798-
"[vfs][ls_filtered][ls_filtered_v2][recursion]",
799-
TestBackends) {
795+
"[vfs][ls_filtered][ls_filtered_v2][rest][recursion]",
796+
LsRecursiveBackends) {
800797
TestType fs({10, 50});
801798
if (!fs.is_supported()) {
802799
return;
@@ -822,7 +819,7 @@ TEMPLATE_LIST_TEST_CASE(
822819
TEMPLATE_LIST_TEST_CASE(
823820
"VFS: ls_filtered non-recursive",
824821
"[vfs][ls_filtered][ls_filtered_v2]",
825-
TestBackends) {
822+
LsRecursiveBackends) {
826823
TestType fs({10});
827824
if (!fs.is_supported()) {
828825
return;
@@ -860,9 +857,11 @@ TEMPLATE_LIST_TEST_CASE(
860857
}
861858
}
862859

863-
TEST_CASE("VFS: Throwing filters for ls_recursive", "[vfs][ls_recursive]") {
864-
std::string prefix = GENERATE("s3://", "azure://", "gcs://", "gs://");
865-
VFSTest vfs_test({0}, prefix);
860+
TEMPLATE_LIST_TEST_CASE(
861+
"VFS: Throwing filters for ls_recursive",
862+
"[vfs][ls_recursive]",
863+
LsRecursiveBackends) {
864+
TestType vfs_test({0});
866865
if (!vfs_test.is_supported()) {
867866
return;
868867
}
@@ -1005,7 +1004,7 @@ TEST_CASE(
10051004
"Validate GCS service account impersonation",
10061005
"[gcs][credentials][impersonation]") {
10071006
ThreadPool thread_pool(2);
1008-
Config cfg = set_config_params(true);
1007+
Config cfg;
10091008
std::string impersonate_service_account, target_service_account;
10101009
std::vector<std::string> delegates;
10111010

@@ -1049,7 +1048,7 @@ TEST_CASE(
10491048
"Validate GCS service account credentials",
10501049
"[gcs][credentials][service-account]") {
10511050
ThreadPool thread_pool(2);
1052-
Config cfg = set_config_params(true);
1051+
Config cfg;
10531052
// The content of the credentials does not matter; it does not get parsed
10541053
// until it is used in an API request, which we are not doing.
10551054
std::string service_account_key = "{\"foo\": \"bar\"}";
@@ -1072,7 +1071,7 @@ TEST_CASE(
10721071
"Validate GCS service account credentials with impersonation",
10731072
"[gcs][credentials][service-account-and-impersonation]") {
10741073
ThreadPool thread_pool(2);
1075-
Config cfg = set_config_params(true);
1074+
Config cfg;
10761075
// The content of the credentials does not matter; it does not get parsed
10771076
// until it is used in an API request, which we are not doing.
10781077
std::string service_account_key = "{\"foo\": \"bar\"}";
@@ -1107,7 +1106,7 @@ TEST_CASE(
11071106
"Validate GCS external account credentials",
11081107
"[gcs][credentials][external-account]") {
11091108
ThreadPool thread_pool(2);
1110-
Config cfg = set_config_params(true);
1109+
Config cfg;
11111110
// The content of the credentials does not matter; it does not get parsed
11121111
// until it is used in an API request, which we are not doing.
11131112
std::string workload_identity_configuration = "{\"foo\": \"bar\"}";

test/src/unit.cc

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#define CATCH_CONFIG_RUNNER
2+
#include <test/support/src/helpers.h>
23
#include <test/support/tdb_catch.h>
34

45
#include <cstdlib>
@@ -11,15 +12,6 @@
1112
#include <crtdbg.h>
1213
#endif
1314

14-
namespace tiledb {
15-
namespace test {
16-
17-
// Command line arguments.
18-
int store_g_vfs(std::string&& vfs, std::vector<std::string> vfs_fs);
19-
20-
} // namespace test
21-
} // namespace tiledb
22-
2315
int main(const int argc, char** const argv) {
2416
#if defined(_MSC_VER)
2517
// We disable the following events on abort in CI environments:

test/support/src/helpers.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,10 @@ void throw_if_error(tiledb_ctx_t* ctx, capi_return_t thing) {
210210
}
211211
}
212212

213+
bool is_g_vfs_enabled(const std::string& vfs) {
214+
return vfs == "memfs" || vfs == g_vfs;
215+
}
216+
213217
int store_g_vfs(std::string&& vfs, std::vector<std::string> vfs_fs) {
214218
if (!vfs.empty()) {
215219
if (std::find(vfs_fs.begin(), vfs_fs.end(), vfs) == vfs_fs.end()) {

test/support/src/helpers.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ typedef std::pair<tiledb_filter_type_t, int> Compressor;
118118
template <class T>
119119
using SubarrayRanges = std::vector<std::vector<T>>;
120120

121+
/** Checks whether the given VFS is enabled by tiledb_unit's command line. */
122+
bool is_g_vfs_enabled(const std::string& vfs);
123+
124+
// Command line arguments.
125+
int store_g_vfs(std::string&& vfs, std::vector<std::string> vfs_fs);
126+
121127
/**
122128
* Throws if the return code is not OK.
123129
* For use in test setup for object allocation.

0 commit comments

Comments
 (0)