Add Heal VNFC conformance test in Xtesting 88/11888/8
authorKoichi Edagawa <edagawa.kc@nec.com>
Wed, 11 Oct 2023 10:28:22 +0000 (19:28 +0900)
committerAshutosh Mishra <ashutosh.mishra1@india.nec.com>
Thu, 18 Jan 2024 08:01:58 +0000 (08:01 +0000)
This patch adds a new conformance test for healing VNFC based on
ETSI NFV-TST 010 specification with Xtesting.

Issue-ID: SMO-119
Change-Id: Ie30b396256c40489f179efe9ebf471f08657362d
Signed-off-by: Koichi Edagawa <edagawa.kc@nec.com>
docs/developer-guide.rst
tacker/tacker/tests/xtesting/api-tests/SOL002/cnflcm/PrepareHealVnfc.robot [new file with mode: 0644]
tacker/tacker/tests/xtesting/api-tests/SOL005/CNFPrecondition/packageTest.sh
tacker/tacker/tests/xtesting/testcases.yaml

index 3e3b505..567409d 100644 (file)
@@ -81,6 +81,7 @@ The following steps are the procedure of API conformance test according to the s
 
       .. code:: bash
 
+         $ cp -r /tmp/o2/tacker/tacker/tests/xtesting/api-tests/SOL002/cnflcm ./api-tests/SOL002
          $ cp -r /tmp/o2/tacker/tacker/tests/xtesting/api-tests/SOL003/CNFDeployment ./api-tests/SOL003
          $ cp -r /tmp/o2/tacker/tacker/tests/xtesting/api-tests/SOL003/cnflcm ./api-tests/SOL003
          $ cp -r /tmp/o2/tacker/tacker/tests/xtesting/api-tests/SOL005/CNFPrecondition ./api-tests/SOL005
@@ -114,6 +115,7 @@ The following steps are the procedure of API conformance test according to the s
       .. code:: bash
 
          $ cp ./api-tests/SOL003/VNFLifecycleManagement-API/jsons/healVnfRequest.json ./jsons
+         $ cp ./api-tests/SOL003/VNFLifecycleManagement-API/jsons/healVnfRequest.json ./jsons/healVnfcRequest.json
          $ mkdir schemas
          $ cp ./api-tests/SOL003/VNFLifecycleManagement-API/schemas/vnfInstance.schema.json ./schemas
 
@@ -145,7 +147,7 @@ The following steps are the procedure of API conformance test according to the s
       .. code:: bash
 
          $ cd ~/tacker/tacker/tests/xtesting/api-tests/SOL005/CNFPrecondition
-         $ ./packageTest.sh ../../SOL003/VNFLifecycleManagement-API/environment/configuration.txt
+         $ ./packageTest.sh
 
    5. Get 'vnfdId' and change it in the file 'createVnfRequest.json' as below.
 
@@ -287,7 +289,13 @@ The following steps are the procedure of API conformance test according to the s
             |   cnf-deployments-validation  |       smo       |      00:01       |      PASS      |
             +-------------------------------+-----------------+------------------+----------------+
 
-   3. For Re-testing, user must delete all the VNF instances and packages created in the above test. An example of steps is below.
+   3. Revert all the changes in json files for Re-testing.
+
+      .. code:: bash
+
+         $ cp ./api-tests/SOL003/VNFLifecycleManagement-API/jsons/healVnfRequest.json ./jsons/healVnfRequest.json
+
+   4. For Re-testing, user must delete all the VNF instances and packages created in the above test. An example of steps is below.
 
       .. code:: bash
 
diff --git a/tacker/tacker/tests/xtesting/api-tests/SOL002/cnflcm/PrepareHealVnfc.robot b/tacker/tacker/tests/xtesting/api-tests/SOL002/cnflcm/PrepareHealVnfc.robot
new file mode 100644 (file)
index 0000000..1ce3b14
--- /dev/null
@@ -0,0 +1,35 @@
+*** Settings ***
+Resource    ../VNFLifecycleManagement-API/environment/variables.txt
+Library    REST    ${VNFM_SCHEMA}://${VNFM_HOST}:${VNFM_PORT}     ssl_verify=false
+Library    JSONLibrary
+Library    OperatingSystem
+Library    Process
+Library    Collections
+Library    String
+
+*** Test Cases ***
+GET VNFC Instance Id
+    [Documentation]    Test ID: 6.3.4.9.3
+    ...    Test title: GET VNFC Instance Id
+    ...    Test objective: The objective is to Get the VNF Instance Id
+    ...    Pre-conditions: none
+    ...    Applicability: none
+    ...    Post-Conditions: none
+    Get VNFC Instance Id
+
+*** Keywords ***
+Get VNFC Instance Id
+    log    Trying to perform a GET. This keyword is defined for fetching the Vnfc Instance ID.
+    Set Headers    {"Accept":"${ACCEPT}"}
+    Set Headers    {"Content-Type": "${CONTENT_TYPE}"}
+    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
+    Get    ${apiRoot}/${apiName}/${apiVersion}/vnf_instances/${vnfInstanceId}
+    ${outputResponse}=    Output    response
+    ${body} =    Get From Dictionary     ${outputResponse}    body
+    ${instantiatedVnfInfo} =    Get From Dictionary    ${body}    instantiatedVnfInfo
+    ${vnfcResourceInfo} =    Get From Dictionary    ${instantiatedVnfInfo}    vnfcResourceInfo
+    ${dict} =    Get From List    ${vnfcResourceInfo}    0
+    ${vnfc_id} =    Get From Dictionary    ${dict}    id
+    ${json_file_path} =    Set Variable    jsons/healVnfRequest.json
+    Run Keyword And Ignore Error    Run    jq '.cause = "healing" | .vnfcInstanceId = ["${vnfc_id}"]' "${json_file_path}" > "${json_file_path}.tmp"
+    Run Process  mv  ${json_file_path}.tmp    ${json_file_path}    shell=yes
index db33846..20a21aa 100755 (executable)
@@ -1,10 +1,7 @@
 #!/bin/sh
 
-variableFile=$1    # file path of configuration.txt in which environmental variables should be updated
-if [ ! $1 ]; then
-        echo "Input parameter is missing"
-        exit 1
-fi
+sol002VariableFile=../../SOL002/VNFLifecycleManagement-API/environment/variables.txt
+sol003VariableFile=../../SOL003/VNFLifecycleManagement-API/environment/configuration.txt
 
 #curl command for token generation
 curl -X POST -H 'Content-Type:application/json' --data '{"auth": {"scope":
@@ -48,19 +45,36 @@ else
         exit 1
 fi
 
-#update environmental variables in configuration.txt
-sed -i '/${vnfPkgId}/d' $variableFile
-sed -i '/${AUTHORIZATION_HEADER}/d' $variableFile
-sed -i '/${AUTHORIZATION_TOKEN}/d' $variableFile
-sed -i '/${VNFM_PORT}/d' $variableFile
-sed -i '/${VNFM_SCHEMA}/d' $variableFile
-
-echo "" >> $variableFile
-echo "\${vnfPkgId}     $Packageid" >> $variableFile
-echo "\${AUTHORIZATION_HEADER}    X-Auth-Token" >> $variableFile
-echo "\${AUTHORIZATION_TOKEN}     $token" >> $variableFile
-echo "\${VNFM_PORT}      9890" >> $variableFile
-echo "\${VNFM_SCHEMA}    http" >> $variableFile
+#update environmental variables in variables.txt
+vnfdid=$(curl -g -X GET http://localhost:9890/vnfpkgm/v1/vnf_packages/$Packageid \
+        -H "Accept: application/json" -H "User-Agent: python-tackerclient" \
+        -H "X-Auth-Token: $token" | jq -r .vnfdId)
+
+sed -i '/${AUTHORIZATION_HEADER}/d' $sol002VariableFile
+sed -i '/${AUTHORIZATION_TOKEN}/d' $sol002VariableFile
+sed -i '/${VNFM_PORT}/d' $sol002VariableFile
+sed -i '/${VNFM_SCHEMA}/d' $sol002VariableFile
+
+echo "" >> $sol002VariableFile
+echo "\${AUTHORIZATION_HEADER}    X-Auth-Token" >> $sol002VariableFile
+echo "\${AUTHORIZATION_TOKEN}     $token" >> $sol002VariableFile
+echo "\${VNFM_PORT}      9890" >> $sol002VariableFile
+echo "\${VNFM_SCHEMA}    http" >> $sol002VariableFile
+
+sed -i '/${vnfPkgId}/d' $sol003VariableFile
+sed -i '/${vnfdId}/d' $sol003VariableFile
+sed -i '/${AUTHORIZATION_HEADER}/d' $sol003VariableFile
+sed -i '/${AUTHORIZATION_TOKEN}/d' $sol003VariableFile
+sed -i '/${VNFM_PORT}/d' $sol003VariableFile
+sed -i '/${VNFM_SCHEMA}/d' $sol003VariableFile
+
+echo "" >> $sol003VariableFile
+echo "\${vnfPkgId}     $Packageid" >> $sol003VariableFile
+echo "\${vnfdId}     $vnfdid" >> $sol003VariableFile
+echo "\${AUTHORIZATION_HEADER}    X-Auth-Token" >> $sol003VariableFile
+echo "\${AUTHORIZATION_TOKEN}     $token" >> $sol003VariableFile
+echo "\${VNFM_PORT}      9890" >> $sol003VariableFile
+echo "\${VNFM_SCHEMA}    http" >> $sol003VariableFile
 
 #comment out test cases in api-tests
 # TODO: Although the bug in the test case "Check Individual VNF LCM operation occurrence operationState is"
@@ -99,4 +113,25 @@ insertSteps="\    \${res_body}=    Get From Dictionary     \${outputResponse}
 Command="sed -i '$((lineNo))i $insertSteps' $robotFile"
 eval "$Command"
 
+#comment out test cases in api-tests which are unnecessary for conformance test
+robotFile=../../SOL003/VNFLifecycleManagement-API/VNFInstances.robot
+lineNo=`cat -n $robotFile | sed -n '/POST Create a new vnfInstance/,$p' | grep -E '^([0-9]|[[:space:]])+$' | head -1`
+insertSteps="*** comment ***"
+Command="sed -i '$((lineNo))a $insertSteps' $robotFile"
+eval "$Command"
+
+robotFile=../../SOL002/VNFLifecycleManagement-API/HealVNFTask.robot
+lineNo=`cat -n $robotFile | sed -n '/POST Heal a vnfInstance/,$p' | grep -E '^([0-9]|[[:space:]])+$' | head -1`
+insertSteps="*** comment ***"
+Command="sed -i '$((lineNo))a $insertSteps' $robotFile"
+eval "$Command"
+
+#modify api-tests code so that vnfInstanceId is treated as global variable
+# TODO: After the modification is officially done in api-tests by ETSI NFV TST, we need to remove below step.
+robotFile=../../SOL003/VNFLifecycleManagement-API/VnfLcmMntOperationKeywords.robot
+lineNo=`cat -n $robotFile | sed -n '/POST Create a new vnfInstance/,$p' | grep -E '^([0-9]|[[:space:]])+$' | head -1`
+insertSteps="\    \${res_body}=    Get From Dictionary     \${outputResponse}    body\n    \${res_id}=    Get From Dictionary     \${res_body}    id\n    Set Global Variable    \${vnfInstanceId}     \${res_id}"
+Command="sed -i '$((lineNo))i $insertSteps' $robotFile"
+eval "$Command"
+
 exit 0
index 727437b..ab33f53 100644 (file)
@@ -17,6 +17,9 @@ tiers:
                 - /opt/stack/tacker/tacker/tests/xtesting/api-tests/SOL003/VNFLifecycleManagement-API/InstantiateVNFTask.robot
                 - /opt/stack/tacker/tacker/tests/xtesting/api-tests/SOL003/cnflcm/SleepTestCase.robot
                 - /opt/stack/tacker/tacker/tests/xtesting/api-tests/SOL003/VNFLifecycleManagement-API/HealVNFTask.robot
+                - /opt/stack/tacker/tacker/tests/xtesting/api-tests/SOL003/cnflcm/SleepTestCase.robot
+                - /opt/stack/tacker/tacker/tests/xtesting/api-tests/SOL002/cnflcm/PrepareHealVnfc.robot
+                - /opt/stack/tacker/tacker/tests/xtesting/api-tests/SOL002/VNFLifecycleManagement-API/HealVNFTask.robot
       - case_name: cnf-deployments-validation
         project_name: smo
         criteria: 100