Search in sources :

Example 26 with Service

use of com.google.monitoring.v3.Service in project quarkus by quarkusio.

the class KnativeWithVolumesTest 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(spec.getTemplate()).satisfies(template -> {
                    assertThat(template.getSpec()).satisfies(revisionSpec -> {
                        assertThat(revisionSpec.getVolumes()).haveAtLeastOne(new Condition<Volume>(v -> v.getName().equals("client-crts") && v.getSecret().getSecretName().equals("clientcerts"), "Has secret volume named client-crts referencing secret clientcerts"));
                        assertThat(revisionSpec.getVolumes()).haveAtLeastOne(new Condition<Volume>(v -> v.getName().equals("client-cfg") && v.getConfigMap().getName().equals("clientconfig"), "Has config-map named client-cfg referencing configmap clientconfig"));
                        assertThat(revisionSpec.getContainers()).hasSize(1).singleElement().satisfies(c -> {
                            assertThat(c.getVolumeMounts()).haveAtLeastOne(new Condition<VolumeMount>(m -> m.getName().equals("client-crts"), "Has client-crts mount"));
                            assertThat(c.getVolumeMounts()).haveAtLeastOne(new Condition<VolumeMount>(m -> m.getName().equals("client-cfg"), "Has client-cfg mount"));
                            assertThat(c.getPorts()).hasSize(1).singleElement().satisfies(p -> {
                                assertThat(p.getName()).isEqualTo("http1");
                            });
                        });
                    });
                });
            });
        });
    });
}
Also used : Path(java.nio.file.Path) VolumeMount(io.fabric8.kubernetes.api.model.VolumeMount) QuarkusProdModeTest(io.quarkus.test.QuarkusProdModeTest) Service(io.fabric8.knative.serving.v1.Service) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) IOException(java.io.IOException) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) Test(org.junit.jupiter.api.Test) List(java.util.List) RegisterExtension(org.junit.jupiter.api.extension.RegisterExtension) Condition(org.assertj.core.api.Condition) ProdBuildResults(io.quarkus.test.ProdBuildResults) ProdModeTestResults(io.quarkus.test.ProdModeTestResults) Path(java.nio.file.Path) Volume(io.fabric8.kubernetes.api.model.Volume) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) Volume(io.fabric8.kubernetes.api.model.Volume) VolumeMount(io.fabric8.kubernetes.api.model.VolumeMount) QuarkusProdModeTest(io.quarkus.test.QuarkusProdModeTest) Test(org.junit.jupiter.api.Test)

Example 27 with Service

use of com.google.monitoring.v3.Service in project quarkus by quarkusio.

the class KnativeTest 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.getNamespace()).isNull();
                });
                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");
                            });
                        });
                    });
                });
            });
        });
    });
}
Also used : Path(java.nio.file.Path) Test(org.junit.jupiter.api.Test) List(java.util.List) QuarkusProdModeTest(io.quarkus.test.QuarkusProdModeTest) RegisterExtension(org.junit.jupiter.api.extension.RegisterExtension) Service(io.fabric8.knative.serving.v1.Service) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ProdBuildResults(io.quarkus.test.ProdBuildResults) IOException(java.io.IOException) ProdModeTestResults(io.quarkus.test.ProdModeTestResults) Path(java.nio.file.Path) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) Test(org.junit.jupiter.api.Test) QuarkusProdModeTest(io.quarkus.test.QuarkusProdModeTest)

Example 28 with Service

use of com.google.monitoring.v3.Service in project quarkus by quarkusio.

the class KnativeWithImagePullSecretTest method assertGeneratedResources.

@Test
public void assertGeneratedResources() throws IOException {
    final Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes");
    assertThat(kubernetesDir).isDirectoryContaining(p -> p.getFileName().endsWith("knative.json")).isDirectoryContaining(p -> p.getFileName().endsWith("knative.yml"));
    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.getMetadata()).satisfies(m -> {
                assertThat(m.getName()).isEqualTo("knative-with-image-pull-secret");
            });
            assertThat(s.getSpec()).satisfies(serviceSpec -> {
                assertThat(serviceSpec.getTemplate()).satisfies(t -> {
                    assertThat(t.getSpec()).satisfies(r -> {
                        assertThat(r.getServiceAccountName()).isEqualTo("knative-with-image-pull-secret");
                    });
                });
            });
        });
    });
    assertThat(kubernetesList).filteredOn(i -> "ServiceAccount".equals(i.getKind())).singleElement().satisfies(i -> {
        assertThat(i).isInstanceOfSatisfying(ServiceAccount.class, s -> {
            assertTrue(s.getImagePullSecrets().stream().anyMatch(r -> r.getName().equals("my-secret")));
        });
    });
}
Also used : Path(java.nio.file.Path) ShrinkWrap(org.jboss.shrinkwrap.api.ShrinkWrap) AppArtifact(io.quarkus.bootstrap.model.AppArtifact) QuarkusProdModeTest(io.quarkus.test.QuarkusProdModeTest) Service(io.fabric8.knative.serving.v1.Service) Version(io.quarkus.builder.Version) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) IOException(java.io.IOException) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) Test(org.junit.jupiter.api.Test) List(java.util.List) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) RegisterExtension(org.junit.jupiter.api.extension.RegisterExtension) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) ProdBuildResults(io.quarkus.test.ProdBuildResults) ProdModeTestResults(io.quarkus.test.ProdModeTestResults) ServiceAccount(io.fabric8.kubernetes.api.model.ServiceAccount) Path(java.nio.file.Path) Collections(java.util.Collections) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) QuarkusProdModeTest(io.quarkus.test.QuarkusProdModeTest) Test(org.junit.jupiter.api.Test)

Example 29 with Service

use of com.google.monitoring.v3.Service in project quarkus by quarkusio.

the class KnativeClusterLocalTest 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"));
    assertThat(getKNativeService(kubernetesDir)).satisfies(service -> {
        assertThat(service.getMetadata()).satisfies(m -> {
            assertThat(m.getLabels()).contains(entry("networking.knative.dev/visibility", "cluster-local"));
        });
    });
}
Also used : Path(java.nio.file.Path) QuarkusProdModeTest(io.quarkus.test.QuarkusProdModeTest) Files(java.nio.file.Files) Service(io.fabric8.knative.serving.v1.Service) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) IOException(java.io.IOException) Assertions.entry(org.assertj.core.api.Assertions.entry) StandardCharsets(java.nio.charset.StandardCharsets) Test(org.junit.jupiter.api.Test) Assertions.fail(org.assertj.core.api.Assertions.fail) RegisterExtension(org.junit.jupiter.api.extension.RegisterExtension) ProdBuildResults(io.quarkus.test.ProdBuildResults) ProdModeTestResults(io.quarkus.test.ProdModeTestResults) Path(java.nio.file.Path) QuarkusProdModeTest(io.quarkus.test.QuarkusProdModeTest) Test(org.junit.jupiter.api.Test)

Example 30 with Service

use of com.google.monitoring.v3.Service in project yakc by manusa.

the class ServiceIT method deleteNamespacedService.

@Test
@DisplayName("deleteNamespacedService, should delete existing Service")
void deleteNamespacedService() throws IOException {
    // When
    final Service result = KC.create(CoreV1Api.class).deleteNamespacedService(serviceName, NAMESPACE).get();
    // Then
    assertThat(result).isNotNull().extracting(Service::getMetadata).hasFieldOrPropertyWithValue("name", serviceName);
}
Also used : Service(com.marcnuri.yakc.model.io.k8s.api.core.v1.Service) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

Test (org.junit.jupiter.api.Test)33 Test (org.junit.Test)30 Service (io.fabric8.knative.serving.v1.Service)28 Connector (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector)22 Service (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service)22 AbstractMessage (com.google.protobuf.AbstractMessage)19 CoreException (org.eclipse.core.runtime.CoreException)18 MockGrpcService (com.google.api.gax.grpc.testing.MockGrpcService)16 Service (com.google.monitoring.v3.Service)16 IOException (java.io.IOException)16 HashMap (java.util.HashMap)14 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)13 ArrayList (java.util.ArrayList)12 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)11 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)11 StatusRuntimeException (io.grpc.StatusRuntimeException)11 ProdBuildResults (io.quarkus.test.ProdBuildResults)11 ProdModeTestResults (io.quarkus.test.ProdModeTestResults)11 QuarkusProdModeTest (io.quarkus.test.QuarkusProdModeTest)11 Path (java.nio.file.Path)11