<commit_before>import os
import os.path

from assertions import assert_almost_equal
from dtest import DISABLE_VNODES, Tester
from jmxutils import JolokiaAgent, make_mbean, remove_perf_disable_shared_mem
from tools import (create_c1c2_table, insert_c1c2, known_failure, new_node,
                   query_c1c2, since)


@since('3.2')
class TestDiskBalance(Tester):
    """
    @jira_ticket CASSANDRA-6696
    """
    def disk_balance_stress_test(self):
        cluster = self.cluster
        cluster.set_configuration_options(values={'allocate_tokens_for_keyspace': 'keyspace1'})
        if not DISABLE_VNODES:
            cluster.set_configuration_options(values={'num_tokens': 256})
        cluster.populate(4).start(wait_for_binary_proto=True)
        node1 = cluster.nodes['node1']

        node1.stress(['write', 'n=10k', '-rate', 'threads=100', '-schema', 'replication(factor=2)'])
        cluster.flush()
        # make sure the data directories are balanced:
        for node in cluster.nodelist():
            self.assert_balanced(node)

    @known_failure(failure_source='test',
                   jira_url='https://issues.apache.org/jira/browse/CASSANDRA-11279',
                   flaky=True)
    def disk_balance_bootstrap_test(self):
        cluster = self.cluster
        if not DISABLE_VNODES:
            cluster.set_configuration_options(values={'num_tokens': 256})
        # apparently we have legitimate errors in the log when bootstrapping (see bootstrap_test.py)
        self.allow_log_errors = True
        cluster.set_configuration_options(values={'allocate_tokens_for_keyspace': 'keyspace1'})
        cluster.populate(4).start(wait_for_binary_proto=True)
        node1 = cluster.nodes['node1']

        node1.stress(['write', 'n=10k', '-rate', 'threads=100', '-schema', 'replication(factor=3)'])
        cluster.flush()
        node5 = new_node(cluster)
        node5.start(wait_for_binary_proto=True)
        self.assert_balanced(node5)

        cluster.cleanup()

        self.assert_balanced(node5)

        if DISABLE_VNODES:
            for node in cluster.nodelist():
                node.nodetool('relocatesstables')
            self.assertTrue(len(node5.grep_log("No sstables to RELOCATE for keyspace1.standard1")) > 0)

        for node in cluster.nodelist():
            self.assert_balanced(node)
<commit_msg>tag known failure in disk_balance_test module<commit_after>import os
import os.path

from assertions import assert_almost_equal
from dtest import DISABLE_VNODES, Tester
from jmxutils import JolokiaAgent, make_mbean, remove_perf_disable_shared_mem
from tools import (create_c1c2_table, insert_c1c2, known_failure, new_node,
                   query_c1c2, since)


@since('3.2')
class TestDiskBalance(Tester):
    """
    @jira_ticket CASSANDRA-6696
    """
    def disk_balance_stress_test(self):
        cluster = self.cluster
        cluster.set_configuration_options(values={'allocate_tokens_for_keyspace': 'keyspace1'})
        if not DISABLE_VNODES:
            cluster.set_configuration_options(values={'num_tokens': 256})
        cluster.populate(4).start(wait_for_binary_proto=True)
        node1 = cluster.nodes['node1']

        node1.stress(['write', 'n=10k', '-rate', 'threads=100', '-schema', 'replication(factor=2)'])
        cluster.flush()
        # make sure the data directories are balanced:
        for node in cluster.nodelist():
            self.assert_balanced(node)

    @known_failure(failure_source='test',
                   jira_url='https://issues.apache.org/jira/browse/CASSANDRA-11279',
                   flaky=True)
    def disk_balance_bootstrap_test(self):
        cluster = self.cluster
        if not DISABLE_VNODES:
            cluster.set_configuration_options(values={'num_tokens': 256})
        # apparently we have legitimate errors in the log when bootstrapping (see bootstrap_test.py)
        self.allow_log_errors = True
        cluster.set_configuration_options(values={'allocate_tokens_for_keyspace': 'keyspace1'})
        cluster.populate(4).start(wait_for_binary_proto=True)
        node1 = cluster.nodes['node1']

        node1.stress(['write', 'n=10k', '-rate', 'threads=100', '-schema', 'replication(factor=3)'])
        cluster.flush()
        node5 = new_node(cluster)
        node5.start(wait_for_binary_proto=True)
        self.assert_balanced(node5)

        cluster.cleanup()

        self.assert_balanced(node5)

        if DISABLE_VNODES:
            for node in cluster.nodelist():
                node.nodetool('relocatesstables')
            self.assertTrue(len(node5.grep_log("No sstables to RELOCATE for keyspace1.standard1")) > 0)

        for node in cluster.nodelist():
            self.assert_balanced(node)

    @known_failure(failure_source='test',
                   jira_url='https://issues.apache.org/jira/browse/CASSANDRA-11279',
                   flaky=True)
{'fraction_non_alphanumeric': 0.10844608446084461, 'fraction_numerical': 0.022755227552275523, 'mean_word_length': 3.103448275862069, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '72636', 'n_tokens_mistral': 1572, 'n_tokens_neox': 1486, 'n_words': 266}