-
Notifications
You must be signed in to change notification settings - Fork 244
switch off stop-writes-sys-memory-pct metric for aerosspike enterprise #1761
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,6 @@ | |
| import com.playtika.test.aerospike.AerospikeProperties; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.testcontainers.containers.Container; | ||
| import org.testcontainers.containers.GenericContainer; | ||
|
|
||
| import java.io.IOException; | ||
|
|
@@ -15,26 +14,29 @@ public class AerospikeEnterpriseConfigurer { | |
| private final AerospikeProperties aerospikeProperties; | ||
| private final AerospikeEnterpriseProperties enterpriseProperties; | ||
|
|
||
| public void configure(GenericContainer<?> aerospikeContainer) throws IOException, InterruptedException { | ||
| public void configure(GenericContainer<?> aerospikeContainer) throws IOException, InterruptedException { | ||
| if (aerospikeProperties.getFeatureKey() == null || aerospikeProperties.getFeatureKey().isEmpty()) { | ||
| log.warn("Evaluation feature key file not provided by 'embedded.aerospike.featureKey' property. " + | ||
| "Pay attention to license details: https://github.com/aerospike/aerospike-server.docker/blob/master/enterprise/ENTERPRISE_LICENSE"); | ||
| } | ||
|
|
||
| setupDisallowExpunge(aerospikeContainer); | ||
| } | ||
|
|
||
| private void setupDisallowExpunge(GenericContainer<?> aerospikeContainer) throws IOException, InterruptedException { | ||
| if (!enterpriseProperties.isDurableDeletes()) { | ||
| return; | ||
| } | ||
| log.info("Setting up 'disallow-expunge' to true..."); | ||
| String namespace = aerospikeProperties.getNamespace(); | ||
| Container.ExecResult result = aerospikeContainer.execInContainer("asadm", "-e", | ||
| String.format("enable; manage config namespace %s param disallow-expunge to true", namespace)); | ||
| if (result.getStderr().length() > 0) { | ||
| throw new IllegalStateException("Failed to set up 'disallow-expunge' to true: " + result.getStderr()); | ||
| AsadmCommandExecutor asadmCommandExecutor = new AsadmCommandExecutor(aerospikeContainer); | ||
|
|
||
| /* | ||
| By default, the value of this metric is 90%, we set it to 100% to prevent stopping writes for the Aerospike | ||
| Enterprise container during high consumption of system memory. For the Aerospike Community Edition, this metric is not used. | ||
| Documentation: https://aerospike.com/docs/server/reference/configuration#stop-writes-sys-memory-pct | ||
| */ | ||
| log.info("Switching off 'stop-writes-sys-memory-pct'... "); | ||
| asadmCommandExecutor.execute(String.format("manage config namespace %s param stop-writes-sys-memory-pct to 100", namespace)); | ||
| log.info("Success switching off 'stop-writes-sys-memory-pct'"); | ||
|
|
||
| if (enterpriseProperties.isDurableDeletes()) { | ||
| log.info("Setting up 'disallow-expunge' to true..."); | ||
| asadmCommandExecutor.execute(String.format("manage config namespace %s param disallow-expunge to true", namespace)); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why don't you check execute the result of the command? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is checked in AsadmCommandExecutor |
||
| log.info("Success setting up 'disallow-expunge' to true"); | ||
| } | ||
| log.info("Set up 'disallow-expunge' to true: {}", result.getStdout()); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| package com.playtika.testcontainers.aerospike.enterprise; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.testcontainers.containers.Container; | ||
| import org.testcontainers.containers.GenericContainer; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| @RequiredArgsConstructor | ||
| @Slf4j | ||
| public class AsadmCommandExecutor { | ||
|
|
||
| private final GenericContainer<?> aerospikeContainer; | ||
|
|
||
| public void execute(String command) throws IOException, InterruptedException { | ||
| Container.ExecResult result = aerospikeContainer.execInContainer("asadm", "--enable", "-e", command); | ||
| logStdout(result); | ||
| if (result.getExitCode() != 0 || isBadResponse(result)) { | ||
| throw new IllegalStateException(String.format("Failed to execute \"asadm --enable -e '%s'\": \nstdout:\n%s\nstderr:\n%s", | ||
| command, result.getStdout(), result.getStderr())); | ||
| } | ||
| } | ||
|
|
||
| private boolean isBadResponse(Container.ExecResult execResult) { | ||
| String stdout = execResult.getStdout(); | ||
| /* | ||
| Example of the stdout without error: | ||
| ~Set Namespace Param stop-writes-sys-memory-pct to 100~ | ||
| Node|Response | ||
| 728bb242e58c:3000|ok | ||
| Number of rows: 1 | ||
| */ | ||
| return !stdout.contains("|ok"); | ||
| } | ||
|
|
||
| private static void logStdout(Container.ExecResult result) { | ||
| log.debug("Aerospike asadm util stdout: \n{}\n{}", result.getStdout(), result.getStderr()); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package com.playtika.testcontainers.aerospike.enterprise; | ||
|
|
||
| import com.playtika.test.aerospike.AerospikeProperties; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.beans.factory.annotation.Qualifier; | ||
| import org.testcontainers.containers.GenericContainer; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThatExceptionOfType; | ||
|
|
||
| public class AsadmCommandExecutorTest extends BaseEnterpriseAerospikeTest { | ||
|
|
||
| @Autowired | ||
| @Qualifier(AerospikeProperties.AEROSPIKE_BEAN_NAME) | ||
| private GenericContainer<?> aerospikeContainer; | ||
|
|
||
| @Test | ||
| public void shouldFailCommandExecutionWithBadOption() { | ||
| AsadmCommandExecutor commandExecutor = new AsadmCommandExecutor(aerospikeContainer); | ||
| assertThatExceptionOfType(IllegalStateException.class) | ||
| .isThrownBy(() -> commandExecutor.execute("-tttttt")); | ||
| } | ||
|
|
||
| @Test | ||
| public void shouldFailCommandExecutionWithBadCommand() { | ||
| AsadmCommandExecutor commandExecutor = new AsadmCommandExecutor(aerospikeContainer); | ||
| assertThatExceptionOfType(IllegalStateException.class) | ||
| .isThrownBy(() -> commandExecutor.execute("manage config namespace NAMESPACE_NOT_EXISTS param disallow-expunge to true")); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,13 +20,13 @@ void failOnNonEnterpriseImage() { | |
|
|
||
| @Test | ||
| void failOnUnsuitableEnterpriseImageVersion() { | ||
| contextRunner.withPropertyValues("embedded.aerospike.dockerImage=aerospike/aerospike-server-enterprise:6.1.0.16_1") | ||
| contextRunner.withPropertyValues("embedded.aerospike.dockerImage=aerospike/aerospike-server-enterprise:6.1.0.16") | ||
wolfchkov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| .run(context -> assertThat(context).hasFailed()); | ||
| } | ||
|
|
||
| @Test | ||
| void skipValidation() { | ||
| contextRunner.withPropertyValues("embedded.aerospike.dockerImage=aerospike-server:6.1.0.16_1", | ||
| contextRunner.withPropertyValues("embedded.aerospike.dockerImage=aerospike-server:6.1.0.16", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not 16_1? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it just checks version format, no matter |
||
| "embedded.aerospike.enabled=false") | ||
| .run(context -> assertThat(context).hasNotFailed()); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you check execute the result of the command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is checked in AsadmCommandExecutor