FileTestTie() : _tempdir("metrics_testpath"), _path(boost::filesystem::path(_tempdir.path()) / kTestFile), _writer(&_config) { deleteFileIfNeeded(_path); ASSERT_OK(_writer.open(_path)); }
// File Sanity check TEST(FTDCFileTest, TestFileBasicMetadata) { unittest::TempDir tempdir("metrics_testpath"); boost::filesystem::path p(tempdir.path()); p /= kTestFile; deleteFileIfNeeded(p); BSONObj doc1 = BSON("name" << "joe" << "key1" << 34 << "key2" << 45); BSONObj doc2 = BSON("name" << "joe" << "key3" << 34 << "key5" << 45); FTDCConfig config; FTDCFileWriter writer(&config); ASSERT_OK(writer.open(p)); ASSERT_OK(writer.writeMetadata(doc1, Date_t())); ASSERT_OK(writer.writeMetadata(doc2, Date_t())); writer.close(); FTDCFileReader reader; ASSERT_OK(reader.open(p)); ASSERT_OK(reader.hasNext()); BSONObj doc1a = std::get<1>(reader.next()); ASSERT_BSONOBJ_EQ(doc1, doc1a); ASSERT_OK(reader.hasNext()); BSONObj doc2a = std::get<1>(reader.next()); ASSERT_BSONOBJ_EQ(doc2, doc2a); auto sw = reader.hasNext(); ASSERT_OK(sw); ASSERT_EQUALS(sw.getValue(), false); }