Search in sources :

Example 21 with ApplicationPackage

use of com.yahoo.config.application.api.ApplicationPackage 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 22 with ApplicationPackage

use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.

the class ApplicationPreprocessor method run.

public void run() throws IOException, TransformerException, ParserConfigurationException, SAXException {
    DeployLogger logger = new BaseDeployLogger();
    FilesApplicationPackage.Builder applicationPackageBuilder = new FilesApplicationPackage.Builder(applicationDir);
    outputDir.ifPresent(applicationPackageBuilder::preprocessedDir);
    ApplicationPackage preprocessed = applicationPackageBuilder.build().preprocess(new Zone(environment.orElse(Environment.defaultEnvironment()), region.orElse(RegionName.defaultName())), logger);
    preprocessed.validateXML();
}
Also used : BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) DeployLogger(com.yahoo.config.application.api.DeployLogger) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) FilesApplicationPackage(com.yahoo.config.model.application.provider.FilesApplicationPackage) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) FilesApplicationPackage(com.yahoo.config.model.application.provider.FilesApplicationPackage)

Example 23 with ApplicationPackage

use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.

the class FilesApplicationPackageTest method testPreprocessing.

@Test
public void testPreprocessing() throws IOException, TransformerException, ParserConfigurationException, SAXException {
    File appDir = temporaryFolder.newFolder();
    IOUtils.copyDirectory(new File("src/test/resources/multienvapp"), appDir);
    assertTrue(new File(appDir, "services.xml").exists());
    assertTrue(new File(appDir, "hosts.xml").exists());
    FilesApplicationPackage app = FilesApplicationPackage.fromFile(appDir);
    ApplicationPackage processed = app.preprocess(new Zone(Environment.dev, RegionName.defaultName()), new BaseDeployLogger());
    assertTrue(new File(appDir, ".preprocessed").exists());
    String expectedServices = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><services xmlns:deploy=\"vespa\" xmlns:preprocess=\"properties\" version=\"1.0\">\n" + "    <admin version=\"2.0\">\n" + "        <adminserver hostalias=\"node0\"/>\n" + "    </admin>\n" + "    <content id=\"foo\" version=\"1.0\">\n" + "      <redundancy>1</redundancy>\n" + "      <documents>\n" + "        <document mode=\"index\" type=\"music.sd\"/>\n" + "      </documents>\n" + "      <nodes>\n" + "        <node distribution-key=\"0\" hostalias=\"node0\"/>\n" + "      </nodes>\n" + "    </content>\n" + "    <jdisc id=\"stateless\" version=\"1.0\">\n" + "      <search/>\n" + "      <component bundle=\"foobundle\" class=\"MyFoo\" id=\"foo\"/>\n" + "      <component bundle=\"foobundle\" class=\"TestBar\" id=\"bar\"/>\n" + "      <nodes>\n" + "        <node hostalias=\"node0\" baseport=\"5000\"/>\n" + "      </nodes>\n" + "    </jdisc>\n" + "</services>";
    TestBase.assertDocument(expectedServices, processed.getServices());
    String expectedHosts = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><hosts xmlns:deploy=\"vespa\" xmlns:preprocess=\"properties\">\n" + "    <host name=\"bar.yahoo.com\">\n" + "        <alias>node1</alias>\n" + "    </host>\n" + "</hosts>";
    TestBase.assertDocument(expectedHosts, processed.getHosts());
}
Also used : Zone(com.yahoo.config.provision.Zone) File(java.io.File) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) Test(org.junit.Test)

Example 24 with ApplicationPackage

use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.

the class RankingConstantsValidator method validate.

@Override
public void validate(VespaModel model, DeployState deployState) {
    ApplicationPackage applicationPackage = deployState.getApplicationPackage();
    ExceptionMessageCollector exceptionMessageCollector = new ExceptionMessageCollector("Invalid constant tensor file(s):");
    for (SearchDefinition sd : deployState.getSearchDefinitions()) {
        for (RankingConstant rc : sd.getSearch().getRankingConstants().values()) {
            try {
                validateRankingConstant(rc, applicationPackage);
            } catch (InvalidConstantTensor | FileNotFoundException ex) {
                exceptionMessageCollector.add(ex, rc.getName(), rc.getFileName());
            }
        }
    }
    if (exceptionMessageCollector.exceptionsOccurred) {
        throw new TensorValidationFailed(exceptionMessageCollector.combinedMessage);
    }
}
Also used : FileNotFoundException(java.io.FileNotFoundException) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) FilesApplicationPackage(com.yahoo.config.model.application.provider.FilesApplicationPackage) SearchDefinition(com.yahoo.vespa.model.search.SearchDefinition) RankingConstant(com.yahoo.searchdefinition.RankingConstant) InvalidConstantTensor(com.yahoo.vespa.model.application.validation.ConstantTensorJsonValidator.InvalidConstantTensor)

Example 25 with ApplicationPackage

use of com.yahoo.config.application.api.ApplicationPackage 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)

Aggregations

ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)39 MockApplicationPackage (com.yahoo.config.model.test.MockApplicationPackage)25 Test (org.junit.Test)21 VespaModel (com.yahoo.vespa.model.VespaModel)14 FilesApplicationPackage (com.yahoo.config.model.application.provider.FilesApplicationPackage)13 DeployState (com.yahoo.config.model.deploy.DeployState)12 File (java.io.File)11 NullConfigModelRegistry (com.yahoo.config.model.NullConfigModelRegistry)10 DeployProperties (com.yahoo.config.model.deploy.DeployProperties)8 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)7 InMemoryProvisioner (com.yahoo.config.model.provision.InMemoryProvisioner)6 Matchers.containsString (org.hamcrest.Matchers.containsString)5 VespaModelCreatorWithMockPkg (com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg)4 TestDriver (com.yahoo.config.model.test.TestDriver)3 Path (com.yahoo.path.Path)3 DeployLogger (com.yahoo.config.application.api.DeployLogger)2 MockRoot (com.yahoo.config.model.test.MockRoot)2 Zone (com.yahoo.config.provision.Zone)2 ConfigDefinition (com.yahoo.vespa.config.ConfigDefinition)2 ConfigDefinitionKey (com.yahoo.vespa.config.ConfigDefinitionKey)2