Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

recursion-ninja
Copy link
Collaborator

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.

@recursion-ninja
Copy link
Collaborator Author

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 TestTree to insert them.

Copy link
Collaborator

@jorisdral jorisdral left a 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

@jorisdral jorisdral changed the title Recursion ninja/golden test suite Golden test suite for snapshot codec Dec 16, 2024
Copy link
Collaborator

@jorisdral jorisdral left a 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
Comment on lines 454 to 465
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
Copy link
Collaborator

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

Copy link
Collaborator Author

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.

Comment on lines 1 to 6
{-# LANGUAGE CPP #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
Copy link
Collaborator

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 Show resolved Hide resolved
test/codec-test.hs Outdated Show resolved Hide resolved
test/codec-test.hs Outdated Show resolved Hide resolved
test/codec-test.hs Outdated Show resolved Hide resolved
Comment on lines 86 to 98
-- 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
]
Copy link
Collaborator

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

Copy link
Collaborator Author

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.

test/codec-test.hs Outdated Show resolved Hide resolved
@recursion-ninja recursion-ninja force-pushed the recursion-ninja/golden-test-suite branch 2 times, most recently from 351d4b2 to 8b0d38e Compare December 22, 2024 17:53
…e for serialization backwards compatibility testing.
@recursion-ninja recursion-ninja force-pushed the recursion-ninja/golden-test-suite branch from 8b0d38e to 4c00cf4 Compare December 22, 2024 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants