Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ut): fix the dsn.meta.test using a directorty may has not permission #2019

Merged
merged 2 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/common/fs_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ dir_node *fs_manager::find_best_dir_for_new_replica(const gpid &pid) const
for (const auto &dn : _dir_nodes) {
// Do not allocate new replica on dir_node which is not NORMAL.
if (dn->status != disk_status::NORMAL) {
LOG_INFO("skip the {} state dir_node({})", enum_to_string(dn->status), dn->tag);
continue;
}
CHECK(!dn->has(pid), "gpid({}) already exists in dir_node({})", pid, dn->tag);
Expand Down Expand Up @@ -440,6 +441,7 @@ dir_node *fs_manager::find_replica_dir(absl::string_view app_type, gpid pid)
for (const auto &dn : _dir_nodes) {
// Skip IO error dir_node.
if (dn->status == disk_status::IO_ERROR) {
LOG_INFO("skip the {} state dir_node({})", enum_to_string(dn->status), dn->tag);
continue;
}
const auto dir = dn->replica_dir(app_type, pid);
Expand Down Expand Up @@ -498,6 +500,7 @@ dir_node *fs_manager::create_child_replica_dir(absl::string_view app_type,
for (const auto &dn : _dir_nodes) {
// Skip non-available dir_node.
if (dn->status != disk_status::NORMAL) {
LOG_INFO("skip the {} state dir_node({})", enum_to_string(dn->status), dn->tag);
continue;
}
child_dir = dn->replica_dir(app_type, child_pid);
Expand Down
28 changes: 13 additions & 15 deletions src/meta/test/misc/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "misc.h"

#include <boost/lexical_cast.hpp>
#include <fmt/core.h>
// IWYU pragma: no_include <ext/alloc_traits.h>
#include <stdio.h>
#include <atomic>
Expand All @@ -50,6 +51,7 @@
#include "runtime/rpc/dns_resolver.h" // IWYU pragma: keep
#include "runtime/rpc/rpc_address.h"
#include "runtime/rpc/rpc_host_port.h"
#include "utils/filesystem.h"
#include "utils/fmt_logging.h"
#include "utils/rand.h"

Expand Down Expand Up @@ -195,15 +197,13 @@ void generate_node_fs_manager(const app_mapper &apps,
int total_disks)
{
nfm.clear();
const char *prefix = "/home/work/";
char pid_dir[256];
std::string prefix;
CHECK(dsn::utils::filesystem::get_current_directory(prefix), "");
std::vector<std::string> data_dirs(total_disks);
std::vector<std::string> tags(total_disks);
for (int i = 0; i < data_dirs.size(); ++i) {
snprintf(pid_dir, 256, "%sdisk%d", prefix, i + 1);
data_dirs[i] = pid_dir;
snprintf(pid_dir, 256, "disk%d", i + 1);
tags[i] = pid_dir;
data_dirs[i] = fmt::format("{}disk{}", prefix, i + 1);
tags[i] = fmt::format("disk{}", i + 1);
}

for (const auto &kv : nodes) {
Expand All @@ -215,15 +215,13 @@ void generate_node_fs_manager(const app_mapper &apps,
manager.initialize(data_dirs, tags);
ns.for_each_partition([&](const dsn::gpid &pid) {
const config_context &cc = *get_config_context(apps, pid);
snprintf(pid_dir,
256,
"%s%s/%d.%d.test",
prefix,
cc.find_from_serving(ns.host_port())->disk_tag.c_str(),
pid.get_app_id(),
pid.get_partition_index());
LOG_DEBUG("concat pid_dir({}) of node({})", pid_dir, ns.host_port());
manager.add_replica(pid, pid_dir);
const auto dir = fmt::format("{}{}/{}.{}.test",
prefix,
cc.find_from_serving(ns.host_port())->disk_tag,
pid.get_app_id(),
pid.get_partition_index());
LOG_DEBUG("concat {} of node({})", dir, ns.host_port());
manager.add_replica(pid, dir);
return true;
});
}
Expand Down
Loading