use of com.yahoo.config.model.ApplicationConfigProducerRoot in project vespa by vespa-engine.
the class SystemModelTestCase method testVespaModel.
@Test
public void testVespaModel() {
VespaModel vespaModel = getVespaModelDoNotValidateXml(TESTDIR + "simpleconfig/");
assertNotNull(vespaModel);
assertEquals("There are two instances of the simple model + Routing and AdminModel (set up implicitly)", 4, vespaModel.configModelRepo().asMap().size());
assertNotNull("One gets the default name as there is no explicit id", vespaModel.configModelRepo().asMap().get("simple"));
assertNotNull("The other gets the explicit id as name", vespaModel.configModelRepo().asMap().get("second"));
ApplicationConfigProducerRoot root = vespaModel.getVespa();
assertNotNull(root);
// Verify configIds from vespa
assertTrue(6 <= root.getConfigIds().size());
assertTrue(root.getConfigIds().contains("client"));
assertTrue(root.getConfigIds().contains("simple"));
assertTrue(root.getConfigIds().contains("second"));
assertTrue(root.getConfigIds().contains("simple/simpleservice.0"));
assertTrue(root.getConfigIds().contains("simple/simpleservice.1"));
assertTrue(root.getConfigIds().contains("second/simpleservice.0"));
// Verify configIds from vespaModel
assertTrue(12 <= vespaModel.getConfigIds().size());
String localhost = HostName.getLocalhost();
String localhostConfigId = "hosts/" + localhost;
Set<String> configIds = vespaModel.getConfigIds();
assertTrue(configIds.contains("client"));
assertTrue(configIds.contains(localhostConfigId));
assertTrue(configIds.contains("simple/simpleservice.0"));
assertTrue(configIds.contains("second/simpleservice.0"));
assertTrue(configIds.contains("hosts/" + localhost + "/logd"));
// Verify sentinel config
SentinelConfig sentinelConfig = new SentinelConfig((SentinelConfig.Builder) vespaModel.getConfig(new SentinelConfig.Builder(), localhostConfigId));
boolean found = false;
for (SentinelConfig.Service service : sentinelConfig.service()) {
if ("logd".equals(service.name())) {
found = true;
}
}
assertTrue(found);
// Get the simple model config from VespaModel
assertEquals(vespaModel.getConfig(StandardConfig.class, "simple/simpleservice.0").astring(), "simpleservice");
assertEquals(vespaModel.getConfig(StandardConfig.class, "second/simpleservice.0").astring(), "simpleservice");
}
use of com.yahoo.config.model.ApplicationConfigProducerRoot in project vespa by vespa-engine.
the class SystemModelTestCase method testPlugins.
/**
* This test is the same as the system test cloudconfig/plugins.
* Be sure to update it as well if you change this.
*/
@Test
public void testPlugins() {
VespaModel vespaModel = getVespaModelDoNotValidateXml(TESTDIR + "plugins");
assertNotNull(vespaModel);
ApplicationConfigProducerRoot root = vespaModel.getVespa();
assertEquals(5, vespaModel.configModelRepo().asMap().size());
assertTrue(vespaModel.configModelRepo().asMap().keySet().contains("simple"));
assertTrue(vespaModel.configModelRepo().asMap().keySet().contains("api"));
assertTrue(root.getConfigIds().contains("simple/simpleservice.0"));
assertTrue(root.getConfigIds().contains("simple/simpleservice.1"));
assertTrue(root.getConfigIds().contains("api/apiservice.0"));
// Verify that configModelRegistry iterates in dependency order
Iterator<ConfigModel> i = vespaModel.configModelRepo().iterator();
ConfigModel plugin = i.next();
assertEquals("admin", plugin.getId());
plugin = i.next();
assertEquals("simple", plugin.getId());
plugin = i.next();
assertEquals("simple2", plugin.getId());
plugin = i.next();
assertEquals("api", plugin.getId());
plugin = i.next();
assertEquals("routing", plugin.getId());
assertEquals(vespaModel.getConfig(StandardConfig.class, "api/apiservice.0").astring(), "apiservice");
assertEquals(vespaModel.getConfig(StandardConfig.class, "simple/simpleservice.0").astring(), "simpleservice");
assertEquals(vespaModel.getConfig(StandardConfig.class, "simple/simpleservice.1").astring(), "simpleservice");
assertEquals(vespaModel.getConfig(StandardConfig.class, "simple2/simpleservice.0").astring(), "simpleservice");
}
use of com.yahoo.config.model.ApplicationConfigProducerRoot in project vespa by vespa-engine.
the class AdminTestCase method testOnlyAdminserver.
/**
* Test that a very simple config with only adminserver tag creates
* adminserver, logserver, configserver and slobroks
*/
@Test
public void testOnlyAdminserver() throws Exception {
VespaModel vespaModel = getVespaModel(TESTDIR + "simpleadminconfig20");
// Verify that the admin plugin has been loaded (always loads routing).
assertThat(vespaModel.configModelRepo().asMap().size(), is(2));
ApplicationConfigProducerRoot root = vespaModel.getVespa();
assertNotNull(root);
// Verify configIds
Set<String> configIds = vespaModel.getConfigIds();
String localhost = HostName.getLocalhost();
String localhostConfigId = "hosts/" + localhost;
assertTrue(configIds.contains(localhostConfigId));
assertTrue(configIds.contains("admin/logserver"));
assertTrue(configIds.contains("admin/configservers/configserver.0"));
assertTrue(configIds.contains("admin/slobrok.0"));
assertFalse(configIds.contains("admin/slobrok.1"));
// Verify services in the sentinel config
SentinelConfig.Builder b = new SentinelConfig.Builder();
vespaModel.getConfig(b, localhostConfigId);
SentinelConfig sentinelConfig = new SentinelConfig(b);
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"));
assertThat(sentinelConfig.service(0).affinity().cpuSocket(), is(-1));
assertTrue(sentinelConfig.service(0).preShutdownCommand().isEmpty());
// Confirm slobrok config
SlobroksConfig.Builder sb = new SlobroksConfig.Builder();
vespaModel.getConfig(sb, "admin");
SlobroksConfig sc = new SlobroksConfig(sb);
assertEquals(sc.slobrok().size(), 1);
assertTrue(sc.slobrok().get(0).connectionspec().matches(".*" + localhost + ".*"));
}
use of com.yahoo.config.model.ApplicationConfigProducerRoot in project vespa by vespa-engine.
the class AdminTestCase method testAdmin20.
/**
* Test that version 2.0 of adminconfig works as expected.
*/
@Test
public void testAdmin20() throws Exception {
VespaModel vespaModel = getVespaModel(TESTDIR + "adminconfig20");
// Verify that the admin plugin has been loaded (always loads routing).
assertThat(vespaModel.configModelRepo().asMap().size(), is(2));
ApplicationConfigProducerRoot root = vespaModel.getVespa();
assertNotNull(root);
// Verify configIds
Set<String> configIds = vespaModel.getConfigIds();
String localhost = HostName.getLocalhost();
String localhostConfigId = "hosts/" + localhost;
assertTrue(configIds.contains(localhostConfigId));
assertTrue(configIds.contains("admin/logserver"));
assertTrue(configIds.contains("admin/configservers/configserver.0"));
assertTrue(configIds.contains("admin/slobrok.0"));
assertTrue(configIds.contains("admin/slobrok.1"));
assertFalse(configIds.contains("admin/slobrok.2"));
assertTrue(configIds.contains("admin"));
// Confirm 2 slobroks in config
SlobroksConfig.Builder sb = new SlobroksConfig.Builder();
vespaModel.getConfig(sb, "admin/slobrok.0");
SlobroksConfig sc = new SlobroksConfig(sb);
assertEquals(sc.slobrok().size(), 2);
boolean localHostOK = false;
for (Slobrok s : sc.slobrok()) {
if (s.connectionspec().matches(".*" + localhost + ".*"))
localHostOK = true;
}
assertTrue(localHostOK);
LogdConfig.Builder lb = new LogdConfig.Builder();
vespaModel.getConfig(lb, "admin/slobrok.0");
LogdConfig lc = new LogdConfig(lb);
assertEquals(lc.logserver().host(), localhost);
// Verify services in the sentinel config
SentinelConfig.Builder b = new SentinelConfig.Builder();
vespaModel.getConfig(b, localhostConfigId);
SentinelConfig sentinelConfig = new SentinelConfig(b);
assertThat(sentinelConfig.service().size(), is(4));
assertThat(sentinelConfig.service(0).name(), is("logserver"));
assertThat(sentinelConfig.service(1).name(), is("slobrok"));
assertThat(sentinelConfig.service(2).name(), is("slobrok2"));
assertThat(sentinelConfig.service(3).name(), is("logd"));
}
use of com.yahoo.config.model.ApplicationConfigProducerRoot in project vespa by vespa-engine.
the class AdminTestCase method testMultipleConfigServers.
@Test
public void testMultipleConfigServers() throws Exception {
VespaModel vespaModel = getVespaModel(TESTDIR + "multipleconfigservers");
// Verify that the admin plugin has been loaded (always loads routing).
assertThat(vespaModel.configModelRepo().asMap().size(), is(2));
ApplicationConfigProducerRoot root = vespaModel.getVespa();
assertNotNull(root);
Admin admin = vespaModel.getAdmin();
assertNotNull(admin);
// Verify configIds
Set<String> configIds = vespaModel.getConfigIds();
String localhost = HostName.getLocalhost();
String localhostConfigId = "hosts/" + localhost;
assertTrue(configIds.contains(localhostConfigId));
assertTrue(configIds.contains("admin/logserver"));
assertTrue(configIds.contains("admin/configservers/configserver.0"));
assertTrue(configIds.contains("admin/configservers/configserver.1"));
assertThat(admin.getConfigservers().size(), is(2));
// Default configserver is the first one in the list and should have the default ports too
Configserver server1 = admin.getConfigservers().get(0);
assertEquals(admin.getConfigserver(), server1);
assertThat(server1.getPortCount(), is(2));
assertThat(server1.getRelativePort(0), is(19070));
assertThat(server1.getRelativePort(1), is(19071));
// Second configserver should be on second host but have the same port number
Configserver server2 = admin.getConfigservers().get(1);
assertNotSame(server1, server2);
assertNotSame(server1.getHostName(), server2.getHostName());
assertThat(server2.getPortCount(), is(2));
assertThat(server2.getRelativePort(0), is(19070));
assertThat(server2.getRelativePort(1), is(19071));
}
Aggregations