@@ -20,6 +20,7 @@ import java.time.Duration;
|
||||
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;
|
||||
@@ -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;
|
||||
|
||||
@@ -158,7 +159,7 @@ class EventReloadConfigMapTest {
|
||||
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;
|
||||
});
|
||||
|
||||
@@ -168,7 +169,7 @@ class EventReloadConfigMapTest {
|
||||
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) {
|
||||
@@ -237,7 +238,7 @@ class EventReloadConfigMapTest {
|
||||
@Primary
|
||||
ConfigurationUpdateStrategy configurationUpdateStrategy() {
|
||||
return new ConfigurationUpdateStrategy("to-console", () -> {
|
||||
strategyCalled[0] = true;
|
||||
STRATEGY_CALLED.set(true);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Base64;
|
||||
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;
|
||||
@@ -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;
|
||||
|
||||
@@ -160,7 +161,7 @@ class EventReloadSecretTest {
|
||||
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;
|
||||
});
|
||||
|
||||
@@ -170,7 +171,7 @@ class EventReloadSecretTest {
|
||||
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) {
|
||||
@@ -242,7 +243,7 @@ class EventReloadSecretTest {
|
||||
@Primary
|
||||
ConfigurationUpdateStrategy configurationUpdateStrategy() {
|
||||
return new ConfigurationUpdateStrategy("to-console", () -> {
|
||||
strategyCalled[0] = true;
|
||||
STRATEGY_CALLED.set(true);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.time.Duration;
|
||||
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;
|
||||
@@ -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;
|
||||
|
||||
@@ -140,15 +141,18 @@ class PollingReloadConfigMapTest {
|
||||
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) {
|
||||
@@ -216,7 +220,7 @@ class PollingReloadConfigMapTest {
|
||||
@Primary
|
||||
ConfigurationUpdateStrategy configurationUpdateStrategy() {
|
||||
return new ConfigurationUpdateStrategy("to-console", () -> {
|
||||
strategyCalled[0] = true;
|
||||
STRATEGY_CALLED.set(true);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Base64;
|
||||
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;
|
||||
@@ -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;
|
||||
|
||||
@@ -141,7 +142,7 @@ class PollingReloadSecretTest {
|
||||
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;
|
||||
});
|
||||
|
||||
@@ -149,7 +150,7 @@ class PollingReloadSecretTest {
|
||||
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) {
|
||||
@@ -222,7 +223,7 @@ class PollingReloadSecretTest {
|
||||
@Primary
|
||||
ConfigurationUpdateStrategy configurationUpdateStrategy() {
|
||||
return new ConfigurationUpdateStrategy("to-console", () -> {
|
||||
strategyCalled[0] = true;
|
||||
STRATEGY_CALLED.set(true);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public final class ConfigReloadUtil {
|
||||
|
||||
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 {
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.time.Duration;
|
||||
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;
|
||||
@@ -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() {
|
||||
@@ -118,7 +119,7 @@ public class EventReloadConfigMapTest {
|
||||
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;
|
||||
});
|
||||
|
||||
@@ -132,7 +133,7 @@ public class EventReloadConfigMapTest {
|
||||
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) {
|
||||
@@ -197,7 +198,7 @@ public class EventReloadConfigMapTest {
|
||||
@Primary
|
||||
ConfigurationUpdateStrategy configurationUpdateStrategy() {
|
||||
return new ConfigurationUpdateStrategy("to-console", () -> {
|
||||
strategyCalled[0] = true;
|
||||
STRATEGY_CALLED.set(true);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Base64;
|
||||
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;
|
||||
@@ -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() {
|
||||
@@ -120,7 +121,7 @@ class EventReloadSecretTest {
|
||||
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;
|
||||
});
|
||||
|
||||
@@ -134,7 +135,7 @@ class EventReloadSecretTest {
|
||||
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) {
|
||||
@@ -204,7 +205,7 @@ class EventReloadSecretTest {
|
||||
@Primary
|
||||
ConfigurationUpdateStrategy configurationUpdateStrategy() {
|
||||
return new ConfigurationUpdateStrategy("to-console", () -> {
|
||||
strategyCalled[0] = true;
|
||||
STRATEGY_CALLED.set(true);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.time.Duration;
|
||||
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;
|
||||
@@ -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() {
|
||||
@@ -113,7 +114,7 @@ class PollingReloadConfigMapTest {
|
||||
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;
|
||||
});
|
||||
|
||||
@@ -121,7 +122,7 @@ class PollingReloadConfigMapTest {
|
||||
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) {
|
||||
@@ -187,7 +188,7 @@ class PollingReloadConfigMapTest {
|
||||
@Primary
|
||||
ConfigurationUpdateStrategy configurationUpdateStrategy() {
|
||||
return new ConfigurationUpdateStrategy("to-console", () -> {
|
||||
strategyCalled[0] = true;
|
||||
STRATEGY_CALLED.set(true);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Base64;
|
||||
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;
|
||||
@@ -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() {
|
||||
@@ -116,7 +117,7 @@ public class PollingReloadSecretTest {
|
||||
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;
|
||||
});
|
||||
|
||||
@@ -124,7 +125,7 @@ public class PollingReloadSecretTest {
|
||||
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) {
|
||||
@@ -194,7 +195,7 @@ public class PollingReloadSecretTest {
|
||||
@Primary
|
||||
ConfigurationUpdateStrategy configurationUpdateStrategy() {
|
||||
return new ConfigurationUpdateStrategy("to-console", () -> {
|
||||
strategyCalled[0] = true;
|
||||
STRATEGY_CALLED.set(true);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user