Search in sources :

Example 1 with ApplicationPackage

use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.

the class ConfigModelRepo method getPermanentServices.

private Collection<Element> getPermanentServices(DeployState deployState) throws IOException, SAXException {
    List<Element> permanentServices = new ArrayList<>();
    Optional<ApplicationPackage> applicationPackage = deployState.getPermanentApplicationPackage();
    if (applicationPackage.isPresent()) {
        ApplicationFile file = applicationPackage.get().getFile(Path.fromString(ApplicationPackage.PERMANENT_SERVICES));
        if (file.exists()) {
            try (Reader reader = file.createReader()) {
                Element permanentServicesRoot = getServicesFromReader(reader);
                permanentServices.addAll(getServiceElements(permanentServicesRoot));
            }
        }
    }
    return permanentServices;
}
Also used : Element(org.w3c.dom.Element) ApplicationFile(com.yahoo.config.application.api.ApplicationFile) Reader(java.io.Reader) StringReader(java.io.StringReader) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage)

Example 2 with ApplicationPackage

use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.

the class DeployStateTest method testBuilder.

@Test
public void testBuilder() {
    DeployState.Builder builder = new DeployState.Builder();
    ApplicationPackage app = MockApplicationPackage.createEmpty();
    builder.permanentApplicationPackage(Optional.of(app));
    DeployState state = builder.build(true);
    assertThat(state.getPermanentApplicationPackage().get(), is(app));
}
Also used : ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) FilesApplicationPackage(com.yahoo.config.model.application.provider.FilesApplicationPackage) Test(org.junit.Test)

Example 3 with ApplicationPackage

use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.

the class SingleNodeProvisionerTest method require_allocate_clustermembership_works.

@Test
public void require_allocate_clustermembership_works() throws IOException, SAXException {
    String servicesXml = "<services version='1.0'>" + "  <admin version='3.0'>" + "    <nodes count='1' />" + "  </admin>" + "  <jdisc version='1.0'>" + "    <search />" + "    <nodes count='1' />" + "  </jdisc>" + "</services>";
    ApplicationPackage app = new MockApplicationPackage.Builder().withServices(servicesXml).build();
    VespaModel model = new VespaModel(app);
    assertThat(model.getHosts().size(), is(1));
}
Also used : VespaModel(com.yahoo.vespa.model.VespaModel) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) Test(org.junit.Test)

Example 4 with ApplicationPackage

use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.

the class ValidationTester method deploy.

/**
 * Deploys an application
 *
 * @param previousModel the previous model, or null if no previous
 * @param services the services file content
 * @param validationOverrides the validation overrides file content, or null if none
 * @return the new model and any change actions
 */
public Pair<VespaModel, List<ConfigChangeAction>> deploy(VespaModel previousModel, String services, String validationOverrides) {
    Instant now = LocalDate.parse("2000-01-01", DateTimeFormatter.ISO_DATE).atStartOfDay().atZone(ZoneOffset.UTC).toInstant();
    ApplicationPackage newApp = new MockApplicationPackage.Builder().withServices(services).withSearchDefinition(MockApplicationPackage.MUSIC_SEARCHDEFINITION).withValidationOverrides(validationOverrides).build();
    VespaModelCreatorWithMockPkg newModelCreator = new VespaModelCreatorWithMockPkg(newApp);
    DeployState.Builder deployStateBuilder = new DeployState.Builder().applicationPackage(newApp).properties(new DeployProperties.Builder().hostedVespa(true).build()).modelHostProvisioner(new InMemoryProvisioner(nodeCount)).now(now);
    if (previousModel != null)
        deployStateBuilder.previousModel(previousModel);
    VespaModel newModel = newModelCreator.create(deployStateBuilder);
    return new Pair<>(newModel, newModelCreator.configChangeActions);
}
Also used : VespaModelCreatorWithMockPkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg) DeployState(com.yahoo.config.model.deploy.DeployState) InMemoryProvisioner(com.yahoo.config.model.provision.InMemoryProvisioner) Instant(java.time.Instant) DeployProperties(com.yahoo.config.model.deploy.DeployProperties) VespaModel(com.yahoo.vespa.model.VespaModel) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) Pair(com.yahoo.collections.Pair)

Example 5 with ApplicationPackage

use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.

the class ContainerModelBuilderTest method qrconfig_is_produced.

@Test
public void qrconfig_is_produced() throws IOException, SAXException {
    String servicesXml = "<services>" + "<admin version='3.0'>" + "    <nodes count='1'/>" + "</admin>" + "<jdisc id ='default' version='1.0'>" + "  <nodes>" + "    <node hostalias='node1' />" + "  </nodes>" + "</jdisc>" + "</services>";
    ApplicationPackage applicationPackage = new MockApplicationPackage.Builder().withServices(servicesXml).build();
    VespaModel model = new VespaModel(new NullConfigModelRegistry(), new DeployState.Builder().applicationPackage(applicationPackage).properties(new DeployProperties.Builder().build()).build(true));
    // Using the same way of getting hostname as filedistribution model
    String hostname = HostName.getLocalhost();
    QrConfig config = model.getConfig(QrConfig.class, "default/container.0");
    assertEquals("default.container.0", config.discriminator());
    assertEquals(19102, config.rpc().port());
    assertEquals("vespa/service/default/container.0", config.rpc().slobrokId());
    assertEquals(true, config.rpc().enabled());
    assertEquals("", config.rpc().host());
    assertEquals(false, config.restartOnDeploy());
    assertEquals(false, config.coveragereports());
    assertEquals("filedistribution/" + hostname, config.filedistributor().configid());
}
Also used : NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) VespaModel(com.yahoo.vespa.model.VespaModel) QrConfig(com.yahoo.container.QrConfig) 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)

Aggregations

ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)39 MockApplicationPackage (com.yahoo.config.model.test.MockApplicationPackage)25 Test (org.junit.Test)21 VespaModel (com.yahoo.vespa.model.VespaModel)14 FilesApplicationPackage (com.yahoo.config.model.application.provider.FilesApplicationPackage)13 DeployState (com.yahoo.config.model.deploy.DeployState)12 File (java.io.File)11 NullConfigModelRegistry (com.yahoo.config.model.NullConfigModelRegistry)10 DeployProperties (com.yahoo.config.model.deploy.DeployProperties)8 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)7 InMemoryProvisioner (com.yahoo.config.model.provision.InMemoryProvisioner)6 Matchers.containsString (org.hamcrest.Matchers.containsString)5 VespaModelCreatorWithMockPkg (com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg)4 TestDriver (com.yahoo.config.model.test.TestDriver)3 Path (com.yahoo.path.Path)3 DeployLogger (com.yahoo.config.application.api.DeployLogger)2 MockRoot (com.yahoo.config.model.test.MockRoot)2 Zone (com.yahoo.config.provision.Zone)2 ConfigDefinition (com.yahoo.vespa.config.ConfigDefinition)2 ConfigDefinitionKey (com.yahoo.vespa.config.ConfigDefinitionKey)2