Path: blob/develop/tests/unit/customizations/emr/test_create_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 TestCreateHBaseBackup(BaseAWSCommandParamsTest):20prefix = 'emr create-hbase-backup'21steps = [{22'HadoopJarStep': {23'Args': [24'emr.hbase.backup.Main',25'--backup',26'--backup-dir',27's3://abc/'28],29'Jar': '/home/hadoop/lib/hbase.jar'30},31'Name': 'Backup HBase',32'ActionOnFailure': 'CANCEL_AND_WAIT'33}]3435def test_create_hbase_backup(self):36args = ' --cluster-id j-ABCD --dir s3://abc/'37cmdline = self.prefix + args38result = {'JobFlowId': 'j-ABCD', 'Steps': self.steps}3940self.assert_params_for_cmd(cmdline, result)4142def test_create_hbase_backup_consitent(self):43args = ' --cluster-id j-ABCD --dir s3://abc/ --consistent'44cmdline = self.prefix + args4546steps = deepcopy(self.steps)47steps[0]['HadoopJarStep']['Args'].append('--consistent')48result = {'JobFlowId': 'j-ABCD', 'Steps': steps}4950self.assert_params_for_cmd(cmdline, result)5152@mock.patch('awscli.customizations.emr.'53'emrutils.get_release_label')54def test_unsupported_command_on_release_based_cluster_error(55self, grl_patch):56grl_patch.return_value = 'emr-4.0'57args = ' --cluster-id j-ABCD --dir s3://abc/'58cmdline = self.prefix + args59expected_error_msg = ("\naws: error: create-hbase-backup"60" is not supported with 'emr-4.0' release.\n")61result = self.run_cmd(cmdline, 255)6263self.assertEqual(result[1], expected_error_msg)6465if __name__ == "__main__":66unittest.main()676869