use of com.yahoo.cloud.config.SentinelConfig 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.cloud.config.SentinelConfig 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.cloud.config.SentinelConfig 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.cloud.config.SentinelConfig in project vespa by vespa-engine.
the class GenericServicesTest method testServicesSentinelConfig.
@Test
public void testServicesSentinelConfig() throws IOException, SAXException {
String sentinelConfigId1 = "hosts/bogusname1/sentinel";
String sentinelConfigId2 = "hosts/bogusname2/sentinel";
String sentinelConfigId3 = "hosts/bogusname3/sentinel";
String sentinelConfigId4 = "hosts/bogusname4/sentinel";
SentinelConfig sentinel1 = model.getConfig(SentinelConfig.class, sentinelConfigId1);
SentinelConfig sentinel2 = model.getConfig(SentinelConfig.class, sentinelConfigId2);
SentinelConfig sentinel3 = model.getConfig(SentinelConfig.class, sentinelConfigId3);
SentinelConfig sentinel4 = model.getConfig(SentinelConfig.class, sentinelConfigId4);
assertServiceExists(sentinel1, "myservice", "mycmd1.sh", "myservice/0", true, true);
assertServiceExists(sentinel2, "myservice", "mycmd1.sh", "myservice/1", true, true);
assertServiceExists(sentinel3, "myservice", "mycmd1.sh", "myservice/2", true, true);
assertServiceExists(sentinel3, "myservice2", "mycmd1.sh", "myservice/3", true, true);
assertServiceExists(sentinel3, "myotherservice", "/home/vespa/bin/mycmd2.sh --ytest $FOO_BAR", "myotherservice/0", true, true);
assertServiceExists(sentinel4, "myotherservice", "/home/vespa/bin/mycmd2.sh --ytest $FOO_BAR", "myotherservice/1", true, true);
}
use of com.yahoo.cloud.config.SentinelConfig 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"));
}
Aggregations