diff options
Diffstat (limited to 'src/mongo/db/ftdc/compressor_test.cpp')
-rw-r--r-- | src/mongo/db/ftdc/compressor_test.cpp | 223 |
1 files changed, 55 insertions, 168 deletions
diff --git a/src/mongo/db/ftdc/compressor_test.cpp b/src/mongo/db/ftdc/compressor_test.cpp index 143a6c4b391..509504037b7 100644 --- a/src/mongo/db/ftdc/compressor_test.cpp +++ b/src/mongo/db/ftdc/compressor_test.cpp @@ -70,18 +70,12 @@ TEST_F(FTDCCompressorTest, TestBasic) { auto st = c.addSample(BSON("name" << "joe" - << "key1" - << 33 - << "key2" - << 42), + << "key1" << 33 << "key2" << 42), Date_t()); ASSERT_HAS_SPACE(st); st = c.addSample(BSON("name" << "joe" - << "key1" - << 34 - << "key2" - << 45), + << "key1" << 34 << "key2" << 45), Date_t()); ASSERT_HAS_SPACE(st); @@ -190,112 +184,64 @@ TEST_F(FTDCCompressorTest, TestSchemaChanges) { auto st = c.addSample(BSON("name" << "joe" - << "key1" - << 33 - << "key2" - << 42)); + << "key1" << 33 << "key2" << 42)); ASSERT_HAS_SPACE(st); st = c.addSample(BSON("name" << "joe" - << "key1" - << 34 - << "key2" - << 45)); + << "key1" << 34 << "key2" << 45)); ASSERT_HAS_SPACE(st); st = c.addSample(BSON("name" << "joe" - << "key1" - << 34 - << "key2" - << 45)); + << "key1" << 34 << "key2" << 45)); ASSERT_HAS_SPACE(st); // Add Field st = c.addSample(BSON("name" << "joe" - << "key1" - << 34 - << "key2" - << 45 - << "key3" - << 47)); + << "key1" << 34 << "key2" << 45 << "key3" << 47)); ASSERT_SCHEMA_CHANGED(st); st = c.addSample(BSON("name" << "joe" - << "key1" - << 34 - << "key2" - << 45 - << "key3" - << 47)); + << "key1" << 34 << "key2" << 45 << "key3" << 47)); ASSERT_HAS_SPACE(st); // Rename field st = c.addSample(BSON("name" << "joe" - << "key1" - << 34 - << "key5" - << 45 - << "key3" - << 47)); + << "key1" << 34 << "key5" << 45 << "key3" << 47)); ASSERT_SCHEMA_CHANGED(st); // Change type st = c.addSample(BSON("name" << "joe" - << "key1" - << 34 - << "key5" + << "key1" << 34 << "key5" << "45" - << "key3" - << 47)); + << "key3" << 47)); ASSERT_SCHEMA_CHANGED(st); // Add Field st = c.addSample(BSON("name" << "joe" - << "key1" - << 34 - << "key2" - << 45 - << "key3" - << 47 - << "key7" - << 34 - << "key9" - << 45 - << "key13" - << 47)); + << "key1" << 34 << "key2" << 45 << "key3" << 47 << "key7" << 34 << "key9" + << 45 << "key13" << 47)); ASSERT_SCHEMA_CHANGED(st); // Remove Field st = c.addSample(BSON("name" << "joe" - << "key7" - << 34 - << "key9" - << 45 - << "key13" - << 47)); + << "key7" << 34 << "key9" << 45 << "key13" << 47)); ASSERT_SCHEMA_CHANGED(st); st = c.addSample(BSON("name" << "joe" - << "key7" - << 34 - << "key9" - << 45 - << "key13" - << 47)); + << "key7" << 34 << "key9" << 45 << "key13" << 47)); ASSERT_HAS_SPACE(st); // Start new batch st = c.addSample(BSON("name" << "joe" - << "key7" - << 5)); + << "key7" << 5)); ASSERT_SCHEMA_CHANGED(st); // Change field to object @@ -309,22 +255,19 @@ TEST_F(FTDCCompressorTest, TestSchemaChanges) { // Change field from object to number st = c.addSample(BSON("name" << "joe" - << "key7" - << 7)); + << "key7" << 7)); ASSERT_SCHEMA_CHANGED(st); // Change field from number to array st = c.addSample(BSON("name" << "joe" - << "key7" - << BSON_ARRAY(13 << 17))); + << "key7" << BSON_ARRAY(13 << 17))); ASSERT_SCHEMA_CHANGED(st); // Change field from array to number st = c.addSample(BSON("name" << "joe" - << "key7" - << 19)); + << "key7" << 19)); ASSERT_SCHEMA_CHANGED(st); @@ -351,13 +294,11 @@ TEST_F(FTDCCompressorTest, TestStringSchemaChanges) { auto st = c.addSample(BSON("str1" << "joe" - << "int1" - << 42)); + << "int1" << 42)); ASSERT_HAS_SPACE(st); st = c.addSample(BSON("str1" << "joe" - << "int1" - << 45)); + << "int1" << 45)); ASSERT_HAS_SPACE(st); // Add string field @@ -365,8 +306,7 @@ TEST_F(FTDCCompressorTest, TestStringSchemaChanges) { << "joe" << "str2" << "smith" - << "int1" - << 47)); + << "int1" << 47)); ASSERT_HAS_SPACE(st); // Reset schema by renaming a int field @@ -374,41 +314,34 @@ TEST_F(FTDCCompressorTest, TestStringSchemaChanges) { << "joe" << "str2" << "smith" - << "int2" - << 48)); + << "int2" << 48)); ASSERT_SCHEMA_CHANGED(st); // Remove string field st = c.addSample(BSON("str1" << "joe" - << "int2" - << 49)); + << "int2" << 49)); ASSERT_HAS_SPACE(st); // Add string field as last element st = c.addSample(BSON("str1" << "joe" - << "int2" - << 50 - << "str3" + << "int2" << 50 << "str3" << "bar")); ASSERT_HAS_SPACE(st); // Reset schema by renaming a int field st = c.addSample(BSON("str1" << "joe" - << "int1" - << 51 - << "str3" + << "int1" << 51 << "str3" << "bar")); ASSERT_SCHEMA_CHANGED(st); // Remove string field as last element st = c.addSample(BSON("str1" << "joe" - << "int1" - << 52)); + << "int1" << 52)); ASSERT_HAS_SPACE(st); @@ -419,8 +352,7 @@ TEST_F(FTDCCompressorTest, TestStringSchemaChanges) { << "smith" << "str3" << "foo" - << "int1" - << 53)); + << "int1" << 53)); ASSERT_HAS_SPACE(st); // Reset schema by renaming a int field @@ -430,15 +362,13 @@ TEST_F(FTDCCompressorTest, TestStringSchemaChanges) { << "smith" << "str3" << "foo" - << "int2" - << 54)); + << "int2" << 54)); ASSERT_SCHEMA_CHANGED(st); // Remove 2 string fields st = c.addSample(BSON("str1" << "joe" - << "int2" - << 55)); + << "int2" << 55)); ASSERT_HAS_SPACE(st); // Change string to number @@ -448,8 +378,7 @@ TEST_F(FTDCCompressorTest, TestStringSchemaChanges) { // Change number to string st = c.addSample(BSON("str1" << "joe" - << "int1" - << 67)); + << "int1" << 67)); ASSERT_SCHEMA_CHANGED(st); } @@ -459,24 +388,15 @@ TEST_F(FTDCCompressorTest, TestNumbersCompat) { auto st = c.addSample(BSON("name" << "joe" - << "key1" - << 33 - << "key2" - << 42LL)); + << "key1" << 33 << "key2" << 42LL)); ASSERT_HAS_SPACE(st); st = c.addSample(BSON("name" << "joe" - << "key1" - << 34LL - << "key2" - << 45.0f)); + << "key1" << 34LL << "key2" << 45.0f)); ASSERT_HAS_SPACE(st); st = c.addSample(BSON("name" << "joe" - << "key1" - << static_cast<char>(32) - << "key2" - << 45.0F)); + << "key1" << static_cast<char>(32) << "key2" << 45.0F)); ASSERT_HAS_SPACE(st); } @@ -500,50 +420,35 @@ TEST_F(FTDCCompressorTest, Types) { auto st = c.addSample(BSON("name" << "joe" - << "key1" - << 33 - << "key2" - << 42LL)); + << "key1" << 33 << "key2" << 42LL)); ASSERT_HAS_SPACE(st); const char bytes[] = {0x1, 0x2, 0x3}; - BSONObj o = BSON("created" << DATENOW // date_t - << "null" - << BSONNULL // { a : null } - << "undefined" - << BSONUndefined // { a : undefined } + BSONObj o = BSON("created" << DATENOW // date_t + << "null" << BSONNULL // { a : null } + << "undefined" << BSONUndefined // { a : undefined } << "obj" << BSON( // nested object "a" << "abc" - << "b" - << 123LL) + << "b" << 123LL) << "foo" << BSON_ARRAY("bar" << "baz" - << "qux") // array of strings - << "foo2" - << BSON_ARRAY(5 << 6 << 7) // array of ints - << "bindata" - << BSONBinData(&bytes[0], 3, bdtCustom) // bindata - << "oid" - << OID("010203040506070809101112") // oid - << "bool" - << true // bool - << "regex" - << BSONRegEx("mongodb") // regex - << "ref" - << BSONDBRef("c", OID("010203040506070809101112")) // ref - << "code" - << BSONCode("func f() { return 1; }") // code + << "qux") // array of strings + << "foo2" << BSON_ARRAY(5 << 6 << 7) // array of ints + << "bindata" << BSONBinData(&bytes[0], 3, bdtCustom) // bindata + << "oid" << OID("010203040506070809101112") // oid + << "bool" << true // bool + << "regex" << BSONRegEx("mongodb") // regex + << "ref" << BSONDBRef("c", OID("010203040506070809101112")) // ref + << "code" << BSONCode("func f() { return 1; }") // code << "codewscope" << BSONCodeWScope("func f() { return 1; }", BSON("c" << true)) // codew - << "minkey" - << MINKEY // minkey - << "maxkey" - << MAXKEY // maxkey - ); + << "minkey" << MINKEY // minkey + << "maxkey" << MAXKEY // maxkey + ); st = c.addSample(o); ASSERT_SCHEMA_CHANGED(st); @@ -553,17 +458,11 @@ TEST_F(FTDCCompressorTest, Types) { st = c.addSample(BSON("name" << "joe" - << "key1" - << 34LL - << "key2" - << 45.0f)); + << "key1" << 34LL << "key2" << 45.0f)); ASSERT_SCHEMA_CHANGED(st); st = c.addSample(BSON("name" << "joe" - << "key1" - << static_cast<char>(32) - << "key2" - << 45.0F)); + << "key1" << static_cast<char>(32) << "key2" << 45.0F)); ASSERT_HAS_SPACE(st); } @@ -575,37 +474,25 @@ TEST_F(FTDCCompressorTest, TestFull) { auto st = c.addSample(BSON("name" << "joe" - << "key1" - << 33 - << "key2" - << 42)); + << "key1" << 33 << "key2" << 42)); ASSERT_HAS_SPACE(st); for (size_t i = 0; i != FTDCConfig::kMaxSamplesPerArchiveMetricChunkDefault - 2; i++) { st = c.addSample(BSON("name" << "joe" - << "key1" - << static_cast<long long int>(i * j) - << "key2" - << 45)); + << "key1" << static_cast<long long int>(i * j) << "key2" << 45)); ASSERT_HAS_SPACE(st); } st = c.addSample(BSON("name" << "joe" - << "key1" - << 34 - << "key2" - << 45)); + << "key1" << 34 << "key2" << 45)); ASSERT_FULL(st); // Add Value st = c.addSample(BSON("name" << "joe" - << "key1" - << 34 - << "key2" - << 45)); + << "key1" << 34 << "key2" << 45)); ASSERT_HAS_SPACE(st); } } |