2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
16 source _common_test.sh
20 base_url="http://localhost:9015/v1"
21 kubeconfig_path="$HOME/.kube/config"
22 csar_id=cb009bfe-bbee-11e8-9766-525400435678
24 rb_version="plugin_test"
26 profile_name="test_profile"
27 release_name="test-release"
28 namespace="plugin-tests-namespace"
30 cloud_region_owner="localhost"
34 populate_CSAR_edgex_rbdefinition "$csar_id"
36 print_msg "Registering resource bundle"
39 "rb-name": "${rb_name}",
40 "rb-version": "${rb_version}",
41 "chart-name": "${chart_name}"
45 call_api -d "${payload}" "${base_url}/rb/definition"
47 print_msg "Uploading resource bundle content"
48 call_api --data-binary "@${CSAR_DIR}/${csar_id}/rb_definition.tar.gz" \
49 "${base_url}/rb/definition/${rb_name}/${rb_version}/content"
51 print_msg "Registering rb's profile"
54 "rb-name": "${rb_name}",
55 "rb-version": "${rb_version}",
56 "profile-name": "${profile_name}",
57 "release-name": "${release_name}",
58 "namespace": "${namespace}"
62 call_api -d "${payload}" "${base_url}/rb/definition/${rb_name}/${rb_version}/profile"
64 print_msg "Uploading profile data"
65 call_api --data-binary "@${CSAR_DIR}/${csar_id}/rb_profile.tar.gz" \
66 "${base_url}/rb/definition/${rb_name}/${rb_version}/profile/${profile_name}/content"
68 print_msg "Setup cloud data"
71 "cloud-region": "$cloud_region_id",
72 "cloud-owner": "$cloud_region_owner"
76 call_api -F "metadata=$payload" \
77 -F "file=@$kubeconfig_path" \
78 "${base_url}/connectivity-info" >/dev/null #massive output
80 print_msg "Creating EdgeX VNF Instance"
83 "rb-name": "${rb_name}",
84 "rb-version": "${rb_version}",
85 "profile-name": "${profile_name}",
86 "cloud-region": "${cloud_region_id}"
90 response="$(call_api -d "${payload}" "${base_url}/instance")"
92 vnf_id="$(jq -r '.id' <<< "${response}")"
94 print_msg "Validating Kubernetes"
95 kubectl get --no-headers=true --namespace=${namespace} deployment edgex-core-command
96 kubectl get --no-headers=true --namespace=${namespace} service edgex-core-command
97 # TODO: Add health checks to verify EdgeX services
99 print_msg "Retrieving VNF details"
100 call_api "${base_url}/instance/${vnf_id}"
104 print_msg "Deleting VNF Instance"
105 delete_resource "${base_url}/instance/${vnf_id}"
107 print_msg "Deleting Profile"
108 delete_resource "${base_url}/rb/definition/${rb_name}/${rb_version}/profile/${profile_name}"
110 print_msg "Deleting Resource Bundle"
111 delete_resource "${base_url}/rb/definition/${rb_name}/${rb_version}"
113 print_msg "Deleting ${cloud_region_id} cloud region connection"
114 delete_resource "${base_url}/connectivity-info/${cloud_region_id}"