You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by "yatriks (via GitHub)" <gi...@apache.org> on 2026/09/08 19:41:14 UTC
[PR] test: Add compatibility tests across versions of `kvrocks` [kvrocks]
yatriks opened a new pull request, #3610:
URL: https://github.com/apache/kvrocks/pull/3610
## What
Adds integration tests validating that kvrocks data files written by older releases load and serve correctly on the current code, using [testcontainers-go](https://github.com/testcontainers/testcontainers-go) (#1372). Old versions run in containers against a shared volume, populate real data, then a freshly built `current` image starts on the same volume and verifies every key/value survived intact.
## Compatibility matrix
| Old version | Types exercised | Type first supported in |
|-------------|-----------------|-------------------------|
| v2.3.0 | string, hash, list, set, zset, stream, bitmap | — |
| v2.6.0 | + bloom filter | v2.6.0 |
| v2.7.0 | + json | v2.7.0 |
| v2.10.0 | + hyperloglog | v2.10.0 |
| v2.14.0 | + tdigest | v2.14.0 |
| v2.15.0 | + timeseries | v2.15.0 (disabled in v2.14.0) |
Each old version is populated only with the types it supports (version-aware capability map), then all are verified on the new side.
## CI
New `compatibility.yml` workflow runs the 6 pairs in parallel: builds the PR's own image once (`current`), pre-pulls the published old-version images, then each matrix job validates one pair. Runs on PRs touching storage/types/ commands/config, on pushes to `unstable`, and on releases.
Tests are gated behind a `compat` build tag so the default gocase suite in the main CI stays unaffected.
Local verification: full matrix passes (`KVROCKS_OLD_VERSION=v2.x go test -tags compat -count=1 -run TestCompatibilityAllTypes ./integration/compatibility/`).
Verified with GHA on fork: https://github.com/yatriks/kvrocks/pull/1
## Feedback notes
- Can the CI live in a better place? Downstream of other builds perhaps? (Note currently we build the `current` image and pull the rest from DockerHub)
- Does a release checklist need to be updated to add new images to this files with release/something we should automate?
- Please double check the compatibility matrix for correctness, as I have inferred from release notes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test: Add compatibility tests across versions of `kvrocks` [kvrocks]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #3610:
URL: https://github.com/apache/kvrocks/pull/3610#discussion_r4037157102
##########
.github/workflows/compatibility.yml:
##########
@@ -0,0 +1,109 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: Compatibility Tests
+
+on:
+ push:
+ branches: [unstable]
+ pull_request:
+ paths:
+ - '.github/workflows/compatibility.yml'
+ - 'src/**'
+ - 'tests/**'
Review Comment:
The workflow builds and runs the repository Docker image, but PRs changing only `Dockerfile` or the copied root `kvrocks.conf` do not trigger it. Such changes can alter startup, paths, or storage configuration without exercising this compatibility suite; include both inputs in the path filter.
##########
tests/gocase/integration/compatibility/compatibility_test.go:
##########
@@ -0,0 +1,163 @@
+//go:build compat
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package compatibility
+
+import (
+ "context"
+ "fmt"
+ "io"
+ "os"
+ "strings"
+ "testing"
+ "time"
+
+ dimage "github.com/docker/docker/api/types/image"
+
+ "github.com/redis/go-redis/v9"
+ "github.com/stretchr/testify/require"
+ "github.com/testcontainers/testcontainers-go"
+ "github.com/testcontainers/testcontainers-go/wait"
+)
+
+const (
+ kvrocksPort = "6666"
+ kvrocksDataDir = "/var/lib/kvrocks/db"
+ defaultVersion = "v2.3.0"
+)
+
+var oldVersion = os.Getenv("KVROCKS_OLD_VERSION")
+var newVersion = os.Getenv("KVROCKS_NEW_VERSION")
+
+func init() {
+ if oldVersion == "" {
+ oldVersion = defaultVersion
+ }
+ if newVersion == "" {
+ newVersion = "latest"
+ }
+}
+
+func startKvrocksContainer(ctx context.Context, t *testing.T, image, volumeName string) (testcontainers.Container, error) {
+ client, err := testcontainers.NewDockerClientWithOpts(ctx)
+ if err != nil {
+ return nil, fmt.Errorf("connect to docker: %w", err)
+ }
+ imageInspect, err := client.ImageInspect(ctx, image)
+ if err != nil {
+ // Image not present locally (e.g. fresh CI runner): pull it first.
+ // Container creation would pull anyway, but the entrypoint rewrite
+ // below needs the image's config.
+ rc, pullErr := client.ImagePull(ctx, image, dimage.PullOptions{})
+ if pullErr != nil {
+ return nil, fmt.Errorf("pull image %s: %w", image, pullErr)
+ }
+ _, _ = io.Copy(io.Discard, rc) // consume until the pull completes
+ rc.Close()
+ imageInspect, err = client.ImageInspect(ctx, image)
+ if err != nil {
+ return nil, fmt.Errorf("inspect image %s after pull: %w", image, err)
+ }
+ }
+ originalEntrypointCmd := strings.Join(imageInspect.Config.Entrypoint, " ")
+ workingDir := imageInspect.Config.WorkingDir
+
+ // older images had default user as root; in the entrypoint, we check if we're running as uid 999, then:
+ // 1. set ownership of the database mounted volume, as older versions will have this directory owned by root,
+ // 2. change user to 999:999 kvrocks
+ preambleCmd := fmt.Sprintf("[ $(id -u) -eq 999 ] && chown -R 999:999 /var/lib/kvrocks/db && su kvrocks || cd %s", workingDir)
Review Comment:
Because the container request forces `User: "root"`, `id -u` is always 0 here, so this ownership/drop-privileges branch is unreachable. Moreover, `su kvrocks` would start a shell rather than execute the server if reached. This makes every tested image run as root and masks the ownership transition the preamble claims to validate; inspect the image's configured user, chown as root when needed, and execute the entrypoint under that user explicitly.
##########
tests/gocase/integration/compatibility/testdata.go:
##########
@@ -0,0 +1,1104 @@
+//go:build compat
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package compatibility
+
+import (
+ "context"
+ "encoding/json"
+ "fmt"
+ "math"
+ "math/rand"
+ "strconv"
+ "strings"
+
+ "github.com/redis/go-redis/v9"
+)
+
+// SeededRandom provides deterministic random generation for reproducible tests
+type SeededRandom struct {
+ rng *rand.Rand
+}
+
+// NewSeededRandom creates a SeededRandom with the given seed
+func NewSeededRandom(seed int64) *SeededRandom {
+ return &SeededRandom{rng: rand.New(rand.NewSource(seed))}
+}
+
+// String generates a random alphanumeric string of the given length
+func (r *SeededRandom) String(length int) string {
+ const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
+ b := make([]byte, length)
+ for i := range b {
+ b[i] = charset[r.rng.Intn(len(charset))]
+ }
+ return string(b)
+}
+
+// Bytes generates random bytes of the given length
+func (r *SeededRandom) Bytes(length int) []byte {
+ b := make([]byte, length)
+ r.rng.Read(b)
+ return b
+}
+
+// Int63 returns a random int64 in range [0, upper)
+func (r *SeededRandom) Int63(upper int64) int64 {
+ return r.rng.Int63n(upper)
+}
+
+// Int returns a random int in range [0, upper)
+func (r *SeededRandom) Int(upper int) int {
+ return r.rng.Intn(upper)
+}
+
+// Float64 returns a random float64 in [0, 1)
+func (r *SeededRandom) Float64() float64 {
+ return r.rng.Float64()
+}
+
+// TestData contains all populated test data for verification
+type TestData struct {
+ Strings map[string]string
+ Hashes map[string]map[string]string
+ Lists map[string][]string
+ Sets map[string][]string
+ ZSets map[string][]ZSetEntry
+ Streams map[string][]StreamEntry
+ Bitmaps map[string][]byte
+ BloomFilters map[string][]string
+ JSONs map[string]string
+ HLLs map[string][]string
+ TDigests map[string][]float64
+ TimeSeries map[string][]TSSample
+}
+
+// TSSample represents a time series sample
+type TSSample struct {
+ Timestamp uint64
+ Value float64
+}
+
+// ZSetEntry represents a sorted set member
+type ZSetEntry struct {
+ Score float64
+ Member string
+}
+
+// StreamEntry represents a stream entry
+type StreamEntry struct {
+ ID string
+ Field string
+ Value string
+}
+
+// Data type identifiers
+const (
+ TypeString = "string"
+ TypeHash = "hash"
+ TypeList = "list"
+ TypeSet = "set"
+ TypeZSet = "zset"
+ TypeStream = "stream"
+ TypeBitmap = "bitmap"
+ TypeBloomFilter = "bloomfilter"
+ TypeJSON = "json"
+ TypeHyperLogLog = "hyperloglog"
+ TypeTDigest = "tdigest"
+ TypeTimeSeries = "timeseries"
+)
+
+// supportedTypesByVersion maps version strings to supported data types.
+// Verified against the command registration in each release tag (e.g.
+// bf.reserve in v2.6.0, json.set in v2.7.0, pfadd in v2.10.0,
+// tdigest.create in v2.14.0; timeseries exists in v2.14.0 source but its
+// REDIS_REGISTER_COMMANDS is commented out, so it is not listed there and
+// first appears in v2.15.0).
+var supportedTypesByVersion = map[string][]string{
+ "v2.3.0": {TypeString, TypeHash, TypeList, TypeSet, TypeZSet, TypeStream, TypeBitmap},
+ "v2.6.0": {TypeString, TypeHash, TypeList, TypeSet, TypeZSet, TypeStream, TypeBitmap, TypeBloomFilter},
+ "v2.7.0": {TypeString, TypeHash, TypeList, TypeSet, TypeZSet, TypeStream, TypeBitmap, TypeBloomFilter, TypeJSON},
+ "v2.10.0": {TypeString, TypeHash, TypeList, TypeSet, TypeZSet, TypeStream, TypeBitmap, TypeBloomFilter, TypeJSON, TypeHyperLogLog},
+ "v2.14.0": {TypeString, TypeHash, TypeList, TypeSet, TypeZSet, TypeStream, TypeBitmap, TypeBloomFilter, TypeJSON, TypeHyperLogLog, TypeTDigest},
+ "v2.15.0": {TypeString, TypeHash, TypeList, TypeSet, TypeZSet, TypeStream, TypeBitmap, TypeBloomFilter, TypeJSON, TypeHyperLogLog, TypeTDigest, TypeTimeSeries},
+}
+
+// IsTypeSupported checks if a data type is supported by the given version
+func IsTypeSupported(version string, dataType string) bool {
+ types, ok := supportedTypesByVersion[version]
+ if !ok {
+ return false
+ }
+ for _, t := range types {
+ if t == dataType {
+ return true
+ }
+ }
+ return false
+}
+
+// PopulateTestData populates all supported data types for the given version
+func PopulateTestData(ctx context.Context, client *redis.Client, version string) (*TestData, error) {
+ data := &TestData{
+ Strings: make(map[string]string),
+ Hashes: make(map[string]map[string]string),
+ Lists: make(map[string][]string),
+ Sets: make(map[string][]string),
+ ZSets: make(map[string][]ZSetEntry),
+ Streams: make(map[string][]StreamEntry),
+ Bitmaps: make(map[string][]byte),
+ BloomFilters: make(map[string][]string),
+ JSONs: make(map[string]string),
+ HLLs: make(map[string][]string),
+ TDigests: make(map[string][]float64),
+ TimeSeries: make(map[string][]TSSample),
+ }
+
+ // Use version-based seed for determinism
+ seed := int64(12345)
+ r := NewSeededRandom(seed)
+
+ // Populate strings (seed 0)
+ if IsTypeSupported(version, TypeString) {
+ var err error
+ data.Strings, err = populateStrings(ctx, client, r)
+ if err != nil {
+ return nil, fmt.Errorf("strings: %w", err)
+ }
+ }
+
+ // Populate hashes (seed 1)
+ if IsTypeSupported(version, TypeHash) {
+ r1 := NewSeededRandom(seed + 1)
+ var err error
+ data.Hashes, err = populateHashes(ctx, client, r1)
+ if err != nil {
+ return nil, fmt.Errorf("hashes: %w", err)
+ }
+ }
+
+ // Populate lists (seed 2)
+ if IsTypeSupported(version, TypeList) {
+ r2 := NewSeededRandom(seed + 2)
+ var err error
+ data.Lists, err = populateLists(ctx, client, r2)
+ if err != nil {
+ return nil, fmt.Errorf("lists: %w", err)
+ }
+ }
+
+ // Populate sets (seed 3)
+ if IsTypeSupported(version, TypeSet) {
+ r3 := NewSeededRandom(seed + 3)
+ var err error
+ data.Sets, err = populateSets(ctx, client, r3)
+ if err != nil {
+ return nil, fmt.Errorf("sets: %w", err)
+ }
+ }
+
+ // Populate zsets (seed 4)
+ if IsTypeSupported(version, TypeZSet) {
+ r4 := NewSeededRandom(seed + 4)
+ var err error
+ data.ZSets, err = populateZSets(ctx, client, r4)
+ if err != nil {
+ return nil, fmt.Errorf("zsets: %w", err)
+ }
+ }
+
+ // Populate streams (seed 5)
+ if IsTypeSupported(version, TypeStream) {
+ r5 := NewSeededRandom(seed + 5)
+ var err error
+ data.Streams, err = populateStreams(ctx, client, r5)
+ if err != nil {
+ return nil, fmt.Errorf("streams: %w", err)
+ }
+ }
+
+ // Populate bitmaps (seed 6)
+ if IsTypeSupported(version, TypeBitmap) {
+ r6 := NewSeededRandom(seed + 6)
+ var err error
+ data.Bitmaps, err = populateBitmaps(ctx, client, r6)
+ if err != nil {
+ return nil, fmt.Errorf("bitmaps: %w", err)
+ }
+ }
+
+ // Populate bloom filters (seed 7)
+ if IsTypeSupported(version, TypeBloomFilter) {
+ r7 := NewSeededRandom(seed + 7)
+ var err error
+ data.BloomFilters, err = populateBloomFilters(ctx, client, r7)
+ if err != nil {
+ return nil, fmt.Errorf("bloom filters: %w", err)
+ }
+ }
+
+ // Populate JSON docs (seed 8)
+ if IsTypeSupported(version, TypeJSON) {
+ r8 := NewSeededRandom(seed + 8)
+ var err error
+ data.JSONs, err = populateJSONs(ctx, client, r8)
+ if err != nil {
+ return nil, fmt.Errorf("json: %w", err)
+ }
+ }
+
+ // Populate hyperloglogs (seed 9)
+ if IsTypeSupported(version, TypeHyperLogLog) {
+ r9 := NewSeededRandom(seed + 9)
+ var err error
+ data.HLLs, err = populateHLLs(ctx, client, r9)
+ if err != nil {
+ return nil, fmt.Errorf("hyperloglogs: %w", err)
+ }
+ }
+
+ // Populate tdigests (seed 10)
+ if IsTypeSupported(version, TypeTDigest) {
+ r10 := NewSeededRandom(seed + 10)
+ var err error
+ data.TDigests, err = populateTDigests(ctx, client, r10)
+ if err != nil {
+ return nil, fmt.Errorf("tdigests: %w", err)
+ }
+ }
+
+ // Populate time series (seed 11)
+ if IsTypeSupported(version, TypeTimeSeries) {
+ r11 := NewSeededRandom(seed + 11)
+ var err error
+ data.TimeSeries, err = populateTimeSeries(ctx, client, r11)
+ if err != nil {
+ return nil, fmt.Errorf("time series: %w", err)
+ }
+ }
+
+ return data, nil
+}
+
+// VerifyTestData verifies all test data is preserved
+func VerifyTestData(ctx context.Context, client *redis.Client, data *TestData) error {
+ seed := int64(12345)
+
+ if data.Strings != nil {
+ r := NewSeededRandom(seed)
+ if err := verifyStrings(ctx, client, data.Strings, r); err != nil {
+ return fmt.Errorf("strings: %w", err)
+ }
+ }
+
+ if data.Hashes != nil {
+ r := NewSeededRandom(seed + 1)
+ if err := verifyHashes(ctx, client, data.Hashes, r); err != nil {
+ return fmt.Errorf("hashes: %w", err)
+ }
+ }
+
+ if data.Lists != nil {
+ r := NewSeededRandom(seed + 2)
+ if err := verifyLists(ctx, client, data.Lists, r); err != nil {
+ return fmt.Errorf("lists: %w", err)
+ }
+ }
+
+ if data.Sets != nil {
+ r := NewSeededRandom(seed + 3)
+ if err := verifySets(ctx, client, data.Sets, r); err != nil {
+ return fmt.Errorf("sets: %w", err)
+ }
+ }
+
+ if data.ZSets != nil {
+ r := NewSeededRandom(seed + 4)
+ if err := verifyZSets(ctx, client, data.ZSets, r); err != nil {
+ return fmt.Errorf("zsets: %w", err)
+ }
+ }
+
+ if data.Streams != nil {
+ r := NewSeededRandom(seed + 5)
+ if err := verifyStreams(ctx, client, data.Streams, r); err != nil {
+ return fmt.Errorf("streams: %w", err)
+ }
+ }
+
+ if data.Bitmaps != nil {
+ r := NewSeededRandom(seed + 6)
+ if err := verifyBitmaps(ctx, client, data.Bitmaps, r); err != nil {
+ return fmt.Errorf("bitmaps: %w", err)
+ }
+ }
+
+ // Maps are always initialized; empty means the old version did not
+ // support the type, so there is nothing to verify.
+ if len(data.BloomFilters) > 0 {
+ r := NewSeededRandom(seed + 7)
+ if err := verifyBloomFilters(ctx, client, data.BloomFilters, r); err != nil {
+ return fmt.Errorf("bloom filters: %w", err)
+ }
+ }
+
+ if len(data.JSONs) > 0 {
+ r := NewSeededRandom(seed + 8)
+ if err := verifyJSONs(ctx, client, data.JSONs, r); err != nil {
+ return fmt.Errorf("json: %w", err)
+ }
+ }
+
+ if len(data.HLLs) > 0 {
+ r := NewSeededRandom(seed + 9)
+ if err := verifyHLLs(ctx, client, data.HLLs, r); err != nil {
+ return fmt.Errorf("hyperloglogs: %w", err)
+ }
+ }
+
+ if len(data.TDigests) > 0 {
+ r := NewSeededRandom(seed + 10)
+ if err := verifyTDigests(ctx, client, data.TDigests, r); err != nil {
+ return fmt.Errorf("tdigests: %w", err)
+ }
+ }
+
+ if len(data.TimeSeries) > 0 {
+ r := NewSeededRandom(seed + 11)
+ if err := verifyTimeSeries(ctx, client, data.TimeSeries, r); err != nil {
+ return fmt.Errorf("time series: %w", err)
+ }
+ }
+
+ return nil
+}
+
+// populateStrings creates random string keys and returns what was stored
+func populateStrings(ctx context.Context, client *redis.Client, r *SeededRandom) (map[string]string, error) {
+ result := make(map[string]string)
+
+ // Generate N random string keys
+ for i := 0; i < 10; i++ {
+ key := fmt.Sprintf("str:%d", i)
+ value := r.String(64) // 64 char random string
+ if err := client.Set(ctx, key, value, 0).Err(); err != nil {
Review Comment:
All generated keys are persistent, so this suite never checks compatibility of the metadata expiration field. That field is a particularly important boundary here because legacy metadata stores expiry in 32-bit seconds while the current format uses 64-bit milliseconds (`src/storage/redis_metadata.h:162-168`); add long-lived expiring data and verify its absolute expiry remains approximately unchanged after reopening.
##########
tests/gocase/integration/compatibility/testdata.go:
##########
@@ -0,0 +1,1104 @@
+//go:build compat
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package compatibility
+
+import (
+ "context"
+ "encoding/json"
+ "fmt"
+ "math"
+ "math/rand"
+ "strconv"
+ "strings"
+
+ "github.com/redis/go-redis/v9"
+)
+
+// SeededRandom provides deterministic random generation for reproducible tests
+type SeededRandom struct {
+ rng *rand.Rand
+}
+
+// NewSeededRandom creates a SeededRandom with the given seed
+func NewSeededRandom(seed int64) *SeededRandom {
+ return &SeededRandom{rng: rand.New(rand.NewSource(seed))}
+}
+
+// String generates a random alphanumeric string of the given length
+func (r *SeededRandom) String(length int) string {
+ const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
+ b := make([]byte, length)
+ for i := range b {
+ b[i] = charset[r.rng.Intn(len(charset))]
+ }
+ return string(b)
+}
+
+// Bytes generates random bytes of the given length
+func (r *SeededRandom) Bytes(length int) []byte {
+ b := make([]byte, length)
+ r.rng.Read(b)
+ return b
+}
+
+// Int63 returns a random int64 in range [0, upper)
+func (r *SeededRandom) Int63(upper int64) int64 {
+ return r.rng.Int63n(upper)
+}
+
+// Int returns a random int in range [0, upper)
+func (r *SeededRandom) Int(upper int) int {
+ return r.rng.Intn(upper)
+}
+
+// Float64 returns a random float64 in [0, 1)
+func (r *SeededRandom) Float64() float64 {
+ return r.rng.Float64()
+}
+
+// TestData contains all populated test data for verification
+type TestData struct {
+ Strings map[string]string
+ Hashes map[string]map[string]string
+ Lists map[string][]string
+ Sets map[string][]string
+ ZSets map[string][]ZSetEntry
+ Streams map[string][]StreamEntry
+ Bitmaps map[string][]byte
+ BloomFilters map[string][]string
+ JSONs map[string]string
+ HLLs map[string][]string
+ TDigests map[string][]float64
+ TimeSeries map[string][]TSSample
+}
+
+// TSSample represents a time series sample
+type TSSample struct {
+ Timestamp uint64
+ Value float64
+}
+
+// ZSetEntry represents a sorted set member
+type ZSetEntry struct {
+ Score float64
+ Member string
+}
+
+// StreamEntry represents a stream entry
+type StreamEntry struct {
+ ID string
+ Field string
+ Value string
+}
+
+// Data type identifiers
+const (
+ TypeString = "string"
+ TypeHash = "hash"
+ TypeList = "list"
+ TypeSet = "set"
+ TypeZSet = "zset"
+ TypeStream = "stream"
+ TypeBitmap = "bitmap"
+ TypeBloomFilter = "bloomfilter"
+ TypeJSON = "json"
+ TypeHyperLogLog = "hyperloglog"
+ TypeTDigest = "tdigest"
+ TypeTimeSeries = "timeseries"
+)
+
+// supportedTypesByVersion maps version strings to supported data types.
+// Verified against the command registration in each release tag (e.g.
+// bf.reserve in v2.6.0, json.set in v2.7.0, pfadd in v2.10.0,
+// tdigest.create in v2.14.0; timeseries exists in v2.14.0 source but its
+// REDIS_REGISTER_COMMANDS is commented out, so it is not listed there and
+// first appears in v2.15.0).
+var supportedTypesByVersion = map[string][]string{
+ "v2.3.0": {TypeString, TypeHash, TypeList, TypeSet, TypeZSet, TypeStream, TypeBitmap},
+ "v2.6.0": {TypeString, TypeHash, TypeList, TypeSet, TypeZSet, TypeStream, TypeBitmap, TypeBloomFilter},
+ "v2.7.0": {TypeString, TypeHash, TypeList, TypeSet, TypeZSet, TypeStream, TypeBitmap, TypeBloomFilter, TypeJSON},
+ "v2.10.0": {TypeString, TypeHash, TypeList, TypeSet, TypeZSet, TypeStream, TypeBitmap, TypeBloomFilter, TypeJSON, TypeHyperLogLog},
+ "v2.14.0": {TypeString, TypeHash, TypeList, TypeSet, TypeZSet, TypeStream, TypeBitmap, TypeBloomFilter, TypeJSON, TypeHyperLogLog, TypeTDigest},
+ "v2.15.0": {TypeString, TypeHash, TypeList, TypeSet, TypeZSet, TypeStream, TypeBitmap, TypeBloomFilter, TypeJSON, TypeHyperLogLog, TypeTDigest, TypeTimeSeries},
+}
+
+// IsTypeSupported checks if a data type is supported by the given version
+func IsTypeSupported(version string, dataType string) bool {
+ types, ok := supportedTypesByVersion[version]
+ if !ok {
+ return false
+ }
+ for _, t := range types {
+ if t == dataType {
+ return true
+ }
+ }
+ return false
+}
+
+// PopulateTestData populates all supported data types for the given version
+func PopulateTestData(ctx context.Context, client *redis.Client, version string) (*TestData, error) {
+ data := &TestData{
+ Strings: make(map[string]string),
+ Hashes: make(map[string]map[string]string),
+ Lists: make(map[string][]string),
+ Sets: make(map[string][]string),
+ ZSets: make(map[string][]ZSetEntry),
+ Streams: make(map[string][]StreamEntry),
+ Bitmaps: make(map[string][]byte),
+ BloomFilters: make(map[string][]string),
+ JSONs: make(map[string]string),
+ HLLs: make(map[string][]string),
+ TDigests: make(map[string][]float64),
+ TimeSeries: make(map[string][]TSSample),
+ }
+
+ // Use version-based seed for determinism
+ seed := int64(12345)
+ r := NewSeededRandom(seed)
+
+ // Populate strings (seed 0)
+ if IsTypeSupported(version, TypeString) {
+ var err error
+ data.Strings, err = populateStrings(ctx, client, r)
+ if err != nil {
+ return nil, fmt.Errorf("strings: %w", err)
+ }
+ }
+
+ // Populate hashes (seed 1)
+ if IsTypeSupported(version, TypeHash) {
+ r1 := NewSeededRandom(seed + 1)
+ var err error
+ data.Hashes, err = populateHashes(ctx, client, r1)
+ if err != nil {
+ return nil, fmt.Errorf("hashes: %w", err)
+ }
+ }
+
+ // Populate lists (seed 2)
+ if IsTypeSupported(version, TypeList) {
+ r2 := NewSeededRandom(seed + 2)
+ var err error
+ data.Lists, err = populateLists(ctx, client, r2)
+ if err != nil {
+ return nil, fmt.Errorf("lists: %w", err)
+ }
+ }
+
+ // Populate sets (seed 3)
+ if IsTypeSupported(version, TypeSet) {
+ r3 := NewSeededRandom(seed + 3)
+ var err error
+ data.Sets, err = populateSets(ctx, client, r3)
+ if err != nil {
+ return nil, fmt.Errorf("sets: %w", err)
+ }
+ }
+
+ // Populate zsets (seed 4)
+ if IsTypeSupported(version, TypeZSet) {
+ r4 := NewSeededRandom(seed + 4)
+ var err error
+ data.ZSets, err = populateZSets(ctx, client, r4)
+ if err != nil {
+ return nil, fmt.Errorf("zsets: %w", err)
+ }
+ }
+
+ // Populate streams (seed 5)
+ if IsTypeSupported(version, TypeStream) {
+ r5 := NewSeededRandom(seed + 5)
+ var err error
+ data.Streams, err = populateStreams(ctx, client, r5)
+ if err != nil {
+ return nil, fmt.Errorf("streams: %w", err)
+ }
+ }
+
+ // Populate bitmaps (seed 6)
+ if IsTypeSupported(version, TypeBitmap) {
+ r6 := NewSeededRandom(seed + 6)
+ var err error
+ data.Bitmaps, err = populateBitmaps(ctx, client, r6)
+ if err != nil {
+ return nil, fmt.Errorf("bitmaps: %w", err)
+ }
+ }
+
+ // Populate bloom filters (seed 7)
+ if IsTypeSupported(version, TypeBloomFilter) {
+ r7 := NewSeededRandom(seed + 7)
+ var err error
+ data.BloomFilters, err = populateBloomFilters(ctx, client, r7)
+ if err != nil {
+ return nil, fmt.Errorf("bloom filters: %w", err)
+ }
+ }
+
+ // Populate JSON docs (seed 8)
+ if IsTypeSupported(version, TypeJSON) {
+ r8 := NewSeededRandom(seed + 8)
+ var err error
+ data.JSONs, err = populateJSONs(ctx, client, r8)
+ if err != nil {
+ return nil, fmt.Errorf("json: %w", err)
+ }
+ }
+
+ // Populate hyperloglogs (seed 9)
+ if IsTypeSupported(version, TypeHyperLogLog) {
+ r9 := NewSeededRandom(seed + 9)
+ var err error
+ data.HLLs, err = populateHLLs(ctx, client, r9)
+ if err != nil {
+ return nil, fmt.Errorf("hyperloglogs: %w", err)
+ }
+ }
+
+ // Populate tdigests (seed 10)
+ if IsTypeSupported(version, TypeTDigest) {
+ r10 := NewSeededRandom(seed + 10)
+ var err error
+ data.TDigests, err = populateTDigests(ctx, client, r10)
+ if err != nil {
+ return nil, fmt.Errorf("tdigests: %w", err)
+ }
+ }
+
+ // Populate time series (seed 11)
+ if IsTypeSupported(version, TypeTimeSeries) {
+ r11 := NewSeededRandom(seed + 11)
+ var err error
+ data.TimeSeries, err = populateTimeSeries(ctx, client, r11)
+ if err != nil {
+ return nil, fmt.Errorf("time series: %w", err)
+ }
+ }
+
+ return data, nil
+}
+
+// VerifyTestData verifies all test data is preserved
+func VerifyTestData(ctx context.Context, client *redis.Client, data *TestData) error {
+ seed := int64(12345)
+
+ if data.Strings != nil {
+ r := NewSeededRandom(seed)
+ if err := verifyStrings(ctx, client, data.Strings, r); err != nil {
+ return fmt.Errorf("strings: %w", err)
+ }
+ }
+
+ if data.Hashes != nil {
+ r := NewSeededRandom(seed + 1)
+ if err := verifyHashes(ctx, client, data.Hashes, r); err != nil {
+ return fmt.Errorf("hashes: %w", err)
+ }
+ }
+
+ if data.Lists != nil {
+ r := NewSeededRandom(seed + 2)
+ if err := verifyLists(ctx, client, data.Lists, r); err != nil {
+ return fmt.Errorf("lists: %w", err)
+ }
+ }
+
+ if data.Sets != nil {
+ r := NewSeededRandom(seed + 3)
+ if err := verifySets(ctx, client, data.Sets, r); err != nil {
+ return fmt.Errorf("sets: %w", err)
+ }
+ }
+
+ if data.ZSets != nil {
+ r := NewSeededRandom(seed + 4)
+ if err := verifyZSets(ctx, client, data.ZSets, r); err != nil {
+ return fmt.Errorf("zsets: %w", err)
+ }
+ }
+
+ if data.Streams != nil {
+ r := NewSeededRandom(seed + 5)
+ if err := verifyStreams(ctx, client, data.Streams, r); err != nil {
+ return fmt.Errorf("streams: %w", err)
+ }
+ }
+
+ if data.Bitmaps != nil {
+ r := NewSeededRandom(seed + 6)
+ if err := verifyBitmaps(ctx, client, data.Bitmaps, r); err != nil {
+ return fmt.Errorf("bitmaps: %w", err)
+ }
+ }
+
+ // Maps are always initialized; empty means the old version did not
+ // support the type, so there is nothing to verify.
+ if len(data.BloomFilters) > 0 {
+ r := NewSeededRandom(seed + 7)
+ if err := verifyBloomFilters(ctx, client, data.BloomFilters, r); err != nil {
+ return fmt.Errorf("bloom filters: %w", err)
+ }
+ }
+
+ if len(data.JSONs) > 0 {
+ r := NewSeededRandom(seed + 8)
+ if err := verifyJSONs(ctx, client, data.JSONs, r); err != nil {
+ return fmt.Errorf("json: %w", err)
+ }
+ }
+
+ if len(data.HLLs) > 0 {
+ r := NewSeededRandom(seed + 9)
+ if err := verifyHLLs(ctx, client, data.HLLs, r); err != nil {
+ return fmt.Errorf("hyperloglogs: %w", err)
+ }
+ }
+
+ if len(data.TDigests) > 0 {
+ r := NewSeededRandom(seed + 10)
+ if err := verifyTDigests(ctx, client, data.TDigests, r); err != nil {
+ return fmt.Errorf("tdigests: %w", err)
+ }
+ }
+
+ if len(data.TimeSeries) > 0 {
+ r := NewSeededRandom(seed + 11)
+ if err := verifyTimeSeries(ctx, client, data.TimeSeries, r); err != nil {
+ return fmt.Errorf("time series: %w", err)
+ }
+ }
+
+ return nil
+}
+
+// populateStrings creates random string keys and returns what was stored
+func populateStrings(ctx context.Context, client *redis.Client, r *SeededRandom) (map[string]string, error) {
+ result := make(map[string]string)
+
+ // Generate N random string keys
+ for i := 0; i < 10; i++ {
+ key := fmt.Sprintf("str:%d", i)
+ value := r.String(64) // 64 char random string
+ if err := client.Set(ctx, key, value, 0).Err(); err != nil {
+ return nil, fmt.Errorf("set %s: %w", key, err)
+ }
+ result[key] = value
+ }
+
+ return result, nil
+}
+
+// verifyStrings re-generates expected values and compares
+func verifyStrings(ctx context.Context, client *redis.Client, stored map[string]string, r *SeededRandom) error {
+ for i := 0; i < 10; i++ {
+ key := fmt.Sprintf("str:%d", i)
+ expected := r.String(64)
+ actual, err := client.Get(ctx, key).Result()
+ if err != nil {
+ return fmt.Errorf("get %s: %w", key, err)
+ }
+ if actual != expected {
+ return fmt.Errorf("key %s: expected %q, got %q", key, expected, actual)
+ }
+ }
+ return nil
+}
+
+// populateHashes creates random hash keys and returns what was stored
+func populateHashes(ctx context.Context, client *redis.Client, r *SeededRandom) (map[string]map[string]string, error) {
+ result := make(map[string]map[string]string)
+
+ for i := 0; i < 5; i++ {
+ key := fmt.Sprintf("hash:%d", i)
+ fields := make(map[string]string)
+ fieldCount := 3 + r.Int(5)
+
+ for j := 0; j < fieldCount; j++ {
+ field := fmt.Sprintf("f%d", j)
+ value := r.String(32)
+ fields[field] = value
+ }
+
+ // Convert to flat args for HSET
+ args := make([]interface{}, 0, len(fields)*2)
+ for k, v := range fields {
+ args = append(args, k, v)
+ }
+ if err := client.HSet(ctx, key, args...).Err(); err != nil {
+ return nil, fmt.Errorf("hset %s: %w", key, err)
+ }
+ result[key] = fields
+ }
+
+ return result, nil
+}
+
+// verifyHashes re-generates expected values and compares
+func verifyHashes(ctx context.Context, client *redis.Client, stored map[string]map[string]string, r *SeededRandom) error {
+ for i := 0; i < 5; i++ {
+ key := fmt.Sprintf("hash:%d", i)
+ fieldCount := 3 + r.Int(5)
+
+ // Re-generate expected fields
+ fields := make(map[string]string)
+ for j := 0; j < fieldCount; j++ {
+ field := fmt.Sprintf("f%d", j)
+ fields[field] = r.String(32)
+ }
+
+ // Compare against stored
+ for f, expVal := range fields {
+ actVal, err := client.HGet(ctx, key, f).Result()
+ if err != nil {
+ return fmt.Errorf("hget %s %s: %w", key, f, err)
+ }
+ if actVal != expVal {
+ return fmt.Errorf("hash %s field %s: expected %q, got %q", key, f, expVal, actVal)
+ }
+ }
+ }
+ return nil
+}
+
+// populateLists creates random list keys and returns what was stored
+func populateLists(ctx context.Context, client *redis.Client, r *SeededRandom) (map[string][]string, error) {
+ result := make(map[string][]string)
+
+ for i := 0; i < 5; i++ {
+ key := fmt.Sprintf("list:%d", i)
+ elemCount := 5 + r.Int(20)
+ elems := make([]string, elemCount)
+
+ for j := 0; j < elemCount; j++ {
+ elems[j] = r.String(32)
+ }
+
+ args := make([]interface{}, len(elems))
+ for j, e := range elems {
+ args[j] = e
+ }
+ if err := client.RPush(ctx, key, args...).Err(); err != nil {
+ return nil, fmt.Errorf("rpush %s: %w", key, err)
+ }
+ result[key] = elems
+ }
+
+ return result, nil
+}
+
+// verifyLists re-generates expected values and compares
+func verifyLists(ctx context.Context, client *redis.Client, stored map[string][]string, r *SeededRandom) error {
+ for i := 0; i < 5; i++ {
+ key := fmt.Sprintf("list:%d", i)
+ elemCount := 5 + r.Int(20)
+
+ actual, err := client.LRange(ctx, key, 0, -1).Result()
+ if err != nil {
+ return fmt.Errorf("lrange %s: %w", key, err)
+ }
+
+ for j := 0; j < elemCount; j++ {
+ expected := r.String(32)
+ if actual[j] != expected {
+ return fmt.Errorf("list %s[%d]: expected %q, got %q", key, j, expected, actual[j])
+ }
+ }
+ }
+ return nil
+}
+
+// populateSets creates random set keys and returns what was stored
+func populateSets(ctx context.Context, client *redis.Client, r *SeededRandom) (map[string][]string, error) {
+ result := make(map[string][]string)
+
+ for i := 0; i < 5; i++ {
+ key := fmt.Sprintf("set:%d", i)
+ memberCount := 10 + r.Int(30)
+ seen := make(map[string]bool)
+ members := make([]string, 0, memberCount)
+
+ for j := 0; j < memberCount; j++ {
+ member := r.String(32)
+ for seen[member] {
+ member = r.String(32)
+ }
+ seen[member] = true
+ members = append(members, member)
+ if err := client.SAdd(ctx, key, member).Err(); err != nil {
+ return nil, fmt.Errorf("sadd %s: %w", key, err)
+ }
+ }
+ result[key] = members
+ }
+
+ return result, nil
+}
+
+// verifySets re-generates expected values and compares (order-independent)
+func verifySets(ctx context.Context, client *redis.Client, stored map[string][]string, r *SeededRandom) error {
+ for i := 0; i < 5; i++ {
+ key := fmt.Sprintf("set:%d", i)
+ memberCount := 10 + r.Int(30)
+
+ actual, err := client.SMembers(ctx, key).Result()
+ if err != nil {
+ return fmt.Errorf("smembers %s: %w", key, err)
+ }
+
+ // Re-generate expected and check membership
+ seen := make(map[string]bool)
+ for j := 0; j < memberCount; j++ {
+ member := r.String(32)
+ for seen[member] {
+ member = r.String(32)
+ }
+ seen[member] = true
+ found := false
+ for _, a := range actual {
+ if a == member {
+ found = true
+ break
+ }
+ }
+ if !found {
+ return fmt.Errorf("set %s: missing member %q", key, member)
+ }
+ }
+ }
+ return nil
+}
+
+// populateZSets creates random sorted set keys and returns what was stored
+func populateZSets(ctx context.Context, client *redis.Client, r *SeededRandom) (map[string][]ZSetEntry, error) {
+ result := make(map[string][]ZSetEntry)
+
+ for i := 0; i < 5; i++ {
+ key := fmt.Sprintf("zset:%d", i)
+ entryCount := 10 + r.Int(30)
+ entries := make([]ZSetEntry, entryCount)
+
+ for j := 0; j < entryCount; j++ {
+ member := r.String(32)
+ score := r.Float64() * 1000
+ entries[j] = ZSetEntry{Score: score, Member: member}
+ if err := client.ZAdd(ctx, key, redis.Z{Score: score, Member: member}).Err(); err != nil {
+ return nil, fmt.Errorf("zadd %s: %w", key, err)
+ }
+ }
+ result[key] = entries
+ }
+
+ return result, nil
+}
+
+// verifyZSets re-generates expected values and compares
+func verifyZSets(ctx context.Context, client *redis.Client, stored map[string][]ZSetEntry, r *SeededRandom) error {
+ for i := 0; i < 5; i++ {
+ key := fmt.Sprintf("zset:%d", i)
+ entryCount := 10 + r.Int(30)
+
+ actual, err := client.ZRangeWithScores(ctx, key, 0, -1).Result()
+ if err != nil {
+ return fmt.Errorf("zrange %s: %w", key, err)
+ }
+
+ if len(actual) != entryCount {
+ return fmt.Errorf("zset %s: expected %d entries, got %d", key, entryCount, len(actual))
+ }
+
+ // Re-generate expected entries and build lookup by member
+ expected := make(map[string]float64)
+ for j := 0; j < entryCount; j++ {
+ member := r.String(32)
+ score := r.Float64() * 1000
+ expected[member] = score
+ }
+
+ // Verify all actual entries match expected
+ for _, z := range actual {
+ member, _ := z.Member.(string)
+ expScore, ok := expected[member]
+ if !ok {
+ return fmt.Errorf("zset %s: unexpected member %q", key, member)
+ }
+ if z.Score != expScore {
+ return fmt.Errorf("zset %s member %q: expected score %.2f, got %.2f",
+ key, member, expScore, z.Score)
+ }
+ }
+ }
+ return nil
+}
+
+// populateStreams creates random stream keys and returns what was stored
+func populateStreams(ctx context.Context, client *redis.Client, r *SeededRandom) (map[string][]StreamEntry, error) {
+ result := make(map[string][]StreamEntry)
+
+ for i := 0; i < 3; i++ {
+ key := fmt.Sprintf("stream:%d", i)
+ entryCount := 5 + r.Int(15)
+ entries := make([]StreamEntry, entryCount)
+
+ for j := 0; j < entryCount; j++ {
+ field := fmt.Sprintf("field%d", j)
+ value := r.String(32)
+ entries[j] = StreamEntry{Field: field, Value: value}
+
+ id, err := client.XAdd(ctx, &redis.XAddArgs{
+ Stream: key,
+ Values: map[string]interface{}{field: value},
+ }).Result()
+ if err != nil {
+ return nil, fmt.Errorf("xadd %s: %w", key, err)
+ }
+ entries[j].ID = id
+ }
+ result[key] = entries
+ }
+
+ return result, nil
+}
+
+// verifyStreams re-generates expected values and compares
+func verifyStreams(ctx context.Context, client *redis.Client, stored map[string][]StreamEntry, r *SeededRandom) error {
+ for i := 0; i < 3; i++ {
+ key := fmt.Sprintf("stream:%d", i)
+ entryCount := 5 + r.Int(15)
+
+ actual, err := client.XRange(ctx, key, "-", "+").Result()
+ if err != nil {
+ return fmt.Errorf("xrange %s: %w", key, err)
+ }
+
+ for j := 0; j < entryCount; j++ {
+ field := fmt.Sprintf("field%d", j)
+ expected := r.String(32)
+ if actual[j].Values[field] != expected {
+ return fmt.Errorf("stream %s[%d]: expected %s=%q, got %v",
+ key, j, field, expected, actual[j].Values)
+ }
+ }
Review Comment:
Stream IDs and cardinality are not verified even though the generated IDs are retained in `stored`. An ID-encoding regression or extra decoded entries would therefore pass as long as values remain in the same prefix; compare the full length and each returned ID as well as its field value.
##########
tests/gocase/integration/compatibility/testdata.go:
##########
@@ -0,0 +1,1104 @@
+//go:build compat
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package compatibility
+
+import (
+ "context"
+ "encoding/json"
+ "fmt"
+ "math"
+ "math/rand"
+ "strconv"
+ "strings"
+
+ "github.com/redis/go-redis/v9"
+)
+
+// SeededRandom provides deterministic random generation for reproducible tests
+type SeededRandom struct {
+ rng *rand.Rand
+}
+
+// NewSeededRandom creates a SeededRandom with the given seed
+func NewSeededRandom(seed int64) *SeededRandom {
+ return &SeededRandom{rng: rand.New(rand.NewSource(seed))}
+}
+
+// String generates a random alphanumeric string of the given length
+func (r *SeededRandom) String(length int) string {
+ const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
+ b := make([]byte, length)
+ for i := range b {
+ b[i] = charset[r.rng.Intn(len(charset))]
+ }
+ return string(b)
+}
+
+// Bytes generates random bytes of the given length
+func (r *SeededRandom) Bytes(length int) []byte {
+ b := make([]byte, length)
+ r.rng.Read(b)
+ return b
+}
+
+// Int63 returns a random int64 in range [0, upper)
+func (r *SeededRandom) Int63(upper int64) int64 {
+ return r.rng.Int63n(upper)
+}
+
+// Int returns a random int in range [0, upper)
+func (r *SeededRandom) Int(upper int) int {
+ return r.rng.Intn(upper)
+}
+
+// Float64 returns a random float64 in [0, 1)
+func (r *SeededRandom) Float64() float64 {
+ return r.rng.Float64()
+}
+
+// TestData contains all populated test data for verification
+type TestData struct {
+ Strings map[string]string
+ Hashes map[string]map[string]string
+ Lists map[string][]string
+ Sets map[string][]string
+ ZSets map[string][]ZSetEntry
+ Streams map[string][]StreamEntry
+ Bitmaps map[string][]byte
+ BloomFilters map[string][]string
+ JSONs map[string]string
+ HLLs map[string][]string
+ TDigests map[string][]float64
+ TimeSeries map[string][]TSSample
+}
+
+// TSSample represents a time series sample
+type TSSample struct {
+ Timestamp uint64
+ Value float64
+}
+
+// ZSetEntry represents a sorted set member
+type ZSetEntry struct {
+ Score float64
+ Member string
+}
+
+// StreamEntry represents a stream entry
+type StreamEntry struct {
+ ID string
+ Field string
+ Value string
+}
+
+// Data type identifiers
+const (
+ TypeString = "string"
+ TypeHash = "hash"
+ TypeList = "list"
+ TypeSet = "set"
+ TypeZSet = "zset"
+ TypeStream = "stream"
+ TypeBitmap = "bitmap"
+ TypeBloomFilter = "bloomfilter"
+ TypeJSON = "json"
+ TypeHyperLogLog = "hyperloglog"
+ TypeTDigest = "tdigest"
+ TypeTimeSeries = "timeseries"
+)
+
+// supportedTypesByVersion maps version strings to supported data types.
+// Verified against the command registration in each release tag (e.g.
+// bf.reserve in v2.6.0, json.set in v2.7.0, pfadd in v2.10.0,
+// tdigest.create in v2.14.0; timeseries exists in v2.14.0 source but its
+// REDIS_REGISTER_COMMANDS is commented out, so it is not listed there and
+// first appears in v2.15.0).
+var supportedTypesByVersion = map[string][]string{
+ "v2.3.0": {TypeString, TypeHash, TypeList, TypeSet, TypeZSet, TypeStream, TypeBitmap},
+ "v2.6.0": {TypeString, TypeHash, TypeList, TypeSet, TypeZSet, TypeStream, TypeBitmap, TypeBloomFilter},
+ "v2.7.0": {TypeString, TypeHash, TypeList, TypeSet, TypeZSet, TypeStream, TypeBitmap, TypeBloomFilter, TypeJSON},
+ "v2.10.0": {TypeString, TypeHash, TypeList, TypeSet, TypeZSet, TypeStream, TypeBitmap, TypeBloomFilter, TypeJSON, TypeHyperLogLog},
+ "v2.14.0": {TypeString, TypeHash, TypeList, TypeSet, TypeZSet, TypeStream, TypeBitmap, TypeBloomFilter, TypeJSON, TypeHyperLogLog, TypeTDigest},
+ "v2.15.0": {TypeString, TypeHash, TypeList, TypeSet, TypeZSet, TypeStream, TypeBitmap, TypeBloomFilter, TypeJSON, TypeHyperLogLog, TypeTDigest, TypeTimeSeries},
+}
+
+// IsTypeSupported checks if a data type is supported by the given version
+func IsTypeSupported(version string, dataType string) bool {
+ types, ok := supportedTypesByVersion[version]
+ if !ok {
+ return false
+ }
+ for _, t := range types {
+ if t == dataType {
+ return true
+ }
+ }
+ return false
+}
+
+// PopulateTestData populates all supported data types for the given version
+func PopulateTestData(ctx context.Context, client *redis.Client, version string) (*TestData, error) {
+ data := &TestData{
+ Strings: make(map[string]string),
+ Hashes: make(map[string]map[string]string),
+ Lists: make(map[string][]string),
+ Sets: make(map[string][]string),
+ ZSets: make(map[string][]ZSetEntry),
+ Streams: make(map[string][]StreamEntry),
+ Bitmaps: make(map[string][]byte),
+ BloomFilters: make(map[string][]string),
+ JSONs: make(map[string]string),
+ HLLs: make(map[string][]string),
+ TDigests: make(map[string][]float64),
+ TimeSeries: make(map[string][]TSSample),
+ }
+
+ // Use version-based seed for determinism
+ seed := int64(12345)
+ r := NewSeededRandom(seed)
+
+ // Populate strings (seed 0)
+ if IsTypeSupported(version, TypeString) {
+ var err error
+ data.Strings, err = populateStrings(ctx, client, r)
+ if err != nil {
+ return nil, fmt.Errorf("strings: %w", err)
+ }
+ }
+
+ // Populate hashes (seed 1)
+ if IsTypeSupported(version, TypeHash) {
+ r1 := NewSeededRandom(seed + 1)
+ var err error
+ data.Hashes, err = populateHashes(ctx, client, r1)
+ if err != nil {
+ return nil, fmt.Errorf("hashes: %w", err)
+ }
+ }
+
+ // Populate lists (seed 2)
+ if IsTypeSupported(version, TypeList) {
+ r2 := NewSeededRandom(seed + 2)
+ var err error
+ data.Lists, err = populateLists(ctx, client, r2)
+ if err != nil {
+ return nil, fmt.Errorf("lists: %w", err)
+ }
+ }
+
+ // Populate sets (seed 3)
+ if IsTypeSupported(version, TypeSet) {
+ r3 := NewSeededRandom(seed + 3)
+ var err error
+ data.Sets, err = populateSets(ctx, client, r3)
+ if err != nil {
+ return nil, fmt.Errorf("sets: %w", err)
+ }
+ }
+
+ // Populate zsets (seed 4)
+ if IsTypeSupported(version, TypeZSet) {
+ r4 := NewSeededRandom(seed + 4)
+ var err error
+ data.ZSets, err = populateZSets(ctx, client, r4)
+ if err != nil {
+ return nil, fmt.Errorf("zsets: %w", err)
+ }
+ }
+
+ // Populate streams (seed 5)
+ if IsTypeSupported(version, TypeStream) {
+ r5 := NewSeededRandom(seed + 5)
+ var err error
+ data.Streams, err = populateStreams(ctx, client, r5)
+ if err != nil {
+ return nil, fmt.Errorf("streams: %w", err)
+ }
+ }
+
+ // Populate bitmaps (seed 6)
+ if IsTypeSupported(version, TypeBitmap) {
+ r6 := NewSeededRandom(seed + 6)
+ var err error
+ data.Bitmaps, err = populateBitmaps(ctx, client, r6)
+ if err != nil {
+ return nil, fmt.Errorf("bitmaps: %w", err)
+ }
+ }
+
+ // Populate bloom filters (seed 7)
+ if IsTypeSupported(version, TypeBloomFilter) {
+ r7 := NewSeededRandom(seed + 7)
+ var err error
+ data.BloomFilters, err = populateBloomFilters(ctx, client, r7)
+ if err != nil {
+ return nil, fmt.Errorf("bloom filters: %w", err)
+ }
+ }
+
+ // Populate JSON docs (seed 8)
+ if IsTypeSupported(version, TypeJSON) {
+ r8 := NewSeededRandom(seed + 8)
+ var err error
+ data.JSONs, err = populateJSONs(ctx, client, r8)
+ if err != nil {
+ return nil, fmt.Errorf("json: %w", err)
+ }
+ }
+
+ // Populate hyperloglogs (seed 9)
+ if IsTypeSupported(version, TypeHyperLogLog) {
+ r9 := NewSeededRandom(seed + 9)
+ var err error
+ data.HLLs, err = populateHLLs(ctx, client, r9)
+ if err != nil {
+ return nil, fmt.Errorf("hyperloglogs: %w", err)
+ }
+ }
+
+ // Populate tdigests (seed 10)
+ if IsTypeSupported(version, TypeTDigest) {
+ r10 := NewSeededRandom(seed + 10)
+ var err error
+ data.TDigests, err = populateTDigests(ctx, client, r10)
+ if err != nil {
+ return nil, fmt.Errorf("tdigests: %w", err)
+ }
+ }
+
+ // Populate time series (seed 11)
+ if IsTypeSupported(version, TypeTimeSeries) {
+ r11 := NewSeededRandom(seed + 11)
+ var err error
+ data.TimeSeries, err = populateTimeSeries(ctx, client, r11)
+ if err != nil {
+ return nil, fmt.Errorf("time series: %w", err)
+ }
+ }
+
+ return data, nil
+}
+
+// VerifyTestData verifies all test data is preserved
+func VerifyTestData(ctx context.Context, client *redis.Client, data *TestData) error {
+ seed := int64(12345)
+
+ if data.Strings != nil {
+ r := NewSeededRandom(seed)
+ if err := verifyStrings(ctx, client, data.Strings, r); err != nil {
+ return fmt.Errorf("strings: %w", err)
+ }
+ }
+
+ if data.Hashes != nil {
+ r := NewSeededRandom(seed + 1)
+ if err := verifyHashes(ctx, client, data.Hashes, r); err != nil {
+ return fmt.Errorf("hashes: %w", err)
+ }
+ }
+
+ if data.Lists != nil {
+ r := NewSeededRandom(seed + 2)
+ if err := verifyLists(ctx, client, data.Lists, r); err != nil {
+ return fmt.Errorf("lists: %w", err)
+ }
+ }
+
+ if data.Sets != nil {
+ r := NewSeededRandom(seed + 3)
+ if err := verifySets(ctx, client, data.Sets, r); err != nil {
+ return fmt.Errorf("sets: %w", err)
+ }
+ }
+
+ if data.ZSets != nil {
+ r := NewSeededRandom(seed + 4)
+ if err := verifyZSets(ctx, client, data.ZSets, r); err != nil {
+ return fmt.Errorf("zsets: %w", err)
+ }
+ }
+
+ if data.Streams != nil {
+ r := NewSeededRandom(seed + 5)
+ if err := verifyStreams(ctx, client, data.Streams, r); err != nil {
+ return fmt.Errorf("streams: %w", err)
+ }
+ }
+
+ if data.Bitmaps != nil {
+ r := NewSeededRandom(seed + 6)
+ if err := verifyBitmaps(ctx, client, data.Bitmaps, r); err != nil {
+ return fmt.Errorf("bitmaps: %w", err)
+ }
+ }
+
+ // Maps are always initialized; empty means the old version did not
+ // support the type, so there is nothing to verify.
+ if len(data.BloomFilters) > 0 {
+ r := NewSeededRandom(seed + 7)
+ if err := verifyBloomFilters(ctx, client, data.BloomFilters, r); err != nil {
+ return fmt.Errorf("bloom filters: %w", err)
+ }
+ }
+
+ if len(data.JSONs) > 0 {
+ r := NewSeededRandom(seed + 8)
+ if err := verifyJSONs(ctx, client, data.JSONs, r); err != nil {
+ return fmt.Errorf("json: %w", err)
+ }
+ }
+
+ if len(data.HLLs) > 0 {
+ r := NewSeededRandom(seed + 9)
+ if err := verifyHLLs(ctx, client, data.HLLs, r); err != nil {
+ return fmt.Errorf("hyperloglogs: %w", err)
+ }
+ }
+
+ if len(data.TDigests) > 0 {
+ r := NewSeededRandom(seed + 10)
+ if err := verifyTDigests(ctx, client, data.TDigests, r); err != nil {
+ return fmt.Errorf("tdigests: %w", err)
+ }
+ }
+
+ if len(data.TimeSeries) > 0 {
+ r := NewSeededRandom(seed + 11)
+ if err := verifyTimeSeries(ctx, client, data.TimeSeries, r); err != nil {
+ return fmt.Errorf("time series: %w", err)
+ }
+ }
+
+ return nil
+}
+
+// populateStrings creates random string keys and returns what was stored
+func populateStrings(ctx context.Context, client *redis.Client, r *SeededRandom) (map[string]string, error) {
+ result := make(map[string]string)
+
+ // Generate N random string keys
+ for i := 0; i < 10; i++ {
+ key := fmt.Sprintf("str:%d", i)
+ value := r.String(64) // 64 char random string
+ if err := client.Set(ctx, key, value, 0).Err(); err != nil {
+ return nil, fmt.Errorf("set %s: %w", key, err)
+ }
+ result[key] = value
+ }
+
+ return result, nil
+}
+
+// verifyStrings re-generates expected values and compares
+func verifyStrings(ctx context.Context, client *redis.Client, stored map[string]string, r *SeededRandom) error {
+ for i := 0; i < 10; i++ {
+ key := fmt.Sprintf("str:%d", i)
+ expected := r.String(64)
+ actual, err := client.Get(ctx, key).Result()
+ if err != nil {
+ return fmt.Errorf("get %s: %w", key, err)
+ }
+ if actual != expected {
+ return fmt.Errorf("key %s: expected %q, got %q", key, expected, actual)
+ }
+ }
+ return nil
+}
+
+// populateHashes creates random hash keys and returns what was stored
+func populateHashes(ctx context.Context, client *redis.Client, r *SeededRandom) (map[string]map[string]string, error) {
+ result := make(map[string]map[string]string)
+
+ for i := 0; i < 5; i++ {
+ key := fmt.Sprintf("hash:%d", i)
+ fields := make(map[string]string)
+ fieldCount := 3 + r.Int(5)
+
+ for j := 0; j < fieldCount; j++ {
+ field := fmt.Sprintf("f%d", j)
+ value := r.String(32)
+ fields[field] = value
+ }
+
+ // Convert to flat args for HSET
+ args := make([]interface{}, 0, len(fields)*2)
+ for k, v := range fields {
+ args = append(args, k, v)
+ }
+ if err := client.HSet(ctx, key, args...).Err(); err != nil {
+ return nil, fmt.Errorf("hset %s: %w", key, err)
+ }
+ result[key] = fields
+ }
+
+ return result, nil
+}
+
+// verifyHashes re-generates expected values and compares
+func verifyHashes(ctx context.Context, client *redis.Client, stored map[string]map[string]string, r *SeededRandom) error {
+ for i := 0; i < 5; i++ {
+ key := fmt.Sprintf("hash:%d", i)
+ fieldCount := 3 + r.Int(5)
+
+ // Re-generate expected fields
+ fields := make(map[string]string)
+ for j := 0; j < fieldCount; j++ {
+ field := fmt.Sprintf("f%d", j)
+ fields[field] = r.String(32)
+ }
+
+ // Compare against stored
+ for f, expVal := range fields {
+ actVal, err := client.HGet(ctx, key, f).Result()
+ if err != nil {
+ return fmt.Errorf("hget %s %s: %w", key, f, err)
+ }
+ if actVal != expVal {
+ return fmt.Errorf("hash %s field %s: expected %q, got %q", key, f, expVal, actVal)
+ }
+ }
+ }
+ return nil
+}
+
+// populateLists creates random list keys and returns what was stored
+func populateLists(ctx context.Context, client *redis.Client, r *SeededRandom) (map[string][]string, error) {
+ result := make(map[string][]string)
+
+ for i := 0; i < 5; i++ {
+ key := fmt.Sprintf("list:%d", i)
+ elemCount := 5 + r.Int(20)
+ elems := make([]string, elemCount)
+
+ for j := 0; j < elemCount; j++ {
+ elems[j] = r.String(32)
+ }
+
+ args := make([]interface{}, len(elems))
+ for j, e := range elems {
+ args[j] = e
+ }
+ if err := client.RPush(ctx, key, args...).Err(); err != nil {
+ return nil, fmt.Errorf("rpush %s: %w", key, err)
+ }
+ result[key] = elems
+ }
+
+ return result, nil
+}
+
+// verifyLists re-generates expected values and compares
+func verifyLists(ctx context.Context, client *redis.Client, stored map[string][]string, r *SeededRandom) error {
+ for i := 0; i < 5; i++ {
+ key := fmt.Sprintf("list:%d", i)
+ elemCount := 5 + r.Int(20)
+
+ actual, err := client.LRange(ctx, key, 0, -1).Result()
+ if err != nil {
+ return fmt.Errorf("lrange %s: %w", key, err)
+ }
+
+ for j := 0; j < elemCount; j++ {
+ expected := r.String(32)
+ if actual[j] != expected {
+ return fmt.Errorf("list %s[%d]: expected %q, got %q", key, j, expected, actual[j])
+ }
+ }
+ }
+ return nil
+}
+
+// populateSets creates random set keys and returns what was stored
+func populateSets(ctx context.Context, client *redis.Client, r *SeededRandom) (map[string][]string, error) {
+ result := make(map[string][]string)
+
+ for i := 0; i < 5; i++ {
+ key := fmt.Sprintf("set:%d", i)
+ memberCount := 10 + r.Int(30)
+ seen := make(map[string]bool)
+ members := make([]string, 0, memberCount)
+
+ for j := 0; j < memberCount; j++ {
+ member := r.String(32)
+ for seen[member] {
+ member = r.String(32)
+ }
+ seen[member] = true
+ members = append(members, member)
+ if err := client.SAdd(ctx, key, member).Err(); err != nil {
+ return nil, fmt.Errorf("sadd %s: %w", key, err)
+ }
+ }
+ result[key] = members
+ }
+
+ return result, nil
+}
+
+// verifySets re-generates expected values and compares (order-independent)
+func verifySets(ctx context.Context, client *redis.Client, stored map[string][]string, r *SeededRandom) error {
+ for i := 0; i < 5; i++ {
+ key := fmt.Sprintf("set:%d", i)
+ memberCount := 10 + r.Int(30)
+
+ actual, err := client.SMembers(ctx, key).Result()
+ if err != nil {
+ return fmt.Errorf("smembers %s: %w", key, err)
+ }
+
+ // Re-generate expected and check membership
+ seen := make(map[string]bool)
+ for j := 0; j < memberCount; j++ {
+ member := r.String(32)
+ for seen[member] {
+ member = r.String(32)
+ }
+ seen[member] = true
+ found := false
+ for _, a := range actual {
+ if a == member {
+ found = true
+ break
+ }
+ }
+ if !found {
+ return fmt.Errorf("set %s: missing member %q", key, member)
+ }
+ }
+ }
+ return nil
+}
+
+// populateZSets creates random sorted set keys and returns what was stored
+func populateZSets(ctx context.Context, client *redis.Client, r *SeededRandom) (map[string][]ZSetEntry, error) {
+ result := make(map[string][]ZSetEntry)
+
+ for i := 0; i < 5; i++ {
+ key := fmt.Sprintf("zset:%d", i)
+ entryCount := 10 + r.Int(30)
+ entries := make([]ZSetEntry, entryCount)
+
+ for j := 0; j < entryCount; j++ {
+ member := r.String(32)
+ score := r.Float64() * 1000
+ entries[j] = ZSetEntry{Score: score, Member: member}
+ if err := client.ZAdd(ctx, key, redis.Z{Score: score, Member: member}).Err(); err != nil {
+ return nil, fmt.Errorf("zadd %s: %w", key, err)
+ }
+ }
+ result[key] = entries
+ }
+
+ return result, nil
+}
+
+// verifyZSets re-generates expected values and compares
+func verifyZSets(ctx context.Context, client *redis.Client, stored map[string][]ZSetEntry, r *SeededRandom) error {
+ for i := 0; i < 5; i++ {
+ key := fmt.Sprintf("zset:%d", i)
+ entryCount := 10 + r.Int(30)
+
+ actual, err := client.ZRangeWithScores(ctx, key, 0, -1).Result()
+ if err != nil {
+ return fmt.Errorf("zrange %s: %w", key, err)
+ }
+
+ if len(actual) != entryCount {
+ return fmt.Errorf("zset %s: expected %d entries, got %d", key, entryCount, len(actual))
+ }
+
+ // Re-generate expected entries and build lookup by member
+ expected := make(map[string]float64)
+ for j := 0; j < entryCount; j++ {
+ member := r.String(32)
+ score := r.Float64() * 1000
+ expected[member] = score
+ }
+
+ // Verify all actual entries match expected
+ for _, z := range actual {
+ member, _ := z.Member.(string)
+ expScore, ok := expected[member]
+ if !ok {
+ return fmt.Errorf("zset %s: unexpected member %q", key, member)
+ }
+ if z.Score != expScore {
+ return fmt.Errorf("zset %s member %q: expected score %.2f, got %.2f",
+ key, member, expScore, z.Score)
+ }
+ }
+ }
+ return nil
+}
+
+// populateStreams creates random stream keys and returns what was stored
+func populateStreams(ctx context.Context, client *redis.Client, r *SeededRandom) (map[string][]StreamEntry, error) {
+ result := make(map[string][]StreamEntry)
+
+ for i := 0; i < 3; i++ {
+ key := fmt.Sprintf("stream:%d", i)
+ entryCount := 5 + r.Int(15)
+ entries := make([]StreamEntry, entryCount)
+
+ for j := 0; j < entryCount; j++ {
+ field := fmt.Sprintf("field%d", j)
+ value := r.String(32)
+ entries[j] = StreamEntry{Field: field, Value: value}
+
+ id, err := client.XAdd(ctx, &redis.XAddArgs{
+ Stream: key,
+ Values: map[string]interface{}{field: value},
+ }).Result()
+ if err != nil {
+ return nil, fmt.Errorf("xadd %s: %w", key, err)
+ }
+ entries[j].ID = id
+ }
+ result[key] = entries
+ }
+
+ return result, nil
+}
+
+// verifyStreams re-generates expected values and compares
+func verifyStreams(ctx context.Context, client *redis.Client, stored map[string][]StreamEntry, r *SeededRandom) error {
+ for i := 0; i < 3; i++ {
+ key := fmt.Sprintf("stream:%d", i)
+ entryCount := 5 + r.Int(15)
+
+ actual, err := client.XRange(ctx, key, "-", "+").Result()
+ if err != nil {
+ return fmt.Errorf("xrange %s: %w", key, err)
+ }
+
+ for j := 0; j < entryCount; j++ {
+ field := fmt.Sprintf("field%d", j)
+ expected := r.String(32)
+ if actual[j].Values[field] != expected {
+ return fmt.Errorf("stream %s[%d]: expected %s=%q, got %v",
+ key, j, field, expected, actual[j].Values)
+ }
+ }
+ }
+ return nil
+}
+
+// populateBitmaps creates random bitmap keys and returns what was stored
+func populateBitmaps(ctx context.Context, client *redis.Client, r *SeededRandom) (map[string][]byte, error) {
+ result := make(map[string][]byte)
+
+ for i := 0; i < 5; i++ {
+ key := fmt.Sprintf("bitmap:%d", i)
+ size := 64 + r.Int(256) // 64-320 bytes
+ bytes := r.Bytes(size)
+ if err := client.Set(ctx, key, string(bytes), 0).Err(); err != nil {
+ return nil, fmt.Errorf("set %s: %w", key, err)
+ }
Review Comment:
This creates an ordinary `kRedisString`, not Kvrocks' segmented `kRedisBitmap`, so the advertised bitmap row never exercises bitmap on-disk compatibility. Populate a missing key through `SETBIT` (the established bitmap-test pattern) and continue verifying the reconstructed bytes with `GET`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test: Add compatibility tests across versions of `kvrocks` [kvrocks]
Posted by "PragmaTwice (via GitHub)" <gi...@apache.org>.
PragmaTwice commented on code in PR #3610:
URL: https://github.com/apache/kvrocks/pull/3610#discussion_r4037077937
##########
.github/workflows/compatibility.yml:
##########
@@ -0,0 +1,112 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: Compatibility Tests
+
+on:
+ push:
+ branches: [unstable]
+ pull_request:
+ paths:
+ - '.github/workflows/compatibility.yml'
+ - 'src/storage/**'
+ - 'src/types/**'
+ - 'src/commands/**'
+ - 'src/config/**'
+ - 'tests/gocase/**'
Review Comment:
```suggestion
- 'src/**'
- 'tests/**'
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test: Add compatibility tests across versions of `kvrocks` [kvrocks]
Posted by "yatriks (via GitHub)" <gi...@apache.org>.
yatriks commented on PR #3610:
URL: https://github.com/apache/kvrocks/pull/3610#issuecomment-5706226830
@PragmaTwice fixed 🙏
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test: Add compatibility tests across versions of `kvrocks` [kvrocks]
Posted by "PragmaTwice (via GitHub)" <gi...@apache.org>.
PragmaTwice merged PR #3610:
URL: https://github.com/apache/kvrocks/pull/3610
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test: Add compatibility tests across versions of `kvrocks` [kvrocks]
Posted by "PragmaTwice (via GitHub)" <gi...@apache.org>.
PragmaTwice commented on code in PR #3610:
URL: https://github.com/apache/kvrocks/pull/3610#discussion_r4037074265
##########
.github/workflows/compatibility.yml:
##########
@@ -0,0 +1,112 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: Compatibility Tests
+
+on:
+ push:
+ branches: [unstable]
+ pull_request:
+ paths:
+ - '.github/workflows/compatibility.yml'
+ - 'src/storage/**'
+ - 'src/types/**'
+ - 'src/commands/**'
+ - 'src/config/**'
+ - 'tests/gocase/**'
+ release:
+ types: [published]
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.number || github.run_id }}
+ cancel-in-progress: true
+
+jobs:
+ build:
+ name: Build current kvrocks image
+ runs-on: ubuntu-22.04
+ steps:
+ - uses: actions/checkout@v6
+
+ # The old-version images are pulled from Docker Hub by the test; only
+ # the "new" side is built here, once, and handed to the parallel test
+ # jobs. Uses the same buildx method as the nightly image build; push
+ # defaults to false, so the image stays local.
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd
Review Comment:
```suggestion
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org