Search in sources :

Example 6 with BridgeExecutor

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

the class BridgeExecutorSteps method deployBridgeIngressWithDefaultSecrets.

@When("^deploy BridgeExecutor with default secret:$")
public void deployBridgeIngressWithDefaultSecrets(String bridgeExecutorYaml) {
    InputStream resourceStream = new ByteArrayInputStream(bridgeExecutorYaml.getBytes(StandardCharsets.UTF_8));
    BridgeExecutor bridgeExecutor = context.getClient().resources(BridgeExecutor.class).inNamespace(context.getNamespace()).load(resourceStream).create();
    Secret secret = new SecretBuilder().withMetadata(new ObjectMetaBuilder().withNamespace(bridgeExecutor.getMetadata().getNamespace()).withName(bridgeExecutor.getMetadata().getName()).build()).build();
    context.getClient().secrets().inNamespace(bridgeExecutor.getMetadata().getNamespace()).withName(bridgeExecutor.getMetadata().getName()).createOrReplace(secret);
}
Also used : Secret(io.fabric8.kubernetes.api.model.Secret) SecretBuilder(io.fabric8.kubernetes.api.model.SecretBuilder) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) BridgeExecutor(com.redhat.service.bridge.shard.operator.resources.BridgeExecutor) ObjectMetaBuilder(io.fabric8.kubernetes.api.model.ObjectMetaBuilder) When(io.cucumber.java.en.When)

Example 7 with BridgeExecutor

use of com.redhat.service.bridge.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();
    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).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);
    assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_GROUP_ID_ENV_VAR).length()).isGreaterThan(0);
}
Also used : Secret(io.fabric8.kubernetes.api.model.Secret) ProcessorDTO(com.redhat.service.bridge.infra.models.dto.ProcessorDTO) BridgeExecutor(com.redhat.service.bridge.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.bridge.shard.operator.resources.BridgeExecutor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgeExecutorControllerTest method testBridgeExecutorDeployment_deploymentTimeoutFailure.

@Test
void testBridgeExecutorDeployment_deploymentTimeoutFailure() throws Exception {
    // Given
    BridgeExecutor bridgeExecutor = buildBridgeExecutor();
    deployBridgeExecutorSecret(bridgeExecutor);
    // When
    bridgeExecutorController.reconcile(bridgeExecutor, null);
    Deployment deployment = getDeploymentFor(bridgeExecutor);
    // Then
    kubernetesResourcePatcher.patchDeploymentAsTimeoutFailed(deployment.getMetadata().getName(), deployment.getMetadata().getNamespace());
    UpdateControl<BridgeExecutor> updateControl = bridgeExecutorController.reconcile(bridgeExecutor, null);
    assertThat(updateControl.isUpdateStatus()).isTrue();
    assertThat(updateControl.getResource().getStatus().getConditionByType(ConditionType.Ready).get().getReason()).isEqualTo(ConditionReason.DeploymentFailed);
    assertThat(updateControl.getResource().getStatus().getConditionByType(ConditionType.Augmentation).get().getStatus()).isEqualTo(ConditionStatus.False);
}
Also used : Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) BridgeExecutor(com.redhat.service.bridge.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.bridge.shard.operator.resources.BridgeExecutor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgeExecutorControllerTest method testCreateNewBridgeExecutor.

@Test
void testCreateNewBridgeExecutor() {
    // Given
    BridgeExecutor bridgeExecutor = buildBridgeExecutor();
    deployBridgeExecutorSecret(bridgeExecutor);
    // When
    UpdateControl<BridgeExecutor> updateControl = bridgeExecutorController.reconcile(bridgeExecutor, null);
    // Then
    assertThat(updateControl.isUpdateStatus()).isTrue();
    assertThat(bridgeExecutor.getStatus()).isNotNull();
    assertThat(bridgeExecutor.getStatus().isReady()).isFalse();
    assertThat(bridgeExecutor.getStatus().getConditionByType(ConditionType.Augmentation)).isPresent().hasValueSatisfying(c -> {
        assertThat(c.getStatus()).isEqualTo(ConditionStatus.False);
    });
    assertThat(bridgeExecutor.getStatus().getConditionByType(ConditionType.Ready)).isPresent().hasValueSatisfying(c -> {
        assertThat(c.getStatus()).isEqualTo(ConditionStatus.False);
        assertThat(c.getReason()).isEqualTo(ConditionReason.DeploymentNotAvailable);
    });
}
Also used : BridgeExecutor(com.redhat.service.bridge.shard.operator.resources.BridgeExecutor) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Aggregations

BridgeExecutor (com.redhat.service.bridge.shard.operator.resources.BridgeExecutor)9 QuarkusTest (io.quarkus.test.junit.QuarkusTest)7 Test (org.junit.jupiter.api.Test)7 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)3 ProcessorDTO (com.redhat.service.bridge.infra.models.dto.ProcessorDTO)2 Secret (io.fabric8.kubernetes.api.model.Secret)2 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