Merge "Merge V2 and V2.1 services functional tests"
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
{
|
||||
"services": [
|
||||
{
|
||||
"id": 1,
|
||||
"binary": "nova-scheduler",
|
||||
"host": "host1",
|
||||
"state": "up",
|
||||
"status": "disabled",
|
||||
"updated_at": "2012-10-29T13:42:02.000000",
|
||||
"zone": "internal"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"binary": "nova-compute",
|
||||
"host": "host1",
|
||||
"state": "up",
|
||||
"status": "disabled",
|
||||
"updated_at": "2012-10-29T13:42:05.000000",
|
||||
"zone": "nova"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"binary": "nova-scheduler",
|
||||
"host": "host2",
|
||||
"state": "down",
|
||||
"status": "enabled",
|
||||
"updated_at": "2012-09-19T06:55:34.000000",
|
||||
"zone": "internal"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"binary": "nova-compute",
|
||||
"host": "host2",
|
||||
"state": "down",
|
||||
"status": "disabled",
|
||||
"updated_at": "2012-09-18T08:03:38.000000",
|
||||
"zone": "nova"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"host": "host1",
|
||||
"binary": "nova-compute",
|
||||
"disabled_reason": "test2"
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"service": {
|
||||
"binary": "nova-compute",
|
||||
"host": "host1",
|
||||
"disabled_reason": "test2",
|
||||
"status": "disabled"
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"host": "host1",
|
||||
"binary": "nova-compute"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"service": {
|
||||
"host": "host1",
|
||||
"binary": "nova-compute",
|
||||
"status": "disabled"
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"host": "host1",
|
||||
"binary": "nova-compute"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"service": {
|
||||
"host": "host1",
|
||||
"binary": "nova-compute",
|
||||
"status": "enabled"
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
{
|
||||
"services": [
|
||||
{
|
||||
"binary": "nova-scheduler",
|
||||
"host": "host1",
|
||||
"state": "up",
|
||||
"status": "disabled",
|
||||
"updated_at": "2012-10-29T13:42:02.000000",
|
||||
"zone": "internal",
|
||||
"disabled_reason": "test1"
|
||||
},
|
||||
{
|
||||
"binary": "nova-compute",
|
||||
"host": "host1",
|
||||
"state": "up",
|
||||
"status": "disabled",
|
||||
"updated_at": "2012-10-29T13:42:05.000000",
|
||||
"zone": "nova",
|
||||
"disabled_reason": "test2"
|
||||
},
|
||||
{
|
||||
"binary": "nova-scheduler",
|
||||
"host": "host2",
|
||||
"state": "down",
|
||||
"status": "enabled",
|
||||
"updated_at": "2012-09-19T06:55:34.000000",
|
||||
"zone": "internal",
|
||||
"disabled_reason": null
|
||||
},
|
||||
{
|
||||
"binary": "nova-compute",
|
||||
"host": "host2",
|
||||
"state": "down",
|
||||
"status": "disabled",
|
||||
"updated_at": "2012-09-18T08:03:38.000000",
|
||||
"zone": "nova",
|
||||
"disabled_reason": "test4"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
{
|
||||
"services": [
|
||||
{
|
||||
"binary": "nova-scheduler",
|
||||
"host": "host1",
|
||||
"state": "up",
|
||||
"status": "disabled",
|
||||
"updated_at": "2012-10-29T13:42:02.000000",
|
||||
"zone": "internal"
|
||||
},
|
||||
{
|
||||
"binary": "nova-compute",
|
||||
"host": "host1",
|
||||
"state": "up",
|
||||
"status": "disabled",
|
||||
"updated_at": "2012-10-29T13:42:05.000000",
|
||||
"zone": "nova"
|
||||
},
|
||||
{
|
||||
"binary": "nova-scheduler",
|
||||
"host": "host2",
|
||||
"state": "down",
|
||||
"status": "enabled",
|
||||
"updated_at": "2012-09-19T06:55:34.000000",
|
||||
"zone": "internal"
|
||||
},
|
||||
{
|
||||
"binary": "nova-compute",
|
||||
"host": "host2",
|
||||
"state": "down",
|
||||
"status": "disabled",
|
||||
"updated_at": "2012-09-18T08:03:38.000000",
|
||||
"zone": "nova"
|
||||
}
|
||||
]
|
||||
}
|
||||
-40
@@ -1,40 +0,0 @@
|
||||
{
|
||||
"services": [
|
||||
{
|
||||
"id": 1,
|
||||
"binary": "nova-scheduler",
|
||||
"host": "host1",
|
||||
"state": "up",
|
||||
"status": "disabled",
|
||||
"updated_at": "%(strtime)s",
|
||||
"zone": "internal"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"binary": "nova-compute",
|
||||
"host": "host1",
|
||||
"state": "up",
|
||||
"status": "disabled",
|
||||
"updated_at": "%(strtime)s",
|
||||
"zone": "nova"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"binary": "nova-scheduler",
|
||||
"host": "host2",
|
||||
"state": "down",
|
||||
"status": "enabled",
|
||||
"updated_at": "%(strtime)s",
|
||||
"zone": "internal"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"binary": "nova-compute",
|
||||
"host": "host2",
|
||||
"state": "down",
|
||||
"status": "disabled",
|
||||
"updated_at": "%(strtime)s",
|
||||
"zone": "nova"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"host": "%(host)s",
|
||||
"binary": "%(binary)s",
|
||||
"disabled_reason": "%(disabled_reason)s"
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"service": {
|
||||
"binary": "%(binary)s",
|
||||
"host": "%(host)s",
|
||||
"disabled_reason": "%(disabled_reason)s",
|
||||
"status": "disabled"
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"host": "%(host)s",
|
||||
"binary": "%(binary)s"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"service": {
|
||||
"host": "%(host)s",
|
||||
"binary": "%(binary)s",
|
||||
"status": "disabled"
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"host": "%(host)s",
|
||||
"binary": "%(binary)s"
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"service": {
|
||||
"host": "%(host)s",
|
||||
"binary": "%(binary)s",
|
||||
"status": "enabled"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
{
|
||||
"services": [
|
||||
{
|
||||
"binary": "nova-scheduler",
|
||||
"host": "host1",
|
||||
"disabled_reason": "test1",
|
||||
"state": "up",
|
||||
"status": "disabled",
|
||||
"updated_at": "%(strtime)s",
|
||||
"zone": "internal"
|
||||
},
|
||||
{
|
||||
"binary": "nova-compute",
|
||||
"host": "host1",
|
||||
"disabled_reason": "test2",
|
||||
"state": "up",
|
||||
"status": "disabled",
|
||||
"updated_at": "%(strtime)s",
|
||||
"zone": "nova"
|
||||
},
|
||||
{
|
||||
"binary": "nova-scheduler",
|
||||
"host": "host2",
|
||||
"disabled_reason": null,
|
||||
"state": "down",
|
||||
"status": "enabled",
|
||||
"updated_at": "%(strtime)s",
|
||||
"zone": "internal"
|
||||
},
|
||||
{
|
||||
"binary": "nova-compute",
|
||||
"host": "host2",
|
||||
"disabled_reason": "test4",
|
||||
"state": "down",
|
||||
"status": "disabled",
|
||||
"updated_at": "%(strtime)s",
|
||||
"zone": "nova"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
{
|
||||
"services": [
|
||||
{
|
||||
"binary": "nova-scheduler",
|
||||
"host": "host1",
|
||||
"state": "up",
|
||||
"status": "disabled",
|
||||
"updated_at": "%(strtime)s",
|
||||
"zone": "internal"
|
||||
},
|
||||
{
|
||||
"binary": "nova-compute",
|
||||
"host": "host1",
|
||||
"state": "up",
|
||||
"status": "disabled",
|
||||
"updated_at": "%(strtime)s",
|
||||
"zone": "nova"
|
||||
},
|
||||
{
|
||||
"binary": "nova-scheduler",
|
||||
"host": "host2",
|
||||
"state": "down",
|
||||
"status": "enabled",
|
||||
"updated_at": "%(strtime)s",
|
||||
"zone": "internal"
|
||||
},
|
||||
{
|
||||
"binary": "nova-compute",
|
||||
"host": "host2",
|
||||
"state": "down",
|
||||
"status": "disabled",
|
||||
"updated_at": "%(strtime)s",
|
||||
"zone": "nova"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -47,7 +47,6 @@ from nova import test
|
||||
from nova.tests.functional import api_samples_test_base
|
||||
from nova.tests.functional import integrated_helpers
|
||||
from nova.tests.unit.api.openstack.compute.contrib import test_fping
|
||||
from nova.tests.unit.api.openstack.compute.contrib import test_services
|
||||
from nova.tests.unit.api.openstack import fakes
|
||||
from nova.tests.unit import fake_network
|
||||
from nova.tests.unit import fake_utils
|
||||
@@ -608,139 +607,6 @@ class UsedLimitsForAdminSamplesJsonTest(ApiSampleTestBaseV2):
|
||||
response, 200)
|
||||
|
||||
|
||||
class ServicesJsonTest(ApiSampleTestBaseV2):
|
||||
extension_name = "nova.api.openstack.compute.contrib.services.Services"
|
||||
ADMIN_API = True
|
||||
|
||||
def setUp(self):
|
||||
super(ServicesJsonTest, self).setUp()
|
||||
self.stubs.Set(db, "service_get_all",
|
||||
test_services.fake_db_api_service_get_all)
|
||||
self.stubs.Set(timeutils, "utcnow", test_services.fake_utcnow)
|
||||
self.stubs.Set(timeutils, "utcnow_ts", test_services.fake_utcnow_ts)
|
||||
self.stubs.Set(db, "service_get_by_host_and_binary",
|
||||
test_services.fake_service_get_by_host_binary)
|
||||
self.stubs.Set(db, "service_update",
|
||||
test_services.fake_service_update)
|
||||
|
||||
def tearDown(self):
|
||||
super(ServicesJsonTest, self).tearDown()
|
||||
timeutils.clear_time_override()
|
||||
|
||||
def fake_load(self, service_name):
|
||||
return service_name == 'os-extended-services'
|
||||
|
||||
def test_services_list(self):
|
||||
"""Return a list of all agent builds."""
|
||||
response = self._do_get('os-services')
|
||||
subs = {'binary': 'nova-compute',
|
||||
'host': 'host1',
|
||||
'zone': 'nova',
|
||||
'status': 'disabled',
|
||||
'state': 'up'}
|
||||
subs.update(self._get_regexes())
|
||||
self._verify_response('services-list-get-resp', subs, response, 200)
|
||||
|
||||
def test_service_enable(self):
|
||||
"""Enable an existing agent build."""
|
||||
subs = {"host": "host1",
|
||||
'binary': 'nova-compute'}
|
||||
response = self._do_put('os-services/enable',
|
||||
'service-enable-put-req', subs)
|
||||
subs = {"host": "host1",
|
||||
"binary": "nova-compute"}
|
||||
self._verify_response('service-enable-put-resp', subs, response, 200)
|
||||
|
||||
def test_service_disable(self):
|
||||
"""Disable an existing agent build."""
|
||||
subs = {"host": "host1",
|
||||
'binary': 'nova-compute'}
|
||||
response = self._do_put('os-services/disable',
|
||||
'service-disable-put-req', subs)
|
||||
subs = {"host": "host1",
|
||||
"binary": "nova-compute"}
|
||||
self._verify_response('service-disable-put-resp', subs, response, 200)
|
||||
|
||||
def test_service_detail(self):
|
||||
"""Return a list of all running services with the disable reason
|
||||
information if that exists.
|
||||
"""
|
||||
self.stubs.Set(extensions.ExtensionManager, "is_loaded",
|
||||
self.fake_load)
|
||||
response = self._do_get('os-services')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
subs = {'binary': 'nova-compute',
|
||||
'host': 'host1',
|
||||
'zone': 'nova',
|
||||
'status': 'disabled',
|
||||
'state': 'up'}
|
||||
subs.update(self._get_regexes())
|
||||
self._verify_response('services-get-resp',
|
||||
subs, response, 200)
|
||||
|
||||
def test_service_disable_log_reason(self):
|
||||
"""Disable an existing service and log the reason."""
|
||||
self.stubs.Set(extensions.ExtensionManager, "is_loaded",
|
||||
self.fake_load)
|
||||
subs = {"host": "host1",
|
||||
'binary': 'nova-compute',
|
||||
'disabled_reason': 'test2'}
|
||||
response = self._do_put('os-services/disable-log-reason',
|
||||
'service-disable-log-put-req', subs)
|
||||
return self._verify_response('service-disable-log-put-resp',
|
||||
subs, response, 200)
|
||||
|
||||
|
||||
class ExtendedServicesJsonTest(ApiSampleTestBaseV2):
|
||||
"""This extension is extending the functionalities of the
|
||||
Services extension so the funcionalities introduced by this extension
|
||||
are tested in the ServicesJsonTest and ServicesXmlTest classes.
|
||||
"""
|
||||
ADMIN_API = True
|
||||
extension_name = ("nova.api.openstack.compute.contrib."
|
||||
"extended_services.Extended_services")
|
||||
|
||||
|
||||
@mock.patch.object(db, 'service_get_all',
|
||||
side_effect=test_services.fake_db_api_service_get_all)
|
||||
@mock.patch.object(db, 'service_get_by_host_and_binary',
|
||||
side_effect=test_services.fake_service_get_by_host_binary)
|
||||
class ExtendedServicesDeleteJsonTest(ApiSampleTestBaseV2):
|
||||
ADMIN_API = True
|
||||
extends_name = ("nova.api.openstack.compute.contrib.services.Services")
|
||||
extension_name = ("nova.api.openstack.compute.contrib."
|
||||
"extended_services_delete.Extended_services_delete")
|
||||
|
||||
def setUp(self):
|
||||
super(ExtendedServicesDeleteJsonTest, self).setUp()
|
||||
timeutils.set_time_override(test_services.fake_utcnow())
|
||||
|
||||
def tearDown(self):
|
||||
super(ExtendedServicesDeleteJsonTest, self).tearDown()
|
||||
timeutils.clear_time_override()
|
||||
|
||||
def test_service_detail(self, *mocks):
|
||||
"""Return a list of all running services with the disable reason
|
||||
information if that exists.
|
||||
"""
|
||||
response = self._do_get('os-services')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
subs = {'id': 1,
|
||||
'binary': 'nova-compute',
|
||||
'host': 'host1',
|
||||
'zone': 'nova',
|
||||
'status': 'disabled',
|
||||
'state': 'up'}
|
||||
subs.update(self._get_regexes())
|
||||
return self._verify_response('services-get-resp',
|
||||
subs, response, 200)
|
||||
|
||||
def test_service_delete(self, *mocks):
|
||||
response = self._do_delete('os-services/1')
|
||||
self.assertEqual(response.status_code, 204)
|
||||
self.assertEqual(response.content, "")
|
||||
|
||||
|
||||
class SimpleTenantUsageSampleJsonTest(ServersSampleBase):
|
||||
extension_name = ("nova.api.openstack.compute.contrib.simple_tenant_usage."
|
||||
"Simple_tenant_usage")
|
||||
|
||||
@@ -13,16 +13,37 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from nova import db
|
||||
from nova.tests.functional.v3 import api_sample_base
|
||||
from nova.tests.unit.api.openstack.compute.contrib import test_services
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('osapi_compute_extension',
|
||||
'nova.api.openstack.compute.extensions')
|
||||
|
||||
|
||||
class ServicesJsonTest(api_sample_base.ApiSampleTestBaseV3):
|
||||
ADMIN_API = True
|
||||
extension_name = "os-services"
|
||||
# TODO(gmann): Overriding '_api_version' till all functional tests
|
||||
# are merged between v2 and v2.1. After that base class variable
|
||||
# itself can be changed to 'v2'
|
||||
_api_version = 'v2'
|
||||
|
||||
def _get_flags(self):
|
||||
f = super(ServicesJsonTest, self)._get_flags()
|
||||
f['osapi_compute_extension'] = CONF.osapi_compute_extension[:]
|
||||
f['osapi_compute_extension'].append(
|
||||
'nova.api.openstack.compute.contrib.services.Services')
|
||||
f['osapi_compute_extension'].append('nova.api.openstack.compute.'
|
||||
'contrib.extended_services_delete.'
|
||||
'Extended_services_delete')
|
||||
f['osapi_compute_extension'].append('nova.api.openstack.compute.'
|
||||
'contrib.extended_services.Extended_services')
|
||||
return f
|
||||
|
||||
def setUp(self):
|
||||
super(ServicesJsonTest, self).setUp()
|
||||
|
||||
Reference in New Issue
Block a user