diff options
author | Igor D.C <igor.duarte.cardoso@intel.com> | 2020-07-20 18:16:15 +0000 |
---|---|---|
committer | Igor D.C <igor.duarte.cardoso@intel.com> | 2020-07-29 20:01:37 +0000 |
commit | 715787e1e9c995f86b0ac57f0e1f22f119298038 (patch) | |
tree | 5297342489d88c3e5bf604bfcedeb83bc838b602 /src/dcm/test | |
parent | 783ed87fb39a8aa25e303e97aff2170dca059068 (diff) |
Add cleanup step to dcm_call_api.sh test script
dcm_call_api.sh exercises some DCM API calls.
This patch adds an optional cleanup phase where it
also exercises the API calls to delete resources.
Plus added two extra GET calls for individual clusters
and minor tweaks like set DCM port to 9077 (prevent
conflict with orchestrator).
Issue-ID: MULTICLOUD-1143
Signed-off-by: Igor D.C <igor.duarte.cardoso@intel.com>
Change-Id: I7a00edb5c986b26ec4be739bf8b01ac362abec90
Diffstat (limited to 'src/dcm/test')
-rwxr-xr-x | src/dcm/test/dcm_call_api.sh | 83 |
1 files changed, 68 insertions, 15 deletions
diff --git a/src/dcm/test/dcm_call_api.sh b/src/dcm/test/dcm_call_api.sh index 3bf27524..966bc3d6 100755 --- a/src/dcm/test/dcm_call_api.sh +++ b/src/dcm/test/dcm_call_api.sh @@ -15,11 +15,24 @@ # */ +dcm_addr="http://localhost:9077" + +# parameters project="test-project" description="test-description" logical_cloud_name="lc1" -logical_cloud_url="http://localhost:9015/v2/projects/${project}/logical-clouds" +namespace="ns1" +user="user-1" +permission="permission-1" +cluster_provider_name="cp-1" +cluster_1_name="c1" +cluster_1_name="c2" +lc_cluster_1_name="lc-cl-1" +lc_cluster_2_name="lc-cl-2" quota_name="quota-1" + +# endpoints +logical_cloud_url="$dcm_addr/v2/projects/${project}/logical-clouds" quota_url="${logical_cloud_url}/${logical_cloud_name}/cluster-quotas" cluster_url="${logical_cloud_url}/${logical_cloud_name}/cluster-references" @@ -28,17 +41,17 @@ logical_cloud_data="$(cat << EOF { "metadata" : { "name": "${logical_cloud_name}", - "description": "${test-description}", + "description": "${description}", "userData1":"<user data>", "userData2":"<user data>" }, "spec" : { - "namespace" : "ns-1", + "namespace" : "${namespace}", "user" : { - "user-name" : "user-1", + "user-name" : "${user}", "type" : "certificate", "user-permissions" : [ - { "permission-name" : "permission-1", + { "permission-name" : "${permission}", "apiGroups" : ["stable.example.com"], "resources" : ["secrets", "pods"], "verbs" : ["get", "watch", "list", "create"] @@ -53,15 +66,15 @@ EOF cluster_1_data="$(cat << EOF { "metadata" : { - "name": "lc-cl-1", - "description": "${test-description}", + "name": "${lc_cluster_1_name}", + "description": "${description}", "userData1":"<user data>", "userData2":"<user data>" }, "spec" : { - "cluster-provider": "cp-1", - "cluster-name": "c1", + "cluster-provider": "${cluster_provider_name}", + "cluster-name": "${cluster_1_name}", "loadbalancer-ip" : "0.0.0.0" } } @@ -71,26 +84,47 @@ EOF cluster_2_data="$(cat << EOF { "metadata" : { - "name": "lc-cl-2", - "description": "${test-description}", + "name": "${lc_cluster_2_name}", + "description": "${description}", "userData1":"<user data>", "userData2":"<user data>" }, "spec" : { - "cluster-provider": "cp-1", - "cluster-name": "c2", + "cluster-provider": "${cluster_provider_name}", + "cluster-name": "${cluster_2_name}", "loadbalancer-ip" : "0.0.0.1" } } EOF )" +# removed all special chars from quota spec keys +# due to loss of data when unmarshalling from json quota_data="$(cat << EOF { "metadata" : { "name" : "${quota_name}", - "description": "${test-description}" + "description": "${description}" + }, + "spec" : { + "persistentvolumeclaims" : "10", + "pods": "500", + "configmaps" : "10", + "replicationcontrollers": "10", + "resourcequotas" : "10", + "services": "10", + "secrets" : "10" + } +} +EOF +)" + +quota_data_original="$(cat << EOF +{ + "metadata" : { + "name" : "${quota_name}", + "description": "${description}" }, "spec" : { "limits.cpu": "400", @@ -143,5 +177,24 @@ curl -X GET "${logical_cloud_url}/${logical_cloud_name}" printf "\n\nGetting clusters info for logical cloud\n\n" curl -X GET ${cluster_url} +printf "\n\nGetting first cluster of logical cloud\n" +curl -X GET ${cluster_url}/${lc_cluster_1_name} + +printf "\n\nGetting second cluster of logical cloud\n" +curl -X GET ${cluster_url}/${lc_cluster_2_name} + printf "\n\nGetting Quota info for the logical cloud\n\n" -curl -X GET "${quota_url}/${quota_name}"
\ No newline at end of file +curl -X GET "${quota_url}/${quota_name}" + +# Cleanup (delete created resources) +if [ "$1" == "clean" ]; then + printf "\n\nDeleting Quota info for the logical cloud\n\n" + curl -X DELETE "${quota_url}/${quota_name}" + + printf "\n\nDeleting the two clusters from logical cloud\n\n" + curl -X DELETE ${cluster_url}/${lc_cluster_1_name} + curl -X DELETE ${cluster_url}/${lc_cluster_2_name} + + printf "\n\nDeleting logical cloud data\n\n" + curl -X DELETE ${logical_cloud_url}/${logical_cloud_name} +fi |