Skip to content

Commit

Permalink
add logs and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
empiredan committed Nov 13, 2024
1 parent bbcb2ed commit 72b076e
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 7 deletions.
18 changes: 16 additions & 2 deletions src/meta/duplication/meta_duplication_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,14 @@ void meta_duplication_service::on_follower_app_creating_for_duplication(
// after executing, now using `_is_altering` to judge whether `updating` or
// `completed`, if `_is_altering`, dup->alter_status() will return `ERR_BUSY`
_meta_svc->get_meta_storage()->set_data(
std::string(dup->store_path), std::move(value), [dup]() { dup->persist_status(); });
std::string(dup->store_path), std::move(value), [dup]() {
dup->persist_status();
LOG_INFO("create follower app[{}.{}] to trigger duplicate checkpoint successfully: "
"duplication_status = {}",
dup->remote_cluster_name,
dup->remote_app_name,
duplication_status_to_string(dup->status()));
});
}

void meta_duplication_service::on_follower_app_created_for_duplication(
Expand Down Expand Up @@ -725,7 +732,14 @@ void meta_duplication_service::check_follower_app_if_create_completed(
// after executing, now using `_is_altering` to judge whether `updating` or
// `completed`, if `_is_altering`, dup->alter_status() will return `ERR_BUSY`
_meta_svc->get_meta_storage()->set_data(
std::string(dup->store_path), std::move(value), [dup]() { dup->persist_status(); });
std::string(dup->store_path), std::move(value), [dup]() {
dup->persist_status();
LOG_INFO("all of the replicas of follower app[{}.{}] have been ready: "
"duplication_status = {}",
dup->remote_cluster_name,
dup->remote_app_name,
duplication_status_to_string(dup->status()));
});
});
}

Expand Down
10 changes: 5 additions & 5 deletions src/meta/server_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1220,12 +1220,12 @@ void server_state::create_app(dsn::message_ex *msg)

#define FAIL_UNDEFINED_CREATE_FOLLOWER_APP_STATUS(val, desc) \
LOG_ERROR("undefined value({}) of env {} in the {}: app_name={}, app_id={}", \
(val), \
val, \
duplication_constants::kDuplicationEnvMasterCreateFollowerAppStatusKey, \
(desc), \
desc, \
app->app_name, \
app->app_id); \
FAIL_CREATE_APP_RESPONSE(msg, response, ERR_INVALID_STATE)
FAIL_CREATE_APP_RESPONSE(msg, response, ERR_INVALID_PARAMETERS)

void server_state::process_create_follower_app_status(
message_ex *msg,
Expand Down Expand Up @@ -1280,7 +1280,7 @@ void server_state::process_create_follower_app_status(

if (req_status->second ==
duplication_constants::kDuplicationEnvMasterCreateFollowerAppStatusCreated) {
// Update the creating status both on the remote storage and local memory.
// Mark the status as created both on the remote storage and local memory.
update_create_follower_app_status(
msg,
duplication_constants::kDuplicationEnvMasterCreateFollowerAppStatusCreating,
Expand All @@ -1306,7 +1306,7 @@ void server_state::process_create_follower_app_status(
my_status->second,
app->app_name,
app->app_id);
FAIL_CREATE_APP_RESPONSE(msg, response, ERR_INVALID_STATE);
FAIL_CREATE_APP_RESPONSE(msg, response, ERR_APP_EXIST);
}

if (req_status->second ==
Expand Down
48 changes: 48 additions & 0 deletions src/meta/test/meta_app_operation_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,22 @@ TEST_F(meta_app_operation_test, create_app)
{duplication_constants::kDuplicationEnvMasterAppNameKey, DUP_MASTER_APP_NAME},
{duplication_constants::kDuplicationEnvMasterCreateFollowerAppStatusKey,
duplication_constants::kDuplicationEnvMasterCreateFollowerAppStatusCreating}}},
// Process the request of creating follower app for duplication without the env of
// creating status.
{DUP_FOLLOWER_APP_NAME,
4,
3,
2,
3,
3,
false,
app_status::AS_AVAILABLE,
ERR_APP_EXIST,
{
{duplication_constants::kDuplicationEnvMasterClusterKey, "source_cluster"},
{duplication_constants::kDuplicationEnvMasterMetasKey, "10.1.2.3:34601"},
{duplication_constants::kDuplicationEnvMasterAppNameKey, DUP_MASTER_APP_NAME},
}},
// Process the repeated request of creating follower app for duplication from the
// source cluster.
{DUP_FOLLOWER_APP_NAME,
Expand Down Expand Up @@ -598,6 +614,22 @@ TEST_F(meta_app_operation_test, create_app)
{duplication_constants::kDuplicationEnvMasterAppNameKey, DUP_MASTER_APP_NAME},
{duplication_constants::kDuplicationEnvMasterCreateFollowerAppStatusKey,
duplication_constants::kDuplicationEnvMasterCreateFollowerAppStatusCreated}}},
// Process the request of creating follower app for duplication from the source
// cluster while it has been marked as created.
{DUP_FOLLOWER_APP_NAME,
4,
3,
2,
3,
3,
false,
app_status::AS_AVAILABLE,
ERR_APP_EXIST,
{{duplication_constants::kDuplicationEnvMasterClusterKey, "source_cluster"},
{duplication_constants::kDuplicationEnvMasterMetasKey, "10.1.2.3:34601"},
{duplication_constants::kDuplicationEnvMasterAppNameKey, DUP_MASTER_APP_NAME},
{duplication_constants::kDuplicationEnvMasterCreateFollowerAppStatusKey,
duplication_constants::kDuplicationEnvMasterCreateFollowerAppStatusCreating}}},
// Process the repeated request of marking follower app as created for duplication
// from the source cluster.
{DUP_FOLLOWER_APP_NAME,
Expand All @@ -614,6 +646,22 @@ TEST_F(meta_app_operation_test, create_app)
{duplication_constants::kDuplicationEnvMasterAppNameKey, DUP_MASTER_APP_NAME},
{duplication_constants::kDuplicationEnvMasterCreateFollowerAppStatusKey,
duplication_constants::kDuplicationEnvMasterCreateFollowerAppStatusCreated}}},
// Process the request of creating follower app for duplication with invalid creating
// status.
{DUP_FOLLOWER_APP_NAME,
4,
3,
2,
3,
3,
false,
app_status::AS_AVAILABLE,
ERR_INVALID_PARAMETERS,
{{duplication_constants::kDuplicationEnvMasterClusterKey, "source_cluster"},
{duplication_constants::kDuplicationEnvMasterMetasKey, "10.1.2.3:34601"},
{duplication_constants::kDuplicationEnvMasterAppNameKey, DUP_MASTER_APP_NAME},
{duplication_constants::kDuplicationEnvMasterCreateFollowerAppStatusKey,
"invalid_creating_status"}}},
};

clear_nodes();
Expand Down

0 comments on commit 72b076e

Please sign in to comment.