Search in sources :

Example 6 with ClusterDef

use of com.yahoo.vespaclient.ClusterDef in project vespa by vespa-engine.

the class VespaFeedHandlerTestCase method testRemoveBadSyntax.

@Test
public void testRemoveBadSyntax() throws Exception {
    setup(null);
    context.getClusterList().getStorageClusters().add(new ClusterDef("storage", "storage/cluster.storage"));
    Result res = testRequest(HttpRequest.createTestRequest("removelocation?group=foo&user=12345", com.yahoo.jdisc.http.HttpRequest.Method.PUT));
    assertEquals(0, res.messages.size());
    assertTrue(res.error.toString().contains("Exactly one of"));
}
Also used : ClusterDef(com.yahoo.vespaclient.ClusterDef) Test(org.junit.Test)

Example 7 with ClusterDef

use of com.yahoo.vespaclient.ClusterDef in project vespa by vespa-engine.

the class VespaFeedHandlerTestCase method testRemoveGroupMultipleClusters.

@Test
public void testRemoveGroupMultipleClusters() throws Exception {
    setup(null);
    context.getClusterList().getStorageClusters().add(new ClusterDef("storage1", "storage/cluster.storage1"));
    context.getClusterList().getStorageClusters().add(new ClusterDef("storage2", "storage/cluster.storage2"));
    Result res = testRequest(HttpRequest.createTestRequest("removelocation?group=foo", com.yahoo.jdisc.http.HttpRequest.Method.PUT));
    assertEquals(0, res.messages.size());
    assertTrue(res.error.toString().contains("More than one"));
}
Also used : ClusterDef(com.yahoo.vespaclient.ClusterDef) Test(org.junit.Test)

Example 8 with ClusterDef

use of com.yahoo.vespaclient.ClusterDef in project vespa by vespa-engine.

the class VdsVisit method resolveClusterRoute.

protected static String resolveClusterRoute(ClusterList clusters, String wantedCluster) {
    if (clusters.getStorageClusters().size() == 0) {
        throw new IllegalArgumentException("Your Vespa cluster does not have any content clusters " + "declared. Visiting feature is not available.");
    }
    ClusterDef found = null;
    String names = "";
    for (ClusterDef c : clusters.getStorageClusters()) {
        if (!names.isEmpty()) {
            names += ", ";
        }
        names += c.getName();
    }
    if (wantedCluster != null) {
        for (ClusterDef c : clusters.getStorageClusters()) {
            if (c.getName().equals(wantedCluster)) {
                found = c;
            }
        }
        if (found == null) {
            throw new IllegalArgumentException("Your vespa cluster contains the content clusters " + names + ", not " + wantedCluster + ". Please select a valid vespa cluster.");
        }
    } else if (clusters.getStorageClusters().size() == 1) {
        found = clusters.getStorageClusters().get(0);
    } else {
        throw new IllegalArgumentException("Your vespa cluster contains the content clusters " + names + ". Please use the -c option to select one of them as a target for visiting.");
    }
    return "[Storage:cluster=" + found.getName() + ";clusterconfigid=" + found.getConfigId() + "]";
}
Also used : ClusterDef(com.yahoo.vespaclient.ClusterDef)

Example 9 with ClusterDef

use of com.yahoo.vespaclient.ClusterDef in project vespa by vespa-engine.

the class VdsVisitTestCase method testBadClusterName.

@Test
public void testBadClusterName() throws Exception {
    List<ClusterDef> clusterDefs = new ArrayList<>();
    clusterDefs.add(new ClusterDef("storage", "content/cluster.foo/storage"));
    ClusterList clusterList = new ClusterList(clusterDefs);
    try {
        VdsVisit.resolveClusterRoute(clusterList, "borkbork");
    } catch (IllegalArgumentException e) {
        assertTrue(e.getMessage().contains("Your vespa cluster contains the content clusters storage, not borkbork."));
    }
}
Also used : ClusterList(com.yahoo.vespaclient.ClusterList) ClusterDef(com.yahoo.vespaclient.ClusterDef) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 10 with ClusterDef

use of com.yahoo.vespaclient.ClusterDef in project vespa by vespa-engine.

the class VdsVisitTestCase method testExplicitClusterOptionWithMultipleClusters.

@Test
public void testExplicitClusterOptionWithMultipleClusters() {
    List<ClusterDef> clusterDefs = new ArrayList<>();
    clusterDefs.add(new ClusterDef("storage", "content/cluster.foo/storage"));
    clusterDefs.add(new ClusterDef("storage2", "content/cluster.bar/storage"));
    ClusterList clusterList = new ClusterList(clusterDefs);
    String route = VdsVisit.resolveClusterRoute(clusterList, "storage2");
    assertEquals("[Storage:cluster=storage2;clusterconfigid=content/cluster.bar/storage]", route);
}
Also used : ClusterList(com.yahoo.vespaclient.ClusterList) ClusterDef(com.yahoo.vespaclient.ClusterDef) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

ClusterDef (com.yahoo.vespaclient.ClusterDef)19 Test (org.junit.Test)16 ClusterList (com.yahoo.vespaclient.ClusterList)7 ArrayList (java.util.ArrayList)5 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)1 StaticThrottlePolicy (com.yahoo.messagebus.StaticThrottlePolicy)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 ArgumentMatcher (org.mockito.ArgumentMatcher)1