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"));
}
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());
}
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());
}
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());
}
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());
}
Aggregations