Search in sources :

Example 91 with Service

use of com.google.cloud.servicedirectory.v1.Service in project dekorate by dekorateio.

the class Issue586ScaleBoundsTest method shouldContainMinAndMaxBounds.

@Test
public void shouldContainMinAndMaxBounds() {
    KubernetesList list = Serialization.unmarshalAsList(getClass().getClassLoader().getResourceAsStream("META-INF/dekorate/knative.yml"));
    assertNotNull(list);
    Service s = findFirst(list, Service.class).orElseThrow(() -> new IllegalStateException());
    String minScale = s.getMetadata().getAnnotations().get("autoscaling.knative.dev/minScale");
    String maxScale = s.getMetadata().getAnnotations().get("autoscaling.knative.dev/maxScale");
    assertEquals("3", minScale);
    assertEquals("5", maxScale);
}
Also used : Service(io.fabric8.knative.serving.v1.Service) KubernetesList(io.fabric8.kubernetes.api.model.KubernetesList) Test(org.junit.jupiter.api.Test)

Example 92 with Service

use of com.google.cloud.servicedirectory.v1.Service in project java-servicedirectory by googleapis.

the class RegistrationServiceClientTest method listServicesTest.

@Test
public void listServicesTest() throws Exception {
    Service responsesElement = Service.newBuilder().build();
    ListServicesResponse expectedResponse = ListServicesResponse.newBuilder().setNextPageToken("").addAllServices(Arrays.asList(responsesElement)).build();
    mockRegistrationService.addResponse(expectedResponse);
    NamespaceName parent = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]");
    ListServicesPagedResponse pagedListResponse = client.listServices(parent);
    List<Service> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getServicesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockRegistrationService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListServicesRequest actualRequest = ((ListServicesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListServicesPagedResponse(com.google.cloud.servicedirectory.v1.RegistrationServiceClient.ListServicesPagedResponse) MockGrpcService(com.google.api.gax.grpc.testing.MockGrpcService) Test(org.junit.Test)

Example 93 with Service

use of com.google.cloud.servicedirectory.v1.Service in project java-servicedirectory by googleapis.

the class ServicesDelete method deleteService.

// Delete a service.
public static void deleteService(String projectId, String locationId, String namespaceId, String serviceId) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (RegistrationServiceClient client = RegistrationServiceClient.create()) {
        // The service to delete.
        ServiceName serviceName = ServiceName.of(projectId, locationId, namespaceId, serviceId);
        // Send the request to delete the service.
        client.deleteService(serviceName);
        // Log the action.
        System.out.println("Deleted Service: " + serviceName.toString());
    }
}
Also used : ServiceName(com.google.cloud.servicedirectory.v1.ServiceName) RegistrationServiceClient(com.google.cloud.servicedirectory.v1.RegistrationServiceClient)

Example 94 with Service

use of com.google.cloud.servicedirectory.v1.Service in project java-servicedirectory by googleapis.

the class ServicesResolve method resolveService.

// Resolve a service.
public static void resolveService(String projectId, String locationId, String namespaceId, String serviceId) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (LookupServiceClient client = LookupServiceClient.create()) {
        // The service to resolve.
        ServiceName name = ServiceName.of(projectId, locationId, namespaceId, serviceId);
        // Construct the resolve request to be sent to the client.
        ResolveServiceRequest request = ResolveServiceRequest.newBuilder().setName(name.toString()).build();
        // Send the request to resolve the service.
        ResolveServiceResponse resolveResponse = client.resolveService(request);
        // Process the response.
        System.out.println("Resolved Service: " + resolveResponse.getService().getName());
        System.out.println("Endpoints found:");
        for (Endpoint endpoint : resolveResponse.getService().getEndpointsList()) {
            System.out.println(endpoint.getName() + " -- " + endpoint.getAddress() + ":" + endpoint.getPort());
        }
    }
}
Also used : ResolveServiceResponse(com.google.cloud.servicedirectory.v1.ResolveServiceResponse) Endpoint(com.google.cloud.servicedirectory.v1.Endpoint) ServiceName(com.google.cloud.servicedirectory.v1.ServiceName) ResolveServiceRequest(com.google.cloud.servicedirectory.v1.ResolveServiceRequest) LookupServiceClient(com.google.cloud.servicedirectory.v1.LookupServiceClient)

Aggregations

Test (org.junit.jupiter.api.Test)33 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 Test (org.junit.Test)19 MockGrpcService (com.google.api.gax.grpc.testing.MockGrpcService)18 CoreException (org.eclipse.core.runtime.CoreException)18 Service (com.google.monitoring.v3.Service)16 IOException (java.io.IOException)15 AbstractMessage (com.google.protobuf.AbstractMessage)14 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)13 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