use of com.google.monitoring.v3.Service in project quarkus by quarkusio.
the class KnativeWithTrafficSplittingTest method assertGeneratedResources.
@Test
public void assertGeneratedResources() throws IOException {
Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes");
assertThat(kubernetesDir).isDirectoryContaining(p -> p.getFileName().endsWith("knative.json")).isDirectoryContaining(p -> p.getFileName().endsWith("knative.yml")).satisfies(p -> assertThat(p.toFile().listFiles()).hasSize(2));
List<HasMetadata> kubernetesList = DeserializationUtil.deserializeAsList(kubernetesDir.resolve("knative.yml"));
assertThat(kubernetesList).filteredOn(i -> "Service".equals(i.getKind())).singleElement().satisfies(i -> {
assertThat(i).isInstanceOfSatisfying(Service.class, s -> {
assertThat(s.getSpec()).satisfies(spec -> {
assertThat(s.getMetadata()).satisfies(m -> {
assertThat(m.getName()).isEqualTo("knative-with-traffic-splitting");
});
assertThat(spec.getTemplate()).satisfies(template -> {
assertThat(template.getMetadata().getName()).isEqualTo("my-revision");
});
assertThat(spec.getTraffic()).singleElement().satisfies(t -> {
assertThat(t.getPercent()).isEqualTo(80);
});
});
});
});
}
use of com.google.monitoring.v3.Service in project quarkus by quarkusio.
the class KnativeWithRevisionAutoscalingTest method assertGeneratedResources.
@Test
public void assertGeneratedResources() throws IOException {
Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes");
assertThat(kubernetesDir).isDirectoryContaining(p -> p.getFileName().endsWith("knative.json")).isDirectoryContaining(p -> p.getFileName().endsWith("knative.yml")).satisfies(p -> assertThat(p.toFile().listFiles()).hasSize(2));
List<HasMetadata> kubernetesList = DeserializationUtil.deserializeAsList(kubernetesDir.resolve("knative.yml"));
assertThat(kubernetesList).filteredOn(i -> "Service".equals(i.getKind())).singleElement().satisfies(i -> {
Service service = (Service) i;
assertThat(service.getMetadata().getName()).isEqualTo(NAME);
// Issue: https://github.com/quarkusio/quarkus/issues/23832
// assertThat(service.getSpec().getTemplate().getSpec().getContainerConcurrency()).isEqualTo(5);
Map<String, String> annotations = service.getSpec().getTemplate().getMetadata().getAnnotations();
assertThat(annotations).contains(entry("autoscaling.knative.dev/class", "kpa.autoscaling.knative.dev"));
assertThat(annotations).contains(entry("autoscaling.knative.dev/metric", "cpu"));
assertThat(annotations).contains(entry("autoscaling.knative.dev/target-utilization-percentage", "55"));
assertThat(annotations).contains(entry("autoscaling.knative.dev/target", "80"));
});
}
use of com.google.monitoring.v3.Service in project quarkus by quarkusio.
the class KnativeWithSpecifiedContainerNameTest method assertGeneratedResources.
@Test
public void assertGeneratedResources() throws IOException {
Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes");
assertThat(kubernetesDir).isDirectoryContaining(p -> p.getFileName().endsWith("knative.json")).isDirectoryContaining(p -> p.getFileName().endsWith("knative.yml")).satisfies(p -> assertThat(p.toFile().listFiles()).hasSize(2));
List<HasMetadata> kubernetesList = DeserializationUtil.deserializeAsList(kubernetesDir.resolve("knative.yml"));
assertThat(kubernetesList).filteredOn(i -> "Service".equals(i.getKind())).singleElement().satisfies(i -> {
assertThat(i).isInstanceOfSatisfying(Service.class, s -> {
assertThat(s.getSpec()).satisfies(spec -> {
assertThat(s.getMetadata()).satisfies(m -> {
assertThat(m.getName()).isEqualTo("kfoo");
});
assertThat(spec.getTemplate().getSpec().getContainers()).singleElement().satisfies(container -> {
assertThat(container.getCommand()).contains("my-command");
assertThat(container.getName()).isEqualTo("kbar");
assertThat(container.getArgs()).containsExactly("A", "B");
});
});
});
});
}
use of com.google.monitoring.v3.Service in project quarkus by quarkusio.
the class KnativeScaleBoundsTest method assertGeneratedResources.
@Test
public void assertGeneratedResources() throws IOException {
Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes");
assertThat(kubernetesDir).isDirectoryContaining(p -> p.getFileName().endsWith("knative.json")).isDirectoryContaining(p -> p.getFileName().endsWith("knative.yml")).satisfies(p -> assertThat(p.toFile().listFiles()).hasSize(2));
List<HasMetadata> kubernetesList = DeserializationUtil.deserializeAsList(kubernetesDir.resolve("knative.yml"));
assertThat(kubernetesList).filteredOn(i -> "Service".equals(i.getKind())).singleElement().satisfies(i -> {
Service service = (Service) i;
Map<String, String> annotations = service.getSpec().getTemplate().getMetadata().getAnnotations();
assertThat(annotations).contains(entry("autoscaling.knative.dev/minScale", "3"));
assertThat(annotations).contains(entry("autoscaling.knative.dev/maxScale", "5"));
});
}
use of com.google.monitoring.v3.Service in project quarkus by quarkusio.
the class KnativeWithApplicationPropertiesTest method assertGeneratedResources.
@Test
public void assertGeneratedResources() throws IOException {
Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes");
assertThat(kubernetesDir).isDirectoryContaining(p -> p.getFileName().endsWith("knative.json")).isDirectoryContaining(p -> p.getFileName().endsWith("knative.yml")).satisfies(p -> assertThat(p.toFile().listFiles()).hasSize(2));
List<HasMetadata> kubernetesList = DeserializationUtil.deserializeAsList(kubernetesDir.resolve("knative.yml"));
assertThat(kubernetesList).filteredOn(i -> "Service".equals(i.getKind())).singleElement().satisfies(i -> {
assertThat(i).isInstanceOfSatisfying(Service.class, s -> {
assertThat(s.getSpec()).satisfies(spec -> {
assertThat(s.getMetadata()).satisfies(m -> {
assertThat(m.getName()).isEqualTo("test-it");
assertThat(m.getLabels()).contains(entry("foo", "bar"));
assertThat(m.getAnnotations()).contains(entry("bar", "baz"));
assertThat(m.getNamespace()).isEqualTo("applications");
});
assertThat(spec.getTemplate()).satisfies(template -> {
assertThat(template.getSpec()).satisfies(templateSpec -> {
assertThat(templateSpec.getContainers()).hasSize(1).singleElement().satisfies(c -> {
assertThat(c.getPorts()).hasSize(1).singleElement().satisfies(p -> {
assertThat(p.getName()).isEqualTo("http1");
});
});
});
});
});
});
});
}
Aggregations