Search in sources :

Example 16 with NullConfigModelRegistry

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

the class VespaModelFactoryTest method testThatFactoryModelValidationCanBeIgnored.

@Test
public void testThatFactoryModelValidationCanBeIgnored() {
    VespaModelFactory modelFactory = new VespaModelFactory(new NullConfigModelRegistry());
    ModelCreateResult createResult = modelFactory.createAndValidateModel(new MockModelContext(createApplicationPackageThatFailsWhenValidating()), true);
    assertNotNull(createResult.getModel());
    assertNotNull(createResult.getConfigChangeActions());
    assertTrue(createResult.getConfigChangeActions().isEmpty());
}
Also used : NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) MockModelContext(com.yahoo.config.model.MockModelContext) ModelCreateResult(com.yahoo.config.model.api.ModelCreateResult) Test(org.junit.Test)

Example 17 with NullConfigModelRegistry

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

the class VespaModelFactoryTest method hostedVespaZoneApplicationAllocatesNodesFromNodeRepo.

@Test
public void hostedVespaZoneApplicationAllocatesNodesFromNodeRepo() {
    String hostName = "test-host-name";
    String routingClusterName = "routing-cluster";
    String hosts = "<?xml version='1.0' encoding='utf-8' ?>\n" + "<hosts>\n" + "  <host name='" + hostName + "'>\n" + "    <alias>proxy1</alias>\n" + "  </host>\n" + "</hosts>";
    String services = "<?xml version='1.0' encoding='utf-8' ?>\n" + "<services version='1.0' xmlns:deploy='vespa'>\n" + "    <admin version='2.0'>\n" + "        <adminserver hostalias='proxy1' />\n" + "    </admin>" + "    <jdisc id='" + routingClusterName + "' version='1.0'>\n" + "        <nodes type='proxy'/>\n" + "    </jdisc>\n" + "</services>";
    HostProvisioner provisionerToOverride = new HostProvisioner() {

        @Override
        public HostSpec allocateHost(String alias) {
            return new HostSpec(hostName, Collections.emptyList(), ClusterMembership.from(ClusterSpec.from(ClusterSpec.Type.admin, new ClusterSpec.Id(routingClusterName), ClusterSpec.Group.from(0), Version.fromString("6.42"), false), 0));
        }

        @Override
        public List<HostSpec> prepare(ClusterSpec cluster, Capacity capacity, int groups, ProvisionLogger logger) {
            return Collections.singletonList(new HostSpec(hostName, Collections.emptyList(), ClusterMembership.from(ClusterSpec.from(ClusterSpec.Type.container, new ClusterSpec.Id(routingClusterName), ClusterSpec.Group.from(0), Version.fromString("6.42"), false), 0)));
        }
    };
    ModelContext modelContext = createMockModelContext(hosts, services, provisionerToOverride);
    Model model = new VespaModelFactory(new NullConfigModelRegistry()).createModel(modelContext);
    List<HostInfo> allocatedHosts = new ArrayList<>(model.getHosts());
    assertThat(allocatedHosts.size(), is(1));
    HostInfo hostInfo = allocatedHosts.get(0);
    assertThat(hostInfo.getHostname(), is(hostName));
    assertTrue("Routing service should run on host " + hostName, hostInfo.getServices().stream().map(ServiceInfo::getConfigId).anyMatch(configId -> configId.contains(routingClusterName)));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) Capacity(com.yahoo.config.provision.Capacity) InstanceName(com.yahoo.config.provision.InstanceName) ApplicationName(com.yahoo.config.provision.ApplicationName) Version(com.yahoo.component.Version) ApplicationId(com.yahoo.config.provision.ApplicationId) ClusterMembership(com.yahoo.config.provision.ClusterMembership) HostInfo(com.yahoo.config.model.api.HostInfo) ClusterSpec(com.yahoo.config.provision.ClusterSpec) TenantName(com.yahoo.config.provision.TenantName) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Assert.assertThat(org.junit.Assert.assertThat) ProvisionLogger(com.yahoo.config.provision.ProvisionLogger) MockModelContext(com.yahoo.config.model.MockModelContext) Before(org.junit.Before) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) Rotation(com.yahoo.config.provision.Rotation) ModelContext(com.yahoo.config.model.api.ModelContext) Assert.assertNotNull(org.junit.Assert.assertNotNull) HostSpec(com.yahoo.config.provision.HostSpec) Set(java.util.Set) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) List(java.util.List) HostProvisioner(com.yahoo.config.model.api.HostProvisioner) ConfigServerSpec(com.yahoo.config.model.api.ConfigServerSpec) Zone(com.yahoo.config.provision.Zone) ModelCreateResult(com.yahoo.config.model.api.ModelCreateResult) Optional(java.util.Optional) Collections(java.util.Collections) Model(com.yahoo.config.model.api.Model) ServiceInfo(com.yahoo.config.model.api.ServiceInfo) HostName(com.yahoo.config.provision.HostName) ArrayList(java.util.ArrayList) ClusterSpec(com.yahoo.config.provision.ClusterSpec) HostSpec(com.yahoo.config.provision.HostSpec) MockModelContext(com.yahoo.config.model.MockModelContext) ModelContext(com.yahoo.config.model.api.ModelContext) ServiceInfo(com.yahoo.config.model.api.ServiceInfo) NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) Capacity(com.yahoo.config.provision.Capacity) ProvisionLogger(com.yahoo.config.provision.ProvisionLogger) Model(com.yahoo.config.model.api.Model) ApplicationId(com.yahoo.config.provision.ApplicationId) HostInfo(com.yahoo.config.model.api.HostInfo) HostProvisioner(com.yahoo.config.model.api.HostProvisioner) Test(org.junit.Test)

Example 18 with NullConfigModelRegistry

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

the class VespaModelFactoryTest method testThatFactoryCanBuildModel.

@Test
public void testThatFactoryCanBuildModel() {
    VespaModelFactory modelFactory = new VespaModelFactory(new NullConfigModelRegistry());
    Model model = modelFactory.createModel(testModelContext);
    assertNotNull(model);
    assertTrue(model instanceof VespaModel);
}
Also used : NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) Model(com.yahoo.config.model.api.Model) Test(org.junit.Test)

Example 19 with NullConfigModelRegistry

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

the class AccessControlValidatorTest method cluster_with_handler_fails_validation_without_write_protection.

@Test
public void cluster_with_handler_fails_validation_without_write_protection() throws IOException, SAXException {
    exceptionRule.expect(IllegalArgumentException.class);
    exceptionRule.expectMessage("Access-control must be enabled for write operations to container clusters in production zones: [default]");
    DeployState deployState = deployState(servicesXml(true, false));
    VespaModel model = new VespaModel(new NullConfigModelRegistry(), deployState);
    new AccessControlValidator().validate(model, deployState);
}
Also used : NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) DeployState(com.yahoo.config.model.deploy.DeployState) VespaModel(com.yahoo.vespa.model.VespaModel) Test(org.junit.Test)

Example 20 with NullConfigModelRegistry

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

the class AccessControlValidatorTest method no_http_element_has_same_effect_as_no_write_protection.

@Test
public void no_http_element_has_same_effect_as_no_write_protection() throws IOException, SAXException {
    exceptionRule.expect(IllegalArgumentException.class);
    exceptionRule.expectMessage("Access-control must be enabled for write operations to container clusters in production zones: [default]");
    String servicesXml = joinLines("<services version='1.0'>", "  <container id='default' version='1.0'>", httpHandlerXml, "  </container>", "</services>");
    DeployState deployState = deployState(servicesXml);
    VespaModel model = new VespaModel(new NullConfigModelRegistry(), deployState);
    new AccessControlValidator().validate(model, deployState);
}
Also used : NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) DeployState(com.yahoo.config.model.deploy.DeployState) VespaModel(com.yahoo.vespa.model.VespaModel) 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