Skip to content

Commit

Permalink
fix 1-phase of testing
Browse files Browse the repository at this point in the history
  • Loading branch information
osalyk committed Jul 22, 2024
1 parent 0241cf8 commit d1aade3
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 52 deletions.
24 changes: 21 additions & 3 deletions src/tests/ras/unsafe_shutdown/local_move_tests.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2023, Intel Corporation
* Copyright 2018-2024, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -37,6 +37,8 @@ std::ostream& operator<<(std::ostream& stream, move_param const& m) {
return stream;
}

bool pmem;

std::vector<move_param> GetMoveParams() {
std::vector<move_param> ret_vec;
LocalTestPhase& test_phase = LocalTestPhase::GetInstance();
Expand All @@ -54,6 +56,7 @@ std::vector<move_param> GetMoveParams() {
} else {
tc.enough_dimms = false;
}
tc.pmem = true;
ret_vec.emplace_back(tc);
}

Expand All @@ -68,6 +71,7 @@ std::vector<move_param> GetMoveParams() {
} else {
tc.enough_dimms = false;
}
tc.pmem = false;
ret_vec.emplace_back(tc);
}

Expand All @@ -82,6 +86,7 @@ std::vector<move_param> GetMoveParams() {
} else {
tc.enough_dimms = false;
}
tc.pmem = true;
ret_vec.emplace_back(tc);
}

Expand All @@ -96,6 +101,7 @@ std::vector<move_param> GetMoveParams() {
} else {
tc.enough_dimms = false;
}
tc.pmem = true;
ret_vec.emplace_back(tc);
}

Expand All @@ -110,6 +116,7 @@ std::vector<move_param> GetMoveParams() {
} else {
tc.enough_dimms = false;
}
tc.pmem = true;
ret_vec.emplace_back(tc);
}

Expand All @@ -124,6 +131,7 @@ std::vector<move_param> GetMoveParams() {
} else {
tc.enough_dimms = false;
}
tc.pmem = false;
ret_vec.emplace_back(tc);
}
return ret_vec;
Expand All @@ -136,6 +144,7 @@ void MovePoolClean::SetUp() {
<< "Insufficient number of DIMMs to run this test";
src_pool_path_ = param.src_pool_dir + GetNormalizedTestName() + "_pool";
dest_pool_path_ = param.dest_pool_dir + GetNormalizedTestName() + "_pool";
pmem = param.pmem;
}

/**
Expand All @@ -144,7 +153,7 @@ void MovePoolClean::SetUp() {
* and closed properly can be reopened.
* Trigger unsafe shutdown after closing the pool.
* \test
* \li \c Step1. Create pool on device. / SUCCESS
* \li \c Step1. Disable SDS. Create pool on device. Enable SDS. / SUCCESS
* \li \c Step2. Write pattern persistently to pool, close the pool
* / SUCCESS
* \li \c Step3. Increment USC on DIMM specified by parameter, power cycle
Expand All @@ -156,10 +165,15 @@ void MovePoolClean::SetUp() {
*/
TEST_P(MovePoolClean, TC_MOVE_POOL_CLEAN_phase_1) {
/* Step1 */
if (pmem == false)
set_sds_at_create_func(false);
pop_ = pmemobj_create(src_pool_path_.c_str(), nullptr, PMEMOBJ_MIN_POOL, 0644);
ASSERT_TRUE(pop_ != nullptr) << "Pool creating failed. Errno: " << errno
<< std::endl
<< pmemobj_errormsg();
if (pmem == false)
set_sds_at_create_func(true);

/* Step2 */
ObjData<int> pd{pop_};
ASSERT_EQ(0, pd.Write(obj_data_)) << "Writing to pool failed";
Expand Down Expand Up @@ -202,7 +216,7 @@ void MovePoolDirty::SetUp() {
* Check if pool moved between devices in a manner specified by test parameters
* can be opened.
* \test
* \li \c Step1. Create pool on device. / SUCCESS
* \li \c Step1. Disable SDS. Create pool on device. Enable SDS. / SUCCESS
* \li \c Step2. Write pattern persistently to pool / SUCCESS
* \li \c Step3. Increment USC on DIMM specified by parameter, power cycle,
* confirm USC is incremented / SUCCESS
Expand All @@ -215,9 +229,13 @@ void MovePoolDirty::SetUp() {
*/
TEST_P(MovePoolDirty, TC_MOVE_POOL_DIRTY_phase_1) {
/* Step1 */
if (pmem == false)
set_sds_at_create_func(false);
pop_ = pmemobj_create(src_pool_path_.c_str(), nullptr, PMEMOBJ_MIN_POOL, 0644);
ASSERT_TRUE(pop_ != nullptr) << "Pool creating failed" << std::endl
<< pmemobj_errormsg();
if (pmem == false)
set_sds_at_create_func(true);

/* Step2 */
ObjData<int> pd{pop_};
Expand Down
3 changes: 2 additions & 1 deletion src/tests/ras/unsafe_shutdown/local_move_tests.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018, Intel Corporation
* Copyright 2018-2024, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -40,6 +40,7 @@ struct move_param {
std::string src_pool_dir;
std::string dest_pool_dir;
bool enough_dimms;
bool pmem;
};

std::ostream& operator<<(std::ostream& stream, move_param const& m);
Expand Down
66 changes: 21 additions & 45 deletions src/tests/ras/unsafe_shutdown/local_replicas_tests.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2023, Intel Corporation
* Copyright 2018-2024, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -37,10 +37,13 @@ std::ostream& operator<<(std::ostream& stream, sync_local_replica_tc const& p) {
return stream;
}

bool is_pmem;

void SyncLocalReplica::SetUp() {
sync_local_replica_tc param = GetParam();
ASSERT_TRUE(param.enough_dimms)
<< "Insufficient number of DIMMs to run this test";
is_pmem = param.pmem;
}

/**
Expand Down Expand Up @@ -71,10 +74,14 @@ TEST_P(SyncLocalReplica, TC_SYNC_LOCAL_REPLICA_phase_1) {
ASSERT_TRUE(p_mgmt.PoolsetFileExists(ps))
<< "Poolset file " << ps.GetFullPath() << " does not exist";

if (is_pmem == false)
set_sds_at_create_func(true);
pop_ = pmemobj_create(ps.GetFullPath().c_str(), nullptr, 0, 0644);
ASSERT_TRUE(pop_ != nullptr)
<< "Error while creating the pool. Errno:" << errno << std::endl
<< pmemobj_errormsg();
if (is_pmem == false)
set_sds_at_create_func(false);

/* Step2 */
ObjData<int> pd{pop_};
Expand Down Expand Up @@ -149,32 +156,14 @@ std::vector<sync_local_replica_tc> GetSyncLocalReplicaParams() {
} else {
tc.enough_dimms = false;
}
tc.pmem = true;
ret_vec.emplace_back(tc);
}

/* Master replica on unsafely shutdown DIMM, healthy secondary replica on
* non-pmem device. */
{
sync_local_replica_tc tc;
tc.description =
"Master replica on unsafely shutdown DIMM, healthy secondary replica "
"on non-pmem device.";
if (unsafe_dn.size() > 0) {
tc.enough_dimms = true;
tc.poolset = Poolset{
unsafe_dn[0].GetTestDir(),
"pool_tc2.set",
{{"PMEMPOOLSET",
"9MB " + unsafe_dn[0].GetTestDir() + "tc2_master.part0",
"9MB " + unsafe_dn[0].GetTestDir() + "tc2_master.part1"},
{"REPLICA", "9MB " + test_phase.GetTestDir() + "tc2_replica.part0",
"9MB " + test_phase.GetTestDir() + "tc2_replica.part1"}}};
tc.is_syncable = true;
} else {
tc.enough_dimms = false;
}
ret_vec.emplace_back(tc);
}
* non-pmem device.
* XXX - Because of the change about always-on SDS,
* this test case does not make sense anymore. */

/* Two local secodary replicas, one partially on unsafely shutdown DIMM, other
* on safely shutdown DIMM.
Expand All @@ -201,6 +190,7 @@ std::vector<sync_local_replica_tc> GetSyncLocalReplicaParams() {
} else {
tc.enough_dimms = false;
}
tc.pmem = true;
ret_vec.emplace_back(tc);
}

Expand All @@ -223,6 +213,7 @@ std::vector<sync_local_replica_tc> GetSyncLocalReplicaParams() {
} else {
tc.enough_dimms = false;
}
tc.pmem = false;
ret_vec.emplace_back(tc);
}

Expand All @@ -246,6 +237,7 @@ std::vector<sync_local_replica_tc> GetSyncLocalReplicaParams() {
} else {
tc.enough_dimms = false;
}
tc.pmem = false;
ret_vec.emplace_back(tc);
}

Expand All @@ -269,6 +261,7 @@ std::vector<sync_local_replica_tc> GetSyncLocalReplicaParams() {
} else {
tc.enough_dimms = false;
}
tc.pmem = false;
ret_vec.emplace_back(tc);
}

Expand All @@ -294,32 +287,14 @@ std::vector<sync_local_replica_tc> GetSyncLocalReplicaParams() {
} else {
tc.enough_dimms = false;
}
tc.pmem = false;
ret_vec.emplace_back(tc);
}

/* Master replica and secondary replica partially on non-pmem,
* partially on two us-dimms. */
{
sync_local_replica_tc tc;
tc.description =
"Master and secondary replica partially on non-pmem, partially on two "
"unsafely shutdown dimms.";
if (unsafe_dn.size() >= 2) {
tc.enough_dimms = true;
tc.poolset = Poolset{
unsafe_dn[0].GetTestDir(),
"pool5.set",
{{"PMEMPOOLSET", "9MB " + unsafe_dn[0].GetTestDir() + "master5.part0",
"9MB " + test_phase.GetTestDir() + "master5.part1",
"9MB " + unsafe_dn[0].GetTestDir() + "master5.part2"},
{"REPLICA", "9MB " + unsafe_dn[1].GetTestDir() + "replica5.part0",
"18MB " + test_phase.GetTestDir() + "replica5.part1"}}};
tc.is_syncable = false;
} else {
tc.enough_dimms = false;
}
ret_vec.emplace_back(tc);
}
* partially on two us-dimms.
* XXX - Because of the change about always-on SDS,
* this test case does not make sense anymore. */

/* Master and two secondary replicas on unsafely shutdown DIMMs */
{
Expand All @@ -344,6 +319,7 @@ std::vector<sync_local_replica_tc> GetSyncLocalReplicaParams() {
} else {
tc.enough_dimms = false;
}
tc.pmem = false;
ret_vec.emplace_back(tc);
}
return ret_vec;
Expand Down
3 changes: 2 additions & 1 deletion src/tests/ras/unsafe_shutdown/local_replicas_tests.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018, Intel Corporation
* Copyright 2018-2024, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -40,6 +40,7 @@ struct sync_local_replica_tc {
Poolset poolset;
bool enough_dimms;
bool is_syncable;
bool pmem;
};

class SyncLocalReplica
Expand Down
11 changes: 10 additions & 1 deletion src/tests/ras/unsafe_shutdown/unsafe_shutdown.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018, Intel Corporation
* Copyright 2018-2024, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -86,3 +86,12 @@ int UnsafeShutdown::PmempoolRepair(std::string pool_file_path) const {

return pmempool_check_end(ppc);
}

/* Change the status of the shutdown state */
void set_sds_at_create_func(bool state) {
int ret = pmemobj_ctl_set(NULL, "sds.at_create", &state);
if (ret) {
std::cerr << "Failed to set sds.at_create: " << pmemobj_errormsg() << std::endl;
exit(1);
}
}
4 changes: 3 additions & 1 deletion src/tests/ras/unsafe_shutdown/unsafe_shutdown.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2023, Intel Corporation
* Copyright 2018-2024, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -80,4 +80,6 @@ class UnsafeShutdown : public ::testing::Test {
void StampPassedResult() const;
};

void set_sds_at_create_func(bool state);

#endif // UNSAFE_SHUTDOWN_H

0 comments on commit d1aade3

Please sign in to comment.