# Path to callback receiver
CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
+generate_uuid
+
# Tested variants of REST/DMAAP/SDNC config
TESTED_VARIANTS="REST DMAAP REST+SDNC DMAAP+SDNC"
#Test agent and simulator protocol versions (others are http only)
#### TEST BEGIN ####
+generate_uuid
+
#Local vars in test script
##########################
# Path to callback receiver
#### TEST BEGIN ####
+generate_uuid
+
#Local vars in test script
##########################
. ../common/agent_api_functions.sh
. ../common/ricsimulator_api_functions.sh
+generate_uuid
#Local vars in test script
##########################
#### TEST BEGIN ####
+generate_uuid
+
#Test agent and simulator protocol versions (others are http only)
TESTED_PROTOCOLS="HTTP HTTPS"
#### TEST BEGIN ####
+generate_uuid
+
#Local vars in test script
##########################
# Path to callback receiver
#### TEST BEGIN ####
+generate_uuid
# Clean container and start all needed containers #
clean_containers
#### TEST BEGIN ####
+generate_uuid
+
#Local vars in test script
##########################
# Path to callback receiver
#### TEST BEGIN ####
+generate_uuid
+
#Local vars in test script
##########################
# Path to callback receiver
#### TEST BEGIN ####
+generate_uuid
+
#Local vars in test script
##########################
# Path to callback receiver
NUM_RICS=20
NUM_POLICIES_PER_RIC=500
+generate_uuid
+
for __httpx in $TESTED_PROTOCOLS ; do
for interface in $TESTED_VARIANTS ; do
start_mr # Not used, but removes error messages from the agent log
+ start_control_panel
+
start_policy_agent
set_agent_debug
# ============LICENSE_END=================================================
#
-TC_ONELINE_DESCR="Testing of the Control Panel and the Health Check app - populating with types and instances"
+TC_ONELINE_DESCR="Preparation for test of the Control Panel and the Health Check app - populating a number of ric simulators with types and instances"
#App names to exclude checking pulling images for, space separated list
EXCLUDED_IMAGES="SDNC SDNC_ONAP"
OSC_NUM_RICS=6
STD_NUM_RICS=5
-start_ric_simulators ricsim_g1 $OSC_NUM_RICS OSC_2.1.0
+start_ric_simulators $RIC_SIM_PREFIX"_g1" $OSC_NUM_RICS OSC_2.1.0
-start_ric_simulators ricsim_g2 $STD_NUM_RICS STD_1.1.3
+start_ric_simulators $RIC_SIM_PREFIX"_g2" $STD_NUM_RICS STD_1.1.3
start_mr #Just to prevent errors in the agent log...
# Print the A1 version for OSC
for ((i=1; i<=$OSC_NUM_RICS; i++))
do
- sim_print ricsim_g1_$i interface
+ sim_print $RIC_SIM_PREFIX"_g1_"$i interface
done
# Print the A1 version for STD
for ((i=1; i<=$STD_NUM_RICS; i++))
do
- sim_print ricsim_g2_$i interface
+ sim_print $RIC_SIM_PREFIX"_g2_"$i interface
done
# Load the polictypes in osc
for ((i=1; i<=$OSC_NUM_RICS; i++))
do
- sim_put_policy_type 201 ricsim_g1_$i 2 testdata/OSC/sim_hw.json
- sim_put_policy_type 201 ricsim_g1_$i 20008 testdata/OSC/sim_tsa.json
+ sim_put_policy_type 201 $RIC_SIM_PREFIX"_g1_"$i 2 testdata/OSC/sim_hw.json
+ sim_put_policy_type 201 $RIC_SIM_PREFIX"_g1_"$i 100 testdata/OSC/sim_qos.json
+ sim_put_policy_type 201 $RIC_SIM_PREFIX"_g1_"$i 20008 testdata/OSC/sim_tsa.json
done
#Check the number of schemas and the individual schemas in OSC
-api_equal json:policy_types 3 120
+api_equal json:policy_types 4 120
for ((i=1; i<=$OSC_NUM_RICS; i++))
do
- api_equal json:policy_types?ric=ricsim_g1_$i 2 120
+ api_equal json:policy_types?ric=$RIC_SIM_PREFIX"_g1_"$i 3 120
done
# Check the schemas in OSC
for ((i=1; i<=$OSC_NUM_RICS; i++))
do
api_get_policy_schema 200 2 testdata/OSC/hw-agent-modified.json
+ api_get_policy_schema 200 100 testdata/OSC/qos-agent-modified.json
api_get_policy_schema 200 20008 testdata/OSC/tsa-agent-modified.json
done
# Create policies
use_agent_rest_http
-api_put_service 201 "rapp1" 0 "$CR_PATH/1"
+api_put_service 201 "Emergency-response-app" 0 "$CR_PATH/1"
# Create policies in OSC
for ((i=1; i<=$OSC_NUM_RICS; i++))
do
- api_put_policy 201 "rapp1" ricsim_g1_$i 2 $((2000+$i)) NOTRANSIENT testdata/OSC/pihw_template.json 1
- api_put_policy 201 "rapp1" ricsim_g1_$i 20008 $((2050+$i*10)) NOTRANSIENT testdata/OSC/pitsa_template.json 1
+ generate_uuid
+ api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g1_"$i 2 $((2000+$i)) NOTRANSIENT testdata/OSC/pihw_template.json 1
+ generate_uuid
+ api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g1_"$i 100 $((3000+$i)) NOTRANSIENT testdata/OSC/piqos_template.json 1
+ generate_uuid
+ api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g1_"$i 20008 $((4000+$i)) NOTRANSIENT testdata/OSC/pitsa_template.json 1
done
# Check the number of policies in OSC
for ((i=1; i<=$OSC_NUM_RICS; i++))
do
- sim_equal ricsim_g1_$i num_instances 2
+ sim_equal $RIC_SIM_PREFIX"_g1_"$i num_instances 3
done
# Create policies in STD
for ((i=1; i<=$STD_NUM_RICS; i++))
do
- api_put_policy 201 "rapp1" ricsim_g2_$i NOTYPE $((2100+$i)) NOTRANSIENT testdata/STD/pi1_template.json 1
+ generate_uuid
+ api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g2_"$i NOTYPE $((2100+$i)) NOTRANSIENT testdata/STD/pi1_template.json 1
done
# Check the number of policies in STD
for ((i=1; i<=$STD_NUM_RICS; i++))
do
- sim_equal ricsim_g2_$i num_instances 1
+ sim_equal $RIC_SIM_PREFIX"_g2_"$i num_instances 1
done
check_policy_agent_logs
"qosId"
]
},
- "qosObjective": {
+ "qosObjectives": {
"type": "object",
"properties": {
"priorityLevel": {
},
"additionalProperties": false,
"required": [
- "scope", "qosObjective"
+ "scope", "qosObjectives"
]
}
"qosId"
]
},
- "qosObjective": {
+ "qosObjectives": {
"type": "object",
"properties": {
"priorityLevel": {
},
"additionalProperties": false,
"required": [
- "scope", "qosObjective"
+ "scope", "qosObjectives"
]
}
"groupId"
]
},
- "qosObjective": {
+ "qosObjectives": {
"type": "object",
"properties": {
"priorityLevel": {
},
"additionalProperties": false,
"required": [
- "scope", "qosObjective"
+ "scope", "qosObjectives"
]
}
"groupId"
]
},
- "qosObjective": {
+ "qosObjectives": {
"type": "object",
"properties": {
"priorityLevel": {
},
"additionalProperties": false,
"required": [
- "scope", "qosObjective"
+ "scope", "qosObjectives"
]
}
"cellId"
]
},
- "qosObjective": {
+ "qosObjectives": {
"type": "object",
"properties": {
"priorityLevel": {
},
"additionalProperties": false,
"required": [
- "scope", "qosObjective"
+ "scope", "qosObjectives"
]
}
"cellId"
]
},
- "qosObjective": {
+ "qosObjectives": {
"type": "object",
"properties": {
"priorityLevel": {
},
"additionalProperties": false,
"required": [
- "scope", "qosObjective"
+ "scope", "qosObjectives"
]
}
"cellId"
]
},
- "qosObjective": {
+ "qosObjectives": {
"type": "object",
"properties": {
"priorityLevel": {
},
"additionalProperties": false,
"required": [
- "scope", "qosObjective"
+ "scope", "qosObjectives"
]
}
"cellId"
]
},
- "qosObjective": {
+ "qosObjectives": {
"type": "object",
"properties": {
"priorityLevel": {
},
"additionalProperties": false,
"required": [
- "scope", "qosObjective"
+ "scope", "qosObjectives"
]
}
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "2",
- "description": "HW policy type",
+ "description": "Hello World policy type",
"type": "object",
"properties": {
"threshold": {
{
"$schema": "http://json-schema.org/draft-07/schema#",
- "title": "HW Policy",
- "description": "HW policy type",
+ "title": "Hello World Policy",
+ "description": "Hello World policy type",
"type": "object",
"properties": {
"threshold": {
"ueId": "ueXXX",
"qosId": "qosXXX"
},
- "qosObjective": {
+ "qosObjectives": {
"priorityLevel": XXX
}
}
\ No newline at end of file
"scope": {
"groupId": "groupXXX"
},
- "qosObjective": {
+ "qosObjectives": {
"priorityLevel": XXX
}
}
\ No newline at end of file
"scope": {
"cellId": "cellXXX"
},
- "qosObjective": {
+ "qosObjectives": {
"priorityLevel": XXX
}
}
\ No newline at end of file
"sliceId": "sliceXXX",
"cellId": "cellXXX"
},
- "qosObjective": {
+ "qosObjectives": {
"priorityLevel": XXX
}
}
\ No newline at end of file
--- /dev/null
+{
+ "scope": {
+ "ueId": "ueXXX",
+ "qosId": "qosXXX"
+ },
+ "qosObjectives": {
+ "priorityLevel": XXX
+ }
+ }
\ No newline at end of file
--- /dev/null
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "100",
+ "description": "Quality of Service policy type",
+ "type": "object",
+ "properties": {
+ "scope": {
+ "type": "object",
+ "properties": {
+ "ueId": {
+ "type": "string"
+ },
+ "qosId": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "ueId",
+ "qosId"
+ ]
+ },
+ "qosObjectives": {
+ "type": "object",
+ "properties": {
+ "priorityLevel": {
+ "type": "number"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "priorityLevel"
+ ]
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "scope", "qosObjectives"
+ ]
+ }
--- /dev/null
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "OSC_Type1_1.0.0",
+ "description": "Quality of Service policy type",
+ "type": "object",
+ "properties": {
+ "scope": {
+ "type": "object",
+ "properties": {
+ "ueId": {
+ "type": "string"
+ },
+ "qosId": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "ueId",
+ "qosId"
+ ]
+ },
+ "qosObjectives": {
+ "type": "object",
+ "properties": {
+ "priorityLevel": {
+ "type": "number"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "priorityLevel"
+ ]
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "scope", "qosObjectives"
+ ]
+}
"qosId"
]
},
- "qosObjective": {
+ "qosObjectives": {
"type": "object",
"properties": {
"priorityLevel": {
},
"additionalProperties": false,
"required": [
- "scope", "qosObjective"
+ "scope", "qosObjectives"
]
}
}
"groupId"
]
},
- "qosObjective": {
+ "qosObjectives": {
"type": "object",
"properties": {
"priorityLevel": {
},
"additionalProperties": false,
"required": [
- "scope", "qosObjective"
+ "scope", "qosObjectives"
]
}
}
"cellId"
]
},
- "qosObjective": {
+ "qosObjectives": {
"type": "object",
"properties": {
"priorityLevel": {
},
"additionalProperties": false,
"required": [
- "scope", "qosObjective"
+ "scope", "qosObjectives"
]
}
}
"cellId"
]
},
- "qosObjective": {
+ "qosObjectives": {
"type": "object",
"properties": {
"priorityLevel": {
},
"additionalProperties": false,
"required": [
- "scope", "qosObjective"
+ "scope", "qosObjectives"
]
}
}
"create_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "HW Policy",
- "description": "HW policy type",
+ "description": "Hello World policy type",
"type": "object",
"properties": {
"threshold": {
--- /dev/null
+{
+ "name": "pt1",
+ "description": "pt1 policy type",
+ "policy_type_id": 100,
+ "create_schema": {
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "OSC_Type1_1.0.0",
+ "description": "Quality of Service policy type",
+ "type": "object",
+ "properties": {
+ "scope": {
+ "type": "object",
+ "properties": {
+ "ueId": {
+ "type": "string"
+ },
+ "qosId": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "ueId",
+ "qosId"
+ ]
+ },
+ "qosObjectives": {
+ "type": "object",
+ "properties": {
+ "priorityLevel": {
+ "type": "number"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "priorityLevel"
+ ]
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "scope", "qosObjectives"
+ ]
+ }
+}
"create_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "TS Policy",
- "description": "TS policy type",
+ "description": "Traffic Steering - High prio traffic - policy type",
"type": "object",
"properties": {
"threshold": {
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "20008",
- "description": "TS policy type",
+ "description": "Traffic Steering - High prio traffic - policy type",
"type": "object",
"properties": {
"threshold": {
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "TS Policy",
- "description": "TS policy type",
+ "description": "Traffic Steering - High prio traffic - policy type",
"type": "object",
"properties": {
"threshold": {
"ueId": "ueXXX",
"qosId": "qosXXX"
},
- "qosObjective": {
+ "qosObjectives": {
"priorityLevel": XXX
}
}
\ No newline at end of file
| `remote-remove` | same as remote but all images are removed first so that fresh images are pulled when running |
| `auto-clean` | all containers will be automatically stopped and removed when the test case is complete. Requires the function 'auto_clean_containers' to be included last in the applicable auto-test script |
| `--stop-at-error` | intended for debugging and make the script stop at first 'FAIL' and save all logs with a prefix 'STOP_AT_ERROR' |
-| `--use-local-image` | Only applicable when running as 'remote' or 'remote-remove'. Mainly for debugging when a locally built image shall be used together with other remote images from nexus.Accepts a space separated list of PA, CP, RICSIM, SDNC for Policy Agent, Control Panel, A1-controller and the Ric simulator |
+| `--use-local-image <app-nam> [<app-name>]*` | nnly applicable when running as 'remote' or 'remote-remove'. Mainly for debugging when a locally built image shall be used together with other remote images from nexus.Accepts a space separated list of PA, CP, RICSIM, SDNC for Policy Agent, Control Panel, A1-controller and the Ric simulator |
+| `--ricsim-prefix <prefix>` | use another prefix for the ric simulator container name than the standard 'ricsim'. Note that the testscript has to read and use the env var `$RIC_SIM_PREFIX` instead of a hardcoded name of the ric(s). |
#### Function: print_result ####
Print a test report of an auto-test script.
| `<sleep-time-in-sec> ` | Number of seconds to sleep |
| `<any-text-in-quotes-to-be-printed>` | Optional. The text will be printed, if present |
-
+#### Function: generate_uuid ####
+Geneate a UUID prefix to use along with the policy instance number when creating/deleting policies. Sets the env var UUID.
+UUID is then automatically added to the policy id in GET/PUT/DELETE.
+| arg list |
+|--|
+| None |
#### Function: consul_config_app ####
Function to load a json config from a file into consul for the Policy Agent
fi
if [ $paramError -ne 0 ]; then
- __print_err "<response-code> <ric-id>|NORIC <service-id>|NOSERVICE <policy-ype-id>|NOTYPE [ NOID | [<policy-id> <ric-id> <service-id> EMPTY|<policy-type-id> <template-file>]*]" $@
+ __print_err "<response-code> <ric-id>|NORIC <service-id>|NOSERVICE <policy-type-id>|NOTYPE [ NOID | [<policy-id> <ric-id> <service-id> EMPTY|<policy-type-id> <template-file>]*]" $@
return 1
fi
queryparams=""
if [ "$targetJson" != "[" ]; then
targetJson=$targetJson","
fi
- targetJson=$targetJson"{\"id\":\"${arr[$i]}\",\"lastModified\":\"????\",\"ric\":\"${arr[$i+1]}\",\"service\":\"${arr[$i+2]}\",\"type\":"
+ targetJson=$targetJson"{\"id\":\"$UUID${arr[$i]}\",\"lastModified\":\"????\",\"ric\":\"${arr[$i+1]}\",\"service\":\"${arr[$i+2]}\",\"type\":"
if [ "${arr[$i+3]}" == "EMPTY" ]; then
targetJson=$targetJson"\"\","
else
return 1
fi
- query="/policy?id=$2"
+ query="/policy?id=$UUID$2"
res="$(__do_curl_to_agent GET $query)"
status=${res:${#res}-3}
file=$7
while [ $count -lt $max ]; do
- query="/policy?id=$pid&ric=$ric&service=$2"
+ query="/policy?id=$UUID$pid&ric=$ric&service=$2"
if [ $4 != "NOTYPE" ]; then
query=$query"&type=$4"
status=${res:${#res}-3}
echo -ne " Creating "$count"("$max")${SAMELINE}"
if [ $status -ne $1 ]; then
- let pid=$pid+1
echo " Created "$count"?("$max")"
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
file=$7
ARR=""
while [ $count -lt $max ]; do
- query="/policy?id=$pid&ric=$ric&service=$2"
+ query="/policy?id=$UUID$pid&ric=$ric&service=$2"
if [ $4 != "NOTYPE" ]; then
query=$query"&type=$4"
echo -ne " Requested(batch) "$count"("$max")${SAMELINE}"
if [ $status -ne 200 ]; then
- let pid=$pid+1
echo " Requested(batch) "$count"?("$max")"
echo -e $RED" FAIL. Exepected status 200 (in request), got "$status $ERED
((RES_FAIL++))
echo -ne " Created(batch) "$count"("$max")${SAMELINE}"
if [ $status -ne $1 ]; then
- let pid=$pid+1
echo " Created(batch) "$count"?("$max")"
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
for ((i=1; i<=$pids; i++))
do
+ uuid=$UUID
+ if [ -z "$uuid" ]; then
+ uuid="NOUUID"
+ fi
echo "" > ".pid${i}.res.txt"
- echo $resp_code $urlbase $ric_base $num_rics $start_id $template $count $pids $i > ".pid${i}.txt"
+ echo $resp_code $urlbase $ric_base $num_rics $uuid $start_id $template $count $pids $i > ".pid${i}.txt"
echo $i
done | xargs -n 1 -I{} -P $pids bash -c '{
arg=$(echo {})
pid=$2
while [ $count -lt $max ]; do
- query="/policy?id="$pid
+ query="/policy?id="$UUID$pid
res="$(__do_curl_to_agent DELETE $query)"
status=${res:${#res}-3}
echo -ne " Deleting "$count"("$max")${SAMELINE}"
pid=$2
ARR=""
while [ $count -lt $max ]; do
- query="/policy?id="$pid
+ query="/policy?id="$UUID$pid
res="$(__do_curl_to_agent DELETE_BATCH $query)"
status=${res:${#res}-3}
echo -ne " Requested(batch) "$count"("$max")${SAMELINE}"
if [ $status -ne 200 ]; then
- let pid=$pid+1
echo " Requested(batch) "$count"?("$max")"
echo -e $RED" FAIL. Exepected status 200 (in request), got "$status $ERED
((RES_FAIL++))
echo -ne " Deleted(batch) "$count"("$max")${SAMELINE}"
if [ $status -ne $1 ]; then
- let pid=$pid+1
echo " Deleted(batch) "$count"?("$max")"
echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
((RES_FAIL++))
for ((i=1; i<=$pids; i++))
do
+ uuid=$UUID
+ if [ -z "$uuid" ]; then
+ uuid="NOUUID"
+ fi
echo "" > ".pid${i}.del.res.txt"
- echo $resp_code $urlbase $num_rics $start_id $count $pids $i > ".pid${i}.del.txt"
+ echo $resp_code $urlbase $num_rics $uuid $start_id $count $pids $i > ".pid${i}.del.txt"
echo $i
done | xargs -n 1 -I{} -P $pids bash -c '{
arg=$(echo {})
targetJson=$targetJson","
fi
if [ $pid != "NOID" ]; then
- targetJson=$targetJson"\"$pid\""
+ targetJson=$targetJson"\"$UUID$pid\""
fi
done
return 1
fi
- query="/policy_status?id="$2
+ query="/policy_status?id="$UUID$2
res="$(__do_curl_to_agent GET $query)"
status=${res:${#res}-3}
if [ "$targetJson" != "[" ]; then
targetJson=$targetJson","
fi
- targetJson=$targetJson"\"$pid\""
+ targetJson=$targetJson"\"$UUID$pid\""
done
targetJson=$targetJson"]"
paramError=1
if [ $# -eq 5 ] && [ $2 == "OSC" ]; then
- url="http://$3:$RIC_SIM_INTERNAL_PORT/a1-p/policytypes/$4/policies/$5"
+ url="http://$3:$RIC_SIM_INTERNAL_PORT/a1-p/policytypes/$4/policies/$UUID$5"
paramError=0
elif [ $# -eq 4 ] && [ $2 == "STD" ]; then
- url="http://$3:$RIC_SIM_INTERNAL_PORT/A1-P/v1/policies/$4"
+ url="http://$3:$RIC_SIM_INTERNAL_PORT/A1-P/v1/policies/$UUID$4"
paramError=0
fi
paramError=1
if [ $# -eq 6 ] && [ $2 == "OSC" ]; then
- url="http://$3:$RIC_SIM_INTERNAL_PORT/a1-p/policytypes/$4/policies/$5"
+ url="http://$3:$RIC_SIM_INTERNAL_PORT/a1-p/policytypes/$4/policies/$UUID$5"
body=$(sed 's/XXX/'${5}'/g' $6)
paramError=0
elif [ $# -eq 5 ] && [ $2 == "STD" ]; then
- url="http://$3:$RIC_SIM_INTERNAL_PORT/A1-P/v1/policies/$4"
+ url="http://$3:$RIC_SIM_INTERNAL_PORT/A1-P/v1/policies/$UUID$4"
body=$(sed 's/XXX/'${4}'/g' $5)
paramError=0
fi
targetJson=""
paramError=1
if [ $# -ge 5 ] && [ $2 == "OSC" ]; then
- url="http://$3:$RIC_SIM_INTERNAL_PORT/a1-p/policytypes/$4/policies/$5/status"
+ url="http://$3:$RIC_SIM_INTERNAL_PORT/a1-p/policytypes/$4/policies/$UUID$5/status"
if [ $# -gt 5 ]; then
targetJson="{\"instance_status\":\"$6\""
targetJson=$targetJson",\"has_been_deleted\":\"$7\""
fi
paramError=0
elif [ $# -ge 4 ] && [ $2 == "STD" ]; then
- url="http://$3:$RIC_SIM_INTERNAL_PORT/A1-P/v1/policies/$4/status"
+ url="http://$3:$RIC_SIM_INTERNAL_PORT/A1-P/v1/policies/$UUID$4/status"
if [ $# -gt 4 ]; then
targetJson="{\"enforceStatus\":\"$5\""
if [ $# -eq 6 ]; then
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
-#arg responsecode baseurl ric_base num_rics startid templatepath count pids pid_id
+#arg responsecode baseurl ric_base num_rics uuid startid templatepath count pids pid_id
try:
- if len(sys.argv) != 10:
- print("1Expected 9 args, got "+str(len(sys.argv)-1)+ ". Args: responsecode baseurl ric_base num_rics startid templatepath count pids pid_id")
+ if len(sys.argv) != 11:
+ print("1Expected 10 args, got "+str(len(sys.argv)-1)+ ". Args: responsecode baseurl ric_base num_rics uuid startid templatepath count pids pid_id")
sys.exit()
responsecode=int(sys.argv[1])
baseurl=sys.argv[2]
ric_base=sys.argv[3]
num_rics=int(sys.argv[4])
- start=int(sys.argv[5])
- templatepath=sys.argv[6]
- count=int(sys.argv[7])
- pids=int(sys.argv[8])
- pid_id=int(sys.argv[9])
+ uuid=sys.argv[5]
+ start=int(sys.argv[6])
+ templatepath=sys.argv[7]
+ count=int(sys.argv[8])
+ pids=int(sys.argv[9])
+ pid_id=int(sys.argv[10])
+
+ if uuid == "NOUUID":
+ uuid=""
with open(templatepath, 'r') as file:
template = file.read()
payload=template.replace("XXX",str(i))
ric_id=(i%num_rics)+1
ric=ric_base+str(ric_id)
- url=baseurl+"&id="+str(i)+"&ric="+str(ric)
+ url=baseurl+"&id="+uuid+str(i)+"&ric="+str(ric)
try:
headers = {'Content-type': 'application/json'}
resp=requests.put(url, json.dumps(json.loads(payload)), headers=headers, verify=False, timeout=90)
except Exception as e1:
- print("1Put failed for id:"+str(i)+ ", "+str(e1) + " "+traceback.format_exc())
+ print("1Put failed for id:"+uuid+str(i)+ ", "+str(e1) + " "+traceback.format_exc())
sys.exit()
if (resp.status_code == None):
- print("1Put failed for id:"+str(i)+ ", expected response code: "+responsecode+", got: None")
+ print("1Put failed for id:"+uuid+str(i)+ ", expected response code: "+responsecode+", got: None")
sys.exit()
if (resp.status_code != responsecode):
- print("1Put failed for id:"+str(i)+ ", expected response code: "+responsecode+", got: "+str(resp.status_code))
+ print("1Put failed for id:"+uuid+str(i)+ ", expected response code: "+responsecode+", got: "+str(resp.status_code))
sys.exit()
print("0")
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
-#arg responsecode baseurl num_rics startid count pids pid_id
+#arg responsecode baseurl num_rics uuid startid count pids pid_id
try:
- if len(sys.argv) != 8:
- print("1Expected 7 args, got "+str(len(sys.argv)-1)+ ". Args: responsecode baseurl num_rics startid count pids pid_id")
+ if len(sys.argv) != 9:
+ print("1Expected 8 args, got "+str(len(sys.argv)-1)+ ". Args: responsecode baseurl num_rics uuid startid count pids pid_id")
sys.exit()
responsecode=int(sys.argv[1])
baseurl=sys.argv[2]
num_rics=int(sys.argv[3])
- start=int(sys.argv[4])
- count=int(sys.argv[5])
- pids=int(sys.argv[6])
- pid_id=int(sys.argv[7])
+ uuid=sys.argv[4]
+ start=int(sys.argv[5])
+ count=int(sys.argv[6])
+ pids=int(sys.argv[7])
+ pid_id=int(sys.argv[8])
+
+ if uuid == "NOUUID":
+ uuid=""
stop=count*num_rics+start
for i in range(start,stop):
if (i%pids == (pid_id-1)):
- url=str(baseurl+"?id="+str(i))
+ url=str(baseurl+"?id="+uuid+str(i))
try:
resp=requests.delete(url, verify=False, timeout=90)
except Exception as e1:
- print("1Delete failed for id:"+str(i)+ ", "+str(e1) + " "+traceback.format_exc())
+ print("1Delete failed for id:"+uuid+str(i)+ ", "+str(e1) + " "+traceback.format_exc())
sys.exit()
if (resp.status_code == None):
- print("1Delete failed for id:"+str(i)+ ", expected response code: "+responsecode+", got: None")
+ print("1Delete failed for id:"+uuid+str(i)+ ", expected response code: "+responsecode+", got: None")
sys.exit()
if (resp.status_code != responsecode):
- print("1Delete failed for id:"+str(i)+ ", expected response code: "+responsecode+", got: "+str(resp.status_code))
+ print("1Delete failed for id:"+uuid+str(i)+ ", expected response code: "+responsecode+", got: "+str(resp.status_code))
sys.exit()
print("0")
export RIC_SIM_BASE="g" # Base name of the RIC Simulator container, shall be the group code
# Note, a prefix is added to each container name by the .env file in the 'ric' dir
RIC_SIM_PREFIX="ricsim" # Prefix added to ric container name, added in the .env file in the 'ric' dir
+ # This prefix can be changed from the command line
export RIC_SIM_INTERNAL_PORT=8085 # RIC Simulator container internal port (container -> container).
# (external ports allocated by docker)
export RIC_SIM_INTERNAL_SECURE_PORT=8185 # RIC Simulator container internal secure port (container -> container).
export CONTROL_PANEL_INTERNAL_PORT=8080 # Control Panel container external port (host -> container)
CONTROL_PANEL_LOGPATH="/logs/nonrtric-controlpanel.log" # Path the application log in the Control Panel container
+UUID="" # UUID used as prefix to the policy id to simulate a real UUID
+ # Testscript need to set the UUID to use other this empty prefix is used
+
RESTBASE="http://localhost:"$POLICY_AGENT_EXTERNAL_PORT # Base url to the Agent NB REST interface
RESTBASE_SECURE="https://localhost:"$POLICY_AGENT_EXTERNAL_SECURE_PORT # Base url to the secure Agent NB REST interface
DMAAPBASE="http://localhost:"$MR_EXTERNAL_PORT # Base url to the Dmaap adapter
#
# This is a script that contains all the functions needed for auto test
-# Arg: local|remote|remote-remove [auto-clean]
+# Arg: local|remote|remote-remove [auto-clean] [--stop-at-error] [--ricsim-prefix <prefix> ] [--use-local-image <app-nam> [<app-name>]*]
#Formatting for 'echo' cmd
# Var to hold the app names to use local image for when running 'remote' or 'remote-remove'
USE_LOCAL_IMAGES=""
+# List of available apps to override with local image
+AVAILABLE_LOCAL_IMAGES_OVERRIDE="PA CP SDNC RICSIM"
+
# Use this var (STOP_AT_ERROR=1 in the test script) for debugging/trouble shooting to take all logs and exit at first FAIL test case
STOP_AT_ERROR=0
shift;
fi
fi
-if [ $paramerror -eq 0 ]; then
- if [ "$1" == "auto-clean" ]; then
- AUTO_CLEAN="auto"
- shift;
+foundparm=0
+while [ $paramerror -eq 0 ] && [ $foundparm -eq 0 ]; do
+ foundparm=1
+ if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "auto-clean" ]; then
+ AUTO_CLEAN="auto"
+ echo "Option set - Auto clean at end of test script"
+ shift;
+ foundparm=0
+ fi
fi
-fi
-if [ $paramerror -eq 0 ]; then
- if [ "$1" == "--stop-at-error" ]; then
- STOP_AT_ERROR=1
- shift;
+ if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "--stop-at-error" ]; then
+ STOP_AT_ERROR=1
+ echo "Option set - Stop at first error"
+ shift;
+ foundparm=0
+ fi
fi
-fi
-if [ $paramerror -eq 0 ]; then
- if [ "$1" == "--use-local-image" ]; then
- USE_LOCAL_IMAGES=${@:2}
- while [ $# -gt 0 ]; do
+ if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "--ricsim-prefix" ]; then
shift;
- done
+ RIC_SIM_PREFIX=$1
+ if [ -z "$1" ]; then
+ paramerror=1
+ else
+ echo "Option set - Overriding RIC_SIM_PREFIX with: "$1
+ shift;
+ foundparm=0
+ fi
+ fi
fi
-fi
+ if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "--use-local-image" ]; then
+ USE_LOCAL_IMAGES=""
+ shift
+ while [ $# -gt 0 ] && [[ "$1" != "--"* ]]; do
+ USE_LOCAL_IMAGES=$USE_LOCAL_IMAGES" "$1
+ if [[ "$AVAILABLE_LOCAL_IMAGES_OVERRIDE" != *"$1"* ]]; then
+ paramerror=1
+ fi
+ shift;
+ done
+ foundparm=0
+ if [ -z "$USE_LOCAL_IMAGES" ]; then
+ paramerror=1
+ else
+ echo "Option set - Override remote images for app(s):"$USE_LOCAL_IMAGES
+ fi
+ fi
+ fi
+done
+echo ""
+#Still params left?
if [ $paramerror -eq 0 ] && [ $# -gt 0 ]; then
paramerror=1
fi
if [ $paramerror -eq 1 ]; then
- echo -e $RED"Expected arg: local|remote|remote-remove [auto-clean] [--stop-at-error] [--use-local-image <app-nam> [<app-name>]*]"$ERED
+ echo -e $RED"Expected arg: local|remote|remote-remove [auto-clean] [--stop-at-error] [--ricsim-prefix <prefix> ] [--use-local-image <app-nam> [<app-name>]*]"$ERED
exit 1
fi
echo -e $BOLD" Removing all dangling/untagged docker images"$EBOLD
docker rmi --force $(docker images -q -f dangling=true) &> /dev/null
echo ""
+
+ CONTRS=$(docker ps | awk '$1 != "CONTAINER" { n++ }; END { print n+0 }')
+ if [ $? -eq 0 ]; then
+ if [ $CONTRS -ne 0 ]; then
+ echo -e $RED"Containers running, may cause distubance to the test case"$ERED
+ docker ps -a
+ fi
+ fi
}
# Function stop and remove all container in the end of the test script, if the arg 'auto-clean' is given at test script start
return 0
}
+# Generate a UUID to use as prefix for policy ids
+generate_uuid() {
+ UUID=$(python3 -c 'import sys,uuid; sys.stdout.write(uuid.uuid4().hex)')
+ #Reduce length to make space for serial id, us 'a' as marker where the serial id is added
+ UUID=${UUID:0:${#UUID}-4}"a"
+}
+
####################
### Consul functions
####################
config_json=$config_json"\n \"ric\": ["
- rics=$(docker ps | grep ricsim | awk '{print $NF}')
+ rics=$(docker ps | grep $RIC_SIM_PREFIX | awk '{print $NF}')
if [ $? -ne 0 ] || [ -z "$rics" ]; then
echo -e $RED" FAIL - the names of the running RIC Simulator cannot be retrieved." $ERED
}
# Start one group (ricsim_g1, ricsim_g2 or ricsim_g3) with a number of RIC Simulators using a given A interface
+# 'ricsim' may be set on command line to other prefix
# args: ricsim_g1|ricsim_g2|ricsim_g3 <count> <interface-id>
# (Function for test scripts)
start_ric_simulators() {
echo -e $BOLD"Starting RIC Simulators"$EBOLD
+ RIC1=$RIC_SIM_PREFIX"_g1"
+ RIC2=$RIC_SIM_PREFIX"_g2"
+ RIC3=$RIC_SIM_PREFIX"_g3"
+
if [ $# != 3 ]; then
((RES_CONF_FAIL++))
- __print_err "need three args, ricsim_g1|ricsim_g2|ricsim_g3 <count> <interface-id>" $@
+ __print_err "need three args, $RIC1|$RIC2|$RIC3 <count> <interface-id>" $@
exit 1
fi
echo " $2 simulators using basename: $1 on interface: $3"
#Set env var for simulator count and A1 interface vesion for the given group
- if [ $1 == "ricsim_g1" ]; then
+ if [ $1 == "$RIC1" ]; then
G1_COUNT=$2
G1_A1_VERSION=$3
- elif [ $1 == "ricsim_g2" ]; then
+ elif [ $1 == "$RIC2" ]; then
G2_COUNT=$2
G2_A1_VERSION=$3
- elif [ $1 == "ricsim_g3" ]; then
+ elif [ $1 == "$RIC3" ]; then
G3_COUNT=$2
G3_A1_VERSION=$3
else
((RES_CONF_FAIL++))
- __print_err "need three args, gricsim_g1|ricsim_g2|ricsim_g3 <count> <interface-id>" $@
+ __print_err "need three args, $RIC1|$RIC2|$RIC3 <count> <interface-id>" $@
exit 1
fi
function getSimCtr(url, index, cb) {
var data = '';
- console.log("URL: "+ url + " - ")
+ //console.log("URL: "+ url + " - ")
try {
http.get(url, (resp) => {
// A chunk of data has been recieved.
var refreshInterval=4000
+var ricbasename="ricsim"
+
function fetchAllMetrics() {
setTimeout(() => {
if (getCtr%3 == 0) {
//Extract the port numbers from the running simulators, for every 3 calls
const { exec } = require('child_process');
- exec('docker ps --filter "name=ricsim" --format "{{.Names}} {{.Ports}}" | sed s/0.0.0.0:// | cut -d \'>\' -f1 | sed \'s/[[-]]*$//\'', (err, stdout, stderr) => {
+ exec('docker ps --filter "name='+ricbasename+'" --format "{{.Names}} {{.Ports}}" | sed s/0.0.0.0:// | cut -d \'>\' -f1 | sed \'s/[[-]]*$//\'', (err, stdout, stderr) => {
var simulators = ""
simulators=`${stdout}`.replace(/(\r\n|\n|\r)/gm," ");
app.get("/mon",function(req, res){
+ var bn=req.query.basename
+
+ if (bn == undefined) {
+ getCtr=0
+ return res.redirect('/mon?basename=ricsim');
+ } else {
+ ricbasename=bn
+ }
refreshInterval=2000
"<title>Policy Agent and simulator monitor</title>"+
"</head>" +
"<body>" +
+ "<font size=\"-3\" face=\"monospace\">" +
+ "<p>Change basename in url if other ric sim prefix is used</p>" +
+ "</font>" +
"<h3>Policy agent</h3>" +
"<font face=\"monospace\">" +
"Status:..............................." + formatDataRow(ag1) + "<br>" +