Skip to content

Commit

Permalink
Test according to design doc with Redis 8.0-M03
Browse files Browse the repository at this point in the history
  • Loading branch information
sazzad16 committed Jan 22, 2025
1 parent fc01783 commit bcb66d6
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 35 deletions.
4 changes: 4 additions & 0 deletions src/main/java/redis/clients/jedis/CommandObjects.java
Original file line number Diff line number Diff line change
Expand Up @@ -3531,19 +3531,23 @@ public final CommandObject<Set<String>> ftTagVals(String indexName, String field
.add(fieldName), BuilderFactory.STRING_SET);
}

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

@Deprecated
public final CommandObject<Map<String, Object>> ftConfigGet(String indexName, String option) {
return directSearchCommand(ftConfigGet(option), indexName);
}

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

@Deprecated
public final CommandObject<String> ftConfigSet(String indexName, String option, String value) {
return directSearchCommand(ftConfigSet(option, value), indexName);
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/redis/clients/jedis/PipeliningBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -3565,21 +3565,25 @@ public Response<Set<String>> ftTagVals(String indexName, String fieldName) {
}

@Override
@Deprecated
public Response<Map<String, Object>> ftConfigGet(String option) {
return appendCommand(commandObjects.ftConfigGet(option));
}

@Override
@Deprecated
public Response<Map<String, Object>> ftConfigGet(String indexName, String option) {
return appendCommand(commandObjects.ftConfigGet(indexName, option));
}

@Override
@Deprecated
public Response<String> ftConfigSet(String option, String value) {
return appendCommand(commandObjects.ftConfigSet(option, value));
}

@Override
@Deprecated
public Response<String> ftConfigSet(String indexName, String option, String value) {
return appendCommand(commandObjects.ftConfigSet(indexName, option, value));
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/redis/clients/jedis/UnifiedJedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -4067,21 +4067,25 @@ public Set<String> ftTagVals(String indexName, String fieldName) {
}

@Override
@Deprecated
public Map<String, Object> ftConfigGet(String option) {
return executeCommand(commandObjects.ftConfigGet(option));
}

@Override
@Deprecated
public Map<String, Object> ftConfigGet(String indexName, String option) {
return executeCommand(commandObjects.ftConfigGet(indexName, option));
}

@Override
@Deprecated
public String ftConfigSet(String option, String value) {
return executeCommand(commandObjects.ftConfigSet(option, value));
}

@Override
@Deprecated
public String ftConfigSet(String indexName, String option, String value) {
return executeCommand(commandObjects.ftConfigSet(indexName, option, value));
}
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/redis/clients/jedis/search/RediSearchCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import redis.clients.jedis.commands.ConfigCommands;

import redis.clients.jedis.resps.Tuple;
import redis.clients.jedis.search.aggr.AggregationBuilder;
Expand Down Expand Up @@ -107,12 +108,22 @@ Map<String, Map<String, Double>> ftSpellCheck(String index, String query,

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

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

@Deprecated
Map<String, Object> ftConfigGet(String indexName, String option);

/**
* @deprecated {@link ConfigCommands#configSet(java.lang.String, java.lang.String)} is used since Redis 8.
*/
@Deprecated
String ftConfigSet(String option, String value);

@Deprecated
String ftConfigSet(String indexName, String option, String value);

long ftSugAdd(String key, String string, double score);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,16 @@ Response<Map<String, Map<String, Double>>> ftSpellCheck(String index, String que

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

@Deprecated
Response<Map<String, Object>> ftConfigGet(String option);

@Deprecated
Response<Map<String, Object>> ftConfigGet(String indexName, String option);

@Deprecated
Response<String> ftConfigSet(String option, String value);

@Deprecated
Response<String> ftConfigSet(String indexName, String option, String value);

Response<Long> ftSugAdd(String key, String string, double score);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package redis.clients.jedis.modules;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.aMapWithSize;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;

import java.util.Collections;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import redis.clients.jedis.RedisProtocol;
import redis.clients.jedis.commands.jedis.JedisCommandsTestBase;
import redis.clients.jedis.exceptions.JedisDataException;

@RunWith(Parameterized.class)
public class RedisModulesConsolidatedConfigurationCommandsTest extends JedisCommandsTestBase {

public RedisModulesConsolidatedConfigurationCommandsTest(RedisProtocol redisProtocol) {
super(redisProtocol);
}

@org.junit.Ignore(value = "failing")
@Test
public void setSearchConfigGloballyTest() {
final String configParam = "search-default-dialect";
// confirm default - Redis 8.0-M03 has no default dialect
//assertEquals(Collections.singletonMap(configParam, "1"), jedis.configGet(configParam));
assertEquals(Collections.emptyMap(), jedis.configGet(configParam));

try {
assertEquals("OK", jedis.configSet(configParam, "2"));
assertEquals(Collections.singletonMap(configParam, "2"), jedis.configGet(configParam));

} finally {
// restore to default
assertEquals("OK", jedis.configSet(configParam, "1"));
}
}

@Test
public void setReadOnlySearchConfigTest() {
JedisDataException de = assertThrows(JedisDataException.class, () -> jedis.configSet("search-max-doctablesize", "10"));
assertThat(de.getMessage(), Matchers.not(Matchers.emptyOrNullString()));
}

@Test
public void getSearchConfigSettingTest() {
assertThat(jedis.configGet("search-timeout"), aMapWithSize(0)); // Redis 8.0-M03 has no default value
}

@Test
public void getTSConfigSettingTest() {
assertThat(jedis.configGet("ts-retention-policy"), aMapWithSize(1));
}

@Test
public void getBFConfigSettingTest() {
assertThat(jedis.configGet("bf-error-rate"), aMapWithSize(1));
}

@Test
public void getCFConfigSettingTest() {
assertThat(jedis.configGet("cf-initial-size"), aMapWithSize(1));
}

@Test
public void getAllConigSettings() {
assertThat(jedis.configGet("*").size(), Matchers.greaterThan(0));
}
}

This file was deleted.

1 change: 0 additions & 1 deletion src/test/resources/endpoints.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"standalone0": {
"password": "foobared",
"tls": false,
"endpoints": [
"redis://localhost:6379"
Expand Down

0 comments on commit bcb66d6

Please sign in to comment.