fuse test fixes

This commit is contained in:
Scott E. Graves 2024-10-24 18:27:36 -05:00
parent f5b827a039
commit 8692541e7f
4 changed files with 39 additions and 35 deletions

View File

@ -90,8 +90,8 @@ auto meta_db::get_api_path_list() -> std::vector<std::string> {
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]);

View File

@ -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 <typename provider_t> class fuse_test : public ::testing::Test {
public:
static std::string cfg_directory;
static std::unique_ptr<curl_comm> comm;
static std::unique_ptr<app_config> config;
static std::filesystem::path current_directory;
static std::unique_ptr<fuse_drive> drive;
static std::vector<std::string> drive_args;
static std::unique_ptr<meta_db> meta;
static std::string mount_location;
static std::unique_ptr<i_provider> provider;
static std::string test_directory;
protected:
@ -80,7 +81,6 @@ protected:
config = std::make_unique<app_config>(provider_t::type, cfg_directory);
std::vector<std::string> 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<curl_comm>(config->get_s3_config());
drive_args = std::vector<std::string>({
"-s3",
"-na",
"repertory",
"repertory_s3",
});
} break;
@ -112,7 +111,11 @@ protected:
config->set_host_config(src_cfg.get_host_config());
}
comm = std::make_unique<curl_comm>(config->get_host_config());
drive_args = std::vector<std::string>({
"-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<curl_comm>(config->get_s3_config());
// provider = std::make_unique<s3_provider>(*config, *comm);
// drive_args = std::vector<std::string>({"-en"});
// } break;
default:
@ -137,9 +136,10 @@ protected:
return;
}
provider = std::make_unique<provider_t>(*config, *comm);
meta = std::make_unique<meta_db>(*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 <typename provider_t>
std::string fuse_test<provider_t>::cfg_directory{};
template <typename provider_t>
std::unique_ptr<curl_comm> fuse_test<provider_t>::comm{};
template <typename provider_t>
std::unique_ptr<app_config> fuse_test<provider_t>::config{};
@ -245,11 +247,14 @@ std::filesystem::path fuse_test<provider_t>::current_directory{};
template <typename provider_t>
std::unique_ptr<fuse_drive> fuse_test<provider_t>::drive{};
template <typename provider_t>
std::vector<std::string> fuse_test<provider_t>::drive_args;
template <typename provider_t>
std::string fuse_test<provider_t>::mount_location{};
template <typename provider_t>
std::unique_ptr<i_provider> fuse_test<provider_t>::provider{};
std::unique_ptr<meta_db> fuse_test<provider_t>::meta{};
template <typename provider_t>
std::string fuse_test<provider_t>::test_directory;

View File

@ -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<std::string>({
"-s3",
"-na",
"storj",
"repertory_s3",
});
} break;
@ -247,5 +246,4 @@ using winfsp_provider_types = ::testing::Types<s3_provider, sia_provider>;
} // namespace repertory
#endif // defined(_WIN32)
// #endif // 0
#endif // REPERTORY_TEST_INCLUDE_FIXTURES_WINFSP_FIXTURE_HPP

View File

@ -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);