<commit_before>from testconfig import config

from tests.integration.core.chroma_integration_testcase import ChromaIntegrationTestCase


class TestConfParams(ChromaIntegrationTestCase):
    def _create_with_params(self):
        self.hosts = self.add_hosts([
            config['lustre_servers'][0]['address'],
            config['lustre_servers'][1]['address'],
        ])

        # Since the test code seems to rely on this ordering, we should
        # check for it right away and blow up if it's not as we expect.
        self.assertEqual([h['address'] for h in self.hosts],
                         [config['lustre_servers'][0]['address'],
                          config['lustre_servers'][1]['address']])

        volumes = self.get_usable_volumes()
        self.assertGreaterEqual(len(volumes), 4)

        mgt_volume = volumes[0]
        mdt_volume = volumes[1]
        ost_volume = volumes[2]
        self.set_volume_mounts(mgt_volume, self.hosts[0]['id'], self.hosts[1]['id'])
        self.set_volume_mounts(mdt_volume, self.hosts[0]['id'], self.hosts[1]['id'])
        self.set_volume_mounts(ost_volume, self.hosts[0]['id'], self.hosts[1]['id'])

        self.filesystem_id = self.create_filesystem(
                {
                'name': 'testfs',
                'mgt': {'volume_id': mgt_volume['id']},
                'mdt': {
                    'volume_id': mdt_volume['id'],
                    'conf_params': {'lov.stripesize': '2097152'}

                },
                'osts': [{
                    'volume_id': ost_volume['id'],
                    'conf_params': {'ost.writethrough_cache_enable': '0'}
                }],
                'conf_params': {'llite.max_cached_mb': '16'}
            }
        )

    def _test_params(self):
        # Mount the filesystem
        response = self.chroma_manager.get(
            '/api/filesystem/',
        )
        self.assertEqual(response.status_code, 200, response.text)
        self.assertEqual(len(response.json['objects']), 1)
        filesystem = response.json['objects'][0]
        client = config['lustre_clients'].keys()[0]
        self.remote_operations.mount_filesystem(client, filesystem)

        try:
            self.assertEqual("16", self.remote_operations.read_proc(client, "/proc/fs/lustre/llite/*/max_cached_mb"))

            server_address = self.hosts[0]['address']
            self.assertEqual("2097152", self.remote_operations.read_proc(server_address, "/proc/fs/lustre/lov/testfs-MDT0000-mdtlov/stripesize"))
            self.assertEqual("0", self.remote_operations.read_proc(server_address, "/proc/fs/lustre/obdfilter/testfs-OST0000/writethrough_cache_enable"))
        finally:
            self.remote_operations.unmount_filesystem(client, filesystem)

    def test_creation_conf_params(self):
        self._create_with_params()
        self._test_params()
        self.graceful_teardown(self.chroma_manager)

    def test_writeconf_conf_params(self):
        self._create_with_params()
        self._test_params()
<commit_msg>HYD-2169: sometimes data not propagated when the read is done: wait_until_true asserts instead<commit_after>from testconfig import config

from tests.integration.core.chroma_integration_testcase import ChromaIntegrationTestCase


class TestConfParams(ChromaIntegrationTestCase):
    def _create_with_params(self):
        self.hosts = self.add_hosts([
            config['lustre_servers'][0]['address'],
            config['lustre_servers'][1]['address'],
        ])

        # Since the test code seems to rely on this ordering, we should
        # check for it right away and blow up if it's not as we expect.
        self.assertEqual([h['address'] for h in self.hosts],
                         [config['lustre_servers'][0]['address'],
                          config['lustre_servers'][1]['address']])

        volumes = self.get_usable_volumes()
        self.assertGreaterEqual(len(volumes), 4)

        mgt_volume = volumes[0]
        mdt_volume = volumes[1]
        ost_volume = volumes[2]
        self.set_volume_mounts(mgt_volume, self.hosts[0]['id'], self.hosts[1]['id'])
        self.set_volume_mounts(mdt_volume, self.hosts[0]['id'], self.hosts[1]['id'])
        self.set_volume_mounts(ost_volume, self.hosts[0]['id'], self.hosts[1]['id'])

        self.filesystem_id = self.create_filesystem(
                {
                'name': 'testfs',
                'mgt': {'volume_id': mgt_volume['id']},
                'mdt': {
                    'volume_id': mdt_volume['id'],
                    'conf_params': {'lov.stripesize': '2097152'}

                },
                'osts': [{
                    'volume_id': ost_volume['id'],
                    'conf_params': {'ost.writethrough_cache_enable': '0'}
                }],
                'conf_params': {'llite.max_cached_mb': '16'}
            }
        )

    def _test_params(self):
        # Mount the filesystem
        response = self.chroma_manager.get(
            '/api/filesystem/',
        )
        self.assertEqual(response.status_code, 200, response.text)
        self.assertEqual(len(response.json['objects']), 1)
        filesystem = response.json['objects'][0]
        client = config['lustre_clients'].keys()[0]
        self.remote_operations.mount_filesystem(client, filesystem)

        try:
            self.assertEqual("16", self.remote_operations.read_proc(client, "/proc/fs/lustre/llite/*/max_cached_mb"))

            server_address = self.hosts[0]['address']
            self.wait_until_true(lambda: "2097152" == self.remote_operations.read_proc(server_address, "/proc/fs/lustre/lov/testfs-MDT0000-mdtlov/stripesize"))
            self.wait_until_true(lambda: "0" == self.remote_operations.read_proc(server_address, "/proc/fs/lustre/obdfilter/testfs-OST0000/writethrough_cache_enable"))
        finally:
            self.remote_operations.unmount_filesystem(client, filesystem)

    def test_creation_conf_params(self):
        self._create_with_params()
        self._test_params()
        self.graceful_teardown(self.chroma_manager)

    def test_writeconf_conf_params(self):
        self._create_with_params()
        self._test_params()

{'fraction_non_alphanumeric': 0.13036437246963561, 'fraction_numerical': 0.01651821862348178, 'mean_word_length': 2.5210946408209804, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '2147288', 'n_tokens_mistral': 1953, 'n_tokens_neox': 1832, 'n_words': 280}