Search in sources :

Example 16 with BridgeIngress

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

Example 17 with BridgeIngress

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

the class BridgeIngressServiceTest method waitUntilBridgeIngressDoesntExist.

private void waitUntilBridgeIngressDoesntExist(BridgeDTO dto) {
    Awaitility.await().atMost(Duration.ofSeconds(30)).pollInterval(Duration.ofMillis(200)).untilAsserted(() -> {
        BridgeIngress bridgeIngress = fetchBridgeIngress(dto);
        assertThat(bridgeIngress).isNull();
    });
}
Also used : BridgeIngress(com.redhat.service.smartevents.shard.operator.resources.BridgeIngress)

Example 18 with BridgeIngress

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

the class BridgeIngressServiceTest method testBridgeIngressRedeployment.

@Test
public void testBridgeIngressRedeployment() {
    // Given
    BridgeDTO dto = TestSupport.newProvisioningBridgeDTO();
    String patchedCustomerId = TestSupport.CUSTOMER_ID + "-patched";
    // When
    bridgeIngressService.createBridgeIngress(dto);
    waitUntilBridgeIngressExists(dto);
    dto.setCustomerId(patchedCustomerId);
    bridgeIngressService.createBridgeIngress(dto);
    waitUntilBridgeIngressExists(dto);
    // Then
    BridgeIngress bridgeIngress = fetchBridgeIngress(dto);
    assertThat(bridgeIngress).isNotNull();
    assertThat(bridgeIngress.getSpec().getCustomerId()).isEqualTo(patchedCustomerId);
    assertThat(bridgeIngress.getSpec().getOwner()).isEqualTo(dto.getOwner());
    Secret secret = fetchBridgeIngressSecret(dto);
    assertThat(secret).isNotNull();
    assertThat(secret.getMetadata().getName()).isEqualTo(bridgeIngress.getMetadata().getName());
}
Also used : BridgeIngress(com.redhat.service.smartevents.shard.operator.resources.BridgeIngress) Secret(io.fabric8.kubernetes.api.model.Secret) BridgeDTO(com.redhat.service.smartevents.infra.models.dto.BridgeDTO) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 19 with BridgeIngress

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

the class KubernetesNetworkingService method fetchOrCreateNetworkIngress.

@Override
public NetworkResource fetchOrCreateNetworkIngress(BridgeIngress bridgeIngress, Service service) {
    Ingress expected = buildIngress(bridgeIngress, service);
    Ingress existing = client.network().v1().ingresses().inNamespace(service.getMetadata().getNamespace()).withName(service.getMetadata().getName()).get();
    if (existing == null || !expected.getSpec().equals(existing.getSpec())) {
        client.network().v1().ingresses().inNamespace(service.getMetadata().getNamespace()).withName(service.getMetadata().getName()).createOrReplace(expected);
        return buildNetworkingResource(expected);
    }
    return buildNetworkingResource(existing);
}
Also used : BridgeIngress(com.redhat.service.smartevents.shard.operator.resources.BridgeIngress) Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress)

Aggregations

BridgeIngress (com.redhat.service.smartevents.shard.operator.resources.BridgeIngress)19 QuarkusTest (io.quarkus.test.junit.QuarkusTest)12 Test (org.junit.jupiter.api.Test)12 BridgeDTO (com.redhat.service.smartevents.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.smartevents.shard.operator.BridgeIngressService)1 WithPrometheus (com.redhat.service.smartevents.shard.operator.WithPrometheus)1 LabelsBuilder (com.redhat.service.smartevents.shard.operator.utils.LabelsBuilder)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