1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-29 17:41:15 +03:00

feat: Enable CI for Redis CE 8.0 (#3274)

* chore: extract benchmark tests

* wip

* enable pubsub tests

* enable ring tests

* stop tests with build redis from source

* start all tests

* mix of makefile and action

* add sentinel configs

* fix example test

* stop debug on re

* wip

* enable gears for redis 7.2

* wip

* enable sentinel, they are expected to fail

* fix: linter configuration

* chore: update re versions

* return older redis enterprise version

* add basic codeql

* wip: increase timeout, focus only sentinel tests

* sentinels with docker network host

* enable all tests

* fix flanky test

* enable example tests

* tidy docker compose

* add debug output

* stop shutingdown masters

* don't test sentinel for re

* skip unsuported addscores

* Update README

bump go version in CI

* Update README.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update CONTRIBUTING.md

add information about new test setup

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Nedyalko Dyakov
2025-02-28 12:49:00 +02:00
committed by GitHub
parent 5314a57132
commit ebe11d06ca
60 changed files with 671 additions and 561 deletions

View File

@ -21,6 +21,8 @@ func ExampleClient_bloom() {
})
// REMOVE_START
// make sure we are working with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bikes:models")
// REMOVE_END

View File

@ -21,6 +21,8 @@ func ExampleClient_bf() {
})
// REMOVE_START
// make sure we are working with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bike:1:stats")
// REMOVE_END

View File

@ -21,6 +21,8 @@ func ExampleClient_ping() {
})
// REMOVE_START
// make sure we are working with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "pings:2024-01-01-00:00")
// REMOVE_END
@ -66,6 +68,8 @@ func ExampleClient_bitcount() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
_, err := rdb.SetBit(ctx, "pings:2024-01-01-00:00", 123, 1).Result()
if err != nil {

View File

@ -23,6 +23,8 @@ func ExampleClient_del_cmd() {
})
// REMOVE_START
// make sure we are working with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "key1", "key2", "key3")
// REMOVE_END
@ -68,6 +70,8 @@ func ExampleClient_expire_cmd() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "mykey")
// REMOVE_END
@ -167,6 +171,8 @@ func ExampleClient_ttl_cmd() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "mykey")
// REMOVE_END

View File

@ -22,6 +22,8 @@ func ExampleClient_hset() {
})
// REMOVE_START
// make sure we are working with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "myhash")
// REMOVE_END
@ -112,6 +114,8 @@ func ExampleClient_hget() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "myhash")
// REMOVE_END
@ -157,6 +161,8 @@ func ExampleClient_hgetall() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "myhash")
// REMOVE_END
@ -209,6 +215,8 @@ func ExampleClient_hvals() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "myhash")
// REMOVE_END

View File

@ -22,6 +22,8 @@ func ExampleClient_cmd_flushall() {
// STEP_START flushall
// REMOVE_START
// make sure we are working with fresh database
rdb.FlushDB(ctx)
rdb.Set(ctx, "testkey1", "1", 0)
rdb.Set(ctx, "testkey2", "2", 0)
rdb.Set(ctx, "testkey3", "3", 0)

View File

@ -21,6 +21,8 @@ func ExampleClient_zadd_cmd() {
})
// REMOVE_START
// make sure we are working with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "myzset")
// REMOVE_END
@ -82,6 +84,8 @@ func ExampleClient_zrange1() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "myzset")
// REMOVE_END
@ -140,6 +144,8 @@ func ExampleClient_zrange2() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "myzset")
// REMOVE_END
@ -180,6 +186,8 @@ func ExampleClient_zrange3() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "myzset")
// REMOVE_END

View File

@ -21,6 +21,8 @@ func ExampleClient_cmd_incr() {
})
// REMOVE_START
// make sure we are working with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "mykey")
// REMOVE_END

View File

@ -21,6 +21,8 @@ func ExampleClient_cms() {
})
// REMOVE_START
// make sure we are working with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bikes:profit")
// REMOVE_END

View File

@ -21,6 +21,8 @@ func ExampleClient_cuckoo() {
})
// REMOVE_START
// make sure we are working with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bikes:models")
// REMOVE_END

View File

@ -20,7 +20,10 @@ func ExampleClient_geoindex() {
DB: 0, // use default DB
Protocol: 2,
})
// REMOVE_START
// make sure we are working with fresh database
rdb.FlushDB(ctx)
rdb.FTDropIndex(ctx, "productidx")
rdb.FTDropIndex(ctx, "geomidx")
rdb.Del(ctx, "product:46885", "product:46886", "shape:1", "shape:2", "shape:3", "shape:4")

View File

@ -21,6 +21,8 @@ func ExampleClient_geoadd() {
})
// REMOVE_START
// make sure we are working with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bikes:rentable")
// REMOVE_END
@ -81,6 +83,8 @@ func ExampleClient_geosearch() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bikes:rentable")
_, err := rdb.GeoAdd(ctx, "bikes:rentable",

View File

@ -21,6 +21,8 @@ func ExampleClient_set_get_all() {
})
// REMOVE_START
// make sure we are working with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bike:1")
// REMOVE_END
@ -102,6 +104,8 @@ func ExampleClient_hmget() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bike:1")
// REMOVE_END
@ -160,6 +164,8 @@ func ExampleClient_hincrby() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bike:1")
// REMOVE_END
@ -209,6 +215,8 @@ func ExampleClient_incrby_get_mget() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bike:1:stats")
// REMOVE_END

View File

@ -21,6 +21,8 @@ func ExampleClient_pfadd() {
})
// REMOVE_START
// make sure we are working with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bikes", "commuter_bikes", "all_bikes")
// REMOVE_END

View File

@ -26,6 +26,8 @@ func ExampleClient_search_json() {
})
// STEP_END
// REMOVE_START
// make sure we are working with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "user:1", "user:2", "user:3")
rdb.FTDropIndex(ctx, "idx:users")
// REMOVE_END

View File

@ -20,6 +20,8 @@ func ExampleClient_setget() {
})
// REMOVE_START
// make sure we are working with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bike")
// REMOVE_END
@ -67,6 +69,8 @@ func ExampleClient_str() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bike")
// REMOVE_END
@ -120,6 +124,8 @@ func ExampleClient_num() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "crashes")
// REMOVE_END
@ -174,6 +180,8 @@ func ExampleClient_arr() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "newbike")
// REMOVE_END

View File

@ -21,6 +21,8 @@ func ExampleClient_queue() {
})
// REMOVE_START
// make sure we are working with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bikes:repairs")
// REMOVE_END
@ -75,6 +77,8 @@ func ExampleClient_stack() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bikes:repairs")
// REMOVE_END
@ -129,6 +133,8 @@ func ExampleClient_llen() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bikes:repairs")
// REMOVE_END
@ -156,6 +162,8 @@ func ExampleClient_lmove_lrange() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bikes:repairs")
rdb.Del(ctx, "bikes:finished")
// REMOVE_END
@ -220,6 +228,8 @@ func ExampleClient_lpush_rpush() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bikes:repairs")
// REMOVE_END
@ -274,6 +284,8 @@ func ExampleClient_variadic() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bikes:repairs")
// REMOVE_END
@ -319,6 +331,8 @@ func ExampleClient_lpop_rpop() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bikes:repairs")
// REMOVE_END
@ -384,6 +398,8 @@ func ExampleClient_ltrim() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bikes:repairs")
// REMOVE_END
@ -429,6 +445,8 @@ func ExampleClient_ltrim_end_of_list() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bikes:repairs")
// REMOVE_END
@ -474,6 +492,8 @@ func ExampleClient_brpop() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bikes:repairs")
// REMOVE_END
@ -529,6 +549,8 @@ func ExampleClient_rule1() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "new_bikes")
// REMOVE_END

View File

@ -20,6 +20,8 @@ func ExampleClient_transactions() {
DB: 0, // use default DB
})
// REMOVE_START
// make sure we are working with fresh database
rdb.FlushDB(ctx)
for i := 0; i < 5; i++ {
rdb.Del(ctx, fmt.Sprintf("seat:%d", i))
}

View File

@ -21,6 +21,8 @@ func ExampleClient_query_agg() {
})
// HIDE_END
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.FTDropIndex(ctx, "idx:bicycle")
rdb.FTDropIndex(ctx, "idx:email")
// REMOVE_END

View File

@ -5,6 +5,8 @@ package example_commands_test
import (
"context"
"fmt"
"slices"
"strings"
"github.com/redis/go-redis/v9"
)
@ -21,6 +23,8 @@ func ExampleClient_query_em() {
// HIDE_END
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.FTDropIndex(ctx, "idx:bicycle")
rdb.FTDropIndex(ctx, "idx:email")
// REMOVE_END
@ -274,11 +278,16 @@ func ExampleClient_query_em() {
fmt.Println(res3.Total) // >>> 5
for _, doc := range res3.Docs {
docs := res3.Docs
slices.SortFunc(docs, func(a, b redis.Document) int {
return strings.Compare(a.ID, b.ID)
})
for _, doc := range docs {
fmt.Println(doc.ID)
}
// >>> bicycle:5
// >>> bicycle:0
// >>> bicycle:5
// >>> bicycle:6
// >>> bicycle:7
// >>> bicycle:8
@ -350,8 +359,8 @@ func ExampleClient_query_em() {
// 1
// bicycle:0
// 5
// bicycle:5
// bicycle:0
// bicycle:5
// bicycle:6
// bicycle:7
// bicycle:8

View File

@ -21,6 +21,8 @@ func ExampleClient_query_ft() {
})
// HIDE_END
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.FTDropIndex(ctx, "idx:bicycle")
rdb.FTDropIndex(ctx, "idx:email")
// REMOVE_END

View File

@ -21,6 +21,8 @@ func ExampleClient_query_geo() {
})
// HIDE_END
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.FTDropIndex(ctx, "idx:bicycle")
// REMOVE_END

View File

@ -21,6 +21,8 @@ func ExampleClient_Set_and_get() {
// HIDE_END
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
errFlush := rdb.FlushDB(ctx).Err() // Clear the database before each test
if errFlush != nil {
panic(errFlush)

View File

@ -21,6 +21,8 @@ func ExampleClient_sadd() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bikes:racing:france")
rdb.Del(ctx, "bikes:racing:usa")
// REMOVE_END
@ -76,6 +78,8 @@ func ExampleClient_sismember() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bikes:racing:france")
rdb.Del(ctx, "bikes:racing:usa")
// REMOVE_END
@ -125,6 +129,8 @@ func ExampleClient_sinter() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bikes:racing:france")
rdb.Del(ctx, "bikes:racing:usa")
// REMOVE_END
@ -165,6 +171,8 @@ func ExampleClient_scard() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bikes:racing:france")
// REMOVE_END
@ -198,6 +206,8 @@ func ExampleClient_saddsmembers() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bikes:racing:france")
// REMOVE_END
@ -216,7 +226,7 @@ func ExampleClient_saddsmembers() {
panic(err)
}
// Sort the strings in the slice to make sure the output is lexicographical
// Sort the strings in the slice to make sure the output is lexicographical
sort.Strings(res10)
fmt.Println(res10) // >>> [bike:1 bike:2 bike:3]
@ -237,6 +247,8 @@ func ExampleClient_smismember() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bikes:racing:france")
// REMOVE_END
@ -279,6 +291,8 @@ func ExampleClient_sdiff() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bikes:racing:france")
rdb.Del(ctx, "bikes:racing:usa")
// REMOVE_END
@ -298,8 +312,7 @@ func ExampleClient_sdiff() {
panic(err)
}
// Sort the strings in the slice to make sure the output is lexicographical
// Sort the strings in the slice to make sure the output is lexicographical
sort.Strings(res13)
fmt.Println(res13) // >>> [bike:2 bike:3]
@ -319,6 +332,8 @@ func ExampleClient_multisets() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bikes:racing:france")
rdb.Del(ctx, "bikes:racing:usa")
rdb.Del(ctx, "bikes:racing:italy")
@ -357,7 +372,7 @@ func ExampleClient_multisets() {
panic(err)
}
// Sort the strings in the slice to make sure the output is lexicographical
// Sort the strings in the slice to make sure the output is lexicographical
sort.Strings(res15)
fmt.Println(res15) // >>> [bike:1 bike:2 bike:3 bike:4]
@ -384,7 +399,7 @@ func ExampleClient_multisets() {
panic(err)
}
// Sort the strings in the slice to make sure the output is lexicographical
// Sort the strings in the slice to make sure the output is lexicographical
sort.Strings(res18)
fmt.Println(res18) // >>> [bike:2 bike:3]
@ -408,6 +423,8 @@ func ExampleClient_srem() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bikes:racing:france")
// REMOVE_END

View File

@ -20,6 +20,8 @@ func ExampleClient_zadd() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "racer_scores")
// REMOVE_END
@ -76,6 +78,8 @@ func ExampleClient_zrange() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "racer_scores")
// REMOVE_END
@ -127,6 +131,8 @@ func ExampleClient_zrangewithscores() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "racer_scores")
// REMOVE_END
@ -168,6 +174,8 @@ func ExampleClient_zrangebyscore() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "racer_scores")
// REMOVE_END
@ -211,6 +219,8 @@ func ExampleClient_zremrangebyscore() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "racer_scores")
// REMOVE_END
@ -270,6 +280,8 @@ func ExampleClient_zrank() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "racer_scores")
// REMOVE_END
@ -316,6 +328,8 @@ func ExampleClient_zaddlex() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "racer_scores")
// REMOVE_END
@ -377,6 +391,8 @@ func ExampleClient_leaderboard() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "racer_scores")
// REMOVE_END

View File

@ -26,6 +26,8 @@ func ExampleClient_xadd() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "race:france")
// REMOVE_END
@ -105,6 +107,8 @@ func ExampleClient_racefrance1() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "race:france")
// REMOVE_END
@ -227,6 +231,8 @@ func ExampleClient_raceusa() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "race:usa")
// REMOVE_END
@ -310,6 +316,8 @@ func ExampleClient_racefrance2() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "race:france")
// REMOVE_END
@ -478,6 +486,8 @@ func ExampleClient_xgroupcreate() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "race:france")
// REMOVE_END
@ -520,6 +530,8 @@ func ExampleClient_xgroupcreatemkstream() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "race:italy")
// REMOVE_END
@ -549,6 +561,8 @@ func ExampleClient_xgroupread() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "race:italy")
// REMOVE_END
@ -654,6 +668,8 @@ func ExampleClient_raceitaly() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "race:italy")
rdb.XGroupDestroy(ctx, "race:italy", "italy_riders")
// REMOVE_END
@ -1011,6 +1027,8 @@ func ExampleClient_xdel() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "race:italy")
// REMOVE_END

View File

@ -20,6 +20,8 @@ func ExampleClient_set_get() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bike:1")
// REMOVE_END
@ -56,6 +58,8 @@ func ExampleClient_setnx_xx() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Set(ctx, "bike:1", "Deimos", 0)
// REMOVE_END
@ -101,6 +105,8 @@ func ExampleClient_mset() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bike:1", "bike:2", "bike:3")
// REMOVE_END
@ -137,6 +143,8 @@ func ExampleClient_incr() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "total_crashes")
// REMOVE_END

View File

@ -21,6 +21,8 @@ func ExampleClient_tdigstart() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "racer_ages", "bikes:sales")
// REMOVE_END
@ -69,6 +71,8 @@ func ExampleClient_tdigcdf() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "racer_ages", "bikes:sales")
// REMOVE_END
@ -126,6 +130,8 @@ func ExampleClient_tdigquant() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "racer_ages")
// REMOVE_END
@ -177,6 +183,8 @@ func ExampleClient_tdigmin() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "racer_ages")
// REMOVE_END
@ -228,6 +236,8 @@ func ExampleClient_tdigreset() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "racer_ages")
// REMOVE_END
_, err := rdb.TDigestCreate(ctx, "racer_ages").Result()

View File

@ -21,6 +21,8 @@ func ExampleClient_topk() {
})
// REMOVE_START
// start with fresh database
rdb.FlushDB(ctx)
rdb.Del(ctx, "bikes:keywords")
// REMOVE_END