use of org.entando.kubernetes.controller.coordinator.common.SimpleKubernetesClientDouble in project entando-k8s-controller-coordinator by entando-k8s.
the class ConfigListenerTest method shouldKillTheOperator.
@Test
void shouldKillTheOperator() {
System.setProperty(EntandoOperatorSpiConfigProperty.ENTANDO_CONTROLLER_POD_NAME.getJvmSystemProperty(), "my-pod");
// Given the operator is alive and listening to K8S resource events
final File file = Paths.get("/tmp/EntandoControllerCoordinator.ready").toFile();
Liveness.alive();
assertTrue(file.exists());
final ConfigListener configListener = new ConfigListener(new SimpleKubernetesClientDouble());
// When the Operator loses the connection to the ConfigMap listener
configListener.onClose(new WatcherException("Something went wrong"));
// Then the operator has been killed
assertFalse(file.exists());
}
use of org.entando.kubernetes.controller.coordinator.common.SimpleKubernetesClientDouble in project entando-k8s-controller-coordinator by entando-k8s.
the class ConfigListenerTest method shoulReflectLatestConfig.
@Test
void shoulReflectLatestConfig() {
// Given the operator is alive and listening to K8S resource events
final ConfigListener configListener = new ConfigListener(new SimpleKubernetesClientDouble());
// When the entando-operator-config configmap is updated
configListener.eventReceived(Action.MODIFIED, new ConfigMapBuilder().withNewMetadata().withName("some-map").withNamespace("some-namespce").endMetadata().addToData(ControllerCoordinatorProperty.ENTANDO_K8S_CONTROLLER_REMOVAL_DELAY.getJvmSystemProperty(), "400").build());
// Then the latest property value reflects
assertThat(EntandoOperatorConfigBase.lookupProperty(ControllerCoordinatorProperty.ENTANDO_K8S_CONTROLLER_REMOVAL_DELAY).get(), is("400"));
}
use of org.entando.kubernetes.controller.coordinator.common.SimpleKubernetesClientDouble in project entando-k8s-controller-coordinator by entando-k8s.
the class TrustStoreSecretRegeneratorTest method testRegenerate.
@Test
void testRegenerate() {
final SimpleKubernetesClientDouble client = new SimpleKubernetesClientDouble();
Secret oldCaSecret = CertificateSecretHelper.buildCertificateSecretsFromDirectory(client.getControllerNamespace(), Paths.get("src", "test", "resources", "tls", "ampie.dynu.net")).get(0);
client.overwriteControllerSecret(oldCaSecret);
TrustStoreSecretRegenerator.regenerateIfNecessary(client);
Secret oldTrustStoreSecret = client.loadControllerSecret(TrustStoreHelper.DEFAULT_TRUSTSTORE_SECRET);
assertThat(oldTrustStoreSecret, notNullValue());
Secret newCaSecret = client.loadControllerSecret(EntandoOperatorSpiConfig.getCertificateAuthoritySecretName().get());
// add file
newCaSecret.getData().put("some-other.crt", oldCaSecret.getData().get("ca.crt"));
client.overwriteControllerSecret(newCaSecret);
TrustStoreSecretRegenerator.regenerateIfNecessary(client);
Secret newTrustStoreSecret = client.loadControllerSecret(TrustStoreHelper.DEFAULT_TRUSTSTORE_SECRET);
assertThat(newTrustStoreSecret, notNullValue());
assertNotEquals(newTrustStoreSecret.getMetadata().getResourceVersion(), oldTrustStoreSecret.getMetadata().getResourceVersion());
}
Aggregations