Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/tests/unit/customizations/emr/test_create_hbase_backup.py
1569 views
1
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License"). You
4
# may not use this file except in compliance with the License. A copy of
5
# the License is located at
6
#
7
# http://aws.amazon.com/apache2.0/
8
#
9
# or in the "license" file accompanying this file. This file is
10
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
# ANY KIND, either express or implied. See the License for the specific
12
# language governing permissions and limitations under the License.
13
from awscli.testutils import mock
14
15
from tests.unit.customizations.emr import EMRBaseAWSCommandParamsTest as \
16
BaseAWSCommandParamsTest
17
from copy import deepcopy
18
19
20
class TestCreateHBaseBackup(BaseAWSCommandParamsTest):
21
prefix = 'emr create-hbase-backup'
22
steps = [{
23
'HadoopJarStep': {
24
'Args': [
25
'emr.hbase.backup.Main',
26
'--backup',
27
'--backup-dir',
28
's3://abc/'
29
],
30
'Jar': '/home/hadoop/lib/hbase.jar'
31
},
32
'Name': 'Backup HBase',
33
'ActionOnFailure': 'CANCEL_AND_WAIT'
34
}]
35
36
def test_create_hbase_backup(self):
37
args = ' --cluster-id j-ABCD --dir s3://abc/'
38
cmdline = self.prefix + args
39
result = {'JobFlowId': 'j-ABCD', 'Steps': self.steps}
40
41
self.assert_params_for_cmd(cmdline, result)
42
43
def test_create_hbase_backup_consitent(self):
44
args = ' --cluster-id j-ABCD --dir s3://abc/ --consistent'
45
cmdline = self.prefix + args
46
47
steps = deepcopy(self.steps)
48
steps[0]['HadoopJarStep']['Args'].append('--consistent')
49
result = {'JobFlowId': 'j-ABCD', 'Steps': steps}
50
51
self.assert_params_for_cmd(cmdline, result)
52
53
@mock.patch('awscli.customizations.emr.'
54
'emrutils.get_release_label')
55
def test_unsupported_command_on_release_based_cluster_error(
56
self, grl_patch):
57
grl_patch.return_value = 'emr-4.0'
58
args = ' --cluster-id j-ABCD --dir s3://abc/'
59
cmdline = self.prefix + args
60
expected_error_msg = ("\naws: error: create-hbase-backup"
61
" is not supported with 'emr-4.0' release.\n")
62
result = self.run_cmd(cmdline, 255)
63
64
self.assertEqual(result[1], expected_error_msg)
65
66
if __name__ == "__main__":
67
unittest.main()
68
69