Search in sources :

Example 1 with ApplicationView

use of com.yahoo.vespa.serviceview.bindings.ApplicationView in project vespa by vespa-engine.

the class StateResourceTest method testLinkEquality.

@Test
public final void testLinkEquality() {
    ApplicationView explicitParameters = testResource.getUserInfo("default", "default", "default", "default", "default");
    ApplicationView implicitParameters = testResource.getDefaultUserInfo();
    assertEquals(explicitParameters.clusters.get(0).services.get(0).url, implicitParameters.clusters.get(0).services.get(0).url);
}
Also used : ApplicationView(com.yahoo.vespa.serviceview.bindings.ApplicationView) Test(org.junit.Test)

Example 2 with ApplicationView

use of com.yahoo.vespa.serviceview.bindings.ApplicationView in project vespa by vespa-engine.

the class ServiceModelTest method test.

@Test
public final void test() {
    final String uriBase = "http://configserver:5000/";
    ApplicationView x = model.showAllClusters(uriBase, "/tenant/default/application/default");
    assertEquals(2, x.clusters.size());
    String urlTracking = null;
    for (com.yahoo.vespa.serviceview.bindings.ClusterView c : x.clusters) {
        for (ServiceView s : c.services) {
            if ("examplename".equals(s.serviceName)) {
                assertEquals("something", s.serviceType);
                urlTracking = s.url;
                break;
            }
        }
    }
    assertNotNull(urlTracking);
    final String serviceIdentifier = urlTracking.substring(urlTracking.indexOf("something"), urlTracking.length() - "/state/v1/".length());
    Service y = model.getService(serviceIdentifier);
    assertEquals("examplename", y.name);
}
Also used : ServiceView(com.yahoo.vespa.serviceview.bindings.ServiceView) ApplicationView(com.yahoo.vespa.serviceview.bindings.ApplicationView) HostService(com.yahoo.vespa.serviceview.bindings.HostService) Test(org.junit.Test)

Example 3 with ApplicationView

use of com.yahoo.vespa.serviceview.bindings.ApplicationView in project vespa by vespa-engine.

the class ConfigServerClientMock method getApplicationView.

// Returns a canned example response
@Override
public ApplicationView getApplicationView(String tenantName, String applicationName, String instanceName, String environment, String region) {
    ApplicationView applicationView = new ApplicationView();
    ClusterView cluster = new ClusterView();
    cluster.name = "cluster1";
    cluster.type = "content";
    cluster.url = "http://localhost:8080/application/v4/tenant/tenant1/application/application1/environment/prod/region/us-west-1/instance/default/service/container-clustercontroller-6s8slgtps7ry8uh6lx21ejjiv/cluster/v2/cluster1";
    ServiceView service = new ServiceView();
    service.configId = "cluster1/storage/0";
    service.host = "host1";
    service.serviceName = "storagenode";
    service.serviceType = "storagenode";
    service.url = "http://localhost:8080/application/v4/tenant/tenant1/application/application1/environment/prod/region/us-west-1/instance/default/service/storagenode-awe3slno6mmq2fye191y324jl/state/v1/";
    cluster.services = new ArrayList<>();
    cluster.services.add(service);
    applicationView.clusters = new ArrayList<>();
    applicationView.clusters.add(cluster);
    return applicationView;
}
Also used : ClusterView(com.yahoo.vespa.serviceview.bindings.ClusterView) ServiceView(com.yahoo.vespa.serviceview.bindings.ServiceView) ApplicationView(com.yahoo.vespa.serviceview.bindings.ApplicationView)

Example 4 with ApplicationView

use of com.yahoo.vespa.serviceview.bindings.ApplicationView in project vespa by vespa-engine.

the class ServiceApiResponseTest method testServiceViewResponse.

@Test
public void testServiceViewResponse() throws URISyntaxException, IOException {
    ServiceApiResponse response = new ServiceApiResponse(ZoneId.from(Environment.prod, RegionName.from("us-west-1")), ApplicationId.from("tenant1", "application1", "default"), Collections.singletonList(new URI("config-server1")), new URI("http://server1:4080/request/path?foo=bar"));
    ApplicationView applicationView = new ApplicationView();
    ClusterView clusterView = new ClusterView();
    clusterView.type = "container";
    clusterView.name = "cluster1";
    clusterView.url = "cluster-url";
    ServiceView serviceView = new ServiceView();
    serviceView.url = null;
    serviceView.serviceType = "container";
    serviceView.serviceName = "service1";
    serviceView.configId = "configId1";
    serviceView.host = "host1";
    serviceView.legacyStatusPages = "legacyPages";
    clusterView.services = Collections.singletonList(serviceView);
    applicationView.clusters = Collections.singletonList(clusterView);
    response.setResponse(applicationView);
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    response.render(stream);
    Slime responseSlime = SlimeUtils.jsonToSlime(stream.toByteArray());
    Slime expectedSlime = SlimeUtils.jsonToSlime(IOUtils.readFile(new File(responseFiles + "service-api-response.json")).getBytes(StandardCharsets.UTF_8));
    assertEquals("service-api-response.json", new String(SlimeUtils.toJsonBytes(expectedSlime), StandardCharsets.UTF_8), new String(SlimeUtils.toJsonBytes(responseSlime), StandardCharsets.UTF_8));
}
Also used : ClusterView(com.yahoo.vespa.serviceview.bindings.ClusterView) ServiceView(com.yahoo.vespa.serviceview.bindings.ServiceView) ApplicationView(com.yahoo.vespa.serviceview.bindings.ApplicationView) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Slime(com.yahoo.slime.Slime) URI(java.net.URI) File(java.io.File) Test(org.junit.Test)

Example 5 with ApplicationView

use of com.yahoo.vespa.serviceview.bindings.ApplicationView in project vespa by vespa-engine.

the class ServiceModel method showAllClusters.

/**
 * The top level view of a given application.
 *
 * @return a top level view of the entire application in a form suitable for
 *         consumption by a REST API
 */
public ApplicationView showAllClusters(String uriBase, String applicationIdentifier) {
    ApplicationView response = new ApplicationView();
    List<ClusterView> clusterViews = new ArrayList<>();
    for (Cluster c : clusters) {
        clusterViews.add(showCluster(c, uriBase, applicationIdentifier));
    }
    response.clusters = clusterViews;
    return response;
}
Also used : ClusterView(com.yahoo.vespa.serviceview.bindings.ClusterView) ArrayList(java.util.ArrayList) ApplicationView(com.yahoo.vespa.serviceview.bindings.ApplicationView)

Aggregations

ApplicationView (com.yahoo.vespa.serviceview.bindings.ApplicationView)7 ClusterView (com.yahoo.vespa.serviceview.bindings.ClusterView)4 ServiceView (com.yahoo.vespa.serviceview.bindings.ServiceView)4 Test (org.junit.Test)4 Slime (com.yahoo.slime.Slime)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 File (java.io.File)2 URI (java.net.URI)2 ApplicationId (com.yahoo.config.provision.ApplicationId)1 HostService (com.yahoo.vespa.serviceview.bindings.HostService)1 ArrayList (java.util.ArrayList)1