From de770716c3d79c666d5f8b84f965027b67ee78f9 Mon Sep 17 00:00:00 2001 From: Oksana Salyk Date: Mon, 22 Jul 2024 08:43:10 +0200 Subject: [PATCH] fix 1-phase of testing --- CMakeLists.txt | 5 +- .../ras/unsafe_shutdown/local_move_tests.cc | 24 ++++++- .../ras/unsafe_shutdown/local_move_tests.h | 3 +- .../unsafe_shutdown/local_replicas_tests.cc | 66 ++++++------------- .../unsafe_shutdown/local_replicas_tests.h | 3 +- .../ras/unsafe_shutdown/unsafe_shutdown.cc | 11 +++- .../ras/unsafe_shutdown/unsafe_shutdown.h | 4 +- 7 files changed, 63 insertions(+), 53 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 42d1b0b8..8dc62d0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2017-2023, Intel Corporation +# Copyright 2017-2024, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -35,6 +35,9 @@ cmake_minimum_required(VERSION 2.8.12) project(pmdk_tests) +# ignore all the warnings +add_definitions(-w) + # check if 32-bit architecture if (NOT CMAKE_SIZEOF_VOID_P EQUAL 8) message(FATAL_ERROR "----Building as 64-bit is required. Please set build to 64-bit----") diff --git a/src/tests/ras/unsafe_shutdown/local_move_tests.cc b/src/tests/ras/unsafe_shutdown/local_move_tests.cc index 2fbd12df..5db0a2c1 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 @@ -37,6 +37,8 @@ std::ostream& operator<<(std::ostream& stream, move_param const& m) { return stream; } +bool pmem; + std::vector GetMoveParams() { std::vector ret_vec; LocalTestPhase& test_phase = LocalTestPhase::GetInstance(); @@ -54,6 +56,7 @@ std::vector GetMoveParams() { } else { tc.enough_dimms = false; } + tc.pmem = true; ret_vec.emplace_back(tc); } @@ -68,6 +71,7 @@ std::vector GetMoveParams() { } else { tc.enough_dimms = false; } + tc.pmem = false; ret_vec.emplace_back(tc); } @@ -82,6 +86,7 @@ std::vector GetMoveParams() { } else { tc.enough_dimms = false; } + tc.pmem = true; ret_vec.emplace_back(tc); } @@ -96,6 +101,7 @@ std::vector GetMoveParams() { } else { tc.enough_dimms = false; } + tc.pmem = true; ret_vec.emplace_back(tc); } @@ -110,6 +116,7 @@ std::vector GetMoveParams() { } else { tc.enough_dimms = false; } + tc.pmem = true; ret_vec.emplace_back(tc); } @@ -124,6 +131,7 @@ std::vector GetMoveParams() { } else { tc.enough_dimms = false; } + tc.pmem = false; ret_vec.emplace_back(tc); } return ret_vec; @@ -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; } /** @@ -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 @@ -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 pd{pop_}; ASSERT_EQ(0, pd.Write(obj_data_)) << "Writing to pool failed"; @@ -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 @@ -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 pd{pop_}; diff --git a/src/tests/ras/unsafe_shutdown/local_move_tests.h b/src/tests/ras/unsafe_shutdown/local_move_tests.h index d6a70149..60ef4372 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 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 188cb323..8153fff2 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 @@ -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; } /** @@ -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 pd{pop_}; @@ -149,32 +156,14 @@ std::vector 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. @@ -201,6 +190,7 @@ std::vector GetSyncLocalReplicaParams() { } else { tc.enough_dimms = false; } + tc.pmem = true; ret_vec.emplace_back(tc); } @@ -223,6 +213,7 @@ std::vector GetSyncLocalReplicaParams() { } else { tc.enough_dimms = false; } + tc.pmem = false; ret_vec.emplace_back(tc); } @@ -246,6 +237,7 @@ std::vector GetSyncLocalReplicaParams() { } else { tc.enough_dimms = false; } + tc.pmem = false; ret_vec.emplace_back(tc); } @@ -269,6 +261,7 @@ std::vector GetSyncLocalReplicaParams() { } else { tc.enough_dimms = false; } + tc.pmem = false; ret_vec.emplace_back(tc); } @@ -294,32 +287,14 @@ std::vector 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 */ { @@ -344,6 +319,7 @@ std::vector GetSyncLocalReplicaParams() { } else { tc.enough_dimms = false; } + tc.pmem = false; ret_vec.emplace_back(tc); } return ret_vec; diff --git a/src/tests/ras/unsafe_shutdown/local_replicas_tests.h b/src/tests/ras/unsafe_shutdown/local_replicas_tests.h index 829c7035..fb6f6833 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 @@ -40,6 +40,7 @@ struct sync_local_replica_tc { Poolset poolset; bool enough_dimms; bool is_syncable; + bool pmem; }; class SyncLocalReplica diff --git a/src/tests/ras/unsafe_shutdown/unsafe_shutdown.cc b/src/tests/ras/unsafe_shutdown/unsafe_shutdown.cc index e28aa85a..3343fa25 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 @@ -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); + } +} diff --git a/src/tests/ras/unsafe_shutdown/unsafe_shutdown.h b/src/tests/ras/unsafe_shutdown/unsafe_shutdown.h index 28ba6f12..75c8a8a0 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 @@ -80,4 +80,6 @@ class UnsafeShutdown : public ::testing::Test { void StampPassedResult() const; }; +void set_sds_at_create_func(bool state); + #endif // UNSAFE_SHUTDOWN_H