From f443b2307f6cab0f0023c781c501e2d1723fe0f6 Mon Sep 17 00:00:00 2001 From: Aditya Sharoff Date: Wed, 22 Jul 2020 16:36:53 -0700 Subject: Series of negative tests that validate EMCO open api's All negative tests are in negative_tests directory Null is provided as an input to the POST, DELETE, and GET commands and the behavior is observed Issue-ID: MULTICLOUD-1142 Signed-off-by: Aditya Sharoff Change-Id: I8ccf4b5615fc378698faf7f88971db1e250de9b6 Signed-off-by: Aditya Sharoff --- kud/tests/negative_tests/_test_functions.sh | 346 +++++++++++++++++++++ kud/tests/negative_tests/_test_variables_setup.sh | 95 ++++++ kud/tests/negative_tests/readme.txt | 19 ++ kud/tests/negative_tests/test_all_final.sh | 29 ++ kud/tests/negative_tests/test_all_intents.sh | 122 ++++++++ kud/tests/negative_tests/test_composite_app.sh | 95 ++++++ kud/tests/negative_tests/test_controllers.sh | 94 ++++++ .../negative_tests/test_deployment_intent_group.sh | 135 ++++++++ .../test_generic_placement_intent.sh | 111 +++++++ .../test_generic_placement_intent_app.sh | 134 ++++++++ kud/tests/negative_tests/test_multipart.sh | 95 ++++++ kud/tests/negative_tests/test_profile.sh | 101 ++++++ kud/tests/negative_tests/test_profile_apps.sh | 109 +++++++ kud/tests/negative_tests/test_project.sh | 75 +++++ 14 files changed, 1560 insertions(+) create mode 100755 kud/tests/negative_tests/_test_functions.sh create mode 100755 kud/tests/negative_tests/_test_variables_setup.sh create mode 100644 kud/tests/negative_tests/readme.txt create mode 100755 kud/tests/negative_tests/test_all_final.sh create mode 100755 kud/tests/negative_tests/test_all_intents.sh create mode 100755 kud/tests/negative_tests/test_composite_app.sh create mode 100755 kud/tests/negative_tests/test_controllers.sh create mode 100755 kud/tests/negative_tests/test_deployment_intent_group.sh create mode 100755 kud/tests/negative_tests/test_generic_placement_intent.sh create mode 100755 kud/tests/negative_tests/test_generic_placement_intent_app.sh create mode 100755 kud/tests/negative_tests/test_multipart.sh create mode 100755 kud/tests/negative_tests/test_profile.sh create mode 100755 kud/tests/negative_tests/test_profile_apps.sh create mode 100755 kud/tests/negative_tests/test_project.sh (limited to 'kud') diff --git a/kud/tests/negative_tests/_test_functions.sh b/kud/tests/negative_tests/_test_functions.sh new file mode 100755 index 00000000..f4e9472d --- /dev/null +++ b/kud/tests/negative_tests/_test_functions.sh @@ -0,0 +1,346 @@ +# /* +# * Copyright 2020 Intel Corporation, Inc +# * +# * Licensed under the Apache License, Version 2.0 (the "License"); +# * you may not use this file except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.apache.org/licenses/LICENSE-2.0 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# */ + +# Additional functions to run negative tests + +set -o errexit +set -o nounset +set -o pipefail + +FUNCTIONS_DIR="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")" +my_directory=$(dirname $PWD) + +source /etc/environment +source ${my_directory}/negative_tests/_test_variables_setup.sh +source ${my_directory}/_common_test.sh +source ${my_directory}/_functions.sh +source ${my_directory}/_common.sh + +function call_api_negative { + #Runs curl with passed flags and provides + #additional error handling and debug information + + #Function outputs server response body + #and performs validation of http_code + + local status + local curl_response_file="$(mktemp -p /tmp)" + local curl_common_flags=(-s -w "%{http_code}" -o "${curl_response_file}") + local command=(curl "${curl_common_flags[@]}" "$@") + + echo "[INFO] Running '${command[@]}'" >&2 + if ! status="$("${command[@]}")"; then + echo "[ERROR] Internal curl error! '$status'" >&2 + cat "${curl_response_file}" + rm "${curl_response_file}" + return 2 + else + echo "[INFO] Server replied with status: ${status}" >&2 + cat "${curl_response_file}" + rm "${curl_response_file}" + return_status=$status + fi +} + + +function delete_resource_negative { + #Issues DELETE http call to provided endpoint + #and further validates by following GET request + + call_api_negative -X DELETE "$1" + #! call_api -X GET "$1" >/dev/null +} + +function get_resource_negative { + #! call_api_negative -X GET "$1" >/dev/null + ! call_api_negative -X GET "$1" + echo $return_status +} + + +# Create a test rpoject +# EOF must start as first chracter in a line for cat to identify the end +function create_project { + project_name="test_project" + project_description="test_project_description" + userData1="user1" + userData2="user2" + print_msg "Registering project" + payload="$(cat <.sh + example: ./test_project.sh diff --git a/kud/tests/negative_tests/test_all_final.sh b/kud/tests/negative_tests/test_all_final.sh new file mode 100755 index 00000000..c986e03b --- /dev/null +++ b/kud/tests/negative_tests/test_all_final.sh @@ -0,0 +1,29 @@ + +# /* +# * Copyright 2020 Intel Corporation, Inc +# * +# * Licensed under the Apache License, Version 2.0 (the "License"); +# * you may not use this file except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.apache.org/licenses/LICENSE-2.0 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# */ + +# Script to run all the tests at once + +./test_all_intents.sh +./test_composite_app.sh +./test_deployment_intent_group.sh +./test_controllers.sh +./test_generic_placement_intent_app.sh +./test_generic_placement_intent.sh +./test_multipart.sh +./test_profile_apps.sh +./test_profile.sh +./test_project.sh diff --git a/kud/tests/negative_tests/test_all_intents.sh b/kud/tests/negative_tests/test_all_intents.sh new file mode 100755 index 00000000..1f2f721f --- /dev/null +++ b/kud/tests/negative_tests/test_all_intents.sh @@ -0,0 +1,122 @@ +# /* +# * Copyright 2020 Intel Corporation, Inc +# * +# * Licensed under the Apache License, Version 2.0 (the "License"); +# * you may not use this file except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.apache.org/licenses/LICENSE-2.0 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# */ + +# Script name: ./test_all_intents.sh +# Purpose: To ascertain whether or not the POST/DELETE/GET API is able to register a null name +# Description, userdata1, and userdata2 have values that I have assigned. + +set -o errexit +set -o nounset +set -o pipefail + +source _test_functions.sh + +if [ ${1:+1} ]; then + if [ "$1" == "--external" ]; then + master_ip=$(kubectl cluster-info | grep "Kubernetes master" | \ + awk -F ":" '{print $2}' | awk -F "//" '{print $2}') + onap_svc_node_port=30498 + base_url="http://$master_ip:$onap_svc_node_port/v1" + fi +fi + +# Setup +install_deps +populate_CSAR_composite_app_helm "$csar_id" + +# clean up +delete_all + +# Create project +create_project + +# Create composite app +create_composite_app + +create_app "collectd.tar.gz" "collectd" "collectd_desc" +create_app "prometheus-operator.tar.gz" "prometheus" "prometheus_desc" + +create_main_composite_profile + +create_profile_app "test_composite_profile1" "collectd" "collectd_profile.tar.gz" +create_profile_app "test_composite_profile2" "prometheus" "prometheus-operator_profile.tar.gz" + +create_generic_placement_intent_app1 + +create_placement_intent_app "appIntentForApp1" "AppIntentForApp1Desc" "collectd" +create_placement_intent_app "appIntentForApp2" "AppIntentForApp2Desc" "prometheus" + +create_deployment_intent_group + +# BEGIN: Adding intents to an intent group +print_msg "Adding all the intents to the deploymentIntent group" +intentToBeAddedinDeploymentIntentGroup="" +payload="$(cat <