Skip to content

Commit 243b446

Browse files
committed
Add redis major version env
Enable filtering test per redis major version Fix test for FT.SEARCH WITHSCORE, the default scorer has changed. fix Makefile syntax remove filter from github action fix makefile use the container name in Makefile
1 parent a2c85f9 commit 243b446

File tree

5 files changed

+30
-12
lines changed

5 files changed

+30
-12
lines changed

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

Lines changed: 2 additions & 3 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,12 +53,10 @@ 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" \
6059
--ginkgo.skip-file="pubsub_test.go" \
6160
--ginkgo.skip-file="gears_commands_test.go" \
62-
--ginkgo.label-filter="!NonRedisEnterprise && RedisVersion: isSubsetOf {$redis_major_version}"
61+
--ginkgo.label-filter="!NonRedisEnterprise"
6362
shell: bash

.github/workflows/test-redis-enterprise.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ jobs:
4747
- name: Test
4848
env:
4949
RE_CLUSTER: true
50+
REDIS_MAJOR_VERSION: 7
5051
run: |
5152
go test \
5253
--ginkgo.skip-file="ring_test.go" \

Makefile

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

44
test: testdeps
55
$(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) "
76
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
87
$(eval GO_VERSION := $(shell go version | cut -d " " -f 3 | cut -d. -f2))
98
set -e; for dir in $(GO_MOD_DIRS); do \
@@ -14,7 +13,7 @@ test: testdeps
1413
echo "go test in $${dir}"; \
1514
(cd "$${dir}" && \
1615
go mod tidy -compat=1.18 && \
17-
go test --ginkgo.label-filter="RedisVersion: isSubsetOf \"$(R_MAJOR)\""&& \
16+
go test && \
1817
go test ./... -short -race && \
1918
go test ./... -run=NONE -bench=. -benchmem && \
2019
env GOOS=linux GOARCH=386 go test && \
@@ -23,11 +22,13 @@ test: testdeps
2322
done
2423
cd internal/customvet && go build .
2524
go vet -vettool ./internal/customvet/customvet
26-
docker stop (docker container ls -a -q --filter name=go-redis-redis-stack)
27-
28-
testdeps: testdata/redis/src/redis-server
25+
docker stop go-redis-redis-stack
2926

27+
dockertest:
28+
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
29+
docker stop go-redis-redis-stack
3030

31+
testdeps: testdata/redis/src/redis-server
3132

3233
bench: testdeps
3334
go test ./... -test.run=NONE -test.bench=. -test.benchmem

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: 9 additions & 3 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())
@@ -384,7 +387,7 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() {
384387

385388
res, err := client.FTSearchWithArgs(ctx, "idx1", "quick", &redis.FTSearchOptions{WithScores: true}).Result()
386389
Expect(err).NotTo(HaveOccurred())
387-
Expect(*res.Docs[0].Score).To(BeNumerically("<=", 0.22471909420069797))
390+
Expect(*res.Docs[0].Score).To(BeNumerically("<=", 0.236))
388391

389392
res, err = client.FTSearchWithArgs(ctx, "idx1", "quick", &redis.FTSearchOptions{WithScores: true, Scorer: "TFIDF"}).Result()
390393
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)