Search in sources :

Example 21 with MockCurator

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

the class CuratorCompletionWaiterTest method testCompletionWaiter.

@Test
public void testCompletionWaiter() throws InterruptedException {
    Curator curator = new MockCurator();
    Curator.CompletionWaiter waiter = CuratorCompletionWaiter.createAndInitialize(curator, Path.createRoot(), "foo", 1, "foo");
    Curator.CompletionWaiter notifier = CuratorCompletionWaiter.create(curator.framework(), Path.fromString("/foo"), 1, "bar");
    Thread t1 = new Thread(() -> {
        try {
            waiter.awaitCompletion(Duration.ofSeconds(120));
        } catch (CompletionTimeoutException e) {
            fail("Waiting failed due to timeout");
        }
    });
    notifier.notifyCompletion();
    t1.join();
}
Also used : MockCurator(com.yahoo.vespa.curator.mock.MockCurator) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Test(org.junit.Test)

Example 22 with MockCurator

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

the class CuratorLockTest method setupLock.

@Before
public void setupLock() {
    curator = new MockCurator();
    curatorLock = new CuratorLock(curator, "/foo");
}
Also used : MockCurator(com.yahoo.vespa.curator.mock.MockCurator) CuratorLock(com.yahoo.vespa.curator.recipes.CuratorLock) Before(org.junit.Before)

Example 23 with MockCurator

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

the class CuratorDatabaseTest method testThatCounterIncreasesAlsoOnCommitFailure.

@Test
public void testThatCounterIncreasesAlsoOnCommitFailure() throws Exception {
    MockCurator curator = new MockCurator();
    CuratorDatabase database = new CuratorDatabase(curator, Path.fromString("/"), true);
    assertEquals(0L, (long) curator.counter("/changeCounter").get().get().postValue());
    try {
        // fail as parent does not exist
        commitCreate("/1/2", database);
        fail("Expected exception");
    } catch (Exception expected) {
    // expected because the parent does not exist
    }
    assertEquals(1L, (long) curator.counter("/changeCounter").get().get().postValue());
}
Also used : MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Test(org.junit.Test)

Example 24 with MockCurator

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

the class AclProvisioningTest method before.

@Before
public void before() {
    this.curator = new MockCurator();
    this.nameResolver = new MockNameResolver().mockAnyLookup();
    this.tester = new ProvisioningTester(Zone.defaultZone(), createConfig(), curator, nameResolver);
}
Also used : MockNameResolver(com.yahoo.vespa.hosted.provision.testutils.MockNameResolver) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Before(org.junit.Before)

Example 25 with MockCurator

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

the class ProvisioningTest method application_deployment_retires_nodes_having_retired_flavor.

@Test
public void application_deployment_retires_nodes_having_retired_flavor() {
    String flavorToRetire = "default";
    String replacementFlavor = "new-default";
    ApplicationId application = ApplicationId.from(TenantName.from(UUID.randomUUID().toString()), ApplicationName.from(UUID.randomUUID().toString()), InstanceName.from(UUID.randomUUID().toString()));
    Curator curator = new MockCurator();
    NameResolver nameResolver = new MockNameResolver().mockAnyLookup();
    // Deploy with flavor that will eventually be retired
    {
        FlavorConfigBuilder b = new FlavorConfigBuilder();
        b.addFlavor("default", 1., 1., 10, Flavor.Type.BARE_METAL).cost(2);
        ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")), b.build(), curator, nameResolver);
        tester.makeReadyNodes(4, flavorToRetire);
        SystemState state = prepare(application, 2, 0, 2, 0, flavorToRetire, tester);
        tester.activate(application, state.allHosts);
    }
    // Re-deploy with same flavor, which is now retired
    {
        // Retire "default" flavor and add "new-default" as replacement
        FlavorConfigBuilder b = new FlavorConfigBuilder();
        b.addFlavor(flavorToRetire, 1., 1., 10, Flavor.Type.BARE_METAL).cost(2).retired(true);
        FlavorsConfig.Flavor.Builder newDefault = b.addFlavor(replacementFlavor, 2., 2., 20, Flavor.Type.BARE_METAL).cost(2);
        b.addReplaces(flavorToRetire, newDefault);
        ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")), b.build(), curator, nameResolver);
        // Add nodes with "new-default" flavor
        tester.makeReadyNodes(4, replacementFlavor);
        SystemState state = prepare(application, 2, 0, 2, 0, flavorToRetire, tester);
        tester.activate(application, state.allHosts);
        // Nodes with retired flavor are retired
        NodeList retired = tester.getNodes(application).retired();
        assertEquals(4, retired.size());
        assertTrue("Nodes are retired by system", retired.asList().stream().allMatch(retiredBy(Agent.system)));
    }
}
Also used : MockNameResolver(com.yahoo.vespa.hosted.provision.testutils.MockNameResolver) Zone(com.yahoo.config.provision.Zone) NodeList(com.yahoo.vespa.hosted.provision.NodeList) Curator(com.yahoo.vespa.curator.Curator) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) ApplicationId(com.yahoo.config.provision.ApplicationId) FlavorsConfig(com.yahoo.config.provisioning.FlavorsConfig) NameResolver(com.yahoo.vespa.hosted.provision.persistence.NameResolver) MockNameResolver(com.yahoo.vespa.hosted.provision.testutils.MockNameResolver) 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