1
# Copyright (c) 2014 Mirantis Inc.
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
7
# http://www.apache.org/licenses/LICENSE-2.0
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
16
from testtools import testcase
18
from sahara.tests.integration.configs import config as cfg
19
from sahara.tests.integration.tests import base as b
20
from sahara.tests.integration.tests import edp
21
from sahara.tests.integration.tests import scaling
22
from sahara.tests.integration.tests import swift
23
from sahara.utils import edp as utils_edp
26
class HDP2GatingTest(swift.SwiftTest, scaling.ScalingTest,
29
config = cfg.ITConfig().hdp2_config
30
SKIP_EDP_TEST = config.SKIP_EDP_TEST
31
SKIP_SWIFT_TEST = config.SKIP_SWIFT_TEST
32
SKIP_SCALING_TEST = config.SKIP_SCALING_TEST
35
super(HDP2GatingTest, self).setUp()
36
self.cluster_id = None
37
self.cluster_template_id = None
38
self.ng_template_ids = []
40
def _prepare_test(self):
41
self.hdp2_config = cfg.ITConfig().hdp2_config
42
self.floating_ip_pool = self.common_config.FLOATING_IP_POOL
43
self.internal_neutron_net = None
44
if self.common_config.NEUTRON_ENABLED:
45
self.internal_neutron_net = self.get_internal_neutron_net_id()
46
self.floating_ip_pool = (
47
self.get_floating_ip_pool_id_for_neutron_net())
49
self.hdp2_config.IMAGE_ID, self.hdp2_config.SSH_USERNAME = (
50
self.get_image_id_and_ssh_username(self.hdp2_config))
52
@b.errormsg("Failure while 'rm-nn' node group template creation: ")
53
def _create_rm_nn_ng_template(self):
55
'name': 'test-node-group-template-hdp2-rm-nn',
56
'plugin_config': self.hdp2_config,
57
'description': 'test node group template for HDP plugin',
58
'node_processes': self.hdp2_config.MASTER_NODE_PROCESSES,
59
'floating_ip_pool': self.floating_ip_pool,
62
self.ng_tmpl_rm_nn_id = self.create_node_group_template(**template)
63
self.ng_template_ids.append(self.ng_tmpl_rm_nn_id)
65
@b.errormsg("Failure while 'nm-dn' node group template creation: ")
66
def _create_nm_dn_ng_template(self):
68
'name': 'test-node-group-template-hdp2-nm-dn',
69
'plugin_config': self.hdp2_config,
70
'description': 'test node group template for HDP plugin',
71
'node_processes': self.hdp2_config.WORKER_NODE_PROCESSES,
72
'floating_ip_pool': self.floating_ip_pool,
75
self.ng_tmpl_nm_dn_id = self.create_node_group_template(**template)
76
self.ng_template_ids.append(self.ng_tmpl_nm_dn_id)
78
@b.errormsg("Failure while cluster template creation: ")
79
def _create_cluster_template(self):
81
'name': 'test-cluster-template-hdp2',
82
'plugin_config': self.hdp2_config,
83
'description': 'test cluster template for HDP plugin',
86
'yarn.log-aggregation-enable': False
91
'name': 'master-node-dn',
92
'node_group_template_id': self.ng_tmpl_rm_nn_id,
96
'name': 'worker-node-nm',
97
'node_group_template_id': self.ng_tmpl_nm_dn_id,
101
'net_id': self.internal_neutron_net
103
self.cluster_template_id = self.create_cluster_template(**template)
105
@b.errormsg("Failure while cluster creation: ")
106
def _create_cluster(self):
107
cluster_name = '%s-%s-v2' % (self.common_config.CLUSTER_NAME,
108
self.hdp2_config.PLUGIN_NAME)
110
'name': cluster_name,
111
'plugin_config': self.hdp2_config,
112
'cluster_template_id': self.cluster_template_id,
113
'description': 'test cluster',
114
'cluster_configs': {}
116
self.create_cluster(**cluster)
117
self.cluster_info = self.get_cluster_info(self.hdp2_config)
118
self.await_active_workers_for_namenode(self.cluster_info['node_info'],
121
@b.errormsg("Failure during check of Swift availability: ")
122
def _check_swift(self):
123
self.check_swift_availability(self.cluster_info)
125
@b.errormsg("Failure while EDP testing: ")
126
def _check_edp(self):
131
pig_job = self.edp_info.read_pig_example_script()
132
pig_lib = self.edp_info.read_pig_example_jar()
134
self.edp_testing(job_type=utils_edp.JOB_TYPE_PIG,
135
job_data_list=[{'pig': pig_job}],
136
lib_data_list=[{'jar': pig_lib}],
138
hdfs_local_output=True)
141
mapreduce_jar = self.edp_info.read_mapreduce_example_jar()
142
mapreduce_configs = self.edp_info.mapreduce_example_configs()
143
self.edp_testing(job_type=utils_edp.JOB_TYPE_MAPREDUCE,
145
lib_data_list=[{'jar': mapreduce_jar}],
146
configs=mapreduce_configs,
148
hdfs_local_output=True)
150
# check mapreduce streaming
151
self.edp_testing(job_type=utils_edp.JOB_TYPE_MAPREDUCE_STREAMING,
154
configs=self.edp_info.mapreduce_streaming_configs())
157
java_jar = self.edp_info.read_java_example_lib(2)
158
java_configs = self.edp_info.java_example_configs(2)
159
self.edp_testing(utils_edp.JOB_TYPE_JAVA,
161
lib_data_list=[{'jar': java_jar}],
162
configs=java_configs)
164
@b.errormsg("Failure while cluster scaling: ")
165
def _check_scaling(self):
166
datanode_count_after_resizing = (
167
self.cluster_info['node_info']['datanode_count']
168
+ self.hdp_config.SCALE_EXISTING_NG_COUNT)
171
'operation': 'resize',
172
'info': ['worker-node-nm',
173
datanode_count_after_resizing]
177
'info': ['new-worker-node-tt-dn',
178
self.hdp2_config.SCALE_NEW_NG_COUNT,
179
'%s' % self.ng_tmpl_nm_dn_id]
183
self.cluster_info = self.cluster_scaling(self.cluster_info,
185
self.await_active_workers_for_namenode(self.cluster_info['node_info'],
189
"Failure during check of Swift availability after cluster scaling: ")
190
def _check_swift_after_scaling(self):
191
self.check_swift_availability(self.cluster_info)
193
@b.errormsg("Failure while EDP testing after cluster scaling: ")
194
def _check_edp_after_scaling(self):
197
@testcase.attr('hdp2')
198
@testcase.skipIf(config.SKIP_ALL_TESTS_FOR_PLUGIN,
199
'All tests for HDP2 plugin were skipped')
200
def test_hdp2_plugin_gating(self):
202
self._create_rm_nn_ng_template()
203
self._create_nm_dn_ng_template()
204
self._create_cluster_template()
205
self._create_cluster()
210
if not self.hdp2_config.SKIP_SCALING_TEST:
211
self._check_scaling()
212
self._check_swift_after_scaling()
213
self._check_edp_after_scaling()
216
self.delete_objects(self.cluster_id, self.cluster_template_id,
217
self.ng_template_ids)
218
super(HDP2GatingTest, self).tearDown()