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"));
}
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"));
}
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() + "]";
}
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."));
}
}
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);
}
Aggregations