Skip to content

Commit

Permalink
Merge pull request #100 from pmem/add_sds
Browse files Browse the repository at this point in the history
fix 1-phase of testing
  • Loading branch information
janekmi authored Jul 24, 2024
2 parents 0241cf8 + fed3773 commit b636a12
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 53 deletions.
17 changes: 14 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 @@ -51,6 +51,7 @@ std::vector<move_param> GetMoveParams() {
tc.enough_dimms = true;
tc.src_pool_dir = unsafe_dn[0].GetTestDir();
tc.dest_pool_dir = test_phase.GetTestDir();
tc.src_pool_dir_is_pmem = true;
} else {
tc.enough_dimms = false;
}
Expand All @@ -65,6 +66,7 @@ std::vector<move_param> GetMoveParams() {
tc.enough_dimms = true;
tc.src_pool_dir = test_phase.GetTestDir();
tc.dest_pool_dir = unsafe_dn[0].GetTestDir();
tc.src_pool_dir_is_pmem = false;
} else {
tc.enough_dimms = false;
}
Expand All @@ -79,6 +81,7 @@ std::vector<move_param> GetMoveParams() {
tc.enough_dimms = true;
tc.src_pool_dir = unsafe_dn[0].GetTestDir();
tc.dest_pool_dir = safe_dn[0].GetTestDir();
tc.src_pool_dir_is_pmem = true;
} else {
tc.enough_dimms = false;
}
Expand All @@ -93,6 +96,7 @@ std::vector<move_param> GetMoveParams() {
tc.enough_dimms = true;
tc.src_pool_dir = unsafe_dn[1].GetTestDir();
tc.dest_pool_dir = unsafe_dn[0].GetTestDir();
tc.src_pool_dir_is_pmem = true;
} else {
tc.enough_dimms = false;
}
Expand All @@ -107,6 +111,7 @@ std::vector<move_param> GetMoveParams() {
tc.enough_dimms = true;
tc.src_pool_dir = safe_dn[0].GetTestDir();
tc.dest_pool_dir = test_phase.GetTestDir();
tc.src_pool_dir_is_pmem = true;
} else {
tc.enough_dimms = false;
}
Expand All @@ -121,6 +126,7 @@ std::vector<move_param> GetMoveParams() {
tc.enough_dimms = true;
tc.src_pool_dir = test_phase.GetTestDir();
tc.dest_pool_dir = safe_dn[0].GetTestDir();
tc.src_pool_dir_is_pmem = false;
} else {
tc.enough_dimms = false;
}
Expand All @@ -136,6 +142,8 @@ 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";
create_on_pmem = param.src_pool_dir_is_pmem;
UnsafeShutdown::SetUp();
}

/**
Expand All @@ -144,7 +152,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. Create a pool on the device. / 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 @@ -160,6 +168,7 @@ TEST_P(MovePoolClean, TC_MOVE_POOL_CLEAN_phase_1) {
ASSERT_TRUE(pop_ != nullptr) << "Pool creating failed. Errno: " << errno
<< std::endl
<< pmemobj_errormsg();

/* Step2 */
ObjData<int> pd{pop_};
ASSERT_EQ(0, pd.Write(obj_data_)) << "Writing to pool failed";
Expand Down Expand Up @@ -195,14 +204,16 @@ void MovePoolDirty::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";
create_on_pmem = param.src_pool_dir_is_pmem;
UnsafeShutdown::SetUp();
}

/**
* TC_MOVE_POOL_DIRTY
* 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. Create a pool on the device. / 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 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 src_pool_dir_is_pmem;
};

std::ostream& operator<<(std::ostream& stream, move_param const& m);
Expand Down
52 changes: 7 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 @@ -41,6 +41,8 @@ void SyncLocalReplica::SetUp() {
sync_local_replica_tc param = GetParam();
ASSERT_TRUE(param.enough_dimms)
<< "Insufficient number of DIMMs to run this test";
create_on_pmem = true;
UnsafeShutdown::SetUp();
}

/**
Expand Down Expand Up @@ -153,28 +155,8 @@ std::vector<sync_local_replica_tc> GetSyncLocalReplicaParams() {
}

/* 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.
* Note: The use case was deemed irrelevant and deleted. */

/* Two local secodary replicas, one partially on unsafely shutdown DIMM, other
* on safely shutdown DIMM.
Expand Down Expand Up @@ -298,28 +280,8 @@ std::vector<sync_local_replica_tc> GetSyncLocalReplicaParams() {
}

/* 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.
* Note: The use case was deemed irrelevant and deleted. */

/* Master and two secondary replicas on unsafely shutdown DIMMs */
{
Expand Down
2 changes: 1 addition & 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
20 changes: 18 additions & 2 deletions 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 @@ -48,7 +48,7 @@ void UnsafeShutdown::StampPassedResult() const {
}
}

bool UnsafeShutdown::PassedOnPreviousPhase() const {
bool UnsafeShutdown:: PassedOnPreviousPhase() const {
bool ret = ApiC::RegularFileExists(GetPassedStamp());
if (ret) {
ApiC::RemoveFile(GetPassedStamp());
Expand Down Expand Up @@ -86,3 +86,19 @@ int UnsafeShutdown::PmempoolRepair(std::string pool_file_path) const {

return pmempool_check_end(ppc);
}

void UnsafeShutdown::SetSdsAtCreate(bool state) const {
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);
}
}

void UnsafeShutdown::SetUp() {
if (!create_on_pmem) {
SetSdsAtCreate(false);
} else {
SetSdsAtCreate(true);
}
}
7 changes: 6 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 @@ -58,6 +58,9 @@ class UnsafeShutdown : public ::testing::Test {
std::string GetNormalizedTestName() const;
int PmempoolRepair(std::string pool_file_path) const;


void SetUp() override;

~UnsafeShutdown() {
StampPassedResult();
if (close_pools_at_end_) {
Expand All @@ -69,6 +72,7 @@ class UnsafeShutdown : public ::testing::Test {

protected:
bool close_pools_at_end_ = true;
bool create_on_pmem = true;

private:
const ::testing::TestInfo& GetTestInfo() const {
Expand All @@ -78,6 +82,7 @@ class UnsafeShutdown : public ::testing::Test {
return test_phase_.GetTestDir() + GetNormalizedTestName() + "_passed";
}
void StampPassedResult() const;
void SetSdsAtCreate(bool state) const;
};

#endif // UNSAFE_SHUTDOWN_H

0 comments on commit b636a12

Please sign in to comment.