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());
}
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)));
}
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);
}
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);
}
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);
}
Aggregations