Skip to content

Commit

Permalink
Test modules CONFIG support (#3103)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
sazzad16 authored Jan 31, 2025
1 parent d76e39e commit 9dd83b1
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
run: |
# Map requested version to github or tag
case "${{ matrix.redis_version }}" in
"unstable") redis_branch="unstable" stack_version="8.0-M03-pre" ;;
"unstable") redis_branch="unstable" stack_version="8.0-M04-pre" ;;
"8.0") redis_branch="8.0" stack_version="8.0-M04-pre" ;;
"7.4") redis_branch="7.4" stack_version="rs-7.4.0-v2" ;;
"7.2") redis_branch="7.2" stack_version="rs-7.2.0-v14" ;;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/*
* Copyright 2011-Present, Redis Ltd. and Contributors
* All rights reserved.
*
* Licensed under the MIT License.
*
* This file contains contributions from third-party contributors
* licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.lettuce.core.commands;

import static io.lettuce.TestTags.INTEGRATION_TEST;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assumptions.assumeTrue;

import io.lettuce.core.*;
import io.lettuce.core.api.sync.RedisCommands;
import io.lettuce.test.condition.RedisConditions;

import org.junit.jupiter.api.*;

import java.util.Collections;
import java.util.Map;

/**
* Integration tests for {@link io.lettuce.core.api.sync.RedisServerCommands} with Redis modules since Redis 8.0.
*
* @author M Sazzadul Hoque
*/
@Tag(INTEGRATION_TEST)
public class ConsolidatedConfigurationCommandIntegrationTests extends RedisContainerIntegrationTests {

private static RedisClient client;

private static RedisCommands<String, String> redis;

@BeforeAll
public static void setup() {
RedisURI redisURI = RedisURI.Builder.redis("127.0.0.1").withPort(16379).build();

client = RedisClient.create(redisURI);
redis = client.connect().sync();
assumeTrue(RedisConditions.of(redis).hasVersionGreaterOrEqualsTo("7.9"));
}

@AfterAll
static void teardown() {
if (client != null) {
client.shutdown();
}
}

@BeforeEach
void setUp() {
redis.flushall();
}

@Test
public void setSearchConfigGloballyTest() {
final String configParam = "search-default-dialect";
// confirm default
assertThat(redis.configGet(configParam)).isEqualTo(Collections.singletonMap(configParam, "1"));

try {
assertThat(redis.configSet(configParam, "2")).isEqualTo("OK");
assertThat(redis.configGet(configParam)).isEqualTo(Collections.singletonMap(configParam, "2"));
} finally {
// restore to default
assertThat(redis.configSet(configParam, "1")).isEqualTo("OK");
}
}

@Test
public void setReadOnlySearchConfigTest() {
assertThatThrownBy(() -> redis.configSet("search-max-doctablesize", "10"))
.isInstanceOf(RedisCommandExecutionException.class);
}

@Test
public void getSearchConfigSettingTest() {
assertThat(redis.configGet("search-timeout")).hasSize(1);
}

@Test
public void getTSConfigSettingTest() {
assertThat(redis.configGet("ts-retention-policy")).hasSize(1);
}

@Test
public void getBFConfigSettingTest() {
assertThat(redis.configGet("bf-error-rate")).hasSize(1);
}

@Test
public void getCFConfigSettingTest() {
assertThat(redis.configGet("cf-initial-size")).hasSize(1);
}

@Test
public void getAllConfigSettings() {
assertThat(redis.configGet("*").keySet()).contains("search-default-dialect", "search-timeout", "ts-retention-policy",
"bf-error-rate", "cf-initial-size");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,11 @@ void configGetMultipleParameters() {
.containsEntry("hash-max-listpack-entries", "512");
}

@Test
public void getAllConfigSettings() {
assertThat(redis.configGet("*")).isNotEmpty();
}

@Test
void configResetstat() {
redis.get(key);
Expand Down

0 comments on commit 9dd83b1

Please sign in to comment.