Search in sources :

Example 41 with Version

use of com.yahoo.component.Version in project vespa by vespa-engine.

the class YqlParserTestCase method testSegmenting.

@Test
public void testSegmenting() {
    assertParse("select * from bar where ([{\"segmenter\": {\"version\": \"58.67.49\", \"backend\": " + "\"yell\"}}] title contains \"madonna\");", "title:madonna");
    assertEquals("yell", parser.getSegmenterBackend());
    assertEquals(new Version("58.67.49"), parser.getSegmenterVersion());
    assertParse("select * from bar where ([{\"segmenter\": {\"version\": \"8.7.3\", \"backend\": " + "\"yell\"}}]([{\"targetNumHits\": 9999438}] weakAnd(format contains \"online\", title contains " + "\"madonna\")));", "WAND(9999438) format:online title:madonna");
    assertEquals("yell", parser.getSegmenterBackend());
    assertEquals(new Version("8.7.3"), parser.getSegmenterVersion());
    assertParse("select * from bar where [{\"segmenter\": {\"version\": \"18.47.39\", \"backend\": " + "\"yell\"}}] ([{\"targetNumHits\": 99909438}] weakAnd(format contains \"online\", title contains " + "\"madonna\"));", "WAND(99909438) format:online title:madonna");
    assertEquals("yell", parser.getSegmenterBackend());
    assertEquals(new Version("18.47.39"), parser.getSegmenterVersion());
    assertParse("select * from bar where [{\"targetNumHits\": 99909438}] weakAnd(format contains " + "\"online\", title contains \"madonna\");", "WAND(99909438) format:online title:madonna");
    assertNull(parser.getSegmenterBackend());
    assertNull(parser.getSegmenterVersion());
    assertParse("select * from bar where [{\"segmenter\": {\"version\": \"58.67.49\", \"backend\": " + "\"yell\"}}](title contains \"madonna\") order by shoesize;", "title:madonna");
    assertEquals("yell", parser.getSegmenterBackend());
    assertEquals(new Version("58.67.49"), parser.getSegmenterVersion());
}
Also used : Version(com.yahoo.component.Version) Test(org.junit.Test)

Example 42 with Version

use of com.yahoo.component.Version in project vespa by vespa-engine.

the class MockNodeRepository method populate.

private void populate() {
    NodeRepositoryProvisioner provisioner = new NodeRepositoryProvisioner(this, flavors, Zone.defaultZone());
    List<Node> nodes = new ArrayList<>();
    final List<String> ipAddressesForAllHost = Arrays.asList("127.0.0.1", "::1");
    Collections.sort(ipAddressesForAllHost);
    final HashSet<String> ipAddresses = new HashSet<>(ipAddressesForAllHost);
    final List<String> additionalIpAddressesForAllHost = Arrays.asList("::2", "::3", "::4");
    Collections.sort(additionalIpAddressesForAllHost);
    final HashSet<String> additionalIpAddresses = new HashSet<>(additionalIpAddressesForAllHost);
    nodes.add(createNode("node1", "host1.yahoo.com", ipAddresses, Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.tenant));
    nodes.add(createNode("node2", "host2.yahoo.com", ipAddresses, Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.tenant));
    nodes.add(createNode("node3", "host3.yahoo.com", ipAddresses, Optional.empty(), flavors.getFlavorOrThrow("expensive"), NodeType.tenant));
    Node node4 = createNode("node4", "host4.yahoo.com", ipAddresses, Optional.of("dockerhost1.yahoo.com"), flavors.getFlavorOrThrow("docker"), NodeType.tenant);
    node4 = node4.with(node4.status().withVespaVersion(new Version("6.41.0")));
    nodes.add(node4);
    Node node5 = createNode("node5", "host5.yahoo.com", ipAddresses, Optional.of("dockerhost2.yahoo.com"), flavors.getFlavorOrThrow("docker"), NodeType.tenant);
    nodes.add(node5.with(node5.status().withVespaVersion(new Version("1.2.3"))));
    nodes.add(createNode("node6", "host6.yahoo.com", ipAddresses, Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.tenant));
    nodes.add(createNode("node7", "host7.yahoo.com", ipAddresses, Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.tenant));
    // 8 and 9 are added by web service calls
    Node node10 = createNode("node10", "host10.yahoo.com", ipAddresses, Optional.of("parent1.yahoo.com"), flavors.getFlavorOrThrow("default"), NodeType.tenant);
    Status node10newStatus = node10.status();
    node10newStatus = node10newStatus.withVespaVersion(Version.fromString("5.104.142"));
    node10 = node10.with(node10newStatus);
    nodes.add(node10);
    Node node55 = createNode("node55", "host55.yahoo.com", ipAddresses, Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.tenant);
    nodes.add(node55.with(node55.status().withWantToRetire(true).withWantToDeprovision(true)));
    /* Setup docker hosts (two of these will be reserved for spares */
    nodes.add(createNode("dockerhost1", "dockerhost1.yahoo.com", ipAddresses, additionalIpAddresses, Optional.empty(), flavors.getFlavorOrThrow("large"), NodeType.host));
    nodes.add(createNode("dockerhost2", "dockerhost2.yahoo.com", ipAddresses, additionalIpAddresses, Optional.empty(), flavors.getFlavorOrThrow("large"), NodeType.host));
    nodes.add(createNode("dockerhost3", "dockerhost3.yahoo.com", ipAddresses, additionalIpAddresses, Optional.empty(), flavors.getFlavorOrThrow("large"), NodeType.host));
    nodes.add(createNode("dockerhost4", "dockerhost4.yahoo.com", ipAddresses, additionalIpAddresses, Optional.empty(), flavors.getFlavorOrThrow("large"), NodeType.host));
    nodes.add(createNode("dockerhost5", "dockerhost5.yahoo.com", ipAddresses, additionalIpAddresses, Optional.empty(), flavors.getFlavorOrThrow("large"), NodeType.host));
    nodes = addNodes(nodes);
    nodes.remove(6);
    nodes.remove(7);
    nodes = setDirty(nodes, Agent.system, getClass().getSimpleName());
    setReady(nodes, Agent.system, getClass().getSimpleName());
    fail("host5.yahoo.com", Agent.system, getClass().getSimpleName());
    setDirty("host55.yahoo.com", Agent.system, getClass().getSimpleName());
    ApplicationId zoneApp = ApplicationId.from(TenantName.from("zoneapp"), ApplicationName.from("zoneapp"), InstanceName.from("zoneapp"));
    ClusterSpec zoneCluster = ClusterSpec.request(ClusterSpec.Type.container, ClusterSpec.Id.from("node-admin"), Version.fromString("6.42"), false);
    activate(provisioner.prepare(zoneApp, zoneCluster, Capacity.fromRequiredNodeType(NodeType.host), 1, null), zoneApp, provisioner);
    ApplicationId app1 = ApplicationId.from(TenantName.from("tenant1"), ApplicationName.from("application1"), InstanceName.from("instance1"));
    ClusterSpec cluster1 = ClusterSpec.request(ClusterSpec.Type.container, ClusterSpec.Id.from("id1"), Version.fromString("6.42"), false);
    provisioner.prepare(app1, cluster1, Capacity.fromNodeCount(2), 1, null);
    ApplicationId app2 = ApplicationId.from(TenantName.from("tenant2"), ApplicationName.from("application2"), InstanceName.from("instance2"));
    ClusterSpec cluster2 = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("id2"), Version.fromString("6.42"), false);
    activate(provisioner.prepare(app2, cluster2, Capacity.fromNodeCount(2), 1, null), app2, provisioner);
    ApplicationId app3 = ApplicationId.from(TenantName.from("tenant3"), ApplicationName.from("application3"), InstanceName.from("instance3"));
    ClusterSpec cluster3 = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("id3"), Version.fromString("6.42"), false);
    activate(provisioner.prepare(app3, cluster3, Capacity.fromNodeCount(2, Optional.of("docker"), false), 1, null), app3, provisioner);
}
Also used : Status(com.yahoo.vespa.hosted.provision.node.Status) Version(com.yahoo.component.Version) Node(com.yahoo.vespa.hosted.provision.Node) NodeRepositoryProvisioner(com.yahoo.vespa.hosted.provision.provisioning.NodeRepositoryProvisioner) ArrayList(java.util.ArrayList) ClusterSpec(com.yahoo.config.provision.ClusterSpec) ApplicationId(com.yahoo.config.provision.ApplicationId) HashSet(java.util.HashSet)

Example 43 with Version

use of com.yahoo.component.Version in project vespa by vespa-engine.

the class TestDriver method validate.

private void validate(ApplicationPackage appPkg) throws IOException {
    if (!validate) {
        return;
    }
    SchemaValidators schemaValidators = new SchemaValidators(new Version(6), new BaseDeployLogger());
    if (appPkg.getHosts() != null) {
        schemaValidators.hostsXmlValidator().validate(appPkg.getHosts());
    }
    schemaValidators.servicesXmlValidator().validate(appPkg.getServices());
}
Also used : Version(com.yahoo.component.Version) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) SchemaValidators(com.yahoo.config.model.application.provider.SchemaValidators)

Example 44 with Version

use of com.yahoo.component.Version 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 45 with Version

use of com.yahoo.component.Version in project vespa by vespa-engine.

the class ApplicationRepository method deployFromLocalActive.

/**
 * Creates a new deployment from the active application, if available.
 *
 * @param application the active application to be redeployed
 * @param timeout the timeout to use for each individual deployment operation
 * @return a new deployment from the local active, or empty if a local active application
 *         was not present for this id (meaning it either is not active or active on another
 *         node in the config server cluster)
 */
@Override
public Optional<com.yahoo.config.provision.Deployment> deployFromLocalActive(ApplicationId application, Duration timeout) {
    Tenant tenant = tenants.getTenant(application.tenant());
    if (tenant == null)
        return Optional.empty();
    LocalSession activeSession = getActiveSession(tenant, application);
    if (activeSession == null)
        return Optional.empty();
    TimeoutBudget timeoutBudget = new TimeoutBudget(clock, timeout);
    LocalSession newSession = tenant.getSessionFactory().createSessionFromExisting(activeSession, logger, timeoutBudget);
    tenant.getLocalSessionRepo().addSession(newSession);
    // Keep manually deployed applications on the latest version, don't change version otherwise
    Version version = environment.isManuallyDeployed() ? Vtag.currentVersion : newSession.getVespaVersion();
    return Optional.of(Deployment.unprepared(newSession, this, hostProvisioner, tenant, timeout, clock, // don't validate as this is already deployed
    false, version));
}
Also used : Tenant(com.yahoo.vespa.config.server.tenant.Tenant) Version(com.yahoo.component.Version) LocalSession(com.yahoo.vespa.config.server.session.LocalSession)

Aggregations

Version (com.yahoo.component.Version)83 Test (org.junit.Test)46 Application (com.yahoo.vespa.hosted.controller.Application)32 JobType.systemTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)30 ApplicationPackage (com.yahoo.vespa.hosted.controller.application.ApplicationPackage)25 JobType.stagingTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)25 DeploymentTester (com.yahoo.vespa.hosted.controller.deployment.DeploymentTester)24 VespaVersion (com.yahoo.vespa.hosted.controller.versions.VespaVersion)22 ApplicationPackageBuilder (com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder)17 ApplicationVersion (com.yahoo.vespa.hosted.controller.application.ApplicationVersion)15 ApplicationId (com.yahoo.config.provision.ApplicationId)11 Collections (java.util.Collections)11 List (java.util.List)11 Deployment (com.yahoo.vespa.hosted.controller.application.Deployment)10 Optional (java.util.Optional)10 Slime (com.yahoo.slime.Slime)9 Map (java.util.Map)9 ControllerTester (com.yahoo.vespa.hosted.controller.ControllerTester)7 ZoneId (com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)7 URI (java.net.URI)7