Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/tests/unit/customizations/emr/test_disable_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 TestDisableHBaseBackups(BaseAWSCommandParamsTest):
21
prefix = 'emr disable-hbase-backups'
22
DISABLE_FULL_BACKUP = '--disable-full-backups'
23
DISABLE_INCR_BACKUP = '--disable-incremental-backups'
24
default_steps = [{
25
'HadoopJarStep': {
26
'Args': [
27
'emr.hbase.backup.Main',
28
'--set-scheduled-backup',
29
'false'
30
],
31
'Jar': '/home/hadoop/lib/hbase.jar'
32
},
33
'Name': 'Modify Backup Schedule',
34
'ActionOnFailure': 'CANCEL_AND_WAIT'
35
}]
36
37
def test_disable_hbase_backups_full(self):
38
args = ' --cluster-id j-ABCD --full'
39
cmdline = self.prefix + args
40
41
steps = deepcopy(self.default_steps)
42
steps[0]['HadoopJarStep']['Args'].append(self.DISABLE_FULL_BACKUP)
43
result = {'JobFlowId': 'j-ABCD', 'Steps': steps}
44
45
self.assert_params_for_cmd(cmdline, result)
46
47
def test_disable_hbase_backups_incremental(self):
48
args = ' --cluster-id j-ABCD --incremental'
49
cmdline = self.prefix + args
50
51
steps = deepcopy(self.default_steps)
52
steps[0]['HadoopJarStep']['Args'].append(self.DISABLE_INCR_BACKUP)
53
result = {'JobFlowId': 'j-ABCD', 'Steps': steps}
54
55
self.assert_params_for_cmd(cmdline, result)
56
57
def test_disable_hbase_backups_both(self):
58
args = ' --cluster-id j-ABCD --full --incremental'
59
cmdline = self.prefix + args
60
61
steps = deepcopy(self.default_steps)
62
steps[0]['HadoopJarStep']['Args'].append(self.DISABLE_FULL_BACKUP)
63
steps[0]['HadoopJarStep']['Args'].append(self.DISABLE_INCR_BACKUP)
64
result = {'JobFlowId': 'j-ABCD', 'Steps': steps}
65
66
self.assert_params_for_cmd(cmdline, result)
67
68
def test_disable_hbase_backups_none(self):
69
args = ' --cluster-id j-ABCD'
70
cmdline = self.prefix + args
71
expected_error_msg = '\nShould specify at least one of --full' +\
72
' and --incremental.\n'
73
result = self.run_cmd(cmdline, 255)
74
75
self.assertEqual(expected_error_msg, result[1])
76
77
@mock.patch('awscli.customizations.emr.'
78
'emrutils.get_release_label')
79
def test_unsupported_command_on_release_based_cluster_error(
80
self, grl_patch):
81
grl_patch.return_value = 'emr-4.0'
82
args = ' --cluster-id j-ABCD --full'
83
cmdline = self.prefix + args
84
expected_error_msg = ("\naws: error: disable-hbase-backups"
85
" is not supported with 'emr-4.0' release.\n")
86
result = self.run_cmd(cmdline, 255)
87
88
self.assertEqual(result[1], expected_error_msg)
89
90
if __name__ == "__main__":
91
unittest.main()
92
93