Added function test of ecs type subscriptions
Corrected image tag for Rapp Catalogue in d-release test
Issue-ID: NONRTRIC-573
Signed-off-by: BjornMagnussonXA <bjorn.magnusson@est.tech>
Change-Id: I5fb935a04fac94085672ca9d1bc162e0e30ba875
diff --git a/test/common/README.md b/test/common/README.md
index 8f37377..6c277bd 100644
--- a/test/common/README.md
+++ b/test/common/README.md
@@ -1038,6 +1038,48 @@
| `EMPTY` | Indicator for an empty list |
| `<ric-id>` | Id of the ric |
+## Function: cr_api_check_all_ecs_events() ##
+
+Check the contents of all current status events for one id from ECS
+
+| arg list |
+|--|
+| `<response-code> <id> [ EMPTY \| ( <status> )+ ]` |
+
+| parameter | description |
+| --------- | ----------- |
+| `<response-code>` | Expected http response code |
+| `<id>` | Id of the callback destination |
+| `EMPTY` | Indicator for an empty list |
+| `<status>` | Status string |
+
+## Function: cr_api_check_all_ecs_subscription_events() ##
+
+Check the contents of all current subscription events for one id from ECS
+
+| arg list |
+|--|
+| `<response-code> <id> [ EMPTY | ( <type-id> <schema> <registration-status> )+ ]` |
+
+| parameter | description |
+| --------- | ----------- |
+| `<response-code>` | Expected http response code |
+| `<id>` | Id of the callback destination |
+| `EMPTY` | Indicator for an empty list |
+| `<type-id>` | Id of the data type |
+| `<schema>` | Path to typeschema file |
+| `<registration-status>` | Status string |
+
+
+## Function: cr_api_reset() ##
+
+Reset the callback receiver
+
+| arg list |
+|--|
+| - |
+
+
# Description of functions in ecs_api_functions.sh #
## Function: use_ecs_rest_http ##
@@ -1662,6 +1704,64 @@
| `<producer-id>` |Id of the producer |
| `<timeout>` | Timeout |
+
+## Function: ecs_api_idc_get_subscription_ids() ##
+Test of GET '/data-consumer/v1/info-type-subscription' with the returned list of subscription ids
+
+| arg list |
+|--|
+| `<response-code> <owner-id>|NOOWNER [ EMPTY | <subscription-id>+]` |
+
+| parameter | description |
+| --------- | ----------- |
+| `<response-code>` | Expected http response code |
+| `<owner-id>` | Id of the owner |
+| `<NOOWNER>` | Indicator for empty owner |
+| `<EMPTY>` | Indicated for empty list of subscription ids |
+| `<subscription-id>` |Id of the subscription |
+
+## Function: ecs_api_idc_get_subscription() ##
+Test of GET '/data-consumer/v1/info-type-subscription/{subscriptionId}' with the subscription information
+
+| arg list |
+|--|
+| `<response-code> <subscription-id> [ <owner-id> <status-uri> ]` |
+
+| parameter | description |
+| --------- | ----------- |
+| `<response-code>` | Expected http response code |
+| `<subscription-id>` |Id of the subscription |
+| `<owner-id>` | Id of the owner |
+| `<status-uri>` | Url for status notifications |
+
+
+## Function: ecs_api_idc_put_subscription() ##
+Test of PUT '/data-consumer/v1/info-type-subscription/{subscriptionId}' with the subscription information
+
+| arg list |
+|--|
+| `<response-code> <subscription-id> <owner-id> <status-uri>` |
+
+| parameter | description |
+| --------- | ----------- |
+| `<response-code>` | Expected http response code |
+| `<subscription-id>` |Id of the subscription |
+| `<owner-id>` | Id of the owner |
+| `<status-uri>` | Url for status notifications |
+
+## Function: ecs_api_idc_delete_subscription() ##
+Test of DELETE /data-consumer/v1/info-type-subscription/{subscriptionId}
+
+| arg list |
+|--|
+| `<response-code> <subscription-id>` |
+
+| parameter | description |
+| --------- | ----------- |
+| `<response-code>` | Expected http response code |
+| `<subscription-id>` |Id of the subscription |
+
+
## Function: ecs_api_admin_reset() ##
Test of GET '/status'.
diff --git a/test/common/cr_api_functions.sh b/test/common/cr_api_functions.sh
index 134f50c..c19797a 100644
--- a/test/common/cr_api_functions.sh
+++ b/test/common/cr_api_functions.sh
@@ -390,4 +390,88 @@
fi
__log_test_pass
return 0
+}
+
+# CR API: Check the contents of all current type subscription events for one id from ECS
+# <response-code> <id> [ EMPTY | ( <type-id> <schema> <registration-status> )+ ]
+# (Function for test scripts)
+cr_api_check_all_ecs_subscription_events() {
+ __log_test_start $@
+
+ #Valid number of parameter 2,3,7,11
+ paramError=1
+ if [ $# -eq 2 ]; then
+ paramError=0
+ fi
+ if [ $# -eq 3 ] && [ "$3" == "EMPTY" ]; then
+ paramError=0
+ fi
+ variablecount=$(($#-2))
+ if [ $# -gt 3 ] && [ $(($variablecount%3)) -eq 0 ]; then
+ paramError=0
+ fi
+ if [ $paramError -eq 1 ]; then
+ __print_err "<response-code> <id> [ EMPTY | ( <type-id> <schema> <registration-status> )+ ]" $@
+ return 1
+ fi
+
+ query="/get-all-events/"$2
+ res="$(__do_curl_to_api CR GET $query)"
+ status=${res:${#res}-3}
+
+ if [ $status -ne $1 ]; then
+ __log_test_fail_status_code $1 $status
+ return 1
+ fi
+
+ if [ $# -gt 2 ]; then
+ body=${res:0:${#res}-3}
+ targetJson="["
+ if [ $# -gt 3 ]; then
+ arr=(${@:3})
+ for ((i=0; i<$(($#-3)); i=i+3)); do
+ if [ "$targetJson" != "[" ]; then
+ targetJson=$targetJson","
+ fi
+ if [ -f ${arr[$i+1]} ]; then
+ jobfile=$(cat ${arr[$i+1]})
+ else
+ __log_test_fail_general "Job schema file "${arr[$i+1]}", does not exist"
+ return 1
+ fi
+ targetJson=$targetJson"{\"info_type_id\":\"${arr[$i]}\",\"job_data_schema\":$jobfile,\"status\":\"${arr[$i+2]}\"}"
+ done
+ fi
+ targetJson=$targetJson"]"
+
+ echo " TARGET JSON: $targetJson" >> $HTTPLOG
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
+
+ if [ $res -ne 0 ]; then
+ __log_test_fail_body
+ return 1
+ fi
+ fi
+
+ __log_test_pass
+ return 0
+}
+
+
+# CR API: Reset all events and counters
+# Arg: -
+# (Function for test scripts)
+cr_api_reset() {
+ __log_conf_start $@
+
+ res="$(__do_curl_to_api CR GET /reset)"
+ status=${res:${#res}-3}
+
+ if [ $status -ne 200 ]; then
+ __log_conf_fail_status_code $1 $status
+ return 1
+ fi
+
+ __log_conf_ok
+ return 0
}
\ No newline at end of file
diff --git a/test/common/ecs_api_functions.sh b/test/common/ecs_api_functions.sh
index 5ad1b98..805fae4 100644
--- a/test/common/ecs_api_functions.sh
+++ b/test/common/ecs_api_functions.sh
@@ -2017,13 +2017,13 @@
}
# API Test function: GET /data-consumer/v1/info-types/{infoTypeId}
-# args: <response-code> <type-id> [<schema-file>]
+# args: <response-code> <type-id> [<schema-file> [<type-status> <producers-count]]
# (Function for test scripts)
ecs_api_idc_get_type() {
__log_test_start $@
- if [ $# -lt 2 ] || [ $# -gt 3 ]; then
- __print_err "<response-code> <type-id> [<schema-file>]" $@
+ if [ $# -lt 2 ] || [ $# -gt 5 ]; then
+ __print_err "<response-code> <type-id> [<schema-file> [<type-status> <producers-count]]" $@
return 1
fi
@@ -2036,7 +2036,7 @@
return 1
fi
- if [ $# -eq 3 ]; then
+ if [ $# -gt 2 ]; then
body=${res:0:${#res}-3}
if [ -f $3 ]; then
schema=$(cat $3)
@@ -2044,7 +2044,11 @@
__log_test_fail_general "Schema file "$3", does not exist"
return 1
fi
- targetJson="{\"job_data_schema\":$schema}"
+ if [ $# -eq 5 ]; then
+ targetJson="{\"job_data_schema\":$schema, \"type_status\":\"$4\", \"no_of_producers\":$5}"
+ else
+ targetJson="{\"job_data_schema\":$schema}"
+ fi
echo " TARGET JSON: $targetJson" >> $HTTPLOG
res=$(python3 ../common/compare_json.py "$targetJson" "$body")
@@ -2223,6 +2227,148 @@
}
##########################################
+#### Type subscriptions ####
+##########################################
+
+# API Test function: GET /data-consumer/v1/info-type-subscription
+# args: <response-code> <owner-id>|NOOWNER [ EMPTY | <subscription-id>+]
+# (Function for test scripts)
+ecs_api_idc_get_subscription_ids() {
+ __log_test_start $@
+
+ if [ $# -lt 3 ]; then
+ __print_err "<response-code> <owner-id>|NOOWNER [ EMPTY | <subscription-id>+]" $@
+ return 1
+ fi
+
+ query="/data-consumer/v1/info-type-subscription"
+ search=""
+ if [ $2 != "NOOWNER" ]; then
+ search="?owner="$2
+ fi
+
+ res="$(__do_curl_to_api ECS GET $query$search)"
+ status=${res:${#res}-3}
+
+ if [ $status -ne $1 ]; then
+ __log_test_fail_status_code $1 $status
+ return 1
+ fi
+
+ if [ $# -gt 2 ]; then
+ body=${res:0:${#res}-3}
+ targetJson="["
+ if [ $3 != "EMPTY" ]; then
+ for pid in ${@:3} ; do
+ if [ "$targetJson" != "[" ]; then
+ targetJson=$targetJson","
+ fi
+ targetJson=$targetJson"\"$pid\""
+ done
+ fi
+ targetJson=$targetJson"]"
+ echo " TARGET JSON: $targetJson" >> $HTTPLOG
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
+
+ if [ $res -ne 0 ]; then
+ __log_test_fail_body
+ return 1
+ fi
+ fi
+
+ __log_test_pass
+ return 0
+}
+
+# API Test function: GET /data-consumer/v1/info-type-subscription/{subscriptionId}
+# args: <response-code> <subscription-id> [ <owner-id> <status-uri> ]
+# (Function for test scripts)
+ecs_api_idc_get_subscription() {
+ __log_test_start $@
+
+ if [ $# -ne 2 ] && [ $# -ne 4 ]; then
+ __print_err "<response-code> <subscription-id> [ <owner-id> <status-uri> ]" $@
+ return 1
+ fi
+
+ query="/data-consumer/v1/info-type-subscription/$2"
+ res="$(__do_curl_to_api ECS GET $query)"
+ status=${res:${#res}-3}
+
+ if [ $status -ne $1 ]; then
+ __log_test_fail_status_code $1 $status
+ return 1
+ fi
+
+ if [ $# -gt 2 ]; then
+ body=${res:0:${#res}-3}
+ targetJson="{\"owner\":\"$3\",\"status_result_uri\":\"$4\"}"
+ echo " TARGET JSON: $targetJson" >> $HTTPLOG
+ res=$(python3 ../common/compare_json.py "$targetJson" "$body")
+
+ if [ $res -ne 0 ]; then
+ __log_test_fail_body
+ return 1
+ fi
+ fi
+
+ __log_test_pass
+ return 0
+}
+
+# API Test function: PUT /data-consumer/v1/info-type-subscription/{subscriptionId}
+# args: <response-code> <subscription-id> <owner-id> <status-uri>
+# (Function for test scripts)
+ecs_api_idc_put_subscription() {
+ __log_test_start $@
+
+ if [ $# -ne 4 ]; then
+ __print_err "<response-code> <subscription-id> <owner-id> <status-uri>" $@
+ return 1
+ fi
+
+ inputJson="{\"owner\": \"$3\",\"status_result_uri\": \"$4\"}"
+ file="./tmp/.p.json"
+ echo "$inputJson" > $file
+
+ query="/data-consumer/v1/info-type-subscription/$2"
+ res="$(__do_curl_to_api ECS PUT $query $file)"
+ status=${res:${#res}-3}
+
+ if [ $status -ne $1 ]; then
+ __log_test_fail_status_code $1 $status
+ return 1
+ fi
+
+ __log_test_pass
+ return 0
+}
+
+# API Test function: DELETE /data-consumer/v1/info-type-subscription/{subscriptionId}
+# args: <response-code> <subscription-id>
+# (Function for test scripts)
+ecs_api_idc_delete_subscription() {
+ __log_test_start $@
+
+ if [ $# -ne 2 ]; then
+ __print_err "<response-code> <subscription-id> " $@
+ return 1
+ fi
+
+ query="/data-consumer/v1/info-type-subscription/$2"
+ res="$(__do_curl_to_api ECS DELETE $query)"
+ status=${res:${#res}-3}
+
+ if [ $status -ne $1 ]; then
+ __log_test_fail_status_code $1 $status
+ return 1
+ fi
+
+ __log_test_pass
+ return 0
+}
+
+##########################################
#### Reset jobs ####
##########################################
# Function prefix: ecs_api_admin
diff --git a/test/common/test_env-oran-d-release.sh b/test/common/test_env-oran-d-release.sh
index 77907d3..399f362 100755
--- a/test/common/test_env-oran-d-release.sh
+++ b/test/common/test_env-oran-d-release.sh
@@ -116,10 +116,10 @@
# RAPP Catalogue image and tags
RAPP_CAT_IMAGE_BASE="o-ran-sc/nonrtric-r-app-catalogue"
-RAPP_CAT_IMAGE_TAG_LOCAL="1.1.0-SNAPSHOT"
-RAPP_CAT_IMAGE_TAG_REMOTE_SNAPSHOT="1.1.0-SNAPSHOT"
-RAPP_CAT_IMAGE_TAG_REMOTE="1.1.0"
-RAPP_CAT_IMAGE_TAG_REMOTE_RELEASE="1.1.0"
+RAPP_CAT_IMAGE_TAG_LOCAL="1.0.1-SNAPSHOT"
+RAPP_CAT_IMAGE_TAG_REMOTE_SNAPSHOT="1.0.1-SNAPSHOT"
+RAPP_CAT_IMAGE_TAG_REMOTE="1.0.1"
+RAPP_CAT_IMAGE_TAG_REMOTE_RELEASE="1.0.1"
# Near RT RIC Simulator image and tags - same version as cherry
diff --git a/test/common/test_env-oran-e-release.sh b/test/common/test_env-oran-e-release.sh
index be6c0df..e468d03 100755
--- a/test/common/test_env-oran-e-release.sh
+++ b/test/common/test_env-oran-e-release.sh
@@ -247,7 +247,7 @@
ECS_CONFIG_MOUNT_PATH=/opt/app/enrichment-coordinator-service/config # Internal container path for configuration
ECS_CONFIG_FILE=application.yaml # Config file name
ECS_VERSION="V1-2" # Version where the types are decoupled from the producer registration
-ECS_FEATURE_LEVEL="INFO-TYPES" # Space separated list of features
+ECS_FEATURE_LEVEL="INFO-TYPES TYPE-SUBSCRIPTIONS" # Space separated list of features
MR_DMAAP_APP_NAME="dmaap-mr" # Name for the Dmaap MR
MR_STUB_APP_NAME="mr-stub" # Name of the MR stub
diff --git a/test/common/testcase_common.sh b/test/common/testcase_common.sh
index 7b1201d..5f1b097 100755
--- a/test/common/testcase_common.sh
+++ b/test/common/testcase_common.sh
@@ -229,7 +229,7 @@
# Function to print current statistics
__print_current_stats() {
if [ $PRINT_CURRENT_STATS -ne 0 ]; then
- echo " Currrent stats - tests, passes, fails, conf fails, deviations: $RES_TEST, $RES_PASS, $RES_FAIL, $RES_CONF_FAIL, $RES_DEVIATION"
+ echo " Current stats - exe-time, tests, passes, fails, conf fails, deviations: $(($SECONDS-$TCTEST_START)), $RES_TEST, $RES_PASS, $RES_FAIL, $RES_CONF_FAIL, $RES_DEVIATION"
fi
}
@@ -2500,13 +2500,15 @@
__var_test() {
checkjsonarraycount=0
-
+ TIMESTAMP=$(date "+%Y-%m-%d %H:%M:%S")
if [ $# -eq 6 ]; then
if [[ $3 == "json:"* ]]; then
checkjsonarraycount=1
fi
echo -e $BOLD"TEST $TEST_SEQUENCE_NR (${BASH_LINENO[1]}): ${1}, ${3} ${4} ${5} within ${6} seconds"$EBOLD
+ echo "TEST $TEST_SEQUENCE_NR - ${TIMESTAMP}: (${BASH_LINENO[1]}): ${1}, ${3} ${4} ${5} within ${6} seconds" >> $HTTPLOG
+
((RES_TEST++))
((TEST_SEQUENCE_NR++))
start=$SECONDS
@@ -2575,6 +2577,7 @@
fi
echo -e $BOLD"TEST $TEST_SEQUENCE_NR (${BASH_LINENO[1]}): ${1}, ${3} ${4} ${5}"$EBOLD
+ echo "TEST $TEST_SEQUENCE_NR - ${TIMESTAMP}: (${BASH_LINENO[1]}): ${1}, ${3} ${4} ${5}" >> $HTTPLOG
((RES_TEST++))
((TEST_SEQUENCE_NR++))
if [ $checkjsonarraycount -eq 0 ]; then