use of com.yahoo.vespa.hosted.provision.persistence.NameResolver 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