TEST(MultiDatabase, ClearAllLog) { int iGroupCount = 2; MultiDatabase oDB; ASSERT_TRUE(InitDB(iGroupCount, oDB) == 0); const uint64_t llInstanceID = 3; std::string sValue = "hello paxos"; for (int iGroupIdx = 0; iGroupIdx < iGroupCount; iGroupIdx++) { WriteOptions oWriteOptions; oWriteOptions.bSync = true; ASSERT_TRUE(oDB.Put(oWriteOptions, iGroupIdx, llInstanceID, sValue) == 0); } for (int iGroupIdx = 0; iGroupIdx < iGroupCount; iGroupIdx++) { ASSERT_TRUE(oDB.ClearAllLog(iGroupIdx) == 0); } for (int iGroupIdx = 0; iGroupIdx < iGroupCount; iGroupIdx++) { const uint64_t llInstanceID = 3; std::string sGetValue; ASSERT_TRUE(oDB.Get(iGroupIdx, llInstanceID, sGetValue) == 1); } }
TEST(MultiDatabase, GetMaxInstanceID) { int iGroupCount = 2; MultiDatabase oDB; ASSERT_TRUE(InitDB(iGroupCount, oDB) == 0); const uint64_t llInstanceID = 3; std::string sValue = "hello paxos"; WriteOptions oWriteOptions; oWriteOptions.bSync = true; for (int iGroupIdx = 0; iGroupIdx < iGroupCount; iGroupIdx++) { ASSERT_TRUE(oDB.Put(oWriteOptions, iGroupIdx, llInstanceID + 1, sValue) == 0); ASSERT_TRUE(oDB.Put(oWriteOptions, iGroupIdx, llInstanceID + 3, sValue) == 0); uint64_t llMaxInstanceID = 0; ASSERT_TRUE(oDB.GetMaxInstanceID(iGroupIdx, llMaxInstanceID) == 0); EXPECT_TRUE(llMaxInstanceID == llInstanceID + 3); } }