Skip to content

Commit fa6dc01

Browse files
ghemawatcmumford
authored andcommitted
A zippy change broke test assumptions about the size of compressed output.
Fix the tests by allowing more slop in zippy's behavior. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=123432472
1 parent 06a191b commit fa6dc01

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

table/table_test.cc

+14-6
Original file line numberDiff line numberDiff line change
@@ -853,12 +853,20 @@ TEST(TableTest, ApproximateOffsetOfCompressed) {
853853
options.compression = kSnappyCompression;
854854
c.Finish(options, &keys, &kvmap);
855855

856-
ASSERT_TRUE(Between(c.ApproximateOffsetOf("abc"), 0, 0));
857-
ASSERT_TRUE(Between(c.ApproximateOffsetOf("k01"), 0, 0));
858-
ASSERT_TRUE(Between(c.ApproximateOffsetOf("k02"), 0, 0));
859-
ASSERT_TRUE(Between(c.ApproximateOffsetOf("k03"), 2000, 3000));
860-
ASSERT_TRUE(Between(c.ApproximateOffsetOf("k04"), 2000, 3000));
861-
ASSERT_TRUE(Between(c.ApproximateOffsetOf("xyz"), 4000, 6000));
856+
// Expected upper and lower bounds of space used by compressible strings.
857+
static const int kSlop = 1000; // Compressor effectiveness varies.
858+
const int expected = 2500; // 10000 * compression ratio (0.25)
859+
const int min_z = expected - kSlop;
860+
const int max_z = expected + kSlop;
861+
862+
ASSERT_TRUE(Between(c.ApproximateOffsetOf("abc"), 0, kSlop));
863+
ASSERT_TRUE(Between(c.ApproximateOffsetOf("k01"), 0, kSlop));
864+
ASSERT_TRUE(Between(c.ApproximateOffsetOf("k02"), 0, kSlop));
865+
// Have now emitted a large compressible string, so adjust expected offset.
866+
ASSERT_TRUE(Between(c.ApproximateOffsetOf("k03"), min_z, max_z));
867+
ASSERT_TRUE(Between(c.ApproximateOffsetOf("k04"), min_z, max_z));
868+
// Have now emitted two large compressible strings, so adjust expected offset.
869+
ASSERT_TRUE(Between(c.ApproximateOffsetOf("xyz"), 2 * min_z, 2 * max_z));
862870
}
863871

864872
} // namespace leveldb

0 commit comments

Comments
 (0)