Ejemplo n.º 1
0
    def test_transform_command_for_large_serverset(self):
        try:
            command = '/usr/local/bin/zk_download_data.py -f /var/serverset/discovery.stingray_dsl_mapper.prod -p /discovery/stingray_dsl_mapper/prod -m serverset'
            notification_timestamp = 1426859717.707331
            with open(LARGE_SERVERSET_EXAMPLE_FILE_PATH) as f:
                large_serverset_value = f.readline()
            (transformed_command, tmp_filepath) = transform_command_with_value(
                command, large_serverset_value, notification_timestamp)

            santinized_value = large_serverset_value.strip('\n').strip('\r')

            expected_tmp_filepath = '/tmp/zk_update_largefile_' + zk_util.get_md5_digest(
                santinized_value) + '_' + str(notification_timestamp)
            expected_transformed_command = '/usr/local/bin/zk_download_data.py -l ' \
                                           + expected_tmp_filepath + ' -f /var/serverset/discovery.stingray_dsl_mapper.prod -p /discovery/stingray_dsl_mapper/prod -m serverset'
            self.assertEqual(expected_transformed_command, transformed_command)
            self.assertEqual(expected_tmp_filepath, tmp_filepath)

            # Validate the file content
            tmpfile = open(expected_tmp_filepath)
            tmpfile_value = tmpfile.readline().rstrip('\n')
            tmpfile_md5 = tmpfile.readline()

            expected_tmpfile_value = santinized_value
            expected_tmpfile_md5 = zk_util.get_md5_digest(
                expected_tmpfile_value)

            self.assertEqual(expected_tmpfile_value, tmpfile_value)
            self.assertEqual(expected_tmpfile_md5, tmpfile_md5)
        finally:
            if os.path.isfile(tmp_filepath):
                os.remove(tmp_filepath)
Ejemplo n.º 2
0
    def test_transform_command_for_large_serverset(self):
        try:
            command = '/usr/local/bin/zk_download_data.py -f /var/serverset/discovery.stingray_dsl_mapper.prod -p /discovery/stingray_dsl_mapper/prod -m serverset'
            notification_timestamp = 1426859717.707331
            with open(LARGE_SERVERSET_EXAMPLE_FILE_PATH) as f:
                large_serverset_value = f.readline()
            (transformed_command, tmp_filepath) = transform_command_with_value(
                command, large_serverset_value, notification_timestamp)

            santinized_value = large_serverset_value.strip('\n').strip('\r')

            expected_tmp_filepath = '/tmp/zk_update_largefile_' + zk_util.get_md5_digest(
                santinized_value) + '_' + str(notification_timestamp)
            expected_transformed_command = '/usr/local/bin/zk_download_data.py -l ' \
                                           + expected_tmp_filepath + ' -f /var/serverset/discovery.stingray_dsl_mapper.prod -p /discovery/stingray_dsl_mapper/prod -m serverset'
            self.assertEqual(expected_transformed_command, transformed_command)
            self.assertEqual(expected_tmp_filepath, tmp_filepath)

            # Validate the file content
            tmpfile = open(expected_tmp_filepath)
            tmpfile_value = tmpfile.readline().rstrip('\n')
            tmpfile_md5 = tmpfile.readline()

            expected_tmpfile_value = santinized_value
            expected_tmpfile_md5 = zk_util.get_md5_digest(expected_tmpfile_value)

            self.assertEqual(expected_tmpfile_value, tmpfile_value)
            self.assertEqual(expected_tmpfile_md5, tmpfile_md5)
        finally:
            if os.path.isfile(tmp_filepath):
                os.remove(tmp_filepath)
Ejemplo n.º 3
0
    def test_transform_command_for_small_serverset(self):
        command = '/usr/local/bin/zk_download_data.py -f /var/serverset/discovery.stingray_dsl_mapper.prod -p /discovery/stingray_dsl_mapper/prod -m serverset'
        notification_timestamp = 1426859717.707331
        small_serverset_value = SMALL_SERVERSET_EXAMPLE
        (transformed_command, tmp_filepath) = transform_command_with_value(
            command, small_serverset_value, notification_timestamp)

        expected_tmp_filepath = None
        expected_transformed_command = '/usr/local/bin/zk_download_data.py -v ' \
                                       + "'" + small_serverset_value + "'" + ' -f /var/serverset/discovery.stingray_dsl_mapper.prod -p /discovery/stingray_dsl_mapper/prod -m serverset'
        self.assertEqual(expected_transformed_command, transformed_command)
        self.assertEqual(expected_tmp_filepath, tmp_filepath)
Ejemplo n.º 4
0
    def test_transform_command_for_small_serverset(self):
        command = '/usr/local/bin/zk_download_data.py -f /var/serverset/discovery.stingray_dsl_mapper.prod -p /discovery/stingray_dsl_mapper/prod -m serverset'
        notification_timestamp = 1426859717.707331
        small_serverset_value = SMALL_SERVERSET_EXAMPLE
        (transformed_command,
         tmp_filepath) = transform_command_with_value(command,
                                                      small_serverset_value,
                                                      notification_timestamp)

        expected_tmp_filepath = None
        expected_transformed_command = '/usr/local/bin/zk_download_data.py -v ' \
                                       + "'" + small_serverset_value + "'" + ' -f /var/serverset/discovery.stingray_dsl_mapper.prod -p /discovery/stingray_dsl_mapper/prod -m serverset'
        self.assertEqual(expected_transformed_command, transformed_command)
        self.assertEqual(expected_tmp_filepath, tmp_filepath)