Fix dsvm failure caused by devstack plugin and event/auditing func.

This patch will fix dsvm failure:
1. The new changes in devstack [1]. Whereby, plugin was not enabled
to use multiple times. Currently, almost functions like fixup_quota,
add_key and add_secgrp enable plugin which runs multiple times.
2. Some functional tests were not working with event/auditing function.
[1]https://review.openstack.org/#/c/396794/

Change-Id: I1846c0df1d59557919a4caa612f2a4c60fbf7ce8
Closes-Bug: #1646807
This commit is contained in:
doantungbk 2016-11-30 06:36:59 -08:00
parent 0de40f7328
commit 17e28c9d90
12 changed files with 38 additions and 37 deletions

View File

@ -60,7 +60,7 @@ then
owner=stack
sudo_env=
log_dir="/tmp/${venv}-logs"
source $DEVSTACK_DIR/openrc admin admin
fixup_quota
add_key
add_secgrp

View File

@ -15,7 +15,6 @@
PRIVATE_KEY_FILE=${PRIVATE_KEY_FILE:-"keypair.priv"}
function fixup_quota {
source $DEVSTACK_DIR/openrc admin admin
echo "Disable nova compute instance & core quota"
nova quota-class-update --instances -1 --cores -1 default
projectId=$(openstack project list | awk '/\ nfv\ / {print $2}')
@ -26,7 +25,6 @@ function fixup_quota {
# Adding nova keypair if not exist to support key_name (#1578785).
function add_key_if_not_exist {
echo "Adding nova key if not exist"
source $DEVSTACK_DIR/openrc admin admin
userId=$(openstack user list | awk '/\ nfv_user\ / {print $2}')
nova keypair-show userKey --user $userId >/dev/null
if [[ "$?" != "0" ]]; then
@ -40,7 +38,6 @@ function add_key_if_not_exist {
# used by OpenStack CI since it will fail if $? is not 0
function add_key {
echo "Adding nova key"
source $DEVSTACK_DIR/openrc admin admin
userId=$(openstack user list | awk '/\ nfv_user\ / {print $2}')
nova keypair-add userKey --user $userId > ${PRIVATE_KEY_FILE}
}
@ -61,7 +58,6 @@ function _check_secgrps {
function add_secgrp_if_not_exist {
echo "Adding nova security group"
source $DEVSTACK_DIR/openrc admin admin
openstack security group show test_secgrp
if [[ "$?" != "0" ]]; then
_create_secgrps
@ -74,7 +70,6 @@ function add_secgrp_if_not_exist {
# Adding nova security groups (#1591372).
function add_secgrp {
echo "Adding nova security group"
source $DEVSTACK_DIR/openrc admin admin
_create_secgrps
_check_secgrps
}

View File

@ -171,8 +171,10 @@ class BaseTackerTest(base.BaseTestCase):
"List of VNF events are Empty")
self.assertEqual(cnt, len(vnf_evt_list['vnf_events']))
def verify_vnfd_events(self, vnfd_id, evt_type, tstamp=None, cnt=1):
def verify_vnfd_events(self, vnfd_id, evt_type, res_state,
tstamp=None, cnt=1):
params = {'resource_id': vnfd_id,
'resource_state': res_state,
'resource_type': evt_constants.RES_TYPE_VNFD,
'event_type': evt_type}
if tstamp:

View File

@ -48,8 +48,7 @@ class VimTestCreate(base.BaseTackerTest):
vim_obj = vim_res['vim']
vim_id = vim_obj['id']
self.verify_vim(vim_obj, data, name, description, version)
self.verify_vim_events(vim_id, evt_constants.RES_EVT_CREATE,
vim_obj[evt_constants.RES_EVT_CREATED_FLD])
self.verify_vim_events(vim_id, evt_constants.RES_EVT_CREATE)
# Read vim
vim_show_res = self.client.show_vim(vim_id)

View File

@ -76,8 +76,8 @@ class VnfTestToscaCreate(base.BaseTackerTest):
resource_name=field)
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.PENDING_CREATE,
vnf_instance['vnf'][evt_constants.RES_EVT_CREATED_FLD])
vnf_id, evt_constants.RES_EVT_CREATE,
evt_constants.PENDING_CREATE, cnt=2)
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.ACTIVE)
return vnfd_id, vnf_id
@ -154,8 +154,8 @@ class VnfTestToscaCreateFlavorCreation(base.BaseTackerTest):
self.assertIsNotNone(self.client.show_vnf(vnf_id)['vnf']['mgmt_url'])
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.PENDING_CREATE,
vnf_instance['vnf'][evt_constants.RES_EVT_CREATED_FLD])
vnf_id, evt_constants.RES_EVT_CREATE,
evt_constants.PENDING_CREATE, cnt=2)
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.ACTIVE)
@ -216,8 +216,8 @@ class VnfTestToscaCreateImageCreation(base.BaseTackerTest):
self.assertIsNotNone(self.client.show_vnf(vnf_id)['vnf']['mgmt_url'])
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.PENDING_CREATE,
vnf_instance['vnf'][evt_constants.RES_EVT_CREATED_FLD])
vnf_id, evt_constants.RES_EVT_CREATE,
evt_constants.PENDING_CREATE, cnt=2)
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.ACTIVE)

View File

@ -52,8 +52,8 @@ class VnfTestToscaMultipleVDU(base.BaseTackerTest):
self.validate_vnf_instance(vnfd_instance, vnf_instance)
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.PENDING_CREATE,
vnf_instance['vnf'][evt_constants.RES_EVT_CREATED_FLD])
vnf_id, evt_constants.RES_EVT_CREATE,
evt_constants.PENDING_CREATE, cnt=2)
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.ACTIVE)

View File

@ -23,10 +23,9 @@ CONF = cfg.CONF
class VnfdTestCreate(base.BaseTackerTest):
def _test_create_list_delete_tosca_vnfd(self, tosca_vnfd_file):
def _test_create_list_delete_tosca_vnfd(self, tosca_vnfd_file, vnfd_name):
input_yaml = read_file(tosca_vnfd_file)
tosca_dict = yaml.safe_load(input_yaml)
vnfd_name = 'sample-tosca-vnfd'
tosca_arg = {'vnfd': {'name': vnfd_name,
'attributes': {'vnfd': tosca_dict}}}
vnfd_instance = self.client.create_vnfd(body=tosca_arg)
@ -38,17 +37,20 @@ class VnfdTestCreate(base.BaseTackerTest):
vnfd_id = vnfd_instance['vnfd']['id']
self.verify_vnfd_events(
vnfd_id, evt_constants.RES_EVT_CREATE,
vnfd_instance['vnfd'][evt_constants.RES_EVT_CREATED_FLD])
evt_constants.RES_EVT_VNFD_ONBOARDED)
try:
self.client.delete_vnfd(vnfd_id)
except Exception:
assert False, "vnfd Delete failed"
self.verify_vnfd_events(vnfd_id, evt_constants.RES_EVT_DELETE)
self.verify_vnfd_events(vnfd_id, evt_constants.RES_EVT_DELETE,
evt_constants.RES_EVT_VNFD_NA_STATE)
def test_tosca_vnfd(self):
self._test_create_list_delete_tosca_vnfd('sample-tosca-vnfd.yaml')
self._test_create_list_delete_tosca_vnfd('sample-tosca-vnfd.yaml',
'sample-tosca-vnfd-template')
def test_tosca_large_vnfd(self):
self._test_create_list_delete_tosca_vnfd(
'sample-tosca-vnfd-large-template.yaml')
'sample-tosca-vnfd-large-template.yaml',
'sample-tosca-vnfd-large-template')

View File

@ -59,8 +59,8 @@ class VnfTestCreate(base.BaseTackerTest):
self.assertIn('type', vnf_details)
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.PENDING_CREATE,
vnf_instance['vnf'][evt_constants.RES_EVT_CREATED_FLD])
vnf_id, evt_constants.RES_EVT_CREATE,
evt_constants.PENDING_CREATE, cnt=2)
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.ACTIVE)

View File

@ -52,8 +52,8 @@ class VnfTestMultipleVDU(base.BaseTackerTest):
self.validate_vnf_instance(vnfd_instance, vnf_instance)
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.PENDING_CREATE,
vnf_instance['vnf'][evt_constants.RES_EVT_CREATED_FLD])
vnf_id, evt_constants.RES_EVT_CREATE,
evt_constants.PENDING_CREATE, cnt=2)
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.ACTIVE)

View File

@ -39,12 +39,13 @@ class VnfdTestCreate(base.BaseTackerTest):
self.verify_vnfd_events(
vnfd_id, evt_constants.RES_EVT_CREATE,
vnfd_instance['vnfd'][evt_constants.RES_EVT_CREATED_FLD])
evt_constants.RES_EVT_VNFD_ONBOARDED)
try:
self.client.delete_vnfd(vnfd_id)
except Exception:
assert False, "vnfd Delete failed"
self.verify_vnfd_events(vnfd_id, evt_constants.RES_EVT_DELETE)
self.verify_vnfd_events(vnfd_id, evt_constants.RES_EVT_DELETE,
evt_constants.RES_EVT_VNFD_NA_STATE)
def test_vnfd(self):
self._test_create_list_delete_vnfd('sample_cirros_vnf.yaml')

View File

@ -37,7 +37,7 @@ class VnfmTestParam(base.BaseTackerTest):
self.assertIsNotNone(vnfd_id)
self.verify_vnfd_events(
vnfd_id, evt_constants.RES_EVT_CREATE,
vnfd_instance['vnfd'][evt_constants.RES_EVT_CREATED_FLD])
evt_constants.RES_EVT_VNFD_ONBOARDED)
return vnfd_instance
def _test_vnfd_delete(self, vnfd_instance):
@ -48,7 +48,8 @@ class VnfmTestParam(base.BaseTackerTest):
self.client.delete_vnfd(vnfd_id)
except Exception:
assert False, "vnfd Delete failed"
self.verify_vnfd_events(vnfd_id, evt_constants.RES_EVT_DELETE)
self.verify_vnfd_events(vnfd_id, evt_constants.RES_EVT_DELETE,
evt_constants.RES_EVT_VNFD_NA_STATE)
try:
vnfd_d = self.client.show_vnfd(vnfd_id)
except Exception:
@ -73,8 +74,8 @@ class VnfmTestParam(base.BaseTackerTest):
vnf_instance = self.client.show_vnf(vnf_id)
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.PENDING_CREATE,
vnf_instance['vnf'][evt_constants.RES_EVT_CREATED_FLD])
vnf_id, evt_constants.RES_EVT_CREATE,
evt_constants.PENDING_CREATE, cnt=2)
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.ACTIVE)
@ -116,8 +117,8 @@ class VnfmTestParam(base.BaseTackerTest):
self._test_vnf_delete(vnf_instance)
vnf_id = vnf_instance['vnf']['id']
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.PENDING_CREATE,
vnf_instance['vnf'][evt_constants.RES_EVT_CREATED_FLD])
vnf_id, evt_constants.RES_EVT_CREATE,
evt_constants.PENDING_CREATE, cnt=2)
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.ACTIVE)
self.wait_until_vnf_delete(vnf_id,
@ -145,8 +146,8 @@ class VnfmTestParam(base.BaseTackerTest):
self._test_vnf_delete(vnf_instance)
vnf_id = vnf_instance['vnf']['id']
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.PENDING_CREATE,
vnf_instance['vnf'][evt_constants.RES_EVT_CREATED_FLD])
vnf_id, evt_constants.RES_EVT_CREATE,
evt_constants.PENDING_CREATE, cnt=2)
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.ACTIVE)
self.wait_until_vnf_delete(vnf_id,

View File

@ -12,6 +12,7 @@ if [ ! -f ${DEVSTACK_DIR}/openrc ]; then
exit 1
fi
source $DEVSTACK_DIR/openrc admin admin
source ${TACKER_DIR}/tacker/tests/contrib/post_test_hook_lib.sh
fixup_quota