Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;

import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.client.WireMock;
Expand Down Expand Up @@ -81,7 +82,7 @@ class EventReloadConfigMapTest {

private static final String NAMESPACE = "spring-k8s";

private static final boolean[] strategyCalled = new boolean[] { false };
private static final AtomicBoolean STRATEGY_CALLED = new AtomicBoolean(false);

private static CoreV1Api coreV1Api;

Expand Down Expand Up @@ -158,7 +159,7 @@ void test(CapturedOutput output) {
boolean two = output.getOut().contains("Failed to load source");
boolean three = output.getOut()
.contains("Reloadable condition was not satisfied, reload will not be triggered");
boolean updateStrategyNotCalled = !strategyCalled[0];
boolean updateStrategyNotCalled = !STRATEGY_CALLED.get();
return one && two && three && updateStrategyNotCalled;
});

Expand All @@ -168,7 +169,7 @@ void test(CapturedOutput output) {
Awaitility.await()
.atMost(Duration.ofSeconds(10))
.pollInterval(Duration.ofSeconds(1))
.until(() -> strategyCalled[0]);
.until(STRATEGY_CALLED::get);
}

private static V1ConfigMap configMap(String name, Map<String, String> data) {
Expand Down Expand Up @@ -237,7 +238,7 @@ KubernetesNamespaceProvider namespaceProvider(AbstractEnvironment environment) {
@Primary
ConfigurationUpdateStrategy configurationUpdateStrategy() {
return new ConfigurationUpdateStrategy("to-console", () -> {
strategyCalled[0] = true;
STRATEGY_CALLED.set(true);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;

import com.github.tomakehurst.wiremock.WireMockServer;
Expand Down Expand Up @@ -83,7 +84,7 @@ class EventReloadSecretTest {

private static final String NAMESPACE = "spring-k8s";

private static final boolean[] strategyCalled = new boolean[] { false };
private static final AtomicBoolean STRATEGY_CALLED = new AtomicBoolean(false);

private static CoreV1Api coreV1Api;

Expand Down Expand Up @@ -160,7 +161,7 @@ void test(CapturedOutput output) {
boolean two = output.getOut().contains("Failed to load source");
boolean three = output.getOut()
.contains("Reloadable condition was not satisfied, reload will not be triggered");
boolean updateStrategyNotCalled = !strategyCalled[0];
boolean updateStrategyNotCalled = !STRATEGY_CALLED.get();
return one && two && three && updateStrategyNotCalled;
});

Expand All @@ -170,7 +171,7 @@ void test(CapturedOutput output) {
Awaitility.await()
.atMost(Duration.ofSeconds(10))
.pollInterval(Duration.ofSeconds(1))
.until(() -> strategyCalled[0]);
.until(STRATEGY_CALLED::get);
}

private static V1Secret secret(String name, Map<String, String> data) {
Expand Down Expand Up @@ -242,7 +243,7 @@ KubernetesNamespaceProvider namespaceProvider(AbstractEnvironment environment) {
@Primary
ConfigurationUpdateStrategy configurationUpdateStrategy() {
return new ConfigurationUpdateStrategy("to-console", () -> {
strategyCalled[0] = true;
STRATEGY_CALLED.set(true);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;

import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.client.WireMock;
Expand Down Expand Up @@ -79,7 +80,7 @@ class PollingReloadConfigMapTest {

private static final String NAMESPACE = "spring-k8s";

private static final boolean[] strategyCalled = new boolean[] { false };
private static final AtomicBoolean STRATEGY_CALLED = new AtomicBoolean(false);

private static CoreV1Api coreV1Api;

Expand Down Expand Up @@ -140,15 +141,18 @@ void test(CapturedOutput output) {
boolean two = output.getOut().contains("Failed to load source");
boolean three = output.getOut()
.contains("Reloadable condition was not satisfied, reload will not be triggered");
boolean updateStrategyNotCalled = !strategyCalled[0];
boolean updateStrategyNotCalled = !STRATEGY_CALLED.get();
System.out.println("one: " + one + " two: " + two + " three: " + three + " updateStrategyNotCalled: " + updateStrategyNotCalled);
return one && two && three && updateStrategyNotCalled;
});

System.out.println("first assertion passed");

// it passes while reading 'configMapTwo'
Awaitility.await()
.atMost(Duration.ofSeconds(20))
.pollInterval(Duration.ofSeconds(1))
.until(() -> strategyCalled[0]);
.until(STRATEGY_CALLED::get);
}

private static V1ConfigMap configMap(String name, Map<String, String> data) {
Expand Down Expand Up @@ -216,7 +220,7 @@ KubernetesNamespaceProvider namespaceProvider(AbstractEnvironment environment) {
@Primary
ConfigurationUpdateStrategy configurationUpdateStrategy() {
return new ConfigurationUpdateStrategy("to-console", () -> {
strategyCalled[0] = true;
STRATEGY_CALLED.set(true);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;

import com.github.tomakehurst.wiremock.WireMockServer;
Expand Down Expand Up @@ -81,7 +82,7 @@ class PollingReloadSecretTest {

private static final String NAMESPACE = "spring-k8s";

private static final boolean[] strategyCalled = new boolean[] { false };
private static final AtomicBoolean STRATEGY_CALLED = new AtomicBoolean(false);

private static CoreV1Api coreV1Api;

Expand Down Expand Up @@ -141,15 +142,15 @@ void test(CapturedOutput output) {
boolean two = output.getOut().contains("Failed to load source");
boolean three = output.getOut()
.contains("Reloadable condition was not satisfied, reload will not be triggered");
boolean updateStrategyNotCalled = !strategyCalled[0];
boolean updateStrategyNotCalled = !STRATEGY_CALLED.get();
return one && two && three && updateStrategyNotCalled;
});

// it passes while reading 'secretTwo'
Awaitility.await()
.atMost(Duration.ofSeconds(20))
.pollInterval(Duration.ofSeconds(1))
.until(() -> strategyCalled[0]);
.until(STRATEGY_CALLED::get);
}

private static V1Secret secret(String name, Map<String, String> data) {
Expand Down Expand Up @@ -222,7 +223,7 @@ KubernetesNamespaceProvider namespaceProvider(AbstractEnvironment environment) {
@Primary
ConfigurationUpdateStrategy configurationUpdateStrategy() {
return new ConfigurationUpdateStrategy("to-console", () -> {
strategyCalled[0] = true;
STRATEGY_CALLED.set(true);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static boolean reload(PropertySourceLocator locator, ConfigurableEnvironm

boolean changed = changed(sourceFromK8s, existingSources);
if (changed) {
LOG.info("Detected change in config maps/secrets, reload will ne triggered");
LOG.info("Detected change in config maps/secrets, reload will be triggered");
return true;
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;

import io.fabric8.kubernetes.api.model.ConfigMap;
import io.fabric8.kubernetes.api.model.ConfigMapBuilder;
Expand Down Expand Up @@ -72,7 +73,7 @@ public class EventReloadConfigMapTest {

private static KubernetesClient kubernetesClient;

private static final boolean[] strategyCalled = new boolean[] { false };
private static final AtomicBoolean STRATEGY_CALLED = new AtomicBoolean(false);

@BeforeAll
static void beforeAll() {
Expand Down Expand Up @@ -118,7 +119,7 @@ void test(CapturedOutput output) {
boolean two = output.getOut().contains("Failed to load source");
boolean three = output.getOut()
.contains("Reloadable condition was not satisfied, reload will not be triggered");
boolean updateStrategyNotCalled = !strategyCalled[0];
boolean updateStrategyNotCalled = !STRATEGY_CALLED.get();
return one && two && three && updateStrategyNotCalled;
});

Expand All @@ -132,7 +133,7 @@ void test(CapturedOutput output) {
Awaitility.await()
.atMost(Duration.ofSeconds(10))
.pollInterval(Duration.ofSeconds(1))
.until(() -> strategyCalled[0]);
.until(STRATEGY_CALLED::get);
}

private static ConfigMap configMap(String name, Map<String, String> data) {
Expand Down Expand Up @@ -197,7 +198,7 @@ KubernetesNamespaceProvider namespaceProvider(AbstractEnvironment environment) {
@Primary
ConfigurationUpdateStrategy configurationUpdateStrategy() {
return new ConfigurationUpdateStrategy("to-console", () -> {
strategyCalled[0] = true;
STRATEGY_CALLED.set(true);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;

import io.fabric8.kubernetes.api.model.Secret;
Expand Down Expand Up @@ -75,7 +76,7 @@ class EventReloadSecretTest {

private static KubernetesClient kubernetesClient;

private static final boolean[] strategyCalled = new boolean[] { false };
private static final AtomicBoolean STRATEGY_CALLED = new AtomicBoolean(false);

@BeforeAll
static void beforeAll() {
Expand Down Expand Up @@ -120,7 +121,7 @@ void test(CapturedOutput output) {
boolean two = output.getOut().contains("Failed to load source");
boolean three = output.getOut()
.contains("Reloadable condition was not satisfied, reload will not be triggered");
boolean updateStrategyNotCalled = !strategyCalled[0];
boolean updateStrategyNotCalled = !STRATEGY_CALLED.get();
return one && two && three && updateStrategyNotCalled;
});

Expand All @@ -134,7 +135,7 @@ void test(CapturedOutput output) {
Awaitility.await()
.atMost(Duration.ofSeconds(10))
.pollInterval(Duration.ofSeconds(1))
.until(() -> strategyCalled[0]);
.until(STRATEGY_CALLED::get);
}

private static Secret secret(String name, Map<String, String> data) {
Expand Down Expand Up @@ -204,7 +205,7 @@ KubernetesNamespaceProvider namespaceProvider(AbstractEnvironment environment) {
@Primary
ConfigurationUpdateStrategy configurationUpdateStrategy() {
return new ConfigurationUpdateStrategy("to-console", () -> {
strategyCalled[0] = true;
STRATEGY_CALLED.set(true);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;

import io.fabric8.kubernetes.api.model.ConfigMap;
import io.fabric8.kubernetes.api.model.ConfigMapBuilder;
Expand Down Expand Up @@ -73,7 +74,7 @@ class PollingReloadConfigMapTest {

private static KubernetesClient kubernetesClient;

private static final boolean[] strategyCalled = new boolean[] { false };
private static final AtomicBoolean STRATEGY_CALLED = new AtomicBoolean(false);

@BeforeAll
static void beforeAll() {
Expand Down Expand Up @@ -113,15 +114,15 @@ void test(CapturedOutput output) {
boolean two = output.getOut().contains("Failed to load source");
boolean three = output.getOut()
.contains("Reloadable condition was not satisfied, reload will not be triggered");
boolean updateStrategyNotCalled = !strategyCalled[0];
boolean updateStrategyNotCalled = !STRATEGY_CALLED.get();
return one && two && three && updateStrategyNotCalled;
});

// it passes while reading 'configMapTwo'
Awaitility.await()
.atMost(Duration.ofSeconds(20))
.pollInterval(Duration.ofSeconds(1))
.until(() -> strategyCalled[0]);
.until(STRATEGY_CALLED::get);
}

private static ConfigMap configMap(String name, Map<String, String> data) {
Expand Down Expand Up @@ -187,7 +188,7 @@ KubernetesNamespaceProvider namespaceProvider(AbstractEnvironment environment) {
@Primary
ConfigurationUpdateStrategy configurationUpdateStrategy() {
return new ConfigurationUpdateStrategy("to-console", () -> {
strategyCalled[0] = true;
STRATEGY_CALLED.set(true);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;

import io.fabric8.kubernetes.api.model.Secret;
Expand Down Expand Up @@ -76,7 +77,7 @@ public class PollingReloadSecretTest {

private static KubernetesClient kubernetesClient;

private static final boolean[] strategyCalled = new boolean[] { false };
private static final AtomicBoolean STRATEGY_CALLED = new AtomicBoolean(false);

@BeforeAll
static void beforeAll() {
Expand Down Expand Up @@ -116,15 +117,15 @@ void test(CapturedOutput output) {
boolean two = output.getOut().contains("Failed to load source");
boolean three = output.getOut()
.contains("Reloadable condition was not satisfied, reload will not be triggered");
boolean updateStrategyNotCalled = !strategyCalled[0];
boolean updateStrategyNotCalled = !STRATEGY_CALLED.get();
return one && two && three && updateStrategyNotCalled;
});

// it passes while reading 'secretTwo'
Awaitility.await()
.atMost(Duration.ofSeconds(20))
.pollInterval(Duration.ofSeconds(1))
.until(() -> strategyCalled[0]);
.until(STRATEGY_CALLED::get);
}

private static Secret secret(String name, Map<String, String> data) {
Expand Down Expand Up @@ -194,7 +195,7 @@ KubernetesNamespaceProvider namespaceProvider(AbstractEnvironment environment) {
@Primary
ConfigurationUpdateStrategy configurationUpdateStrategy() {
return new ConfigurationUpdateStrategy("to-console", () -> {
strategyCalled[0] = true;
STRATEGY_CALLED.set(true);
});
}

Expand Down
Loading