Search in sources :

Example 11 with BridgeIngress

use of com.redhat.service.bridge.shard.operator.resources.BridgeIngress 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);
}
Also used : BridgeIngress(com.redhat.service.bridge.shard.operator.resources.BridgeIngress) Secret(io.fabric8.kubernetes.api.model.Secret) BridgeDTO(com.redhat.service.bridge.infra.models.dto.BridgeDTO) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 12 with BridgeIngress

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

the class BridgeIngressControllerTest method testBridgeIngressDeployment.

@Test
void testBridgeIngressDeployment() {
    // Given
    BridgeIngress bridgeIngress = buildBridgeIngress();
    deployBridgeIngressSecret(bridgeIngress);
    // When
    bridgeIngressController.reconcile(bridgeIngress, null);
    // Then
    Deployment deployment = kubernetesClient.apps().deployments().inNamespace(bridgeIngress.getMetadata().getNamespace()).withName(bridgeIngress.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 : BridgeIngress(com.redhat.service.bridge.shard.operator.resources.BridgeIngress) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 13 with BridgeIngress

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

the class BridgeIngressControllerTest method testBridgeIngressDeployment_deploymentReplicaFailure.

@Test
void testBridgeIngressDeployment_deploymentReplicaFailure() throws Exception {
    // Given
    BridgeIngress bridgeIngress = buildBridgeIngress();
    deployBridgeIngressSecret(bridgeIngress);
    // When
    bridgeIngressController.reconcile(bridgeIngress, null);
    Deployment deployment = getDeploymentFor(bridgeIngress);
    // Then
    kubernetesResourcePatcher.patchDeploymentAsReplicaFailed(deployment.getMetadata().getName(), deployment.getMetadata().getNamespace());
    UpdateControl<BridgeIngress> updateControl = bridgeIngressController.reconcile(bridgeIngress, 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 : BridgeIngress(com.redhat.service.bridge.shard.operator.resources.BridgeIngress) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 14 with BridgeIngress

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

the class BridgeIngressControllerTest method testCreateNewBridgeIngressWithoutSecrets.

@Test
void testCreateNewBridgeIngressWithoutSecrets() {
    // Given
    BridgeIngress bridgeIngress = buildBridgeIngress();
    // When
    UpdateControl<BridgeIngress> updateControl = bridgeIngressController.reconcile(bridgeIngress, null);
    // Then
    assertThat(updateControl.isNoUpdate()).isTrue();
}
Also used : BridgeIngress(com.redhat.service.bridge.shard.operator.resources.BridgeIngress) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 15 with BridgeIngress

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

the class KubernetesNetworkingService method buildIngress.

private Ingress buildIngress(BridgeIngress bridgeIngress, Service service) {
    Ingress ingress = templateProvider.loadBridgeIngressKubernetesIngressTemplate(bridgeIngress);
    IngressBackend ingressBackend = new IngressBackendBuilder().withService(new IngressServiceBackendBuilder().withName(service.getMetadata().getName()).withPort(new ServiceBackendPortBuilder().withNumber(service.getSpec().getPorts().get(0).getPort()).build()).build()).build();
    HTTPIngressPath httpIngressPath = new HTTPIngressPathBuilder().withBackend(ingressBackend).withPath("/" + service.getMetadata().getName() + PATH_REGEX).withPathType("Prefix").build();
    IngressRule ingressRule = new IngressRuleBuilder().withHttp(new HTTPIngressRuleValueBuilder().withPaths(httpIngressPath).build()).build();
    IngressSpec ingressSpec = new IngressSpecBuilder().withRules(ingressRule).build();
    ingress.setSpec(ingressSpec);
    return ingress;
}
Also used : IngressRuleBuilder(io.fabric8.kubernetes.api.model.networking.v1.IngressRuleBuilder) IngressSpec(io.fabric8.kubernetes.api.model.networking.v1.IngressSpec) IngressRule(io.fabric8.kubernetes.api.model.networking.v1.IngressRule) IngressBackendBuilder(io.fabric8.kubernetes.api.model.networking.v1.IngressBackendBuilder) HTTPIngressRuleValueBuilder(io.fabric8.kubernetes.api.model.networking.v1.HTTPIngressRuleValueBuilder) IngressSpecBuilder(io.fabric8.kubernetes.api.model.networking.v1.IngressSpecBuilder) IngressServiceBackendBuilder(io.fabric8.kubernetes.api.model.networking.v1.IngressServiceBackendBuilder) ServiceBackendPortBuilder(io.fabric8.kubernetes.api.model.networking.v1.ServiceBackendPortBuilder) Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress) BridgeIngress(com.redhat.service.bridge.shard.operator.resources.BridgeIngress) HTTPIngressPathBuilder(io.fabric8.kubernetes.api.model.networking.v1.HTTPIngressPathBuilder) HTTPIngressPath(io.fabric8.kubernetes.api.model.networking.v1.HTTPIngressPath) IngressBackend(io.fabric8.kubernetes.api.model.networking.v1.IngressBackend)

Aggregations

BridgeIngress (com.redhat.service.bridge.shard.operator.resources.BridgeIngress)16 QuarkusTest (io.quarkus.test.junit.QuarkusTest)11 Test (org.junit.jupiter.api.Test)11 BridgeDTO (com.redhat.service.bridge.infra.models.dto.BridgeDTO)6 Secret (io.fabric8.kubernetes.api.model.Secret)4 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)4 Ingress (io.fabric8.kubernetes.api.model.networking.v1.Ingress)3 Namespace (io.fabric8.kubernetes.api.model.Namespace)2 ObjectMetaBuilder (io.fabric8.kubernetes.api.model.ObjectMetaBuilder)2 SecretBuilder (io.fabric8.kubernetes.api.model.SecretBuilder)2 BridgeIngressService (com.redhat.service.bridge.shard.operator.BridgeIngressService)1 WithPrometheus (com.redhat.service.bridge.shard.operator.WithPrometheus)1 When (io.cucumber.java.en.When)1 Service (io.fabric8.kubernetes.api.model.Service)1 HTTPIngressPath (io.fabric8.kubernetes.api.model.networking.v1.HTTPIngressPath)1 HTTPIngressPathBuilder (io.fabric8.kubernetes.api.model.networking.v1.HTTPIngressPathBuilder)1 HTTPIngressRuleValueBuilder (io.fabric8.kubernetes.api.model.networking.v1.HTTPIngressRuleValueBuilder)1 IngressBackend (io.fabric8.kubernetes.api.model.networking.v1.IngressBackend)1 IngressBackendBuilder (io.fabric8.kubernetes.api.model.networking.v1.IngressBackendBuilder)1 IngressRule (io.fabric8.kubernetes.api.model.networking.v1.IngressRule)1