Exemplo n.º 1
0
    def compression_cql_enabled_with_alter_test(self):
        """
        @jira_ticket CASSANDRA-8384
        starting with compression disabled and enabling it
        """
        cluster = self.cluster
        cluster.populate(1).start(wait_for_binary_proto=True)
        [node] = cluster.nodelist()

        session = self.patient_cql_connection(node)
        self.create_ks(session, 'ks', 1)
        session.execute(
            "create table start_disabled_compression_table (id uuid PRIMARY KEY ) WITH compression = {'enabled': false};"
        )
        meta = session.cluster.metadata.keyspaces['ks'].tables[
            'start_disabled_compression_table']
        self.assertEqual('false', meta.options['compression']['enabled'])
        session.execute("""alter table start_disabled_compression_table
                                WITH compression = {
                                        'class': 'SnappyCompressor',
                                        'chunk_length_in_kb': 256
                                    } AND crc_check_chance = 0.25;""")

        session.cluster.refresh_schema_metadata()
        meta = session.cluster.metadata.keyspaces['ks'].tables[
            'start_disabled_compression_table']
        self.assertEqual('org.apache.cassandra.io.compress.SnappyCompressor',
                         meta.options['compression']['class'])
        self.assertEqual('256',
                         meta.options['compression']['chunk_length_in_kb'])
        assert_crc_check_chance_equal(session,
                                      "start_disabled_compression_table", 0.25)
Exemplo n.º 2
0
    def test_compression_cql_enabled_with_alter(self):
        """
        @jira_ticket CASSANDRA-8384
        starting with compression disabled and enabling it
        """
        cluster = self.cluster
        cluster.populate(1).start(wait_for_binary_proto=True)
        [node] = cluster.nodelist()

        session = self.patient_cql_connection(node)
        create_ks(session, 'ks', 1)
        session.execute("create table start_disabled_compression_table (id uuid PRIMARY KEY ) WITH compression = {'enabled': false};")
        meta = session.cluster.metadata.keyspaces['ks'].tables['start_disabled_compression_table']
        assert 'false' == meta.options['compression']['enabled']
        session.execute("""alter table start_disabled_compression_table
                                WITH compression = {
                                        'class': 'SnappyCompressor',
                                        'chunk_length_in_kb': 256
                                    } AND crc_check_chance = 0.25;""")

        session.cluster.refresh_schema_metadata()
        meta = session.cluster.metadata.keyspaces['ks'].tables['start_disabled_compression_table']
        assert 'org.apache.cassandra.io.compress.SnappyCompressor' == meta.options['compression']['class']
        assert '256' == meta.options['compression']['chunk_length_in_kb']
        assert_crc_check_chance_equal(session, "start_disabled_compression_table", 0.25)
Exemplo n.º 3
0
    def compression_cql_disabled_with_alter_test(self):
        """
        @jira_ticket CASSANDRA-8384
        starting with compression enabled then disabling it
        """
        cluster = self.cluster
        cluster.populate(1).start(wait_for_binary_proto=True)
        [node] = cluster.nodelist()

        session = self.patient_cql_connection(node)
        create_ks(session, "ks", 1)
        session.execute(
            """
            create table start_enabled_compression_table
                (id uuid PRIMARY KEY )
                WITH compression = {
                    'class': 'SnappyCompressor',
                    'chunk_length_in_kb': 256
                }
                AND crc_check_chance = 0.25;
            """
        )
        meta = session.cluster.metadata.keyspaces["ks"].tables["start_enabled_compression_table"]
        self.assertEqual("org.apache.cassandra.io.compress.SnappyCompressor", meta.options["compression"]["class"])
        self.assertEqual("256", meta.options["compression"]["chunk_length_in_kb"])
        assert_crc_check_chance_equal(session, "start_enabled_compression_table", 0.25)
        session.execute("alter table start_enabled_compression_table with compression = {'enabled': false};")

        session.cluster.refresh_schema_metadata()
        meta = session.cluster.metadata.keyspaces["ks"].tables["start_enabled_compression_table"]
        self.assertEqual("false", meta.options["compression"]["enabled"])
    def test_compression_cql_options(self):
        """
        @jira_ticket CASSANDRA-8384
        using new cql create table syntax to configure compression
        """
        cluster = self.cluster
        cluster.populate(1).start(wait_for_binary_proto=True)
        [node] = cluster.nodelist()

        session = self.patient_cql_connection(node)
        create_ks(session, 'ks', 1)
        session.execute("""
            create table compression_opts_table
                (id uuid PRIMARY KEY )
                WITH compression = {
                    'class': 'DeflateCompressor',
                    'chunk_length_in_kb': 256
                }
                AND crc_check_chance = 0.25;
            """)

        session.cluster.refresh_schema_metadata()
        meta = session.cluster.metadata.keyspaces['ks'].tables['compression_opts_table']
        assert 'org.apache.cassandra.io.compress.DeflateCompressor' == meta.options['compression']['class']
        assert '256' == meta.options['compression']['chunk_length_in_kb']
        assert_crc_check_chance_equal(session, "compression_opts_table", 0.25)

        warn = node.grep_log("The option crc_check_chance was deprecated as a compression option.")
        assert len(warn) == 0
        session.execute("""
            alter table compression_opts_table
                WITH compression = {
                    'class': 'DeflateCompressor',
                    'chunk_length_in_kb': 256,
                    'crc_check_chance': 0.6
                }
            """)
        warn = node.grep_log("The option crc_check_chance was deprecated as a compression option.")
        assert len(warn) == 1

        # check metadata again after crc_check_chance_update
        session.cluster.refresh_schema_metadata()
        meta = session.cluster.metadata.keyspaces['ks'].tables['compression_opts_table']
        assert 'org.apache.cassandra.io.compress.DeflateCompressor' == meta.options['compression']['class']
        assert '256' == meta.options['compression']['chunk_length_in_kb']
        assert_crc_check_chance_equal(session, "compression_opts_table", 0.6)

        for n in range(0, 100):
            session.execute("insert into compression_opts_table (id) values (uuid());")

        sstables = self.flush('compression_opts_table')
        sstable_paths = self.get_table_paths('compression_opts_table')
        found = False
        for sstable_path in sstable_paths:
            sstable = os.path.join(sstable_path, sstables['compression_opts_table'][1])
            if os.path.exists(sstable):
                assert 'DEFLATE' == self._get_compression_type(sstable)
                found = True
        assert found
Exemplo n.º 5
0
 def verify_new_crc_check_chance(self, node):
     session = self.patient_exclusive_cql_connection(node)
     session.cluster.refresh_schema_metadata(0)
     meta = session.cluster.metadata.keyspaces['ks'].tables['cf1']
     assert 'org.apache.cassandra.io.compress.DeflateCompressor' == meta.options['compression']['class']
     assert '256' == meta.options['compression']['chunk_length_in_kb']
     assert_crc_check_chance_equal(session, "cf1", 0.6)
     session.shutdown()
 def verify_new_crc_check_chance(self, node):
     session = self.patient_exclusive_cql_connection(node)
     session.cluster.refresh_schema_metadata(0)
     meta = session.cluster.metadata.keyspaces['ks'].tables['cf1']
     self.assertEqual('org.apache.cassandra.io.compress.DeflateCompressor', meta.options['compression']['class'])
     self.assertEqual('256', meta.options['compression']['chunk_length_in_kb'])
     assert_crc_check_chance_equal(session, "cf1", 0.6)
     session.shutdown()