本文整理汇总了Python中sahara.tests.unit.testutils.create_cluster函数的典型用法代码示例。如果您正苦于以下问题:Python create_cluster函数的具体用法?Python create_cluster怎么用?Python create_cluster使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_cluster函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_check_cluster_scaling_missing_resource
def test_check_cluster_scaling_missing_resource(self, ops,
m_nova, m_image):
ops.get_engine_type_and_version.return_value = "heat.1.1"
ng1 = tu.make_ng_dict('ng', '42', ['namenode'], 1)
nova = mock.Mock()
m_nova.return_value = nova
nova.keypairs.get.side_effect = u._get_keypair
cluster = tu.create_cluster(
"cluster1", "tenant1", "fake", "0.1", [ng1],
status=c_u.CLUSTER_STATUS_ACTIVE,
sahara_info={"infrastructure_engine": "heat.1.1"},
id='12321', user_keypair_id='keypair')
self._assert_check_scaling(
data={}, cluster=cluster,
expected_exception=ex.NotFoundException,
expected_message="Requested keypair 'keypair' not found")
image = mock.Mock()
m_image.return_value = image
image.list_registered.return_value = [mock.Mock(id='image1'),
mock.Mock(id='image2')]
cluster = tu.create_cluster(
"cluster1", "tenant1", "fake", "0.1", [ng1],
status=c_u.CLUSTER_STATUS_ACTIVE,
sahara_info={"infrastructure_engine": "heat.1.1"},
id='12321', default_image_id='image_id',
user_keypair_id='test_keypair')
self._assert_check_scaling(
data={}, cluster=cluster,
expected_message="Requested image 'image_id' is not registered")
示例2: test_validate
def test_validate(self):
plugin = p.IDHProvider()
ng_mng = tu.make_ng_dict('mng', 'f1', ['manager'], 1)
ng_nn = tu.make_ng_dict('nn', 'f1', ['namenode'], 1)
ng_rm = tu.make_ng_dict('rm', 'f1', ['resourcemanager'], 1)
ng_dn = tu.make_ng_dict('dn', 'f1', ['datanode'], 2)
ng_nm = tu.make_ng_dict('nm', 'f1', ['nodemanager'], 2)
cl = tu.create_cluster('cl1', 't1', 'intel', '3.0.2',
[ng_nn] + [ng_dn])
self.assertRaises(g_ex.InvalidComponentCountException,
plugin.validate, cl)
cl = tu.create_cluster('cl1', 't1', 'intel', '3.0.2', [ng_mng])
self.assertRaises(g_ex.InvalidComponentCountException,
plugin.validate, cl)
cl = tu.create_cluster('cl1', 't1', 'intel', '3.0.2',
[ng_mng] + [ng_nn] * 2)
self.assertRaises(g_ex.InvalidComponentCountException,
plugin.validate, cl)
cl = tu.create_cluster('cl1', 't1', 'intel', '3.0.2',
[ng_mng] + [ng_nn] + [ng_nm])
self.assertRaises(g_ex.RequiredServiceMissingException,
plugin.validate, cl)
cl = tu.create_cluster('cl1', 't1', 'intel', '3.0.2',
[ng_mng] + [ng_nn] + [ng_rm] * 2 + [ng_rm])
self.assertRaises(g_ex.InvalidComponentCountException,
plugin.validate, cl)
示例3: test_validate
def test_validate(self):
plugin = p.IDHProvider()
ng_mng = tu.make_ng_dict('mng', 'f1', ['manager'], 1)
ng_nn = tu.make_ng_dict('nn', 'f1', ['namenode'], 1)
ng_jt = tu.make_ng_dict('jt', 'f1', ['jobtracker'], 1)
ng_dn = tu.make_ng_dict('dn', 'f1', ['datanode'], 2)
ng_tt = tu.make_ng_dict('tt', 'f1', ['tasktracker'], 2)
cl = tu.create_cluster('cl1', 't1', 'intel', '2.5.1',
[ng_nn] + [ng_dn])
self.assertRaises(g_ex.InvalidComponentCountException,
plugin.validate, cl)
cl = tu.create_cluster('cl1', 't1', 'intel', '2.5.1', [ng_mng])
self.assertRaises(g_ex.InvalidComponentCountException,
plugin.validate, cl)
cl = tu.create_cluster('cl1', 't1', 'intel', '2.5.1',
[ng_mng] + [ng_nn] * 2)
self.assertRaises(g_ex.InvalidComponentCountException,
plugin.validate, cl)
cl = tu.create_cluster('cl1', 't1', 'intel', '2.5.1',
[ng_mng] + [ng_nn] + [ng_tt])
self.assertRaises(g_ex.RequiredServiceMissingException,
plugin.validate, cl)
cl = tu.create_cluster('cl1', 't1', 'intel', '2.5.1',
[ng_mng] + [ng_nn] + [ng_jt] * 2 + [ng_tt])
self.assertRaises(g_ex.InvalidComponentCountException,
plugin.validate, cl)
示例4: test_get_jobtracker
def test_get_jobtracker(self):
cl = tu.create_cluster('cl1', 't1', 'vanilla', '1.2.1',
[self.ng_manager, self.ng_jobtracker])
self.assertEqual('jt1', u.get_jobtracker(cl).instance_id)
cl = tu.create_cluster('cl1', 't1', 'vanilla', '1.2.1',
[self.ng_manager])
self.assertIsNone(u.get_jobtracker(cl))
示例5: test_get_oozie
def test_get_oozie(self):
cl = tu.create_cluster('cl1', 't1', 'vanilla', '2.7.1',
[self.ng_manager, self.ng_oozie])
self.assertEqual('ooz1', u.get_oozie(cl).instance_id)
cl = tu.create_cluster('cl1', 't1', 'vanilla', '2.7.1',
[self.ng_manager])
self.assertIsNone(u.get_oozie(cl))
示例6: test_get_namenode
def test_get_namenode(self):
cl = tu.create_cluster('cl1', 't1', 'vanilla', '2.6.0',
[self.ng_manager, self.ng_namenode])
self.assertEqual('nn1', u.get_namenode(cl).instance_id)
cl = tu.create_cluster('cl1', 't1', 'vanilla', '2.6.0',
[self.ng_manager])
self.assertIsNone(u.get_namenode(cl))
示例7: test_get_hiveserver
def test_get_hiveserver(self):
cl = tu.create_cluster('cl1', 't1', 'vanilla', '2.6.0',
[self.ng_manager, self.ng_hiveserver])
self.assertEqual('hs1', u.get_hiveserver(cl).instance_id)
cl = tu.create_cluster('cl1', 't1', 'vanilla', '2.6.0',
[self.ng_manager])
self.assertIsNone(u.get_hiveserver(cl))
示例8: test_get_secondarynamenodes
def test_get_secondarynamenodes(self):
cl = tu.create_cluster('cl1', 't1', 'vanilla', '2.6.0',
[self.ng_manager, self.ng_namenode,
self.ng_secondarynamenode])
self.assertEqual('snn1', u.get_secondarynamenode(cl).instance_id)
cl = tu.create_cluster('cl1', 't1', 'vanilla', '2.6.0',
[self.ng_manager])
self.assertEqual(None, u.get_secondarynamenode(cl))
示例9: test_get_tasktrackers
def test_get_tasktrackers(self):
cl = tu.create_cluster('cl1', 't1', 'vanilla', '1.2.1',
[self.ng_manager, self.ng_jobtracker,
self.ng_tasktracker])
tasktrackers = u.get_tasktrackers(cl)
self.assertEqual(2, len(tasktrackers))
self.assertEqual(set(['tt1', 'tt2']),
set([tasktrackers[0].instance_id,
tasktrackers[1].instance_id]))
cl = tu.create_cluster('cl1', 't1', 'vanilla', '1.2.1',
[self.ng_manager])
self.assertEqual([], u.get_tasktrackers(cl))
示例10: test_get_datanodes
def test_get_datanodes(self):
cl = tu.create_cluster('cl1', 't1', 'vanilla', '2.6.0',
[self.ng_manager, self.ng_namenode,
self.ng_datanode])
datanodes = u.get_datanodes(cl)
self.assertEqual(2, len(datanodes))
self.assertEqual(set(['dn1', 'dn2']),
set([datanodes[0].instance_id,
datanodes[1].instance_id]))
cl = tu.create_cluster('cl1', 't1', 'vanilla', '2.6.0',
[self.ng_manager])
self.assertEqual([], u.get_datanodes(cl))
示例11: _make_cluster
def _make_cluster(self, mng_network, ng1, ng2, anti_affinity=[]):
return tu.create_cluster("cluster", "tenant1", "general",
"2.6.0", [ng1, ng2],
user_keypair_id='user_key',
neutron_management_network=mng_network,
default_image_id='1', image_id=None,
anti_affinity=anti_affinity)
示例12: _get_context
def _get_context(self):
i1 = tu.make_inst_dict('id_1', 'instance_1', '1.1.1.1')
master_proc = [
yarn.RESOURCE_MANAGER.ui_name,
yarn.NODE_MANAGER.ui_name,
yarn.HISTORY_SERVER.ui_name,
maprfs.CLDB.ui_name,
maprfs.FILE_SERVER.ui_name,
oozie.OOZIE.ui_name,
management.ZOOKEEPER.ui_name,
]
master_ng = tu.make_ng_dict('master', 'large', master_proc, 1, [i1])
cluster_configs = {
'Service': {
'key': 'value',
'Service Version': '1.1',
},
}
cluster = tu.create_cluster(
name='test_cluster',
tenant='large',
plugin='mapr',
version='4.0.1.mrv1',
node_groups=[master_ng],
cluster_configs=cluster_configs,
)
self.ng = cluster.node_groups[0]
self.instance = self.ng.instances[0]
return cc.Context(cluster, handler.VersionHandler())
示例13: test_load_template_with_anti_affinity_single_ng
def test_load_template_with_anti_affinity_single_ng(self):
"""This test checks Heat cluster template with Neutron enabled
and anti-affinity feature enabled for single node process
in single node group.
"""
ng1 = tu.make_ng_dict('master', 42, ['namenode'], 1,
floating_ip_pool='floating', image_id=None,
volumes_per_node=0, volumes_size=0, id=1)
ng2 = tu.make_ng_dict('worker', 42, ['datanode'], 2,
floating_ip_pool='floating', image_id=None,
volumes_per_node=0, volumes_size=0, id=2)
cluster = tu.create_cluster("cluster", "tenant1", "general",
"1.2.1", [ng1, ng2],
user_keypair_id='user_key',
neutron_management_network='private_net',
default_image_id='1',
anti_affinity=['datanode'], image_id=None)
aa_heat_template = h.ClusterTemplate(cluster)
aa_heat_template.add_node_group_extra(ng1['id'], 1,
get_ud_generator('line1\nline2'))
aa_heat_template.add_node_group_extra(ng2['id'], 2,
get_ud_generator('line2\nline3'))
self.override_config("use_neutron", True)
main_template = h._load_template(
'main.heat', {'resources':
aa_heat_template._serialize_resources()})
self.assertEqual(
json.loads(main_template),
json.loads(f.get_file_text(
"tests/unit/resources/"
"test_serialize_resources_aa.heat")))
示例14: test_edp_main_class_spark
def test_edp_main_class_spark(self, job_get, cluster_get):
job_get.return_value = mock.Mock(type=edp.JOB_TYPE_SPARK,
interface=[])
ng = tu.make_ng_dict('master', 42, ['namenode'], 1,
instances=[tu.make_inst_dict('id', 'name')])
cluster_get.return_value = tu.create_cluster("cluster", "tenant1",
"spark", "1.0.0", [ng])
self._assert_create_object_validation(
data={
"cluster_id": six.text_type(uuid.uuid4()),
"job_configs": {"configs": {},
"params": {},
"args": []}
},
bad_req_i=(1, "INVALID_DATA",
"%s job must "
"specify edp.java.main_class" % edp.JOB_TYPE_SPARK))
self._assert_create_object_validation(
data={
"cluster_id": six.text_type(uuid.uuid4()),
"job_configs": {
"configs": {
"edp.java.main_class": "org.me.myclass"},
"params": {},
"args": []}
})
示例15: test_check_cluster_scaling_resize_ng
def test_check_cluster_scaling_resize_ng(self, ops):
ops.get_engine_type_and_version.return_value = "direct.1.1"
ng1 = tu.make_ng_dict('ng', '42', ['namenode'], 1)
cluster = tu.create_cluster("cluster1", "tenant1", "fake", "0.1",
[ng1],
status=c_u.CLUSTER_STATUS_VALIDATING,
id='12321')
self._assert_check_scaling(
data={}, cluster=cluster,
expected_message="Cluster cannot be scaled "
"not in '" + c_u.CLUSTER_STATUS_ACTIVE +
"' status. Cluster status: " +
c_u.CLUSTER_STATUS_VALIDATING)
cluster = tu.create_cluster("cluster1", "tenant1", "fake", "0.1",
[ng1], status=c_u.CLUSTER_STATUS_ACTIVE,
id='12321')
data = {
'resize_node_groups': [
{
'name': 'a',
'flavor_id': '42',
'node_processes': ['namenode']
}
],
}
self._assert_check_scaling(
data=data, cluster=cluster,
expected_message="Cluster doesn't contain "
"node group with name 'a'")
data.update({'resize_node_groups': [
{
'name': 'a',
'flavor_id': '42',
'node_processes': ['namenode']
},
{
'name': 'a',
'flavor_id': '42',
'node_processes': ['namenode']
}
]})
self._assert_check_scaling(
data=data, cluster=cluster,
expected_message=self.duplicates_detected,
expected_exception=ex.InvalidDataException)