diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2016-09-07 11:17:10 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2016-09-07 11:17:10 -0400 |
commit | b5277068ff66e7fe2b2a98144aa6993ca6e17f5c (patch) | |
tree | 7716ab116ef71fbff129fa31eb590649ed5c610a /src/mongo/db/ftdc/file_writer_test.cpp | |
parent | 40bd5f736fdf42a7032892eef272d3dfacd2e2a2 (diff) | |
download | mongo-b5277068ff66e7fe2b2a98144aa6993ca6e17f5c.tar.gz |
SERVER-25868 Incomplete FTDC files on Windows
Diffstat (limited to 'src/mongo/db/ftdc/file_writer_test.cpp')
-rw-r--r-- | src/mongo/db/ftdc/file_writer_test.cpp | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/mongo/db/ftdc/file_writer_test.cpp b/src/mongo/db/ftdc/file_writer_test.cpp index 86841fd475a..14fd205ad0a 100644 --- a/src/mongo/db/ftdc/file_writer_test.cpp +++ b/src/mongo/db/ftdc/file_writer_test.cpp @@ -45,6 +45,7 @@ namespace mongo { const char* kTestFile = "metrics.test"; +const char* kTestFileCopy = "metrics.test.copy"; // File Sanity check TEST(FTDCFileTest, TestFileBasicMetadata) { @@ -172,7 +173,27 @@ public: } private: - void validate(bool forceCompress = true) { + void validate() { + // Verify we are flushing writes correctly by copying the file, and then reading it. + auto tempfile(boost::filesystem::path(_tempdir.path()) / kTestFileCopy); + boost::filesystem::copy_file(_path, tempfile); + + // Read the file to make sure it is correct. + // We do not verify contents because the compressor may not have flushed the final records + // which is expected. + { + FTDCFileReader reader; + + ASSERT_OK(reader.open(tempfile)); + + auto sw = reader.hasNext(); + while (sw.isOK() && sw.getValue()) { + sw = reader.hasNext(); + } + + ASSERT_OK(sw); + } + _writer.close(); ValidateDocumentList(_path, _docs); @@ -296,6 +317,23 @@ TEST(FTDCFileTest, TestFull) { } } +// Test a large documents so that we cause multiple 4kb buffers to flush on Windows. +TEST(FTDCFileTest, TestLargeDocuments) { + FileTestTie c; + + for (int j = 0; j < 5; j++) { + for (size_t i = 0; i <= FTDCConfig::kMaxSamplesPerArchiveMetricChunkDefault; i++) { + BSONObjBuilder b; + b.append("name", "joe"); + for (size_t k = 0; k < 200; k++) { + b.appendNumber("num", static_cast<long long int>(i * j + 5000 - (sin(k) * 100))); + } + + c.addSample(b.obj()); + } + } +} + // Test a bad file TEST(FTDCFileTest, TestBadFile) { unittest::TempDir tempdir("metrics_testpath"); |