当前位置: 首页>>代码示例>>Python>>正文


Python utils.resource函数代码示例

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


在下文中一共展示了resource函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _test_retries_and_retry_interval_impl

 def _test_retries_and_retry_interval_impl(self,
                                           blueprint,
                                           retries,
                                           retry_interval,
                                           expected_interval,
                                           expected_retries,
                                           invocations_type,
                                           expect_failure=False,
                                           inputs=None):
     self.configure(retries=retries, retry_interval=retry_interval)
     deployment_id = str(uuid.uuid4())
     if expect_failure:
         with self.assertRaises(RuntimeError) as cm:
             deploy(
                 dsl_path=resource(blueprint),
                 deployment_id=deployment_id,
                 inputs=inputs)
         self.assertIn('Failing task on user defined exception',
                       str(cm.exception))
     else:
         deploy(resource(blueprint),
                deployment_id=deployment_id,
                inputs=inputs)
     invocations = self.get_plugin_data(
         plugin_name='testmockoperations',
         deployment_id=deployment_id
     )[invocations_type]
     self.assertEqual(expected_retries + 1, len(invocations))
     for i in range(len(invocations) - 1):
         self.assertLessEqual(expected_interval,
                              invocations[i+1] - invocations[i])
开发者ID:arcivanov,项目名称:cloudify-manager,代码行数:31,代码来源:test_task_retries.py

示例2: _test_retries_and_retry_interval_impl

 def _test_retries_and_retry_interval_impl(self,
                                           blueprint,
                                           retries,
                                           retry_interval,
                                           expected_interval,
                                           expected_retries,
                                           invocations_type,
                                           expect_failure=False):
     self.configure(retries=retries, retry_interval=retry_interval)
     deployment_id = str(uuid.uuid4())
     if expect_failure:
         self.assertRaises(RuntimeError, deploy,
                           dsl_path=resource(blueprint),
                           deployment_id=deployment_id)
     else:
         deploy(resource(blueprint),
                deployment_id=deployment_id)
     invocations = self.get_plugin_data(
         plugin_name='testmockoperations',
         deployment_id=deployment_id
     )[invocations_type]
     self.assertEqual(expected_retries + 1, len(invocations))
     for i in range(len(invocations) - 1):
         self.assertLessEqual(expected_interval,
                              invocations[i+1] - invocations[i])
开发者ID:filipposc5,项目名称:cloudify-manager,代码行数:25,代码来源:test_task_retries.py

示例3: _local_task_fail_impl

 def _local_task_fail_impl(self, wf_name):
     if self.do_get:
         deploy(resource('dsl/workflow_api.yaml'), wf_name,
                parameters={'do_get': self.do_get})
     else:
         self.assertRaises(RuntimeError,
                           deploy,
                           resource('dsl/workflow_api.yaml'),
                           wf_name,
                           parameters={'do_get': self.do_get})
开发者ID:filipposc5,项目名称:cloudify-manager,代码行数:10,代码来源:test_wf_api.py

示例4: test_workflow_deployment_scaling_groups

 def test_workflow_deployment_scaling_groups(self):
     deployment, _ = deploy(resource('dsl/store-scaling-groups.yaml'),
                            workflow_name='workflow')
     instance = self.client.node_instances.list(deployment.id)[0]
     self.assertEqual(
         ['node'],
         instance.runtime_properties['scaling_groups']['group1']['members'])
开发者ID:gvsurenderreddy,项目名称:cloudify-manager,代码行数:7,代码来源:test_wf_api.py

示例5: test_plugin_workdir

    def test_plugin_workdir(self):
        filename = 'test_plugin_workdir.txt'
        host_content = 'HOST_CONTENT'
        central_content = 'CENTRAL_CONTENT'

        dsl_path = resource("dsl/plugin_workdir.yaml")
        deployment, _ = deploy(dsl_path,
                               inputs={
                                   'filename': filename,
                                   'host_content': host_content,
                                   'central_content': central_content
                               })
        host_id = self.client.node_instances.list(node_id='host').items[0].id

        from testenv import testenv_instance
        test_workdir = testenv_instance.test_working_dir
        central_agent = CeleryWorkerProcess(['cloudify.management'],
                                            test_workdir)
        host_agent = CeleryWorkerProcess([host_id], test_workdir)

        central_file = os.path.join(
            central_agent.workdir, 'deployments', deployment.id, 'plugins',
            'testmockoperations', filename)
        host_file = os.path.join(
            host_agent.workdir, 'plugins', 'testmockoperations', filename)

        with open(central_file) as f:
            self.assertEqual(central_content, f.read())
        with open(host_file) as f:
            self.assertEqual(host_content, f.read())
开发者ID:01000101,项目名称:cloudify-manager,代码行数:30,代码来源:test_plugin_workdir.py

示例6: test_executions_sort

 def test_executions_sort(self):
     deployment = deploy(resource('dsl/sort.yaml'))
     for i in range(5):
         execute_workflow('install', deployment.id)
         execute_workflow('uninstall', deployment.id)
     self._test_sort('executions',
                     ['deployment_id', '-status'])
开发者ID:01000101,项目名称:cloudify-manager,代码行数:7,代码来源:test_rest_service_sort.py

示例7: test_cancel_on_wait_for_task_termination

 def test_cancel_on_wait_for_task_termination(self):
     _, eid = deploy(
         resource('dsl/workflow_api.yaml'), self._testMethodName,
         parameters={'do_get': self.do_get}, wait_for_execution=False)
     self.wait_for_execution_status(eid, status=Execution.STARTED)
     self.client.executions.cancel(eid)
     self.wait_for_execution_status(eid, status=Execution.CANCELLED)
开发者ID:filipposc5,项目名称:cloudify-manager,代码行数:7,代码来源:test_wf_api.py

示例8: test_deployment_logs

    def test_deployment_logs(self):
        message = 'TEST MESSAGE'
        inputs = {'message': message}

        dsl_path = resource("dsl/deployment_logs.yaml")
        deployment, _ = deploy(dsl_path, inputs=inputs)

        work_dir = testenv.testenv_instance.test_working_dir
        deployment_log_path = os.path.join(
            work_dir, 'cloudify.management', 'work', 'logs',
            '{0}.log'.format(deployment.id))

        def verify_logs_exist_with_content():
            print deployment_log_path
            self.assertTrue(os.path.isfile(deployment_log_path))
            with open(deployment_log_path) as f:
                self.assertIn(message, f.read())

        verify_logs_exist_with_content()

        undeploy(deployment.id, is_delete_deployment=True)

        # Verify log file id truncated on deployment delete
        with open(deployment_log_path) as f:
            self.assertTrue('' == f.read())

        deployment, _ = deploy(dsl_path, inputs=inputs,
                               deployment_id=deployment.id)

        # Verify new deployment with the same deployment id
        # can write to the previous location.
        verify_logs_exist_with_content()
开发者ID:01000101,项目名称:cloudify-manager,代码行数:32,代码来源:test_deployment_logs.py

示例9: _execute_and_cancel_execution

    def _execute_and_cancel_execution(self, workflow_id, force=False,
                                      wait_for_termination=True,
                                      is_wait_for_asleep_node=True):
        dsl_path = resource('dsl/sleep_workflows.yaml')
        _id = uuid.uuid1()
        blueprint_id = 'blueprint_{0}'.format(_id)
        deployment_id = 'deployment_{0}'.format(_id)
        self.client.blueprints.upload(dsl_path, blueprint_id)
        self.client.deployments.create(blueprint_id, deployment_id)
        do_retries(verify_deployment_environment_creation_complete, 30,
                   deployment_id=deployment_id)
        execution = self.client.executions.start(
            deployment_id, workflow_id)

        node_inst_id = self.client.node_instances.list(deployment_id)[0].id

        if is_wait_for_asleep_node:
            for retry in range(30):
                if self.client.node_instances.get(
                        node_inst_id).state == 'asleep':
                    break
                time.sleep(1)
            else:
                raise RuntimeError("Execution was expected to go"
                                   " into 'sleeping' status")

        execution = self.client.executions.cancel(execution.id, force)
        expected_status = Execution.FORCE_CANCELLING if force else \
            Execution.CANCELLING
        self.assertEquals(expected_status, execution.status)
        if wait_for_termination:
            wait_for_execution_to_end(execution)
            execution = self.client.executions.get(execution.id)
        return execution, deployment_id
开发者ID:filipposc5,项目名称:cloudify-manager,代码行数:34,代码来源:test_executions.py

示例10: test_post_source_started_location_target

 def test_post_source_started_location_target(self):
     dsl_path = resource(
         "dsl/relationship_interface_post_source_location_target.yaml")
     deployment, _ = deploy(dsl_path)
     self.verify_assertions(deployment.id,
                            hook='post-init',
                            runs_on_source=False)
开发者ID:01000101,项目名称:cloudify-manager,代码行数:7,代码来源:test_relationships.py

示例11: test_illegal_non_graph_to_graph_mode

 def test_illegal_non_graph_to_graph_mode(self):
     if not self.do_get:
         # no need to run twice
         return
     self.assertRaises(RuntimeError, deploy,
                       resource('dsl/workflow_api.yaml'),
                       self._testMethodName)
开发者ID:filipposc5,项目名称:cloudify-manager,代码行数:7,代码来源:test_wf_api.py

示例12: test_executions_pagination

 def test_executions_pagination(self):
     deployment = deploy(resource('dsl/pagination.yaml'))
     for i in range(5):
         execute_workflow('install', deployment.id)
         execute_workflow('uninstall', deployment.id)
     self._test_pagination(partial(self.client.executions.list,
                                   deployment_id=deployment.id))
开发者ID:Acidburn0zzz,项目名称:cloudify-manager,代码行数:7,代码来源:test_rest_service_pagination.py

示例13: test_delete_botched_deployment

    def test_delete_botched_deployment(self):

        from testenv import testenv_instance
        storage_file_path = os.path.join(
            testenv_instance.plugins_storage_dir,
            'agent.json'
        )

        dsl_path = resource('dsl/basic.yaml')
        _id = uuid.uuid1()
        blueprint_id = 'blueprint_{0}'.format(_id)
        deployment_id = 'deployment_{0}'.format(_id)

        data = {
            deployment_id: {'raise_exception_on_delete': True}
        }
        with open(storage_file_path, 'w') as f:
            json.dump(data, f)

        self.client.blueprints.upload(dsl_path, blueprint_id)
        self.client.deployments.create(blueprint_id, deployment_id)
        execution = \
            self.client.executions.list(deployment_id,
                                        include_system_workflows=True)[0]

        wait_for_execution_to_end(execution)
        self.client.deployments.delete(deployment_id)

        try:
            self.client.deployments.get(deployment_id)
            self.fail("Expected deployment to be deleted")
        except CloudifyClientError as e:
            self.assertEquals(404, e.status_code)
开发者ID:GigaSpaces-ProfessionalServices,项目名称:cloudify-manager,代码行数:33,代码来源:test_deployment_workflows.py

示例14: test_deploy_with_operation_executor_override

    def test_deploy_with_operation_executor_override(self):
        dsl_path = resource('dsl/operation_executor_override.yaml')
        deployment, _ = deploy(dsl_path)
        deployment_nodes = self.client.node_instances.list(
            deployment_id=deployment.id
        )

        webserver_nodes = filter(lambda node: 'host' not in node.node_id,
                                 deployment_nodes)
        self.assertEquals(1, len(webserver_nodes))
        webserver_node = webserver_nodes[0]
        start_invocation = self.get_plugin_data(
            plugin_name='target_aware_mock_plugin',
            deployment_id=deployment.id
        )[webserver_node.id]['start']

        expected_start_invocation = {'target': deployment.id}
        self.assertEqual(expected_start_invocation, start_invocation)

        plugin_installer_data = self.get_plugin_data(
            plugin_name='plugin_installer',
            deployment_id=deployment.id
        )

        deployment_operations_worker_name = deployment.id
        # target_aware_mock_plugin should have been installed
        # on the deployment worker as well because 'start'
        # overrides the executor
        self.assertEqual(
            plugin_installer_data[
                deployment_operations_worker_name
            ]['target_aware_mock_plugin'],
            ['installed'])
        undeploy(deployment_id=deployment.id)
开发者ID:nagyist,项目名称:cloudify-manager,代码行数:34,代码来源:test_workflow.py

示例15: test_pre_source_started_location_source

 def test_pre_source_started_location_source(self):
     dsl_path = resource(
         "dsl/relationship_interface_pre_source_location_source.yaml")
     deployment, _ = deploy(dsl_path)
     self.verify_assertions(deployment.id,
                            hook='pre-init',
                            runs_on_source=True)
开发者ID:01000101,项目名称:cloudify-manager,代码行数:7,代码来源:test_relationships.py


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