From ad0477833fe6a8270f274e17f73022a2d881f074 Mon Sep 17 00:00:00 2001 From: BjornMagnussonXA Date: Mon, 8 Jun 2020 15:54:11 +0200 Subject: [PATCH] Added UUID to policy ids and new policy types Change-Id: I0b0f600b4c5f4f10e36a84c76d1b104fcf3d712d Issue-ID: NONRTRIC-154 Signed-off-by: BjornMagnussonXA --- test/auto-test/FTC1.sh | 2 + test/auto-test/FTC10.sh | 2 + test/auto-test/FTC100.sh | 2 + test/auto-test/FTC110.sh | 1 + test/auto-test/FTC150.sh | 2 + test/auto-test/FTC300.sh | 2 + test/auto-test/FTC310.sh | 1 + test/auto-test/FTC350.sh | 2 + test/auto-test/FTC800.sh | 2 + test/auto-test/FTC810.sh | 2 + test/auto-test/FTC850.sh | 4 + test/auto-test/FTC900.sh | 37 +++++--- test/auto-test/testdata/OSC/1-agent-modified.json | 4 +- test/auto-test/testdata/OSC/1.json | 4 +- test/auto-test/testdata/OSC/3-agent-modified.json | 4 +- test/auto-test/testdata/OSC/3.json | 4 +- test/auto-test/testdata/OSC/4-agent-modified.json | 4 +- test/auto-test/testdata/OSC/4.json | 4 +- test/auto-test/testdata/OSC/5-agent-modified.json | 4 +- test/auto-test/testdata/OSC/5.json | 4 +- test/auto-test/testdata/OSC/hw-agent-modified.json | 2 +- test/auto-test/testdata/OSC/hw.json | 4 +- test/auto-test/testdata/OSC/pi1_template.json | 2 +- test/auto-test/testdata/OSC/pi3_template.json | 2 +- test/auto-test/testdata/OSC/pi4_template.json | 2 +- test/auto-test/testdata/OSC/pi5_template.json | 2 +- test/auto-test/testdata/OSC/piqos_template.json | 9 ++ .../auto-test/testdata/OSC/qos-agent-modified.json | 40 ++++++++ test/auto-test/testdata/OSC/qos.json | 40 ++++++++ test/auto-test/testdata/OSC/sim_1.json | 4 +- test/auto-test/testdata/OSC/sim_3.json | 4 +- test/auto-test/testdata/OSC/sim_4.json | 4 +- test/auto-test/testdata/OSC/sim_5.json | 4 +- test/auto-test/testdata/OSC/sim_hw.json | 2 +- test/auto-test/testdata/OSC/sim_qos.json | 45 +++++++++ test/auto-test/testdata/OSC/sim_tsa.json | 2 +- .../auto-test/testdata/OSC/tsa-agent-modified.json | 2 +- test/auto-test/testdata/OSC/tsa.json | 2 +- test/auto-test/testdata/STD/pi1_template.json | 2 +- test/common/README.md | 10 +- test/common/agent_api_functions.sh | 35 +++---- test/common/controller_api_functions.sh | 14 +-- test/common/create_policies_process.py | 28 +++--- test/common/delete_policies_process.py | 26 ++--- test/common/test_env.sh | 4 + test/common/testcase_common.sh | 105 ++++++++++++++++----- test/simulator-group/sim-monitor.js | 17 +++- 47 files changed, 379 insertions(+), 125 deletions(-) create mode 100644 test/auto-test/testdata/OSC/piqos_template.json create mode 100644 test/auto-test/testdata/OSC/qos-agent-modified.json create mode 100644 test/auto-test/testdata/OSC/qos.json create mode 100644 test/auto-test/testdata/OSC/sim_qos.json diff --git a/test/auto-test/FTC1.sh b/test/auto-test/FTC1.sh index 877a2097..d9a88b17 100755 --- a/test/auto-test/FTC1.sh +++ b/test/auto-test/FTC1.sh @@ -35,6 +35,8 @@ EXCLUDED_IMAGES="SDNC_ONAP" # 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) diff --git a/test/auto-test/FTC10.sh b/test/auto-test/FTC10.sh index 771ee555..eaa6de29 100755 --- a/test/auto-test/FTC10.sh +++ b/test/auto-test/FTC10.sh @@ -28,6 +28,8 @@ EXCLUDED_IMAGES="SDNC SDNC_ONAP" #### TEST BEGIN #### +generate_uuid + #Local vars in test script ########################## # Path to callback receiver diff --git a/test/auto-test/FTC100.sh b/test/auto-test/FTC100.sh index 8ee7e37b..6f90437e 100755 --- a/test/auto-test/FTC100.sh +++ b/test/auto-test/FTC100.sh @@ -29,6 +29,8 @@ EXCLUDED_IMAGES="SDNC_ONAP" #### TEST BEGIN #### +generate_uuid + #Local vars in test script ########################## diff --git a/test/auto-test/FTC110.sh b/test/auto-test/FTC110.sh index 1efce997..8427ad14 100755 --- a/test/auto-test/FTC110.sh +++ b/test/auto-test/FTC110.sh @@ -27,6 +27,7 @@ EXCLUDED_IMAGES="SDMC SDNC_ONAP" . ../common/agent_api_functions.sh . ../common/ricsimulator_api_functions.sh +generate_uuid #Local vars in test script ########################## diff --git a/test/auto-test/FTC150.sh b/test/auto-test/FTC150.sh index 93203029..1cd2a33a 100755 --- a/test/auto-test/FTC150.sh +++ b/test/auto-test/FTC150.sh @@ -29,6 +29,8 @@ EXCLUDED_IMAGES="PA CP SDNC_ONAP" #### TEST BEGIN #### +generate_uuid + #Test agent and simulator protocol versions (others are http only) TESTED_PROTOCOLS="HTTP HTTPS" diff --git a/test/auto-test/FTC300.sh b/test/auto-test/FTC300.sh index 93206062..2ab4385b 100755 --- a/test/auto-test/FTC300.sh +++ b/test/auto-test/FTC300.sh @@ -28,6 +28,8 @@ EXCLUDED_IMAGES="SDNC_ONAP" #### TEST BEGIN #### +generate_uuid + #Local vars in test script ########################## # Path to callback receiver diff --git a/test/auto-test/FTC310.sh b/test/auto-test/FTC310.sh index 18d68163..7eb3c19b 100755 --- a/test/auto-test/FTC310.sh +++ b/test/auto-test/FTC310.sh @@ -30,6 +30,7 @@ EXCLUDED_IMAGES="SDNC_ONAP" #### TEST BEGIN #### +generate_uuid # Clean container and start all needed containers # clean_containers diff --git a/test/auto-test/FTC350.sh b/test/auto-test/FTC350.sh index 0fe253f5..416a77dc 100755 --- a/test/auto-test/FTC350.sh +++ b/test/auto-test/FTC350.sh @@ -28,6 +28,8 @@ EXCLUDED_IMAGES="SDNC_ONAP" #### TEST BEGIN #### +generate_uuid + #Local vars in test script ########################## # Path to callback receiver diff --git a/test/auto-test/FTC800.sh b/test/auto-test/FTC800.sh index 6bab06ba..e97f3ff6 100755 --- a/test/auto-test/FTC800.sh +++ b/test/auto-test/FTC800.sh @@ -28,6 +28,8 @@ EXCLUDED_IMAGES="SDNC_ONAP" #### TEST BEGIN #### +generate_uuid + #Local vars in test script ########################## # Path to callback receiver diff --git a/test/auto-test/FTC810.sh b/test/auto-test/FTC810.sh index 2dae7e75..e9f19f8c 100755 --- a/test/auto-test/FTC810.sh +++ b/test/auto-test/FTC810.sh @@ -28,6 +28,8 @@ EXCLUDED_IMAGES="SDNC_ONAP" #### TEST BEGIN #### +generate_uuid + #Local vars in test script ########################## # Path to callback receiver diff --git a/test/auto-test/FTC850.sh b/test/auto-test/FTC850.sh index f45246d1..32e450f2 100755 --- a/test/auto-test/FTC850.sh +++ b/test/auto-test/FTC850.sh @@ -42,6 +42,8 @@ TESTED_PROTOCOLS="HTTP HTTPS" NUM_RICS=20 NUM_POLICIES_PER_RIC=500 +generate_uuid + for __httpx in $TESTED_PROTOCOLS ; do for interface in $TESTED_VARIANTS ; do @@ -80,6 +82,8 @@ for __httpx in $TESTED_PROTOCOLS ; do start_mr # Not used, but removes error messages from the agent log + start_control_panel + start_policy_agent set_agent_debug diff --git a/test/auto-test/FTC900.sh b/test/auto-test/FTC900.sh index 5a719161..05b6ff63 100755 --- a/test/auto-test/FTC900.sh +++ b/test/auto-test/FTC900.sh @@ -17,7 +17,7 @@ # ============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" @@ -38,9 +38,9 @@ clean_containers 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... @@ -60,37 +60,39 @@ api_get_status 200 # 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 @@ -98,34 +100,39 @@ 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 diff --git a/test/auto-test/testdata/OSC/1-agent-modified.json b/test/auto-test/testdata/OSC/1-agent-modified.json index 3b37214a..a40aa88b 100644 --- a/test/auto-test/testdata/OSC/1-agent-modified.json +++ b/test/auto-test/testdata/OSC/1-agent-modified.json @@ -20,7 +20,7 @@ "qosId" ] }, - "qosObjective": { + "qosObjectives": { "type": "object", "properties": { "priorityLevel": { @@ -35,6 +35,6 @@ }, "additionalProperties": false, "required": [ - "scope", "qosObjective" + "scope", "qosObjectives" ] } diff --git a/test/auto-test/testdata/OSC/1.json b/test/auto-test/testdata/OSC/1.json index 5fe68ce0..c865bac5 100644 --- a/test/auto-test/testdata/OSC/1.json +++ b/test/auto-test/testdata/OSC/1.json @@ -20,7 +20,7 @@ "qosId" ] }, - "qosObjective": { + "qosObjectives": { "type": "object", "properties": { "priorityLevel": { @@ -35,6 +35,6 @@ }, "additionalProperties": false, "required": [ - "scope", "qosObjective" + "scope", "qosObjectives" ] } diff --git a/test/auto-test/testdata/OSC/3-agent-modified.json b/test/auto-test/testdata/OSC/3-agent-modified.json index 303b36b0..3bf9a47e 100644 --- a/test/auto-test/testdata/OSC/3-agent-modified.json +++ b/test/auto-test/testdata/OSC/3-agent-modified.json @@ -16,7 +16,7 @@ "groupId" ] }, - "qosObjective": { + "qosObjectives": { "type": "object", "properties": { "priorityLevel": { @@ -31,6 +31,6 @@ }, "additionalProperties": false, "required": [ - "scope", "qosObjective" + "scope", "qosObjectives" ] } diff --git a/test/auto-test/testdata/OSC/3.json b/test/auto-test/testdata/OSC/3.json index ab0204d5..4966dea6 100644 --- a/test/auto-test/testdata/OSC/3.json +++ b/test/auto-test/testdata/OSC/3.json @@ -16,7 +16,7 @@ "groupId" ] }, - "qosObjective": { + "qosObjectives": { "type": "object", "properties": { "priorityLevel": { @@ -31,6 +31,6 @@ }, "additionalProperties": false, "required": [ - "scope", "qosObjective" + "scope", "qosObjectives" ] } diff --git a/test/auto-test/testdata/OSC/4-agent-modified.json b/test/auto-test/testdata/OSC/4-agent-modified.json index 868ceea3..7fb71a62 100644 --- a/test/auto-test/testdata/OSC/4-agent-modified.json +++ b/test/auto-test/testdata/OSC/4-agent-modified.json @@ -16,7 +16,7 @@ "cellId" ] }, - "qosObjective": { + "qosObjectives": { "type": "object", "properties": { "priorityLevel": { @@ -31,6 +31,6 @@ }, "additionalProperties": false, "required": [ - "scope", "qosObjective" + "scope", "qosObjectives" ] } diff --git a/test/auto-test/testdata/OSC/4.json b/test/auto-test/testdata/OSC/4.json index c5e785c4..3891b76a 100644 --- a/test/auto-test/testdata/OSC/4.json +++ b/test/auto-test/testdata/OSC/4.json @@ -16,7 +16,7 @@ "cellId" ] }, - "qosObjective": { + "qosObjectives": { "type": "object", "properties": { "priorityLevel": { @@ -31,6 +31,6 @@ }, "additionalProperties": false, "required": [ - "scope", "qosObjective" + "scope", "qosObjectives" ] } diff --git a/test/auto-test/testdata/OSC/5-agent-modified.json b/test/auto-test/testdata/OSC/5-agent-modified.json index b5fd5bc1..1b1c508f 100644 --- a/test/auto-test/testdata/OSC/5-agent-modified.json +++ b/test/auto-test/testdata/OSC/5-agent-modified.json @@ -20,7 +20,7 @@ "cellId" ] }, - "qosObjective": { + "qosObjectives": { "type": "object", "properties": { "priorityLevel": { @@ -35,6 +35,6 @@ }, "additionalProperties": false, "required": [ - "scope", "qosObjective" + "scope", "qosObjectives" ] } diff --git a/test/auto-test/testdata/OSC/5.json b/test/auto-test/testdata/OSC/5.json index dee440a1..1708a1e3 100644 --- a/test/auto-test/testdata/OSC/5.json +++ b/test/auto-test/testdata/OSC/5.json @@ -20,7 +20,7 @@ "cellId" ] }, - "qosObjective": { + "qosObjectives": { "type": "object", "properties": { "priorityLevel": { @@ -35,6 +35,6 @@ }, "additionalProperties": false, "required": [ - "scope", "qosObjective" + "scope", "qosObjectives" ] } diff --git a/test/auto-test/testdata/OSC/hw-agent-modified.json b/test/auto-test/testdata/OSC/hw-agent-modified.json index c48736e7..5ea5802a 100644 --- a/test/auto-test/testdata/OSC/hw-agent-modified.json +++ b/test/auto-test/testdata/OSC/hw-agent-modified.json @@ -1,7 +1,7 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "2", - "description": "HW policy type", + "description": "Hello World policy type", "type": "object", "properties": { "threshold": { diff --git a/test/auto-test/testdata/OSC/hw.json b/test/auto-test/testdata/OSC/hw.json index 684f80df..b15b93e9 100644 --- a/test/auto-test/testdata/OSC/hw.json +++ b/test/auto-test/testdata/OSC/hw.json @@ -1,7 +1,7 @@ { "$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": { diff --git a/test/auto-test/testdata/OSC/pi1_template.json b/test/auto-test/testdata/OSC/pi1_template.json index 77958087..da255547 100644 --- a/test/auto-test/testdata/OSC/pi1_template.json +++ b/test/auto-test/testdata/OSC/pi1_template.json @@ -3,7 +3,7 @@ "ueId": "ueXXX", "qosId": "qosXXX" }, - "qosObjective": { + "qosObjectives": { "priorityLevel": XXX } } \ No newline at end of file diff --git a/test/auto-test/testdata/OSC/pi3_template.json b/test/auto-test/testdata/OSC/pi3_template.json index a916fad5..02d33bc8 100644 --- a/test/auto-test/testdata/OSC/pi3_template.json +++ b/test/auto-test/testdata/OSC/pi3_template.json @@ -2,7 +2,7 @@ "scope": { "groupId": "groupXXX" }, - "qosObjective": { + "qosObjectives": { "priorityLevel": XXX } } \ No newline at end of file diff --git a/test/auto-test/testdata/OSC/pi4_template.json b/test/auto-test/testdata/OSC/pi4_template.json index 0673dec9..dff4b6be 100644 --- a/test/auto-test/testdata/OSC/pi4_template.json +++ b/test/auto-test/testdata/OSC/pi4_template.json @@ -2,7 +2,7 @@ "scope": { "cellId": "cellXXX" }, - "qosObjective": { + "qosObjectives": { "priorityLevel": XXX } } \ No newline at end of file diff --git a/test/auto-test/testdata/OSC/pi5_template.json b/test/auto-test/testdata/OSC/pi5_template.json index e362c9e9..af6be9d3 100644 --- a/test/auto-test/testdata/OSC/pi5_template.json +++ b/test/auto-test/testdata/OSC/pi5_template.json @@ -3,7 +3,7 @@ "sliceId": "sliceXXX", "cellId": "cellXXX" }, - "qosObjective": { + "qosObjectives": { "priorityLevel": XXX } } \ No newline at end of file diff --git a/test/auto-test/testdata/OSC/piqos_template.json b/test/auto-test/testdata/OSC/piqos_template.json new file mode 100644 index 00000000..da255547 --- /dev/null +++ b/test/auto-test/testdata/OSC/piqos_template.json @@ -0,0 +1,9 @@ +{ + "scope": { + "ueId": "ueXXX", + "qosId": "qosXXX" + }, + "qosObjectives": { + "priorityLevel": XXX + } + } \ No newline at end of file diff --git a/test/auto-test/testdata/OSC/qos-agent-modified.json b/test/auto-test/testdata/OSC/qos-agent-modified.json new file mode 100644 index 00000000..3a012cd8 --- /dev/null +++ b/test/auto-test/testdata/OSC/qos-agent-modified.json @@ -0,0 +1,40 @@ +{ + "$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" + ] + } diff --git a/test/auto-test/testdata/OSC/qos.json b/test/auto-test/testdata/OSC/qos.json new file mode 100644 index 00000000..070ebe4e --- /dev/null +++ b/test/auto-test/testdata/OSC/qos.json @@ -0,0 +1,40 @@ +{ + "$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" + ] +} diff --git a/test/auto-test/testdata/OSC/sim_1.json b/test/auto-test/testdata/OSC/sim_1.json index 537d86f7..aeea7733 100644 --- a/test/auto-test/testdata/OSC/sim_1.json +++ b/test/auto-test/testdata/OSC/sim_1.json @@ -24,7 +24,7 @@ "qosId" ] }, - "qosObjective": { + "qosObjectives": { "type": "object", "properties": { "priorityLevel": { @@ -39,7 +39,7 @@ }, "additionalProperties": false, "required": [ - "scope", "qosObjective" + "scope", "qosObjectives" ] } } diff --git a/test/auto-test/testdata/OSC/sim_3.json b/test/auto-test/testdata/OSC/sim_3.json index 1b97047c..d21a9a90 100644 --- a/test/auto-test/testdata/OSC/sim_3.json +++ b/test/auto-test/testdata/OSC/sim_3.json @@ -20,7 +20,7 @@ "groupId" ] }, - "qosObjective": { + "qosObjectives": { "type": "object", "properties": { "priorityLevel": { @@ -35,7 +35,7 @@ }, "additionalProperties": false, "required": [ - "scope", "qosObjective" + "scope", "qosObjectives" ] } } diff --git a/test/auto-test/testdata/OSC/sim_4.json b/test/auto-test/testdata/OSC/sim_4.json index ac1fa2b3..a55b34e4 100644 --- a/test/auto-test/testdata/OSC/sim_4.json +++ b/test/auto-test/testdata/OSC/sim_4.json @@ -20,7 +20,7 @@ "cellId" ] }, - "qosObjective": { + "qosObjectives": { "type": "object", "properties": { "priorityLevel": { @@ -35,7 +35,7 @@ }, "additionalProperties": false, "required": [ - "scope", "qosObjective" + "scope", "qosObjectives" ] } } diff --git a/test/auto-test/testdata/OSC/sim_5.json b/test/auto-test/testdata/OSC/sim_5.json index 4d8f3c9c..fd5290fc 100644 --- a/test/auto-test/testdata/OSC/sim_5.json +++ b/test/auto-test/testdata/OSC/sim_5.json @@ -24,7 +24,7 @@ "cellId" ] }, - "qosObjective": { + "qosObjectives": { "type": "object", "properties": { "priorityLevel": { @@ -39,7 +39,7 @@ }, "additionalProperties": false, "required": [ - "scope", "qosObjective" + "scope", "qosObjectives" ] } } diff --git a/test/auto-test/testdata/OSC/sim_hw.json b/test/auto-test/testdata/OSC/sim_hw.json index 65085c58..47e0ae05 100644 --- a/test/auto-test/testdata/OSC/sim_hw.json +++ b/test/auto-test/testdata/OSC/sim_hw.json @@ -5,7 +5,7 @@ "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": { diff --git a/test/auto-test/testdata/OSC/sim_qos.json b/test/auto-test/testdata/OSC/sim_qos.json new file mode 100644 index 00000000..92eaa6ff --- /dev/null +++ b/test/auto-test/testdata/OSC/sim_qos.json @@ -0,0 +1,45 @@ +{ + "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" + ] + } +} diff --git a/test/auto-test/testdata/OSC/sim_tsa.json b/test/auto-test/testdata/OSC/sim_tsa.json index 4520cfac..9227b5ea 100644 --- a/test/auto-test/testdata/OSC/sim_tsa.json +++ b/test/auto-test/testdata/OSC/sim_tsa.json @@ -5,7 +5,7 @@ "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": { diff --git a/test/auto-test/testdata/OSC/tsa-agent-modified.json b/test/auto-test/testdata/OSC/tsa-agent-modified.json index 7d48ff91..d9426c79 100644 --- a/test/auto-test/testdata/OSC/tsa-agent-modified.json +++ b/test/auto-test/testdata/OSC/tsa-agent-modified.json @@ -1,7 +1,7 @@ { "$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": { diff --git a/test/auto-test/testdata/OSC/tsa.json b/test/auto-test/testdata/OSC/tsa.json index b1d443ba..5f4d20d3 100644 --- a/test/auto-test/testdata/OSC/tsa.json +++ b/test/auto-test/testdata/OSC/tsa.json @@ -1,7 +1,7 @@ { "$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": { diff --git a/test/auto-test/testdata/STD/pi1_template.json b/test/auto-test/testdata/STD/pi1_template.json index 2a875131..e06b0316 100644 --- a/test/auto-test/testdata/STD/pi1_template.json +++ b/test/auto-test/testdata/STD/pi1_template.json @@ -3,7 +3,7 @@ "ueId": "ueXXX", "qosId": "qosXXX" }, - "qosObjective": { + "qosObjectives": { "priorityLevel": XXX } } \ No newline at end of file diff --git a/test/common/README.md b/test/common/README.md index 62ee8428..a048c646 100644 --- a/test/common/README.md +++ b/test/common/README.md @@ -63,7 +63,8 @@ The script can be started with these arguments | `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 []*` | 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 ` | 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. @@ -130,7 +131,12 @@ Make the script sleep for a number of seconds. | ` ` | Number of seconds to sleep | | `` | 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 diff --git a/test/common/agent_api_functions.sh b/test/common/agent_api_functions.sh index b2d6a240..550ace0e 100644 --- a/test/common/agent_api_functions.sh +++ b/test/common/agent_api_functions.sh @@ -251,7 +251,7 @@ api_get_policies() { fi if [ $paramError -ne 0 ]; then - __print_err " |NORIC |NOSERVICE |NOTYPE [ NOID | [ EMPTY| ]*]" $@ + __print_err " |NORIC |NOSERVICE |NOTYPE [ NOID | [ EMPTY| ]*]" $@ return 1 fi queryparams="" @@ -297,7 +297,7 @@ api_get_policies() { 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 @@ -341,7 +341,7 @@ api_get_policy() { return 1 fi - query="/policy?id=$2" + query="/policy?id=$UUID$2" res="$(__do_curl_to_agent GET $query)" status=${res:${#res}-3} @@ -398,7 +398,7 @@ api_put_policy() { 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" @@ -414,7 +414,6 @@ api_put_policy() { 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++)) @@ -458,7 +457,7 @@ api_put_policy_batch() { 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" @@ -475,7 +474,6 @@ api_put_policy_batch() { 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++)) @@ -498,7 +496,6 @@ api_put_policy_batch() { 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++)) @@ -562,8 +559,12 @@ api_put_policy_parallel() { 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 {}) @@ -625,7 +626,7 @@ api_delete_policy() { 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}" @@ -671,13 +672,12 @@ api_delete_policy_batch() { 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++)) @@ -701,7 +701,6 @@ api_delete_policy_batch() { 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++)) @@ -747,8 +746,12 @@ api_delete_policy_parallel() { 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 {}) @@ -841,7 +844,7 @@ api_get_policy_ids() { targetJson=$targetJson"," fi if [ $pid != "NOID" ]; then - targetJson=$targetJson"\"$pid\"" + targetJson=$targetJson"\"$UUID$pid\"" fi done @@ -998,7 +1001,7 @@ api_get_policy_status() { 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} diff --git a/test/common/controller_api_functions.sh b/test/common/controller_api_functions.sh index daab47c6..e33c6190 100644 --- a/test/common/controller_api_functions.sh +++ b/test/common/controller_api_functions.sh @@ -119,7 +119,7 @@ controller_api_get_A1_policy_ids() { if [ "$targetJson" != "[" ]; then targetJson=$targetJson"," fi - targetJson=$targetJson"\"$pid\"" + targetJson=$targetJson"\"$UUID$pid\"" done targetJson=$targetJson"]" @@ -209,10 +209,10 @@ controller_api_delete_A1_policy() { 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 @@ -254,12 +254,12 @@ controller_api_put_A1_policy() { 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 @@ -304,7 +304,7 @@ controller_api_get_A1_policy_status() { 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\"" @@ -312,7 +312,7 @@ controller_api_get_A1_policy_status() { 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 diff --git a/test/common/create_policies_process.py b/test/common/create_policies_process.py index 19a77ba4..8d37678f 100644 --- a/test/common/create_policies_process.py +++ b/test/common/create_policies_process.py @@ -30,21 +30,25 @@ from requests.packages import urllib3 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() @@ -57,18 +61,18 @@ try: 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") diff --git a/test/common/delete_policies_process.py b/test/common/delete_policies_process.py index fe879191..e647118d 100644 --- a/test/common/delete_policies_process.py +++ b/test/common/delete_policies_process.py @@ -30,35 +30,39 @@ from requests.packages import urllib3 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") diff --git a/test/common/test_env.sh b/test/common/test_env.sh index 55a4957f..11c3b6d2 100755 --- a/test/common/test_env.sh +++ b/test/common/test_env.sh @@ -132,6 +132,7 @@ export CONFIG_BINDING_SERVICE="config-binding-service" # Host name of C 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). @@ -167,6 +168,9 @@ export CONTROL_PANEL_EXTERNAL_PORT=8080 # Control Panel 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 diff --git a/test/common/testcase_common.sh b/test/common/testcase_common.sh index 4d89d0c1..d694ef10 100755 --- a/test/common/testcase_common.sh +++ b/test/common/testcase_common.sh @@ -18,7 +18,7 @@ # # 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 ] [--use-local-image []*] #Formatting for 'echo' cmd @@ -94,6 +94,9 @@ AUTO_CLEAN="" # 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 @@ -180,33 +183,67 @@ if [ $paramerror -eq 0 ]; then 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 []*]"$ERED + echo -e $RED"Expected arg: local|remote|remote-remove [auto-clean] [--stop-at-error] [--ricsim-prefix ] [--use-local-image []*]"$ERED exit 1 fi @@ -829,6 +866,14 @@ clean_containers() { 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 @@ -1048,6 +1093,13 @@ __start_container() { 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 #################### @@ -1182,7 +1234,7 @@ prepare_consul_config() { 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 @@ -1257,31 +1309,36 @@ use_simulator_https() { } # 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 # (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 " $@ + __print_err "need three args, $RIC1|$RIC2|$RIC3 " $@ 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 " $@ + __print_err "need three args, $RIC1|$RIC2|$RIC3 " $@ exit 1 fi diff --git a/test/simulator-group/sim-monitor.js b/test/simulator-group/sim-monitor.js index d56ad7f9..17d32058 100644 --- a/test/simulator-group/sim-monitor.js +++ b/test/simulator-group/sim-monitor.js @@ -41,7 +41,7 @@ app.get("/",function(req, res){ 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. @@ -185,6 +185,8 @@ var getCtr=0 var refreshInterval=4000 +var ricbasename="ricsim" + function fetchAllMetrics() { setTimeout(() => { @@ -195,7 +197,7 @@ function fetchAllMetrics() { 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," "); @@ -377,6 +379,14 @@ setInterval(() => { 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 @@ -388,6 +398,9 @@ app.get("/mon",function(req, res){ "Policy Agent and simulator monitor"+ "" + "" + + "" + + "

Change basename in url if other ric sim prefix is used

" + + "
" + "

Policy agent

" + "" + "Status:..............................." + formatDataRow(ag1) + "
" + -- 2.16.6