From 42cae0c48a4c9e4219649b5cb72eb9e0cb36b64d Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 30 Jun 2021 10:38:24 -0700 Subject: [PATCH] #1490: tests: add test for new restoreFromFileInPlace --- .../collection/test_checkpoint.extended.cc | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tests/unit/collection/test_checkpoint.extended.cc b/tests/unit/collection/test_checkpoint.extended.cc index 36f4fc61f8..3ab0cec516 100644 --- a/tests/unit/collection/test_checkpoint.extended.cc +++ b/tests/unit/collection/test_checkpoint.extended.cc @@ -223,7 +223,67 @@ TEST_F(TestCheckpoint, test_checkpoint_1) { // Ensure that all elements were properly destroyed EXPECT_EQ(counter, 0); } +} + +TEST_F(TestCheckpoint, test_checkpoint_in_place_2) { + auto this_node = theContext()->getNode(); + auto num_nodes = static_cast(theContext()->getNumNodes()); + + auto range = vt::Index3D(num_nodes, num_elms, 4); + auto checkpoint_name = "test_checkpoint_dir"; + auto proxy = vt::theCollection()->constructCollective(range); + + vt::runInEpochCollective([&]{ + if (this_node == 0) { + proxy.broadcast(); + } + }); + + for (int i = 0; i < 5; i++) { + vt::runInEpochCollective([&]{ + if (this_node == 0) { + proxy.template broadcast(); + } + }); + } + + vt::theCollection()->checkpointToFile(proxy, checkpoint_name); + + // Wait for all checkpoints to complete + vt::theCollective()->barrier(); + + // Null the token to ensure we don't end up getting the same instance + vt::runInEpochCollective([&]{ + if (this_node == 0) { + proxy.broadcast(); + } + }); + + vt::thePhase()->nextPhaseCollective(); + + vt::theCollective()->barrier(); + + vt::theCollection()->restoreFromFileInPlace( + proxy, range, checkpoint_name + ); + + // Restoration should be done now + vt::theCollective()->barrier(); + + runInEpochCollective([&]{ + if (this_node == 0) { + proxy.broadcast(); + } + }); + + runInEpochCollective([&]{ + if (this_node == 0) { + proxy.destroy(); + } + }); + // Ensure that all elements were properly destroyed + EXPECT_EQ(counter, 0); } }}} // end namespace vt::tests::unit