本文整理汇总了Python中sahara.tests.unit.testutils.make_ng_dict函数的典型用法代码示例。如果您正苦于以下问题:Python make_ng_dict函数的具体用法?Python make_ng_dict怎么用?Python make_ng_dict使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_ng_dict函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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)
示例2: 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")))
示例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: _make_node_groups
def _make_node_groups(self, floating_ip_pool=None):
ng1 = tu.make_ng_dict('master', 42, ['namenode'], 1,
floating_ip_pool=floating_ip_pool, image_id=None,
volumes_per_node=0, volumes_size=0, id=1)
ng2 = tu.make_ng_dict('worker', 42, ['datanode'], 1,
floating_ip_pool=floating_ip_pool, image_id=None,
volumes_per_node=2, volumes_size=10, id=2)
return ng1, ng2
示例5: _make_node_groups
def _make_node_groups(self, floating_ip_pool=None, volume_type=None):
ng1 = tu.make_ng_dict('master', 42, ['namenode'], 1,
floating_ip_pool=floating_ip_pool, image_id=None,
volumes_per_node=0, volumes_size=0, id="1",
image_username='root', volume_type=None)
ng2 = tu.make_ng_dict('worker', 42, ['datanode'], 1,
floating_ip_pool=floating_ip_pool, image_id=None,
volumes_per_node=2, volumes_size=10, id="2",
image_username='root', volume_type=volume_type)
return ng1, ng2
示例6: test_load_template_with_anti_affinity_single_ng
def test_load_template_with_anti_affinity_single_ng(self):
"""Checks Heat cluster template with Neutron enabled.
Checks also 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")),
)
示例7: test_load_template_use_neutron
def test_load_template_use_neutron(self):
"""This test checks Heat cluster template with Neutron enabled.
Two NodeGroups used: 'master' with Ephemeral drive attached and
'worker' with 2 attached volumes 10GB size each
"""
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"],
1,
floating_ip_pool="floating",
image_id=None,
volumes_per_node=2,
volumes_size=10,
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=[],
image_id=None,
)
heat_template = h.ClusterTemplate(cluster)
heat_template.add_node_group_extra(ng1["id"], 1, get_ud_generator("line1\nline2"))
heat_template.add_node_group_extra(ng2["id"], 1, get_ud_generator("line2\nline3"))
self.override_config("use_neutron", True)
main_template = h._load_template("main.heat", {"resources": heat_template._serialize_resources()})
self.assertEqual(
json.loads(main_template),
json.loads(f.get_file_text("tests/unit/resources/" "test_serialize_resources_use_neutron.heat")),
)
示例8: setUp
def setUp(self):
super(TestUtils, self).setUp()
self.plugin = p.VanillaProvider()
self.ng_manager = tu.make_ng_dict(
'mng', 'f1', ['manager'], 1,
[tu.make_inst_dict('mng1', 'manager')])
self.ng_namenode = tu.make_ng_dict(
'nn', 'f1', ['namenode'], 1,
[tu.make_inst_dict('nn1', 'namenode')])
self.ng_resourcemanager = tu.make_ng_dict(
'jt', 'f1', ['resourcemanager'], 1,
[tu.make_inst_dict('jt1', 'resourcemanager')])
self.ng_datanode = tu.make_ng_dict(
'dn', 'f1', ['datanode'], 2,
[tu.make_inst_dict('dn1', 'datanode-1'),
tu.make_inst_dict('dn2', 'datanode-2')])
self.ng_nodemanager = tu.make_ng_dict(
'tt', 'f1', ['nodemanager'], 2,
[tu.make_inst_dict('tt1', 'nodemanager-1'),
tu.make_inst_dict('tt2', 'nodemanager-2')])
self.ng_oozie = tu.make_ng_dict(
'ooz1', 'f1', ['oozie'], 1,
[tu.make_inst_dict('ooz1', 'oozie')])
self.ng_hiveserver = tu.make_ng_dict(
'hs', 'f1', ['hiveserver'], 1,
[tu.make_inst_dict('hs1', 'hiveserver')])
self.ng_secondarynamenode = tu.make_ng_dict(
'snn', 'f1', ['secondarynamenode'], 1,
[tu.make_inst_dict('snn1', 'secondarynamenode')])
示例9: get_fake_cluster
def get_fake_cluster(**kwargs):
mng = tu.make_inst_dict('id1', 'manager_inst', management_ip='1.2.3.4')
mng_ng = tu.make_ng_dict('manager_ng', 1, ['MANAGER'], 1, [mng])
mst = tu.make_inst_dict('id2', 'master_inst', management_ip='1.2.3.5')
mst_ng = tu.make_ng_dict('master_ng', 1, ['NAMENODE', 'SECONDARYNAMENODE',
'RESOURCEMANAGER', 'JOBHISTORY',
'OOZIE_SERVER'], 1, [mst])
wkrs = _get_workers()
wkrs_ng = tu.make_ng_dict('worker_ng', 1, ['DATANODE', 'NODEMANAGER'],
len(wkrs), wkrs)
return tu.create_cluster('test_cluster', 1, 'cdh', '5',
[mng_ng, mst_ng, wkrs_ng],
**kwargs)
示例10: 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": []}
})
示例11: test_get_hadoop_ssh_keys
def test_get_hadoop_ssh_keys(self):
cluster_dict = {
'name': 'cluster1',
'plugin_name': 'mock_plugin',
'hadoop_version': 'mock_version',
'default_image_id': 'initial',
'node_groups': [tu.make_ng_dict("ng1", "f1", ["s1"], 1)]}
cluster1 = conductor.cluster_create(context.ctx(), cluster_dict)
(private_key1, public_key1) = c_h.get_hadoop_ssh_keys(cluster1)
#should store keys for old cluster
cluster1 = conductor.cluster_get(context.ctx(), cluster1)
(private_key2, public_key2) = c_h.get_hadoop_ssh_keys(cluster1)
self.assertEqual(public_key1, public_key2)
self.assertEqual(private_key1, private_key2)
#should generate new keys for new cluster
cluster_dict.update({'name': 'cluster2'})
cluster2 = conductor.cluster_create(context.ctx(), cluster_dict)
(private_key3, public_key3) = c_h.get_hadoop_ssh_keys(cluster2)
self.assertNotEqual(public_key1, public_key3)
self.assertNotEqual(private_key1, private_key3)
示例12: 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")
示例13: _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())
示例14: test_check_cluster_scaling_add_ng
def test_check_cluster_scaling_add_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("test-cluster", "tenant1", "fake",
"0.1",
[ng1], status=c_u.CLUSTER_STATUS_ACTIVE,
id='12321')
data = {
'add_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)
data = {
'add_node_groups': [
{
'name': 'ng',
'flavor_id': '42',
'node_processes': ['namenode']
},
]
}
self._assert_check_scaling(
data=data, cluster=cluster,
expected_message="Can't add new nodegroup. "
"Cluster already has nodegroup "
"with name 'ng'")
data = {
'add_node_groups': [
{
'name': 'very-very-very-very-very-very-long-ng-name',
'flavor_id': '42',
'node_processes': ['namenode'],
'count': 10
},
]
}
patchers = u.start_patch()
self._assert_check_scaling(
data=data, cluster=cluster,
expected_message="Composite hostname test-cluster-very-"
"very-very-very-very-very-long-ng-name-"
"010.novalocal in provisioned cluster exceeds "
"maximum limit 64 characters",
expected_exception=ex.InvalidDataException)
u.stop_patch(patchers)
示例15: setUp
def setUp(self):
super(GeneralUtilsTest, self).setUp()
i1 = tu.make_inst_dict("i1", "master")
i2 = tu.make_inst_dict("i2", "worker1")
i3 = tu.make_inst_dict("i3", "worker2")
i4 = tu.make_inst_dict("i4", "worker3")
i5 = tu.make_inst_dict("i5", "sn")
ng1 = tu.make_ng_dict("master", "f1", ["jt", "nn"], 1, [i1])
ng2 = tu.make_ng_dict("workers", "f1", ["tt", "dn"], 3, [i2, i3, i4])
ng3 = tu.make_ng_dict("sn", "f1", ["dn"], 1, [i5])
self.c1 = tu.create_cluster("cluster1", "tenant1", "general", "2.6.0", [ng1, ng2, ng3])
self.ng1 = self.c1.node_groups[0]
self.ng2 = self.c1.node_groups[1]
self.ng3 = self.c1.node_groups[2]