Skip to content

Commit

Permalink
#1490: tests: add test for new restoreFromFileInPlace
Browse files Browse the repository at this point in the history
  • Loading branch information
lifflander committed Aug 2, 2021
1 parent 0d663d4 commit 42cae0c
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions tests/unit/collection/test_checkpoint.extended.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<int32_t>(theContext()->getNumNodes());

auto range = vt::Index3D(num_nodes, num_elms, 4);
auto checkpoint_name = "test_checkpoint_dir";
auto proxy = vt::theCollection()->constructCollective<TestCol>(range);

vt::runInEpochCollective([&]{
if (this_node == 0) {
proxy.broadcast<TestCol::NullMsg,&TestCol::init>();
}
});

for (int i = 0; i < 5; i++) {
vt::runInEpochCollective([&]{
if (this_node == 0) {
proxy.template broadcast<TestCol::NullMsg,&TestCol::doIter>();
}
});
}

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<TestCol::NullMsg,&TestCol::nullToken>();
}
});

vt::thePhase()->nextPhaseCollective();

vt::theCollective()->barrier();

vt::theCollection()->restoreFromFileInPlace<TestCol>(
proxy, range, checkpoint_name
);

// Restoration should be done now
vt::theCollective()->barrier();

runInEpochCollective([&]{
if (this_node == 0) {
proxy.broadcast<TestCol::NullMsg,&TestCol::verify>();
}
});

runInEpochCollective([&]{
if (this_node == 0) {
proxy.destroy();
}
});

// Ensure that all elements were properly destroyed
EXPECT_EQ(counter, 0);
}

}}} // end namespace vt::tests::unit

0 comments on commit 42cae0c

Please sign in to comment.