Search in sources :

Example 1 with DeploymentConfig

use of com.bakdata.quick.manager.config.DeploymentConfig in project quick by bakdata.

the class ImageUpdaterTest method shouldUpdateMultipleGateways.

@Test
void shouldUpdateMultipleGateways() {
    final GatewayClient gatewayClient = Mockito.mock(GatewayClient.class);
    final GatewayResourceLoader loader = new GatewayResourceLoader(new KubernetesResources(), this.getDeploymentConfig(), this.getResourceConfig(), NAMESPACE);
    final GatewayService gatewayService = new KubernetesGatewayService(this.getManagerClient(), gatewayClient, new GraphQLToAvroConverter("test.avro"), loader);
    Completable.mergeArray(gatewayService.createGateway(new GatewayCreationData("gateway", 1, null, null)), gatewayService.createGateway(new GatewayCreationData("gateway2", 1, null, null))).blockingAwait();
    assertThat(this.getDeployments()).hasSize(2).extracting(ImageUpdaterTest::getContainerImage).allMatch(name -> name.equals(String.format("%s/%s:%s", DOCKER_REGISTRY, GatewayResources.GATEWAY_IMAGE, DEFAULT_IMAGE_TAG)));
    final DeploymentConfig newDeploymentConfig = this.createNewDeploymentConfig();
    final ImageUpdater imageUpdater = new ImageUpdater(this.client, newDeploymentConfig);
    imageUpdater.updateManagedDeployments();
    assertThat(this.getDeployments()).hasSize(2).extracting(ImageUpdaterTest::getContainerImage).allMatch(name -> name.equals(String.format("%s/%s:%s", DOCKER_REGISTRY, GatewayResources.GATEWAY_IMAGE, NEW_TAG)));
}
Also used : GraphQLToAvroConverter(com.bakdata.quick.manager.graphql.GraphQLToAvroConverter) GatewayCreationData(com.bakdata.quick.common.api.model.manager.creation.GatewayCreationData) GatewayClient(com.bakdata.quick.common.api.client.GatewayClient) KubernetesGatewayService(com.bakdata.quick.manager.gateway.KubernetesGatewayService) GatewayResourceLoader(com.bakdata.quick.manager.gateway.resource.GatewayResourceLoader) KubernetesResources(com.bakdata.quick.manager.k8s.KubernetesResources) DeploymentConfig(com.bakdata.quick.manager.config.DeploymentConfig) KubernetesGatewayService(com.bakdata.quick.manager.gateway.KubernetesGatewayService) GatewayService(com.bakdata.quick.manager.gateway.GatewayService) KubernetesTest(com.bakdata.quick.manager.k8s.KubernetesTest) Test(org.junit.jupiter.api.Test)

Example 2 with DeploymentConfig

use of com.bakdata.quick.manager.config.DeploymentConfig in project quick by bakdata.

the class ImageUpdaterTest method shouldNotUpdateFixedGateway.

@Test
void shouldNotUpdateFixedGateway() {
    final GatewayClient gatewayClient = Mockito.mock(GatewayClient.class);
    final GatewayResourceLoader loader = new GatewayResourceLoader(new KubernetesResources(), this.getDeploymentConfig(), this.getResourceConfig(), NAMESPACE);
    final GatewayService gatewayService = new KubernetesGatewayService(this.getManagerClient(), gatewayClient, new GraphQLToAvroConverter("test.avro"), loader);
    gatewayService.createGateway(new GatewayCreationData("gateway", 1, FIXED_TAG, null)).blockingAwait();
    assertThat(this.getDeployments()).hasSize(1).first().extracting(ImageUpdaterTest::getContainerImage).isEqualTo(String.format("%s/%s:%s", DOCKER_REGISTRY, GatewayResources.GATEWAY_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, GatewayResources.GATEWAY_IMAGE, FIXED_TAG));
}
Also used : GraphQLToAvroConverter(com.bakdata.quick.manager.graphql.GraphQLToAvroConverter) GatewayCreationData(com.bakdata.quick.common.api.model.manager.creation.GatewayCreationData) GatewayClient(com.bakdata.quick.common.api.client.GatewayClient) KubernetesGatewayService(com.bakdata.quick.manager.gateway.KubernetesGatewayService) GatewayResourceLoader(com.bakdata.quick.manager.gateway.resource.GatewayResourceLoader) KubernetesResources(com.bakdata.quick.manager.k8s.KubernetesResources) DeploymentConfig(com.bakdata.quick.manager.config.DeploymentConfig) KubernetesGatewayService(com.bakdata.quick.manager.gateway.KubernetesGatewayService) GatewayService(com.bakdata.quick.manager.gateway.GatewayService) KubernetesTest(com.bakdata.quick.manager.k8s.KubernetesTest) Test(org.junit.jupiter.api.Test)

Example 3 with DeploymentConfig

use of com.bakdata.quick.manager.config.DeploymentConfig in project quick by bakdata.

the class KubernetesTest method setUpTests.

/**
 * Set up new k8s server and config.
 */
@BeforeEach
public void setUpTests() {
    this.kubernetesServer.before();
    this.client = this.kubernetesServer.getClient();
    this.deploymentConfig = new DeploymentConfig(DOCKER_REGISTRY, DEFAULT_IMAGE_TAG, 1, Optional.of("quick.host.io"), true, "websecure");
    this.managerClient = new KubernetesManagerClient(this.client);
    this.resourceConfig = TestUtil.newResourceConfig();
}
Also used : DeploymentConfig(com.bakdata.quick.manager.config.DeploymentConfig) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with DeploymentConfig

use of com.bakdata.quick.manager.config.DeploymentConfig in project quick by bakdata.

the class ImageUpdaterTest method shouldUpdateGateway.

@Test
void shouldUpdateGateway() {
    final GatewayClient gatewayClient = Mockito.mock(GatewayClient.class);
    final GatewayResourceLoader loader = new GatewayResourceLoader(new KubernetesResources(), this.getDeploymentConfig(), this.getResourceConfig(), NAMESPACE);
    final GatewayService gatewayService = new KubernetesGatewayService(this.getManagerClient(), gatewayClient, new GraphQLToAvroConverter("test.avro"), loader);
    gatewayService.createGateway(new GatewayCreationData("gateway", 1, null, null)).blockingAwait();
    assertThat(this.getDeployments()).hasSize(1).first().extracting(ImageUpdaterTest::getContainerImage).isEqualTo(String.format("%s/%s:%s", DOCKER_REGISTRY, GatewayResources.GATEWAY_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, GatewayResources.GATEWAY_IMAGE, NEW_TAG));
}
Also used : GraphQLToAvroConverter(com.bakdata.quick.manager.graphql.GraphQLToAvroConverter) GatewayCreationData(com.bakdata.quick.common.api.model.manager.creation.GatewayCreationData) GatewayClient(com.bakdata.quick.common.api.client.GatewayClient) KubernetesGatewayService(com.bakdata.quick.manager.gateway.KubernetesGatewayService) GatewayResourceLoader(com.bakdata.quick.manager.gateway.resource.GatewayResourceLoader) KubernetesResources(com.bakdata.quick.manager.k8s.KubernetesResources) DeploymentConfig(com.bakdata.quick.manager.config.DeploymentConfig) KubernetesGatewayService(com.bakdata.quick.manager.gateway.KubernetesGatewayService) GatewayService(com.bakdata.quick.manager.gateway.GatewayService) KubernetesTest(com.bakdata.quick.manager.k8s.KubernetesTest) Test(org.junit.jupiter.api.Test)

Example 5 with DeploymentConfig

use of com.bakdata.quick.manager.config.DeploymentConfig in project quick by bakdata.

the class ImageUpdaterTest method shouldUpdateMultipleMirrors.

@Test
void shouldUpdateMultipleMirrors() {
    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 mirrorCreationData1 = new MirrorCreationData("topic", "service", 1, // use default tag
    null, null);
    mirrorService.createMirror(mirrorCreationData1).blockingAwait();
    final MirrorCreationData mirrorCreationData2 = new MirrorCreationData("topic2", "service2", 1, // use default tag
    null, null);
    mirrorService.createMirror(mirrorCreationData2).blockingAwait();
    assertThat(this.getDeployments()).hasSize(2).extracting(ImageUpdaterTest::getContainerImage).allMatch(name -> name.equals(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(2).extracting(ImageUpdaterTest::getContainerImage).allMatch(name -> name.equals(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)

Aggregations

DeploymentConfig (com.bakdata.quick.manager.config.DeploymentConfig)8 KubernetesResources (com.bakdata.quick.manager.k8s.KubernetesResources)7 KubernetesTest (com.bakdata.quick.manager.k8s.KubernetesTest)7 Test (org.junit.jupiter.api.Test)7 GatewayCreationData (com.bakdata.quick.common.api.model.manager.creation.GatewayCreationData)4 GatewayClient (com.bakdata.quick.common.api.client.GatewayClient)3 MirrorCreationData (com.bakdata.quick.common.api.model.manager.creation.MirrorCreationData)3 GatewayService (com.bakdata.quick.manager.gateway.GatewayService)3 KubernetesGatewayService (com.bakdata.quick.manager.gateway.KubernetesGatewayService)3 GatewayResourceLoader (com.bakdata.quick.manager.gateway.resource.GatewayResourceLoader)3 GraphQLToAvroConverter (com.bakdata.quick.manager.graphql.GraphQLToAvroConverter)3 KubernetesMirrorService (com.bakdata.quick.manager.mirror.KubernetesMirrorService)3 MirrorService (com.bakdata.quick.manager.mirror.MirrorService)3 MirrorResourceLoader (com.bakdata.quick.manager.mirror.resources.MirrorResourceLoader)3 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)1 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)1 IngressSpec (io.fabric8.kubernetes.api.model.networking.v1.IngressSpec)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1