Search in sources :

Example 6 with NullConfigModelRegistry

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

the class ContainerModelBuilderTest method singlenode_servicespec_is_used_with_hosted_vespa.

@Test
public void singlenode_servicespec_is_used_with_hosted_vespa() throws IOException, SAXException {
    String servicesXml = "<jdisc id='default' version='1.0' />";
    ApplicationPackage applicationPackage = new MockApplicationPackage.Builder().withServices(servicesXml).build();
    VespaModel model = new VespaModel(new NullConfigModelRegistry(), new DeployState.Builder().modelHostProvisioner(new InMemoryProvisioner(true, "host1.yahoo.com", "host2.yahoo.com")).applicationPackage(applicationPackage).properties(new DeployProperties.Builder().multitenant(true).hostedVespa(true).build()).build(true));
    assertEquals(1, model.getHostSystem().getHosts().size());
}
Also used : NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) DeployState(com.yahoo.config.model.deploy.DeployState) InMemoryProvisioner(com.yahoo.config.model.provision.InMemoryProvisioner) VespaModel(com.yahoo.vespa.model.VespaModel) Matchers.containsString(org.hamcrest.Matchers.containsString) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest) Test(org.junit.Test)

Example 7 with NullConfigModelRegistry

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

the class VespaModelFactoryTest method testThatFactoryModelValidationFailsWithIllegalArgumentException.

// Uses an application package that throws IllegalArgumentException when validating
@Test(expected = IllegalArgumentException.class)
public void testThatFactoryModelValidationFailsWithIllegalArgumentException() {
    VespaModelFactory modelFactory = new VespaModelFactory(new NullConfigModelRegistry());
    modelFactory.createAndValidateModel(new MockModelContext(createApplicationPackageThatFailsWhenValidating()), false);
}
Also used : NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) MockModelContext(com.yahoo.config.model.MockModelContext) Test(org.junit.Test)

Example 8 with NullConfigModelRegistry

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

the class VespaModelFactoryTest method testThatFactoryModelValidationFails.

// Uses a MockApplicationPackage that throws throws UnsupportedOperationException (rethrown as RuntimeException) when validating
@Test(expected = RuntimeException.class)
public void testThatFactoryModelValidationFails() {
    VespaModelFactory modelFactory = new VespaModelFactory(new NullConfigModelRegistry());
    modelFactory.createAndValidateModel(testModelContext, false);
}
Also used : NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) Test(org.junit.Test)

Example 9 with NullConfigModelRegistry

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

the class DeploymentFileValidatorTest method testDeploymentWithNonExistentGlobalId.

@Test
public void testDeploymentWithNonExistentGlobalId() throws IOException, SAXException {
    final String simpleHosts = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "<hosts>  " + "<host name=\"localhost\">" + "<alias>node0</alias>" + "</host>" + "</hosts>";
    final String services = "<services version='1.0'>" + "  <admin  version='2.0'>" + "    <adminserver hostalias='node0' />" + "  </admin>" + "  <jdisc id='default' version='1.0'>" + "    <search/>" + "      <nodes>" + "        <node hostalias='node0'/>" + "     </nodes>" + "   </jdisc>" + "</services>";
    final String deploymentSpec = "<?xml version='1.0' encoding='UTF-8'?>" + "<deployment version='1.0'>" + "  <test />" + "  <prod global-service-id='non-existing'>" + "    <region active='true'>us-east</region>" + "  </prod>" + "</deployment>";
    ApplicationPackage app = new MockApplicationPackage.Builder().withHosts(simpleHosts).withServices(services).withDeploymentSpec(deploymentSpec).build();
    DeployState.Builder builder = new DeployState.Builder().applicationPackage(app);
    try {
        final DeployState deployState = builder.build(true);
        VespaModel model = new VespaModel(new NullConfigModelRegistry(), deployState);
        new DeploymentFileValidator().validate(model, deployState);
        fail("Did not get expected exception");
    } catch (IllegalArgumentException e) {
        assertThat(e.getMessage(), containsString("specified in deployment.xml does not match any container cluster id"));
    }
}
Also used : NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) DeployState(com.yahoo.config.model.deploy.DeployState) VespaModel(com.yahoo.vespa.model.VespaModel) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) Test(org.junit.Test)

Example 10 with NullConfigModelRegistry

use of com.yahoo.config.model.NullConfigModelRegistry 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)

Aggregations

NullConfigModelRegistry (com.yahoo.config.model.NullConfigModelRegistry)25 Test (org.junit.Test)21 VespaModel (com.yahoo.vespa.model.VespaModel)15 DeployState (com.yahoo.config.model.deploy.DeployState)13 ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)11 MockApplicationPackage (com.yahoo.config.model.test.MockApplicationPackage)9 FilesApplicationPackage (com.yahoo.config.model.application.provider.FilesApplicationPackage)5 VespaModelFactory (com.yahoo.vespa.model.VespaModelFactory)5 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4 MockModelContext (com.yahoo.config.model.MockModelContext)3 DeployProperties (com.yahoo.config.model.deploy.DeployProperties)3 TestComponentRegistry (com.yahoo.vespa.config.server.TestComponentRegistry)3 ModelFactoryRegistry (com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry)3 Model (com.yahoo.config.model.api.Model)2 ModelCreateResult (com.yahoo.config.model.api.ModelCreateResult)2 InMemoryProvisioner (com.yahoo.config.model.provision.InMemoryProvisioner)2 TenantName (com.yahoo.config.provision.TenantName)2 SessionHandlerTest (com.yahoo.vespa.config.server.http.SessionHandlerTest)2 RemoteSession (com.yahoo.vespa.config.server.session.RemoteSession)2