use of com.yahoo.vespa.model.VespaModel 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.vespa.model.VespaModel 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.vespa.model.VespaModel 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));
}
use of com.yahoo.vespa.model.VespaModel in project vespa by vespa-engine.
the class DedicatedAdminV4Test method testLogForwarding.
@Test
public void testLogForwarding() throws IOException, SAXException {
String services = "<services>" + " <admin version='4.0'>" + " <slobroks><nodes count='2' dedicated='true'/></slobroks>" + " <logservers><nodes count='1' dedicated='true'/></logservers>" + " <logforwarding>" + " <splunk deployment-server='foo:123' client-name='foocli'/>" + " </logforwarding>" + " </admin>" + "</services>";
VespaModel model = createModel(hosts, services);
assertEquals(3, model.getHosts().size());
assertHostContainsServices(model, "hosts/myhost0", "logd", "logforwarder", "slobrok");
assertHostContainsServices(model, "hosts/myhost1", "logd", "logforwarder", "slobrok");
assertHostContainsServices(model, "hosts/myhost2", "logd", "logforwarder", "logserver");
Set<String> configIds = model.getConfigIds();
// 1 logforwarder on each host
IntStream.of(0, 1, 2).forEach(i -> assertTrue(configIds.toString(), configIds.contains("hosts/myhost" + i + "/logforwarder")));
// First forwarder
{
LogforwarderConfig.Builder builder = new LogforwarderConfig.Builder();
model.getConfig(builder, "hosts/myhost0/logforwarder");
LogforwarderConfig config = new LogforwarderConfig(builder);
assertEquals("foo:123", config.deploymentServer());
assertEquals("foocli", config.clientName());
assertEquals("/opt/splunkforwarder", config.splunkHome());
}
// Other host's forwarder
{
LogforwarderConfig.Builder builder = new LogforwarderConfig.Builder();
model.getConfig(builder, "hosts/myhost2/logforwarder");
LogforwarderConfig config = new LogforwarderConfig(builder);
assertEquals("foo:123", config.deploymentServer());
assertEquals("foocli", config.clientName());
}
}
use of com.yahoo.vespa.model.VespaModel in project vespa by vespa-engine.
the class ValidationTester method deploy.
/**
* Deploys an application
*
* @param previousModel the previous model, or null if no previous
* @param services the services file content
* @param validationOverrides the validation overrides file content, or null if none
* @return the new model and any change actions
*/
public Pair<VespaModel, List<ConfigChangeAction>> deploy(VespaModel previousModel, String services, String validationOverrides) {
Instant now = LocalDate.parse("2000-01-01", DateTimeFormatter.ISO_DATE).atStartOfDay().atZone(ZoneOffset.UTC).toInstant();
ApplicationPackage newApp = new MockApplicationPackage.Builder().withServices(services).withSearchDefinition(MockApplicationPackage.MUSIC_SEARCHDEFINITION).withValidationOverrides(validationOverrides).build();
VespaModelCreatorWithMockPkg newModelCreator = new VespaModelCreatorWithMockPkg(newApp);
DeployState.Builder deployStateBuilder = new DeployState.Builder().applicationPackage(newApp).properties(new DeployProperties.Builder().hostedVespa(true).build()).modelHostProvisioner(new InMemoryProvisioner(nodeCount)).now(now);
if (previousModel != null)
deployStateBuilder.previousModel(previousModel);
VespaModel newModel = newModelCreator.create(deployStateBuilder);
return new Pair<>(newModel, newModelCreator.configChangeActions);
}
Aggregations