Skip to content

Commit bff9fc4

Browse files
author
Volchkov Andrey
committed
feat: switch off stop-writes-sys-memory-pct metric for aerosspike enterprise
1 parent 5f0a88b commit bff9fc4

File tree

4 files changed

+29
-10
lines changed

4 files changed

+29
-10
lines changed

embedded-aerospike-enterprise/src/main/java/com/playtika/testcontainers/aerospike/enterprise/AerospikeEnterpriseConfigurer.java

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,44 @@ public class AerospikeEnterpriseConfigurer {
1515
private final AerospikeProperties aerospikeProperties;
1616
private final AerospikeEnterpriseProperties enterpriseProperties;
1717

18-
public void configure(GenericContainer<?> aerospikeContainer) throws IOException, InterruptedException {
18+
public void configure(GenericContainer<?> aerospikeContainer) throws IOException, InterruptedException {
1919
if (aerospikeProperties.getFeatureKey() == null || aerospikeProperties.getFeatureKey().isEmpty()) {
2020
log.warn("Evaluation feature key file not provided by 'embedded.aerospike.featureKey' property. " +
2121
"Pay attention to license details: https://github.com/aerospike/aerospike-server.docker/blob/master/enterprise/ENTERPRISE_LICENSE");
2222
}
23-
23+
switchOffStopWritesSysMemoryPctMetric(aerospikeContainer);
2424
setupDisallowExpunge(aerospikeContainer);
2525
}
2626

27+
private void switchOffStopWritesSysMemoryPctMetric(GenericContainer<?> aerospikeContainer) throws IOException, InterruptedException {
28+
log.info("Switching off 'stop-writes-sys-memory-pct'...");
29+
String namespace = aerospikeProperties.getNamespace();
30+
Container.ExecResult result = aerospikeContainer.execInContainer("asadm", "--enable", "-e",
31+
String.format("manage config namespace %s param stop-writes-sys-memory-pct to 100", namespace));
32+
logStdout(result);
33+
if (result.getExitCode() != 0) {
34+
throw new IllegalStateException("Failed switch off 'stop-writes-sys-memory-pct': " + result.getStderr());
35+
}
36+
log.info("Success switching off 'stop-writes-sys-memory-pct'");
37+
}
38+
2739
private void setupDisallowExpunge(GenericContainer<?> aerospikeContainer) throws IOException, InterruptedException {
2840
if (!enterpriseProperties.isDurableDeletes()) {
2941
return;
3042
}
3143
log.info("Setting up 'disallow-expunge' to true...");
3244
String namespace = aerospikeProperties.getNamespace();
33-
Container.ExecResult result = aerospikeContainer.execInContainer("asadm", "-e",
34-
String.format("enable; manage config namespace %s param disallow-expunge to true", namespace));
35-
if (result.getStderr().length() > 0) {
45+
Container.ExecResult result = aerospikeContainer.execInContainer("asadm", "--enable", "-e",
46+
String.format("manage config namespace %s param disallow-expunge to true", namespace));
47+
logStdout(result);
48+
if (result.getExitCode() != 0) {
3649
throw new IllegalStateException("Failed to set up 'disallow-expunge' to true: " + result.getStderr());
3750
}
38-
log.info("Set up 'disallow-expunge' to true: {}", result.getStdout());
51+
log.info("Success setting up 'disallow-expunge' to true");
52+
}
53+
54+
private static void logStdout(Container.ExecResult result) {
55+
log.debug("Aerospike asadm util stdout: \n{}\n{}", result.getStdout(), result.getStderr());
3956
}
57+
4058
}

embedded-aerospike-enterprise/src/main/java/com/playtika/testcontainers/aerospike/enterprise/EnterpriseAerospikeTestOperationsAutoConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ public class EnterpriseAerospikeTestOperationsAutoConfiguration {
2121
@Bean
2222
@ConditionalOnProperty(value = "embedded.aerospike.time-travel.enabled", havingValue = "true", matchIfMissing = true)
2323
public ExpiredDocumentsCleaner expiredDocumentsCleaner(AerospikeClient client,
24+
AerospikeEnterpriseProperties aerospikeEnterpriseProperties,
2425
AerospikeProperties properties) {
25-
return new AerospikeExpiredDocumentsCleaner(client, properties.getNamespace(), true);
26+
return new AerospikeExpiredDocumentsCleaner(client, properties.getNamespace(), aerospikeEnterpriseProperties.isDurableDeletes());
2627
}
2728

2829
}

embedded-aerospike-enterprise/src/test/java/com/playtika/testcontainers/aerospike/enterprise/ValidateEnterpriseAerospikeBootstrapConfigurationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ void failOnNonEnterpriseImage() {
2020

2121
@Test
2222
void failOnUnsuitableEnterpriseImageVersion() {
23-
contextRunner.withPropertyValues("embedded.aerospike.dockerImage=aerospike/aerospike-server-enterprise:6.1.0.16_1")
23+
contextRunner.withPropertyValues("embedded.aerospike.dockerImage=aerospike/aerospike-server-enterprise:6.1.0.16")
2424
.run(context -> assertThat(context).hasFailed());
2525
}
2626

2727
@Test
2828
void skipValidation() {
29-
contextRunner.withPropertyValues("embedded.aerospike.dockerImage=aerospike-server:6.1.0.16_1",
29+
contextRunner.withPropertyValues("embedded.aerospike.dockerImage=aerospike-server:6.1.0.16",
3030
"embedded.aerospike.enabled=false")
3131
.run(context -> assertThat(context).hasNotFailed());
3232

embedded-aerospike-enterprise/src/test/resources/log4j2.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</Console>
77
</Appenders>
88
<Loggers>
9-
<Logger name="com.playtika.testcontainer" level="info"/>
9+
<Logger name="com.playtika.testcontainers" level="info"/>
1010
<Logger name="org.springframework" level="error"/>
1111
<Root level="error">
1212
<AppenderRef ref="Console"/>

0 commit comments

Comments
 (0)