Skip to content

Commit eb4bb8c

Browse files
committed
This change introduces a new test matrix based on Redis versions [8.0.0-M1, 7.4.1, 7.2.6, 6.2.16]
We use docker composer for bringing up test env using redislabs/client-libs-test image. When run against older Redis version it appears that some tests are using commands available only in newer Redis server versions. To resolve this we are introducing two new annotation/rules - Introduce SinceRedisVersion annotation/Rule - for conditionally running test based on Redis server version contacted - Introduce EnableOnCommad annotation/Rule - for conditionally running test 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 Same approach used to mark CSC tests - Disabled client side caching tests for versions below 7.4 Fix in Jedis Client against Redis server 6.x - Fix NPE in CommandInfo command when used against Redis 6 Starting with Redis version 7.2.0: Added entry ID, timestamp created, and timestamp last updated fields. Client will throw NPE if those are missing in the response (e.g when connected against 6.2) Fix is to safe check if (entry ID, timestamp created, and timestamp last) exists in the response before converting them. Fix Tests failures against 6.x - Fix JedisPooledClientSideCacheTest - Fix AccessControlListCommandsTest.aclLogTest:372 » NullPointer - Fix AccessControlListCommandsTest.aclLogWithEntryID:473 » NullPointer - Fix StreamsCommandsTest - Fix StreamsPipelineCommandsTest xadd - Starting with Redis version 7.0.0: Added support for the <ms>-* explicit ID form. - Test env migrated to use native Redis server TLS instead of using stunnel Not all test were migrated - Disable Modules test in containerised test env ModuleTest is using custtom test module to test load/unload/sendCommand. Need to prebuild the test module on same os like test container to avoid erros - Disable UDS tests in containerised test env No easy way to make unix sockets on MAC with docker docker-compose to deploy required IT test envs.
1 parent 9b88636 commit eb4bb8c

File tree

136 files changed

+2688
-667
lines changed

Some content is hidden

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

136 files changed

+2688
-667
lines changed

.github/workflows/integration.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ jobs:
3434
- name: System setup
3535
run: |
3636
sudo apt update
37-
sudo apt install -y stunnel make
38-
make system-setup
37+
sudo apt install -y make
38+
make compile-module
3939
- name: Cache dependencies
4040
uses: actions/cache@v2
4141
with:

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

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
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-M01"
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 CLIENT_LIBS_TEST_IMAGE="${CLIENT_LIBS_IMAGE_PREFIX}:${{ matrix.redis_version }}"
67+
export COMPOSE_ENV_FILES="src/test/resources/env/.env"
68+
if [[ "${{ matrix.redis_version }}" == "6.2.16" ]]; then
69+
COMPOSE_ENV_FILES+=",src/test/resources/env/.env.v${{ matrix.redis_version }}"
70+
fi
71+
docker compose -f src/test/resources/env/docker-compose.yml up -d
72+
- name: Maven offline
73+
run: |
74+
mvn -q dependency:go-offline
75+
- name: Build docs
76+
run: |
77+
mvn javadoc:jar
78+
# Run Tests
79+
- name: Run Maven tests
80+
run: |
81+
export TEST_ENV_PROVIDER=docker
82+
export TEST_WORK_FOLDER=$REDIS_ENV_WORK_DIR
83+
echo $TEST_WORK_FOLDER
84+
if [ -z "$TESTS" ]; then
85+
mvn clean compile test
86+
else
87+
mvn -Dtest=$SPECIFIC_TEST clean compile test
88+
fi
89+
env:
90+
TESTS: ${{ github.event.inputs.specific_test || '' }}
91+
- name: Publish Test Results
92+
uses: EnricoMi/publish-unit-test-result-action@v2
93+
if: always()
94+
with:
95+
files: |
96+
target/surefire-reports/**/*.xml
97+
# Collect logs on failure
98+
- name: Collect logs on failure
99+
if: failure() # This runs only if the previous steps failed
100+
run: |
101+
echo "Collecting logs from $WORK_DIR..."
102+
ls -la $REDIS_ENV_WORK_DIR
103+
# Upload logs as artifacts
104+
- name: Upload logs on failure
105+
if: failure()
106+
uses: actions/upload-artifact@v3
107+
with:
108+
name: redis-env-work-logs
109+
path: ${{ env.REDIS_ENV_WORK_DIR }}
110+
# Bring down the Docker Compose test environment
111+
- name: Tear down Docker Compose environment
112+
if: always()
113+
run: |
114+
docker compose $COMPOSE_ENV_FILES -f src/test/resources/env/docker-compose.yml down
115+
continue-on-error: true
116+
# Upload code coverage
117+
- name: Upload coverage to Codecov
118+
uses: codecov/codecov-action@v4
119+
with:
120+
fail_ci_if_error: false
121+
token: ${{ secrets.CODECOV_TOKEN }}
122+
- name: Upload test results to Codecov
123+
if: ${{ github.event_name == 'schedule' || (github.event_name == 'push') || github.event_name == 'workflow_dispatch'}}
124+
uses: codecov/test-results-action@v1
125+
with:
126+
fail_ci_if_error: false
127+
files: ./target/surefire-reports/TEST*
128+
token: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
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

.run/redis in jedis.run.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="redis in jedis" type="JUnit" factoryName="JUnit" nameIsGenerated="true">
3+
<module name="jedis" />
4+
<extension name="net.ashald.envfile">
5+
<option name="IS_ENABLED" value="false" />
6+
<option name="IS_SUBST" value="false" />
7+
<option name="IS_PATH_MACRO_SUPPORTED" value="false" />
8+
<option name="IS_IGNORE_MISSING_FILES" value="false" />
9+
<option name="IS_ENABLE_EXPERIMENTAL_INTEGRATIONS" value="false" />
10+
<ENTRIES>
11+
<ENTRY IS_ENABLED="true" PARSER="runconfig" IS_EXECUTABLE="false" />
12+
</ENTRIES>
13+
</extension>
14+
<option name="MAIN_CLASS_NAME" value="" />
15+
<option name="METHOD_NAME" value="" />
16+
<option name="TEST_OBJECT" value="directory" />
17+
<option name="VM_PARAMETERS" value="-ea -Djava.net.preferIPv4Stack=true " />
18+
<dir value="$PROJECT_DIR$/src/test/java/redis" />
19+
<method v="2">
20+
<option name="Make" enabled="true" />
21+
</method>
22+
</configuration>
23+
</component>

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ protected-mode no
77
port 6379
88
requirepass foobared
99
user acljedis on allcommands allkeys >fizzbuzz
10+
user deploy on allcommands allkeys >verify
1011
pidfile /tmp/redis1.pid
1112
logfile /tmp/redis1.log
1213
save ""
@@ -189,6 +190,7 @@ endef
189190

190191
define REDIS_SENTINEL5
191192
port 26383
193+
tlsport 36383
192194
daemonize yes
193195
protected-mode no
194196
user default off
@@ -525,8 +527,14 @@ mvn-release:
525527
mvn release:prepare
526528
mvn release:perform -DskipTests
527529

528-
system-setup:
529-
sudo apt install -y gcc g++
530+
install-gcc:
531+
@if [ "$(shell uname)" = "Darwin" ]; then \
532+
brew install gcc; \
533+
else \
534+
sudo apt install -y gcc g++; \
535+
fi
536+
537+
system-setup: install-gcc
530538
[ ! -e redis-git ] && git clone https://github.com/redis/redis.git --branch unstable --single-branch redis-git || true
531539
$(MAKE) -C redis-git clean
532540
$(MAKE) -C redis-git

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
<dependency>
140140
<groupId>org.apache.httpcomponents.client5</groupId>
141141
<artifactId>httpclient5-fluent</artifactId>
142-
<version>5.4.1</version>
142+
<version>5.4</version>
143143
<scope>test</scope>
144144
</dependency>
145145

src/main/java/redis/clients/jedis/resps/AccessControlLogEntry.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ public class AccessControlLogEntry implements Serializable {
3838
private final long timestampCreated;
3939
private final long timestampLastUpdated;
4040

41+
/*
42+
* Starting with Redis version 7.2.0: Added entry ID, timestamp created, and timestamp last updated.
43+
* @see https://redis.io/docs/latest/commands/acl-log/
44+
*/
4145
public AccessControlLogEntry(Map<String, Object> map) {
4246
count = (long) map.get(COUNT);
4347
reason = (String) map.get(REASON);
@@ -47,9 +51,9 @@ public AccessControlLogEntry(Map<String, Object> map) {
4751
ageSeconds = (Double) map.get(AGE_SECONDS);
4852
clientInfo = getMapFromRawClientInfo((String) map.get(CLIENT_INFO));
4953
logEntry = map;
50-
entryId = (long) map.get(ENTRY_ID);
51-
timestampCreated = (long) map.get(TIMESTAMP_CREATED);
52-
timestampLastUpdated = (long) map.get(TIMESTAMP_LAST_UPDATED);
54+
entryId = map.get(ENTRY_ID) == null ? 0L : (long) map.get(ENTRY_ID);
55+
timestampCreated = map.get(TIMESTAMP_CREATED) == null ? 0L : (long) map.get(TIMESTAMP_CREATED);
56+
timestampLastUpdated = map.get(TIMESTAMP_LAST_UPDATED) == null ? 0L : (long) map.get(TIMESTAMP_LAST_UPDATED);
5357
}
5458

5559
public long getCount() {

src/main/java/redis/clients/jedis/resps/CommandInfo.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import redis.clients.jedis.Builder;
44

5+
import java.util.Collections;
56
import java.util.List;
67

78
import static redis.clients.jedis.BuilderFactory.STRING_LIST;
@@ -103,9 +104,13 @@ public CommandInfo build(Object data) {
103104
long firstKey = LONG.build(commandData.get(3));
104105
long lastKey = LONG.build(commandData.get(4));
105106
long step = LONG.build(commandData.get(5));
106-
List<String> aclCategories = STRING_LIST.build(commandData.get(6));
107-
List<String> tips = STRING_LIST.build(commandData.get(7));
108-
List<String> subcommands = STRING_LIST.build(commandData.get(9));
107+
108+
// (as of Redis 6.0)
109+
List<String> aclCategories = commandData.size()>=6?STRING_LIST.build(commandData.get(6)):Collections.emptyList();
110+
111+
// (as of Redis 7.0)
112+
List<String> tips = commandData.size()>=8?STRING_LIST.build(commandData.get(7)):Collections.emptyList();
113+
List<String> subcommands = commandData.size()>=10?STRING_LIST.build(commandData.get(9)): Collections.emptyList();
109114

110115
return new CommandInfo(arity, flags, firstKey, lastKey, step, aclCategories, tips, subcommands);
111116
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package io.redis.test.annotations;
2+
3+
import java.lang.annotation.*;
4+
5+
@Inherited
6+
@Retention(RetentionPolicy.RUNTIME)
7+
@Target({ElementType.METHOD, ElementType.TYPE})
8+
public @interface EnabledOnCommand {
9+
String value();
10+
String subCommand() default "";
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package io.redis.test.annotations;
2+
3+
import java.lang.annotation.*;
4+
5+
@Inherited
6+
@Retention(RetentionPolicy.RUNTIME)
7+
@Target({ElementType.METHOD, ElementType.TYPE})
8+
public @interface SinceRedisVersion {
9+
String value();
10+
String message() default "";
11+
}

0 commit comments

Comments
 (0)