Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
acelyc111 committed Dec 5, 2023
1 parent 2a20084 commit 3923a2a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 39 deletions.
2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ function run_test()
opts="cold_backup_disabled=false,cold_backup_checkpoint_reserve_minutes=0,cold_backup_root=onebox"
fi
if [ "${module}" == "restore_test" ]; then
opts="cold_backup_disabled=false,cold_backup_checkpoint_reserve_minutes=0,cold_backup_root=mycluster"
opts="cold_backup_disabled=false,cold_backup_checkpoint_reserve_minutes=0,cold_backup_root=onebox"
fi
[ -z ${onebox_opts} ] || opts="${opts},${onebox_opts}"
if ! run_start_onebox -m ${m_count} -w -c --opts ${opts}; then
Expand Down
2 changes: 1 addition & 1 deletion src/test/function_test/backup_restore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ set(MY_PROJ_LIBS
dsn_client
dsn_replication_common
dsn_utils
pegasus_client_static
gtest
sasl2
gssapi_krb5
krb5
function_test_utils
pegasus_client_static
)

set(MY_BOOST_LIBS Boost::system Boost::filesystem)
Expand Down
48 changes: 15 additions & 33 deletions src/test/function_test/backup_restore/test_backup_and_restore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,15 @@ class backup_restore_test : public test_util
void TearDown() override
{
ASSERT_EQ(ERR_OK, ddl_client_->drop_app(app_name_, 0));
ASSERT_EQ(ERR_OK, ddl_client_->drop_app(new_app_name_, 0));
ASSERT_EQ(ERR_OK, ddl_client_->drop_app(s_new_app_name, 0));
}

bool write_data()
{
pegasus::pegasus_client *client =
pegasus::pegasus_client_factory::get_client(cluster_name_.c_str(), app_name_.c_str());
if (client == nullptr) {
std::cout << "get pegasus client failed" << std::endl;
return false;
}

for (int i = 0; i < s_num_of_rows; ++i) {
int ret = client->set("hashkey_" + std::to_string(i),
"sortkey_" + std::to_string(i),
"value_" + std::to_string(i));
int ret = client_->set("hashkey_" + std::to_string(i),
"sortkey_" + std::to_string(i),
"value_" + std::to_string(i));
if (ret != pegasus::PERR_OK) {
std::cout << "write data failed. " << std::endl;
return false;
Expand All @@ -72,18 +65,11 @@ class backup_restore_test : public test_util

bool verify_data(const std::string &app_name)
{
pegasus::pegasus_client *client =
pegasus::pegasus_client_factory::get_client(cluster_name_.c_str(), app_name.c_str());
if (client == nullptr) {
std::cout << "get pegasus client failed" << std::endl;
return false;
}

for (int i = 0; i < s_num_of_rows; ++i) {
const std::string &expected_value = "value_" + std::to_string(i);
std::string value;
int ret =
client->get("hashkey_" + std::to_string(i), "sortkey_" + std::to_string(i), value);
client_->get("hashkey_" + std::to_string(i), "sortkey_" + std::to_string(i), value);
if (ret != pegasus::PERR_OK) {
return false;
}
Expand All @@ -96,7 +82,7 @@ class backup_restore_test : public test_util

start_backup_app_response start_backup(const std::string &user_specified_path = "")
{
return ddl_client_->backup_app(app_id_, provider_type_, user_specified_path).get_value();
return ddl_client_->backup_app(app_id_, s_provider_type, user_specified_path).get_value();
}

query_backup_status_response query_backup(int64_t backup_id)
Expand All @@ -106,13 +92,13 @@ class backup_restore_test : public test_util

error_code start_restore(int64_t backup_id, const std::string &user_specified_path = "")
{
return ddl_client_->do_restore(provider_type_,
return ddl_client_->do_restore(s_provider_type,
cluster_name_,
/*policy_name=*/"",
backup_id,
app_name_,
app_id_,
new_app_name_,
s_new_app_name,
/*skip_bad_partition=*/false,
user_specified_path);
}
Expand Down Expand Up @@ -146,7 +132,6 @@ class backup_restore_test : public test_util
sleep(s_check_interval_sec);
sleep_sec += s_check_interval_sec;

int32_t new_app_id;
int32_t partition_count;
std::vector<partition_configuration> partitions;
auto err = ddl_client_->list_app(app_name, app_id_, partition_count, partitions);
Expand All @@ -171,8 +156,6 @@ class backup_restore_test : public test_util

void test_backup_and_restore(const std::string &user_specified_path = "")
{
error_code err = ddl_client_->create_app(app_name_, "pegasus", 4, 3, {}, false);
ASSERT_EQ(ERR_OK, err);
ASSERT_TRUE(wait_app_become_healthy(app_name_, 180));

ASSERT_TRUE(write_data());
Expand All @@ -182,22 +165,21 @@ class backup_restore_test : public test_util
ASSERT_EQ(ERR_OK, resp.err);
int64_t backup_id = resp.backup_id;
ASSERT_TRUE(wait_backup_complete(backup_id, 180));
err = start_restore(backup_id, user_specified_path);
ASSERT_EQ(ERR_OK, err);
ASSERT_TRUE(wait_app_become_healthy(new_app_name_, 180));
ASSERT_EQ(ERR_OK, start_restore(backup_id, user_specified_path));
ASSERT_TRUE(wait_app_become_healthy(s_new_app_name, 180));

ASSERT_TRUE(verify_data(new_app_name_));
ASSERT_TRUE(verify_data(s_new_app_name));
}

private:
static const uint32_t s_num_of_rows = 1000;
static const uint8_t s_check_interval_sec = 10;
static const std::string new_app_name_;
static const std::string provider_type_;
static const std::string s_new_app_name;
static const std::string s_provider_type;
};

const std::string backup_restore_test::new_app_name_ = "new_app";
const std::string backup_restore_test::provider_type_ = "local_service";
const std::string backup_restore_test::s_new_app_name = "new_app";
const std::string backup_restore_test::s_provider_type = "local_service";

TEST_F(backup_restore_test, test_backup_and_restore) { test_backup_and_restore(); }

Expand Down
2 changes: 0 additions & 2 deletions src/test/function_test/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ rpc_timeout_milliseconds = 5000
lb_interval_ms = 3000

[pegasus.clusters]
; TODO(yingchun): leave only 1 cluster config
mycluster = 127.0.0.1:34601,127.0.0.1:34602,127.0.0.1:34603
onebox = 127.0.0.1:34601,127.0.0.1:34602,127.0.0.1:34603
single_master_cluster = 127.0.0.1:34601

Expand Down
2 changes: 1 addition & 1 deletion src/test/function_test/utils/test_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ using std::vector;
namespace pegasus {

test_util::test_util(map<string, string> create_envs)
: cluster_name_("mycluster"), app_name_("temp"), create_envs_(std::move(create_envs))
: cluster_name_("onebox"), app_name_("temp"), create_envs_(std::move(create_envs))
{
}

Expand Down
1 change: 0 additions & 1 deletion src/test/kill_test/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,4 @@ onebox_run_path = @ONEBOX_RUN_PATH@

[pegasus.clusters]
onebox = @LOCAL_HOSTNAME@:34601,@LOCAL_HOSTNAME@:34602,@LOCAL_HOSTNAME@:34603
mycluster = @LOCAL_HOSTNAME@:34601,@LOCALOCAL_HOSTNAMEL_IP@:34602,@LOCAL_HOSTNAME@:34603

0 comments on commit 3923a2a

Please sign in to comment.