Add a shell script for developers to prepare functional test env
After devstack installation, to run functional test cases, the nova instance quota, keypair and neutron port quota should be set to a level which will not block tests. This patch adds a tool to do this preparation so that developers can easily run functional tests locally. Change-Id: I1c2fae110863906e3f7601456dbf79ff06da4c40 Closes-bug: #1617303
This commit is contained in:
parent
fd8e37de5c
commit
b90d3e4d6d
@ -88,17 +88,29 @@ Important guidelines to follow:
|
|||||||
Execution of testcase:
|
Execution of testcase:
|
||||||
======================
|
======================
|
||||||
|
|
||||||
* From tacker directory, testcases can be executed using following commands:
|
* Install tacker server via devstack installation, which registers
|
||||||
|
tacker service and endpoint, creates "nfv_user" and "nfv" project,
|
||||||
|
and registers default VIM with the created user and project.
|
||||||
|
|
||||||
(Note: Make sure tacker server is installed and running)
|
* Under tacker project dir, to prepare function test env via:
|
||||||
|
|
||||||
* To execute all testcases or one testcase use below commands:
|
.. code-block:: console
|
||||||
|
|
||||||
|
./tools/prepare_functional_test.sh
|
||||||
|
|
||||||
|
* From tacker directory, all function testcases can be executed using
|
||||||
|
following commands:
|
||||||
|
|
||||||
.. code-block:: console
|
.. code-block:: console
|
||||||
|
|
||||||
tox -e functional
|
tox -e functional
|
||||||
tox -e functional tacker.tests.functional.vnfd.<testcase>
|
|
||||||
|
|
||||||
|
* Or from tacker directory, specific testcases can be executed using
|
||||||
|
following commands:
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
tox -e functional tacker.tests.functional.xxx.yyy.<testcase>
|
||||||
|
|
||||||
|
|
||||||
Committing testcase and opening a review:
|
Committing testcase and opening a review:
|
||||||
|
@ -53,19 +53,7 @@ function generate_testr_results {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function fixup_nova_quota {
|
source ${TACKER_DIR}/tacker/tests/contrib/post_test_hook_lib.sh
|
||||||
echo "Disable nova compute instance & core quota"
|
|
||||||
source $DEVSTACK_DIR/openrc admin admin
|
|
||||||
nova quota-class-update --instances -1 --cores -1 default
|
|
||||||
}
|
|
||||||
|
|
||||||
# Adding nova keypair to support key_name (#1578785).
|
|
||||||
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 > keypair.priv
|
|
||||||
}
|
|
||||||
|
|
||||||
if [[ "$venv" == dsvm-functional* ]]
|
if [[ "$venv" == dsvm-functional* ]]
|
||||||
then
|
then
|
||||||
@ -73,7 +61,7 @@ then
|
|||||||
sudo_env=
|
sudo_env=
|
||||||
log_dir="/tmp/${venv}-logs"
|
log_dir="/tmp/${venv}-logs"
|
||||||
|
|
||||||
fixup_nova_quota
|
fixup_quota
|
||||||
add_key
|
add_key
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
46
tacker/tests/contrib/post_test_hook_lib.sh
Normal file
46
tacker/tests/contrib/post_test_hook_lib.sh
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/bash -x
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
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}')
|
||||||
|
echo "Disable neutron port quota on project 'nfv' $projectId"
|
||||||
|
neutron quota-update --tenant-id $projectId --port -1
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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
|
||||||
|
nova keypair-add userKey --user $userId > ${PRIVATE_KEY_FILE}
|
||||||
|
else
|
||||||
|
echo "Keypair userKey already exists"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Adding nova keypair to support key_name (#1578785).
|
||||||
|
# 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}
|
||||||
|
}
|
18
tools/prepare_functional_test.sh
Executable file
18
tools/prepare_functional_test.sh
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
# This script is used to prepare functional test env after devstack
|
||||||
|
# installation of tacker
|
||||||
|
|
||||||
|
DEVSTACK_DIR=${DEVSTACK_DIR:-~/devstack}
|
||||||
|
TACKER_DIR=$(dirname "$0")/..
|
||||||
|
PRIVATE_KEY_FILE=${PRIVATE_KEY_FILE:-/dev/null}
|
||||||
|
NFV_USER=${NFV_USER:-"nfv_user"}
|
||||||
|
|
||||||
|
# Test devstack dir setting
|
||||||
|
if [ ! -f ${DEVSTACK_DIR}/openrc ]; then
|
||||||
|
echo "Please set right DEVSTACK_DIR"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
source ${TACKER_DIR}/tacker/tests/contrib/post_test_hook_lib.sh
|
||||||
|
|
||||||
|
fixup_quota
|
||||||
|
add_key_if_not_exist
|
Loading…
Reference in New Issue
Block a user