use of com.yahoo.config.model.test.TestDriver in project vespa by vespa-engine.
the class MultilevelDispatchTest method requireThatSearchCoverageIsSetInSingleLevelSetup.
@Test
public void requireThatSearchCoverageIsSetInSingleLevelSetup() throws Exception {
TestRoot root = new TestDriver(true).buildModel(new MockApplicationPackage.Builder().withServices("<services version='1.0'>" + "<content id='stateful' version='1.0'>" + " <redundancy>1</redundancy>" + " <documents><document mode='index' type='music' /></documents>" + " <nodes>" + " <node distribution-key='1' hostalias='mockroot' />" + " </nodes>" + " <search><coverage><minimum>0.95</minimum></coverage></search>" + "</content>" + "<jdisc id='foo' version='1.0'>" + " <search />" + " <nodes><node hostalias='mockroot' /></nodes>" + "</jdisc>" + "</services>").withSearchDefinition(MockApplicationPackage.MUSIC_SEARCHDEFINITION).build());
PartitionsConfig config = root.getConfig(PartitionsConfig.class, "stateful/search/cluster.stateful/tlds/foo.0.tld.0");
assertThat(config.dataset().size(), is(1));
assertEquals(95.0, config.dataset(0).minimal_searchcoverage(), 0.1);
}
use of com.yahoo.config.model.test.TestDriver in project vespa by vespa-engine.
the class TldTest method requireThatUseLocalPolicyIsOk.
@Test
public void requireThatUseLocalPolicyIsOk() {
ApplicationPackage app = new MockApplicationPackage.Builder().withHosts("<hosts>" + "<host name='search.node1'><alias>search1</alias></host>" + "<host name='search.node2'><alias>search2</alias></host>" + "<host name='jdisc.host.other'><alias>gateway</alias></host>" + "</hosts>").withServices("<services>" + " <admin version='2.0'>" + " <adminserver hostalias='gateway' />" + " </admin>" + " <jdisc version='1.0' id='default'>" + " <search />" + " <nodes>" + " <node hostalias='search1'/>" + " <node hostalias='search2'/>" + " </nodes>" + " </jdisc>" + " <jdisc version='1.0' id='gw'>" + " <document-api/>" + " <nodes>" + " <node hostalias='gateway'/>" + " </nodes>" + " </jdisc>" + " <content version='1.0' id='foo'>" + " <redundancy>2</redundancy>" + " <documents>" + " <document type='music' mode='index'/>" + " </documents>" + " <group name='topGroup'>" + " <distribution partitions='1|*'/>" + " <group name='group1' distribution-key='0'>" + " <node hostalias='search1' distribution-key='0'/>" + " </group>" + " <group name='group2' distribution-key='1'>" + " <node hostalias='search2' distribution-key='1'/>" + " </group>" + " </group>" + " <tuning>" + " <dispatch>" + " <use-local-node>true</use-local-node>" + " </dispatch>" + " </tuning>" + " </content>" + "</services>").withSearchDefinition(MockApplicationPackage.MUSIC_SEARCHDEFINITION).build();
PartitionsConfig.Builder builder = new PartitionsConfig.Builder();
new TestDriver(true).buildModel(app).getConfig(builder, "foo/search/cluster.foo/tlds/gw.0.tld.0");
PartitionsConfig config = new PartitionsConfig(builder);
assertEquals(1, config.dataset().size());
// gateway TLD with no local search node gets all search nodes
assertEquals(2, config.dataset(0).engine().size());
// Load Balance row 0
assertEquals("rowid not equal 0", 0, config.dataset(0).engine(0).rowid());
assertEquals("partid not equal 0", 0, config.dataset(0).engine(0).partid());
assertTrue("Not configured with correct search node", config.dataset(0).engine(0).name_and_port().contains("search.node1"));
// Load Balance row 1
assertEquals("rowid not equal to 1", 1, config.dataset(0).engine(1).rowid());
assertEquals("partid no equal to 0", 0, config.dataset(0).engine(1).partid());
assertTrue("Not configured with correct search node", config.dataset(0).engine(1).name_and_port().contains("search.node2"));
// First container with a local search node
builder = new PartitionsConfig.Builder();
new TestDriver(true).buildModel(app).getConfig(builder, "foo/search/cluster.foo/tlds/default.0.tld.0");
config = new PartitionsConfig(builder);
assertEquals(1, config.dataset().size());
assertEquals(1, config.dataset(0).engine().size());
assertEquals(0, config.dataset(0).engine(0).rowid());
assertEquals(0, config.dataset(0).engine(0).partid());
assertTrue("Not configured with local search node as engine", config.dataset(0).engine(0).name_and_port().contains("search.node1"));
// Second container with a local search node
builder = new PartitionsConfig.Builder();
new TestDriver(true).buildModel(app).getConfig(builder, "foo/search/cluster.foo/tlds/default.1.tld.1");
config = new PartitionsConfig(builder);
assertEquals(1, config.dataset().size());
assertEquals(1, config.dataset(0).engine().size());
assertEquals(0, config.dataset(0).engine(0).rowid());
assertEquals(0, config.dataset(0).engine(0).partid());
assertTrue("Not configured with local search node as engine", config.dataset(0).engine(0).name_and_port().contains("search.node2"));
}
use of com.yahoo.config.model.test.TestDriver in project vespa by vespa-engine.
the class ClusterControllerTestCase method testSeparateHostsRequired.
@Test(expected = IllegalArgumentException.class)
public void testSeparateHostsRequired() throws Exception {
String xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" + "<services>\n" + "\n" + " <admin version=\"2.0\">\n" + " <adminserver hostalias=\"mockhost\" />\n" + " <cluster-controllers standalone-zookeeper=\"true\">\n" + " <cluster-controller hostalias=\"mockhost\"/>" + " <cluster-controller hostalias=\"mockhost\"/>" + " <cluster-controller hostalias=\"mockhost\"/>" + " </cluster-controllers>\n" + " </admin>\n" + " <content version='1.0' id='bar'>" + " <redundancy>1</redundancy>\n" + " <documents>" + " </documents>\n" + " <group>" + " <node hostalias='mockhost' distribution-key='0' />" + " </group>" + " </content>" + "\n" + "</services>";
TestDriver driver = new TestDriver();
driver.buildModel(xml);
}
use of com.yahoo.config.model.test.TestDriver in project vespa by vespa-engine.
the class AdminTestCase method testDisableFileDistributorForAllApps.
@Test
public void testDisableFileDistributorForAllApps() {
DeployState state = new DeployState.Builder().zone(new Zone(Environment.dev, RegionName.from("baz"))).properties(new DeployProperties.Builder().applicationId(new ApplicationId.Builder().tenant("quux").applicationName("foo").instanceName("bim").build()).build()).build(true);
TestRoot root = new TestDriver().buildModel(state);
String localhost = HostName.getLocalhost();
SentinelConfig sentinelConfig = root.getConfig(SentinelConfig.class, "hosts/" + localhost);
assertThat(sentinelConfig.service().size(), is(3));
assertThat(sentinelConfig.service(0).name(), is("logserver"));
assertThat(sentinelConfig.service(1).name(), is("slobrok"));
assertThat(sentinelConfig.service(2).name(), is("logd"));
}
use of com.yahoo.config.model.test.TestDriver in project vespa by vespa-engine.
the class AdminTestCase method testTenantAndAppInSentinelConfig.
@Test
public void testTenantAndAppInSentinelConfig() {
DeployState state = new DeployState.Builder().zone(new Zone(Environment.dev, RegionName.from("baz"))).properties(new DeployProperties.Builder().applicationId(new ApplicationId.Builder().tenant("quux").applicationName("foo").instanceName("bim").build()).build()).build(true);
TestRoot root = new TestDriver().buildModel(state);
String localhost = HostName.getLocalhost();
SentinelConfig config = root.getConfig(SentinelConfig.class, "hosts/" + localhost);
assertThat(config.application().tenant(), is("quux"));
assertThat(config.application().name(), is("foo"));
assertThat(config.application().environment(), is("dev"));
assertThat(config.application().region(), is("baz"));
assertThat(config.application().instance(), is("bim"));
}
Aggregations