use of com.bakdata.quick.common.api.model.manager.creation.GatewayCreationData in project quick by bakdata.
the class GatewayControllerTest method shouldCreateGateway.
@Test
void shouldCreateGateway() throws JsonProcessingException {
when(this.gatewayService.createGateway(isNotNull())).thenReturn(Completable.complete());
final GatewayCreationData creationData = new GatewayCreationData(GATEWAY_NAME, 1, TAG, null);
this.client.toBlocking().exchange(POST("/gateway", new ObjectMapper().writeValueAsString(creationData)));
verify(this.gatewayService).createGateway(creationData);
}
use of com.bakdata.quick.common.api.model.manager.creation.GatewayCreationData in project quick by bakdata.
the class GatewayResourceLoaderTest method shouldCreateGatewayConfigMap.
@Test
void shouldCreateGatewayConfigMap() {
final GatewayCreationData gatewayCreationData = new GatewayCreationData(GATEWAY_NAME, REPLICAS, TAG, null);
final GatewayResources gatewayResources = this.loader.forCreation(gatewayCreationData, ResourcePrefix.GATEWAY);
final Optional<HasMetadata> hasMetadata = findResource(gatewayResources, ResourceKind.CONFIGMAP);
assertThat(hasMetadata).isPresent().get(InstanceOfAssertFactories.type(ConfigMap.class)).satisfies(configMap -> assertThat(configMap).extracting(ConfigMap::getData, InstanceOfAssertFactories.map(String.class, String.class)).containsOnlyKeys("schema.graphql"));
}
use of com.bakdata.quick.common.api.model.manager.creation.GatewayCreationData in project quick by bakdata.
the class GatewayResourceLoaderTest method shouldCreateGatewayMiddleware.
@Test
void shouldCreateGatewayMiddleware() {
final GatewayCreationData gatewayCreationData = new GatewayCreationData(GATEWAY_NAME, REPLICAS, TAG, null);
final GatewayResources gatewayResources = this.loader.forCreation(gatewayCreationData, ResourcePrefix.GATEWAY);
final Optional<HasMetadata> hasMetadata = findResource(gatewayResources, ResourceKind.MIDDLEWARE);
final String expected = ResourcePrefix.GATEWAY.getPrefix() + GATEWAY_NAME;
assertThat(hasMetadata).isPresent().get(InstanceOfAssertFactories.type(Middleware.class)).satisfies(middleware -> {
assertThat(middleware.getMetadata().getName()).isEqualTo(expected);
assertThat(middleware.getSpec().getStripPrefix().getPrefixes()).containsExactly("/gateway/" + GATEWAY_NAME);
});
}
use of com.bakdata.quick.common.api.model.manager.creation.GatewayCreationData in project quick by bakdata.
the class GatewayResourceLoaderTest method shouldCreateGatewayConfigMapWithSchema.
@Test
void shouldCreateGatewayConfigMapWithSchema() {
final GatewayCreationData gatewayCreationData = new GatewayCreationData(GATEWAY_NAME, REPLICAS, TAG, "something");
final GatewayResources gatewayResources = this.loader.forCreation(gatewayCreationData, ResourcePrefix.GATEWAY);
final Optional<HasMetadata> hasMetadata = findResource(gatewayResources, ResourceKind.CONFIGMAP);
assertThat(hasMetadata).isPresent().get(InstanceOfAssertFactories.type(ConfigMap.class)).satisfies(configMap -> assertThat(configMap).extracting(ConfigMap::getData, InstanceOfAssertFactories.map(String.class, String.class)).containsOnlyKeys("schema.graphql").extractingByKey("schema.graphql", InstanceOfAssertFactories.STRING).containsIgnoringWhitespaces("something"));
}
use of com.bakdata.quick.common.api.model.manager.creation.GatewayCreationData in project quick by bakdata.
the class GatewayResourceLoaderTest method shouldCreateGatewayDeployment.
@Test
void shouldCreateGatewayDeployment() {
final GatewayCreationData gatewayCreationData = new GatewayCreationData(GATEWAY_NAME, REPLICAS, TAG, null);
final GatewayResources gatewayResources = this.loader.forCreation(gatewayCreationData, ResourcePrefix.GATEWAY);
final Optional<HasMetadata> hasMetadata = findResource(gatewayResources, ResourceKind.DEPLOYMENT);
final String deploymentName = ResourcePrefix.GATEWAY.getPrefix() + GATEWAY_NAME;
final Map<String, String> labels = Map.of("app.kubernetes.io/component", "gateway", "app.kubernetes.io/managed-by", "quick", "app.kubernetes.io/name", deploymentName);
final Map<String, String> selectors = Map.of("app.kubernetes.io/component", "gateway", "app.kubernetes.io/name", deploymentName);
final Map<String, String> annotations = Map.of("d9p.io/fixed-tag", "true");
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_GATEWAY_IMAGE, TAG));
assertThat(deployment.getMetadata()).satisfies(metadata -> {
assertThat(metadata.getName()).isEqualTo(deploymentName);
assertThat(metadata.getLabels()).containsExactlyInAnyOrderEntriesOf(labels);
assertThat(metadata.getAnnotations()).containsExactlyInAnyOrderEntriesOf(annotations);
});
assertThat(deployment.getSpec()).satisfies(spec -> {
assertThat(spec.getReplicas()).isEqualTo(REPLICAS);
assertThat(spec.getSelector().getMatchLabels()).containsExactlyInAnyOrderEntriesOf(selectors);
assertThat(spec.getTemplate().getMetadata().getLabels()).containsExactlyInAnyOrderEntriesOf(labels);
});
assertThat(deployment.getSpec().getTemplate().getSpec().getVolumes()).hasSize(2).first().hasFieldOrPropertyWithValue("name", "log4j-config").extracting(Volume::getConfigMap).satisfies(configmap -> {
assertThat(configmap.getName()).isEqualTo("quick-log4j");
assertThat(configmap.getItems()).hasSize(1).first().hasFieldOrPropertyWithValue("key", "log4j2.yaml").hasFieldOrPropertyWithValue("path", "log4j2.yaml");
});
assertThat(deployment.getSpec().getTemplate().getSpec().getVolumes()).hasSize(2).element(1).hasFieldOrPropertyWithValue("name", String.format("%s-config-volume", deploymentName)).extracting(Volume::getConfigMap).satisfies(configmap -> assertThat(configmap.getName()).isEqualTo(String.format("%s-config", deploymentName)));
});
}
Aggregations