Merge "Merge cell functional tests for V2 and V2.1"
This commit is contained in:
commit
15fae605ca
|
@ -1,18 +0,0 @@
|
||||||
{
|
|
||||||
"cell": {
|
|
||||||
"capacities": {
|
|
||||||
"ram_free": {
|
|
||||||
"units_by_mb": {
|
|
||||||
"8192": 0, "512": 13, "4096": 1, "2048": 3, "16384": 0
|
|
||||||
},
|
|
||||||
"total_mb": 7680
|
|
||||||
},
|
|
||||||
"disk_free": {
|
|
||||||
"units_by_mb": {
|
|
||||||
"81920": 11, "20480": 46, "40960": 23, "163840": 5, "0": 0
|
|
||||||
},
|
|
||||||
"total_mb": 1052672
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
{
|
|
||||||
"cell": {
|
|
||||||
"name": "cell3",
|
|
||||||
"rpc_host": null,
|
|
||||||
"rpc_port": null,
|
|
||||||
"type": "child",
|
|
||||||
"username": "username3"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"cells": []
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
{
|
|
||||||
"cells": [
|
|
||||||
{
|
|
||||||
"name": "cell1",
|
|
||||||
"rpc_host": null,
|
|
||||||
"rpc_port": null,
|
|
||||||
"type": "child",
|
|
||||||
"username": "username1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cell3",
|
|
||||||
"rpc_host": null,
|
|
||||||
"rpc_port": null,
|
|
||||||
"type": "child",
|
|
||||||
"username": "username3"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cell5",
|
|
||||||
"rpc_host": null,
|
|
||||||
"rpc_port": null,
|
|
||||||
"type": "child",
|
|
||||||
"username": "username5"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cell2",
|
|
||||||
"rpc_host": null,
|
|
||||||
"rpc_port": null,
|
|
||||||
"type": "parent",
|
|
||||||
"username": "username2"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cell4",
|
|
||||||
"rpc_host": null,
|
|
||||||
"rpc_port": null,
|
|
||||||
"type": "parent",
|
|
||||||
"username": "username4"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
{
|
|
||||||
"cell": {
|
|
||||||
"capacities": {
|
|
||||||
"ram_free": {
|
|
||||||
"units_by_mb": {
|
|
||||||
"8192": 0, "512": 13, "4096": 1, "2048": 3, "16384": 0
|
|
||||||
},
|
|
||||||
"total_mb": 7680
|
|
||||||
},
|
|
||||||
"disk_free": {
|
|
||||||
"units_by_mb": {
|
|
||||||
"81920": 11, "20480": 46, "40960": 23, "163840": 5, "0": 0
|
|
||||||
},
|
|
||||||
"total_mb": 1052672
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
{
|
|
||||||
"cell": {
|
|
||||||
"name": "cell3",
|
|
||||||
"username": "username3",
|
|
||||||
"rpc_host": null,
|
|
||||||
"rpc_port": null,
|
|
||||||
"type": "child"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
{
|
|
||||||
"cells": []
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
{
|
|
||||||
"cells": [
|
|
||||||
{
|
|
||||||
"name": "cell1",
|
|
||||||
"username": "username1",
|
|
||||||
"rpc_host": null,
|
|
||||||
"rpc_port": null,
|
|
||||||
"type": "child"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cell2",
|
|
||||||
"username": "username2",
|
|
||||||
"rpc_host": null,
|
|
||||||
"rpc_port": null,
|
|
||||||
"type": "parent"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cell3",
|
|
||||||
"username": "username3",
|
|
||||||
"rpc_host": null,
|
|
||||||
"rpc_port": null,
|
|
||||||
"type": "child"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cell4",
|
|
||||||
"username": "username4",
|
|
||||||
"rpc_host": null,
|
|
||||||
"rpc_port": null,
|
|
||||||
"type": "parent"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cell5",
|
|
||||||
"username": "username5",
|
|
||||||
"rpc_host": null,
|
|
||||||
"rpc_port": null,
|
|
||||||
"type": "child"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -34,8 +34,6 @@ from nova.api.metadata import password
|
||||||
from nova.api.openstack.compute.contrib import fping
|
from nova.api.openstack.compute.contrib import fping
|
||||||
from nova.api.openstack.compute import extensions
|
from nova.api.openstack.compute import extensions
|
||||||
# Import extensions to pull in osapi_compute_extension CONF option used below.
|
# Import extensions to pull in osapi_compute_extension CONF option used below.
|
||||||
from nova.cells import rpcapi as cells_rpcapi
|
|
||||||
from nova.cells import state
|
|
||||||
from nova.cloudpipe import pipelib
|
from nova.cloudpipe import pipelib
|
||||||
from nova.compute import api as compute_api
|
from nova.compute import api as compute_api
|
||||||
from nova.compute import cells_api as cells_api
|
from nova.compute import cells_api as cells_api
|
||||||
|
@ -2329,103 +2327,6 @@ class BaremetalNodesJsonTest(ApiSampleTestBaseV2):
|
||||||
self._verify_response('baremetal-node-get-resp', subs, response, 200)
|
self._verify_response('baremetal-node-get-resp', subs, response, 200)
|
||||||
|
|
||||||
|
|
||||||
class CellsSampleJsonTest(ApiSampleTestBaseV2):
|
|
||||||
extension_name = "nova.api.openstack.compute.contrib.cells.Cells"
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
# db_check_interval < 0 makes cells manager always hit the DB
|
|
||||||
self.flags(enable=True, db_check_interval=-1, group='cells')
|
|
||||||
super(CellsSampleJsonTest, self).setUp()
|
|
||||||
self._stub_cells()
|
|
||||||
|
|
||||||
def _stub_cells(self, num_cells=5):
|
|
||||||
self.cells = []
|
|
||||||
self.cells_next_id = 1
|
|
||||||
|
|
||||||
def _fake_cell_get_all(context):
|
|
||||||
return self.cells
|
|
||||||
|
|
||||||
def _fake_cell_get(inst, context, cell_name):
|
|
||||||
for cell in self.cells:
|
|
||||||
if cell['name'] == cell_name:
|
|
||||||
return cell
|
|
||||||
raise exception.CellNotFound(cell_name=cell_name)
|
|
||||||
|
|
||||||
for x in xrange(num_cells):
|
|
||||||
cell = models.Cell()
|
|
||||||
our_id = self.cells_next_id
|
|
||||||
self.cells_next_id += 1
|
|
||||||
cell.update({'id': our_id,
|
|
||||||
'name': 'cell%s' % our_id,
|
|
||||||
'transport_url': 'rabbit://username%s@/' % our_id,
|
|
||||||
'is_parent': our_id % 2 == 0})
|
|
||||||
self.cells.append(cell)
|
|
||||||
|
|
||||||
self.stubs.Set(db, 'cell_get_all', _fake_cell_get_all)
|
|
||||||
self.stubs.Set(cells_rpcapi.CellsAPI, 'cell_get', _fake_cell_get)
|
|
||||||
|
|
||||||
def test_cells_empty_list(self):
|
|
||||||
# Override this
|
|
||||||
self._stub_cells(num_cells=0)
|
|
||||||
response = self._do_get('os-cells')
|
|
||||||
subs = self._get_regexes()
|
|
||||||
self._verify_response('cells-list-empty-resp', subs, response, 200)
|
|
||||||
|
|
||||||
def test_cells_list(self):
|
|
||||||
response = self._do_get('os-cells')
|
|
||||||
subs = self._get_regexes()
|
|
||||||
self._verify_response('cells-list-resp', subs, response, 200)
|
|
||||||
|
|
||||||
def test_cells_get(self):
|
|
||||||
response = self._do_get('os-cells/cell3')
|
|
||||||
subs = self._get_regexes()
|
|
||||||
self._verify_response('cells-get-resp', subs, response, 200)
|
|
||||||
|
|
||||||
|
|
||||||
class CellsCapacitySampleJsonTest(ApiSampleTestBaseV2):
|
|
||||||
extends_name = ("nova.api.openstack.compute.contrib.cells.Cells")
|
|
||||||
extension_name = ("nova.api.openstack.compute.contrib."
|
|
||||||
"cell_capacities.Cell_capacities")
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
self.flags(enable=True, db_check_interval=-1, group='cells')
|
|
||||||
super(CellsCapacitySampleJsonTest, self).setUp()
|
|
||||||
# (navneetk/kaushikc) : Mock cell capacity to avoid the capacity
|
|
||||||
# being calculated from the compute nodes in the environment
|
|
||||||
self._mock_cell_capacity()
|
|
||||||
|
|
||||||
def test_get_cell_capacity(self):
|
|
||||||
state_manager = state.CellStateManager()
|
|
||||||
my_state = state_manager.get_my_state()
|
|
||||||
response = self._do_get('os-cells/%s/capacities' %
|
|
||||||
my_state.name)
|
|
||||||
subs = self._get_regexes()
|
|
||||||
return self._verify_response('cells-capacities-resp',
|
|
||||||
subs, response, 200)
|
|
||||||
|
|
||||||
def test_get_all_cells_capacity(self):
|
|
||||||
response = self._do_get('os-cells/capacities')
|
|
||||||
subs = self._get_regexes()
|
|
||||||
return self._verify_response('cells-capacities-resp',
|
|
||||||
subs, response, 200)
|
|
||||||
|
|
||||||
def _mock_cell_capacity(self):
|
|
||||||
self.mox.StubOutWithMock(self.cells.manager.state_manager,
|
|
||||||
'get_our_capacities')
|
|
||||||
response = {"ram_free":
|
|
||||||
{"units_by_mb": {"8192": 0, "512": 13,
|
|
||||||
"4096": 1, "2048": 3, "16384": 0},
|
|
||||||
"total_mb": 7680},
|
|
||||||
"disk_free":
|
|
||||||
{"units_by_mb": {"81920": 11, "20480": 46,
|
|
||||||
"40960": 23, "163840": 5, "0": 0},
|
|
||||||
"total_mb": 1052672}
|
|
||||||
}
|
|
||||||
self.cells.manager.state_manager.get_our_capacities(). \
|
|
||||||
AndReturn(response)
|
|
||||||
self.mox.ReplayAll()
|
|
||||||
|
|
||||||
|
|
||||||
class BlockDeviceMappingV2BootJsonTest(ServersSampleBase):
|
class BlockDeviceMappingV2BootJsonTest(ServersSampleBase):
|
||||||
extension_name = ('nova.api.openstack.compute.contrib.'
|
extension_name = ('nova.api.openstack.compute.contrib.'
|
||||||
'block_device_mapping_v2_boot.'
|
'block_device_mapping_v2_boot.'
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from oslo_config import cfg
|
||||||
|
|
||||||
from nova.cells import rpcapi as cells_rpcapi
|
from nova.cells import rpcapi as cells_rpcapi
|
||||||
from nova.cells import state
|
from nova.cells import state
|
||||||
from nova import db
|
from nova import db
|
||||||
|
@ -20,9 +22,26 @@ from nova.db.sqlalchemy import models
|
||||||
from nova import exception
|
from nova import exception
|
||||||
from nova.tests.functional.v3 import api_sample_base
|
from nova.tests.functional.v3 import api_sample_base
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
CONF.import_opt('osapi_compute_extension',
|
||||||
|
'nova.api.openstack.compute.extensions')
|
||||||
|
|
||||||
|
|
||||||
class CellsSampleJsonTest(api_sample_base.ApiSampleTestBaseV3):
|
class CellsSampleJsonTest(api_sample_base.ApiSampleTestBaseV3):
|
||||||
extension_name = "os-cells"
|
extension_name = "os-cells"
|
||||||
|
# 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(CellsSampleJsonTest, self)._get_flags()
|
||||||
|
f['osapi_compute_extension'] = CONF.osapi_compute_extension[:]
|
||||||
|
f['osapi_compute_extension'].append(
|
||||||
|
'nova.api.openstack.compute.contrib.cells.Cells')
|
||||||
|
f['osapi_compute_extension'].append('nova.api.openstack.compute.'
|
||||||
|
'contrib.cell_capacities.Cell_capacities')
|
||||||
|
return f
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
# db_check_interval < 0 makes cells manager always hit the DB
|
# db_check_interval < 0 makes cells manager always hit the DB
|
||||||
|
|
Loading…
Reference in New Issue