diff options
Diffstat (limited to 'kud')
-rw-r--r-- | kud/README.md | 10 | ||||
-rw-r--r-- | kud/demo/firewall/charts/packetgen/values.yaml | 2 | ||||
-rw-r--r-- | kud/demo/firewall/charts/sink/templates/configmap.yaml | 2 | ||||
-rw-r--r-- | kud/demo/firewall/charts/sink/values.yaml | 3 | ||||
-rw-r--r-- | kud/demo/firewall/values.yaml | 2 | ||||
-rw-r--r-- | kud/deployment_infra/galaxy-requirements.yml | 2 | ||||
-rw-r--r-- | kud/deployment_infra/playbooks/configure-kud.yml | 5 | ||||
-rw-r--r-- | kud/deployment_infra/playbooks/configure-multus.yml | 38 | ||||
-rw-r--r-- | kud/deployment_infra/playbooks/configure-ovn4nfv.yml | 8 | ||||
-rw-r--r-- | kud/deployment_infra/playbooks/kud-vars.yml | 4 | ||||
-rwxr-xr-x | kud/hosting_providers/vagrant/installer.sh | 2 | ||||
-rwxr-xr-x | kud/tests/_common.sh | 42 | ||||
-rwxr-xr-x | kud/tests/_functions.sh | 54 | ||||
-rwxr-xr-x | kud/tests/plugin.sh | 75 | ||||
-rwxr-xr-x | kud/tests/plugin_edgex.sh | 134 | ||||
-rwxr-xr-x | kud/tests/plugin_fw.sh | 116 | ||||
-rw-r--r-- | kud/tests/vnfs/edgex/profile/manifest.yaml | 4 | ||||
-rw-r--r-- | kud/tests/vnfs/edgex/profile/override_values.yaml | 1 |
18 files changed, 367 insertions, 137 deletions
diff --git a/kud/README.md b/kud/README.md index 99805c3c..caa731dc 100644 --- a/kud/README.md +++ b/kud/README.md @@ -30,8 +30,8 @@ Apache-2.0 [1]: https://git.onap.org/multicloud/k8s [2]: https://github.com/kubernetes-incubator/kubespray -[3]: playbooks/configure-ovn4nfv.yml -[4]: playbooks/configure-virtlet.yml -[5]: playbooks/configure-multus.yml -[6]: playbooks/configure-nfd.yml -[7]: playbooks/configure-istio.yml +[3]: deployment_infra/playbooks/configure-ovn4nfv.yml +[4]: deployment_infra/playbooks/configure-virtlet.yml +[5]: deployment_infra/playbooks/configure-multus.yml +[6]: deployment_infra/playbooks/configure-nfd.yml +[7]: deployment_infra/playbooks/configure-istio.yml diff --git a/kud/demo/firewall/charts/packetgen/values.yaml b/kud/demo/firewall/charts/packetgen/values.yaml index d79e5485..3df94080 100644 --- a/kud/demo/firewall/charts/packetgen/values.yaml +++ b/kud/demo/firewall/charts/packetgen/values.yaml @@ -7,7 +7,7 @@ replicaCount: 1 image: repository: virtlet.cloud/ubuntu/16.04 tag: latest - pullPolicy: Always + pullPolicy: IfNotPresent nameOverride: "" fullnameOverride: "" diff --git a/kud/demo/firewall/charts/sink/templates/configmap.yaml b/kud/demo/firewall/charts/sink/templates/configmap.yaml index 95a30513..89be1f77 100644 --- a/kud/demo/firewall/charts/sink/templates/configmap.yaml +++ b/kud/demo/firewall/charts/sink/templates/configmap.yaml @@ -1,4 +1,4 @@ -piVersion: v1 +apiVersion: v1 kind: ConfigMap metadata: name: {{ include "sink.name" .}}-configmap diff --git a/kud/demo/firewall/charts/sink/values.yaml b/kud/demo/firewall/charts/sink/values.yaml index e2608e2f..8a70889a 100644 --- a/kud/demo/firewall/charts/sink/values.yaml +++ b/kud/demo/firewall/charts/sink/values.yaml @@ -7,10 +7,9 @@ replicaCount: 1 image: sinkrepo: rtsood/onap-vfw-demo-sink sinktag: 0.2.0 - pullPolicy: Always + pullPolicy: IfNotPresent darkstatrepo: electrocucaracha/darkstat darkstattag: latest - pullPolicy: Always nameOverride: "" fullnameOverride: "" diff --git a/kud/demo/firewall/values.yaml b/kud/demo/firewall/values.yaml index 4c0431be..abc39f01 100644 --- a/kud/demo/firewall/values.yaml +++ b/kud/demo/firewall/values.yaml @@ -7,7 +7,7 @@ replicaCount: 1 image: repository: virtlet.cloud/ubuntu/16.04 tag: latest - pullPolicy: Always + pullPolicy: IfNotPresent nameOverride: "" fullnameOverride: "" diff --git a/kud/deployment_infra/galaxy-requirements.yml b/kud/deployment_infra/galaxy-requirements.yml index 093dec87..17ac1dc2 100644 --- a/kud/deployment_infra/galaxy-requirements.yml +++ b/kud/deployment_infra/galaxy-requirements.yml @@ -8,7 +8,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## - src: andrewrothstein.go - version: v2.1.10 + version: v2.1.15 - src: andrewrothstein.kubernetes-helm version: v1.2.9 - src: geerlingguy.docker diff --git a/kud/deployment_infra/playbooks/configure-kud.yml b/kud/deployment_infra/playbooks/configure-kud.yml index 0e32e69d..6ac0477d 100644 --- a/kud/deployment_infra/playbooks/configure-kud.yml +++ b/kud/deployment_infra/playbooks/configure-kud.yml @@ -23,6 +23,11 @@ when: helm_client.rc != 0 vars: kubernetes_helm_ver: "v{{ helm_client_version }}" + tasks: + - name: Initialize helm client + command: helm init -c + args: + creates: ~/.helm - hosts: kube-node become: yes diff --git a/kud/deployment_infra/playbooks/configure-multus.yml b/kud/deployment_infra/playbooks/configure-multus.yml index 9cca54d1..47109162 100644 --- a/kud/deployment_infra/playbooks/configure-multus.yml +++ b/kud/deployment_infra/playbooks/configure-multus.yml @@ -62,27 +62,25 @@ mode: 0755 when: multus_source_type == "tarball" - name: create multus configuration file - blockinfile: - marker: "" - path: /etc/cni/net.d/00-multus.conf - create: yes - block: | - { - "type": "multus", - "name": "multus-cni", - "cniVersion": "0.3.1", - "kubeconfig": "/etc/kubernetes/admin.conf", - "delegates": [ - { - "type": "flannel", + copy: + dest: /etc/cni/net.d/00-multus.conf + content: | + { + "type": "multus", + "name": "multus-cni", "cniVersion": "0.3.1", - "masterplugin": true, - "delegate": { - "isDefaultGateway": true - } - } - ] - } + "kubeconfig": "/etc/kubernetes/admin.conf", + "delegates": [ + { + "type": "flannel", + "cniVersion": "0.3.1", + "masterplugin": true, + "delegate": { + "isDefaultGateway": true + } + } + ] + } - hosts: localhost pre_tasks: diff --git a/kud/deployment_infra/playbooks/configure-ovn4nfv.yml b/kud/deployment_infra/playbooks/configure-ovn4nfv.yml index 2d1a11d0..2084c95d 100644 --- a/kud/deployment_infra/playbooks/configure-ovn4nfv.yml +++ b/kud/deployment_infra/playbooks/configure-ovn4nfv.yml @@ -13,12 +13,14 @@ - hosts: kube-master:kube-node environment: PATH: "{{ ansible_env.PATH }}:/usr/local/go/bin/" - roles: - - role: andrewrothstein.go - tasks: + pre_tasks: - name: Load kud variables include_vars: file: kud-vars.yml + roles: + - role: andrewrothstein.go + go_ver: "{{ go_version }}" + tasks: - name: clone ovn4nfv-k8s-plugin repo git: repo: "{{ ovn4nfv_url }}" diff --git a/kud/deployment_infra/playbooks/kud-vars.yml b/kud/deployment_infra/playbooks/kud-vars.yml index b11672f3..9b365477 100644 --- a/kud/deployment_infra/playbooks/kud-vars.yml +++ b/kud/deployment_infra/playbooks/kud-vars.yml @@ -54,10 +54,10 @@ istio_url: "https://github.com/istio/istio/releases/download/{{ istio_version }} go_path: "{{ base_dest }}/go" ovn4nfv_dest: "{{ go_path }}/src/ovn4nfv-k8s-plugin" ovn4nfv_source_type: "source" -ovn4nfv_version: aa14577f6bc672bc8622edada8a487825fdebce1 +ovn4nfv_version: adc7b2d430c44aa4137ac7f9420e14cfce3fa354 ovn4nfv_url: "https://git.opnfv.org/ovn4nfv-k8s-plugin/" -go_version: '1.12.4' +go_version: '1.12.5' kubespray_version: 2.8.2 helm_client_version: 2.9.1 # kud playbooks not compatible with 2.8.0 - see MULTICLOUD-634 diff --git a/kud/hosting_providers/vagrant/installer.sh b/kud/hosting_providers/vagrant/installer.sh index c9027150..51ca22e8 100755 --- a/kud/hosting_providers/vagrant/installer.sh +++ b/kud/hosting_providers/vagrant/installer.sh @@ -176,7 +176,7 @@ function install_plugin { if [[ "${testing_enabled}" == "true" ]]; then sudo ./start.sh pushd $kud_tests - for functional_test in plugin plugin_edgex; do + for functional_test in plugin plugin_edgex plugin_fw; do bash ${functional_test}.sh done popd diff --git a/kud/tests/_common.sh b/kud/tests/_common.sh index 3120dad7..044891dd 100755 --- a/kud/tests/_common.sh +++ b/kud/tests/_common.sh @@ -27,10 +27,8 @@ unprotected_private_net=unprotected-private-net protected_private_net=protected-private-net ovn_multus_network_name=ovn-networkobj rbd_metadata=rbd_metatada.json -rbd_content_tarball=vault-consul-dev.tar rbp_metadata=rbp_metatada.json rbp_instance=rbp_instance.json -rbp_content_tarball=profile.tar # vFirewall vars demo_artifacts_version=1.5.0 @@ -1119,16 +1117,38 @@ DEPLOYMENT # populate_CSAR_rbdefinition() - Function that populates CSAR folder # for testing resource bundle definition function populate_CSAR_rbdefinition { - local csar_id=$1 + _checks_args "$1" + pushd "${CSAR_DIR}/$1" + print_msg "Create Helm Chart Archives" + rm -f *.tar.gz + tar -czf rb_profile.tar.gz -C $test_folder/vnfs/testrb/helm/profile . + #Creates vault-consul-dev-0.0.0.tgz + helm package $test_folder/vnfs/testrb/helm/vault-consul-dev --version 0.0.0 + popd +} - _checks_args $csar_id - pushd ${CSAR_DIR}/${csar_id} +# populate_CSAR_edgex_rbdefinition() - Function that populates CSAR folder +# for testing resource bundle definition of edgex scenario +function populate_CSAR_edgex_rbdefinition { + _checks_args "$1" + pushd "${CSAR_DIR}/$1" print_msg "Create Helm Chart Archives" - rm -f ${rbd_content_tarball}.gz - rm -f ${rbp_content_tarball}.gz - tar -cf $rbd_content_tarball -C $test_folder/vnfs/testrb/helm vault-consul-dev - tar -cf $rbp_content_tarball -C $test_folder/vnfs/testrb/helm/profile . - gzip $rbp_content_tarball - gzip $rbd_content_tarball + rm -f *.tar.gz + tar -czf rb_profile.tar.gz -C $test_folder/vnfs/edgex/profile . + tar -czf rb_definition.tar.gz -C $test_folder/vnfs/edgex/helm edgex popd } + +# populate_CSAR_fw_rbdefinition() - Function that populates CSAR folder +# for testing resource bundle definition of firewall scenario +function populate_CSAR_fw_rbdefinition { + _checks_args "$1" + pushd "${CSAR_DIR}/$1" + print_msg "Create Helm Chart Archives for vFirewall" + rm -f *.tar.gz + # Reuse profile from the edgeX case as it is an empty profile + tar -czf rb_profile.tar.gz -C $test_folder/vnfs/edgex/profile . + tar -czf rb_definition.tar.gz -C $test_folder/../demo firewall + popd +} + diff --git a/kud/tests/_functions.sh b/kud/tests/_functions.sh index 483aed5c..d585086b 100755 --- a/kud/tests/_functions.sh +++ b/kud/tests/_functions.sh @@ -25,12 +25,36 @@ function print_msg { } function get_ovn_central_address { - ansible_ifconfig=$(ansible ovn-central[0] -i ${FUNCTIONS_DIR}/../hosting_providers/vagrant/inventory/hosts.ini -m shell -a "ifconfig ${OVN_CENTRAL_INTERFACE} |grep \"inet addr\" |awk '{print \$2}' |awk -F: '{print \$2}'") - if [[ $ansible_ifconfig != *CHANGED* ]]; then - echo "Fail to get the OVN central IP address from ${OVN_CENTRAL_INTERFACE} nic" - exit + #Reuse OVN_CENTRAL_ADDRESS if available (bypassable by --force flag) + if [[ "${1:-}" != "--force" ]] && [[ -n "${OVN_CENTRAL_ADDRESS:-}" ]]; then + echo "${OVN_CENTRAL_ADDRESS}" + return 0 + fi + + local remote_command="ip address show dev $OVN_CENTRAL_INTERFACE primary" + declare -a ansible_command=(ansible ovn-central[0] -i \ + "${FUNCTIONS_DIR}/../hosting_providers/vagrant/inventory/hosts.ini") + declare -a filter=(awk -F '[ \t/]+' \ + 'BEGIN {r=1} {for (i=1; i<=NF; i++) if ($i == "inet") {print $(i+1); r=0}} END {exit r}') + local result + + #Determine OVN_CENTRAL_INTERFACE address + if ! result="$("${ansible_command[@]}" -a "${remote_command}")"; then + echo "Ansible error for remote host ovn-central[0]" >&2 + return 1 + else + if [[ "${result}" != *CHANGED* ]]; then + echo "Failed to execute command on remote host ovn-central[0]" >&2 + return 2 + else + if ! result="$("${filter[@]}" <<< "${result}")"; then + echo "Failed to retrieve interface address from command output" >&2 + return 3 + else + echo "${result}:6641" + fi + fi fi - echo "$(echo ${ansible_ifconfig#*>>} | tr '\n' ':')6641" } function call_api { @@ -149,6 +173,26 @@ function wait_deployment { done } +# wait_for_pod() - Wait until first pod matched by kubectl filters is in running status +function wait_for_pod { + #Example usage: + # wait_for_pods example_pod + # wait_for_pods --namespace test different_pod + # wait_for_pods -n test -l app=plugin_test + + status_phase="" + while [[ "$status_phase" != "Running" ]]; do + new_phase="$(kubectl get pods -o 'go-template={{ index .items 0 "status" "phase" }}' "$@" )" + if [[ "$new_phase" != "$status_phase" ]]; then + echo "$(date +%H:%M:%S) - Filter=[$*] : $new_phase" + status_phase="$new_phase" + fi + if [[ "$new_phase" == "Err"* ]]; then + exit 1 + fi + done +} + # setup() - Base testing setup shared among functional tests function setup { if ! $(kubectl version &>/dev/null); then diff --git a/kud/tests/plugin.sh b/kud/tests/plugin.sh index af74af5f..aff04128 100755 --- a/kud/tests/plugin.sh +++ b/kud/tests/plugin.sh @@ -17,9 +17,11 @@ source _common.sh source _common_test.sh source _functions.sh -base_url="http://localhost:8081" +base_url="http://localhost:9015/v1" +kubeconfig_path="$HOME/.kube/config" #Will resolve to file $KUBE_CONFIG_DIR/kud cloud_region_id="kud" +cloud_region_owner="test_owner" namespace="testns" csar_id="94e414f6-9ca4-11e8-bb6a-52540067263b" rb_name="test-rbdef" @@ -34,10 +36,10 @@ function _build_generic_sim { return fi BUILD_ARGS="--no-cache" - if [ $HTTP_PROXY ]; then + if [ ${HTTP_PROXY:-} ]; then BUILD_ARGS+=" --build-arg HTTP_PROXY=${HTTP_PROXY}" fi - if [ $HTTPS_PROXY ]; then + if [ ${HTTPS_PROXY:-} ]; then BUILD_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}" fi @@ -67,7 +69,7 @@ populate_CSAR_rbdefinition $csar_id # Test print_msg "Create Resource Bundle Definition Metadata" -payload_raw=" +payload=" { \"rb-name\": \"${rb_name}\", \"rb-version\": \"${rb_version}\", @@ -78,14 +80,13 @@ payload_raw=" } } " -payload=$(echo $payload_raw | tr '\n' ' ') -rb_ret_name=$(curl -s -d "$payload" -X POST "${base_url}/v1/rb/definition" | jq -r '."rb-name"') +call_api -d "$payload" "${base_url}/rb/definition" print_msg "Upload Resource Bundle Definition Content" -curl -s --data-binary @${CSAR_DIR}/${csar_id}/${rbd_content_tarball}.gz -X POST "${base_url}/v1/rb/definition/$rb_name/$rb_version/content" +call_api --data-binary "@${CSAR_DIR}/${csar_id}/vault-consul-dev-0.0.0.tgz" "${base_url}/rb/definition/$rb_name/$rb_version/content" print_msg "Listing Resource Bundle Definitions" -rb_list=$(curl -s -X GET "${base_url}/v1/rb/definition/$rb_name") +rb_list=$(call_api "${base_url}/rb/definition/$rb_name") if [[ "$rb_list" != *"${rb_name}"* ]]; then echo $rb_list echo "Resource Bundle Definition not stored" @@ -94,7 +95,7 @@ fi print_msg "Create Resource Bundle Profile Metadata" kubeversion=$(kubectl version | grep 'Server Version' | awk -F '"' '{print $6}') -payload_raw=" +payload=" { \"profile-name\": \"${profile_name}\", \"rb-name\": \"${rb_name}\", @@ -107,22 +108,33 @@ payload_raw=" } } " -payload=$(echo $payload_raw | tr '\n' ' ') -rbp_ret_name=$(curl -s -d "$payload" -X POST "${base_url}/v1/rb/definition/$rb_name/$rb_version/profile" | jq -r '."profile-name"') +call_api -d "$payload" "${base_url}/rb/definition/$rb_name/$rb_version/profile" print_msg "Upload Resource Bundle Profile Content" -curl -s --data-binary @${CSAR_DIR}/${csar_id}/${rbp_content_tarball}.gz -X POST "${base_url}/v1/rb/definition/$rb_name/$rb_version/profile/$profile_name/content" +call_api --data-binary "@${CSAR_DIR}/${csar_id}/rb_profile.tar.gz" "${base_url}/rb/definition/$rb_name/$rb_version/profile/$profile_name/content" print_msg "Getting Resource Bundle Profile" -rbp_ret=$(curl -s -X GET "${base_url}/v1/rb/definition/$rb_name/$rb_version/profile/$profile_name") +rbp_ret=$(call_api "${base_url}/rb/definition/$rb_name/$rb_version/profile/$profile_name") if [[ "$rbp_ret" != *"${profile_name}"* ]]; then echo $rbp_ret echo "Resource Bundle Profile not stored" exit 1 fi +print_msg "Setup cloud data" +payload="$(cat <<EOF +{ + "cloud-region": "$cloud_region_id", + "cloud-owner": "$cloud_region_owner" +} +EOF +)" +call_api -F "metadata=$payload" \ + -F "file=@$kubeconfig_path" \ + "${base_url}/connectivity-info" >/dev/null + print_msg "Instantiate Profile" -payload_raw=" +payload=" { \"cloud-region\": \"$cloud_region_id\", \"rb-name\":\"$rb_name\", @@ -130,8 +142,9 @@ payload_raw=" \"profile-name\":\"$profile_name\" } " -payload=$(echo $payload_raw | tr '\n' ' ') -inst_id=$(curl -s -d "$payload" "${base_url}/v1/instance" | jq -r '.id') +inst_id=$(call_api -d "$payload" "${base_url}/instance") +echo "$inst_id" +inst_id=$(jq -r '.id' <<< "$inst_id") print_msg "Validating Kubernetes" kubectl get --no-headers=true --namespace=${namespace} deployment ${release_name}-vault-consul-dev @@ -139,35 +152,21 @@ kubectl get --no-headers=true --namespace=${namespace} service override-vault-co echo "VNF Instance created succesfully with id: $inst_id" print_msg "Getting $inst_id VNF Instance information" -vnf_details=$(curl -s -X GET "${base_url}/v1/instance/${inst_id}") -if [[ -z "$vnf_details" ]]; then - echo "Cannot retrieved VNF Instance details" - exit 1 -fi -echo "VNF details $vnf_details" +call_api "${base_url}/instance/${inst_id}" +# Teardown print_msg "Deleting $rb_name/$rb_version Resource Bundle Definition" -curl -X DELETE "${base_url}/v1/rb/definition/$rb_name/$rb_version" -if [[ 500 -ne $(curl -o /dev/null -w %{http_code} -s -X GET "${base_url}/v1/rb/definition/$rb_name/$rb_version") ]]; then - echo "Resource Bundle Definition not deleted" # TODO: Change the HTTP code for 404 when the resource is not found in the API - exit 1 -fi +delete_resource "${base_url}/rb/definition/$rb_name/$rb_version" print_msg "Deleting $profile_name Resource Bundle Profile" -curl -X DELETE "${base_url}/v1/rb/definition/$rb_name/$rb_version/profile/$profile_name" -if [[ 500 -ne $(curl -o /dev/null -w %{http_code} -s -X GET "${base_url}/v1/rb/definition/$rb_name/$rb_version/profile/$profile_name") ]]; then - echo "Resource Bundle Profile not deleted" # TODO: Change the HTTP code for 404 when the resource is not found in the API - exit 1 -fi +delete_resource "${base_url}/rb/definition/$rb_name/$rb_version/profile/$profile_name" print_msg "Deleting $inst_id VNF Instance" -curl -X DELETE "${base_url}/v1/instance/${inst_id}" -if [[ 404 -ne $(curl -o /dev/null -w %{http_code} -s -X GET "${base_url}/${inst_id}") ]]; then - echo "VNF Instance not deleted" - exit 1 -fi +delete_resource "${base_url}/instance/${inst_id}" + +print_msg "Deleting ${cloud_region_id} cloud region connection" +delete_resource "${base_url}/connectivity-info/${cloud_region_id}" -# Teardown teardown $plugin_deployment_name diff --git a/kud/tests/plugin_edgex.sh b/kud/tests/plugin_edgex.sh index 4e806e6f..8eae5692 100755 --- a/kud/tests/plugin_edgex.sh +++ b/kud/tests/plugin_edgex.sh @@ -15,57 +15,99 @@ set -o pipefail source _common_test.sh source _functions.sh +source _common.sh -base_url="http://localhost:8081/v1/vnf_instances/" -cloud_region_id="kud" -namespace="default" +base_url="http://localhost:9015/v1" +kubeconfig_path="$HOME/.kube/config" csar_id=cb009bfe-bbee-11e8-9766-525400435678 +rb_name="edgex" +rb_version="plugin_test" +chart_name="edgex" +profile_name="test_profile" +release_name="test-release" +namespace="plugin-tests-namespace" +cloud_region_id="kud" +cloud_region_owner="localhost" # Setup install_deps -_checks_args ${csar_id} -cp -R ./edgex/* ${CSAR_DIR}/${csar_id}/ +populate_CSAR_edgex_rbdefinition "$csar_id" + +print_msg "Registering resource bundle" +payload="$(cat <<EOF +{ + "rb-name": "${rb_name}", + "rb-version": "${rb_version}", + "chart-name": "${chart_name}" +} +EOF +)" +call_api -d "${payload}" "${base_url}/rb/definition" + +print_msg "Uploading resource bundle content" +call_api --data-binary "@${CSAR_DIR}/${csar_id}/rb_definition.tar.gz" \ + "${base_url}/rb/definition/${rb_name}/${rb_version}/content" + +print_msg "Registering rb's profile" +payload="$(cat <<EOF +{ + "rb-name": "${rb_name}", + "rb-version": "${rb_version}", + "profile-name": "${profile_name}", + "release-name": "${release_name}", + "namespace": "${namespace}" +} +EOF +)" +call_api -d "${payload}" "${base_url}/rb/definition/${rb_name}/${rb_version}/profile" + +print_msg "Uploading profile data" +call_api --data-binary "@${CSAR_DIR}/${csar_id}/rb_profile.tar.gz" \ + "${base_url}/rb/definition/${rb_name}/${rb_version}/profile/${profile_name}/content" -# Test -payload_raw=" +print_msg "Setup cloud data" +payload="$(cat <<EOF { - \"cloud_region_id\": \"$cloud_region_id\", - \"namespace\": \"$namespace\", - \"csar_id\": \"$csar_id\" + "cloud-region": "$cloud_region_id", + "cloud-owner": "$cloud_region_owner" } -" -payload=$(echo $payload_raw | tr '\n' ' ') - -echo "Creating EdgeX VNF Instance" - -vnf_id=$(curl -s -d "$payload" "${base_url}" | jq -r '.vnf_id') - -echo "=== Validating Kubernetes ===" -kubectl get --no-headers=true --namespace=${namespace} deployment ${cloud_region_id}-${namespace}-${vnf_id}-edgex-core-command -kubectl get --no-headers=true --namespace=${namespace} service ${cloud_region_id}-${namespace}-${vnf_id}-edgex-core-command -echo "VNF Instance created succesfully with id: $vnf_id" - -# TODO: Add heath checks to verify EdgeX services - -vnf_id_list=$(curl -s -X GET "${base_url}${cloud_region_id}/${namespace}" | jq -r '.vnf_id_list') -if [[ "$vnf_id_list" != *"${vnf_id}"* ]]; then - echo $vnf_id_list - echo "VNF Instance not stored" - exit 1 -fi - -vnf_details=$(curl -s -X GET "${base_url}${cloud_region_id}/${namespace}/${vnf_id}") -if [[ -z "$vnf_details" ]]; then - echo "Cannot retrieved VNF Instance details" - exit 1 -fi -echo "VNF details $vnf_details" - -echo "Deleting $vnf_id VNF Instance" -curl -X DELETE "${base_url}${cloud_region_id}/${namespace}/${vnf_id}" -if [[ -n $(curl -s -X GET "${base_url}${cloud_region_id}/${namespace}/${vnf_id}") ]]; then - echo "VNF Instance not deleted" - exit 1 -fi - -# Teardown +EOF +)" +call_api -F "metadata=$payload" \ + -F "file=@$kubeconfig_path" \ + "${base_url}/connectivity-info" >/dev/null #massive output + +print_msg "Creating EdgeX VNF Instance" +payload="$(cat <<EOF +{ + "rb-name": "${rb_name}", + "rb-version": "${rb_version}", + "profile-name": "${profile_name}", + "cloud-region": "${cloud_region_id}" +} +EOF +)" +response="$(call_api -d "${payload}" "${base_url}/instance")" +echo "$response" +vnf_id="$(jq -r '.id' <<< "${response}")" + +print_msg "Validating Kubernetes" +kubectl get --no-headers=true --namespace=${namespace} deployment edgex-core-command +kubectl get --no-headers=true --namespace=${namespace} service edgex-core-command +# TODO: Add health checks to verify EdgeX services + +print_msg "Retrieving VNF details" +call_api "${base_url}/instance/${vnf_id}" + +#Teardown +print_msg "Deleting VNF Instance" +delete_resource "${base_url}/instance/${vnf_id}" + +print_msg "Deleting Profile" +delete_resource "${base_url}/rb/definition/${rb_name}/${rb_version}/profile/${profile_name}" + +print_msg "Deleting Resource Bundle" +delete_resource "${base_url}/rb/definition/${rb_name}/${rb_version}" + +print_msg "Deleting ${cloud_region_id} cloud region connection" +delete_resource "${base_url}/connectivity-info/${cloud_region_id}" diff --git a/kud/tests/plugin_fw.sh b/kud/tests/plugin_fw.sh new file mode 100755 index 00000000..d7bed4fd --- /dev/null +++ b/kud/tests/plugin_fw.sh @@ -0,0 +1,116 @@ +#!/bin/bash +# SPDX-license-identifier: Apache-2.0 +############################################################################## +# Copyright (c) 2018 +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +set -o errexit +set -o nounset +set -o pipefail +#set -o xtrace + +source _common_test.sh +source _functions.sh +source _common.sh + +base_url="http://localhost:9015/v1" +kubeconfig_path="$HOME/.kube/config" +csar_id=cc009bfe-bbee-11e8-9766-525400435678 +rb_name="vfw" +rb_version="plugin_test" +chart_name="firewall" +profile_name="test_profile" +release_name="test-release" +namespace="plugin-tests-namespace" +cloud_region_id="kud" +cloud_region_owner="localhost" + +# Setup +install_deps +populate_CSAR_fw_rbdefinition "$csar_id" + +print_msg "Registering resource bundle" +payload="$(cat <<EOF +{ + "rb-name": "${rb_name}", + "rb-version": "${rb_version}", + "chart-name": "${chart_name}" +} +EOF +)" +call_api -d "${payload}" "${base_url}/rb/definition" + +print_msg "Uploading resource bundle content" +call_api --data-binary "@${CSAR_DIR}/${csar_id}/rb_definition.tar.gz" \ + "${base_url}/rb/definition/${rb_name}/${rb_version}/content" + +print_msg "Registering rb's profile" +payload="$(cat <<EOF +{ + "rb-name": "${rb_name}", + "rb-version": "${rb_version}", + "profile-name": "${profile_name}", + "release-name": "${release_name}", + "namespace": "${namespace}" +} +EOF +)" +call_api -d "${payload}" "${base_url}/rb/definition/${rb_name}/${rb_version}/profile" + +print_msg "Uploading profile data" +call_api --data-binary "@${CSAR_DIR}/${csar_id}/rb_profile.tar.gz" \ + "${base_url}/rb/definition/${rb_name}/${rb_version}/profile/${profile_name}/content" + +print_msg "Setup cloud data" +payload="$(cat <<EOF +{ + "cloud-region": "$cloud_region_id", + "cloud-owner": "$cloud_region_owner" +} +EOF +)" +call_api -F "metadata=$payload" \ + -F "file=@$kubeconfig_path" \ + "${base_url}/connectivity-info" >/dev/null #massive output + +print_msg "Creating vFW VNF Instance" +payload="$(cat <<EOF +{ + "rb-name": "${rb_name}", + "rb-version": "${rb_version}", + "profile-name": "${profile_name}", + "cloud-region": "${cloud_region_id}" +} +EOF +)" +response="$(call_api -d "${payload}" "${base_url}/instance")" +echo "$response" +vnf_id="$(jq -r '.id' <<< "${response}")" + +print_msg "Validating VNF instance" +# Check if all pods are up +wait_for_pod -n "${namespace}" -l app=sink +wait_for_pod -n "${namespace}" -l app=firewall +wait_for_pod -n "${namespace}" -l app=packetgen +# TODO: Provide some health check to verify vFW work + +print_msg "Retrieving VNF details" +call_api "${base_url}/instance/${vnf_id}" + + +#Teardown +print_msg "Deleting VNF Instance" +delete_resource "${base_url}/instance/${vnf_id}" + +print_msg "Deleting Profile" +delete_resource "${base_url}/rb/definition/${rb_name}/${rb_version}/profile/${profile_name}" + +print_msg "Deleting Resource Bundle" +delete_resource "${base_url}/rb/definition/${rb_name}/${rb_version}" + +print_msg "Deleting ${cloud_region_id} cloud region connection" +delete_resource "${base_url}/connectivity-info/${cloud_region_id}" diff --git a/kud/tests/vnfs/edgex/profile/manifest.yaml b/kud/tests/vnfs/edgex/profile/manifest.yaml new file mode 100644 index 00000000..4d381d02 --- /dev/null +++ b/kud/tests/vnfs/edgex/profile/manifest.yaml @@ -0,0 +1,4 @@ +--- +version: v1 +type: + values: "override_values.yaml" diff --git a/kud/tests/vnfs/edgex/profile/override_values.yaml b/kud/tests/vnfs/edgex/profile/override_values.yaml new file mode 100644 index 00000000..60232e14 --- /dev/null +++ b/kud/tests/vnfs/edgex/profile/override_values.yaml @@ -0,0 +1 @@ +test_value: 7 |