Search in sources :

Example 21 with Service

use of com.google.monitoring.v3.Service in project java-monitoring by googleapis.

the class ServiceMonitoringServiceClientTest method deleteServiceLevelObjectiveExceptionTest.

@Test
public void deleteServiceLevelObjectiveExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockServiceMonitoringService.addException(exception);
    try {
        ServiceLevelObjectiveName name = ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName("[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]");
        client.deleteServiceLevelObjective(name);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : ServiceLevelObjectiveName(com.google.monitoring.v3.ServiceLevelObjectiveName) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Example 22 with Service

use of com.google.monitoring.v3.Service in project java-monitoring by googleapis.

the class ServiceMonitoringServiceClientTest method createServiceLevelObjectiveTest.

@Test
public void createServiceLevelObjectiveTest() throws Exception {
    ServiceLevelObjective expectedResponse = ServiceLevelObjective.newBuilder().setName(ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName("[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]").toString()).setDisplayName("displayName1714148973").setServiceLevelIndicator(ServiceLevelIndicator.newBuilder().build()).setGoal(3178259).putAllUserLabels(new HashMap<String, String>()).build();
    mockServiceMonitoringService.addResponse(expectedResponse);
    ServiceName parent = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
    ServiceLevelObjective serviceLevelObjective = ServiceLevelObjective.newBuilder().build();
    ServiceLevelObjective actualResponse = client.createServiceLevelObjective(parent, serviceLevelObjective);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockServiceMonitoringService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateServiceLevelObjectiveRequest actualRequest = ((CreateServiceLevelObjectiveRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertEquals(serviceLevelObjective, actualRequest.getServiceLevelObjective());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ServiceLevelObjective(com.google.monitoring.v3.ServiceLevelObjective) HashMap(java.util.HashMap) ServiceName(com.google.monitoring.v3.ServiceName) CreateServiceLevelObjectiveRequest(com.google.monitoring.v3.CreateServiceLevelObjectiveRequest) Test(org.junit.Test)

Example 23 with Service

use of com.google.monitoring.v3.Service in project kubernetes-client by fabric8io.

the class ResourceTest method resourceInNamespaceCreate.

// https://github.com/quarkusio/quarkus/issues/19950
@Test
@DisplayName("resource, with Knative model in namespace, can createOrReplace")
void resourceInNamespaceCreate() {
    // Given
    final Service service = new ServiceBuilder().withNewMetadata().withName("service-resource").endMetadata().build();
    // When
    final HasMetadata hm = client.resource(service).inNamespace("default").createOrReplace();
    // Then
    assertNotNull(hm);
}
Also used : HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) Service(io.fabric8.knative.serving.v1.Service) ServiceBuilder(io.fabric8.knative.serving.v1.ServiceBuilder) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 24 with Service

use of com.google.monitoring.v3.Service in project kubernetes-client by fabric8io.

the class ServiceCrudTest method shouldDeleteAService.

@Test
void shouldDeleteAService() {
    Service service3 = new ServiceBuilder().withNewMetadata().withName("service3").endMetadata().build();
    client.services().inNamespace("ns3").create(service3);
    Boolean deleted = client.services().inNamespace("ns3").withName("service3").delete();
    assertTrue(deleted);
}
Also used : Service(io.fabric8.knative.serving.v1.Service) ServiceBuilder(io.fabric8.knative.serving.v1.ServiceBuilder) Test(org.junit.jupiter.api.Test)

Example 25 with Service

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

the class KnativeWithHealthTest 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");
                            });
                            assertThat(c.getReadinessProbe()).isNotNull().satisfies(p -> {
                                assertThat(p.getInitialDelaySeconds()).isEqualTo(0);
                                assertProbePath(p, "/q/health/ready");
                                assertNotNull(p.getHttpGet());
                                assertNull(p.getHttpGet().getPort());
                            });
                            assertThat(c.getLivenessProbe()).isNotNull().satisfies(p -> {
                                assertThat(p.getInitialDelaySeconds()).isEqualTo(20);
                                assertProbePath(p, "/q/health/live");
                                assertNotNull(p.getHttpGet());
                                assertNull(p.getHttpGet().getPort());
                            });
                        });
                    });
                });
            });
        });
    });
}
Also used : Path(java.nio.file.Path) Probe(io.fabric8.kubernetes.api.model.Probe) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) 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) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) 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) ProdBuildResults(io.quarkus.test.ProdBuildResults) ProdModeTestResults(io.quarkus.test.ProdModeTestResults) 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)

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