1
0
mirror of https://github.com/redis/go-redis.git synced 2025-09-05 20:24:00 +03:00

fix(make test): Add default env in makefile (#3491)

* fix(make test): add default env in makefile

* Apply suggestion from @ndyakov

* update hardcoded version
This commit is contained in:
Nedyalko Dyakov
2025-09-01 16:17:28 +03:00
committed by GitHub
parent 6bc7238340
commit e91f6ced09
4 changed files with 28 additions and 8 deletions

View File

@@ -37,7 +37,7 @@ Here's how to get started with your code contribution:
> Note: this clones and builds the docker containers specified in `docker-compose.yml`, to understand more about > Note: this clones and builds the docker containers specified in `docker-compose.yml`, to understand more about
> the infrastructure that will be started you can check the `docker-compose.yml`. You also have the possiblity > the infrastructure that will be started you can check the `docker-compose.yml`. You also have the possiblity
> to specify the redis image that will be pulled with the env variable `CLIENT_LIBS_TEST_IMAGE`. > to specify the redis image that will be pulled with the env variable `CLIENT_LIBS_TEST_IMAGE`.
> By default the docker image that will be pulled and started is `redislabs/client-libs-test:rs-7.4.0-v2`. > By default the docker image that will be pulled and started is `redislabs/client-libs-test:8.2.1-pre`.
> If you want to test with newer Redis version, using a newer version of `redislabs/client-libs-test` should work out of the box. > If you want to test with newer Redis version, using a newer version of `redislabs/client-libs-test` should work out of the box.
4. While developing, make sure the tests pass by running `make test` (if you have the docker containers running, `make test.ci` may be sufficient). 4. While developing, make sure the tests pass by running `make test` (if you have the docker containers running, `make test.ci` may be sufficient).

View File

@@ -1,6 +1,14 @@
GO_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {} \; | sort) GO_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {} \; | sort)
REDIS_VERSION ?= 8.2
RE_CLUSTER ?= false
RCE_DOCKER ?= true
CLIENT_LIBS_TEST_IMAGE ?= redislabs/client-libs-test:8.2.1-pre
docker.start: docker.start:
export RE_CLUSTER=$(RE_CLUSTER) && \
export RCE_DOCKER=$(RCE_DOCKER) && \
export REDIS_VERSION=$(REDIS_VERSION) && \
export CLIENT_LIBS_TEST_IMAGE=$(CLIENT_LIBS_TEST_IMAGE) && \
docker compose --profile all up -d --quiet-pull docker compose --profile all up -d --quiet-pull
docker.stop: docker.stop:
@@ -27,6 +35,9 @@ test.ci:
set -e; for dir in $(GO_MOD_DIRS); do \ set -e; for dir in $(GO_MOD_DIRS); do \
echo "go test in $${dir}"; \ echo "go test in $${dir}"; \
(cd "$${dir}" && \ (cd "$${dir}" && \
export RE_CLUSTER=$(RE_CLUSTER) && \
export RCE_DOCKER=$(RCE_DOCKER) && \
export REDIS_VERSION=$(REDIS_VERSION) && \
go mod tidy -compat=1.18 && \ go mod tidy -compat=1.18 && \
go vet && \ go vet && \
go test -v -coverprofile=coverage.txt -covermode=atomic ./... -race -skip Example); \ go test -v -coverprofile=coverage.txt -covermode=atomic ./... -race -skip Example); \
@@ -38,6 +49,9 @@ test.ci.skip-vectorsets:
set -e; for dir in $(GO_MOD_DIRS); do \ set -e; for dir in $(GO_MOD_DIRS); do \
echo "go test in $${dir} (skipping vector sets)"; \ echo "go test in $${dir} (skipping vector sets)"; \
(cd "$${dir}" && \ (cd "$${dir}" && \
export RE_CLUSTER=$(RE_CLUSTER) && \
export RCE_DOCKER=$(RCE_DOCKER) && \
export REDIS_VERSION=$(REDIS_VERSION) && \
go mod tidy -compat=1.18 && \ go mod tidy -compat=1.18 && \
go vet && \ go vet && \
go test -v -coverprofile=coverage.txt -covermode=atomic ./... -race \ go test -v -coverprofile=coverage.txt -covermode=atomic ./... -race \
@@ -47,11 +61,17 @@ test.ci.skip-vectorsets:
go vet -vettool ./internal/customvet/customvet go vet -vettool ./internal/customvet/customvet
bench: bench:
export RE_CLUSTER=$(RE_CLUSTER) && \
export RCE_DOCKER=$(RCE_DOCKER) && \
export REDIS_VERSION=$(REDIS_VERSION) && \
go test ./... -test.run=NONE -test.bench=. -test.benchmem -skip Example go test ./... -test.run=NONE -test.bench=. -test.benchmem -skip Example
.PHONY: all test test.ci test.ci.skip-vectorsets bench fmt .PHONY: all test test.ci test.ci.skip-vectorsets bench fmt
build: build:
export RE_CLUSTER=$(RE_CLUSTER) && \
export RCE_DOCKER=$(RCE_DOCKER) && \
export REDIS_VERSION=$(REDIS_VERSION) && \
go build . go build .
fmt: fmt:

View File

@@ -2,7 +2,7 @@
services: services:
redis: redis:
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v2} image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:8.2.1-pre}
platform: linux/amd64 platform: linux/amd64
container_name: redis-standalone container_name: redis-standalone
environment: environment:
@@ -23,7 +23,7 @@ services:
- all - all
osscluster: osscluster:
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v2} image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:8.2.1-pre}
platform: linux/amd64 platform: linux/amd64
container_name: redis-osscluster container_name: redis-osscluster
environment: environment:
@@ -40,7 +40,7 @@ services:
- all - all
sentinel-cluster: sentinel-cluster:
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v2} image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:8.2.1-pre}
platform: linux/amd64 platform: linux/amd64
container_name: redis-sentinel-cluster container_name: redis-sentinel-cluster
network_mode: "host" network_mode: "host"
@@ -60,7 +60,7 @@ services:
- all - all
sentinel: sentinel:
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v2} image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:8.2.1-pre}
platform: linux/amd64 platform: linux/amd64
container_name: redis-sentinel container_name: redis-sentinel
depends_on: depends_on:
@@ -84,7 +84,7 @@ services:
- all - all
ring-cluster: ring-cluster:
image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v2} image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:8.2.1-pre}
platform: linux/amd64 platform: linux/amd64
container_name: redis-ring-cluster container_name: redis-ring-cluster
environment: environment:

View File

@@ -68,7 +68,7 @@ var RCEDocker = false
// Notes version of redis we are executing tests against. // Notes version of redis we are executing tests against.
// This can be used before we change the bsm fork of ginkgo for one, // This can be used before we change the bsm fork of ginkgo for one,
// which have support for label sets, so we can filter tests per redis version. // which have support for label sets, so we can filter tests per redis version.
var RedisVersion float64 = 7.2 var RedisVersion float64 = 8.2
func SkipBeforeRedisVersion(version float64, msg string) { func SkipBeforeRedisVersion(version float64, msg string) {
if RedisVersion < version { if RedisVersion < version {
@@ -95,7 +95,7 @@ var _ = BeforeSuite(func() {
RedisVersion, _ = strconv.ParseFloat(strings.Trim(os.Getenv("REDIS_VERSION"), "\""), 64) RedisVersion, _ = strconv.ParseFloat(strings.Trim(os.Getenv("REDIS_VERSION"), "\""), 64)
if RedisVersion == 0 { if RedisVersion == 0 {
RedisVersion = 7.2 RedisVersion = 8.2
} }
fmt.Printf("RECluster: %v\n", RECluster) fmt.Printf("RECluster: %v\n", RECluster)