use of com.redhat.service.bridge.infra.models.dto.BridgeDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeIngressServiceTest method testFetchOrCreateBridgeIngressDeploymentRedeployment.
@Test
public void testFetchOrCreateBridgeIngressDeploymentRedeployment() {
// Given
BridgeDTO dto = TestSupport.newProvisioningBridgeDTO();
String patchedImage = TestSupport.INGRESS_IMAGE + "-patched";
// When
bridgeIngressService.createBridgeIngress(dto);
// Wait until deployment is created by the controller.
Awaitility.await().atMost(Duration.ofMinutes(2)).pollInterval(Duration.ofSeconds(5)).untilAsserted(() -> {
// The deployment is deployed by the controller
Deployment deployment = fetchBridgeIngressDeployment(dto);
assertThat(deployment).isNotNull();
});
// Patch the deployment and replace
Deployment deployment = fetchBridgeIngressDeployment(dto);
deployment.getSpec().getTemplate().getSpec().getContainers().get(0).setImage(patchedImage);
kubernetesClient.apps().deployments().inNamespace(deployment.getMetadata().getNamespace()).createOrReplace(deployment);
// Then
deployment = bridgeIngressService.fetchOrCreateBridgeIngressDeployment(fetchBridgeIngress(dto), fetchBridgeIngressSecret(dto));
assertThat(deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getImage()).isEqualTo(TestSupport.INGRESS_IMAGE);
}
use of com.redhat.service.bridge.infra.models.dto.BridgeDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeIngressServiceTest method testBridgeIngressCreationTriggersController.
@Test
public void testBridgeIngressCreationTriggersController() {
// Given
BridgeDTO dto = TestSupport.newProvisioningBridgeDTO();
// When
bridgeIngressService.createBridgeIngress(dto);
// Then
Awaitility.await().atMost(Duration.ofMinutes(2)).pollInterval(Duration.ofSeconds(5)).untilAsserted(() -> {
// The deployment is deployed by the controller
Deployment deployment = fetchBridgeIngressDeployment(dto);
assertThat(deployment).isNotNull();
assertThat(deployment.getSpec().getProgressDeadlineSeconds()).isEqualTo(60);
List<EnvVar> environmentVariables = deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getEnv();
assertThat(environmentVariables.stream().filter(x -> x.getName().equals(GlobalConfigurationsConstants.SSO_URL_CONFIG_ENV_VAR)).findFirst().get().getValue().length()).isGreaterThan(0);
assertThat(environmentVariables.stream().filter(x -> x.getName().equals(GlobalConfigurationsConstants.SSO_CLIENT_ID_CONFIG_ENV_VAR)).findFirst().get().getValue().length()).isGreaterThan(0);
assertThat(environmentVariables.stream().filter(x -> x.getName().equals(Constants.BRIDGE_INGRESS_CUSTOMER_ID_CONFIG_ENV_VAR)).findFirst().get().getValue().length()).isGreaterThan(0);
assertThat(environmentVariables.stream().filter(x -> x.getName().equals(Constants.BRIDGE_INGRESS_WEBHOOK_TECHNICAL_ACCOUNT_ID)).findFirst().get().getValue().length()).isGreaterThan(0);
});
}
use of com.redhat.service.bridge.infra.models.dto.BridgeDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeIngressServiceTest method testBridgeIngressDeletion.
@Test
public void testBridgeIngressDeletion() {
// Given
BridgeDTO dto = TestSupport.newProvisioningBridgeDTO();
// When
bridgeIngressService.createBridgeIngress(dto);
bridgeIngressService.deleteBridgeIngress(dto);
// Then
BridgeIngress bridgeIngress = fetchBridgeIngress(dto);
assertThat(bridgeIngress).isNull();
}
use of com.redhat.service.bridge.infra.models.dto.BridgeDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeIngressServiceTest method testBridgeIngressCreation.
@Test
public void testBridgeIngressCreation() {
// Given
BridgeDTO dto = TestSupport.newProvisioningBridgeDTO();
// When
bridgeIngressService.createBridgeIngress(dto);
// Then
BridgeIngress bridgeIngress = fetchBridgeIngress(dto);
assertThat(bridgeIngress).isNotNull();
Secret secret = fetchBridgeIngressSecret(dto);
assertThat(secret).isNotNull();
assertThat(secret.getMetadata().getName()).isEqualTo(bridgeIngress.getMetadata().getName());
assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_BOOTSTRAP_SERVERS_ENV_VAR).length()).isGreaterThan(0);
assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_CLIENT_ID_ENV_VAR).length()).isGreaterThan(0);
assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_CLIENT_SECRET_ENV_VAR).length()).isGreaterThan(0);
assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_SECURITY_PROTOCOL_ENV_VAR).length()).isGreaterThan(0);
assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_TOPIC_ENV_VAR).length()).isGreaterThan(0);
}
use of com.redhat.service.bridge.infra.models.dto.BridgeDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ManagerSyncServiceTest method testBridgesAreDeleted.
@Test
public void testBridgesAreDeleted() throws JsonProcessingException, InterruptedException {
List<BridgeDTO> bridgeDTOS = new ArrayList<>();
bridgeDTOS.add(new BridgeDTO("myId-1", "myName-1", "myEndpoint", "myCustomerId", ManagedResourceStatus.DEPROVISION, TestSupport.KAFKA_CONNECTION_DTO));
bridgeDTOS.add(new BridgeDTO("myId-2", "myName-2", "myEndpoint", "myCustomerId", ManagedResourceStatus.DEPROVISION, TestSupport.KAFKA_CONNECTION_DTO));
stubBridgesToDeployOrDelete(bridgeDTOS);
stubBridgeUpdate();
String expectedJsonUpdateRequest = "{\"id\": \"myId-1\", \"name\": \"myName-1\", \"endpoint\": \"myEndpoint\", \"customerId\": \"myCustomerId\", \"status\": \"deleting\"}";
// Two updates to the manager are expected
CountDownLatch latch = new CountDownLatch(2);
addBridgeUpdateRequestListener(latch);
managerSyncService.fetchAndProcessBridgesToDeployOrDelete().await().atMost(Duration.ofSeconds(5));
assertThat(latch.await(60, TimeUnit.SECONDS)).isTrue();
wireMockServer.verify(putRequestedFor(urlEqualTo(APIConstants.SHARD_API_BASE_PATH)).withRequestBody(equalToJson(expectedJsonUpdateRequest, true, true)).withHeader("Content-Type", equalTo("application/json")));
}
Aggregations