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