Purpose of functional testcases is to verify various functionality of tacker features. From tacker home directory, testcases are located at tacker/tests/functional.
Writing a testcase:A testcase is written by declaring a class name derived from class base.BaseTackerTest. BaseTackerTest is class declared in tacker/tests/functional/vnfd/base.py.
A testcase body typically looks as below:
class vnfClassName(base.BaseTackerTest):
def test_create_delete(self):
//Testcase operations
//validations or asserts
//cleanup
In above example test class ‘vnfClassName’ is derived from base.BaseTackerTest. Testcases typically has sections to setup, test, validate results and finally cleanup.
Input yaml files: These are input files used in testcases for operations like create vnfd or create vnf. The location of files is tacker/tests/etc/samples/.
requirements.txt and test-requirements.txt : The file requirements.txt and test-requirements.txt lists all the packages needed for functional test. These packages are installed during devstack installation. If there are any new packages needed for functional test make sure they are added in test-requirements.txt.
Asserting values in testcase: The base class BaseTackerTest inherits base.TestCase which has inbuild assert functions which can be used in testcase. Eg: assertIsNotNone, assertEqual
Tacker-client: In base.py we instantiate tackerclient object which has apis to create/delete/list vnfd/vnf once given the necessary parameters. Verify tackerclient/v1_0/client.py for all the tacker related apis supported.
pip install -r test-requirements.txt
tox -e pep8
./tools/prepare_functional_test.sh
tox -e functional
tox -e functional tacker.tests.functional.xxx.yyy.<testcase>