diff --git a/src/tests/ras/unsafe_shutdown/local_move_tests.cc b/src/tests/ras/unsafe_shutdown/local_move_tests.cc index 2fbd12d..ede90cc 100644 --- a/src/tests/ras/unsafe_shutdown/local_move_tests.cc +++ b/src/tests/ras/unsafe_shutdown/local_move_tests.cc @@ -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 @@ -51,6 +51,7 @@ std::vector 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; } @@ -65,6 +66,7 @@ std::vector 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; } @@ -79,6 +81,7 @@ std::vector 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; } @@ -93,6 +96,7 @@ std::vector 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; } @@ -107,6 +111,7 @@ std::vector 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; } @@ -121,6 +126,7 @@ std::vector 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; } @@ -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(); } /** @@ -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 @@ -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 pd{pop_}; ASSERT_EQ(0, pd.Write(obj_data_)) << "Writing to pool failed"; @@ -195,6 +204,8 @@ 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(); } /** @@ -202,7 +213,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. 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 diff --git a/src/tests/ras/unsafe_shutdown/local_move_tests.h b/src/tests/ras/unsafe_shutdown/local_move_tests.h index d6a7014..00b14fc 100644 --- a/src/tests/ras/unsafe_shutdown/local_move_tests.h +++ b/src/tests/ras/unsafe_shutdown/local_move_tests.h @@ -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 @@ -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); diff --git a/src/tests/ras/unsafe_shutdown/local_replicas_tests.cc b/src/tests/ras/unsafe_shutdown/local_replicas_tests.cc index 188cb32..e8871dd 100644 --- a/src/tests/ras/unsafe_shutdown/local_replicas_tests.cc +++ b/src/tests/ras/unsafe_shutdown/local_replicas_tests.cc @@ -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 @@ -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(); } /** @@ -153,28 +155,8 @@ std::vector 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. @@ -298,28 +280,8 @@ std::vector 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 */ { diff --git a/src/tests/ras/unsafe_shutdown/local_replicas_tests.h b/src/tests/ras/unsafe_shutdown/local_replicas_tests.h index 829c703..8a639d2 100644 --- a/src/tests/ras/unsafe_shutdown/local_replicas_tests.h +++ b/src/tests/ras/unsafe_shutdown/local_replicas_tests.h @@ -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 diff --git a/src/tests/ras/unsafe_shutdown/unsafe_shutdown.cc b/src/tests/ras/unsafe_shutdown/unsafe_shutdown.cc index e28aa85..3e2441c 100644 --- a/src/tests/ras/unsafe_shutdown/unsafe_shutdown.cc +++ b/src/tests/ras/unsafe_shutdown/unsafe_shutdown.cc @@ -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 @@ -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()); @@ -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); + } +} diff --git a/src/tests/ras/unsafe_shutdown/unsafe_shutdown.h b/src/tests/ras/unsafe_shutdown/unsafe_shutdown.h index 28ba6f1..cf1c49d 100644 --- a/src/tests/ras/unsafe_shutdown/unsafe_shutdown.h +++ b/src/tests/ras/unsafe_shutdown/unsafe_shutdown.h @@ -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 @@ -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_) { @@ -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 { @@ -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