From 8692541e7f57e6b1bd88e32069a1896f7d4f237b Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Thu, 24 Oct 2024 18:27:36 -0500 Subject: [PATCH] fuse test fixes --- .../librepertory/src/providers/meta_db.cpp | 8 +-- .../include/fixtures/fuse_fixture.hpp | 61 ++++++++++--------- .../include/fixtures/winfsp_fixture.hpp | 4 +- .../repertory_test/src/fuse_drive_test.cpp | 1 + 4 files changed, 39 insertions(+), 35 deletions(-) diff --git a/repertory/librepertory/src/providers/meta_db.cpp b/repertory/librepertory/src/providers/meta_db.cpp index dee7ad2c..7e4bd4e6 100644 --- a/repertory/librepertory/src/providers/meta_db.cpp +++ b/repertory/librepertory/src/providers/meta_db.cpp @@ -90,8 +90,8 @@ auto meta_db::get_api_path_list() -> std::vector { return ret; } -auto meta_db::get_item_meta(const std::string &api_path, api_meta_map &meta) - -> api_error { +auto meta_db::get_item_meta(const std::string &api_path, + api_meta_map &meta) -> api_error { REPERTORY_USES_FUNCTION_NAME(); auto result = utils::db::sqlite::db_select{*db_, table_name} @@ -274,8 +274,8 @@ auto meta_db::set_item_meta(const std::string &api_path, return update_item_meta(api_path, existing_meta); } -auto meta_db::update_item_meta(const std::string &api_path, api_meta_map meta) - -> api_error { +auto meta_db::update_item_meta(const std::string &api_path, + api_meta_map meta) -> api_error { REPERTORY_USES_FUNCTION_NAME(); auto directory = utils::string::to_bool(meta[META_DIRECTORY]); diff --git a/repertory/repertory_test/include/fixtures/fuse_fixture.hpp b/repertory/repertory_test/include/fixtures/fuse_fixture.hpp index 7b5688ad..002cddaf 100644 --- a/repertory/repertory_test/include/fixtures/fuse_fixture.hpp +++ b/repertory/repertory_test/include/fixtures/fuse_fixture.hpp @@ -30,6 +30,7 @@ #include "drives/fuse/fuse_drive.hpp" #include "platform/platform.hpp" #include "providers/encrypt/encrypt_provider.hpp" +#include "providers/meta_db.hpp" #include "providers/s3/s3_provider.hpp" #include "providers/sia/sia_provider.hpp" #include "types/repertory.hpp" @@ -51,12 +52,12 @@ namespace repertory { template class fuse_test : public ::testing::Test { public: static std::string cfg_directory; - static std::unique_ptr comm; static std::unique_ptr config; static std::filesystem::path current_directory; static std::unique_ptr drive; + static std::vector drive_args; + static std::unique_ptr meta; static std::string mount_location; - static std::unique_ptr provider; static std::string test_directory; protected: @@ -80,7 +81,6 @@ protected: config = std::make_unique(provider_t::type, cfg_directory); - std::vector drive_args{}; switch (provider_t::type) { case provider_type::s3: { { @@ -93,11 +93,10 @@ protected: config->set_s3_config(src_cfg.get_s3_config()); } - comm = std::make_unique(config->get_s3_config()); drive_args = std::vector({ "-s3", "-na", - "repertory", + "repertory_s3", }); } break; @@ -112,7 +111,11 @@ protected: config->set_host_config(src_cfg.get_host_config()); } - comm = std::make_unique(config->get_host_config()); + drive_args = std::vector({ + "-sia", + "-na", + "sia", + }); } break; // case 0U: { // config = @@ -126,10 +129,6 @@ protected: // config->set_event_level(event_level::trace); // config->set_s3_config(src_cfg.get_s3_config()); // } - // - // comm = std::make_unique(config->get_s3_config()); - // provider = std::make_unique(*config, *comm); - // drive_args = std::vector({"-en"}); // } break; default: @@ -137,9 +136,10 @@ protected: return; } - provider = std::make_unique(*config, *comm); + meta = std::make_unique(*config); + drive_args.push_back(mount_location); - execute_mount(drive_args); + execute_mount(); } static void TearDownTestCase() { @@ -174,17 +174,20 @@ public: static auto create_root_file(std::string &file_name) -> std::string { auto file_path = create_file_and_test(file_name); - auto api_path = utils::path::create_api_path(file_name); + std::cout << file_path << std::endl; - provider->set_item_meta(api_path, { - {META_UID, "0"}, - {META_GID, "0"}, - }); + auto api_path = utils::path::create_api_path(file_name); + std::cout << api_path << std::endl; + + meta->set_item_meta(api_path, { + {META_UID, "0"}, + {META_GID, "0"}, + }); return file_path; } - static void execute_mount(auto &&drive_args) { + static void execute_mount() { auto mount_cmd = "./repertory -dd \"" + config->get_data_directory() + "\"" + " " + utils::string::join(drive_args, ' '); std::cout << "mount command: " << mount_cmd << std::endl; @@ -196,8 +199,10 @@ public: static void execute_unmount() { auto unmounted{false}; - auto unmount_cmd = - "./repertory -dd \"" + config->get_data_directory() + "\" -unmount"; + auto unmount_cmd = "./repertory -dd \"" + config->get_data_directory() + + "\"" + " " + utils::string::join(drive_args, ' ') + + " -unmount"; + for (int i = 0; not unmounted && (i < 50); i++) { std::cout << "unmount command: " << unmount_cmd << std::endl; ASSERT_EQ(0, system(unmount_cmd.c_str())); @@ -221,10 +226,10 @@ public: auto api_path = utils::path::create_api_path( utils::path::strip_to_file_name(file_path)); - provider->set_item_meta(api_path, { - {META_UID, std::to_string(getuid())}, - {META_GID, std::to_string(getgid())}, - }); + meta->set_item_meta(api_path, { + {META_UID, std::to_string(getuid())}, + {META_GID, std::to_string(getgid())}, + }); unlink_file_and_test(file_path); } @@ -233,9 +238,6 @@ public: template std::string fuse_test::cfg_directory{}; -template -std::unique_ptr fuse_test::comm{}; - template std::unique_ptr fuse_test::config{}; @@ -245,11 +247,14 @@ std::filesystem::path fuse_test::current_directory{}; template std::unique_ptr fuse_test::drive{}; +template +std::vector fuse_test::drive_args; + template std::string fuse_test::mount_location{}; template -std::unique_ptr fuse_test::provider{}; +std::unique_ptr fuse_test::meta{}; template std::string fuse_test::test_directory; diff --git a/repertory/repertory_test/include/fixtures/winfsp_fixture.hpp b/repertory/repertory_test/include/fixtures/winfsp_fixture.hpp index a48651dd..25bdbcb1 100644 --- a/repertory/repertory_test/include/fixtures/winfsp_fixture.hpp +++ b/repertory/repertory_test/include/fixtures/winfsp_fixture.hpp @@ -21,7 +21,6 @@ */ #ifndef REPERTORY_TEST_INCLUDE_FIXTURES_WINFSP_FIXTURE_HPP #define REPERTORY_TEST_INCLUDE_FIXTURES_WINFSP_FIXTURE_HPP -// #if 0 #if defined(_WIN32) #include "test_common.hpp" @@ -89,7 +88,7 @@ protected: drive_args = std::vector({ "-s3", "-na", - "storj", + "repertory_s3", }); } break; @@ -247,5 +246,4 @@ using winfsp_provider_types = ::testing::Types; } // namespace repertory #endif // defined(_WIN32) -// #endif // 0 #endif // REPERTORY_TEST_INCLUDE_FIXTURES_WINFSP_FIXTURE_HPP diff --git a/repertory/repertory_test/src/fuse_drive_test.cpp b/repertory/repertory_test/src/fuse_drive_test.cpp index 6dad1675..49869eb2 100644 --- a/repertory/repertory_test/src/fuse_drive_test.cpp +++ b/repertory/repertory_test/src/fuse_drive_test.cpp @@ -535,6 +535,7 @@ TYPED_TEST(fuse_test, can_chmod_if_owner) { TYPED_TEST(fuse_test, can_not_chmod_if_not_owner) { std::string file_name{"chmod_test"}; auto file_path = this->create_root_file(file_name); + std::cout << file_path << std::endl; EXPECT_EQ(-1, chmod(file_path.c_str(), S_IRUSR | S_IWUSR)); EXPECT_EQ(EPERM, errno);