Search in sources :

Example 6 with MockCurator

use of com.yahoo.vespa.curator.mock.MockCurator 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 7 with MockCurator

use of com.yahoo.vespa.curator.mock.MockCurator 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 8 with MockCurator

use of com.yahoo.vespa.curator.mock.MockCurator in project vespa by vespa-engine.

the class LocalSessionTest method setupTest.

@Before
public void setupTest() throws Exception {
    curator = new MockCurator();
    configCurator = ConfigCurator.create(curator);
    superModelGenerationCounter = new SuperModelGenerationCounter(curator);
    tenantFileSystemDirs = new TenantFileSystemDirs(Files.createTempDir(), TenantName.from("test_tenant"));
}
Also used : TenantFileSystemDirs(com.yahoo.vespa.config.server.deploy.TenantFileSystemDirs) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Before(org.junit.Before)

Example 9 with MockCurator

use of com.yahoo.vespa.curator.mock.MockCurator in project vespa by vespa-engine.

the class ZKApplicationFileTest method getApplicationFile.

@Override
public ApplicationFile getApplicationFile(Path path) throws IOException {
    ConfigCurator configCurator = ConfigCurator.create(new MockCurator());
    File tmp = Files.createTempDir();
    writeAppTo(tmp);
    feed(configCurator, tmp);
    return new ZKApplicationFile(path, new ZKLiveApp(configCurator, Path.fromString("/0")));
}
Also used : ApplicationFile(com.yahoo.config.application.api.ApplicationFile) File(java.io.File) MockCurator(com.yahoo.vespa.curator.mock.MockCurator)

Example 10 with MockCurator

use of com.yahoo.vespa.curator.mock.MockCurator in project vespa by vespa-engine.

the class CuratorCounterTest method testCounter.

@Test
public void testCounter() throws Exception {
    DistributedAtomicLong counter = new MockCurator().createAtomicCounter("/mycounter");
    counter.initialize(4l);
    assertEquals(4l, counter.get().postValue().longValue());
    assertEquals(5l, counter.increment().postValue().longValue());
}
Also used : DistributedAtomicLong(org.apache.curator.framework.recipes.atomic.DistributedAtomicLong) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Test(org.junit.Test)

Aggregations

MockCurator (com.yahoo.vespa.curator.mock.MockCurator)29 Test (org.junit.Test)16 Before (org.junit.Before)11 Curator (com.yahoo.vespa.curator.Curator)6 ConfigCurator (com.yahoo.vespa.config.server.zookeeper.ConfigCurator)5 MockNameResolver (com.yahoo.vespa.hosted.provision.testutils.MockNameResolver)5 DockerImage (com.yahoo.config.provision.DockerImage)4 NodeRepository (com.yahoo.vespa.hosted.provision.NodeRepository)4 File (java.io.File)4 NullConfigModelRegistry (com.yahoo.config.model.NullConfigModelRegistry)3 NodeFlavors (com.yahoo.config.provision.NodeFlavors)3 Zone (com.yahoo.config.provision.Zone)3 Path (com.yahoo.path.Path)3 ModelFactoryRegistry (com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry)3 VespaModelFactory (com.yahoo.vespa.model.VespaModelFactory)3 ConfigserverConfig (com.yahoo.cloud.config.ConfigserverConfig)2 ManualClock (com.yahoo.test.ManualClock)2 TestComponentRegistry (com.yahoo.vespa.config.server.TestComponentRegistry)2 MemoryTenantApplications (com.yahoo.vespa.config.server.application.MemoryTenantApplications)2 SessionHandlerTest (com.yahoo.vespa.config.server.http.SessionHandlerTest)2