Developers guide for functional tests
Adding developers documentation for tacker functional tests. Closes-Bug: 1516878 Change-Id: Ic31a4152d744f3d9a220538d1d7f3c1b6f6698bb
This commit is contained in:
parent
c59d7000f6
commit
46d6e58bed
doc/source
115
doc/source/devref/tacker_functional_test.rst
Normal file
115
doc/source/devref/tacker_functional_test.rst
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
..
|
||||||
|
This work is licensed under a Creative Commons Attribution 3.0 Unported
|
||||||
|
License.
|
||||||
|
|
||||||
|
http://creativecommons.org/licenses/by/3.0/legalcode
|
||||||
|
|
||||||
|
|
||||||
|
===============================
|
||||||
|
Functional testcases for tacker
|
||||||
|
===============================
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Important guidelines to follow:
|
||||||
|
===============================
|
||||||
|
|
||||||
|
* Install test-requirements.txt with below command:
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
pip install -r test-requirements.txt
|
||||||
|
|
||||||
|
* It is important that the test case executed leaves the
|
||||||
|
system in the same state it was prior to test case execution
|
||||||
|
and not leave any stale data on system as this might affect
|
||||||
|
other test cases.
|
||||||
|
* There should not be any dependencies between testcases
|
||||||
|
which assume one testcase should be executed and be passed
|
||||||
|
for second testcase.
|
||||||
|
* Testcases in tox environment may be executed in parallel.
|
||||||
|
The order in which the testcases are executed may vary
|
||||||
|
between two environments.
|
||||||
|
* The code added should meet pep8 standards. This can be verified with
|
||||||
|
following command and ensuring the code does not return any errors.
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
tox -e pep8
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Execution of testcase:
|
||||||
|
======================
|
||||||
|
|
||||||
|
* From tacker directory, testcases can be executed using following commands:
|
||||||
|
|
||||||
|
(Note: Make sure tacker server is installed and running)
|
||||||
|
|
||||||
|
* To execute all testcases or one testcase use below commands:
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
tox -e functional
|
||||||
|
tox -e functional tacker.tests.functional.vnfd.<testcase>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Committing testcase and opening a review:
|
||||||
|
=========================================
|
||||||
|
|
||||||
|
* Once testcase is added in local setup, commit the testcase and open for
|
||||||
|
review using below guidelines,
|
||||||
|
* http://docs.openstack.org/infra/manual/developers.html
|
||||||
|
|
||||||
|
Sample testcase:
|
||||||
|
================
|
||||||
|
* Check sample tests under following directory:
|
||||||
|
|
||||||
|
https://github.com/openstack/tacker/blob/master/tacker/tests/functional/
|
@ -71,6 +71,7 @@ Developer Info
|
|||||||
devref/development.environment.rst
|
devref/development.environment.rst
|
||||||
devref/api_layer.rst
|
devref/api_layer.rst
|
||||||
devref/api_extensions.rst
|
devref/api_extensions.rst
|
||||||
|
devref/tacker_functional_test.rst
|
||||||
|
|
||||||
Indices and tables
|
Indices and tables
|
||||||
------------------
|
------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user