class TestOSTFClient(base.BaseTestCase):
    def setUp(self):
        mock_keystone = mock.MagicMock()
        self.mock_request = mock_keystone.request
        with mock.patch('fuel_upgrade.clients.ostf_client.KeystoneClient',
                        return_value=mock_keystone):
            self.ostf = OSTFClient('127.0.0.1', 8777)

    def test_get(self):
        self.ostf.get('/some_path')
        self.mock_request.get.assert_called_once_with(
            'http://127.0.0.1:8777/some_path')
示例#2
0
class TestOSTFClient(base.BaseTestCase):

    def setUp(self):
        mock_keystone = mock.MagicMock()
        self.mock_request = mock_keystone.request
        with mock.patch(
                'fuel_upgrade.clients.ostf_client.KeystoneClient',
                return_value=mock_keystone):
            self.ostf = OSTFClient('127.0.0.1', 8777)

    def test_get(self):
        self.ostf.get('/some_path')
        self.mock_request.get.assert_called_once_with(
            'http://127.0.0.1:8777/some_path')
class CheckNoRunningOstf(BaseBeforeUpgradeChecker):
    """Checks that there's no running OSTF tasks.

    :param context: a context object with config and required space info
    """

    def __init__(self, context):
        self.ostf = OSTFClient(**context.config.endpoints['ostf'])

    def check(self):
        logger.info('Check OSTF tasks')

        try:
            tasks = self.ostf.get_tasks()
        except requests.ConnectionError:
            raise errors.OstfIsNotRunningError(
                'Cannot connect to OSTF service.')

        logger.debug('OSTF tasks: %s', tasks)

        running_tasks = filter(
            lambda t: t['status'] == 'running', tasks)

        if running_tasks:
            raise errors.CannotRunUpgrade(
                'Cannot run upgrade since there are OSTF running tasks.')
示例#4
0
 def setUp(self):
     mock_keystone = mock.MagicMock()
     self.mock_request = mock_keystone.request
     with mock.patch(
             'fuel_upgrade.clients.ostf_client.KeystoneClient',
             return_value=mock_keystone):
         self.ostf = OSTFClient('127.0.0.1', 8777)
示例#5
0
    def check(self):
        ostf_client = OSTFClient(**self.endpoints['ostf'])

        def get_request():
            resp = ostf_client.get('/')
            return resp.status_code

        code = self.make_safe_request(get_request)

        return code == 200
示例#6
0
class CheckNoRunningOstf(BaseBeforeUpgradeChecker):
    """Checks that there's no running OSTF tasks.

    :param context: a context object with config and required space info
    """
    def __init__(self, context):
        self.ostf = OSTFClient(**context.config.endpoints['ostf'])

    def check(self):
        logger.info('Check OSTF tasks')

        try:
            tasks = self.ostf.get_tasks()
        except requests.ConnectionError:
            raise errors.OstfIsNotRunningError(
                'Cannot connect to OSTF service.')

        logger.debug('OSTF tasks: %s', tasks)

        running_tasks = filter(lambda t: t['status'] == 'running', tasks)

        if running_tasks:
            raise errors.CannotRunUpgrade(
                'Cannot run upgrade since there are OSTF running tasks.')
示例#7
0
 def __init__(self, context):
     self.ostf = OSTFClient(**context.config.endpoints['ostf'])
 def __init__(self, context):
     self.ostf = OSTFClient(**context.config.endpoints['ostf'])
 def setUp(self):
     mock_keystone = mock.MagicMock()
     self.mock_request = mock_keystone.request
     with mock.patch('fuel_upgrade.clients.ostf_client.KeystoneClient',
                     return_value=mock_keystone):
         self.ostf = OSTFClient('127.0.0.1', 8777)