Search in sources :

Example 1 with ConfigserverConfig

use of com.yahoo.cloud.config.ConfigserverConfig in project vespa by vespa-engine.

the class ConfigserverClusterTest method testConfigserverConfig.

@Test
public void testConfigserverConfig() {
    ConfigserverConfig config = root.getConfig(ConfigserverConfig.class, "configserver/standalone");
    assertThat(config.configModelPluginDir().size(), is(1));
    assertThat(config.configModelPluginDir().get(0), is(Defaults.getDefaults().underVespaHome("lib/jars/config-models")));
    assertThat(config.rpcport(), is(12345));
    assertThat(config.httpport(), is(1337));
    assertThat(config.serverId(), is(HostName.getLocalhost()));
    assertTrue(config.useVespaVersionInRequest());
    assertThat(config.numParallelTenantLoaders(), is(99));
    assertFalse(config.multitenant());
    assertTrue(config.hostedVespa());
    assertThat(config.environment(), is("test"));
    assertThat(config.region(), is("bar"));
}
Also used : ConfigserverConfig(com.yahoo.cloud.config.ConfigserverConfig) Test(org.junit.Test)

Example 2 with ConfigserverConfig

use of com.yahoo.cloud.config.ConfigserverConfig in project vespa by vespa-engine.

the class StatusHandlerTest method require_that_handler_works.

@Test
public void require_that_handler_works() throws IOException {
    TestComponentRegistry componentRegistry = new TestComponentRegistry.Builder().build();
    StatusHandler handler = new StatusHandler(StatusHandler.testOnlyContext(), componentRegistry);
    HttpResponse response = handler.handle(HttpRequest.createTestRequest("/status", GET));
    JsonNode jsonNode = mapper.readTree(SessionHandlerTest.getRenderedString(response));
    ConfigserverConfig expectedConfig = componentRegistry.getConfigserverConfig();
    assertEquals(expectedConfig.rpcport(), jsonNode.get("configserverConfig").get("rpcport").asInt());
    assertEquals(expectedConfig.applicationDirectory(), jsonNode.get("configserverConfig").get("applicationDirectory").asText());
    assertEquals(1, jsonNode.get("modelVersions").size());
}
Also used : ConfigserverConfig(com.yahoo.cloud.config.ConfigserverConfig) TestComponentRegistry(com.yahoo.vespa.config.server.TestComponentRegistry) HttpResponse(com.yahoo.container.jdisc.HttpResponse) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test) SessionHandlerTest(com.yahoo.vespa.config.server.http.SessionHandlerTest)

Example 3 with ConfigserverConfig

use of com.yahoo.cloud.config.ConfigserverConfig in project vespa by vespa-engine.

the class RemoteSessionTest method require_that_permanent_app_is_used.

@Test
public void require_that_permanent_app_is_used() {
    Optional<PermanentApplicationPackage> permanentApp = Optional.of(new PermanentApplicationPackage(new ConfigserverConfig(new ConfigserverConfig.Builder().applicationDirectory(Files.createTempDir().getAbsolutePath()))));
    MockModelFactory mockModelFactory = new MockModelFactory();
    try {
        int sessionId = 3;
        SessionZooKeeperClient zkc = new MockSessionZKClient(curator, tenantName, sessionId);
        createSession(sessionId, zkc, Collections.singletonList(mockModelFactory), permanentApp, mockModelFactory.clock()).ensureApplicationLoaded();
    } catch (Exception e) {
        e.printStackTrace();
    // ignore, we're not interested in deploy errors as long as the below state is OK.
    }
    assertNotNull(mockModelFactory.modelContext);
    assertTrue(mockModelFactory.modelContext.permanentApplicationPackage().isPresent());
}
Also used : ConfigserverConfig(com.yahoo.cloud.config.ConfigserverConfig) PermanentApplicationPackage(com.yahoo.vespa.config.server.application.PermanentApplicationPackage) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) Test(org.junit.Test)

Example 4 with ConfigserverConfig

use of com.yahoo.cloud.config.ConfigserverConfig in project vespa by vespa-engine.

the class RedeployTest method testPurgingOfOldNonActiveDeployments.

@Test
public void testPurgingOfOldNonActiveDeployments() {
    ManualClock clock = new ManualClock(Instant.now());
    ConfigserverConfig configserverConfig = new ConfigserverConfig(new ConfigserverConfig.Builder().configServerDBDir(Files.createTempDir().getAbsolutePath()).configDefinitionsDir(Files.createTempDir().getAbsolutePath()).sessionLifetime(60));
    DeployTester tester = new DeployTester("src/test/apps/app", configserverConfig, clock);
    // session 2 (numbering starts at 2)
    tester.deployApp("myapp", Instant.now());
    clock.advance(Duration.ofSeconds(10));
    Optional<com.yahoo.config.provision.Deployment> deployment2 = tester.redeployFromLocalActive();
    assertTrue(deployment2.isPresent());
    // session 3
    deployment2.get().activate();
    long activeSessionId = tester.tenant().getApplicationRepo().getSessionIdForApplication(tester.applicationId());
    clock.advance(Duration.ofSeconds(10));
    Optional<com.yahoo.config.provision.Deployment> deployment3 = tester.redeployFromLocalActive();
    assertTrue(deployment3.isPresent());
    // session 4 (not activated)
    deployment3.get().prepare();
    LocalSession deployment3session = ((Deployment) deployment3.get()).session();
    assertNotEquals(activeSessionId, deployment3session);
    // No change to active session id
    assertEquals(activeSessionId, tester.tenant().getApplicationRepo().getSessionIdForApplication(tester.applicationId()));
    assertEquals(3, tester.tenant().getLocalSessionRepo().listSessions().size());
    // longer than session lifetime
    clock.advance(Duration.ofHours(1));
    // All sessions except 3 should be removed after the call to purgeOldSessions
    tester.tenant().getLocalSessionRepo().purgeOldSessions();
    final Collection<LocalSession> sessions = tester.tenant().getLocalSessionRepo().listSessions();
    assertEquals(1, sessions.size());
    assertEquals(3, new ArrayList<>(sessions).get(0).getSessionId());
}
Also used : ConfigserverConfig(com.yahoo.cloud.config.ConfigserverConfig) ManualClock(com.yahoo.test.ManualClock) LocalSession(com.yahoo.vespa.config.server.session.LocalSession) Test(org.junit.Test)

Example 5 with ConfigserverConfig

use of com.yahoo.cloud.config.ConfigserverConfig in project vespa by vespa-engine.

the class FileServerTest method requireThatDifferentNumberOfConfigServersWork.

@Test
public void requireThatDifferentNumberOfConfigServersWork() throws IOException {
    // Empty connection pool in tests etc.
    ConfigserverConfig.Builder builder = new ConfigserverConfig.Builder();
    FileServer fileServer = new FileServer(new ConfigserverConfig(builder));
    assertEquals(0, fileServer.downloader().fileReferenceDownloader().connectionPool().getSize());
    // Empty connection pool when only one server, no use in downloading from yourself
    List<ConfigserverConfig.Zookeeperserver.Builder> servers = new ArrayList<>();
    ConfigserverConfig.Zookeeperserver.Builder serverBuilder = new ConfigserverConfig.Zookeeperserver.Builder();
    serverBuilder.hostname(HostName.getLocalhost());
    serverBuilder.port(123456);
    servers.add(serverBuilder);
    builder.zookeeperserver(servers);
    fileServer = new FileServer(new ConfigserverConfig(builder));
    assertEquals(0, fileServer.downloader().fileReferenceDownloader().connectionPool().getSize());
    // connection pool of size 1 when 2 servers
    ConfigserverConfig.Zookeeperserver.Builder serverBuilder2 = new ConfigserverConfig.Zookeeperserver.Builder();
    serverBuilder2.hostname("bar");
    serverBuilder2.port(123456);
    servers.add(serverBuilder2);
    builder.zookeeperserver(servers);
    fileServer = new FileServer(new ConfigserverConfig(builder));
    assertEquals(1, fileServer.downloader().fileReferenceDownloader().connectionPool().getSize());
}
Also used : ConfigserverConfig(com.yahoo.cloud.config.ConfigserverConfig) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

ConfigserverConfig (com.yahoo.cloud.config.ConfigserverConfig)23 Test (org.junit.Test)16 File (java.io.File)4 RpcServer (com.yahoo.vespa.config.server.rpc.RpcServer)3 Before (org.junit.Before)3 Zone (com.yahoo.config.provision.Zone)2 PermanentApplicationPackage (com.yahoo.vespa.config.server.application.PermanentApplicationPackage)2 DeployTester (com.yahoo.vespa.config.server.deploy.DeployTester)2 FileServer (com.yahoo.vespa.config.server.filedistribution.FileServer)2 HostRegistries (com.yahoo.vespa.config.server.host.HostRegistries)2 SessionHandlerTest (com.yahoo.vespa.config.server.http.SessionHandlerTest)2 VersionState (com.yahoo.vespa.config.server.version.VersionState)2 MockCurator (com.yahoo.vespa.curator.mock.MockCurator)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ComponentRegistry (com.yahoo.component.provider.ComponentRegistry)1 NullConfigModelRegistry (com.yahoo.config.model.NullConfigModelRegistry)1 DeployProperties (com.yahoo.config.model.deploy.DeployProperties)1 DeployState (com.yahoo.config.model.deploy.DeployState)1 MockRoot (com.yahoo.config.model.test.MockRoot)1 ApplicationId (com.yahoo.config.provision.ApplicationId)1