Skip to content

Commit c6efd86

Browse files
committed
prototype: fix expectShape assertion
The comparison checked exactly the opposite of what it should, but the tests passed because the writebuffer was not considered in the shapes.
1 parent 72c438c commit c6efd86

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

prototypes/ScheduledMergesTest.hs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ test_regression_empty_run =
4949
del 3
5050

5151
expectShape lsm
52+
0
5253
[ ([], [4,4,4,4])
5354
]
5455

@@ -59,6 +60,7 @@ test_regression_empty_run =
5960
ins 3
6061

6162
expectShape lsm
63+
0
6264
[ ([], [4])
6365
, ([4,4,4,4], [])
6466
]
@@ -67,6 +69,7 @@ test_regression_empty_run =
6769
LSM.supply lsm 16
6870

6971
expectShape lsm
72+
0
7073
[ ([], [4])
7174
, ([], [0])
7275
]
@@ -85,24 +88,21 @@ test_merge_again_with_incoming =
8588
-- (needs 5 runs to go to level 2 so the resulting run becomes too big)
8689
traverse_ ins [101..100+(5*16)]
8790

88-
expectShape lsm -- not yet arrived at level 3, but will soon
89-
[ ([], [4,4,4,4])
90-
, ([16,16,16,16], [])
91-
]
92-
93-
-- get a very small run (4 elements) to 2nd level
91+
-- also get a very small run (4 elements) to 2nd level by re-using keys
9492
replicateM_ 4 $
9593
traverse_ ins [201..200+4]
9694

9795
expectShape lsm
98-
[ ([], [4,4,4,4]) -- these runs share the same keys
99-
, ([4,4,4,4,64], [])
96+
0
97+
[ ([], [4,4,4,4]) -- these runs share keys, will compact down to 4
98+
, ([4,4,4,4,64], []) -- this run will end up in level 3
10099
]
101100

102101
-- get another run to 2nd level, which the small run can be merged with
103102
traverse_ ins [301..300+16]
104103

105104
expectShape lsm
105+
0
106106
[ ([], [4,4,4,4])
107107
, ([4,4,4,4], [])
108108
, ([], [80])
@@ -112,6 +112,7 @@ test_merge_again_with_incoming =
112112
traverse_ ins [401..400+4]
113113

114114
expectShape lsm
115+
0
115116
[ ([], [4])
116117
, ([4,4,4,4,4], [])
117118
, ([], [80])
@@ -121,6 +122,7 @@ test_merge_again_with_incoming =
121122
LSM.supply lsm 16
122123

123124
expectShape lsm
125+
0
124126
[ ([], [4])
125127
, ([], [20])
126128
, ([], [80])
@@ -132,6 +134,7 @@ test_merge_again_with_incoming =
132134
traverse_ ins [501..500+(4*16)]
133135

134136
expectShape lsm
137+
0
135138
[ ([], [4])
136139
, ([4,4,4,4], [])
137140
, ([16,16,16,20,80], [])
@@ -158,10 +161,11 @@ instance Exception TracedException where
158161
displayException (Traced e ev) =
159162
displayException e <> "\ntrace:\n" <> unlines (map show ev)
160163

161-
expectShape :: HasCallStack => LSM s -> [([Int], [Int])] -> ST s ()
162-
expectShape lsm expected = do
164+
expectShape :: HasCallStack => LSM s -> Int -> [([Int], [Int])] -> ST s ()
165+
expectShape lsm expectedWb expectedLevels = do
166+
let expected = ([], [expectedWb]) : expectedLevels
163167
shape <- representationShape <$> dumpRepresentation lsm
164-
when (shape == expected) $
168+
when (shape /= expected) $
165169
error $ unlines
166170
[ "expected shape: " <> show expected
167171
, "actual shape: " <> show shape

0 commit comments

Comments
 (0)