Exemplo n.º 1
0
    def prepare(self, ordered=False, create_keyspace=True, use_cache=False, nodes=2, rf=1, protocol_version=None, **kwargs):
        assert nodes >= 2, "backwards compatibility tests require at least two nodes"
        assert not self._preserve_cluster, "preserve_cluster cannot be True for upgrade tests"

        self.protocol_version = protocol_version

        cluster = self.cluster

        if (ordered):
            cluster.set_partitioner("org.apache.cassandra.dht.ByteOrderedPartitioner")

        if (use_cache):
            cluster.set_configuration_options(values={'row_cache_size_in_mb': 100})

        start_rpc = kwargs.pop('start_rpc', False)
        if start_rpc:
            cluster.set_configuration_options(values={'start_rpc': True})

        cluster.set_configuration_options(values={'internode_compression': 'none'})
        if not cluster.nodelist():
            cluster.populate(nodes)
            node1 = cluster.nodelist()[0]
            self.original_install_dir = node1.get_install_dir()
            self.original_git_branch = cassandra_git_branch()
            self.original_version = get_version_from_build(node_path=node1.get_path())
            if OLD_CASSANDRA_DIR:
                cluster.set_install_dir(install_dir=OLD_CASSANDRA_DIR)
            else:
                # upgrade from 3.0 to current install dir if we're running from trunk
                if self.original_git_branch == 'trunk':
                    cluster.set_install_dir(version='git:cassandra-3.0')
            cluster.start(wait_for_binary_proto=True)
            debug('starting from {}'.format(get_version_from_build(node1.get_install_dir())))

        node1 = cluster.nodelist()[0]
        time.sleep(0.2)

        session = self.patient_cql_connection(node1, protocol_version=protocol_version)
        if create_keyspace:
            self.create_ks(session, 'ks', rf)

        return session
Exemplo n.º 2
0
def get_default_upgrade_path(job_version, cdir=None):
    """
    Given a version (which should be specified as a LooseVersion,
    StrictVersion, or NormalizedVersion object), return a tuple (start, target)
    whose members indicate the git branch that should be downloaded for the
    starting or target versions for an upgrade test. One or both of these
    will be None, so this specifies at most one end of the upgrade path.

    We assume that the version being passed in is the version of C* being
    tested on a CassCI job, which means if the version is less than 3.0, we
    will be running on JDK 1.7. This means we can't run 3.0+ on this version.
    """
    start_version, upgrade_version = None, None
    debug('getting default job version for {}'.format(job_version))

    start_2_2_X_release = 'binary:2.2.3'

    if '2.1' <= job_version < '2.2':
        # If this is 2.1.X, we can upgrade to 2.2.
        # Skip 2.2.X->3.X because of JDK compatibility.
        upgrade_version = start_2_2_X_release
    elif '3.0' <= job_version < '3.1':
        try:
            branch = cassandra_git_branch(cdir=cdir)
        except:
            branch = None
        start_version = ('binary:3.0.0-rc1'
                         if branch == 'trunk'
                         else start_2_2_X_release)
    elif '3.1' <= job_version:
        # 2.2->3.X, where X > 0, isn't a supported upgrade path,
        # but 3.0->3.X is.
        start_version = 'git:cassandra-3.0'

    err = 'Expected one or two upgrade path endpoints to be None; found {}'.format((start_version, upgrade_version))
    assert [start_version, upgrade_version].count(None) >= 1, err
    upgrade_path = UpgradePath(start_version, upgrade_version)
    debug(upgrade_path)
    return upgrade_path