Search in sources :

Example 21 with MirrorCreationData

use of com.bakdata.quick.common.api.model.manager.creation.MirrorCreationData in project quick by bakdata.

the class MirrorResourceLoaderTest method shouldCreateDeploymentWithCustomTag.

@Test
void shouldCreateDeploymentWithCustomTag() {
    final String customTag = "my-tag";
    final MirrorCreationData mirrorCreationData = new MirrorCreationData(DEFAULT_NAME, DEFAULT_TOPIC_NAME, 1, customTag, null);
    final MirrorResources mirrorResources = this.loader.forCreation(mirrorCreationData, ResourcePrefix.MIRROR);
    final Optional<HasMetadata> hasMetadata = findResource(mirrorResources, ResourceKind.DEPLOYMENT);
    assertThat(hasMetadata).isPresent().get(InstanceOfAssertFactories.type(Deployment.class)).satisfies(deployment -> {
        final PodSpec podSpec = deployment.getSpec().getTemplate().getSpec();
        assertThat(podSpec.getContainers()).isNotNull().hasSize(1).first().hasFieldOrPropertyWithValue("image", getImage(DOCKER_REGISTRY, EXPECTED_MIRROR_IMAGE, customTag));
    });
}
Also used : HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) PodSpec(io.fabric8.kubernetes.api.model.PodSpec) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) MirrorCreationData(com.bakdata.quick.common.api.model.manager.creation.MirrorCreationData) KubernetesTest(com.bakdata.quick.manager.k8s.KubernetesTest) Test(org.junit.jupiter.api.Test)

Example 22 with MirrorCreationData

use of com.bakdata.quick.common.api.model.manager.creation.MirrorCreationData in project quick by bakdata.

the class MirrorResourceLoaderTest method shouldCreateServiceWithCustomTopicName.

@Test
void shouldCreateServiceWithCustomTopicName() {
    final String topicName = "__internal-test-topic";
    final String name = "test-topic";
    final MirrorCreationData mirrorCreationData = new MirrorCreationData(name, topicName, 1, null, null);
    final MirrorResources mirrorResources = this.loader.forCreation(mirrorCreationData, ResourcePrefix.MIRROR);
    final Optional<HasMetadata> hasMetadata = findResource(mirrorResources, ResourceKind.SERVICE);
    assertThat(hasMetadata).isPresent().get(InstanceOfAssertFactories.type(Service.class)).satisfies(service -> {
        final String deploymentName = ResourcePrefix.MIRROR.getPrefix() + name;
        assertThat(service.getMetadata()).hasFieldOrPropertyWithValue("name", deploymentName).extracting(ObjectMeta::getLabels, MAP).isNotNull().contains(Map.entry("app.kubernetes.io/name", deploymentName));
        final ServiceSpec serviceSpec = service.getSpec();
        assertThat(serviceSpec.getSelector()).contains(Map.entry("app.kubernetes.io/name", deploymentName));
    });
}
Also used : ObjectMeta(io.fabric8.kubernetes.api.model.ObjectMeta) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) ServiceSpec(io.fabric8.kubernetes.api.model.ServiceSpec) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) MirrorCreationData(com.bakdata.quick.common.api.model.manager.creation.MirrorCreationData) KubernetesTest(com.bakdata.quick.manager.k8s.KubernetesTest) Test(org.junit.jupiter.api.Test)

Example 23 with MirrorCreationData

use of com.bakdata.quick.common.api.model.manager.creation.MirrorCreationData in project quick by bakdata.

the class MirrorResourceLoaderTest method shouldSetRetentionTimeForDeployment.

@Test
void shouldSetRetentionTimeForDeployment() {
    final Duration retentionTime = Duration.ofHours(1);
    final MirrorCreationData mirrorCreationData = new MirrorCreationData(DEFAULT_NAME, DEFAULT_TOPIC_NAME, 1, null, retentionTime);
    final MirrorResources mirrorResources = this.loader.forCreation(mirrorCreationData, ResourcePrefix.MIRROR);
    final Optional<HasMetadata> hasMetadata = findResource(mirrorResources, ResourceKind.DEPLOYMENT);
    assertThat(hasMetadata).isPresent().get(InstanceOfAssertFactories.type(Deployment.class)).satisfies(deployment -> {
        final PodSpec podSpec = deployment.getSpec().getTemplate().getSpec();
        assertThat(podSpec.getContainers()).isNotNull().hasSize(1).first().extracting(Container::getArgs, LIST).isNotEmpty().contains("--input-topics=" + DEFAULT_TOPIC_NAME).contains("--retention-time=" + retentionTime);
    });
}
Also used : HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) PodSpec(io.fabric8.kubernetes.api.model.PodSpec) Duration(java.time.Duration) MirrorCreationData(com.bakdata.quick.common.api.model.manager.creation.MirrorCreationData) KubernetesTest(com.bakdata.quick.manager.k8s.KubernetesTest) Test(org.junit.jupiter.api.Test)

Aggregations

MirrorCreationData (com.bakdata.quick.common.api.model.manager.creation.MirrorCreationData)23 Test (org.junit.jupiter.api.Test)21 KubernetesTest (com.bakdata.quick.manager.k8s.KubernetesTest)17 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)7 KubernetesResources (com.bakdata.quick.manager.k8s.KubernetesResources)5 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)5 MirrorService (com.bakdata.quick.manager.mirror.MirrorService)4 MirrorResourceLoader (com.bakdata.quick.manager.mirror.resources.MirrorResourceLoader)4 PodSpec (io.fabric8.kubernetes.api.model.PodSpec)4 Service (io.fabric8.kubernetes.api.model.Service)4 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)4 Completable (io.reactivex.Completable)4 DeploymentConfig (com.bakdata.quick.manager.config.DeploymentConfig)3 KubernetesMirrorService (com.bakdata.quick.manager.mirror.KubernetesMirrorService)3 ObjectMeta (io.fabric8.kubernetes.api.model.ObjectMeta)3 ServiceSpec (io.fabric8.kubernetes.api.model.ServiceSpec)3 DeploymentSpec (io.fabric8.kubernetes.api.model.apps.DeploymentSpec)3 Duration (java.time.Duration)3 Assertions (org.junit.jupiter.api.Assertions)3 KafkaConfig (com.bakdata.quick.common.config.KafkaConfig)2