Search in sources :

Example 16 with DeployState

use of com.yahoo.config.model.deploy.DeployState in project vespa by vespa-engine.

the class StorageNodeTest method getConfig.

private StorDevicesConfig getConfig(boolean useVdsEngine) {
    String vdsConfig = useVdsEngine ? "    <engine>" + "      <vds/>" + "    </engine>" : "";
    String servicesXml = "<?xml version='1.0' encoding='utf-8' ?>" + "<services version='1.0'>" + "  <admin version='2.0'>" + "    <adminserver hostalias='node0'/>" + "  </admin>" + "  <content version='1.0' id='zoo'>" + "    <redundancy>1</redundancy>" + "    <nodes count='1' />" + "    <documents>" + "      <document type='type1' mode='streaming' />" + "    </documents>" + vdsConfig + "  </content>" + "</services>";
    List<String> searchDefinitions = ApplicationPackageUtils.generateSearchDefinition("type1");
    VespaModelCreatorWithMockPkg modelCreator = new VespaModelCreatorWithMockPkg(null, servicesXml, searchDefinitions);
    ApplicationPackage appPkg = modelCreator.appPkg;
    boolean failOnOutOfCapacity = true;
    InMemoryProvisioner provisioner = new InMemoryProvisioner(failOnOutOfCapacity, "host1.yahoo.com", "host2.yahoo.com");
    DeployProperties.Builder builder = new DeployProperties.Builder();
    DeployProperties properties = builder.hostedVespa(true).build();
    DeployState deployState = new DeployState.Builder().applicationPackage(appPkg).modelHostProvisioner(provisioner).properties(properties).build(true);
    VespaModel model = modelCreator.create(true, deployState);
    return model.getConfig(StorDevicesConfig.class, "zoo/storage/0");
}
Also used : 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) VespaModel(com.yahoo.vespa.model.VespaModel) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage)

Example 17 with DeployState

use of com.yahoo.config.model.deploy.DeployState in project vespa by vespa-engine.

the class VespaModelFactory method createAndValidateModel.

@Override
public ModelCreateResult createAndValidateModel(ModelContext modelContext, boolean ignoreValidationErrors) {
    validateXml(modelContext, ignoreValidationErrors);
    DeployState deployState = createDeployState(modelContext, true);
    VespaModel model = buildModel(deployState);
    List<ConfigChangeAction> changeActions = validateModel(model, deployState, ignoreValidationErrors);
    return new ModelCreateResult(model, changeActions);
}
Also used : ModelCreateResult(com.yahoo.config.model.api.ModelCreateResult) DeployState(com.yahoo.config.model.deploy.DeployState) ConfigChangeAction(com.yahoo.config.model.api.ConfigChangeAction)

Example 18 with DeployState

use of com.yahoo.config.model.deploy.DeployState in project vespa by vespa-engine.

the class ConfigModelContextTest method testConfigModelContext.

@Test
public void testConfigModelContext() {
    AbstractConfigProducer root = new MockRoot();
    String id = "foobar";
    ApplicationPackage pkg = new MockApplicationPackage.Builder().withServices("<services version=\"1.0\"><admin version=\"2.0\" /></services>").build();
    DeployState deployState = DeployState.createTestState(pkg);
    DeployLogger logger = deployState.getDeployLogger();
    ConfigModelContext ctx = ConfigModelContext.create(deployState, null, root, id);
    assertThat(ctx.getApplicationPackage(), is(pkg));
    assertThat(ctx.getProducerId(), is(id));
    assertThat(ctx.getParentProducer(), is(root));
    assertThat(ctx.getDeployLogger(), is(logger));
    ctx = ConfigModelContext.create(null, root, id);
    assertThat(ctx.getProducerId(), is(id));
    assertThat(ctx.getParentProducer(), is(root));
    AbstractConfigProducer newRoot = new MockRoot("bar");
    ctx = ctx.withParent(newRoot);
    assertThat(ctx.getProducerId(), is(id));
    assertThat(ctx.getParentProducer(), is(not(root)));
    assertThat(ctx.getParentProducer(), is(newRoot));
}
Also used : MockRoot(com.yahoo.config.model.test.MockRoot) DeployState(com.yahoo.config.model.deploy.DeployState) AbstractConfigProducer(com.yahoo.config.model.producer.AbstractConfigProducer) DeployLogger(com.yahoo.config.application.api.DeployLogger) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) Test(org.junit.Test)

Example 19 with DeployState

use of com.yahoo.config.model.deploy.DeployState in project vespa by vespa-engine.

the class ApplicationDeployTest method testConfigDefinitionsAndNamespaces.

/**
 * Tests that config definitions with namespace are treated properly when they have the format
 * as in the config definitions dir ($VESPA_HOME/share/vespa/configdefinitions on a machine
 * with Vespa packages installed) (does not test when read from user def files). Also tests a config
 * definition without version in file name
 */
@Test
public void testConfigDefinitionsAndNamespaces() {
    final File appDir = new File("src/test/cfg/application/configdeftest");
    FilesApplicationPackage app = FilesApplicationPackage.fromFile(appDir);
    DeployState deployState = new DeployState.Builder().applicationPackage(app).build(true);
    ConfigDefinition def = deployState.getConfigDefinition(new ConfigDefinitionKey("foo", CNode.DEFAULT_NAMESPACE)).get();
    assertThat(def.getNamespace(), is(CNode.DEFAULT_NAMESPACE));
    def = deployState.getConfigDefinition(new ConfigDefinitionKey("baz", "xyzzy")).get();
    assertThat(def.getNamespace(), is("xyzzy"));
    def = deployState.getConfigDefinition(new ConfigDefinitionKey("foo", "qux")).get();
    assertThat(def.getNamespace(), is("qux"));
    // A config def without version in filename and version in file header
    def = deployState.getConfigDefinition(new ConfigDefinitionKey("xyzzy", CNode.DEFAULT_NAMESPACE)).get();
    assertThat(def.getNamespace(), is(CNode.DEFAULT_NAMESPACE));
    assertThat(def.getName(), is("xyzzy"));
}
Also used : DeployState(com.yahoo.config.model.deploy.DeployState) UnparsedConfigDefinition(com.yahoo.config.application.api.UnparsedConfigDefinition) ConfigDefinition(com.yahoo.vespa.config.ConfigDefinition) ConfigDefinitionKey(com.yahoo.vespa.config.ConfigDefinitionKey) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 20 with DeployState

use of com.yahoo.config.model.deploy.DeployState in project vespa by vespa-engine.

the class AccessControlValidatorTest method deployState.

private static DeployState deployState(String servicesXml) {
    ApplicationPackage app = new MockApplicationPackage.Builder().withServices(servicesXml).build();
    DeployState.Builder builder = new DeployState.Builder().applicationPackage(app).zone(// TODO: remove cd setting
    new Zone(SystemName.cd, Environment.prod, RegionName.from("foo"))).properties(new DeployProperties.Builder().hostedVespa(true).build());
    final DeployState deployState = builder.build(true);
    assertTrue("Test must emulate a hosted deployment.", deployState.isHosted());
    assertEquals("Test must emulate a prod environment.", prod, deployState.zone().environment());
    return deployState;
}
Also used : DeployState(com.yahoo.config.model.deploy.DeployState) Zone(com.yahoo.config.provision.Zone) DeployProperties(com.yahoo.config.model.deploy.DeployProperties) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage)

Aggregations

DeployState (com.yahoo.config.model.deploy.DeployState)29 Test (org.junit.Test)19 VespaModel (com.yahoo.vespa.model.VespaModel)14 NullConfigModelRegistry (com.yahoo.config.model.NullConfigModelRegistry)10 ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)9 DeployProperties (com.yahoo.config.model.deploy.DeployProperties)7 MockApplicationPackage (com.yahoo.config.model.test.MockApplicationPackage)7 Zone (com.yahoo.config.provision.Zone)7 MockRoot (com.yahoo.config.model.test.MockRoot)5 VespaModelCreatorWithMockPkg (com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg)4 InMemoryProvisioner (com.yahoo.config.model.provision.InMemoryProvisioner)3 ConfigserverConfig (com.yahoo.cloud.config.ConfigserverConfig)2 SentinelConfig (com.yahoo.cloud.config.SentinelConfig)2 FilesApplicationPackage (com.yahoo.config.model.application.provider.FilesApplicationPackage)2 TestDriver (com.yahoo.config.model.test.TestDriver)2 TestRoot (com.yahoo.config.model.test.TestRoot)2 AllocatedHosts (com.yahoo.config.provision.AllocatedHosts)2 ContainerCluster (com.yahoo.vespa.model.container.ContainerCluster)2 Optional (java.util.Optional)2 ClusterInfoConfig (com.yahoo.cloud.config.ClusterInfoConfig)1