use of com.yahoo.config.model.deploy.DeployState in project vespa by vespa-engine.
the class VespaModelTestCase method testDeployLogger.
@Test
public void testDeployLogger() throws IOException, SAXException {
final String services = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "<services version=\"1.0\">" + "<config name=\"unknsownfoo\">" + "<logserver><host>foo</host></logserver>" + "</config>" + "<admin version=\"2.0\">" + " <adminserver hostalias=\"node0\" />" + "</admin>" + "</services>";
MyLogger logger = new MyLogger();
final DeployState.Builder builder = new DeployState.Builder();
builder.modelHostProvisioner(new HostsXmlProvisioner(new StringReader(simpleHosts)));
ApplicationPackage app = new MockApplicationPackage.Builder().withHosts(simpleHosts).withServices(services).build();
DeployState deployState = builder.deployLogger(logger).applicationPackage(app).build(true);
VespaModel model = new VespaModel(new NullConfigModelRegistry(), deployState);
Validation.validate(model, true, deployState);
assertFalse(logger.msgs.isEmpty());
}
use of com.yahoo.config.model.deploy.DeployState 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);
}
use of com.yahoo.config.model.deploy.DeployState in project vespa by vespa-engine.
the class ZKApplicationPackageTest method testBasicZKFeed.
@Test
public void testBasicZKFeed() throws IOException {
feed(configCurator, new File(APP));
ZKApplicationPackage zkApp = new ZKApplicationPackage(configCurator, Path.fromString("/0"), Optional.of(new MockNodeFlavors()));
assertTrue(Pattern.compile(".*<slobroks>.*", Pattern.MULTILINE + Pattern.DOTALL).matcher(IOUtils.readAll(zkApp.getServices())).matches());
assertTrue(Pattern.compile(".*<alias>.*", Pattern.MULTILINE + Pattern.DOTALL).matcher(IOUtils.readAll(zkApp.getHosts())).matches());
assertTrue(Pattern.compile(".*<slobroks>.*", Pattern.MULTILINE + Pattern.DOTALL).matcher(IOUtils.readAll(zkApp.getFile(Path.fromString("services.xml")).createReader())).matches());
DeployState deployState = new DeployState.Builder().applicationPackage(zkApp).build(true);
assertEquals(deployState.getSearchDefinitions().size(), 5);
assertEquals(zkApp.searchDefinitionContents().size(), 5);
assertEquals(IOUtils.readAll(zkApp.getRankingExpression("foo.expression")), "foo()+1\n");
assertEquals(zkApp.getFiles(Path.fromString(""), "xml").size(), 3);
assertEquals(zkApp.getFileReference(Path.fromString("components/file.txt")).getAbsolutePath(), "/home/vespa/test/file.txt");
try (Reader foo = zkApp.getFile(Path.fromString("files/foo.json")).createReader()) {
assertEquals(IOUtils.readAll(foo), "foo : foo\n");
}
try (Reader bar = zkApp.getFile(Path.fromString("files/sub/bar.json")).createReader()) {
assertEquals(IOUtils.readAll(bar), "bar : bar\n");
}
assertTrue(zkApp.getFile(Path.createRoot()).exists());
assertTrue(zkApp.getFile(Path.createRoot()).isDirectory());
Version goodVersion = Version.fromIntValues(3, 0, 0);
assertTrue(zkApp.getFileRegistryMap().containsKey(goodVersion));
assertFalse(zkApp.getFileRegistryMap().containsKey(Version.fromIntValues(0, 0, 0)));
assertThat(zkApp.getFileRegistryMap().get(goodVersion).fileSourceHost(), is("dummyfiles"));
AllocatedHosts readInfo = zkApp.getAllocatedHosts().get();
assertThat(Utf8.toString(readInfo.toJson()), is(Utf8.toString(ALLOCATED_HOSTS.toJson())));
assertThat(readInfo.getHosts().iterator().next().flavor(), is(TEST_FLAVOR));
assertTrue(zkApp.getDeployment().isPresent());
assertThat(DeploymentSpec.fromXml(zkApp.getDeployment().get()).globalServiceId().get(), is("mydisc"));
}
use of com.yahoo.config.model.deploy.DeployState in project vespa by vespa-engine.
the class DeploymentFileValidator method validate.
@Override
public void validate(VespaModel model, DeployState deployState) {
Optional<Reader> deployment = deployState.getApplicationPackage().getDeployment();
if (deployment.isPresent()) {
Reader deploymentReader = deployment.get();
DeploymentSpec deploymentSpec = DeploymentSpec.fromXml(deploymentReader);
final Optional<String> globalServiceId = deploymentSpec.globalServiceId();
if (globalServiceId.isPresent()) {
Set<ContainerCluster> containerClusters = model.getRoot().configModelRepo().getModels(ContainerModel.class).stream().map(ContainerModel::getCluster).filter(cc -> cc.getName().equals(globalServiceId.get())).collect(Collectors.toSet());
if (containerClusters.size() != 1) {
throw new IllegalArgumentException("global-service-id '" + globalServiceId.get() + "' specified in deployment.xml does not match any container cluster id");
}
}
}
}
use of com.yahoo.config.model.deploy.DeployState in project vespa by vespa-engine.
the class ModelProvisioningTest method createNonProvisionedMultitenantModel.
private VespaModel createNonProvisionedMultitenantModel(String services) {
VespaModelCreatorWithMockPkg modelCreatorWithMockPkg = new VespaModelCreatorWithMockPkg(null, services, ApplicationPackageUtils.generateSearchDefinition("type1"));
ApplicationPackage appPkg = modelCreatorWithMockPkg.appPkg;
DeployState deployState = new DeployState.Builder().applicationPackage(appPkg).properties((new DeployProperties.Builder()).multitenant(true).build()).build(true);
return modelCreatorWithMockPkg.create(false, deployState);
}
Aggregations