Fix Xtesting for API conformance based on NFV-TST 06/10106/5
authorKoichi Edagawa <edagawa.kc@nec.com>
Tue, 13 Dec 2022 04:21:52 +0000 (13:21 +0900)
committerKoichi Edagawa <edagawa.kc@nec.com>
Mon, 19 Dec 2022 00:36:44 +0000 (09:36 +0900)
This patch fixes Xtesting code which was provided in the previous
patch [1].

[1] https://gerrit.o-ran-sc.org/r/c/smo/o2/+/9539/

Issue-ID: SMO-77
Signed-off-by: Koichi Edagawa <edagawa.kc@nec.com>
Change-Id: Icef9bd08e460fc6cf43d7bce6e5098c7615bf18f

tacker/tacker/tests/xtesting/api-tests/SOL003/CNFDeployment/CnfLcmMntOperationKeywords.robot
tacker/tacker/tests/xtesting/api-tests/SOL003/cnflcm/jsons/inst.json
tacker/tacker/tests/xtesting/api-tests/SOL005/CNFPrecondition/packageTest.sh
tacker/tacker/tests/xtesting/api-tests/SOL005/CNFPrecondition/package_with_helm.zip [moved from tacker/tacker/tests/xtesting/api-tests/SOL005/CNFPrecondition/vnfpackage.zip with 80% similarity]
tacker/tacker/tests/xtesting/api-tests/SOL005/CNFPrecondition/package_without_helm.zip [deleted file]
tacker/tacker/tests/xtesting/testcases.yaml

index 70b5246..f7a5d52 100644 (file)
@@ -14,7 +14,7 @@ Library    String
 *** Keywords ***
 Get All Pods
     Log    Status information for all the pods.
-    GET    api/v1/pods
+    GET    ${PODS_SCHEMA}://${PODS_HOST}:${PODS_PORT}/api/v1/pods
     ${outputResponse}=    Output    response
     Log    ${outputResponse}
         Set Global Variable    ${response}    ${outputResponse}
index 0af036e..390fd59 100644 (file)
@@ -1,15 +1,30 @@
 {
-  "flavourId": "simple",
+  "flavourId": "helmchart",
   "additionalParams": {
-    "lcm-kubernetes-def-files": [
-      "Files/kubernetes/deployment.yaml"
+    "namespace": "default",
+    "use_helm": "true",
+    "using_helm_install_param": [
+      {
+        "exthelmchart": "false",
+        "helmchartfile_path": "Files/kubernetes/localhelm-0.1.0.tgz",
+        "helmreleasename": "tacker-test-vdu"
+      }
     ],
-    "namespace": "default"
+    "helm_replica_values": {
+      "vdu1_aspect": "replicaCount"
+    },
+    "vdu_mapping": {
+      "VDU1": {
+        "kind": "Deployment",
+        "name": "vdu1-localhelm",
+        "helmreleasename": "tacker-test-vdu"
+      }
+    }
   },
   "vimConnectionInfo": [
     {
-      "id": "8a3adb69-0784-43c7-833e-aab0b6ab4470",
-      "vimId": "08260b52-c3f6-47a9-bb1f-cec1f0d3956a",
+      "id": "742f1fc7-7f00-417d-85a6-d4e788353181",
+      "vimId": "d7a811a3-e3fb-41a1-a4e2-4dce2209bcfe",
       "vimType": "kubernetes"
     }
   ]
index 46d0f44..77e1db3 100755 (executable)
@@ -1,43 +1,60 @@
 #!/bin/sh
 
 variableFile=$1
+if [ ! $1 ]; then
+        echo "Input parameter is missing"
+        exit 1
+fi
+
 #curl command for token generation
 curl -X POST -H 'Content-Type:application/json' --data '{"auth": {"scope":
-       {"project": {"domain": {"id": "default"}, "name": "nfv"}}, "identity":
-       {"password": {"user": {"domain": {"id": "default"}, "password":
-       "devstack", "name": "nfv_user"}}, "methods": ["password"]}}}' \
-       -i http://localhost/identity/v3/auth/tokens > outtoken 2>&1
+        {"project": {"domain": {"id": "default"}, "name": "nfv"}}, "identity":
+        {"password": {"user": {"domain": {"id": "default"}, "password":
+        "devstack", "name": "nfv_user"}}, "methods": ["password"]}}}' \
+        -i http://localhost/identity/v3/auth/tokens > outtoken 2>&1
 
 dos2unix outtoken 2>/dev/null
 token=$(cat ./outtoken | grep "X-Subject-Token" | cut -d ' ' -f 2)
+rm -rf outtoken
+if [ ! $token ]; then
+        echo "Token extract is failed, please check nfv_user exist or not with admin role"
+        exit 1
+fi
 
 #curl command for vnf package create
-curl -g -i -X POST http://localhost:9890/vnfpkgm/v1/vnf_packages \
-       -H "Accept: application/json" -H "Content-Type: application/json" \
-       -H "X-Auth-Token: $token" -d '{}' > outtoken 2>&1
-dos2unix outtoken 2>/dev/null
-
-Packageid=$(cat ./outtoken | grep id | cut -d ' ' -f 2 |sed 's/.$//'|tail -c +2 | head -c -2)
+Packageid=$(curl -g -X POST http://localhost:9890/vnfpkgm/v1/vnf_packages \
+        -H "Accept: application/json" -H "Content-Type: application/json" \
+        -H "X-Auth-Token: $token" -d '{}' | jq -r .id 2>/dev/null)
 
 echo "$Packageid created"
 #curl command for vnf package upload
 curl -g -i -X PUT http://localhost:9890/vnfpkgm/v1/vnf_packages/$Packageid/package_content \
-       -H "Accept: application/zip" -H "Content-Type: application/zip" \
-       -H "User-Agent: python-tackerclient" -H "X-Auth-Token: $token" --data-binary "@vnfpackage.zip"
-
-echo "$Packageid uploaded"
-
-sleep 1
-curl -g -i -X GET http://localhost:9890/vnfpkgm/v1/vnf_packages/$Packageid \
-       -H "Accept: application/json" -H "User-Agent: python-tackerclient" \
-       -H "X-Auth-Token: $token" > outtoken 2>&1
-dos2unix outtoken 2>/dev/null
-
-vnfdid=$(cat ./outtoken | grep vnfdId | cut -d ' ' -f 15 |sed 's/.$//'|tail -c +2 | head -c -2)
-
-rm -rf outtoken
-sed -i '/${vnfPkgId}/d' $variableFile
-sed -i '/${vnfdId}/d' $variableFile
-
-echo "\${vnfPkgId}     $Packageid" >> $variableFile # $variableFile environment file path where package ID will be added
-echo "\${vnfdId}     $vnfdid" >> $variableFile
+        -H "Accept: application/zip" -H "Content-Type: application/zip" \
+        -H "User-Agent: python-tackerclient" -H "X-Auth-Token: $token" --data-binary "@package_with_helm.zip"
+
+echo "Please wait for 1 minute. Package is onboarding..."
+sleep 1m
+
+onboardedState=null
+onboardedState=$(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 .onboardingState)
+echo "Onboarding state is $onboardedState"
+
+if [ "$onboardedState" = "ONBOARDED" ]; then
+        echo "$Packageid uploaded successfully"
+        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 '/${vnfPkgId}/d' $variableFile
+        sed -i '/${vnfdId}/d' $variableFile
+
+        echo "\${vnfPkgId}     $Packageid" >> $variableFile # $variableFile environment file path where package ID will be added
+        echo "\${vnfdId}     $vnfdid" >> $variableFile
+        exit 0
+
+else
+        echo "$Packageid upload Failed, please check tacker logs"
+        exit 1
+fi
similarity index 80%
rename from tacker/tacker/tests/xtesting/api-tests/SOL005/CNFPrecondition/vnfpackage.zip
rename to tacker/tacker/tests/xtesting/api-tests/SOL005/CNFPrecondition/package_with_helm.zip
index 9c74075..0cc0ac7 100644 (file)
Binary files a/tacker/tacker/tests/xtesting/api-tests/SOL005/CNFPrecondition/vnfpackage.zip and b/tacker/tacker/tests/xtesting/api-tests/SOL005/CNFPrecondition/package_with_helm.zip differ
diff --git a/tacker/tacker/tests/xtesting/api-tests/SOL005/CNFPrecondition/package_without_helm.zip b/tacker/tacker/tests/xtesting/api-tests/SOL005/CNFPrecondition/package_without_helm.zip
deleted file mode 100644 (file)
index 36d497b..0000000
Binary files a/tacker/tacker/tests/xtesting/api-tests/SOL005/CNFPrecondition/package_without_helm.zip and /dev/null differ
index 12582e7..9575cc2 100644 (file)
@@ -3,8 +3,8 @@ tiers:
   - name: samples
     description: ''
     testcases:
-      - case_name: first
-        project_name: xtesting
+      - case_name: cnf-instantiate
+        project_name: smo
         criteria: 100
         blocking: true
         clean_flag: false
@@ -15,8 +15,8 @@ tiers:
             suites:
               - >-
                 /opt/stack/tacker/tacker/tests/xtesting/api-tests/SOL003/cnflcm/cnflcm.robot
-      - case_name: second
-        project_name: xtesting
+      - case_name: cnf-deployments-validation
+        project_name: smo
         criteria: 100
         blocking: true
         clean_flag: false