Updated destroy function

- updated corresponding unit tests

Change-Id: I016a00b9ec6b0159748b14f8c97becfd70221744
Signed-off-by: Helena McGough <helena.mcgough@intel.com>
This commit is contained in:
Helena McGough 2019-02-28 15:56:15 +00:00
parent a673e65006
commit 57c197abd4
5 changed files with 23 additions and 11 deletions

3
.stestr.conf Normal file
View File

@ -0,0 +1,3 @@
[DEFAULT]
test_path=${OS_TEST_PATH:-./rsd_virt_for_nova/tests}
top_dir=./

View File

@ -151,7 +151,7 @@ man_pages = [
# (source start file, target name, title, author, # (source start file, target name, title, author,
# dir menu entry, description, category) # dir menu entry, description, category)
texinfo_documents = [ texinfo_documents = [
(master_doc, 'rsd_virt_for_nova', u'rsd_virt_for_nova Documentation' (master_doc, 'rsd_virt_for_nova', u'rsd_virt_for_nova Documentation',
author, 'rsd_virt_for_nova', 'One line description of project.', author, 'rsd_virt_for_nova', 'One line description of project.',
'Miscellaneous'), 'Miscellaneous'),
] ]

View File

@ -116,14 +116,16 @@ class TestRSDDriver(base.BaseTestCase):
self.rsd = rsd_lib.main.RSDLib('http://foo.bar:8442', username='foo', self.rsd = rsd_lib.main.RSDLib('http://foo.bar:8442', username='foo',
password='bar', verify=False).factory() password='bar', verify=False).factory()
with open('rsd_virt_for_nova/tests/json_samples/chassis_col.json', 'r') as f: with open('rsd_virt_for_nova/tests/json_samples/chassis_col.json',
'r') as f:
self.root_conn.get.return_value.json.return_value = json.loads( self.root_conn.get.return_value.json.return_value = json.loads(
f.read()) f.read())
self.chassis_col = chassis.ChassisCollection( self.chassis_col = chassis.ChassisCollection(
self.root_conn, '/redfish/v1/Chassis', self.root_conn, '/redfish/v1/Chassis',
redfish_version='1.0.2') redfish_version='1.0.2')
with open('rsd_virt_for_nova/tests/json_samples/chassis.json', 'r') as f: with open('rsd_virt_for_nova/tests/json_samples/chassis.json',
'r') as f:
self.root_conn.get.return_value.json.return_value = json.loads( self.root_conn.get.return_value.json.return_value = json.loads(
f.read()) f.read())
@ -131,7 +133,8 @@ class TestRSDDriver(base.BaseTestCase):
self.root_conn, '/redfish/v1/Chassis/Chassis1', self.root_conn, '/redfish/v1/Chassis/Chassis1',
redfish_version='1.0.2') redfish_version='1.0.2')
with open('rsd_virt_for_nova/tests/json_samples/node_col.json', 'r') as f: with open('rsd_virt_for_nova/tests/json_samples/node_col.json',
'r') as f:
self.root_conn.get.return_value.json.return_value = json.loads( self.root_conn.get.return_value.json.return_value = json.loads(
f.read()) f.read())
self.node_collection = node.NodeCollection( self.node_collection = node.NodeCollection(
@ -144,21 +147,24 @@ class TestRSDDriver(base.BaseTestCase):
self.root_conn, '/redfish/v1/Nodes/Node1', self.root_conn, '/redfish/v1/Nodes/Node1',
redfish_version='1.0.2') redfish_version='1.0.2')
with open('rsd_virt_for_nova/tests/json_samples/node_assembled.json', 'r') as f: with open('rsd_virt_for_nova/tests/json_samples/node_assembled.json',
'r') as f:
self.root_conn.get.return_value.json.return_value = json.loads( self.root_conn.get.return_value.json.return_value = json.loads(
f.read()) f.read())
self.node_ass_inst = node.Node( self.node_ass_inst = node.Node(
self.root_conn, '/redfish/v1/Nodes/Node1', self.root_conn, '/redfish/v1/Nodes/Node1',
redfish_version='1.0.2') redfish_version='1.0.2')
with open('rsd_virt_for_nova/tests/json_samples/sys_collection.json', 'r') as f: with open('rsd_virt_for_nova/tests/json_samples/sys_collection.json',
'r') as f:
self.root_conn.get.return_value.json.return_value = \ self.root_conn.get.return_value.json.return_value = \
json.loads(f.read()) json.loads(f.read())
self.system_col = system.SystemCollection( self.system_col = system.SystemCollection(
self.root_conn, '/redfish/v1/Systems', self.root_conn, '/redfish/v1/Systems',
redfish_version='1.0.2') redfish_version='1.0.2')
with open('rsd_virt_for_nova/tests/json_samples/system.json', 'r') as f: with open('rsd_virt_for_nova/tests/json_samples/system.json',
'r') as f:
self.root_conn.get.return_value.json.return_value = json.loads( self.root_conn.get.return_value.json.return_value = json.loads(
f.read()) f.read())
self.system_inst = system.System( self.system_inst = system.System(
@ -338,6 +344,7 @@ class TestRSDDriver(base.BaseTestCase):
# Mock out instances and composed nodes for testing purposes # Mock out instances and composed nodes for testing purposes
node_collection = self.RSD.driver.PODM.get_node_collection node_collection = self.RSD.driver.PODM.get_node_collection
node_inst = node_collection.return_value.compose_node.return_value node_inst = node_collection.return_value.compose_node.return_value
rep_node = self.RSD.driver.PODM.get_node.return_value
self.RSD._composed_nodes = {self.inst1.uuid: mock_node} self.RSD._composed_nodes = {self.inst1.uuid: mock_node}
# Try to destroy the instance # Try to destroy the instance
@ -347,7 +354,8 @@ class TestRSDDriver(base.BaseTestCase):
mock_node.delete_node.assert_called_once() mock_node.delete_node.assert_called_once()
node_collection.assert_called_once() node_collection.assert_called_once()
node_collection.return_value.compose_node.assert_called_once() node_collection.return_value.compose_node.assert_called_once()
node_inst.assemble_node.assert_called_once() self.RSD.driver.PODM.get_node.assert_called_once_with(node_inst)
rep_node.assemble_node.assert_called_once()
self.assertNotIn(self.inst1.uuid, self.RSD.instances) self.assertNotIn(self.inst1.uuid, self.RSD.instances)
@mock.patch.object(v2_3_node, 'Node', autospec=True) @mock.patch.object(v2_3_node, 'Node', autospec=True)

View File

@ -169,7 +169,8 @@ class RSDDriver(driver.ComputeDriver):
COMPOSED_NODE_COL = self.driver.PODM.get_node_collection() COMPOSED_NODE_COL = self.driver.PODM.get_node_collection()
try: try:
node_inst = COMPOSED_NODE_COL.compose_node() node_inst = COMPOSED_NODE_COL.compose_node()
node_inst.assemble_node() rep_node = self.driver.PODM.get_node(node_inst)
rep_node.assemble_node()
except Exception as ex: except Exception as ex:
LOG.warn("Node is already allocated: %s", ex) LOG.warn("Node is already allocated: %s", ex)
else: else:

View File

@ -5,7 +5,7 @@
ZUUL_CLONER=/usr/zuul-env/bin/zuul-cloner ZUUL_CLONER=/usr/zuul-env/bin/zuul-cloner
BRANCH_NAME=master BRANCH_NAME=master
LIB_NAMES=(nova-rsd nova) LIB_NAMES=(rsd-virt-for-nova nova)
requirements_installed=$(echo "import openstack_requirements" | python 2>/dev/null ; echo $?) requirements_installed=$(echo "import openstack_requirements" | python 2>/dev/null ; echo $?)
set -e set -e
@ -14,7 +14,7 @@ CONSTRAINTS_FILE=$1
shift shift
install_cmd="pip install" install_cmd="pip install"
mydir=$(mktemp -dt "nova-rsd-tox_install-XXXXXXX") mydir=$(mktemp -dt "rsd-virt-for-nova-tox_install-XXXXXXX")
trap "rm -rf $mydir" EXIT trap "rm -rf $mydir" EXIT
localfile=$mydir/upper-constraints.txt localfile=$mydir/upper-constraints.txt
if [[ $CONSTRAINTS_FILE != http* ]]; then if [[ $CONSTRAINTS_FILE != http* ]]; then