Search in sources :

Example 16 with ClusterDef

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

the class VdsVisitTestCase method testFailIfNoContentClustersAvailable.

@Test
public void testFailIfNoContentClustersAvailable() {
    List<ClusterDef> clusterDefs = new ArrayList<>();
    ClusterList clusterList = new ClusterList(clusterDefs);
    try {
        VdsVisit.resolveClusterRoute(clusterList, null);
    } catch (IllegalArgumentException e) {
        assertTrue(e.getMessage().contains("Your Vespa cluster does not have any content clusters"));
    }
}
Also used : ClusterList(com.yahoo.vespaclient.ClusterList) ClusterDef(com.yahoo.vespaclient.ClusterDef) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 17 with ClusterDef

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

the class VdsVisitTestCase method testRequireClusterOptionIfMultipleClusters.

@Test
public void testRequireClusterOptionIfMultipleClusters() {
    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);
    try {
        VdsVisit.resolveClusterRoute(clusterList, null);
    } catch (IllegalArgumentException e) {
        assertTrue(e.getMessage().contains("Please use the -c option to select one of them"));
    }
}
Also used : ClusterList(com.yahoo.vespaclient.ClusterList) ClusterDef(com.yahoo.vespaclient.ClusterDef) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 18 with ClusterDef

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

the class DocumentRetrieverTest method testClusterLookup.

@Test
public void testClusterLookup() throws DocumentRetrieverException {
    final String cluster = "storage", configId = "content/cluster.foo/storage", expectedRoute = "[Storage:cluster=storage;clusterconfigid=content/cluster.foo/storage]";
    ClientParameters params = createParameters().setCluster(cluster).build();
    ClusterList clusterList = new ClusterList(Collections.singletonList(new ClusterDef(cluster, configId)));
    DocumentRetriever documentRetriever = createDocumentRetriever(params, clusterList);
    documentRetriever.retrieveDocuments();
    verify(mockedFactory).createDocumentAccess(argThat(new ArgumentMatcher<MessageBusParams>() {

        @Override
        public boolean matches(Object o) {
            return ((MessageBusParams) o).getRoute().equals(expectedRoute);
        }
    }));
}
Also used : ClusterList(com.yahoo.vespaclient.ClusterList) ArgumentMatcher(org.mockito.ArgumentMatcher) ClusterDef(com.yahoo.vespaclient.ClusterDef) Test(org.junit.Test)

Example 19 with ClusterDef

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

the class DocumentRetrieverTest method testInvalidClusterName.

@Test
public void testInvalidClusterName() throws DocumentRetrieverException {
    exception.expect(DocumentRetrieverException.class);
    exception.expectMessage("The Vespa cluster contains the content clusters storage, not invalidclustername. Please select a valid vespa cluster.");
    ClientParameters params = createParameters().setCluster("invalidclustername").build();
    ClusterList clusterList = new ClusterList(Collections.singletonList(new ClusterDef("storage", "content/cluster.foo/storage")));
    DocumentRetriever documentRetriever = createDocumentRetriever(params, clusterList);
    documentRetriever.retrieveDocuments();
}
Also used : ClusterList(com.yahoo.vespaclient.ClusterList) ClusterDef(com.yahoo.vespaclient.ClusterDef) 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