Skip to content

Commit 9dd83b1

Browse files
authored
Test modules CONFIG support (#3103)
* Test SEARCH module CONFIG support * Test according to design doc with Redis 8.0-M03 * format * Based on RedisContainerIntegrationTests * Use 8.0-M04-pre image * Redis Redis 8.0-M04-pre added a value for search-timeout * enable disabled test * Redis 8.0-M04-pre readded the default value for search-default-dialect * set version condition for test class * Test against Redis unstable should use 8.0-M04-pre for modules * Modify getAllConfigSettings() test
1 parent d76e39e commit 9dd83b1

File tree

3 files changed

+122
-1
lines changed

3 files changed

+122
-1
lines changed

.github/workflows/integration.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
run: |
3636
# Map requested version to github or tag
3737
case "${{ matrix.redis_version }}" in
38-
"unstable") redis_branch="unstable" stack_version="8.0-M03-pre" ;;
38+
"unstable") redis_branch="unstable" stack_version="8.0-M04-pre" ;;
3939
"8.0") redis_branch="8.0" stack_version="8.0-M04-pre" ;;
4040
"7.4") redis_branch="7.4" stack_version="rs-7.4.0-v2" ;;
4141
"7.2") redis_branch="7.2" stack_version="rs-7.2.0-v14" ;;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
* Copyright 2011-Present, Redis Ltd. and Contributors
3+
* All rights reserved.
4+
*
5+
* Licensed under the MIT License.
6+
*
7+
* This file contains contributions from third-party contributors
8+
* licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* https://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
package io.lettuce.core.commands;
21+
22+
import static io.lettuce.TestTags.INTEGRATION_TEST;
23+
import static org.assertj.core.api.Assertions.assertThat;
24+
import static org.assertj.core.api.Assertions.assertThatThrownBy;
25+
import static org.junit.jupiter.api.Assumptions.assumeTrue;
26+
27+
import io.lettuce.core.*;
28+
import io.lettuce.core.api.sync.RedisCommands;
29+
import io.lettuce.test.condition.RedisConditions;
30+
31+
import org.junit.jupiter.api.*;
32+
33+
import java.util.Collections;
34+
import java.util.Map;
35+
36+
/**
37+
* Integration tests for {@link io.lettuce.core.api.sync.RedisServerCommands} with Redis modules since Redis 8.0.
38+
*
39+
* @author M Sazzadul Hoque
40+
*/
41+
@Tag(INTEGRATION_TEST)
42+
public class ConsolidatedConfigurationCommandIntegrationTests extends RedisContainerIntegrationTests {
43+
44+
private static RedisClient client;
45+
46+
private static RedisCommands<String, String> redis;
47+
48+
@BeforeAll
49+
public static void setup() {
50+
RedisURI redisURI = RedisURI.Builder.redis("127.0.0.1").withPort(16379).build();
51+
52+
client = RedisClient.create(redisURI);
53+
redis = client.connect().sync();
54+
assumeTrue(RedisConditions.of(redis).hasVersionGreaterOrEqualsTo("7.9"));
55+
}
56+
57+
@AfterAll
58+
static void teardown() {
59+
if (client != null) {
60+
client.shutdown();
61+
}
62+
}
63+
64+
@BeforeEach
65+
void setUp() {
66+
redis.flushall();
67+
}
68+
69+
@Test
70+
public void setSearchConfigGloballyTest() {
71+
final String configParam = "search-default-dialect";
72+
// confirm default
73+
assertThat(redis.configGet(configParam)).isEqualTo(Collections.singletonMap(configParam, "1"));
74+
75+
try {
76+
assertThat(redis.configSet(configParam, "2")).isEqualTo("OK");
77+
assertThat(redis.configGet(configParam)).isEqualTo(Collections.singletonMap(configParam, "2"));
78+
} finally {
79+
// restore to default
80+
assertThat(redis.configSet(configParam, "1")).isEqualTo("OK");
81+
}
82+
}
83+
84+
@Test
85+
public void setReadOnlySearchConfigTest() {
86+
assertThatThrownBy(() -> redis.configSet("search-max-doctablesize", "10"))
87+
.isInstanceOf(RedisCommandExecutionException.class);
88+
}
89+
90+
@Test
91+
public void getSearchConfigSettingTest() {
92+
assertThat(redis.configGet("search-timeout")).hasSize(1);
93+
}
94+
95+
@Test
96+
public void getTSConfigSettingTest() {
97+
assertThat(redis.configGet("ts-retention-policy")).hasSize(1);
98+
}
99+
100+
@Test
101+
public void getBFConfigSettingTest() {
102+
assertThat(redis.configGet("bf-error-rate")).hasSize(1);
103+
}
104+
105+
@Test
106+
public void getCFConfigSettingTest() {
107+
assertThat(redis.configGet("cf-initial-size")).hasSize(1);
108+
}
109+
110+
@Test
111+
public void getAllConfigSettings() {
112+
assertThat(redis.configGet("*").keySet()).contains("search-default-dialect", "search-timeout", "ts-retention-policy",
113+
"bf-error-rate", "cf-initial-size");
114+
}
115+
116+
}

src/test/java/io/lettuce/core/commands/ServerCommandIntegrationTests.java

+5
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,11 @@ void configGetMultipleParameters() {
398398
.containsEntry("hash-max-listpack-entries", "512");
399399
}
400400

401+
@Test
402+
public void getAllConfigSettings() {
403+
assertThat(redis.configGet("*")).isNotEmpty();
404+
}
405+
401406
@Test
402407
void configResetstat() {
403408
redis.get(key);

0 commit comments

Comments
 (0)