DATAREDIS-659 - Polishing.

Update JavaDoc and assert nullability contract.
Use slowlog-max-len in tests instead of maxclients avoiding potential ulimit errors.

Original Pull Request: #253
This commit is contained in:
Christoph Strobl
2017-07-07 13:34:31 +02:00
parent 4c88fe1794
commit eb3ad1e351
11 changed files with 374 additions and 142 deletions

View File

@@ -26,6 +26,7 @@ import org.springframework.data.redis.connection.RedisClusterNode;
/**
* @author Mark Paluch
* @author Christoph Strobl
*/
public class LettuceReactiveClusterServerCommandsTests extends LettuceReactiveClusterCommandsTestsBase {
@@ -132,25 +133,38 @@ public class LettuceReactiveClusterServerCommandsTests extends LettuceReactiveCl
@Test // DATAREDIS-659
public void setConfigShouldApplyConfiguration() throws InterruptedException {
StepVerifier.create(connection.serverCommands().setConfig("maxclients", "10000")) //
.expectNext("OK") //
.verifyComplete();
final String slowLogKey = "slowlog-max-len";
StepVerifier.create(connection.serverCommands().setConfig(NODE1, "maxclients", "9999")) //
.expectNext("OK") //
.verifyComplete();
String resetValue = connection.serverCommands().getConfig(slowLogKey).map(it -> {
if (it.containsKey(slowLogKey)) {
return it.get(slowLogKey);
}
return it.get("127.0.0.1:7379." + slowLogKey);
}).block().toString();
StepVerifier.create(connection.serverCommands().getConfig(NODE1, "maxclients")) //
.consumeNextWith(properties -> {
assertThat(properties).containsEntry("maxclients", "9999");
}) //
.verifyComplete();
try {
StepVerifier.create(connection.serverCommands().setConfig(slowLogKey, resetValue)) //
.expectNext("OK") //
.verifyComplete();
StepVerifier.create(connection.serverCommands().getConfig(NODE2, "maxclients")) //
.consumeNextWith(properties -> {
assertThat(properties).containsEntry("maxclients", "10000");
}) //
.verifyComplete();
StepVerifier.create(connection.serverCommands().setConfig(NODE1, slowLogKey, "127")) //
.expectNext("OK") //
.verifyComplete();
StepVerifier.create(connection.serverCommands().getConfig(NODE1, slowLogKey)) //
.consumeNextWith(properties -> {
assertThat(properties).containsEntry(slowLogKey, "127");
}) //
.verifyComplete();
StepVerifier.create(connection.serverCommands().getConfig(NODE2, slowLogKey)) //
.consumeNextWith(properties -> {
assertThat(properties).containsEntry(slowLogKey, resetValue);
}) //
.verifyComplete();
} finally {
connection.serverCommands().setConfig(slowLogKey, resetValue).block();
}
}
@Test // DATAREDIS-659

View File

@@ -24,6 +24,7 @@ import org.junit.Test;
/**
* @author Mark Paluch
* @author Christoph Strobl
*/
public class LettuceReactiveServerCommandsTests extends LettuceReactiveCommandsTestsBase {
@@ -156,22 +157,35 @@ public class LettuceReactiveServerCommandsTests extends LettuceReactiveCommandsT
@Test // DATAREDIS-659
public void setConfigShouldApplyConfiguration() {
StepVerifier.create(connection.serverCommands().setConfig("maxclients", "9999")) //
.expectNext("OK") //
.verifyComplete();
final String slowLogKey = "slowlog-max-len";
if (connection instanceof LettuceReactiveRedisClusterConnection) {
StepVerifier.create(connection.serverCommands().getConfig("maxclients")) //
.consumeNextWith(properties -> {
assertThat(properties).containsEntry("127.0.0.1:7379.maxclients", "9999");
}) //
.verifyComplete();
} else {
StepVerifier.create(connection.serverCommands().getConfig("maxclients")) //
.consumeNextWith(properties -> {
assertThat(properties).containsEntry("maxclients", "9999");
}) //
String resetValue = connection.serverCommands().getConfig(slowLogKey).map(it -> {
if (it.containsKey(slowLogKey)) {
return it.get(slowLogKey);
}
return it.get("127.0.0.1:7379." + slowLogKey);
}).block().toString();
try {
StepVerifier.create(connection.serverCommands().setConfig(slowLogKey, "127")) //
.expectNext("OK") //
.verifyComplete();
if (connection instanceof LettuceReactiveRedisClusterConnection) {
StepVerifier.create(connection.serverCommands().getConfig(slowLogKey)) //
.consumeNextWith(properties -> {
assertThat(properties).containsEntry("127.0.0.1:7379." + slowLogKey, "127");
}) //
.verifyComplete();
} else {
StepVerifier.create(connection.serverCommands().getConfig(slowLogKey)) //
.consumeNextWith(properties -> {
assertThat(properties).containsEntry(slowLogKey, "127");
}) //
.verifyComplete();
}
} finally {
connection.serverCommands().setConfig(slowLogKey, resetValue).block();
}
}