Skip to content

Commit f9977e4

Browse files
ggivosazzad16
andauthored
Introduces test matrix based on Redis versions [8.0-M02, 7.4.1, 7.2.6, 6.2.16] (#4015)
* Introduces test matrix based on Redis versions [8.0-M1, 7.4.1, 7.2.6, 6.2.16] Use docker composer to bring up the test env using `redislabs/client-libs-test` image. When run against older Redis version some tests are using commands available only in newer Redis server versions. To resolve this we are introducing two new annotations/rules - Introduce `SinceRedisVersion` annotation/Rule - for conditionally running tests based on Redis server version contacted - Introduce `EnableOnCommad` annotation/Rule - for conditionally running tests based on command availability on the server And mark respective tests with the least Redis Version required by the test - SinceRedisVersion ("7.4.0") - Mark tests using commands/modifiers introduced with Redis 7.4.0 - SinceRedisVersion ("7.2.0") - Mark tests using commands/modifiers introduced with Redis 7.2.0 - SinceRedisVersion ("7.0.0") - Mark tests using commands/modifiers introduced with Redis 7.0.0 The same approach used to mark CSC tests - Disabled client-side caching tests for versions below 7.4 - Test env migrated to use native Redis server TLS instead of using stunnel Not all tests were migrated - Disable Modules test in containerized test env ModuleTest uses custom test module to test load/unload/sendCommand. Requires pre-build test module on the same os like test container to avoid errors - Disable UDS tests in containerized test env No easy way to make unix sockets work on MAC with docker --------- Co-authored-by: M Sazzadul Hoque <[email protected]>
1 parent 180d9aa commit f9977e4

File tree

138 files changed

+2690
-539
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+2690
-539
lines changed

.github/CONTRIBUTING.md

+47
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,53 @@ Jedis unit tests use many Redis instances, so we use a ```Makefile``` to prepare
2525
Start unit tests with ```make test```.
2626
Set up test environments with ```make start```, tear down those environments with ```make stop``` and clean up the environment files with ```make cleanup```.
2727

28+
29+
# Jedis Test Environment Using Docker
30+
31+
This guide explains how to bootstrap and manage a test environment for Jedis using Docker Compose.
32+
33+
## Workflow Steps
34+
1. **Start the test environment** by running the following command (examples below).
35+
- For instance, to start the environment with Redis 8.0-M02, use `make start-test-env`.
36+
2. **Run tests** through your IDE, Maven, or other testing tools as needed.
37+
3. **Stop the test environment** by running the following command:
38+
- `make stop-test-env`
39+
- This will stop and tear down the Docker containers running the Redis service
40+
41+
# Start the Test Environment Using Docker
42+
43+
You can bootstrap the test environment for supported versions of Redis using the provided `make` targets.
44+
45+
## Option 1: Using `make` Targets
46+
To bring up the test environment for a specific Redis version (8.0-M02, 7.4.1, 7.2.6, or 6.2.16), use the following command:
47+
```bash
48+
make start-test-env version=8.0-M02 # Replace with desired version
49+
```
50+
To stop test environment:
51+
```bash
52+
make stop-test-env
53+
```
54+
To run tests using dockerized environment:
55+
```bash
56+
make test-on-docker
57+
```
58+
59+
## Option 2: Using docker compose commands directly
60+
Docker compose file can be found in `src/test/resources/env` folder.
61+
- **Redis 8.0-M02**
62+
```bash
63+
rm -rf /tmp/redis-env-work
64+
export REDIS_VERSION=8.0-M02
65+
docker compose up
66+
```
67+
- **Redis 7.4.1, 7.2.6, 6.2.16,**
68+
```bash
69+
rm -rf /tmp/redis-env-work
70+
export REDIS_VERSION=6.2.16
71+
docker compose --env-file .env --env-file .env.v6.2.16 up
72+
```
73+
74+
2875
# Some rules of Jedis source code
2976

3077
## Code Convention

.github/workflows/integration.yml

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ jobs:
5151
mvn javadoc:jar
5252
- name: Run tests
5353
run: |
54+
export TEST_ENV_PROVIDER=local
5455
make test
5556
env:
5657
JVM_OPTS: -Xmx3200m

.github/workflows/test-on-docker.yml

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
---
2+
3+
name: Build and Test using containerized environment
4+
5+
on:
6+
push:
7+
paths-ignore:
8+
- 'docs/**'
9+
- '**/*.md'
10+
- '**/*.rst'
11+
branches:
12+
- master
13+
- '[0-9].*'
14+
pull_request:
15+
branches:
16+
- master
17+
- '[0-9].*'
18+
schedule:
19+
- cron: '0 1 * * *' # nightly build
20+
workflow_dispatch:
21+
inputs:
22+
specific_test:
23+
description: 'Run specific test(s) (optional)'
24+
required: false
25+
default: ''
26+
jobs:
27+
28+
build:
29+
name: Build and Test
30+
runs-on: ubuntu-latest
31+
env:
32+
REDIS_ENV_WORK_DIR: ${{ github.workspace }}/redis-env-work
33+
REDIS_ENV_CONF_DIR: ${{ github.workspace }}/src/test/resources/env
34+
CLIENT_LIBS_IMAGE_PREFIX: "redislabs/client-libs-test"
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
redis_version:
39+
- "8.0-M02"
40+
- "7.4.1"
41+
- "7.2.6"
42+
# - "6.2.16"
43+
steps:
44+
- uses: actions/checkout@v2
45+
- name: Set up publishing to maven central
46+
uses: actions/setup-java@v2
47+
with:
48+
java-version: '8'
49+
distribution: 'temurin'
50+
- name: System setup
51+
run: |
52+
sudo apt update
53+
sudo apt install -y make
54+
make compile-module
55+
- name: Cache dependencies
56+
uses: actions/cache@v2
57+
with:
58+
path: |
59+
~/.m2/repository
60+
/var/cache/apt
61+
key: jedis-${{hashFiles('**/pom.xml')}}
62+
# Set up Docker Compose environment
63+
- name: Set up Docker Compose environment
64+
run: |
65+
mkdir -m 777 $REDIS_ENV_WORK_DIR
66+
export REDIS_VERSION="${{ matrix.redis_version }}"
67+
make start-test-env version=$REDIS_VERSION
68+
- name: Maven offline
69+
run: |
70+
mvn -q dependency:go-offline
71+
- name: Build docs
72+
run: |
73+
mvn javadoc:jar
74+
# Run Tests
75+
- name: Run Maven tests
76+
run: |
77+
export TEST_ENV_PROVIDER=docker
78+
export TEST_WORK_FOLDER=$REDIS_ENV_WORK_DIR
79+
echo $TEST_WORK_FOLDER
80+
if [ -z "$TESTS" ]; then
81+
mvn clean compile test
82+
else
83+
mvn -Dtest=$TESTS clean compile test
84+
fi
85+
env:
86+
TESTS: ${{ github.event.inputs.specific_test || '' }}
87+
- name: Publish Test Results
88+
uses: EnricoMi/publish-unit-test-result-action@v2
89+
if: always()
90+
with:
91+
files: |
92+
target/surefire-reports/**/*.xml
93+
# Collect logs on failure
94+
- name: Collect logs on failure
95+
if: failure() # This runs only if the previous steps failed
96+
run: |
97+
echo "Collecting logs from $WORK_DIR..."
98+
ls -la $REDIS_ENV_WORK_DIR
99+
# Upload logs as artifacts
100+
- name: Upload logs on failure
101+
if: failure()
102+
uses: actions/upload-artifact@v4
103+
with:
104+
name: redis-env-work-logs-${{ matrix.redis_version }}
105+
path: ${{ env.REDIS_ENV_WORK_DIR }}
106+
# Bring down the Docker Compose test environment
107+
- name: Tear down Docker Compose environment
108+
if: always()
109+
run: |
110+
docker compose $COMPOSE_ENV_FILES -f src/test/resources/env/docker-compose.yml down
111+
continue-on-error: true
112+
# Upload code coverage
113+
- name: Upload coverage to Codecov
114+
uses: codecov/codecov-action@v4
115+
with:
116+
fail_ci_if_error: false
117+
token: ${{ secrets.CODECOV_TOKEN }}
118+
- name: Upload test results to Codecov
119+
if: ${{ github.event_name == 'schedule' || (github.event_name == 'push') || github.event_name == 'workflow_dispatch'}}
120+
uses: codecov/test-results-action@v1
121+
with:
122+
fail_ci_if_error: false
123+
files: ./target/surefire-reports/TEST*
124+
token: ${{ secrets.CODECOV_TOKEN }}

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ build/
1111
bin/
1212
tags
1313
.idea
14+
.run
1415
*.aof
1516
*.rdb
1617
redis-git
1718
appendonlydir/
19+
.DS_Store

0 commit comments

Comments
 (0)