Skip to content

Commit 34bbf00

Browse files
authored
Test modules CONFIG support (#4043)
* Test SEARCH module CONFIG support * Test according to design doc with Redis 8.0-M03 * Set the version rule * Deprecate FT.CONFIG command and keyworkds * Shorten file name * fix typo * Redis 8.0-M03 image reports the version as 7.9.226 * Redis 8.0-M04-pre restored defaults * Based on RedisModuleCommandsTestBase * close resource
1 parent 5e1b5c8 commit 34bbf00

File tree

7 files changed

+102
-3
lines changed

7 files changed

+102
-3
lines changed

src/main/java/redis/clients/jedis/CommandObjects.java

+4
Original file line numberDiff line numberDiff line change
@@ -3531,19 +3531,23 @@ public final CommandObject<Set<String>> ftTagVals(String indexName, String field
35313531
.add(fieldName), BuilderFactory.STRING_SET);
35323532
}
35333533

3534+
@Deprecated
35343535
public final CommandObject<Map<String, Object>> ftConfigGet(String option) {
35353536
return new CommandObject<>(commandArguments(SearchCommand.CONFIG).add(SearchKeyword.GET).add(option),
35363537
protocol == RedisProtocol.RESP3 ? BuilderFactory.AGGRESSIVE_ENCODED_OBJECT_MAP : BuilderFactory.ENCODED_OBJECT_MAP_FROM_PAIRS);
35373538
}
35383539

3540+
@Deprecated
35393541
public final CommandObject<Map<String, Object>> ftConfigGet(String indexName, String option) {
35403542
return directSearchCommand(ftConfigGet(option), indexName);
35413543
}
35423544

3545+
@Deprecated
35433546
public final CommandObject<String> ftConfigSet(String option, String value) {
35443547
return new CommandObject<>(commandArguments(SearchCommand.CONFIG).add(SearchKeyword.SET).add(option).add(value), BuilderFactory.STRING);
35453548
}
35463549

3550+
@Deprecated
35473551
public final CommandObject<String> ftConfigSet(String indexName, String option, String value) {
35483552
return directSearchCommand(ftConfigSet(option, value), indexName);
35493553
}

src/main/java/redis/clients/jedis/PipeliningBase.java

+4
Original file line numberDiff line numberDiff line change
@@ -3565,21 +3565,25 @@ public Response<Set<String>> ftTagVals(String indexName, String fieldName) {
35653565
}
35663566

35673567
@Override
3568+
@Deprecated
35683569
public Response<Map<String, Object>> ftConfigGet(String option) {
35693570
return appendCommand(commandObjects.ftConfigGet(option));
35703571
}
35713572

35723573
@Override
3574+
@Deprecated
35733575
public Response<Map<String, Object>> ftConfigGet(String indexName, String option) {
35743576
return appendCommand(commandObjects.ftConfigGet(indexName, option));
35753577
}
35763578

35773579
@Override
3580+
@Deprecated
35783581
public Response<String> ftConfigSet(String option, String value) {
35793582
return appendCommand(commandObjects.ftConfigSet(option, value));
35803583
}
35813584

35823585
@Override
3586+
@Deprecated
35833587
public Response<String> ftConfigSet(String indexName, String option, String value) {
35843588
return appendCommand(commandObjects.ftConfigSet(indexName, option, value));
35853589
}

src/main/java/redis/clients/jedis/UnifiedJedis.java

+4
Original file line numberDiff line numberDiff line change
@@ -4067,21 +4067,25 @@ public Set<String> ftTagVals(String indexName, String fieldName) {
40674067
}
40684068

40694069
@Override
4070+
@Deprecated
40704071
public Map<String, Object> ftConfigGet(String option) {
40714072
return executeCommand(commandObjects.ftConfigGet(option));
40724073
}
40734074

40744075
@Override
4076+
@Deprecated
40754077
public Map<String, Object> ftConfigGet(String indexName, String option) {
40764078
return executeCommand(commandObjects.ftConfigGet(indexName, option));
40774079
}
40784080

40794081
@Override
4082+
@Deprecated
40804083
public String ftConfigSet(String option, String value) {
40814084
return executeCommand(commandObjects.ftConfigSet(option, value));
40824085
}
40834086

40844087
@Override
4088+
@Deprecated
40854089
public String ftConfigSet(String indexName, String option, String value) {
40864090
return executeCommand(commandObjects.ftConfigSet(indexName, option, value));
40874091
}

src/main/java/redis/clients/jedis/search/RediSearchCommands.java

+11
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.Map;
66
import java.util.Set;
77

8+
import redis.clients.jedis.commands.ConfigCommands;
89
import redis.clients.jedis.resps.Tuple;
910
import redis.clients.jedis.search.aggr.AggregationBuilder;
1011
import redis.clients.jedis.search.aggr.AggregationResult;
@@ -107,12 +108,22 @@ Map<String, Map<String, Double>> ftSpellCheck(String index, String query,
107108

108109
Set<String> ftTagVals(String indexName, String fieldName);
109110

111+
/**
112+
* @deprecated {@link ConfigCommands#configGet(java.lang.String)} is used since Redis 8.
113+
*/
114+
@Deprecated
110115
Map<String, Object> ftConfigGet(String option);
111116

117+
@Deprecated
112118
Map<String, Object> ftConfigGet(String indexName, String option);
113119

120+
/**
121+
* @deprecated {@link ConfigCommands#configSet(java.lang.String, java.lang.String)} is used since Redis 8.
122+
*/
123+
@Deprecated
114124
String ftConfigSet(String option, String value);
115125

126+
@Deprecated
116127
String ftConfigSet(String indexName, String option, String value);
117128

118129
long ftSugAdd(String key, String string, double score);

src/main/java/redis/clients/jedis/search/RediSearchPipelineCommands.java

+4
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,16 @@ Response<Map<String, Map<String, Double>>> ftSpellCheck(String index, String que
9595

9696
Response<Set<String>> ftTagVals(String indexName, String fieldName);
9797

98+
@Deprecated
9899
Response<Map<String, Object>> ftConfigGet(String option);
99100

101+
@Deprecated
100102
Response<Map<String, Object>> ftConfigGet(String indexName, String option);
101103

104+
@Deprecated
102105
Response<String> ftConfigSet(String option, String value);
103106

107+
@Deprecated
104108
Response<String> ftConfigSet(String indexName, String option, String value);
105109

106110
Response<Long> ftSugAdd(String key, String string, double score);

src/main/java/redis/clients/jedis/search/SearchProtocol.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public enum SearchCommand implements ProtocolCommand {
1616
EXPLAINCLI("FT.EXPLAINCLI"),
1717
AGGREGATE("FT.AGGREGATE"),
1818
CURSOR("FT.CURSOR"),
19-
CONFIG("FT.CONFIG"),
19+
@Deprecated CONFIG("FT.CONFIG"),
2020
ALIASADD("FT.ALIASADD"),
2121
ALIASUPDATE("FT.ALIASUPDATE"),
2222
ALIASDEL("FT.ALIASDEL"),
@@ -52,11 +52,12 @@ public enum SearchKeyword implements Rawable {
5252
SCHEMA, TEXT, TAG, NUMERIC, GEO, GEOSHAPE, VECTOR, VERBATIM, NOCONTENT, NOSTOPWORDS, WITHSCORES,
5353
LANGUAGE, INFIELDS, SORTBY, ASC, DESC, LIMIT, HIGHLIGHT, FIELDS, TAGS, SUMMARIZE, FRAGS, LEN,
5454
SEPARATOR, INKEYS, RETURN, FILTER, GEOFILTER, ADD, INCR, MAX, FUZZY, READ, DEL, DD, TEMPORARY,
55-
STOPWORDS, NOFREQS, NOFIELDS, NOOFFSETS, NOHL, SET, GET, ON, SORTABLE, UNF, PREFIX,
55+
STOPWORDS, NOFREQS, NOFIELDS, NOOFFSETS, NOHL, ON, SORTABLE, UNF, PREFIX,
5656
LANGUAGE_FIELD, SCORE, SCORE_FIELD, SCORER, PARAMS, AS, DIALECT, SLOP, TIMEOUT, INORDER,
5757
EXPANDER, MAXTEXTFIELDS, SKIPINITIALSCAN, WITHSUFFIXTRIE, NOSTEM, NOINDEX, PHONETIC, WEIGHT,
5858
CASESENSITIVE, LOAD, APPLY, GROUPBY, MAXIDLE, WITHCURSOR, DISTANCE, TERMS, INCLUDE, EXCLUDE,
59-
SEARCH, AGGREGATE, QUERY, LIMITED, COUNT, REDUCE, INDEXMISSING, INDEXEMPTY, ADDSCORES;
59+
SEARCH, AGGREGATE, QUERY, LIMITED, COUNT, REDUCE, INDEXMISSING, INDEXEMPTY, ADDSCORES,
60+
@Deprecated SET, @Deprecated GET;
6061

6162
private final byte[] raw;
6263

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package redis.clients.jedis.modules;
2+
3+
import static org.hamcrest.MatcherAssert.assertThat;
4+
import static org.hamcrest.Matchers.aMapWithSize;
5+
import static org.junit.Assert.assertEquals;
6+
import static org.junit.Assert.assertThrows;
7+
8+
import io.redis.test.annotations.SinceRedisVersion;
9+
import java.util.Collections;
10+
import org.hamcrest.Matchers;
11+
import org.junit.Test;
12+
import org.junit.runner.RunWith;
13+
import org.junit.runners.Parameterized;
14+
import redis.clients.jedis.RedisProtocol;
15+
import redis.clients.jedis.exceptions.JedisDataException;
16+
17+
@SinceRedisVersion(value = "7.9.0")
18+
@RunWith(Parameterized.class)
19+
public class ConsolidatedConfigurationCommandsTest extends RedisModuleCommandsTestBase {
20+
21+
public ConsolidatedConfigurationCommandsTest(RedisProtocol redisProtocol) {
22+
super(redisProtocol);
23+
}
24+
25+
@Test
26+
public void setSearchConfigGloballyTest() {
27+
final String configParam = "search-default-dialect";
28+
// confirm default
29+
assertEquals(Collections.singletonMap(configParam, "1"), jedis.configGet(configParam));
30+
31+
try {
32+
assertEquals("OK", jedis.configSet(configParam, "2"));
33+
assertEquals(Collections.singletonMap(configParam, "2"), jedis.configGet(configParam));
34+
35+
} finally {
36+
// restore to default
37+
assertEquals("OK", jedis.configSet(configParam, "1"));
38+
}
39+
}
40+
41+
@Test
42+
public void setReadOnlySearchConfigTest() {
43+
JedisDataException de = assertThrows(JedisDataException.class, () -> jedis.configSet("search-max-doctablesize", "10"));
44+
assertThat(de.getMessage(), Matchers.not(Matchers.emptyOrNullString()));
45+
}
46+
47+
@Test
48+
public void getSearchConfigSettingTest() {
49+
assertThat(jedis.configGet("search-timeout"), aMapWithSize(1));
50+
}
51+
52+
@Test
53+
public void getTSConfigSettingTest() {
54+
assertThat(jedis.configGet("ts-retention-policy"), aMapWithSize(1));
55+
}
56+
57+
@Test
58+
public void getBFConfigSettingTest() {
59+
assertThat(jedis.configGet("bf-error-rate"), aMapWithSize(1));
60+
}
61+
62+
@Test
63+
public void getCFConfigSettingTest() {
64+
assertThat(jedis.configGet("cf-initial-size"), aMapWithSize(1));
65+
}
66+
67+
@Test
68+
public void getAllConfigSettings() {
69+
assertThat(jedis.configGet("*").size(), Matchers.greaterThan(0));
70+
}
71+
}

0 commit comments

Comments
 (0)