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


Python OpenEdXInstanceFactory.provision方法代码示例

本文整理汇总了Python中instance.tests.models.factories.instance.OpenEdXInstanceFactory.provision方法的典型用法代码示例。如果您正苦于以下问题:Python OpenEdXInstanceFactory.provision方法的具体用法?Python OpenEdXInstanceFactory.provision怎么用?Python OpenEdXInstanceFactory.provision使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在instance.tests.models.factories.instance.OpenEdXInstanceFactory的用法示例。


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

示例1: test_provision_no_active

# 需要导入模块: from instance.tests.models.factories.instance import OpenEdXInstanceFactory [as 别名]
# 或者: from instance.tests.models.factories.instance.OpenEdXInstanceFactory import provision [as 别名]
    def test_provision_no_active(self, os_server_manager, mock_deploy, mock_set_dns_record,
                                 mock_server_reboot, mock_sleep, mock_update_status):
        """
        Run provisioning sequence, with status jumping from 'started' to 'booted' (no 'active')
        """
        mock_deploy.return_value = (['log'], 0)
        instance = OpenEdXInstanceFactory(sub_domain='run.provisioning.noactive')
        status_queue = [
            OpenStackServer.STARTED,
            OpenStackServer.BOOTED,
            OpenStackServer.BOOTED,
            OpenStackServer.PROVISIONING,
            OpenStackServer.REBOOTING,
            OpenStackServer.READY,
        ]
        status_queue.reverse() # To be able to use pop()

        def update_status(self, provisioning=False, rebooting=False, failed=None):
            """ Simulate status progression successive runs """
            self.status = status_queue.pop()
            self.progress = self.PROGRESS_SUCCESS
        mock_update_status.side_effect = update_status

        with patch('instance.models.server.OpenStackServer.start'):
            instance.provision()
        self.assertEqual(mock_deploy.call_count, 1)
开发者ID:omarkhan,项目名称:opencraft,代码行数:28,代码来源:test_instance.py

示例2: test_provision_with_external_databases

# 需要导入模块: from instance.tests.models.factories.instance import OpenEdXInstanceFactory [as 别名]
# 或者: from instance.tests.models.factories.instance.OpenEdXInstanceFactory import provision [as 别名]
    def test_provision_with_external_databases(self, mocks):
        """
        Run provisioning sequence, with external databases
        """
        mocks.mock_create_server.side_effect = [Mock(id='test-run-provisioning-server'), None]
        mocks.os_server_manager.add_fixture('test-run-provisioning-server', 'openstack/api_server_2_active.json')

        instance = OpenEdXInstanceFactory(sub_domain='run.provisioning', use_ephemeral_databases=False)

        def deploy():
            """
            Make sure that ansible settings are present at deploy time
            """
            ansible_settings = yaml.load(instance.ansible_settings)
            for setting in ('EDXAPP_MYSQL_USER', 'EDXAPP_MONGO_PASSWORD',
                            'EDXAPP_MONGO_USER', 'EDXAPP_MONGO_PASSWORD',
                            'EDXAPP_SWIFT_USERNAME', 'EDXAPP_SWIFT_KEY'):
                self.assertTrue(ansible_settings[setting])
            return (['log'], 0)

        mocks.mock_deploy.side_effect = deploy
        instance.provision()
        self.assertEqual(mocks.mock_provision_mysql.call_count, 1)
        self.assertEqual(mocks.mock_provision_mongo.call_count, 1)
        self.assertEqual(mocks.mock_provision_swift.call_count, 1)
开发者ID:antoviaque,项目名称:opencraft,代码行数:27,代码来源:test_instance.py

示例3: test_provision_unhandled_exception

# 需要导入模块: from instance.tests.models.factories.instance import OpenEdXInstanceFactory [as 别名]
# 或者: from instance.tests.models.factories.instance.OpenEdXInstanceFactory import provision [as 别名]
    def test_provision_unhandled_exception(self, mocks):
        """
        Make sure that all servers are terminated if there is an unhandled exception during
        provisioning.
        """
        mocks.mock_set_dns_record.side_effect = Exception('Something went catastrophically wrong')
        instance = OpenEdXInstanceFactory(sub_domain='run.provisioning')
        with self.assertRaisesRegex(Exception, 'Something went catastrophically wrong'):
            instance.provision()
        self.assertFalse(instance.server_set.exclude_terminated())

        mocks.mock_provision_failed_email.assert_called_once_with(instance.ProvisionMessages.PROVISION_EXCEPTION)
开发者ID:antoviaque,项目名称:opencraft,代码行数:14,代码来源:test_instance.py

示例4: test_provision

# 需要导入模块: from instance.tests.models.factories.instance import OpenEdXInstanceFactory [as 别名]
# 或者: from instance.tests.models.factories.instance.OpenEdXInstanceFactory import provision [as 别名]
    def test_provision(self, os_server_manager, mock_run_playbook, mock_set_dns_record, mock_server_reboot,
                       mock_sleep_until_status, mock_update_status, mock_openstack_create_server):
        """
        Run provisioning sequence
        """
        mock_openstack_create_server.return_value.id = 'test-run-provisioning-server'
        os_server_manager.add_fixture('test-run-provisioning-server', 'openstack/api_server_2_active.json')

        instance = OpenEdXInstanceFactory(sub_domain='run.provisioning')
        instance.provision()
        self.assertEqual(mock_set_dns_record.mock_calls, [
            call(name='run.provisioning', type='A', value='192.168.100.200'),
            call(name='studio.run.provisioning', type='CNAME', value='run.provisioning'),
        ])
        self.assertEqual(mock_run_playbook.call_count, 1)
        self.assertEqual(mock_server_reboot.call_count, 1)
开发者ID:regisb,项目名称:opencraft,代码行数:18,代码来源:test_instance.py

示例5: test_provision

# 需要导入模块: from instance.tests.models.factories.instance import OpenEdXInstanceFactory [as 别名]
# 或者: from instance.tests.models.factories.instance.OpenEdXInstanceFactory import provision [as 别名]
    def test_provision(self, mocks):
        """
        Run provisioning sequence
        """
        mocks.mock_deploy.return_value = (['log'], 0)
        mocks.mock_create_server.side_effect = [Mock(id='test-run-provisioning-server'), None]
        mocks.os_server_manager.add_fixture('test-run-provisioning-server', 'openstack/api_server_2_active.json')
        mock_reboot = mocks.os_server_manager.get_os_server('test-run-provisioning-server').reboot

        instance = OpenEdXInstanceFactory(sub_domain='run.provisioning', use_ephemeral_databases=True)
        instance.provision()
        self.assertEqual(mocks.mock_set_dns_record.mock_calls, [
            call(name='run.provisioning', type='A', value='192.168.100.200'),
            call(name='studio.run.provisioning', type='CNAME', value='run.provisioning'),
        ])
        self.assertEqual(mocks.mock_deploy.call_count, 1)
        self.assertEqual(mock_reboot.call_count, 1)
        self.assertEqual(mocks.mock_provision_mysql.call_count, 0)
        self.assertEqual(mocks.mock_provision_mongo.call_count, 0)
        self.assertEqual(mocks.mock_provision_swift.call_count, 0)
开发者ID:antoviaque,项目名称:opencraft,代码行数:22,代码来源:test_instance.py

示例6: test_provision_failed

# 需要导入模块: from instance.tests.models.factories.instance import OpenEdXInstanceFactory [as 别名]
# 或者: from instance.tests.models.factories.instance.OpenEdXInstanceFactory import provision [as 别名]
    def test_provision_failed(self, mocks):
        """
        Run provisioning sequence failing the deployment on purpose to make sure the
        server status will be set accordingly.
        """
        log_lines = ['log']
        mocks.mock_deploy.return_value = (log_lines, 1)
        instance = OpenEdXInstanceFactory(sub_domain='run.provisioning')

        server = instance.provision()[0]
        self.assertEqual(server.status, Server.Status.Provisioning)
        self.assertEqual(server.progress, Server.Progress.Failed)
        mocks.mock_provision_failed_email.assert_called_once_with(instance.ProvisionMessages.PROVISION_ERROR, log_lines)
        mocks.mock_provision_failed_email.assert_called_once_with(instance.ProvisionMessages.PROVISION_ERROR, log_lines)
开发者ID:antoviaque,项目名称:opencraft,代码行数:16,代码来源:test_instance.py

示例7: test_provision_failed

# 需要导入模块: from instance.tests.models.factories.instance import OpenEdXInstanceFactory [as 别名]
# 或者: from instance.tests.models.factories.instance.OpenEdXInstanceFactory import provision [as 别名]
    def test_provision_failed(self, os_server_manager, mock_deploy, mock_set_dns_record,
                              mock_server_start, mock_os_server, mock_sleep_until_status):
        """
        Run provisioning sequence failing the deployment on purpose to make sure the
        server status will be set accordingly.
        """
        mock_deploy.return_value = (['log'], 1)
        instance = OpenEdXInstanceFactory(sub_domain='run.provisioning')

        def server_start(self):
            """
            Make sure we get the server in the BOOTED state when it is started
            """
            self.status = Server.BOOTED
            self.progress = Server.PROGRESS_SUCCESS
        mock_server_start.side_effect = server_start

        server = instance.provision()[0]
        self.assertEqual(server.status, Server.PROVISIONING)
        self.assertEqual(server.progress, Server.PROGRESS_FAILED)
开发者ID:omarkhan,项目名称:opencraft,代码行数:22,代码来源:test_instance.py


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