2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
5 # Copyright © 2021 Samsung Electronics
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
12 # Script respects environment variable SKIP_CNF_TEARDOWN
13 # If set to "yes", it will preserve CNF for manual handling
20 source _common_test.sh
25 if [ "$1" == "--external" ]; then
26 master_ip=$(kubectl cluster-info | grep "Kubernetes master" | \
27 awk -F ":" '{print $2}' | awk -F "//" '{print $2}')
28 onap_svc_node_port=30498
29 base_url="http://$master_ip:$onap_svc_node_port/v1"
33 base_url=${base_url:-"http://localhost:9015/v1"}
34 kubeconfig_path="$HOME/.kube/config"
35 csar_id=cc009bfe-bbee-11e8-9766-525400435678
37 rb_version="plugin_test"
39 profile_name="test_profile"
40 release_name="test-release"
41 namespace="plugin-tests-namespace"
43 cloud_region_owner="localhost"
47 populate_CSAR_fw_rbdefinition "$csar_id"
49 print_msg "Registering resource bundle"
52 "rb-name": "${rb_name}",
53 "rb-version": "${rb_version}",
54 "chart-name": "${chart_name}"
58 call_api -d "${payload}" "${base_url}/rb/definition"
60 print_msg "Uploading resource bundle content"
61 call_api --data-binary "@${CSAR_DIR}/${csar_id}/rb_definition.tar.gz" \
62 "${base_url}/rb/definition/${rb_name}/${rb_version}/content"
64 print_msg "Registering rb's profile"
67 "rb-name": "${rb_name}",
68 "rb-version": "${rb_version}",
69 "profile-name": "${profile_name}",
70 "release-name": "dummy",
71 "namespace": "${namespace}"
75 call_api -d "${payload}" "${base_url}/rb/definition/${rb_name}/${rb_version}/profile"
77 print_msg "Uploading profile data"
78 call_api --data-binary "@${CSAR_DIR}/${csar_id}/rb_profile.tar.gz" \
79 "${base_url}/rb/definition/${rb_name}/${rb_version}/profile/${profile_name}/content"
81 print_msg "Setup cloud data"
84 "cloud-region": "$cloud_region_id",
85 "cloud-owner": "$cloud_region_owner"
89 call_api -F "metadata=$payload" \
90 -F "file=@$kubeconfig_path" \
91 "${base_url}/connectivity-info" >/dev/null #massive output
93 print_msg "Creating vFW VNF Instance"
96 "rb-name": "${rb_name}",
97 "rb-version": "${rb_version}",
98 "profile-name": "${profile_name}",
99 "release-name": "${release_name}",
100 "cloud-region": "${cloud_region_id}",
101 "labels": {"testCaseName": "plugin_fw.sh"},
102 "override-values": {"global.onapPrivateNetworkName": "onap-private-net-test"}
106 response="$(call_api -d "${payload}" "${base_url}/instance")"
108 vnf_id="$(jq -r '.id' <<< "${response}")"
110 print_msg "[BEGIN] Basic checks for instantiated resource"
111 print_msg "Check if override value has been applied correctly"
112 kubectl get network -n "${namespace}" onap-private-net-test
113 print_msg "Wait for all pods to start"
114 wait_for_pod -n "${namespace}" -l app=sink
115 wait_for_pod -n "${namespace}" -l app=firewall
116 wait_for_pod -n "${namespace}" -l app=packetgen
117 # TODO: Provide some health check to verify vFW work
118 print_msg "Not waiting for vFW to fully install as no further checks are implemented in testcase"
119 #print_msg "Waiting 8minutes for vFW installation"
121 print_msg "[END] Basic checks for instantiated resource"
123 print_msg "Retrieving VNF status (this will result with long output)"
124 call_api "${base_url}/instance/${vnf_id}/status"
126 print_msg "Retrieving VNF details"
127 response="$(call_api "${base_url}/instance/${vnf_id}")"
129 print_msg "Assert additional label has been assigned to rb instance"
130 test "$(jq -r '.request.labels.testCaseName' <<< "${response}")" == plugin_fw.sh
131 print_msg "Assert ReleaseName has been correctly overriden"
132 test "$(jq -r '.request."release-name"' <<< "${response}")" == "${release_name}"
135 if [ "${SKIP_CNF_TEARDOWN:-}" == "yes" ]; then
136 print_msg "Leaving CNF running for further debugging"
137 echo "Remember to later issue following DELETE calls to clean environment"
139 curl -X DELETE "${base_url}/instance/${vnf_id}"
140 curl -X DELETE "${base_url}/rb/definition/${rb_name}/${rb_version}/profile/${profile_name}"
141 curl -X DELETE "${base_url}/rb/definition/${rb_name}/${rb_version}"
142 curl -X DELETE "${base_url}/connectivity-info/${cloud_region_id}"
145 print_msg "Deleting VNF Instance"
146 delete_resource "${base_url}/instance/${vnf_id}"
148 print_msg "Deleting Profile"
149 delete_resource "${base_url}/rb/definition/${rb_name}/${rb_version}/profile/${profile_name}"
151 print_msg "Deleting Resource Bundle"
152 delete_resource "${base_url}/rb/definition/${rb_name}/${rb_version}"
154 print_msg "Deleting ${cloud_region_id} cloud region connection"
155 delete_resource "${base_url}/connectivity-info/${cloud_region_id}"
157 print_msg "Test finished successfully"