Search in sources :

Example 61 with Service

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Service in project kubernetes-client by fabric8io.

the class ServiceCrudTest method shouldListAndGetService.

@Test
void shouldListAndGetService() {
    Service service2 = new ServiceBuilder().withNewMetadata().withName("service2").endMetadata().build();
    client.services().inNamespace("ns2").create(service2);
    ServiceList serviceList = client.services().inNamespace("ns2").list();
    assertNotNull(serviceList);
    assertEquals(1, serviceList.getItems().size());
    Service service = client.services().inNamespace("ns2").withName("service2").get();
    assertNotNull(service);
    assertEquals("service2", service.getMetadata().getName());
}
Also used : ServiceList(io.fabric8.knative.serving.v1.ServiceList) Service(io.fabric8.knative.serving.v1.Service) ServiceBuilder(io.fabric8.knative.serving.v1.ServiceBuilder) Test(org.junit.jupiter.api.Test)

Example 62 with Service

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Service in project kubernetes-client by fabric8io.

the class ServiceCrudTest method shouldIncludeServiceStatus.

@Test
void shouldIncludeServiceStatus() {
    Service service = new ServiceBuilder().withNewMetadata().withName("service").endMetadata().build();
    Service created = client.services().inNamespace("ns2").create(service);
    ServiceList serviceList = client.services().inNamespace("ns2").list();
    assertNotNull(serviceList);
    assertEquals(1, serviceList.getItems().size());
    created.setStatus(new ServiceStatusBuilder().withNewAddress("http://my-service").build());
    assertNotNull(client.services().inNamespace("ns2").withName("service").updateStatus(created).getStatus());
}
Also used : ServiceStatusBuilder(io.fabric8.knative.serving.v1.ServiceStatusBuilder) ServiceList(io.fabric8.knative.serving.v1.ServiceList) Service(io.fabric8.knative.serving.v1.Service) ServiceBuilder(io.fabric8.knative.serving.v1.ServiceBuilder) Test(org.junit.jupiter.api.Test)

Example 63 with Service

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Service in project java-monitoring by googleapis.

the class ServiceMonitoringServiceClientTest method getServiceTest2.

@Test
public void getServiceTest2() throws Exception {
    Service expectedResponse = Service.newBuilder().setName(ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString()).setDisplayName("displayName1714148973").setTelemetry(Service.Telemetry.newBuilder().build()).putAllUserLabels(new HashMap<String, String>()).build();
    mockServiceMonitoringService.addResponse(expectedResponse);
    String name = "name3373707";
    Service actualResponse = client.getService(name);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockServiceMonitoringService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetServiceRequest actualRequest = ((GetServiceRequest) actualRequests.get(0));
    Assert.assertEquals(name, actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) Service(com.google.monitoring.v3.Service) MockGrpcService(com.google.api.gax.grpc.testing.MockGrpcService) GetServiceRequest(com.google.monitoring.v3.GetServiceRequest) Test(org.junit.Test)

Example 64 with Service

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Service in project java-monitoring by googleapis.

the class ServiceMonitoringServiceClientTest method createServiceExceptionTest3.

@Test
public void createServiceExceptionTest3() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockServiceMonitoringService.addException(exception);
    try {
        ProjectName parent = ProjectName.of("[PROJECT]");
        Service service = Service.newBuilder().build();
        client.createService(parent, service);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) ProjectName(com.google.monitoring.v3.ProjectName) StatusRuntimeException(io.grpc.StatusRuntimeException) Service(com.google.monitoring.v3.Service) MockGrpcService(com.google.api.gax.grpc.testing.MockGrpcService) Test(org.junit.Test)

Example 65 with Service

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Service in project java-monitoring by googleapis.

the class ServiceMonitoringServiceClientTest method createServiceTest2.

@Test
public void createServiceTest2() throws Exception {
    Service expectedResponse = Service.newBuilder().setName(ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString()).setDisplayName("displayName1714148973").setTelemetry(Service.Telemetry.newBuilder().build()).putAllUserLabels(new HashMap<String, String>()).build();
    mockServiceMonitoringService.addResponse(expectedResponse);
    OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
    Service service = Service.newBuilder().build();
    Service actualResponse = client.createService(parent, service);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockServiceMonitoringService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateServiceRequest actualRequest = ((CreateServiceRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertEquals(service, actualRequest.getService());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : OrganizationName(com.google.monitoring.v3.OrganizationName) AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) CreateServiceRequest(com.google.monitoring.v3.CreateServiceRequest) Service(com.google.monitoring.v3.Service) MockGrpcService(com.google.api.gax.grpc.testing.MockGrpcService) Test(org.junit.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