Search in sources :

Example 1 with InMemoryProvisioner

use of com.yahoo.config.model.provision.InMemoryProvisioner in project vespa by vespa-engine.

the class DeployStateTest method testProvisionerIsSet.

@Test
public void testProvisionerIsSet() {
    DeployState.Builder builder = new DeployState.Builder();
    HostProvisioner provisioner = new InMemoryProvisioner(true, "foo.yahoo.com");
    builder.modelHostProvisioner(provisioner);
    DeployState state = builder.build(true);
    assertThat(state.getProvisioner(), is(provisioner));
}
Also used : InMemoryProvisioner(com.yahoo.config.model.provision.InMemoryProvisioner) HostProvisioner(com.yahoo.config.model.api.HostProvisioner) Test(org.junit.Test)

Example 2 with InMemoryProvisioner

use of com.yahoo.config.model.provision.InMemoryProvisioner in project vespa by vespa-engine.

the class ValidationTester method deploy.

/**
 * Deploys an application
 *
 * @param previousModel the previous model, or null if no previous
 * @param services the services file content
 * @param validationOverrides the validation overrides file content, or null if none
 * @return the new model and any change actions
 */
public Pair<VespaModel, List<ConfigChangeAction>> deploy(VespaModel previousModel, String services, String validationOverrides) {
    Instant now = LocalDate.parse("2000-01-01", DateTimeFormatter.ISO_DATE).atStartOfDay().atZone(ZoneOffset.UTC).toInstant();
    ApplicationPackage newApp = new MockApplicationPackage.Builder().withServices(services).withSearchDefinition(MockApplicationPackage.MUSIC_SEARCHDEFINITION).withValidationOverrides(validationOverrides).build();
    VespaModelCreatorWithMockPkg newModelCreator = new VespaModelCreatorWithMockPkg(newApp);
    DeployState.Builder deployStateBuilder = new DeployState.Builder().applicationPackage(newApp).properties(new DeployProperties.Builder().hostedVespa(true).build()).modelHostProvisioner(new InMemoryProvisioner(nodeCount)).now(now);
    if (previousModel != null)
        deployStateBuilder.previousModel(previousModel);
    VespaModel newModel = newModelCreator.create(deployStateBuilder);
    return new Pair<>(newModel, newModelCreator.configChangeActions);
}
Also used : VespaModelCreatorWithMockPkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg) DeployState(com.yahoo.config.model.deploy.DeployState) InMemoryProvisioner(com.yahoo.config.model.provision.InMemoryProvisioner) Instant(java.time.Instant) DeployProperties(com.yahoo.config.model.deploy.DeployProperties) VespaModel(com.yahoo.vespa.model.VespaModel) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) Pair(com.yahoo.collections.Pair)

Example 3 with InMemoryProvisioner

use of com.yahoo.config.model.provision.InMemoryProvisioner in project vespa by vespa-engine.

the class ContainerModelBuilderTest method singlenode_servicespec_is_used_with_hosted_vespa.

@Test
public void singlenode_servicespec_is_used_with_hosted_vespa() throws IOException, SAXException {
    String servicesXml = "<jdisc id='default' version='1.0' />";
    ApplicationPackage applicationPackage = new MockApplicationPackage.Builder().withServices(servicesXml).build();
    VespaModel model = new VespaModel(new NullConfigModelRegistry(), new DeployState.Builder().modelHostProvisioner(new InMemoryProvisioner(true, "host1.yahoo.com", "host2.yahoo.com")).applicationPackage(applicationPackage).properties(new DeployProperties.Builder().multitenant(true).hostedVespa(true).build()).build(true));
    assertEquals(1, model.getHostSystem().getHosts().size());
}
Also used : NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) DeployState(com.yahoo.config.model.deploy.DeployState) InMemoryProvisioner(com.yahoo.config.model.provision.InMemoryProvisioner) VespaModel(com.yahoo.vespa.model.VespaModel) Matchers.containsString(org.hamcrest.Matchers.containsString) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest) Test(org.junit.Test)

Example 4 with InMemoryProvisioner

use of com.yahoo.config.model.provision.InMemoryProvisioner in project vespa by vespa-engine.

the class VespaModelTester method createModel.

/**
 * Creates a model using the hosts already added to this
 *
 * @param services the services xml string
 * @param failOnOutOfCapacity whether we should get an exception when not enough hosts of the requested flavor
 *        is available or if we should just silently receive a smaller allocation
 * @return the resulting model
 */
public VespaModel createModel(String services, boolean failOnOutOfCapacity, int startIndexForClusters, String... retiredHostNames) {
    VespaModelCreatorWithMockPkg modelCreatorWithMockPkg = new VespaModelCreatorWithMockPkg(null, services, ApplicationPackageUtils.generateSearchDefinition("type1"));
    ApplicationPackage appPkg = modelCreatorWithMockPkg.appPkg;
    HostProvisioner provisioner = hosted ? new InMemoryProvisioner(hostsByFlavor, failOnOutOfCapacity, startIndexForClusters, retiredHostNames) : new SingleNodeProvisioner();
    DeployProperties properties = new DeployProperties.Builder().hostedVespa(hosted).applicationId(applicationId).build();
    DeployState deployState = new DeployState.Builder().applicationPackage(appPkg).modelHostProvisioner(provisioner).properties(properties).build(true);
    return modelCreatorWithMockPkg.create(false, deployState, configModelRegistry);
}
Also used : SingleNodeProvisioner(com.yahoo.config.model.provision.SingleNodeProvisioner) VespaModelCreatorWithMockPkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg) DeployState(com.yahoo.config.model.deploy.DeployState) InMemoryProvisioner(com.yahoo.config.model.provision.InMemoryProvisioner) DeployProperties(com.yahoo.config.model.deploy.DeployProperties) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) HostProvisioner(com.yahoo.config.model.api.HostProvisioner)

Example 5 with InMemoryProvisioner

use of com.yahoo.config.model.provision.InMemoryProvisioner in project vespa by vespa-engine.

the class StaticProvisionerTest method sameHostsAreProvisioned.

@Test
public void sameHostsAreProvisioned() throws IOException, SAXException {
    ApplicationPackage app = FilesApplicationPackage.fromFile(new File("src/test/apps/hosted"));
    InMemoryProvisioner inMemoryHostProvisioner = new InMemoryProvisioner(false, "host1.yahoo.com", "host2.yahoo.com", "host3.yahoo.com", "host4.yahoo.com");
    VespaModel firstModel = createModel(app, inMemoryHostProvisioner);
    StaticProvisioner staticProvisioner = new StaticProvisioner(firstModel.allocatedHosts());
    VespaModel secondModel = createModel(app, staticProvisioner);
    assertModelConfig(firstModel, secondModel);
}
Also used : InMemoryProvisioner(com.yahoo.config.model.provision.InMemoryProvisioner) VespaModel(com.yahoo.vespa.model.VespaModel) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) FilesApplicationPackage(com.yahoo.config.model.application.provider.FilesApplicationPackage) File(java.io.File) Test(org.junit.Test)

Aggregations

InMemoryProvisioner (com.yahoo.config.model.provision.InMemoryProvisioner)7 ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)6 DeployState (com.yahoo.config.model.deploy.DeployState)5 VespaModel (com.yahoo.vespa.model.VespaModel)5 DeployProperties (com.yahoo.config.model.deploy.DeployProperties)4 MockApplicationPackage (com.yahoo.config.model.test.MockApplicationPackage)4 Test (org.junit.Test)4 VespaModelCreatorWithMockPkg (com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg)3 NullConfigModelRegistry (com.yahoo.config.model.NullConfigModelRegistry)2 HostProvisioner (com.yahoo.config.model.api.HostProvisioner)2 FilesApplicationPackage (com.yahoo.config.model.application.provider.FilesApplicationPackage)2 Pair (com.yahoo.collections.Pair)1 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)1 SingleNodeProvisioner (com.yahoo.config.model.provision.SingleNodeProvisioner)1 AllocatedHosts (com.yahoo.config.provision.AllocatedHosts)1 File (java.io.File)1 Instant (java.time.Instant)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1