2 # * Copyright 2020 Intel Corporation, Inc
4 # * Licensed under the Apache License, Version 2.0 (the "License");
5 # * you may not use this file except in compliance with the License.
6 # * You may obtain a copy of the License at
8 # * http://www.apache.org/licenses/LICENSE-2.0
10 # * Unless required by applicable law or agreed to in writing, software
11 # * distributed under the License is distributed on an "AS IS" BASIS,
12 # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # * See the License for the specific language governing permissions and
14 # * limitations under the License.
22 source _common_test.sh
27 if [ "$1" == "--external" ]; then
28 master_ip=$(kubectl cluster-info | grep "Kubernetes master" | \
29 awk -F ":" '{print $2}' | awk -F "//" '{print $2}')
30 onap_svc_node_port=30498
31 base_url="http://$master_ip:$onap_svc_node_port/v1"
35 base_url=${base_url:-"http://localhost:9015/v2"}
36 kubeconfig_path="$HOME/.kube/config"
37 csar_id=cb009bfe-bbee-11e8-9766-525400435678
40 project_name="test_project"
41 project_description="test_project_description"
45 composite_app_name="test_composite_app_collection"
46 composite_app_description="test_project_description"
47 composite_app_version="test_composite_app_version"
48 app1_helm_path="$CSAR_DIR/$csar_id/collectd.tar.gz"
49 app2_helm_path="$CSAR_DIR/$csar_id/prometheus.tar.gz"
50 app1_profile_path="$CSAR_DIR/$csar_id/collectd_profile.tar.gz"
51 app2_profile_path="$CSAR_DIR/$csar_id/prometheus_profile.tar.gz"
54 app2_name="prometheus"
55 app1_desc="collectd_desc"
56 app2_desc="prometheus_desc"
58 main_composite_profile_name="main_composite_profile"
59 sub_composite_profile_name1="test_composite_profile1"
60 sub_composite_profile_name2="test_composite_profile2"
61 main_composite_profile_description="main_composite_profile_description"
62 sub_composite_profile_description="sub_composite_profile_description"
64 genericPlacementIntentName="test_gen_placement_intent1"
65 genericPlacementIntentDesc="test_gen_placement_intent_desc"
66 logicalCloud="logical_cloud_name"
68 appIntentNameForApp1="appIntentForApp1"
69 appIntentForApp1Desc="AppIntentForApp1Desc"
70 appIntentNameForApp2="appIntentForApp2"
71 appIntentForApp2Desc="AppIntentForApp2Desc"
76 clusterLabelName1="east-us1"
77 clusterLabelName2="east-us2"
79 deploymentIntentGroupName="test_deployment_intent_group"
80 deploymentIntentGroupNameDesc="test_deployment_intent_group_desc"
82 intentToBeAddedinDeploymentIntentGroup="name_of_intent_to_be_added_in_deployment_group"
83 intentToBeAddedinDeploymentIntentGroupDesc="desc_of_intent_to_be_added_in_deployment_group"
86 profile_name="test_profile"
87 release_name="test-release"
88 namespace="plugin-tests-namespace"
90 cloud_region_owner="localhost"
94 populate_CSAR_composite_app_helm "$csar_id"
96 # BEGIN: Register project API
97 print_msg "Registering project"
101 "name": "${project_name}",
102 "description": "${project_description}",
103 "userData1": "${userData1}",
104 "userData2": "${userData2}"
109 call_api -d "${payload}" "${base_url}/projects"
110 # END: Register project API
112 # BEGIN: Register composite-app API
113 print_msg "Registering composite-app"
117 "name": "${composite_app_name}",
118 "description": "${composite_app_description}",
119 "userData1": "${userData1}",
120 "userData2": "${userData2}"
123 "version":"${composite_app_version}"
128 call_api -d "${payload}" "${base_url}/projects/${project_name}/composite-apps"
129 # END: Register composite-app API
134 # BEGIN: Create entries for app1&app2 in the database
135 print_msg "Making app entry in the database"
139 "name": "${app1_name}",
140 "description": "${app1_desc}",
141 "userData1": "${userData1}",
142 "userData2": "${userData2}"
148 call_api -F "metadata=$payload" \
149 -F "file=@$app1_helm_path" \
150 "${base_url}/projects/${project_name}/composite-apps/${composite_app_name}/${composite_app_version}/apps"
153 # BEGIN: Create an entry for app2 in the database
154 print_msg "Making app entry in the database"
158 "name": "${app2_name}",
159 "description": "${app2_desc}",
160 "userData1": "${userData1}",
161 "userData2": "${userData2}"
167 call_api -F "metadata=$payload" \
168 -F "file=@$app2_helm_path" \
169 "${base_url}/projects/${project_name}/composite-apps/${composite_app_name}/${composite_app_version}/apps"
170 # END: Create entries for app1&app2 in the database
173 # BEGIN: Register the main composite-profile
174 print_msg "Registering the main composite-profile"
178 "name":"${main_composite_profile_name}",
179 "description":"${main_composite_profile_description}",
180 "userData1":"${userData1}",
181 "userData2":"${userData2}"
186 call_api -d "${payload}" "${base_url}/projects/${project_name}/composite-apps/${composite_app_name}/${composite_app_version}/composite-profiles"
187 # BEGIN: Register the main composite-profile
190 # BEGIN : Adding profile to each of the two apps - app1(collectd) and app2(prometheus)
191 print_msg "Registering profile with app1(collectd)"
195 "name":"${sub_composite_profile_name1}",
196 "description":"${sub_composite_profile_description}",
197 "userData1":"${userData1}",
198 "userData2":"${userData2}"
201 "app-name": "${app1_name}"
207 call_api -F "metadata=$payload" \
208 -F "file=@$app1_profile_path" \
209 "${base_url}/projects/${project_name}/composite-apps/${composite_app_name}/${composite_app_version}/composite-profiles/${main_composite_profile_name}/profiles"
211 print_msg "Registering profile with app2(prometheus)"
215 "name":"${sub_composite_profile_name2}",
216 "description":"${sub_composite_profile_description}",
217 "userData1":"${userData1}",
218 "userData2":"${userData2}"
221 "app-name": "${app2_name}"
227 call_api -F "metadata=$payload" \
228 -F "file=@$app2_profile_path" \
229 "${base_url}/projects/${project_name}/composite-apps/${composite_app_name}/${composite_app_version}/composite-profiles/${main_composite_profile_name}/profiles"
230 # END : Adding profile to each of the two apps - app1(collectd) and app2(prometheus)
232 # BEGIN: Register GenericPlacementIntents with the database
233 print_msg "Registering GenericPlacementIntent for app1"
237 "name":"${genericPlacementIntentName}",
238 "description":"${genericPlacementIntentDesc}",
239 "userData1":"${userData1}",
240 "userData2":"${userData2}"
243 "logical-cloud":"${logicalCloud}"
248 call_api -d "${payload}" "${base_url}/projects/${project_name}/composite-apps/${composite_app_name}/${composite_app_version}/generic-placement-intents"
249 # END: Register GenericPlacementIntents with the database
251 # BEGIN: Adding placement intent for each app in the composite app.
252 print_msg "Adding placement intent for app1(collectd)"
256 "name":"${appIntentNameForApp1}",
257 "description":"${appIntentForApp1Desc}",
258 "userData1":"${userData1}",
259 "userData2":"${userData2}"
262 "app-name":"${app1_name}",
265 { "provider-name":"${providerName1}",
266 "cluster-name":"${clusterName1}"
269 "provider-name":"${providerName2}",
270 "cluster-name":"${clusterName2}"
275 "provider-name":"${providerName1}",
276 "cluster-label-name":"${clusterLabelName1}"
279 "provider-name":"${providerName2}",
280 "cluster-label-name":"${clusterLabelName2}"
290 call_api -d "${payload}" "${base_url}/projects/${project_name}/composite-apps/${composite_app_name}/${composite_app_version}/generic-placement-intents/${genericPlacementIntentName}/app-intents"
292 print_msg "Adding placement intent for app2(prometheus)"
296 "name":"${appIntentNameForApp2}",
297 "description":"${appIntentForApp2Desc}",
298 "userData1":"${userData1}",
299 "userData2":"${userData2}"
302 "app-name":"${app2_name}",
306 "provider-name":"${providerName1}",
307 "cluster-name":"${clusterName1}"
310 "provider-name":"${providerName2}",
311 "cluster-name":"${clusterName2}"
316 "provider-name":"${providerName1}",
317 "cluster-label-name":"${clusterLabelName1}"
320 "provider-name":"${providerName2}",
321 "cluster-label-name":"${clusterLabelName2}"
331 call_api -d "${payload}" "${base_url}/projects/${project_name}/composite-apps/${composite_app_name}/${composite_app_version}/generic-placement-intents/${genericPlacementIntentName}/app-intents"
332 # END: Adding placement intent for each app in the composite app.
334 # BEGIN: Registering DeploymentIntentGroup in the database
335 print_msg "Registering DeploymentIntentGroup"
339 "name":"${deploymentIntentGroupName}",
340 "description":"${deploymentIntentGroupNameDesc}",
341 "userData1":"${userData1}",
342 "userData2":"${userData2}"
345 "profile":"${main_composite_profile_name}",
346 "version":"${releaseName}",
349 "app-name":"${app1_name}",
352 "collectd_prometheus.service.targetPort":"9104"
356 "app-name":"${app2_name}",
359 "prometheus.service.nameOfPort":"WebPort9090"
367 call_api -d "${payload}" "${base_url}/projects/${project_name}/composite-apps/${composite_app_name}/${composite_app_version}/deployment-intent-groups"
368 # END: Registering DeploymentIntentGroup in the database
370 # BEGIN: Adding intents to an intent group
371 print_msg "Adding the genericPlacement intent to the deploymentIntent group"
375 "name":"${intentToBeAddedinDeploymentIntentGroup}",
376 "description":"${intentToBeAddedinDeploymentIntentGroupDesc}",
377 "userData1":"${userData1}",
378 "userData2":"${userData2}"
382 "generic-placement-intent":"${genericPlacementIntentName}"
388 call_api -d "${payload}" "${base_url}/projects/${project_name}/composite-apps/${composite_app_name}/${composite_app_version}/deployment-intent-groups/${deploymentIntentGroupName}/intents"
389 # END: Adding intents to an intent group
391 #BEGIN: Instantiation
392 print_msg "Getting the sorted templates for each of the apps.."
393 call_api -d "" "${base_url}/projects/${project_name}/composite-apps/${composite_app_name}/${composite_app_version}/deployment-intent-groups/${deploymentIntentGroupName}/instantiate"