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);
}
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)));
}
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));
}
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));
}
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));
}
Aggregations