Path: blob/develop/tests/unit/customizations/emr/test_disable_hbase_backup.py
1569 views
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.1#2# Licensed under the Apache License, Version 2.0 (the "License"). You3# may not use this file except in compliance with the License. A copy of4# the License is located at5#6# http://aws.amazon.com/apache2.0/7#8# or in the "license" file accompanying this file. This file is9# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF10# ANY KIND, either express or implied. See the License for the specific11# language governing permissions and limitations under the License.12from awscli.testutils import mock1314from tests.unit.customizations.emr import EMRBaseAWSCommandParamsTest as \15BaseAWSCommandParamsTest16from copy import deepcopy171819class TestDisableHBaseBackups(BaseAWSCommandParamsTest):20prefix = 'emr disable-hbase-backups'21DISABLE_FULL_BACKUP = '--disable-full-backups'22DISABLE_INCR_BACKUP = '--disable-incremental-backups'23default_steps = [{24'HadoopJarStep': {25'Args': [26'emr.hbase.backup.Main',27'--set-scheduled-backup',28'false'29],30'Jar': '/home/hadoop/lib/hbase.jar'31},32'Name': 'Modify Backup Schedule',33'ActionOnFailure': 'CANCEL_AND_WAIT'34}]3536def test_disable_hbase_backups_full(self):37args = ' --cluster-id j-ABCD --full'38cmdline = self.prefix + args3940steps = deepcopy(self.default_steps)41steps[0]['HadoopJarStep']['Args'].append(self.DISABLE_FULL_BACKUP)42result = {'JobFlowId': 'j-ABCD', 'Steps': steps}4344self.assert_params_for_cmd(cmdline, result)4546def test_disable_hbase_backups_incremental(self):47args = ' --cluster-id j-ABCD --incremental'48cmdline = self.prefix + args4950steps = deepcopy(self.default_steps)51steps[0]['HadoopJarStep']['Args'].append(self.DISABLE_INCR_BACKUP)52result = {'JobFlowId': 'j-ABCD', 'Steps': steps}5354self.assert_params_for_cmd(cmdline, result)5556def test_disable_hbase_backups_both(self):57args = ' --cluster-id j-ABCD --full --incremental'58cmdline = self.prefix + args5960steps = deepcopy(self.default_steps)61steps[0]['HadoopJarStep']['Args'].append(self.DISABLE_FULL_BACKUP)62steps[0]['HadoopJarStep']['Args'].append(self.DISABLE_INCR_BACKUP)63result = {'JobFlowId': 'j-ABCD', 'Steps': steps}6465self.assert_params_for_cmd(cmdline, result)6667def test_disable_hbase_backups_none(self):68args = ' --cluster-id j-ABCD'69cmdline = self.prefix + args70expected_error_msg = '\nShould specify at least one of --full' +\71' and --incremental.\n'72result = self.run_cmd(cmdline, 255)7374self.assertEqual(expected_error_msg, result[1])7576@mock.patch('awscli.customizations.emr.'77'emrutils.get_release_label')78def test_unsupported_command_on_release_based_cluster_error(79self, grl_patch):80grl_patch.return_value = 'emr-4.0'81args = ' --cluster-id j-ABCD --full'82cmdline = self.prefix + args83expected_error_msg = ("\naws: error: disable-hbase-backups"84" is not supported with 'emr-4.0' release.\n")85result = self.run_cmd(cmdline, 255)8687self.assertEqual(result[1], expected_error_msg)8889if __name__ == "__main__":90unittest.main()919293