Search in sources :

Example 16 with MirrorCreationData

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

the class ImageUpdaterTest method shouldNotUpdateFixedMirror.

@Test
void shouldNotUpdateFixedMirror() {
    final MirrorResourceLoader loader = new MirrorResourceLoader(new KubernetesResources(), this.getDeploymentConfig(), this.getResourceConfig());
    final MirrorService mirrorService = new KubernetesMirrorService(new KubernetesResources(), this.getManagerClient(), this.getDeploymentConfig(), loader);
    final MirrorCreationData mirrorCreationData = new MirrorCreationData("topic", "service", 1, // use default tag
    FIXED_TAG, null);
    mirrorService.createMirror(mirrorCreationData).blockingAwait();
    assertThat(this.getDeployments()).hasSize(1).first().extracting(ImageUpdaterTest::getContainerImage).isEqualTo(String.format("%s/%s:%s", DOCKER_REGISTRY, MIRROR_IMAGE, FIXED_TAG));
    final DeploymentConfig newDeploymentConfig = this.createNewDeploymentConfig();
    final ImageUpdater imageUpdater = new ImageUpdater(this.client, newDeploymentConfig);
    imageUpdater.updateManagedDeployments();
    assertThat(this.getDeployments()).hasSize(1).first().extracting(ImageUpdaterTest::getContainerImage).isEqualTo(String.format("%s/%s:%s", DOCKER_REGISTRY, MIRROR_IMAGE, FIXED_TAG));
}
Also used : MirrorResourceLoader(com.bakdata.quick.manager.mirror.resources.MirrorResourceLoader) KubernetesMirrorService(com.bakdata.quick.manager.mirror.KubernetesMirrorService) MirrorService(com.bakdata.quick.manager.mirror.MirrorService) KubernetesResources(com.bakdata.quick.manager.k8s.KubernetesResources) KubernetesMirrorService(com.bakdata.quick.manager.mirror.KubernetesMirrorService) DeploymentConfig(com.bakdata.quick.manager.config.DeploymentConfig) MirrorCreationData(com.bakdata.quick.common.api.model.manager.creation.MirrorCreationData) KubernetesTest(com.bakdata.quick.manager.k8s.KubernetesTest) Test(org.junit.jupiter.api.Test)

Example 17 with MirrorCreationData

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

the class ImageUpdaterTest method shouldUpdateMirror.

@Test
void shouldUpdateMirror() {
    final MirrorResourceLoader loader = new MirrorResourceLoader(new KubernetesResources(), this.getDeploymentConfig(), this.getResourceConfig());
    final MirrorService mirrorService = new KubernetesMirrorService(new KubernetesResources(), this.getManagerClient(), this.getDeploymentConfig(), loader);
    final MirrorCreationData mirrorCreationData = new MirrorCreationData("topic", "service", 1, // use default tag
    null, null);
    mirrorService.createMirror(mirrorCreationData).blockingAwait();
    assertThat(this.getDeployments()).hasSize(1).first().extracting(ImageUpdaterTest::getContainerImage).isEqualTo(String.format("%s/%s:%s", DOCKER_REGISTRY, MIRROR_IMAGE, DEFAULT_IMAGE_TAG));
    final DeploymentConfig newDeploymentConfig = this.createNewDeploymentConfig();
    final ImageUpdater imageUpdater = new ImageUpdater(this.client, newDeploymentConfig);
    imageUpdater.updateManagedDeployments();
    assertThat(this.getDeployments()).hasSize(1).first().extracting(ImageUpdaterTest::getContainerImage).isEqualTo(String.format("%s/%s:%s", DOCKER_REGISTRY, MIRROR_IMAGE, NEW_TAG));
}
Also used : MirrorResourceLoader(com.bakdata.quick.manager.mirror.resources.MirrorResourceLoader) KubernetesMirrorService(com.bakdata.quick.manager.mirror.KubernetesMirrorService) MirrorService(com.bakdata.quick.manager.mirror.MirrorService) KubernetesResources(com.bakdata.quick.manager.k8s.KubernetesResources) KubernetesMirrorService(com.bakdata.quick.manager.mirror.KubernetesMirrorService) DeploymentConfig(com.bakdata.quick.manager.config.DeploymentConfig) MirrorCreationData(com.bakdata.quick.common.api.model.manager.creation.MirrorCreationData) KubernetesTest(com.bakdata.quick.manager.k8s.KubernetesTest) Test(org.junit.jupiter.api.Test)

Example 18 with MirrorCreationData

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

the class MirrorControllerTest method shouldCreateMirrorWithDefaultReplica.

@Test
void shouldCreateMirrorWithDefaultReplica() {
    when(this.service.createMirror(any())).thenReturn(Completable.complete());
    final MirrorCreationData mirrorCreationData = new MirrorCreationData(NAME, NAME, DEFAULT_REPLICA, TAG, null);
    this.httpClient.toBlocking().exchange(POST("topic/mirror", mirrorCreationData));
    verify(this.service).createMirror(mirrorCreationData);
}
Also used : MirrorCreationData(com.bakdata.quick.common.api.model.manager.creation.MirrorCreationData) Test(org.junit.jupiter.api.Test) MicronautTest(io.micronaut.test.extensions.junit5.annotation.MicronautTest)

Example 19 with MirrorCreationData

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

the class KubernetesMirrorServiceTest method shouldDeleteService.

@Test
void shouldDeleteService() {
    final MirrorCreationData mirrorCreationData = new MirrorCreationData(TOPIC_NAME, TOPIC_NAME, 1, null, null);
    this.createMirror(mirrorCreationData);
    assertThat(this.getServices()).isNotNull().hasSize(1);
    final Completable deleteRequest = this.mirrorService.deleteMirror(TOPIC_NAME);
    Optional.ofNullable(deleteRequest.blockingGet()).ifPresent(Assertions::fail);
    assertThat(this.getServices()).isNullOrEmpty();
}
Also used : Completable(io.reactivex.Completable) Assertions(org.junit.jupiter.api.Assertions) MirrorCreationData(com.bakdata.quick.common.api.model.manager.creation.MirrorCreationData) KubernetesTest(com.bakdata.quick.manager.k8s.KubernetesTest) Test(org.junit.jupiter.api.Test)

Example 20 with MirrorCreationData

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

the class KubernetesMirrorServiceTest method shouldRejectDuplicateMirrorCreation.

@Test
void shouldRejectDuplicateMirrorCreation() {
    final MirrorCreationData mirrorCreationData = new MirrorCreationData(TOPIC_NAME, TOPIC_NAME, 1, null, null);
    final Throwable firstDeployment = this.mirrorService.createMirror(mirrorCreationData).blockingGet();
    assertThat(firstDeployment).isNull();
    final Throwable invalidDeployment = this.mirrorService.createMirror(mirrorCreationData).blockingGet();
    assertThat(invalidDeployment).isInstanceOf(BadArgumentException.class).hasMessageContaining(String.format("The resource with the name %s already exists", TOPIC_NAME));
}
Also used : BadArgumentException(com.bakdata.quick.common.exception.BadArgumentException) 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