Skip to content

Commit 62b0260

Browse files
committed
add redis major version
1 parent 8cc7a8b commit 62b0260

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

.github/actions/run-tests/action.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ runs:
3636
)
3737
3838
if [[ -v redis_version_mapping[$REDIS_VERSION] ]]; then
39+
echo "REDIS_MAJOR_VERSION=${redis_major_version}" >> $GITHUB_ENV
3940
echo "REDIS_IMAGE=redis:${{ inputs.redis-version }}" >> $GITHUB_ENV
4041
echo "CLIENT_LIBS_TEST_IMAGE=redislabs/client-libs-test:${redis_version_mapping[$REDIS_VERSION]}" >> $GITHUB_ENV
4142
else
@@ -52,8 +53,6 @@ runs:
5253
RCE_DOCKER: "true"
5354
RE_CLUSTER: "false"
5455
run: |
55-
set -e
56-
redis_major_version=$(echo "$REDIS_VERSION" | grep -oP '^\d+')
5756
go test \
5857
--ginkgo.skip-file="ring_test.go" \
5958
--ginkgo.skip-file="sentinel_test.go" \

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
GO_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {} \; | sort)
2-
REDIS_VERSION="7.4.2"
2+
REDIS_MAJOR="7.4.2"
3+
export REDIS_MAJOR_VERSION := 7
34

45
test: testdeps
56
$(eval R_MAJOR := $(shell echo "$(REDIS_VERSION)" | grep -o '\d' | head -1))
6-
echo "Executing test agains redis-stack-server:latest and redis $(REDIS_VERSION), $(R_MAJOR) "
77
docker start go-redis-redis-stack || docker run -d --name go-redis-redis-stack -p 6379:6379 -e REDIS_ARGS="--enable-debug-command yes --enable-module-command yes" redis/redis-stack-server:latest
88
$(eval GO_VERSION := $(shell go version | cut -d " " -f 3 | cut -d. -f2))
99
set -e; for dir in $(GO_MOD_DIRS); do \
@@ -14,7 +14,7 @@ test: testdeps
1414
echo "go test in $${dir}"; \
1515
(cd "$${dir}" && \
1616
go mod tidy -compat=1.18 && \
17-
go test --ginkgo.label-filter="RedisVersion: isSubsetOf \"$(R_MAJOR)\""&& \
17+
go test && \
1818
go test ./... -short -race && \
1919
go test ./... -run=NONE -bench=. -benchmem && \
2020
env GOOS=linux GOARCH=386 go test && \

main_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ var RECluster = false
7070
// Redis Community Edition Docker
7171
var RCEDocker = false
7272

73+
// Notes the major version of redis we are executing tests.
74+
// This can be used before we change the bsm fork of ginkgo for one,
75+
// which have support for label sets, so we can filter tests per redis major version.
76+
var REDIS_MAJOR_VERSION = 7
77+
7378
func registerProcess(port string, p *redisProcess) {
7479
if processes == nil {
7580
processes = make(map[string]*redisProcess)
@@ -86,7 +91,13 @@ var _ = BeforeSuite(func() {
8691
var err error
8792
RECluster, _ = strconv.ParseBool(os.Getenv("RE_CLUSTER"))
8893
RCEDocker, _ = strconv.ParseBool(os.Getenv("RCE_DOCKER"))
94+
95+
REDIS_MAJOR_VERSION, _ = strconv.Atoi(os.Getenv("REDIS_MAJOR_VERSION"))
96+
Expect(REDIS_MAJOR_VERSION).To(BeNumerically(">=", 6))
97+
Expect(REDIS_MAJOR_VERSION).To(BeNumerically("<=", 8))
98+
8999
fmt.Printf("RECluster: %v\n", RECluster)
100+
fmt.Printf("REDIS_MAJOR_VERSION: %v\n", REDIS_MAJOR_VERSION)
90101
fmt.Printf("RCEDocker: %v\n", RCEDocker)
91102
if !RECluster && !RCEDocker {
92103

search_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,10 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() {
372372
})
373373

374374
// in redis 8, the default scorer is changed BM25
375-
It("should FTSearch WithScores", Label("search", "ftsearch", "RedisVersion:v8"), func() {
375+
It("should FTSearch WithScores", Label("search", "ftsearch"), func() {
376+
if REDIS_MAJOR_VERSION < 8 {
377+
Skip("default scorer is not BM25")
378+
}
376379
text1 := &redis.FieldSchema{FieldName: "description", FieldType: redis.SearchFieldTypeText}
377380
val, err := client.FTCreate(ctx, "idx1", &redis.FTCreateOptions{}, text1).Result()
378381
Expect(err).NotTo(HaveOccurred())
@@ -411,7 +414,10 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() {
411414
Expect(*res.Docs[0].Score).To(BeEquivalentTo(float64(0)))
412415
})
413416

414-
It("should FTSearch WithScores", Label("search", "ftsearch", "RedisVersion:v7"), func() {
417+
It("should FTSearch WithScores", Label("search", "ftsearch"), func() {
418+
if REDIS_MAJOR_VERSION >= 8 {
419+
Skip("default scorer is BM25")
420+
}
415421
text1 := &redis.FieldSchema{FieldName: "description", FieldType: redis.SearchFieldTypeText}
416422
val, err := client.FTCreate(ctx, "idx1", &redis.FTCreateOptions{}, text1).Result()
417423
Expect(err).NotTo(HaveOccurred())

0 commit comments

Comments
 (0)