Search in sources :

Example 11 with DeployState

use of com.yahoo.config.model.deploy.DeployState 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 12 with DeployState

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

the class VespaModelTester method createModel.

/**
 * Creates a model using the hosts already added to this
 *
 * @param services the services xml string
 * @param failOnOutOfCapacity whether we should get an exception when not enough hosts of the requested flavor
 *        is available or if we should just silently receive a smaller allocation
 * @return the resulting model
 */
public VespaModel createModel(String services, boolean failOnOutOfCapacity, int startIndexForClusters, String... retiredHostNames) {
    VespaModelCreatorWithMockPkg modelCreatorWithMockPkg = new VespaModelCreatorWithMockPkg(null, services, ApplicationPackageUtils.generateSearchDefinition("type1"));
    ApplicationPackage appPkg = modelCreatorWithMockPkg.appPkg;
    HostProvisioner provisioner = hosted ? new InMemoryProvisioner(hostsByFlavor, failOnOutOfCapacity, startIndexForClusters, retiredHostNames) : new SingleNodeProvisioner();
    DeployProperties properties = new DeployProperties.Builder().hostedVespa(hosted).applicationId(applicationId).build();
    DeployState deployState = new DeployState.Builder().applicationPackage(appPkg).modelHostProvisioner(provisioner).properties(properties).build(true);
    return modelCreatorWithMockPkg.create(false, deployState, configModelRegistry);
}
Also used : SingleNodeProvisioner(com.yahoo.config.model.provision.SingleNodeProvisioner) 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) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) HostProvisioner(com.yahoo.config.model.api.HostProvisioner)

Example 13 with DeployState

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

the class ZKApplicationPackageTest method testBasicZKFeed.

@Test
public void testBasicZKFeed() throws IOException {
    feed(configCurator, new File(APP));
    ZKApplicationPackage zkApp = new ZKApplicationPackage(configCurator, Path.fromString("/0"), Optional.of(new MockNodeFlavors()));
    assertTrue(Pattern.compile(".*<slobroks>.*", Pattern.MULTILINE + Pattern.DOTALL).matcher(IOUtils.readAll(zkApp.getServices())).matches());
    assertTrue(Pattern.compile(".*<alias>.*", Pattern.MULTILINE + Pattern.DOTALL).matcher(IOUtils.readAll(zkApp.getHosts())).matches());
    assertTrue(Pattern.compile(".*<slobroks>.*", Pattern.MULTILINE + Pattern.DOTALL).matcher(IOUtils.readAll(zkApp.getFile(Path.fromString("services.xml")).createReader())).matches());
    DeployState deployState = new DeployState.Builder().applicationPackage(zkApp).build(true);
    assertEquals(deployState.getSearchDefinitions().size(), 5);
    assertEquals(zkApp.searchDefinitionContents().size(), 5);
    assertEquals(IOUtils.readAll(zkApp.getRankingExpression("foo.expression")), "foo()+1\n");
    assertEquals(zkApp.getFiles(Path.fromString(""), "xml").size(), 3);
    assertEquals(zkApp.getFileReference(Path.fromString("components/file.txt")).getAbsolutePath(), "/home/vespa/test/file.txt");
    try (Reader foo = zkApp.getFile(Path.fromString("files/foo.json")).createReader()) {
        assertEquals(IOUtils.readAll(foo), "foo : foo\n");
    }
    try (Reader bar = zkApp.getFile(Path.fromString("files/sub/bar.json")).createReader()) {
        assertEquals(IOUtils.readAll(bar), "bar : bar\n");
    }
    assertTrue(zkApp.getFile(Path.createRoot()).exists());
    assertTrue(zkApp.getFile(Path.createRoot()).isDirectory());
    Version goodVersion = Version.fromIntValues(3, 0, 0);
    assertTrue(zkApp.getFileRegistryMap().containsKey(goodVersion));
    assertFalse(zkApp.getFileRegistryMap().containsKey(Version.fromIntValues(0, 0, 0)));
    assertThat(zkApp.getFileRegistryMap().get(goodVersion).fileSourceHost(), is("dummyfiles"));
    AllocatedHosts readInfo = zkApp.getAllocatedHosts().get();
    assertThat(Utf8.toString(readInfo.toJson()), is(Utf8.toString(ALLOCATED_HOSTS.toJson())));
    assertThat(readInfo.getHosts().iterator().next().flavor(), is(TEST_FLAVOR));
    assertTrue(zkApp.getDeployment().isPresent());
    assertThat(DeploymentSpec.fromXml(zkApp.getDeployment().get()).globalServiceId().get(), is("mydisc"));
}
Also used : AllocatedHosts(com.yahoo.config.provision.AllocatedHosts) DeployState(com.yahoo.config.model.deploy.DeployState) Version(com.yahoo.config.provision.Version) Reader(java.io.Reader) File(java.io.File) Test(org.junit.Test)

Example 14 with DeployState

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

the class DeploymentFileValidator method validate.

@Override
public void validate(VespaModel model, DeployState deployState) {
    Optional<Reader> deployment = deployState.getApplicationPackage().getDeployment();
    if (deployment.isPresent()) {
        Reader deploymentReader = deployment.get();
        DeploymentSpec deploymentSpec = DeploymentSpec.fromXml(deploymentReader);
        final Optional<String> globalServiceId = deploymentSpec.globalServiceId();
        if (globalServiceId.isPresent()) {
            Set<ContainerCluster> containerClusters = model.getRoot().configModelRepo().getModels(ContainerModel.class).stream().map(ContainerModel::getCluster).filter(cc -> cc.getName().equals(globalServiceId.get())).collect(Collectors.toSet());
            if (containerClusters.size() != 1) {
                throw new IllegalArgumentException("global-service-id '" + globalServiceId.get() + "' specified in deployment.xml does not match any container cluster id");
            }
        }
    }
}
Also used : DeployState(com.yahoo.config.model.deploy.DeployState) ContainerCluster(com.yahoo.vespa.model.container.ContainerCluster) DeploymentSpec(com.yahoo.config.application.api.DeploymentSpec) VespaModel(com.yahoo.vespa.model.VespaModel) ContainerModel(com.yahoo.vespa.model.container.ContainerModel) Optional(java.util.Optional) Set(java.util.Set) Reader(java.io.Reader) Collectors(java.util.stream.Collectors) DeploymentSpec(com.yahoo.config.application.api.DeploymentSpec) Reader(java.io.Reader) ContainerCluster(com.yahoo.vespa.model.container.ContainerCluster) ContainerModel(com.yahoo.vespa.model.container.ContainerModel)

Example 15 with DeployState

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

the class ModelProvisioningTest method createNonProvisionedMultitenantModel.

private VespaModel createNonProvisionedMultitenantModel(String services) {
    VespaModelCreatorWithMockPkg modelCreatorWithMockPkg = new VespaModelCreatorWithMockPkg(null, services, ApplicationPackageUtils.generateSearchDefinition("type1"));
    ApplicationPackage appPkg = modelCreatorWithMockPkg.appPkg;
    DeployState deployState = new DeployState.Builder().applicationPackage(appPkg).properties((new DeployProperties.Builder()).multitenant(true).build()).build(true);
    return modelCreatorWithMockPkg.create(false, deployState);
}
Also used : VespaModelCreatorWithMockPkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg) DeployState(com.yahoo.config.model.deploy.DeployState) DeployProperties(com.yahoo.config.model.deploy.DeployProperties) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage)

Aggregations

DeployState (com.yahoo.config.model.deploy.DeployState)29 Test (org.junit.Test)19 VespaModel (com.yahoo.vespa.model.VespaModel)14 NullConfigModelRegistry (com.yahoo.config.model.NullConfigModelRegistry)10 ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)9 DeployProperties (com.yahoo.config.model.deploy.DeployProperties)7 MockApplicationPackage (com.yahoo.config.model.test.MockApplicationPackage)7 Zone (com.yahoo.config.provision.Zone)7 MockRoot (com.yahoo.config.model.test.MockRoot)5 VespaModelCreatorWithMockPkg (com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg)4 InMemoryProvisioner (com.yahoo.config.model.provision.InMemoryProvisioner)3 ConfigserverConfig (com.yahoo.cloud.config.ConfigserverConfig)2 SentinelConfig (com.yahoo.cloud.config.SentinelConfig)2 FilesApplicationPackage (com.yahoo.config.model.application.provider.FilesApplicationPackage)2 TestDriver (com.yahoo.config.model.test.TestDriver)2 TestRoot (com.yahoo.config.model.test.TestRoot)2 AllocatedHosts (com.yahoo.config.provision.AllocatedHosts)2 ContainerCluster (com.yahoo.vespa.model.container.ContainerCluster)2 Optional (java.util.Optional)2 ClusterInfoConfig (com.yahoo.cloud.config.ClusterInfoConfig)1