Search in sources :

Example 1 with ConfigCurator

use of com.yahoo.vespa.config.server.zookeeper.ConfigCurator in project vespa by vespa-engine.

the class ZooKeeperDeployerTest method require_that_deployer_is_initialized.

@Test
public void require_that_deployer_is_initialized() throws IOException, ParseException {
    ConfigCurator zkfacade = ConfigCurator.create(new MockCurator());
    File serverdbDir = folder.newFolder("serverdb");
    File defsDir = new File(serverdbDir, "serverdefs");
    try {
        IOUtils.createWriter(new File(defsDir, defFile), true);
    } catch (IOException e) {
        e.printStackTrace();
        fail();
    }
    deploy(FilesApplicationPackage.fromFile(new File("src/test/apps/content")), zkfacade, Path.fromString("/1"));
    deploy(FilesApplicationPackage.fromFile(new File("src/test/apps/content")), zkfacade, Path.fromString("/2"));
}
Also used : ConfigCurator(com.yahoo.vespa.config.server.zookeeper.ConfigCurator) IOException(java.io.IOException) File(java.io.File) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Test(org.junit.Test)

Example 2 with ConfigCurator

use of com.yahoo.vespa.config.server.zookeeper.ConfigCurator in project vespa by vespa-engine.

the class InjectedGlobalComponentRegistryTest method setupRegistry.

@Before
public void setupRegistry() {
    curator = new MockCurator();
    ConfigCurator configCurator = ConfigCurator.create(curator);
    metrics = Metrics.createTestMetrics();
    modelFactoryRegistry = new ModelFactoryRegistry(Collections.singletonList(new VespaModelFactory(new NullConfigModelRegistry())));
    configserverConfig = new ConfigserverConfig(new ConfigserverConfig.Builder().configServerDBDir(Files.createTempDir().getAbsolutePath()).configDefinitionsDir(Files.createTempDir().getAbsolutePath()));
    serverDB = new ConfigServerDB(configserverConfig);
    sessionPreparer = new SessionTest.MockSessionPreparer();
    rpcServer = new RpcServer(configserverConfig, null, Metrics.createTestMetrics(), new HostRegistries(), new ConfigRequestHostLivenessTracker(), new FileServer(FileDistribution.getDefaultFileDBPath()));
    generationCounter = new SuperModelGenerationCounter(curator);
    defRepo = new StaticConfigDefinitionRepo();
    permanentApplicationPackage = new PermanentApplicationPackage(configserverConfig);
    hostRegistries = new HostRegistries();
    HostProvisionerProvider hostProvisionerProvider = HostProvisionerProvider.withProvisioner(new SessionHandlerTest.MockProvisioner());
    zone = Zone.defaultZone();
    globalComponentRegistry = new InjectedGlobalComponentRegistry(curator, configCurator, metrics, modelFactoryRegistry, serverDB, sessionPreparer, rpcServer, configserverConfig, generationCounter, defRepo, permanentApplicationPackage, hostRegistries, hostProvisionerProvider, zone);
}
Also used : ConfigserverConfig(com.yahoo.cloud.config.ConfigserverConfig) HostRegistries(com.yahoo.vespa.config.server.host.HostRegistries) HostProvisionerProvider(com.yahoo.vespa.config.server.provision.HostProvisionerProvider) ModelFactoryRegistry(com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry) ConfigRequestHostLivenessTracker(com.yahoo.vespa.config.server.host.ConfigRequestHostLivenessTracker) VespaModelFactory(com.yahoo.vespa.model.VespaModelFactory) NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) ConfigCurator(com.yahoo.vespa.config.server.zookeeper.ConfigCurator) SessionHandlerTest(com.yahoo.vespa.config.server.http.SessionHandlerTest) RpcServer(com.yahoo.vespa.config.server.rpc.RpcServer) PermanentApplicationPackage(com.yahoo.vespa.config.server.application.PermanentApplicationPackage) FileServer(com.yahoo.vespa.config.server.filedistribution.FileServer) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Before(org.junit.Before)

Example 3 with ConfigCurator

use of com.yahoo.vespa.config.server.zookeeper.ConfigCurator in project vespa by vespa-engine.

the class ZooKeeperClientTest method testFeedComponentsFileReferencesToZooKeeper.

// TODO: Evaluate if we want this or not
@Test
@Ignore
public void testFeedComponentsFileReferencesToZooKeeper() throws IOException {
    final String appDir = "src/test/apps/app_sdbundles";
    ConfigCurator zk = ConfigCurator.create(new MockCurator());
    BaseDeployLogger logger = new BaseDeployLogger();
    Path app = Path.fromString("/1");
    ZooKeeperClient zooKeeperClient = new ZooKeeperClient(zk, logger, true, app);
    zooKeeperClient.setupZooKeeper();
    String currentAppPath = app.getAbsolute();
    assertTrue(zk.exists(currentAppPath, ConfigCurator.USERAPP_ZK_SUBPATH.replaceFirst("/", "")));
    assertTrue(zk.exists(currentAppPath + ConfigCurator.USERAPP_ZK_SUBPATH, "components"));
    assertTrue(zk.exists(currentAppPath + ConfigCurator.USERAPP_ZK_SUBPATH + "/components", "testbundle.jar"));
    assertTrue(zk.exists(currentAppPath + ConfigCurator.USERAPP_ZK_SUBPATH + "/components", "testbundle2.jar"));
    String data = zk.getData(currentAppPath + ConfigCurator.USERAPP_ZK_SUBPATH + "/components", "testbundle2.jar");
    assertThat(data, is(new File(appDir + "/components/testbundle2.jar").getAbsolutePath()));
}
Also used : Path(com.yahoo.path.Path) ConfigCurator(com.yahoo.vespa.config.server.zookeeper.ConfigCurator) File(java.io.File) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with ConfigCurator

use of com.yahoo.vespa.config.server.zookeeper.ConfigCurator in project vespa by vespa-engine.

the class ZooKeeperClientTest method testInitZooKeeper.

@Test
public void testInitZooKeeper() throws IOException {
    ConfigCurator zk = ConfigCurator.create(new MockCurator());
    BaseDeployLogger logger = new BaseDeployLogger();
    long generation = 1L;
    ZooKeeperClient zooKeeperClient = new ZooKeeperClient(zk, logger, true, Path.fromString("/1"));
    zooKeeperClient.setupZooKeeper();
    String appPath = "/";
    assertThat(zk.getChildren(appPath).size(), is(1));
    assertTrue(zk.exists("/" + String.valueOf(generation)));
    String currentAppPath = appPath + String.valueOf(generation);
    assertTrue(zk.exists(currentAppPath, ConfigCurator.DEFCONFIGS_ZK_SUBPATH.replaceFirst("/", "")));
    assertThat(zk.getChildren(currentAppPath).size(), is(4));
}
Also used : ConfigCurator(com.yahoo.vespa.config.server.zookeeper.ConfigCurator) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Test(org.junit.Test)

Example 5 with ConfigCurator

use of com.yahoo.vespa.config.server.zookeeper.ConfigCurator in project vespa by vespa-engine.

the class ZooKeeperClientTest method testWritingHostNamesToZooKeeper.

@Test
public void testWritingHostNamesToZooKeeper() throws IOException {
    ConfigCurator zk = ConfigCurator.create(new MockCurator());
    BaseDeployLogger logger = new BaseDeployLogger();
    Path app = Path.fromString("/1");
    ZooKeeperClient zooKeeperClient = new ZooKeeperClient(zk, logger, true, app);
    zooKeeperClient.setupZooKeeper();
    HostSpec host1 = new HostSpec("host1.yahoo.com", Collections.emptyList());
    HostSpec host2 = new HostSpec("host2.yahoo.com", Collections.emptyList());
    ImmutableSet<HostSpec> hosts = ImmutableSet.of(host1, host2);
    zooKeeperClient.write(AllocatedHosts.withHosts(hosts));
    Path hostsPath = app.append(ZKApplicationPackage.allocatedHostsNode);
    assertTrue(zk.exists(hostsPath.getAbsolute()));
    AllocatedHosts deserialized = AllocatedHosts.fromJson(zk.getBytes(hostsPath.getAbsolute()), Optional.empty());
    assertEquals(hosts, deserialized.getHosts());
}
Also used : Path(com.yahoo.path.Path) ConfigCurator(com.yahoo.vespa.config.server.zookeeper.ConfigCurator) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Test(org.junit.Test)

Aggregations

ConfigCurator (com.yahoo.vespa.config.server.zookeeper.ConfigCurator)5 MockCurator (com.yahoo.vespa.curator.mock.MockCurator)5 Test (org.junit.Test)4 Path (com.yahoo.path.Path)2 File (java.io.File)2 ConfigserverConfig (com.yahoo.cloud.config.ConfigserverConfig)1 NullConfigModelRegistry (com.yahoo.config.model.NullConfigModelRegistry)1 PermanentApplicationPackage (com.yahoo.vespa.config.server.application.PermanentApplicationPackage)1 FileServer (com.yahoo.vespa.config.server.filedistribution.FileServer)1 ConfigRequestHostLivenessTracker (com.yahoo.vespa.config.server.host.ConfigRequestHostLivenessTracker)1 HostRegistries (com.yahoo.vespa.config.server.host.HostRegistries)1 SessionHandlerTest (com.yahoo.vespa.config.server.http.SessionHandlerTest)1 ModelFactoryRegistry (com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry)1 HostProvisionerProvider (com.yahoo.vespa.config.server.provision.HostProvisionerProvider)1 RpcServer (com.yahoo.vespa.config.server.rpc.RpcServer)1 VespaModelFactory (com.yahoo.vespa.model.VespaModelFactory)1 IOException (java.io.IOException)1 Before (org.junit.Before)1 Ignore (org.junit.Ignore)1