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

storage: add TestKeySchema_RandomKeys #133077

Merged
merged 1 commit into from
Oct 21, 2024
Merged

Conversation

jbowens
Copy link
Collaborator

@jbowens jbowens commented Oct 21, 2024

Add a randomized test that constructs random keys, writes them to a Pebble columnar block, iterates over the block and asserts that the keys are semantically equal to the original generated keys.

Epic: none
Release note: none

@jbowens jbowens requested a review from a team as a code owner October 21, 2024 16:35
@jbowens jbowens requested a review from itsbilal October 21, 2024 16:35
@cockroach-teamcity
Copy link
Member

This change is Reviewable

it.InitOnce(keySchema, EngineKeyCompare, EngineKeySplit, nil)
require.NoError(t, it.Init(&dec, block.NoTransforms))
for k, kv := 0, it.First(); kv != nil; k, kv = k+1, it.Next() {
require.True(t, EngineKeyEqual(keys[k], kv.K.UserKey))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we compare for exact equality? We assume that the keys will be identical (or at least never longer) when we preallocate the max-key-length buffer

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added an assertion on the length. This test will generate MVCC keys with the synthetic bit so we can't assert exact equality

Add a randomized test that constructs random keys, writes them to a Pebble
columnar block, iterates over the block and asserts that the keys are
semantically equal to the original generated keys.

Epic: none
Release note: none
Copy link
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @itsbilal)


pkg/storage/pebble_key_schema_test.go line 349 at r1 (raw file):

Previously, jbowens (Jackson Owens) wrote…

Added an assertion on the length. This test will generate MVCC keys with the synthetic bit so we can't assert exact equality

👍

@jbowens
Copy link
Collaborator Author

jbowens commented Oct 21, 2024

TFTR!

bors r=RaduBerinde

@craig craig bot merged commit ee22c97 into cockroachdb:master Oct 21, 2024
23 checks passed
@jbowens jbowens deleted the randomized-test branch October 21, 2024 20:25
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.

3 participants