• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python testutils.create_cluster函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sahara.tests.unit.testutils.create_cluster函数的典型用法代码示例。如果您正苦于以下问题:Python create_cluster函数的具体用法?Python create_cluster怎么用?Python create_cluster使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了create_cluster函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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")
开发者ID:openstack,项目名称:sahara,代码行数:31,代码来源:test_cluster_scaling_validation.py


示例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)
开发者ID:qinweiwei,项目名称:sahara,代码行数:32,代码来源:test_plugin_3_0_2.py


示例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)
开发者ID:qinweiwei,项目名称:sahara,代码行数:32,代码来源:test_plugin_2_5_1.py


示例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))
开发者ID:AlexanderYAPPO,项目名称:sahara,代码行数:8,代码来源:test_utils.py


示例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))
开发者ID:Imperat,项目名称:sahara,代码行数:8,代码来源:test_utils.py


示例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))
开发者ID:uladz,项目名称:sahara,代码行数:8,代码来源:test_utils.py


示例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))
开发者ID:uladz,项目名称:sahara,代码行数:8,代码来源:test_utils.py


示例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))
开发者ID:egafford,项目名称:sahara,代码行数:9,代码来源:test_utils.py


示例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))
开发者ID:AlexanderYAPPO,项目名称:sahara,代码行数:13,代码来源:test_utils.py


示例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))
开发者ID:uladz,项目名称:sahara,代码行数:13,代码来源:test_utils.py


示例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)
开发者ID:egafford,项目名称:sahara,代码行数:7,代码来源:test_templates.py


示例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())
开发者ID:AllenFromMinneapolis,项目名称:sahara,代码行数:29,代码来源:test_cluster_context.py


示例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")))
开发者ID:phamtruong91,项目名称:sahara,代码行数:34,代码来源:test_heat.py


示例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": []}
            })
开发者ID:rsaha,项目名称:sahara,代码行数:28,代码来源:test_job_executor.py


示例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)
开发者ID:Imperat,项目名称:sahara,代码行数:47,代码来源:test_cluster_scaling_validation.py


示例16: 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)
开发者ID:Imperat,项目名称:sahara,代码行数:59,代码来源:test_cluster_scaling_validation.py


示例17: _create_cluster

    def _create_cluster(self, *args, **kwargs):
        lst = []
        for i in range(0, len(args)):
            self.ng[i]['count'] = args[i]
            lst.append(self.ng[i])

        return tu.create_cluster("cluster1", "tenant1", "vanilla",
                                 "2.6.0", lst, **kwargs)
开发者ID:AlexanderYAPPO,项目名称:sahara,代码行数:8,代码来源:test_validation.py


示例18: get_fake_cluster_with_process

def get_fake_cluster_with_process(processes=None,
                                  provided_ng_list=None, **kwargs):
    processes = processes or {}
    provided_ng_list = provided_ng_list or []
    inst_counter = itertools.count(start=0)
    ng_counter = itertools.count(start=0)
    ng_id_counter = itertools.count(start=0)

    # default
    mng_ng = ('manager_ng', 1, ['CLOUDERA_MANAGER'], 1)

    mst_ng = ('master_ng', 1, ['HDFS_NAMENODE',
                               'HDFS_SECONDARYNAMENODE',
                               'YARN_RESOURCEMANAGER',
                               'YARN_JOBHISTORY',
                               ], 1)

    wkrs_ng = ('worker_ng', 1, ['HDFS_DATANODE',
                                'YARN_NODEMANAGER'], 3)

    basic_ng_list = [mng_ng, mst_ng, wkrs_ng]

    # if in default_ng_list, change it
    if 'CLOUDERA_MANAGER' in processes:
        if processes['CLOUDERA_MANAGER'] == 0:
            basic_ng_list.remove(mng_ng)
        else:
            processes['CLOUDERA_MANAGER'] -= 1

    for process in mst_ng[2]:
        if process in processes:
            if processes[process] == 0:
                mst_ng[2].remove(process)
            else:
                processes[process] -= 1

    # only consider processes set to 0
    for process in wkrs_ng[2]:
        if process in processes:
            if processes[process] == 0:
                wkrs_ng[2].remove(process)

    other_ng_list = []
    for process, count in six.iteritems(processes):
        if count:
            ng = ('service_ng{0}'.format(six.next(ng_counter)),
                  1, [process], count)
            other_ng_list.append(ng)

    ng_list = basic_ng_list + other_ng_list + provided_ng_list

    ng_dict_list = [make_ng_dict_with_inst(
        inst_counter, *args,
        id="ng_id{0}".format(six.next(ng_id_counter)))
        for args in ng_list]

    return tu.create_cluster('test_cluster', 1, 'cdh',
                             '5', ng_dict_list, **kwargs)
开发者ID:BruceZhou2012,项目名称:sahara,代码行数:58,代码来源:base_validation_tests.py


示例19: _validate_case

    def _validate_case(self, *args):
        lst = []
        for i in range(0, len(args)):
            self.ng[i]['count'] = args[i]
            lst.append(self.ng[i])

        cl = tu.create_cluster("cluster1", "tenant1", "vanilla", "1.2.1", lst)

        self.pl.validate(cl)
开发者ID:AspirinSJL,项目名称:sahara,代码行数:9,代码来源:test_plugin.py


示例20: test_check_heat_cluster_scaling_missing_engine

    def test_check_heat_cluster_scaling_missing_engine(self, engine_version):
        ng1 = tu.make_ng_dict('ng', '42', ['namenode'], 1)
        cluster = tu.create_cluster("cluster1", "tenant1", "vanilla", "1.2.1",
                                    [ng1], status='Active', id='12321')

        self._assert_check_scaling(
            data={}, cluster=cluster,
            expected_message="Cluster created before Juno release can't be "
                             "scaled with heat.1.1 engine")
开发者ID:a9261,项目名称:sahara,代码行数:9,代码来源:test_cluster_scaling_validation.py



注:本文中的sahara.tests.unit.testutils.create_cluster函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python testutils.make_inst_dict函数代码示例发布时间:2022-05-27
下一篇:
Python utils.stop_patch函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap