In Tacker compliance test, some test cases get a failure saying "None is not of type 'string'" as below:
<Error message>
<status status="FAIL" starttime="20211222 08:58:12.183" endtime="20211222 08:58:12.693" critical="yes">ValidationError: Validation error for schema vnfInstance.schema.json: None is not of type 'string'</status>
So far, we have detected similar failure in the following test cases.
(SOL002)
- test_get_information_about_multiple_vnf_instances
- test_post_create_new_vnfinstance
(SOL003)
- test_get_information_about_multiple_vnf_instances
- test_post_create_new_vnfinstance
The following is the root cause of this issue in "test_post_create_new_vnfinstance()" of SOL003 as an example.
<Root cause>
In test_post_create_new_vnfinstance() in tacker/tacker/tests/compliance/sol003/test_vnflcm.py, an API request body is set as pre-conditions.
In this process, "vnfdId" and "vnfInstanceName" are set to body, while "vnfInstanceDescription" is not set.
------------------------------------------------------------------
class VNFInstancesTest(BaseVNFLifecycleManagementTest):
:
def test_post_create_new_vnfinstance(self):
# Pre-conditions:
body = jsonutils.dumps({"vnfdId": "%s" % self.vnfpkginfos[0].vnfdid,
"vnfInstanceName": "sol_api_test"})
rc, output = self._run('POST Create a new vnfInstance', body=body,
filename='createVnfRequest.json')
# Post-Conditions: VNF instance created
vnfid = self._get_id_from_output(output)
if (vnfid is not None):
self._delete_vnf_instance(vnfid)
self.assertEqual(0, rc)
------------------------------------------------------------------
In this case, the value of "vnfInstanceDescription" is inserted as "NULL" by default into a DB record.
------------------------------------------------------------------
mysql> show columns from vnf_instances;
+--------------------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------------------+---------------+------+-----+---------+-------+
| id | varchar(36) | NO | PRI | NULL | |
| vnf_instance_name | varchar(255) | YES | | NULL | |
| vnf_instance_description | varchar(1024) | YES | | NULL | | <==== Default value is 'NULL'
:
------------------------------------------------------------------
------------------------------------------------------------------
mysql> select * from vnf_instances where id="0258d8a3-7a7a-4648-b398-1a95901f9a8f";
+--------------------------------------+-------------------+--------------------------+--------------------------------------+--------------+------------------+----------------------+--------------+---------------------+------------+---------------------+----------------------------------+---------------------+---------------------+---------------------+---------+--------------------------------------+--------------+
| id | vnf_instance_name | vnf_instance_description | vnfd_id | vnf_provider | vnf_product_name | vnf_software_version | vnfd_version | instantiation_state | task_state | vim_connection_info | tenant_id | created_at | updated_at | deleted_at | deleted | vnf_pkg_id | vnf_metadata |
+--------------------------------------+-------------------+--------------------------+--------------------------------------+--------------+------------------+----------------------+--------------+---------------------+------------+---------------------+----------------------------------+---------------------+---------------------+---------------------+---------+--------------------------------------+--------------+
| 0258d8a3-7a7a-4648-b398-1a95901f9a8f | sol_api_test | NULL | 9b247d6b-7f22-4e59-bc15-c295d96ff1b3 | Company | Sample VNF | 1.0 | 1.0 | NOT_INSTANTIATED | NULL | [] | 25167fef64c94b3ba6e8305077b47d11 | 2023-05-23 02:21:25 | 2023-05-23 02:21:25 | 2023-05-23 02:21:25 | 1 | 7bacd251-16aa-499e-9204-e9e2c80219c5 | null |
+--------------------------------------+-------------------+--------------------------+--------------------------------------+--------------+------------------+----------------------+--------------+---------------------+------------+---------------------+----------------------------------+---------------------+---------------------+---------------------+---------+--------------------------------------+--------------+
------------------------------------------------------------------
Then, when Tacker generates a body of API response, Tacker gets "vnfInstanceDescription" value from target DB record with using JSON library.
However, the JSON library recognizes "NULL" in DB as "None" as a Python-based value.
Because of this, the value of "vnfInstanceDescription" in the response body is set to "None", which type is not "string".
As the result, the validation check in NFV TST api-tests always fails due to the mismatch of types between in response body and JSON schema.
Reviewed: https:/ /review. opendev. org/c/openstack /tacker/ +/888757 /opendev. org/openstack/ tacker/ commit/ e48a69245d6c91b 669a93ceb4f6c65 c2f35d1e2c
Committed: https:/
Submitter: "Zuul (22348)"
Branch: master
commit e48a69245d6c91b 669a93ceb4f6c65 c2f35d1e2c
Author: navum <email address hidden>
Date: Tue Jul 18 08:58:21 2023 +0000
Fix errors in tacker compliance tests
This patch fixes the bug in tacker compliance test regarding
some tests cases get a failure saying "None is not of type
'string'".
As a solution we have implemented - "After reading value from cription" has the value "None", cription" key and its value. We have
tacker DB, if "vnfInstanceDes
then omit "vnfInstanceDes
implemented this solution because it meets the ETSI specification.
Other solution is modify json schema file in NFV-TST code so that
"null" type is also acceptable like below.
" vnfInstanceDesc ription" : {
"description" : "Human-readable description of the VNF instance.",
"type": ["string", "null"]
}
-> Add "null" type into "vnfInstanceDes cription schema definition.
But, according to NFV-SOL003 specification, the data type of eDescription" is defined only as "string". This means
"vnfInstanc
adding "null" type is out of ETSI specification.
Therefore, we have implemented fix in Tacker's side because fix can
not be handled at NFV-TST side.
Closes-Bug: #2021454 2624977f9fdf5a8 efaf53c8373
Change-Id: Ie058285d15c054