-
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
lsm-tree.cabal
Outdated
test-suite codec-test | ||
import: language, warnings, wno-x-partial | ||
type: exitcode-stdio-1.0 | ||
hs-source-dirs: test | ||
main-is: codec-test.hs | ||
build-depends: | ||
, base >=4.14 && <4.22 | ||
, fs-api ^>=0.3 | ||
, lsm-tree | ||
, tasty | ||
, tasty-golden | ||
, vector |
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'd suggest to put the tests into Test.Database.LSMTree.Internal.Snapshot.Codec.Golden
, and the golden files in to test/golden/snapshot-codec
or something similar
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.
Great insight. I'm refactored the golden test cases' location on disk and within the TestTree
.
test/codec-test.hs
Outdated
{-# LANGUAGE CPP #-} | ||
{-# LANGUAGE DerivingStrategies #-} | ||
{-# LANGUAGE GeneralisedNewtypeDeriving #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE RankNTypes #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} |
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 some of these language pragmas are unnecessary because they are already included in the common language
cabal stanza, which the test suite imports
test/codec-test.hs
Outdated
-- File comparison test-cases against authoritative "golden" files | ||
testCaseChecksum :: TestTree | ||
testCaseChecksum = Au.goldenVsFile "checksum" checksumAuPath checksumHsPath noWorkAction | ||
testCaseSnapshot :: TestTree | ||
testCaseSnapshot = Au.goldenVsFile "snapshot" snapshotAuPath snapshotHsPath noWorkAction | ||
|
||
-- Be sure to use Tasty's @withResource@ constructor to ensure that the | ||
-- codec serialization occurs only /once/ and is memoized for the /two/ | ||
-- golden tests (snapshot & checksum). | ||
in Tasty.withResource outputAction tidyUpAction $ \tok -> tok `seq` testGroup name | ||
[ testCaseSnapshot | ||
, testCaseChecksum | ||
] |
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.
If we leave out the checksums, we can get rid of the withResource
trickery
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.
Yep, that simplification is included in the refactoring.
351d4b2
to
8b0d38e
Compare
…e for serialization backwards compatibility testing.
8b0d38e
to
4c00cf4
Compare
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.