bool is_clean() const {
return tracker.is_clean();
}
+ template <typename missing_t>
+ bool debug_verify_from_init(
+ const missing_t &init_missing,
+ ostream *oss) const {
+ if (!TrackChanges)
+ return true;
+ auto check_missing(init_missing.get_items());
+ tracker.get_changed([&](const hobject_t &hoid) {
+ check_missing.erase(hoid);
+ if (missing.count(hoid)) {
+ check_missing.insert(*(missing.find(hoid)));
+ }
+ });
+ bool ok = true;
+ if (check_missing.size() != missing.size()) {
+ if (oss) {
+ *oss << "Size mismatch, check: " << check_missing.size()
+ << ", actual: " << missing.size() << "\n";
+ }
+ ok = false;
+ }
+ for (auto &i: missing) {
+ if (!check_missing.count(i.first)) {
+ if (oss)
+ *oss << "check_missing missing " << i.first << "\n";
+ ok = false;
+ } else if (check_missing[i.first] != i.second) {
+ if (oss)
+ *oss << "check_missing missing item mismatch on " << i.first
+ << ", check: " << check_missing[i.first]
+ << ", actual: " << i.second << "\n";
+ ok = false;
+ }
+ }
+ if (oss && !ok) {
+ *oss << "check_missing: " << check_missing << "\n";
+ set<hobject_t, hobject_t::BitwiseComparator> changed;
+ tracker.get_changed([&](const hobject_t &hoid) { changed.insert(hoid); });
+ *oss << "changed: " << changed << "\n";
+ }
+ return ok;
+ }
};
template <bool TrackChanges>
void encode(
const pg_log_entry_t &entry) {}
};
+ template <typename missing_t>
void verify_missing(
const TestCase &tcase,
- const pg_missing_t &missing) {
+ const missing_t &missing) {
ASSERT_EQ(tcase.final.get_items().size(), missing.get_items().size());
for (auto i = missing.get_items().begin();
i != missing.get_items().end();
EXPECT_EQ(tcase.final.get_items().find(i->first)->second.need, i->second.need);
EXPECT_EQ(tcase.final.get_items().find(i->first)->second.have, i->second.have);
}
+ bool correct = missing.debug_verify_from_init(tcase.init, &(std::cout));
+ ASSERT_TRUE(correct);
}
void verify_sideeffects(
pg_info_t info = tcase.get_divinfo();
missing = tcase.init;
+ missing.flush();
IndexedLog olog;
olog = tcase.get_fullauth();
missing.rm(ne.soid, ne.version);
}
+ missing.flush();
EXPECT_FALSE(is_dirty());
EXPECT_FALSE(remove_snap.empty());
EXPECT_TRUE(t.empty());
oe.op = pg_log_entry_t::MODIFY;
missing.add_next_event(oe);
+ missing.flush();
EXPECT_FALSE(is_dirty());
EXPECT_TRUE(remove_snap.empty());
EXPECT_TRUE(t.empty());
TestHandler h(remove_snap);
merge_old_entry(t, oe, info, &h);
+ missing.flush();
EXPECT_FALSE(is_dirty());
EXPECT_TRUE(remove_snap.size() > 0);
EXPECT_TRUE(t.empty());
oe.prior_version = eversion_t(2,1);
missing_add(oe.soid, oe.prior_version, eversion_t());
+ missing.flush();
EXPECT_FALSE(is_dirty());
EXPECT_TRUE(remove_snap.empty());
EXPECT_TRUE(t.empty());
TestHandler h(remove_snap);
merge_old_entry(t, oe, info, &h);
+ missing.flush();
EXPECT_FALSE(is_dirty());
EXPECT_TRUE(remove_snap.empty());
EXPECT_TRUE(t.empty());
missing.add(oe.soid, eversion_t(1,1), eversion_t());
+ missing.flush();
EXPECT_FALSE(is_dirty());
EXPECT_TRUE(remove_snap.empty());
EXPECT_TRUE(t.empty());
TestHandler h(remove_snap);
merge_old_entry(t, oe, info, &h);
+ missing.flush();
EXPECT_FALSE(is_dirty());
EXPECT_EQ(oe.soid, remove_snap.front());
EXPECT_TRUE(t.empty());