Search in sources :

Example 16 with Service

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.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 17 with Service

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.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)

Example 18 with Service

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Service in project yakc by manusa.

the class ServiceLegacyIT method patchNamespacedService.

@Test
@DisplayName("patchNamespacedService, should patch labels of Service")
void patchNamespacedService() throws IOException {
    // When
    final Service result = KC.create(CoreV1Api.class).patchNamespacedService(serviceName, NAMESPACE, Service.builder().metadata(ObjectMeta.builder().putInLabels("patched", "label").build()).build()).get();
    // Then
    assertThat(result).isNotNull().extracting(Service::getMetadata).hasFieldOrPropertyWithValue("name", serviceName).extracting(ObjectMeta::getLabels).asInstanceOf(InstanceOfAssertFactories.MAP).hasSize(2).containsEntry("patched", "label");
}
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)

Example 19 with Service

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Service in project yakc by manusa.

the class ServiceLegacyIT method replaceNamespacedService.

@Test
@DisplayName("replaceNamespacedService, should replace existing Service's port")
void replaceNamespacedService() throws IOException {
    // Given
    final Service existingService = KC.create(CoreV1Api.class).readNamespacedService(serviceName, NAMESPACE).get();
    existingService.getSpec().getPorts().get(0).setTargetPort("http");
    // When
    final Service result = KC.create(CoreV1Api.class).replaceNamespacedService(serviceName, NAMESPACE, existingService).get();
    // Then
    assertThat(result).isNotNull().hasFieldOrPropertyWithValue("metadata.name", serviceName).extracting(Service::getSpec).extracting(ServiceSpec::getPorts).asList().hasSize(2).element(0).hasFieldOrPropertyWithValue("targetPort", "http");
}
Also used : ServiceSpec(com.marcnuri.yakc.model.io.k8s.api.core.v1.ServiceSpec) Service(com.marcnuri.yakc.model.io.k8s.api.core.v1.Service) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 20 with Service

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Service in project dekorate by dekorateio.

the class Feat458Test method shouldHaveKubernetestLabelsKnativeYml.

@Test
public void shouldHaveKubernetestLabelsKnativeYml() {
    KubernetesList list = Serialization.unmarshalAsList(Feat458Test.class.getClassLoader().getResourceAsStream("META-INF/dekorate/knative.yml"));
    assertNotNull(list);
    Service s = findFirst(list, Service.class).orElseThrow(() -> new IllegalStateException());
    assertNotNull(s);
    Map<String, String> labels = s.getMetadata().getLabels();
    assertNotNull(labels);
    assertTrue(labels.containsKey(Labels.NAME));
    assertTrue(labels.containsKey(Labels.VERSION));
    assertFalse(labels.containsKey(OpenshiftLabels.RUNTIME));
    Map<String, String> annotations = s.getMetadata().getAnnotations();
    assertNotNull(annotations);
    assertTrue(annotations.containsKey(Annotations.COMMIT_ID));
    assertFalse(annotations.containsKey(OpenshiftAnnotations.VCS_URL));
    assertTrue(annotations.containsKey(Annotations.VCS_URL));
}
Also used : Service(io.fabric8.knative.serving.v1.Service) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)34 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 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 Test (org.junit.Test)16 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)14 AbstractMessage (com.google.protobuf.AbstractMessage)11 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)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 ArrayList (java.util.ArrayList)11 RegisterExtension (org.junit.jupiter.api.extension.RegisterExtension)11 List (java.util.List)10 DisplayName (org.junit.jupiter.api.DisplayName)10