Search in sources :

Example 1 with NameResolver

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)));
    }
}
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

ApplicationId (com.yahoo.config.provision.ApplicationId)1 Zone (com.yahoo.config.provision.Zone)1 FlavorsConfig (com.yahoo.config.provisioning.FlavorsConfig)1 Curator (com.yahoo.vespa.curator.Curator)1 MockCurator (com.yahoo.vespa.curator.mock.MockCurator)1 NodeList (com.yahoo.vespa.hosted.provision.NodeList)1 NameResolver (com.yahoo.vespa.hosted.provision.persistence.NameResolver)1 MockNameResolver (com.yahoo.vespa.hosted.provision.testutils.MockNameResolver)1 Test (org.junit.Test)1