-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Golden test suite for snapshot codec #499
base: main
Are you sure you want to change the base?
Conversation
So a big question I have is should this be a stand alone test suite (as it currently is) or should I graft it into the "monolithic" LST Tree test suite. I think the later might be more appropriate, and would appreciate a pointer as to where a good place in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new Bounded
and Enum
instances should arguably be orphan instances in the test suite. They are not necessary for the core library to function, or necessary for the user to have
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. There are also some comments we discussed over other channels, but I won't repeat them here
8b0d38e
to
4c00cf4
Compare
4c00cf4
to
00e7a07
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost LGTM! I do have some minor suggestions, but after that we can probably merge
@@ -70,7 +70,7 @@ instance RefCounted m (MergingRun m h) where | |||
getRefCounter = mergeRefCounter | |||
|
|||
data MergePolicyForLevel = LevelTiering | LevelLevelling | |||
deriving stock (Show, Eq) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you might have missed this suggestion: #499 (review)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, did we end up using these instances for the golden tests? It doesn't look like it -- if that's the case, let's remove these instances
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added review suggestions to undo these changes
@@ -47,6 +49,7 @@ tests = testGroup "Test.Database.LSMTree.Internal.Snapshot.Codec" [ | |||
testAll $ \(p :: Proxy a) -> | |||
testGroup (show $ typeRep p) $ | |||
prop_arbitraryAndShrinkPreserveInvariant @a deepseqInvariant | |||
, goldenFileTests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The typical approach we use in this test suite is to include the tests at the top level, so in the Main
module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I had to do some, semi-yucky I/O in the handleOutputFiles
definition, I tired to encapsulate that functionality in the Test.Database.LSMTree.Internal.Snapshot.Codec.Golden
module and just export the test cases. Do you have a suggested alteration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion is to move the call to goldenFileTests
to the Main
module
00e7a07
to
97d4d97
Compare
…e for serialization backwards compatibility testing.
97d4d97
to
623031b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just a few suggestions to resolve, and then we can squash and merge.
-- @Bounded@ and @Enum@ instances are required for test-case enumeration. | ||
deriving stock (Bounded, Enum, Eq, Show) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-- @Bounded@ and @Enum@ instances are required for test-case enumeration. | |
deriving stock (Bounded, Enum, Eq, Show) | |
deriving stock (Show, Eq) |
-- @Bounded@ and @Enum@ instances are required for test-case enumeration. | ||
deriving stock (Bounded, Enum, Eq, Show) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-- @Bounded@ and @Enum@ instances are required for test-case enumeration. | |
deriving stock (Bounded, Enum, Eq, Show) | |
deriving stock (Eq, Show) |
-- @Bounded@ and @Enum@ instances are required for test-case enumeration. | ||
deriving stock (Bounded, Enum, Eq, Show) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-- @Bounded@ and @Enum@ instances are required for test-case enumeration. | |
deriving stock (Bounded, Enum, Eq, Show) | |
deriving stock (Eq, Show) |
-- @Bounded@ and @Enum@ instances are required for test-case enumeration. | ||
deriving stock (Bounded, Enum, Eq, Show) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-- @Bounded@ and @Enum@ instances are required for test-case enumeration. | |
deriving stock (Bounded, Enum, Eq, Show) | |
deriving stock (Eq, Show) |
@@ -87,7 +87,7 @@ newtype SnapshotLabel = SnapshotLabel Text | |||
|
|||
-- TODO: revisit if we need three table types. | |||
data SnapshotTableType = SnapNormalTable | SnapMonoidalTable | SnapFullTable | |||
deriving stock (Show, Eq) | |||
deriving stock (Bounded, Enum, Eq, Show) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deriving stock (Bounded, Enum, Eq, Show) | |
deriving stock (Eq, Show) |
@@ -47,6 +49,7 @@ tests = testGroup "Test.Database.LSMTree.Internal.Snapshot.Codec" [ | |||
testAll $ \(p :: Proxy a) -> | |||
testGroup (show $ typeRep p) $ | |||
prop_arbitraryAndShrinkPreserveInvariant @a deepseqInvariant | |||
, goldenFileTests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion is to move the call to goldenFileTests
to the Main
module
testCodecSnapshotLabel :: TestTree | ||
testCodecSnapshotLabel = | ||
let assembler (tagA, valA) = | ||
let (tagB, valB) = basicSnapshotTableType | ||
(tagC, valC) = basicTableConfig | ||
(_tagD, valD) = basicRunNumber | ||
(tagE, valE) = basicSnapLevels | ||
in (fuseAnnotations [tagA, tagB, tagC, tagE ], SnapshotMetaData valA valB valC valD valE) | ||
in testCodecBuilder "SnapshotLabels" $ assembler <$> enumerateSnapshotLabel | ||
|
||
testCodecSnapshotTableType :: TestTree | ||
testCodecSnapshotTableType = | ||
let assembler (tagB, valB) = | ||
let (tagA, valA) = basicSnapshotLabel | ||
(tagC, valC) = basicTableConfig | ||
(_tagD, valD) = basicRunNumber | ||
(tagE, valE) = basicSnapLevels | ||
in (fuseAnnotations [tagA, tagB, tagC, tagE ], SnapshotMetaData valA valB valC valD valE) | ||
in testCodecBuilder "SnapshotTables" $ assembler <$> enumerateSnapshotTableType | ||
|
||
testCodecTableConfig :: TestTree | ||
testCodecTableConfig = | ||
let assembler (tagC, valC) = | ||
let (tagA, valA) = basicSnapshotLabel | ||
(tagB, valB) = basicSnapshotTableType | ||
(_tagD, valD) = basicRunNumber | ||
(tagE, valE) = basicSnapLevels | ||
in (fuseAnnotations [tagA, tagB, tagC, tagE ], SnapshotMetaData valA valB valC valD valE) | ||
in testCodecBuilder "SnapshotConfig" $ assembler <$> enumerateTableConfig | ||
|
||
testCodecSnapLevels :: TestTree | ||
testCodecSnapLevels = | ||
let assembler (tagE, valE) = | ||
let (tagA, valA) = basicSnapshotLabel | ||
(tagB, valB) = basicSnapshotTableType | ||
(tagC, valC) = basicTableConfig | ||
(_tagD, valD) = basicRunNumber | ||
in (fuseAnnotations [tagA, tagB, tagC, tagE ], SnapshotMetaData valA valB valC valD valE) | ||
in testCodecBuilder "SnapshotLevels" $ assembler <$> enumerateSnapLevels |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't _tagD
be included in the name?
@@ -70,7 +70,7 @@ instance RefCounted m (MergingRun m h) where | |||
getRefCounter = mergeRefCounter | |||
|
|||
data MergePolicyForLevel = LevelTiering | LevelLevelling | |||
deriving stock (Show, Eq) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added review suggestions to undo these changes
Description
Add the golden test cases to ensure that metadata serialization does not accidentally change. This will help ensure we maintain backwards compatibility. Changes in backwards compatibility should case test case failures.