Merge "Require nova_client.api_version >= 2.56"

This commit is contained in:
Zuul
2019-05-27 03:01:47 +00:00
committed by Gerrit Code Review
7 changed files with 88 additions and 16 deletions

View File

@@ -15,8 +15,11 @@
from oslo_upgradecheck.upgradecheck import Code
from watcher.cmd import status
from watcher import conf
from watcher.tests import base
CONF = conf.CONF
class TestUpgradeChecks(base.TestCase):
@@ -24,7 +27,16 @@ class TestUpgradeChecks(base.TestCase):
super(TestUpgradeChecks, self).setUp()
self.cmd = status.Checks()
def test__sample_check(self):
check_result = self.cmd._sample_check()
self.assertEqual(
Code.SUCCESS, check_result.code)
def test_minimum_nova_api_version_ok(self):
# Tests that the default [nova_client]/api_version meets the minimum
# required version.
result = self.cmd._minimum_nova_api_version()
self.assertEqual(Code.SUCCESS, result.code)
def test_minimum_nova_api_version_fail(self):
# Tests the scenario that [nova_client]/api_version is less than the
# minimum required version.
CONF.set_override('api_version', '2.47', group='nova_client')
result = self.cmd._minimum_nova_api_version()
self.assertEqual(Code.FAILURE, result.code)
self.assertIn('Invalid nova_client.api_version 2.47.', result.details)

View File

@@ -26,6 +26,7 @@ from monascaclient.v2_0 import client as monclient_v2
from neutronclient.neutron import client as netclient
from neutronclient.v2_0 import client as netclient_v2
from novaclient import client as nvclient
import six
from watcher.common import clients
from watcher import conf
@@ -125,11 +126,20 @@ class TestClients(base.TestCase):
@mock.patch.object(clients.OpenStackClients, 'session')
def test_clients_nova_diff_vers(self, mock_session):
CONF.set_override('api_version', '2.3', group='nova_client')
CONF.set_override('api_version', '2.60', group='nova_client')
osc = clients.OpenStackClients()
osc._nova = None
osc.nova()
self.assertEqual('2.3', osc.nova().api_version.get_string())
self.assertEqual('2.60', osc.nova().api_version.get_string())
@mock.patch.object(clients.OpenStackClients, 'session')
def test_clients_nova_bad_min_version(self, mock_session):
CONF.set_override('api_version', '2.47', group='nova_client')
osc = clients.OpenStackClients()
osc._nova = None
ex = self.assertRaises(ValueError, osc.nova)
self.assertIn('Invalid nova_client.api_version 2.47',
six.text_type(ex))
@mock.patch.object(clients.OpenStackClients, 'session')
def test_clients_nova_diff_endpoint(self, mock_session):