Search in sources :

Example 1 with SentinelConfig

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");
}
Also used : ApplicationConfigProducerRoot(com.yahoo.config.model.ApplicationConfigProducerRoot) SentinelConfig(com.yahoo.cloud.config.SentinelConfig) Test(org.junit.Test)

Example 2 with SentinelConfig

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 + ".*"));
}
Also used : SlobroksConfig(com.yahoo.cloud.config.SlobroksConfig) ApplicationConfigProducerRoot(com.yahoo.config.model.ApplicationConfigProducerRoot) SentinelConfig(com.yahoo.cloud.config.SentinelConfig) VespaModel(com.yahoo.vespa.model.VespaModel) Test(org.junit.Test)

Example 3 with SentinelConfig

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"));
}
Also used : SlobroksConfig(com.yahoo.cloud.config.SlobroksConfig) LogdConfig(com.yahoo.cloud.config.log.LogdConfig) ApplicationConfigProducerRoot(com.yahoo.config.model.ApplicationConfigProducerRoot) SentinelConfig(com.yahoo.cloud.config.SentinelConfig) VespaModel(com.yahoo.vespa.model.VespaModel) Slobrok(com.yahoo.cloud.config.SlobroksConfig.Slobrok) Test(org.junit.Test)

Example 4 with SentinelConfig

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);
}
Also used : SentinelConfig(com.yahoo.cloud.config.SentinelConfig) Test(org.junit.Test)

Example 5 with SentinelConfig

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"));
}
Also used : DeployState(com.yahoo.config.model.deploy.DeployState) SentinelConfig(com.yahoo.cloud.config.SentinelConfig) Zone(com.yahoo.config.provision.Zone) TestRoot(com.yahoo.config.model.test.TestRoot) TestDriver(com.yahoo.config.model.test.TestDriver) Test(org.junit.Test)

Aggregations

SentinelConfig (com.yahoo.cloud.config.SentinelConfig)7 Test (org.junit.Test)7 ApplicationConfigProducerRoot (com.yahoo.config.model.ApplicationConfigProducerRoot)3 VespaModel (com.yahoo.vespa.model.VespaModel)3 SlobroksConfig (com.yahoo.cloud.config.SlobroksConfig)2 DeployState (com.yahoo.config.model.deploy.DeployState)2 TestDriver (com.yahoo.config.model.test.TestDriver)2 TestRoot (com.yahoo.config.model.test.TestRoot)2 Zone (com.yahoo.config.provision.Zone)2 Slobrok (com.yahoo.cloud.config.SlobroksConfig.Slobrok)1 LogdConfig (com.yahoo.cloud.config.log.LogdConfig)1 VespaModelCreatorWithMockPkg (com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg)1