Search in sources :

Example 71 with VespaModel

use of com.yahoo.vespa.model.VespaModel in project vespa by vespa-engine.

the class VespaModelTestCase method testHostsConfig.

@Test
public void testHostsConfig() {
    VespaModel model = getVespaModel(TESTDIR + "app_qrserverandgw");
    LogdConfig config = getLogdConfig(model, "");
    assertEquals(config.logserver().host(), HostName.getLocalhost());
    assertNotNull(config);
    config = getLogdConfig(model, "hosts");
    assertNotNull(config);
    assertEquals(config.logserver().host(), HostName.getLocalhost());
}
Also used : LogdConfig(com.yahoo.cloud.config.log.LogdConfig) VespaModel(com.yahoo.vespa.model.VespaModel) Test(org.junit.Test)

Example 72 with VespaModel

use of com.yahoo.vespa.model.VespaModel 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());
}
Also used : HostsXmlProvisioner(com.yahoo.config.model.provision.HostsXmlProvisioner) NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) DeployState(com.yahoo.config.model.deploy.DeployState) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) VespaModel(com.yahoo.vespa.model.VespaModel) StringReader(java.io.StringReader) FilesApplicationPackage(com.yahoo.config.model.application.provider.FilesApplicationPackage) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) Test(org.junit.Test)

Example 73 with VespaModel

use of com.yahoo.vespa.model.VespaModel in project vespa by vespa-engine.

the class VespaModelTestCase method testConfigLists.

@Test
public void testConfigLists() {
    VespaModel model = getVespaModel(TESTDIR + "app_nohosts/");
    assertTrue(model.allConfigsProduced().size() > 0);
    assertTrue(model.allConfigIds().size() > 0);
}
Also used : VespaModel(com.yahoo.vespa.model.VespaModel) Test(org.junit.Test)

Example 74 with VespaModel

use of com.yahoo.vespa.model.VespaModel in project vespa by vespa-engine.

the class VespaModelCreatorWithMockPkg method create.

public VespaModel create(boolean validate, DeployState deployState, ConfigModelRegistry configModelRegistry) {
    try {
        this.deployState = deployState;
        VespaModel model = new VespaModel(configModelRegistry, deployState);
        Version vespaVersion = new Version(6);
        if (validate) {
            SchemaValidators validators = new SchemaValidators(vespaVersion);
            try {
                if (appPkg.getHosts() != null) {
                    validators.hostsXmlValidator().validate(appPkg.getHosts());
                }
                if (appPkg.getDeployment().isPresent()) {
                    validators.deploymentXmlValidator().validate(appPkg.getDeployment().get());
                }
                validators.servicesXmlValidator().validate(appPkg.getServices());
            } catch (Exception e) {
                System.err.println(e.getClass());
                throw e instanceof RuntimeException ? (RuntimeException) e : new RuntimeException(e);
            }
            // Validate, but without checking configSources or routing (routing
            // is constructed in a special way and cannot always be validated in
            // this step for unit tests)
            configChangeActions = Validation.validate(model, false, false, deployState);
        }
        return model;
    } catch (Exception e) {
        e.printStackTrace();
        throw e instanceof RuntimeException ? (RuntimeException) e : new RuntimeException(e);
    }
}
Also used : Version(com.yahoo.component.Version) SchemaValidators(com.yahoo.config.model.application.provider.SchemaValidators) VespaModel(com.yahoo.vespa.model.VespaModel)

Example 75 with VespaModel

use of com.yahoo.vespa.model.VespaModel in project vespa by vespa-engine.

the class ApplicationTest method setupHandler.

@Before
public void setupHandler() throws IOException, SAXException {
    File testApp = new File("src/test/apps/app");
    ServerCache cache = createCacheAndAddContent();
    VespaModel model = new VespaModel(FilesApplicationPackage.fromFile(testApp));
    final ApplicationId applicationId = new ApplicationId.Builder().tenant("foo").applicationName("foo").build();
    handler = new Application(model, cache, 1, Version.fromIntValues(1, 2, 3), new MetricUpdater(Metrics.createTestMetrics(), Metrics.createDimensions(applicationId)), applicationId);
}
Also used : ServerCache(com.yahoo.vespa.config.server.ServerCache) MetricUpdater(com.yahoo.vespa.config.server.monitoring.MetricUpdater) VespaModel(com.yahoo.vespa.model.VespaModel) ApplicationId(com.yahoo.config.provision.ApplicationId) File(java.io.File) Before(org.junit.Before)

Aggregations

VespaModel (com.yahoo.vespa.model.VespaModel)153 Test (org.junit.Test)135 VespaModelTester (com.yahoo.vespa.model.test.VespaModelTester)35 VespaModelCreatorWithMockPkg (com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg)26 ContainerCluster (com.yahoo.vespa.model.container.ContainerCluster)22 ContentCluster (com.yahoo.vespa.model.content.cluster.ContentCluster)21 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)18 DeployState (com.yahoo.config.model.deploy.DeployState)18 NullConfigModelRegistry (com.yahoo.config.model.NullConfigModelRegistry)15 ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)14 MockApplicationPackage (com.yahoo.config.model.test.MockApplicationPackage)13 Matchers.containsString (org.hamcrest.Matchers.containsString)12 File (java.io.File)8 ProtonConfig (com.yahoo.vespa.config.search.core.ProtonConfig)6 ValidationTester (com.yahoo.vespa.model.application.validation.ValidationTester)6 ContentSearchCluster (com.yahoo.vespa.model.content.ContentSearchCluster)6 LogdConfig (com.yahoo.cloud.config.log.LogdConfig)5 FilesApplicationPackage (com.yahoo.config.model.application.provider.FilesApplicationPackage)5 InMemoryProvisioner (com.yahoo.config.model.provision.InMemoryProvisioner)5 HostResource (com.yahoo.vespa.model.HostResource)5