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 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.')
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 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
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.')
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)