Search in sources :

Example 6 with GatewayCreationData

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

the class KubernetesGatewayServiceTest method createGateway.

private void createGateway(final String gatewayName, final int replicas, @Nullable final String tag, @Nullable final String schema) {
    final GatewayCreationData creationData = new GatewayCreationData(gatewayName, replicas, tag, schema);
    final Throwable throwable = this.gatewayService.createGateway(creationData).blockingGet();
    Optional.ofNullable(throwable).ifPresent(Assertions::fail);
}
Also used : GatewayCreationData(com.bakdata.quick.common.api.model.manager.creation.GatewayCreationData) Assertions(org.junit.jupiter.api.Assertions)

Example 7 with GatewayCreationData

use of com.bakdata.quick.common.api.model.manager.creation.GatewayCreationData 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 8 with GatewayCreationData

use of com.bakdata.quick.common.api.model.manager.creation.GatewayCreationData 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 9 with GatewayCreationData

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

the class KubernetesGatewayServiceTest method shouldRejectDuplicateGatewayCreation.

@Test
void shouldRejectDuplicateGatewayCreation() {
    final GatewayCreationData creationData = new GatewayCreationData(GATEWAY_NAME, 1, null, null);
    final Throwable firstDeployment = this.gatewayService.createGateway(creationData).blockingGet();
    assertThat(firstDeployment).isNull();
    final Throwable invalidDeployment = this.gatewayService.createGateway(creationData).blockingGet();
    assertThat(invalidDeployment).isInstanceOf(BadArgumentException.class).hasMessageContaining(String.format("The resource with the name %s already exists", GATEWAY_NAME));
}
Also used : BadArgumentException(com.bakdata.quick.common.exception.BadArgumentException) GatewayCreationData(com.bakdata.quick.common.api.model.manager.creation.GatewayCreationData) KubernetesTest(com.bakdata.quick.manager.k8s.KubernetesTest) Test(org.junit.jupiter.api.Test)

Example 10 with GatewayCreationData

use of com.bakdata.quick.common.api.model.manager.creation.GatewayCreationData 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)

Aggregations

GatewayCreationData (com.bakdata.quick.common.api.model.manager.creation.GatewayCreationData)13 Test (org.junit.jupiter.api.Test)12 KubernetesTest (com.bakdata.quick.manager.k8s.KubernetesTest)11 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)7 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)7 DeploymentConfig (com.bakdata.quick.manager.config.DeploymentConfig)5 KubernetesResources (com.bakdata.quick.manager.k8s.KubernetesResources)5 GatewayClient (com.bakdata.quick.common.api.client.GatewayClient)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 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)3 ObjectMeta (io.fabric8.kubernetes.api.model.ObjectMeta)2 PodSpec (io.fabric8.kubernetes.api.model.PodSpec)2 ServiceSpec (io.fabric8.kubernetes.api.model.ServiceSpec)2 IngressSpec (io.fabric8.kubernetes.api.model.networking.v1.IngressSpec)2 BadArgumentException (com.bakdata.quick.common.exception.BadArgumentException)1 TestUtil (com.bakdata.quick.manager.TestUtil)1 Middleware (com.bakdata.quick.manager.k8s.middleware.Middleware)1