Make ovn-central network interface configurable
[multicloud/k8s.git] / kud / tests / plugin_edgex.sh
1 #!/bin/bash
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2018
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 ##############################################################################
10
11 set -o errexit
12 set -o nounset
13 set -o pipefail
14 #set -o xtrace
15
16 source _common_test.sh
17 source _functions.sh
18
19 base_url="http://localhost:8081/v1/vnf_instances/"
20 cloud_region_id="kud"
21 namespace="default"
22 csar_id=cb009bfe-bbee-11e8-9766-525400435678
23
24 # Setup
25 install_deps
26 _checks_args ${csar_id}
27 cp -R ./edgex/* ${CSAR_DIR}/${csar_id}/
28
29 # Test
30 payload_raw="
31 {
32     \"cloud_region_id\": \"$cloud_region_id\",
33     \"namespace\": \"$namespace\",
34     \"csar_id\": \"$csar_id\"
35 }
36 "
37 payload=$(echo $payload_raw | tr '\n' ' ')
38
39 echo "Creating EdgeX VNF Instance"
40
41 vnf_id=$(curl -s -d "$payload" "${base_url}" | jq -r '.vnf_id')
42
43 echo "=== Validating Kubernetes ==="
44 kubectl get --no-headers=true --namespace=${namespace} deployment ${cloud_region_id}-${namespace}-${vnf_id}-edgex-core-command
45 kubectl get --no-headers=true --namespace=${namespace} service ${cloud_region_id}-${namespace}-${vnf_id}-edgex-core-command
46 echo "VNF Instance created succesfully with id: $vnf_id"
47
48 # TODO: Add heath checks to verify EdgeX services
49
50 vnf_id_list=$(curl -s -X GET "${base_url}${cloud_region_id}/${namespace}" | jq -r '.vnf_id_list')
51 if [[ "$vnf_id_list" != *"${vnf_id}"* ]]; then
52     echo $vnf_id_list
53     echo "VNF Instance not stored"
54     exit 1
55 fi
56
57 vnf_details=$(curl -s -X GET "${base_url}${cloud_region_id}/${namespace}/${vnf_id}")
58 if [[ -z "$vnf_details" ]]; then
59     echo "Cannot retrieved VNF Instance details"
60     exit 1
61 fi
62 echo "VNF details $vnf_details"
63
64 echo "Deleting $vnf_id VNF Instance"
65 curl -X DELETE "${base_url}${cloud_region_id}/${namespace}/${vnf_id}"
66 if [[ -n $(curl -s -X GET "${base_url}${cloud_region_id}/${namespace}/${vnf_id}") ]]; then
67     echo "VNF Instance not deleted"
68     exit 1
69 fi
70
71 # Teardown