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