Search in sources :

Example 6 with BridgeExecutor

use of com.redhat.service.smartevents.shard.operator.resources.BridgeExecutor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgeExecutorServiceTest method testBridgeExecutorCreation.

@Test
public void testBridgeExecutorCreation() {
    // Given
    ProcessorDTO dto = TestSupport.newRequestedProcessorDTO();
    // When
    bridgeExecutorService.createBridgeExecutor(dto);
    // Then
    BridgeExecutor bridgeExecutor = kubernetesClient.resources(BridgeExecutor.class).inNamespace(customerNamespaceProvider.resolveName(dto.getCustomerId())).withName(BridgeExecutor.resolveResourceName(dto.getId())).get();
    assertThat(bridgeExecutor).isNotNull();
    assertThat(bridgeExecutor.getSpec().getOwner()).isEqualTo(dto.getOwner());
    Secret secret = fetchBridgeExecutorSecret(dto);
    assertThat(secret).isNotNull();
    assertThat(secret.getMetadata().getName()).isEqualTo(bridgeExecutor.getMetadata().getName());
    assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_BOOTSTRAP_SERVERS_ENV_VAR)).isNotEmpty();
    assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_CLIENT_ID_ENV_VAR)).isNotEmpty();
    assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_CLIENT_SECRET_ENV_VAR)).isNotEmpty();
    assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_SECURITY_PROTOCOL_ENV_VAR)).isNotEmpty();
    assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_TOPIC_ENV_VAR)).isNotEmpty();
    assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_ERROR_STRATEGY_ENV_VAR)).isNotEmpty();
    assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_ERROR_TOPIC_ENV_VAR)).isNotEmpty();
    assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_GROUP_ID_ENV_VAR)).isNotEmpty();
}
Also used : Secret(io.fabric8.kubernetes.api.model.Secret) ProcessorDTO(com.redhat.service.smartevents.infra.models.dto.ProcessorDTO) BridgeExecutor(com.redhat.service.smartevents.shard.operator.resources.BridgeExecutor) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 7 with BridgeExecutor

use of com.redhat.service.smartevents.shard.operator.resources.BridgeExecutor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgeExecutorControllerTest method testBridgeExecutorDeployment.

@Test
void testBridgeExecutorDeployment() {
    // Given
    BridgeExecutor bridgeExecutor = buildBridgeExecutor();
    deployBridgeExecutorSecret(bridgeExecutor);
    // When
    bridgeExecutorController.reconcile(bridgeExecutor, null);
    // Then
    Deployment deployment = kubernetesClient.apps().deployments().inNamespace(bridgeExecutor.getMetadata().getNamespace()).withName(bridgeExecutor.getMetadata().getName()).get();
    assertThat(deployment).isNotNull();
    assertThat(deployment.getMetadata().getOwnerReferences().size()).isEqualTo(1);
    assertThat(deployment.getMetadata().getLabels()).isNotNull();
    assertThat(deployment.getSpec().getSelector().getMatchLabels().size()).isEqualTo(1);
    assertThat(deployment.getSpec().getTemplate().getMetadata().getLabels()).isNotNull();
    assertThat(deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getImage()).isNotNull();
    assertThat(deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getName()).isNotNull();
}
Also used : Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) BridgeExecutor(com.redhat.service.smartevents.shard.operator.resources.BridgeExecutor) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 8 with BridgeExecutor

use of com.redhat.service.smartevents.shard.operator.resources.BridgeExecutor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgeExecutorControllerTest method testBridgeExecutorNewImage.

@Test
void testBridgeExecutorNewImage() {
    // Given
    BridgeExecutor bridgeExecutor = buildBridgeExecutor();
    String oldImage = "oldImage";
    bridgeExecutor.getSpec().setImage(oldImage);
    deployBridgeExecutorSecret(bridgeExecutor);
    // When
    UpdateControl<BridgeExecutor> updateControl = bridgeExecutorController.reconcile(bridgeExecutor, null);
    // Then
    assertThat(updateControl.isUpdateResource()).isTrue();
    // Should be restored
    assertThat(updateControl.getResource().getSpec().getImage()).isEqualTo(TestSupport.EXECUTOR_IMAGE);
}
Also used : BridgeExecutor(com.redhat.service.smartevents.shard.operator.resources.BridgeExecutor) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 9 with BridgeExecutor

use of com.redhat.service.smartevents.shard.operator.resources.BridgeExecutor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgeExecutorControllerTest method testCreateNewBridgeExecutorWithoutSecrets.

@Test
void testCreateNewBridgeExecutorWithoutSecrets() {
    // Given
    BridgeExecutor bridgeExecutor = buildBridgeExecutor();
    // When
    UpdateControl<BridgeExecutor> updateControl = bridgeExecutorController.reconcile(bridgeExecutor, null);
    // Then
    assertThat(updateControl.isNoUpdate()).isTrue();
}
Also used : BridgeExecutor(com.redhat.service.smartevents.shard.operator.resources.BridgeExecutor) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 10 with BridgeExecutor

use of com.redhat.service.smartevents.shard.operator.resources.BridgeExecutor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgeExecutorServiceTest method testBridgeIngressDeletion.

@Test
public void testBridgeIngressDeletion() {
    // Given
    ProcessorDTO dto = TestSupport.newRequestedProcessorDTO();
    // When
    bridgeExecutorService.createBridgeExecutor(dto);
    bridgeExecutorService.deleteBridgeExecutor(dto);
    // Then
    BridgeExecutor bridgeExecutor = kubernetesClient.resources(BridgeExecutor.class).inNamespace(customerNamespaceProvider.resolveName(dto.getCustomerId())).withName(BridgeExecutor.resolveResourceName(dto.getId())).get();
    assertThat(bridgeExecutor).isNull();
}
Also used : ProcessorDTO(com.redhat.service.smartevents.infra.models.dto.ProcessorDTO) BridgeExecutor(com.redhat.service.smartevents.shard.operator.resources.BridgeExecutor) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Aggregations

BridgeExecutor (com.redhat.service.smartevents.shard.operator.resources.BridgeExecutor)10 QuarkusTest (io.quarkus.test.junit.QuarkusTest)8 Test (org.junit.jupiter.api.Test)8 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)3 ProcessorDTO (com.redhat.service.smartevents.infra.models.dto.ProcessorDTO)2 Secret (io.fabric8.kubernetes.api.model.Secret)2 LabelsBuilder (com.redhat.service.smartevents.shard.operator.utils.LabelsBuilder)1 When (io.cucumber.java.en.When)1 Namespace (io.fabric8.kubernetes.api.model.Namespace)1 ObjectMetaBuilder (io.fabric8.kubernetes.api.model.ObjectMetaBuilder)1 SecretBuilder (io.fabric8.kubernetes.api.model.SecretBuilder)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1