Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test modules CONFIG support #3103

Merged
merged 14 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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" ;;
sazzad16 marked this conversation as resolved.
Show resolved Hide resolved
"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,114 @@
/*
* 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;

/**
* 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);
}

ggivo marked this conversation as resolved.
Show resolved Hide resolved
@Test
public void getAllConfigSettings() {
assertThat(redis.configGet("*")).isNotEmpty();
}
sazzad16 marked this conversation as resolved.
Show resolved Hide resolved

}