From: Henrik Andersson Date: Wed, 4 Nov 2020 08:48:58 +0000 (+0000) Subject: Merge "Integrated PMS 2.0 to test env and test cases" X-Git-Tag: 2.1.0~21 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=647744d8ab625d28ea0ecda3e6741e23ba9b0bc7;hp=08d483a877c24c3668f77dc8404ee54cd1e041ab;p=nonrtric.git Merge "Integrated PMS 2.0 to test env and test cases" --- diff --git a/test/auto-test/.gitignore b/test/auto-test/.gitignore index 89e22dec..6091e4ac 100644 --- a/test/auto-test/.gitignore +++ b/test/auto-test/.gitignore @@ -14,3 +14,4 @@ logs .timer* .pid* .result* +tmp diff --git a/test/auto-test/FTC1.sh b/test/auto-test/FTC1.sh index e4482b60..4d05b9b7 100755 --- a/test/auto-test/FTC1.sh +++ b/test/auto-test/FTC1.sh @@ -79,6 +79,9 @@ for __httpx in $TESTED_PROTOCOLS ; do start_ric_simulators ricsim_g1 1 OSC_2.1.0 start_ric_simulators ricsim_g2 1 STD_1.1.3 + if [ "$PMS_VERSION" == "V2" ]; then + start_ric_simulators ricsim_g3 1 STD_2.0.0 + fi start_mr @@ -107,15 +110,27 @@ for __httpx in $TESTED_PROTOCOLS ; do sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json - api_equal json:rics 2 60 + if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:rics 3 60 + + #api_equal json:policy_schemas 2 120 + + api_equal json:policy-types 2 120 + + api_equal json:policies 0 - api_equal json:policy_schemas 2 120 + api_equal json:policy_instances 0 + else + api_equal json:rics 2 60 + + api_equal json:policy_schemas 2 120 - api_equal json:policy_types 2 + api_equal json:policy_types 2 - api_equal json:policies 0 + api_equal json:policies 0 - api_equal json:policy_ids 0 + api_equal json:policy_ids 0 + fi echo "############################################" echo "############## Health check ################" @@ -137,25 +152,40 @@ for __httpx in $TESTED_PROTOCOLS ; do echo "############## RIC Repository ##############" echo "############################################" - api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:AVAILABLE ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE" + if [ "$PMS_VERSION" == "V2" ]; then + api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:AVAILABLE ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE ricsim_g3_1:me1_ricsim_g3_1,me2_ricsim_g3_1:NOTYPE:AVAILABLE" + else + api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:AVAILABLE ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE" + fi echo "############################################" echo "########### A1 Policy Management ###########" echo "############################################" - api_put_policy 201 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT testdata/OSC/pi1_template.json - api_put_policy 200 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT testdata/OSC/pi1_template.json + if [ "$PMS_VERSION" == "V2" ]; then + notificationurl="http://localhost:80" + else + notificationurl="" + fi + api_put_policy 201 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json + api_put_policy 200 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json - api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT testdata/STD/pi1_template.json - api_put_policy 200 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT testdata/STD/pi1_template.json + api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json + api_put_policy 200 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json api_delete_policy 204 5000 api_delete_policy 204 5100 - api_equal json:policies 0 + if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:policies 0 + + api_equal json:policy_instances 0 + else + api_equal json:policies 0 - api_equal json:policy_ids 0 + api_equal json:policy_ids 0 + fi cr_equal received_callbacks 0 @@ -173,9 +203,15 @@ for __httpx in $TESTED_PROTOCOLS ; do if [[ $interface = *"SDNC"* ]]; then sim_contains_str ricsim_g1_1 remote_hosts "a1-controller" sim_contains_str ricsim_g2_1 remote_hosts "a1-controller" + if [ "$PMS_VERSION" == "V2" ]; then + sim_contains_str ricsim_g3_1 remote_hosts "a1-controller" + fi else sim_contains_str ricsim_g1_1 remote_hosts "policy-agent" sim_contains_str ricsim_g2_1 remote_hosts "policy-agent" + if [ "$PMS_VERSION" == "V2" ]; then + sim_contains_str ricsim_g3_1 remote_hosts "policy-agent" + fi fi check_policy_agent_logs diff --git a/test/auto-test/FTC10.sh b/test/auto-test/FTC10.sh index 42b8f587..52a2bb33 100755 --- a/test/auto-test/FTC10.sh +++ b/test/auto-test/FTC10.sh @@ -47,6 +47,10 @@ start_ric_simulators ricsim_g1 3 OSC_2.1.0 start_ric_simulators ricsim_g2 5 STD_1.1.3 +if [ "$PMS_VERSION" == "V2" ]; then + start_ric_simulators ricsim_g3 1 STD_2.0.0 +fi + start_mr start_cr @@ -70,38 +74,52 @@ sim_print ricsim_g1_1 interface sim_print ricsim_g2_1 interface -sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json +if [ "$PMS_VERSION" == "V2" ]; then + sim_print ricsim_g3_1 interface +fi -api_equal json:policy_types 2 60 +sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json +if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:policy-types 2 60 +else + api_equal json:policy_types 2 60 +fi # Create policies + +if [ "$PMS_VERSION" == "V2" ]; then + notificationurl="http://localhost:80" +else + notificationurl="" +fi + use_agent_rest_http api_put_service 201 "service1" 3600 "$CR_PATH/1" -api_put_policy 201 "service1" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json 1 +api_put_policy 201 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1 sim_equal ricsim_g1_1 num_instances 1 use_agent_dmaap_http -api_put_policy 201 "service1" ricsim_g1_1 1 3000 NOTRANSIENT testdata/OSC/pi1_template.json 1 +api_put_policy 201 "service1" ricsim_g1_1 1 3000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1 sim_equal ricsim_g1_1 num_instances 2 use_agent_rest_http -api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT testdata/STD/pi1_template.json 1 +api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1 sim_equal ricsim_g2_1 num_instances 1 use_agent_dmaap_http -api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT testdata/STD/pi1_template.json 1 +api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1 sim_equal ricsim_g2_1 num_instances 2 @@ -111,14 +129,14 @@ use_agent_rest_http api_put_service 200 "service1" 3600 "$CR_PATH/1" -api_put_policy 200 "service1" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json 1 +api_put_policy 200 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1 sim_equal ricsim_g1_1 num_instances 2 use_agent_dmaap_http -api_put_policy 200 "service1" ricsim_g1_1 1 3000 NOTRANSIENT testdata/OSC/pi1_template.json 1 +api_put_policy 200 "service1" ricsim_g1_1 1 3000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1 sim_equal ricsim_g1_1 num_instances 2 @@ -126,22 +144,29 @@ sim_equal ricsim_g1_1 num_instances 2 use_agent_rest_http -api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT testdata/STD/pi1_template.json 1 +api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1 sim_equal ricsim_g2_1 num_instances 2 use_agent_dmaap_http -api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT testdata/STD/pi1_template.json 1 +api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1 sim_equal ricsim_g2_1 num_instances 2 # Check policies -api_get_policy 200 2000 testdata/OSC/pi1_template.json -api_get_policy 200 3000 testdata/OSC/pi1_template.json -api_get_policy 200 2100 testdata/STD/pi1_template.json -api_get_policy 200 3100 testdata/STD/pi1_template.json +if [ "$PMS_VERSION" == "V2" ]; then + api_get_policy 200 2000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl + api_get_policy 200 3000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl + api_get_policy 200 2100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl + api_get_policy 200 3100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl +else + api_get_policy 200 2000 testdata/OSC/pi1_template.json + api_get_policy 200 3000 testdata/OSC/pi1_template.json + api_get_policy 200 2100 testdata/STD/pi1_template.json + api_get_policy 200 3100 testdata/STD/pi1_template.json +fi # Remove policies @@ -157,10 +182,17 @@ api_delete_policy 204 3100 sim_equal ricsim_g1_1 num_instances 0 sim_equal ricsim_g2_1 num_instances 0 +if [ "$PMS_VERSION" == "V2" ]; then + sim_equal ricsim_g3_1 num_instances 0 +fi + # Check remote host access to simulator sim_contains_str ricsim_g1_1 remote_hosts "policy-agent" sim_contains_str ricsim_g2_1 remote_hosts "policy-agent" +if [ "$PMS_VERSION" == "V2" ]; then + sim_contains_str ricsim_g3_1 remote_hosts "policy-agent" +fi # Check policy removal use_agent_rest_http diff --git a/test/auto-test/FTC100.sh b/test/auto-test/FTC100.sh index b617d3f1..13d375b3 100755 --- a/test/auto-test/FTC100.sh +++ b/test/auto-test/FTC100.sh @@ -33,8 +33,10 @@ 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) TESTED_PROTOCOLS="HTTP HTTPS" + for __httpx in $TESTED_PROTOCOLS ; do for interface in $TESTED_VARIANTS ; do @@ -77,6 +79,9 @@ for __httpx in $TESTED_PROTOCOLS ; do start_ric_simulators ricsim_g1 1 OSC_2.1.0 start_ric_simulators ricsim_g2 1 STD_1.1.3 + if [ "$PMS_VERSION" == "V2" ]; then + start_ric_simulators ricsim_g3 1 STD_2.0.0 + fi start_mr @@ -105,15 +110,27 @@ for __httpx in $TESTED_PROTOCOLS ; do sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json sim_put_policy_type 201 ricsim_g1_1 2 testdata/OSC/sim_2.json - api_equal json:rics 2 60 + if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:rics 3 60 - api_equal json:policy_schemas 3 120 + #api_equal json:policy-schemas 3 120 - api_equal json:policy_types 3 + api_equal json:policy-types 3 120 - api_equal json:policies 0 + api_equal json:policies 0 + + api_equal json:policy_instances 0 + else + api_equal json:rics 2 60 - api_equal json:policy_ids 0 + api_equal json:policy_schemas 3 120 + + api_equal json:policy_types 3 + + api_equal json:policies 0 + + api_equal json:policy_ids 0 + fi echo "############################################" @@ -204,47 +221,90 @@ for __httpx in $TESTED_PROTOCOLS ; do echo "############## RIC Repository ##############" echo "############################################" - api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE" - + if [ "$PMS_VERSION" == "V2" ]; then + api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE ricsim_g3_1:me1_ricsim_g3_1,me2_ricsim_g3_1:NOTYPE:AVAILABLE" + else + api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE" + fi api_get_rics 200 1 "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE" api_get_rics 404 47 api_get_rics 404 "test" + if [ "$PMS_VERSION" == "V2" ]; then + api_get_ric 200 me1_ricsim_g1_1 NORIC "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE" + + api_get_ric 200 me2_ricsim_g1_1 NORIC "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE" + + api_get_ric 200 me1_ricsim_g2_1 NORIC "ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE" + + api_get_ric 200 me2_ricsim_g2_1 NORIC "ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE" + + api_get_ric 200 NOME ricsim_g1_1 "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE" - api_get_ric 200 me1_ricsim_g1_1 ricsim_g1_1 + api_get_ric 200 NOME ricsim_g2_1 "ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE" - api_get_ric 200 me2_ricsim_g1_1 ricsim_g1_1 + api_get_ric 404 NOME test1 - api_get_ric 200 me1_ricsim_g2_1 ricsim_g2_1 + api_get_ric 404 test NORIC + + api_get_ric 400 me1_ricsim_g1_1 ricsim_g1_1 + + api_get_ric 400 me1_ricsim_g1_1 TESTRIC + + api_get_ric 400 TESTME ricsim_g1_1 + + else + api_get_ric 200 me1_ricsim_g1_1 ricsim_g1_1 - api_get_ric 200 me2_ricsim_g2_1 ricsim_g2_1 + api_get_ric 200 me2_ricsim_g1_1 ricsim_g1_1 - api_get_ric 404 test + api_get_ric 200 me1_ricsim_g2_1 ricsim_g2_1 + api_get_ric 200 me2_ricsim_g2_1 ricsim_g2_1 + + api_get_ric 404 test + fi echo "############################################" echo "########### A1 Policy Management ###########" echo "############################################" - deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx" - #Behaviour accepted for now - api_get_policy_schema 200 1 testdata/OSC/1-agent-modified.json - deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx" - #Behaviour accepted for now - api_get_policy_schema 200 2 testdata/OSC/2-agent-modified.json - api_get_policy_schema 404 3 - deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx" - #Behaviour accepted for now - api_get_policy_schemas 200 NORIC testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json NOFILE - deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx" - #Behaviour accepted for now - api_get_policy_schemas 200 ricsim_g1_1 testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json + if [ "$PMS_VERSION" == "V2" ]; then + deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx" + #Behaviour accepted for now + api_get_policy_type 200 1 testdata/OSC/1-agent-modified.json + deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx" + #Behaviour accepted for now + api_get_policy_type 200 2 testdata/OSC/2-agent-modified.json - api_get_policy_schemas 200 ricsim_g2_1 NOFILE + api_get_policy_type 404 3 + else + deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx" + #Behaviour accepted for now + api_get_policy_schema 200 1 testdata/OSC/1-agent-modified.json + deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx" + #Behaviour accepted for now + api_get_policy_schema 200 2 testdata/OSC/2-agent-modified.json + + api_get_policy_schema 404 3 + fi - api_get_policy_schemas 404 test + if [ "$PMS_VERSION" == "V2" ]; then + api_get_policy_schemas 404 + else + deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx" + #Behaviour accepted for now + api_get_policy_schemas 200 NORIC testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json NOFILE + deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx" + #Behaviour accepted for now + api_get_policy_schemas 200 ricsim_g1_1 testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json + + api_get_policy_schemas 200 ricsim_g2_1 NOFILE + + api_get_policy_schemas 404 test + fi @@ -260,23 +320,28 @@ for __httpx in $TESTED_PROTOCOLS ; do api_put_service 201 "service10" 3600 "$CR_PATH/1" + if [ "$PMS_VERSION" == "V2" ]; then + notificationurl="http://localhost:80" + else + notificationurl="" + fi deviation "TR10 - agent allows policy creation on unregistered service (orig problem) - test combo $interface and $__httpx" #Kept until decison #api_put_policy 400 "unregistered-service" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json #Allow 201 for now - api_put_policy 201 "unregistered-service" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json + api_put_policy 201 "unregistered-service" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json - api_put_policy 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT testdata/OSC/pi1_template.json - api_put_policy 200 "service10" ricsim_g1_1 1 5000 NOTRANSIENT testdata/OSC/pi1_template.json + api_put_policy 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json + api_put_policy 200 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json - api_put_policy 200 "service10" ricsim_g1_1 1 5000 true testdata/OSC/pi1_template.json - api_put_policy 200 "service10" ricsim_g1_1 1 5000 false testdata/OSC/pi1_template.json + api_put_policy 200 "service10" ricsim_g1_1 1 5000 true $notificationurl testdata/OSC/pi1_template.json + api_put_policy 200 "service10" ricsim_g1_1 1 5000 false $notificationurl testdata/OSC/pi1_template.json - api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT testdata/STD/pi1_template.json - api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT testdata/STD/pi1_template.json + api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json + api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json - api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 true testdata/STD/pi1_template.json - api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 false testdata/STD/pi1_template.json + api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 true $notificationurl testdata/STD/pi1_template.json + api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 false $notificationurl testdata/STD/pi1_template.json VAL='NOT IN EFFECT' api_get_policy_status 200 5000 OSC "$VAL" "false" @@ -293,7 +358,11 @@ for __httpx in $TESTED_PROTOCOLS ; do #kept until decision #api_equal json:policy_ids 2 #Allow 3 for now - api_equal json:policy_ids 3 + if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:policy_instances 3 + else + api_equal json:policy_ids 3 + fi deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx" #kept until decision @@ -323,14 +392,19 @@ for __httpx in $TESTED_PROTOCOLS ; do api_get_policy_ids 200 ricsim_g2_1 NOSERVICE 1 NOID + if [ "$PMS_VERSION" == "V2" ]; then + api_get_policy 200 5000 testdata/OSC/pi1_template.json "service10" ricsim_g1_1 1 false $notificationurl - api_get_policy 200 5000 testdata/OSC/pi1_template.json - - api_get_policy 200 5100 testdata/STD/pi1_template.json + api_get_policy 200 5100 testdata/STD/pi1_template.json "service10" ricsim_g2_1 NOTYPE false $notificationurl + api_get_policies 200 ricsim_g1_1 "service10" 1 5000 ricsim_g1_1 "service10" 1 false $notificationurl testdata/OSC/pi1_template.json + else + api_get_policy 200 5000 testdata/OSC/pi1_template.json - api_get_policies 200 ricsim_g1_1 "service10" 1 5000 ricsim_g1_1 "service10" 1 testdata/OSC/pi1_template.json + api_get_policy 200 5100 testdata/STD/pi1_template.json + api_get_policies 200 ricsim_g1_1 "service10" 1 5000 ricsim_g1_1 "service10" 1 testdata/OSC/pi1_template.json + fi deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx" #kept until decision @@ -344,13 +418,21 @@ for __httpx in $TESTED_PROTOCOLS ; do api_equal json:policies 1 - api_equal json:policy_ids 1 + if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:policy_instances 1 + else + api_equal json:policy_ids 1 + fi api_delete_policy 204 5100 api_equal json:policies 0 - api_equal json:policy_ids 0 + if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:policy_instances 0 + else + api_equal json:policy_ids 0 + fi cr_equal received_callbacks 0 @@ -369,9 +451,15 @@ for __httpx in $TESTED_PROTOCOLS ; do if [[ $interface = *"SDNC"* ]]; then sim_contains_str ricsim_g1_1 remote_hosts "a1-controller" sim_contains_str ricsim_g2_1 remote_hosts "a1-controller" + if [ "$PMS_VERSION" == "V2" ]; then + sim_contains_str ricsim_g3_1 remote_hosts "a1-controller" + fi else sim_contains_str ricsim_g1_1 remote_hosts "policy-agent" sim_contains_str ricsim_g2_1 remote_hosts "policy-agent" + if [ "$PMS_VERSION" == "V2" ]; then + sim_contains_str ricsim_g3_1 remote_hosts "policy-agent" + fi fi check_policy_agent_logs diff --git a/test/auto-test/FTC110.sh b/test/auto-test/FTC110.sh index c840800a..23f68c7e 100755 --- a/test/auto-test/FTC110.sh +++ b/test/auto-test/FTC110.sh @@ -45,6 +45,10 @@ use_agent_rest_http clean_containers start_ric_simulators ricsim_g1 1 OSC_2.1.0 +start_ric_simulators ricsim_g2 1 STD_1.1.3 +if [ "$PMS_VERSION" == "V2" ]; then + start_ric_simulators ricsim_g3 1 STD_2.0.0 +fi start_mr @@ -70,6 +74,10 @@ api_get_status 200 #Print simulator interface version sim_print ricsim_g1_1 interface +sim_print ricsim_g2_1 interface +if [ "$PMS_VERSION" == "V2" ]; then + sim_print ricsim_g3_1 interface +fi api_put_service 201 "service1" 15 "$CR_PATH/service1" @@ -151,32 +159,54 @@ api_put_service 201 "service10" 600 "$CR_PATH/service10" sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json -api_equal json:rics 1 60 +if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:rics 3 60 -api_equal json:policy_schemas 1 120 + #api_equal json:policy_schemas 2 120 -api_equal json:policy_types 1 + api_equal json:policy-types 2 120 -api_equal json:policies 0 + api_equal json:policies 0 +else + api_equal json:rics 2 60 -api_put_policy 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT testdata/OSC/pi1_template.json + api_equal json:policy_schemas 2 120 -api_equal json:policies 1 + api_equal json:policy_types 2 -sim_equal ricsim_g1_1 num_instances 1 + api_equal json:policies 0 +fi + +if [ "$PMS_VERSION" == "V2" ]; then + notificationurl="http://localhost:80" +else + notificationurl="" +fi -api_put_policy 201 "service10" ricsim_g1_1 1 5001 true testdata/OSC/pi1_template.json +api_put_policy 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json +api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json api_equal json:policies 2 +sim_equal ricsim_g1_1 num_instances 1 +sim_equal ricsim_g2_1 num_instances 1 + +api_put_policy 201 "service10" ricsim_g1_1 1 5001 true $notificationurl testdata/OSC/pi1_template.json +api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5101 true $notificationurl testdata/STD/pi1_template.json + +api_equal json:policies 4 + sim_equal ricsim_g1_1 num_instances 2 +sim_equal ricsim_g2_1 num_instances 2 sim_post_delete_instances 200 ricsim_g1_1 +sim_post_delete_instances 200 ricsim_g2_1 #Wait for recreate of non transient policy -api_equal json:policies 1 180 +api_equal json:policies 2 180 sim_equal ricsim_g1_1 num_instances 1 +sim_equal ricsim_g2_1 num_instances 1 api_put_service 200 "service10" 10 "$CR_PATH/service10" @@ -184,12 +214,13 @@ api_put_service 200 "service10" 10 "$CR_PATH/service10" api_equal json:policies 0 120 sim_equal ricsim_g1_1 num_instances 0 - +sim_equal ricsim_g2_1 num_instances 0 api_get_service_ids 200 deviation "TR18 Agents sends callback with empty body" -cr_equal received_callbacks 4 +deviation "TR18 Unclear when callbacks are sent...." +#cr_equal received_callbacks 8 mr_equal requests_submitted 0 check_policy_agent_logs diff --git a/test/auto-test/FTC1100.sh b/test/auto-test/FTC1100.sh index 63c2931f..0a1a0144 100755 --- a/test/auto-test/FTC1100.sh +++ b/test/auto-test/FTC1100.sh @@ -29,6 +29,8 @@ INCLUDED_IMAGES="ECS PRODSTUB" #### TEST BEGIN #### +FLAT_A1_EI="1" + clean_containers use_ecs_rest_http @@ -94,14 +96,27 @@ ecs_api_edp_get_producer_status 404 test-prod ecs_api_edp_delete_producer 404 test-prod -ecs_api_a1_get_job_ids 404 test-type NOWNER -ecs_api_a1_get_job_ids 404 test-type test-owner +if [ -z "$FLAT_A1_EI" ]; then + ecs_api_a1_get_job_ids 404 test-type NOWNER + ecs_api_a1_get_job_ids 404 test-type test-owner + + ecs_api_a1_get_job 404 test-type test-job + + ecs_api_a1_get_job_status 404 test-type test-job +else + ecs_api_a1_get_job_ids 200 test-type NOWNER EMPTY + ecs_api_a1_get_job_ids 200 test-type test-owner EMPTY -ecs_api_a1_get_job 404 test-type test-job + ecs_api_a1_get_job 404 test-job -ecs_api_a1_get_job_status 404 test-type test-job + ecs_api_a1_get_job_status 404 test-job +fi -ecs_api_a1_delete_job 404 test-type test-job +if [ -z "$FLAT_A1_EI" ]; then + ecs_api_a1_delete_job 404 test-type test-job +else + ecs_api_a1_delete_job 404 test-job +fi ecs_api_edp_get_producer_jobs 404 test-prod @@ -112,7 +127,11 @@ ecs_api_edp_put_producer 201 prod-a http://producer-stub:8092/callbacks/create/p ecs_api_edp_put_producer 200 prod-a http://producer-stub:8092/callbacks/create/prod-a http://producer-stub:8092/callbacks/delete/prod-a http://producer-stub:8092/callbacks/supervision/prod-a type1 testdata/ecs/ei-type-1.json ecs_api_a1_get_type_ids 200 type1 -ecs_api_a1_get_type 200 type1 testdata/ecs/ei-type-1.json +if [ -z "$FLAT_A1_EI" ]; then + ecs_api_a1_get_type 200 type1 testdata/ecs/ei-type-1.json +else + ecs_api_a1_get_type 200 type1 testdata/ecs/empty-type.json +fi ecs_api_edp_get_type_ids 200 type1 ecs_api_edp_get_type 200 type1 testdata/ecs/ei-type-1.json prod-a @@ -125,40 +144,72 @@ ecs_api_edp_get_producer_status 200 prod-a ENABLED ecs_api_a1_get_job_ids 200 type1 NOWNER EMPTY ecs_api_a1_get_job_ids 200 type1 test-owner EMPTY -ecs_api_a1_get_job 404 type1 test-job +if [ -z "$FLAT_A1_EI" ]; then + ecs_api_a1_get_job 404 type1 test-job -ecs_api_a1_get_job_status 404 type1 test-job + ecs_api_a1_get_job_status 404 type1 test-job +else + ecs_api_a1_get_job 404 test-job + + ecs_api_a1_get_job_status 404 test-job +fi ecs_api_edp_get_producer_jobs 200 prod-a EMPTY #job1 - prod-a -ecs_api_a1_put_job 201 type1 job1 http://localhost:80/target1 ric1 testdata/ecs/job-template.json +if [ -z "$FLAT_A1_EI" ]; then + ecs_api_a1_put_job 201 type1 job1 http://localhost:80/target1 ric1 testdata/ecs/job-template.json +else + ecs_api_a1_put_job 201 job1 type1 http://localhost:80/target1 ric1 http://localhost:80/status1 testdata/ecs/job-template.json +fi prodstub_check_jobdata 200 prod-a job1 type1 http://localhost:80/target1 testdata/ecs/job-template.json ecs_api_a1_get_job_ids 200 type1 NOWNER job1 ecs_api_a1_get_job_ids 200 type1 ric1 job1 +if [ ! -z "$FLAT_A1_EI" ]; then + ecs_api_a1_get_job_ids 200 NOTYPE NOWNER job1 +fi + +if [ -z "$FLAT_A1_EI" ]; then + ecs_api_a1_get_job 200 type1 job1 http://localhost:80/target1 ric1 testdata/ecs/job-template.json -ecs_api_a1_get_job 200 type1 job1 http://localhost:80/target1 ric1 testdata/ecs/job-template.json + ecs_api_a1_get_job_status 200 type1 job1 ENABLED +else + ecs_api_a1_get_job 200 job1 type1 http://localhost:80/target1 ric1 http://localhost:80/status1 testdata/ecs/job-template.json -ecs_api_a1_get_job_status 200 type1 job1 ENABLED + ecs_api_a1_get_job_status 200 job1 ENABLED +fi ecs_api_edp_get_producer_jobs 200 prod-a job1 type1 http://localhost:80/target1 testdata/ecs/job-template.json #job2 - prod-a -ecs_api_a1_put_job 201 type1 job2 http://localhost:80/target2 ric2 testdata/ecs/job-template.json +if [ -z "$FLAT_A1_EI" ]; then + ecs_api_a1_put_job 201 type1 job2 http://localhost:80/target2 ric2 testdata/ecs/job-template.json +else + ecs_api_a1_put_job 201 job2 type1 http://localhost:80/target2 ric2 http://localhost:80/status2 testdata/ecs/job-template.json +fi prodstub_check_jobdata 200 prod-a job2 type1 http://localhost:80/target2 testdata/ecs/job-template.json ecs_api_a1_get_job_ids 200 type1 NOWNER job1 job2 ecs_api_a1_get_job_ids 200 type1 ric1 job1 ecs_api_a1_get_job_ids 200 type1 ric2 job2 +if [ ! -z "$FLAT_A1_EI" ]; then + ecs_api_a1_get_job_ids 200 NOTYPE NOWNER job1 job2 +fi -ecs_api_a1_get_job 200 type1 job2 http://localhost:80/target2 ric2 testdata/ecs/job-template.json +if [ -z "$FLAT_A1_EI" ]; then + ecs_api_a1_get_job 200 type1 job2 http://localhost:80/target2 ric2 testdata/ecs/job-template.json -ecs_api_a1_get_job_status 200 type1 job2 ENABLED + ecs_api_a1_get_job_status 200 type1 job2 ENABLED +else + ecs_api_a1_get_job 200 job2 type1 http://localhost:80/target2 ric2 http://localhost:80/status2 testdata/ecs/job-template.json + + ecs_api_a1_get_job_status 200 job2 ENABLED +fi ecs_api_edp_get_producer_jobs 200 prod-a job1 type1 http://localhost:80/target1 testdata/ecs/job-template.json job2 type1 http://localhost:80/target2 testdata/ecs/job-template.json @@ -167,8 +218,13 @@ ecs_api_edp_get_producer_jobs 200 prod-a job1 type1 http://localhost:80/target1 ecs_api_edp_put_producer 201 prod-b http://producer-stub:8092/callbacks/create/prod-b http://producer-stub:8092/callbacks/delete/prod-b http://producer-stub:8092/callbacks/supervision/prod-b type2 testdata/ecs/ei-type-2.json ecs_api_a1_get_type_ids 200 type1 type2 -ecs_api_a1_get_type 200 type1 testdata/ecs/ei-type-1.json -ecs_api_a1_get_type 200 type2 testdata/ecs/ei-type-2.json +if [ -z "$FLAT_A1_EI" ]; then + ecs_api_a1_get_type 200 type1 testdata/ecs/ei-type-1.json + ecs_api_a1_get_type 200 type2 testdata/ecs/ei-type-2.json +else + ecs_api_a1_get_type 200 type1 testdata/ecs/empty-type.json + ecs_api_a1_get_type 200 type2 testdata/ecs/empty-type.json +fi ecs_api_edp_get_type_ids 200 type1 type2 ecs_api_edp_get_type 200 type1 testdata/ecs/ei-type-1.json prod-a @@ -182,7 +238,11 @@ ecs_api_edp_get_producer_status 200 prod-b ENABLED #job3 - prod-b -ecs_api_a1_put_job 201 type2 job3 http://localhost:80/target3 ric3 testdata/ecs/job-template.json +if [ -z "$FLAT_A1_EI" ]; then + ecs_api_a1_put_job 201 type2 job3 http://localhost:80/target3 ric3 testdata/ecs/job-template.json +else + ecs_api_a1_put_job 201 job3 type2 http://localhost:80/target3 ric3 http://localhost:80/status3 testdata/ecs/job-template.json +fi prodstub_check_jobdata 200 prod-b job3 type2 http://localhost:80/target3 testdata/ecs/job-template.json @@ -192,9 +252,15 @@ ecs_api_a1_get_job_ids 200 type1 ric1 job1 ecs_api_a1_get_job_ids 200 type1 ric2 job2 ecs_api_a1_get_job_ids 200 type2 ric3 job3 -ecs_api_a1_get_job 200 type2 job3 http://localhost:80/target3 ric3 testdata/ecs/job-template.json +if [ -z "$FLAT_A1_EI" ]; then + ecs_api_a1_get_job 200 type2 job3 http://localhost:80/target3 ric3 testdata/ecs/job-template.json + + ecs_api_a1_get_job_status 200 type2 job3 ENABLED +else + ecs_api_a1_get_job 200 job3 type2 http://localhost:80/target3 ric3 http://localhost:80/status3 testdata/ecs/job-template.json -ecs_api_a1_get_job_status 200 type2 job3 ENABLED + ecs_api_a1_get_job_status 200 job3 ENABLED +fi ecs_api_edp_get_producer_jobs 200 prod-a job1 type1 http://localhost:80/target1 testdata/ecs/job-template.json job2 type1 http://localhost:80/target2 testdata/ecs/job-template.json ecs_api_edp_get_producer_jobs 200 prod-b job3 type2 http://localhost:80/target3 testdata/ecs/job-template.json @@ -210,7 +276,11 @@ ecs_api_edp_get_producer 200 prod-c http://producer-stub:8092/callbacks/create/p ecs_api_edp_get_producer_status 200 prod-c ENABLED -ecs_api_a1_delete_job 204 type2 job3 +if [ -z "$FLAT_A1_EI" ]; then + ecs_api_a1_delete_job 204 type2 job3 +else + ecs_api_a1_delete_job 204 job3 +fi ecs_api_edp_delete_producer 204 prod-b @@ -222,8 +292,12 @@ ecs_api_edp_put_producer 201 prod-d http://producer-stub:8092/callbacks/create/p ecs_api_a1_get_job_ids 200 type4 NOWNER EMPTY -ecs_api_a1_put_job 201 type4 job8 http://localhost:80/target8 ric4 testdata/ecs/job-template.json - +if [ -z "$FLAT_A1_EI" ]; then + ecs_api_a1_put_job 201 type4 job8 http://localhost:80/target8 ric4 testdata/ecs/job-template.json +else + ecs_api_a1_put_job 201 job8 type4 http://localhost:80/target8 ric4 http://localhost:80/status4 testdata/ecs/job-template.json +fi +read -p "" prodstub_equal create/prod-d/job8 1 prodstub_equal delete/prod-d/job8 0 @@ -231,11 +305,32 @@ ecs_api_a1_get_job_ids 200 type4 NOWNER job8 ecs_api_edp_put_producer 200 prod-d http://producer-stub:8092/callbacks/create/prod-d http://producer-stub:8092/callbacks/delete/prod-d http://producer-stub:8092/callbacks/supervision/prod-d NOTYPE -ecs_api_a1_get_job_ids 404 type4 NOWNER +if [ -z "$FLAT_A1_EI" ]; then + ecs_api_a1_get_job_ids 404 type4 NOWNER +else + ecs_api_a1_get_job_ids 200 type4 NOWNER EMPTY + ecs_api_a1_get_job_ids 200 NOTYPE NOWNER job1 job2 job8 +fi prodstub_equal create/prod-d/job8 1 prodstub_equal delete/prod-d/job8 0 + + +ecs_api_edp_put_producer 200 prod-d http://producer-stub:8092/callbacks/create/prod-d http://producer-stub:8092/callbacks/delete/prod-d http://producer-stub:8092/callbacks/supervision/prod-d type4 testdata/ecs/ei-type-1.json + +if [ -z "$FLAT_A1_EI" ]; then + ecs_api_a1_get_job_ids 404 type4 NOWNER +else + ecs_api_a1_get_job_ids 200 type4 NOWNER EMPTY + ecs_api_a1_get_job_ids 200 NOTYPE NOWNER job1 job2 job8 +fi + + + + + + check_sdnc_logs check_ecs_logs diff --git a/test/auto-test/FTC150.sh b/test/auto-test/FTC150.sh index bb527be3..1cd7754d 100755 --- a/test/auto-test/FTC150.sh +++ b/test/auto-test/FTC150.sh @@ -55,6 +55,9 @@ for __nb_httpx in $NB_TESTED_PROTOCOLS ; do start_ric_simulators ricsim_g1 1 OSC_2.1.0 start_ric_simulators ricsim_g2 1 STD_1.1.3 + if [ "$PMS_VERSION" == "V2" ]; then + start_ric_simulators ricsim_g3 1 STD_2.0.0 + fi start_sdnc diff --git a/test/auto-test/FTC300.sh b/test/auto-test/FTC300.sh index fb7bc342..6e00c9d9 100755 --- a/test/auto-test/FTC300.sh +++ b/test/auto-test/FTC300.sh @@ -17,7 +17,7 @@ # ============LICENSE_END================================================= # -TC_ONELINE_DESCR="Resync 10000 policies using OSC interface over REST" +TC_ONELINE_DESCR="Resync 10000 policies using OSC and STD interface" #App names to include in the test, space separated list INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" @@ -78,6 +78,10 @@ for __httpx in $TESTED_PROTOCOLS ; do start_ric_simulators ricsim_g2 4 STD_1.1.3 + if [ "$PMS_VERSION" == "V2" ]; then + start_ric_simulators ricsim_g3 4 STD_2.0.0 + fi + start_mr start_cr @@ -105,65 +109,79 @@ for __httpx in $TESTED_PROTOCOLS ; do sim_print ricsim_g2_1 interface + if [ "$PMS_VERSION" == "V2" ]; then + sim_print ricsim_g3_1 interface + fi + sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json - api_equal json:policy_types 2 120 #Wait for the agent to refresh types from the simulator + if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:policy-types 2 120 #Wait for the agent to refresh types from the simulator + else + api_equal json:policy_types 2 120 #Wait for the agent to refresh types from the simulator + fi api_put_service 201 "serv1" 3600 "$CR_PATH/1" START_ID=2000 NUM_POLICIES=10000 + if [ "$PMS_VERSION" == "V2" ]; then + notificationurl="http://localhost:80" + else + notificationurl="" + fi + if [[ $interface == *"BATCH"* ]]; then - api_put_policy_batch 201 "serv1" ricsim_g1_1 1 $START_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_POLICIES + api_put_policy_batch 201 "serv1" ricsim_g1_1 1 $START_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_POLICIES else - api_put_policy 201 "serv1" ricsim_g1_1 1 $START_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_POLICIES + api_put_policy 201 "serv1" ricsim_g1_1 1 $START_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_POLICIES fi - sim_equal ricsim_g1_1 num_instances 10000 + sim_equal ricsim_g1_1 num_instances $NUM_POLICIES sim_post_delete_instances 200 ricsim_g1_1 sim_equal ricsim_g1_1 num_instances 0 - sim_equal ricsim_g1_1 num_instances 10000 300 + sim_equal ricsim_g1_1 num_instances $NUM_POLICIES 300 - START_ID=$(($START_ID+$NUM_POLICIES)) + START_ID2=$(($START_ID+$NUM_POLICIES)) if [[ $interface == *"BATCH"* ]]; then - api_put_policy_batch 201 "serv1" ricsim_g2_1 NOTYPE $START_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_POLICIES + api_put_policy_batch 201 "serv1" ricsim_g2_1 NOTYPE $START_ID2 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_POLICIES else - api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE $START_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_POLICIES + api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE $START_ID2 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_POLICIES fi - sim_equal ricsim_g2_1 num_instances 10000 + sim_equal ricsim_g2_1 num_instances $NUM_POLICIES sim_post_delete_instances 200 ricsim_g2_1 sim_equal ricsim_g2_1 num_instances 0 - sim_equal ricsim_g2_1 num_instances 10000 300 + sim_equal ricsim_g2_1 num_instances $NUM_POLICIES 300 - api_delete_policy 204 2435 + api_delete_policy 204 $(($START_ID+47)) - api_delete_policy 204 8693 + api_delete_policy 204 $(($START_ID+$NUM_POLICIES-39)) sim_post_delete_instances 200 ricsim_g1_1 - sim_equal ricsim_g1_1 num_instances 9998 300 + sim_equal ricsim_g1_1 num_instances $(($NUM_POLICIES-2)) 300 - api_delete_policy 204 12435 + api_delete_policy 204 $(($START_ID2+37)) - api_delete_policy 204 18693 + api_delete_policy 204 $(($START_ID2+$NUM_POLICIES-93)) - api_delete_policy 204 18697 + api_delete_policy 204 $(($START_ID2+$NUM_POLICIES-91)) sim_post_delete_instances 200 ricsim_g2_1 - sim_equal ricsim_g1_1 num_instances 9998 300 + sim_equal ricsim_g1_1 num_instances $(($NUM_POLICIES-2)) 300 - sim_equal ricsim_g2_1 num_instances 9997 300 + sim_equal ricsim_g2_1 num_instances $(($NUM_POLICIES-3)) 300 - api_equal json:policies 19995 + api_equal json:policies $(($NUM_POLICIES-2+$NUM_POLICIES-3)) check_policy_agent_logs diff --git a/test/auto-test/FTC310.sh b/test/auto-test/FTC310.sh index 856d6f56..bf5785ef 100755 --- a/test/auto-test/FTC310.sh +++ b/test/auto-test/FTC310.sh @@ -38,6 +38,9 @@ clean_containers # Start one RIC of each type start_ric_simulators ricsim_g1 1 OSC_2.1.0 start_ric_simulators ricsim_g2 1 STD_1.1.3 +if [ "$PMS_VERSION" == "V2" ]; then + start_ric_simulators ricsim_g3 1 STD_2.0.0 +fi start_mr @@ -53,29 +56,41 @@ start_control_panel start_policy_agent -api_equal json:rics 2 120 +if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:rics 3 120 +else + api_equal json:rics 2 120 +fi -# Add an OSC RIC and check +# Add an STD RIC and check start_ric_simulators ricsim_g2 2 STD_1.1.3 prepare_consul_config NOSDNC ".consul_config.json" consul_config_app ".consul_config.json" -api_equal json:rics 3 120 +if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:rics 4 120 +else + api_equal json:rics 3 120 +fi check_policy_agent_logs check_control_panel_logs -# Remove one OSC RIC and check +# Remove one RIC RIC and check start_ric_simulators ricsim_g2 1 STD_1.1.3 prepare_consul_config NOSDNC ".consul_config.json" consul_config_app ".consul_config.json" -api_equal json:rics 2 120 +if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:rics 3 120 +else + api_equal json:rics 2 120 +fi check_policy_agent_logs check_control_panel_logs diff --git a/test/auto-test/FTC350.sh b/test/auto-test/FTC350.sh index 4b2e3cb2..4f2244c9 100755 --- a/test/auto-test/FTC350.sh +++ b/test/auto-test/FTC350.sh @@ -138,17 +138,31 @@ for interface in $TESTED_VARIANTS ; do sim_put_policy_type 201 ricsim_g1_8 5 testdata/OSC/sim_5.json sim_put_policy_type 201 ricsim_g1_9 5 testdata/OSC/sim_5.json - api_equal json:policy_types 5 120 - - echo "Check the number of types in the agent for each ric" - api_equal json:policy_types?ric=ricsim_g1_1 1 120 - api_equal json:policy_types?ric=ricsim_g1_2 2 120 - api_equal json:policy_types?ric=ricsim_g1_3 3 120 - api_equal json:policy_types?ric=ricsim_g1_4 4 120 - api_equal json:policy_types?ric=ricsim_g1_5 5 120 - api_equal json:policy_types?ric=ricsim_g1_6 4 120 - api_equal json:policy_types?ric=ricsim_g1_7 3 120 - api_equal json:policy_types?ric=ricsim_g1_8 2 120 + if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:policy-types 5 120 + + echo "Check the number of types in the agent for each ric" + api_equal json:policy-types?ric_id=ricsim_g1_1 1 120 + api_equal json:policy-types?ric_id=ricsim_g1_2 2 120 + api_equal json:policy-types?ric_id=ricsim_g1_3 3 120 + api_equal json:policy-types?ric_id=ricsim_g1_4 4 120 + api_equal json:policy-types?ric_id=ricsim_g1_5 5 120 + api_equal json:policy-types?ric_id=ricsim_g1_6 4 120 + api_equal json:policy-types?ric_id=ricsim_g1_7 3 120 + api_equal json:policy-types?ric_id=ricsim_g1_8 2 120 + else + api_equal json:policy_types 5 120 + + echo "Check the number of types in the agent for each ric" + api_equal json:policy_types?ric=ricsim_g1_1 1 120 + api_equal json:policy_types?ric=ricsim_g1_2 2 120 + api_equal json:policy_types?ric=ricsim_g1_3 3 120 + api_equal json:policy_types?ric=ricsim_g1_4 4 120 + api_equal json:policy_types?ric=ricsim_g1_5 5 120 + api_equal json:policy_types?ric=ricsim_g1_6 4 120 + api_equal json:policy_types?ric=ricsim_g1_7 3 120 + api_equal json:policy_types?ric=ricsim_g1_8 2 120 + fi api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:???? \ ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:1,2:???? \ @@ -165,17 +179,33 @@ for interface in $TESTED_VARIANTS ; do api_equal json:rics 10 120 - echo "Check the number of types in the agent for each ric" - api_equal json:policy_types?ric=ricsim_g1_1 1 120 - api_equal json:policy_types?ric=ricsim_g1_2 2 120 - api_equal json:policy_types?ric=ricsim_g1_3 3 120 - api_equal json:policy_types?ric=ricsim_g1_4 4 120 - api_equal json:policy_types?ric=ricsim_g1_5 5 120 - api_equal json:policy_types?ric=ricsim_g1_6 4 120 - api_equal json:policy_types?ric=ricsim_g1_7 3 120 - api_equal json:policy_types?ric=ricsim_g1_8 2 120 - api_equal json:policy_types?ric=ricsim_g1_9 1 120 - api_equal json:policy_types?ric=ricsim_g1_10 0 120 + if [ "$PMS_VERSION" == "V2" ]; then + + echo "Check the number of types in the agent for each ric" + api_equal json:policy-types?ric_id=ricsim_g1_1 1 120 + api_equal json:policy-types?ric_id=ricsim_g1_2 2 120 + api_equal json:policy-types?ric_id=ricsim_g1_3 3 120 + api_equal json:policy-types?ric_id=ricsim_g1_4 4 120 + api_equal json:policy-types?ric_id=ricsim_g1_5 5 120 + api_equal json:policy-types?ric_id=ricsim_g1_6 4 120 + api_equal json:policy-types?ric_id=ricsim_g1_7 3 120 + api_equal json:policy-types?ric_id=ricsim_g1_8 2 120 + api_equal json:policy-types?ric_id=ricsim_g1_9 1 120 + api_equal json:policy-types?ric_id=ricsim_g1_10 0 120 + else + + echo "Check the number of types in the agent for each ric" + api_equal json:policy_types?ric=ricsim_g1_1 1 120 + api_equal json:policy_types?ric=ricsim_g1_2 2 120 + api_equal json:policy_types?ric=ricsim_g1_3 3 120 + api_equal json:policy_types?ric=ricsim_g1_4 4 120 + api_equal json:policy_types?ric=ricsim_g1_5 5 120 + api_equal json:policy_types?ric=ricsim_g1_6 4 120 + api_equal json:policy_types?ric=ricsim_g1_7 3 120 + api_equal json:policy_types?ric=ricsim_g1_8 2 120 + api_equal json:policy_types?ric=ricsim_g1_9 1 120 + api_equal json:policy_types?ric=ricsim_g1_10 0 120 + fi api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:???? \ ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:1,2:???? \ @@ -191,13 +221,27 @@ for interface in $TESTED_VARIANTS ; do #No policy type in sim #10 - api_equal json:policy_types 5 + if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:policy-types 5 + else + api_equal json:policy_types 5 + fi api_put_service 201 "serv1" 3600 "$CR_PATH/serv1" - api_put_policy 201 "serv1" ricsim_g1_9 5 2000 NOTRANSIENT testdata/OSC/pi5_template.json 1 + if [ "$PMS_VERSION" == "V2" ]; then + notificationurl="http://localhost:80" + else + notificationurl="" + fi + + api_put_policy 201 "serv1" ricsim_g1_9 5 2000 NOTRANSIENT $notificationurl testdata/OSC/pi5_template.json 1 - api_equal json:policy_ids 1 + if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:policy_instances 1 + else + api_equal json:policy_ids 1 + fi sim_equal ricsim_g1_9 num_instances 1 @@ -207,15 +251,27 @@ for interface in $TESTED_VARIANTS ; do api_equal json:rics 8 120 - echo "Check the number of types in the agent for each ric" - api_equal json:policy_types?ric=ricsim_g1_1 1 120 - api_equal json:policy_types?ric=ricsim_g1_2 2 120 - api_equal json:policy_types?ric=ricsim_g1_3 3 120 - api_equal json:policy_types?ric=ricsim_g1_4 4 120 - api_equal json:policy_types?ric=ricsim_g1_5 5 120 - api_equal json:policy_types?ric=ricsim_g1_6 4 120 - api_equal json:policy_types?ric=ricsim_g1_7 3 120 - api_equal json:policy_types?ric=ricsim_g1_8 2 120 + if [ "$PMS_VERSION" == "V2" ]; then + echo "Check the number of types in the agent for each ric" + api_equal json:policy-types?ric_id=ricsim_g1_1 1 120 + api_equal json:policy-types?ric_id=ricsim_g1_2 2 120 + api_equal json:policy-types?ric_id=ricsim_g1_3 3 120 + api_equal json:policy-types?ric_id=ricsim_g1_4 4 120 + api_equal json:policy-types?ric_id=ricsim_g1_5 5 120 + api_equal json:policy-types?ric_id=ricsim_g1_6 4 120 + api_equal json:policy-types?ric_id=ricsim_g1_7 3 120 + api_equal json:policy-types?ric_id=ricsim_g1_8 2 120 + else + echo "Check the number of types in the agent for each ric" + api_equal json:policy_types?ric=ricsim_g1_1 1 120 + api_equal json:policy_types?ric=ricsim_g1_2 2 120 + api_equal json:policy_types?ric=ricsim_g1_3 3 120 + api_equal json:policy_types?ric=ricsim_g1_4 4 120 + api_equal json:policy_types?ric=ricsim_g1_5 5 120 + api_equal json:policy_types?ric=ricsim_g1_6 4 120 + api_equal json:policy_types?ric=ricsim_g1_7 3 120 + api_equal json:policy_types?ric=ricsim_g1_8 2 120 + fi api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:???? \ ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:1,2:???? \ @@ -228,7 +284,11 @@ for interface in $TESTED_VARIANTS ; do sleep_wait 120 - api_equal json:policy_ids 0 + if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:policy_instances 0 + else + api_equal json:policy_ids 0 + fi api_get_policy_types 404 ricsim_g1_9 @@ -241,17 +301,31 @@ for interface in $TESTED_VARIANTS ; do api_equal json:rics 10 120 - echo "Check the number of types in the agent for each ric" - api_equal json:policy_types?ric=ricsim_g1_1 1 120 - api_equal json:policy_types?ric=ricsim_g1_2 2 120 - api_equal json:policy_types?ric=ricsim_g1_3 3 120 - api_equal json:policy_types?ric=ricsim_g1_4 4 120 - api_equal json:policy_types?ric=ricsim_g1_5 5 120 - api_equal json:policy_types?ric=ricsim_g1_6 4 120 - api_equal json:policy_types?ric=ricsim_g1_7 3 120 - api_equal json:policy_types?ric=ricsim_g1_8 2 120 - api_equal json:policy_types?ric=ricsim_g1_9 1 120 - api_equal json:policy_types?ric=ricsim_g1_10 0 120 + if [ "$PMS_VERSION" == "V2" ]; then + echo "Check the number of types in the agent for each ric" + api_equal json:policy-types?ric_id=ricsim_g1_1 1 120 + api_equal json:policy-types?ric_id=ricsim_g1_2 2 120 + api_equal json:policy-types?ric_id=ricsim_g1_3 3 120 + api_equal json:policy-types?ric_id=ricsim_g1_4 4 120 + api_equal json:policy-types?ric_id=ricsim_g1_5 5 120 + api_equal json:policy-types?ric_id=ricsim_g1_6 4 120 + api_equal json:policy-types?ric_id=ricsim_g1_7 3 120 + api_equal json:policy-types?ric_id=ricsim_g1_8 2 120 + api_equal json:policy-types?ric_id=ricsim_g1_9 1 120 + api_equal json:policy-types?ric_id=ricsim_g1_10 0 120 + else + echo "Check the number of types in the agent for each ric" + api_equal json:policy_types?ric=ricsim_g1_1 1 120 + api_equal json:policy_types?ric=ricsim_g1_2 2 120 + api_equal json:policy_types?ric=ricsim_g1_3 3 120 + api_equal json:policy_types?ric=ricsim_g1_4 4 120 + api_equal json:policy_types?ric=ricsim_g1_5 5 120 + api_equal json:policy_types?ric=ricsim_g1_6 4 120 + api_equal json:policy_types?ric=ricsim_g1_7 3 120 + api_equal json:policy_types?ric=ricsim_g1_8 2 120 + api_equal json:policy_types?ric=ricsim_g1_9 1 120 + api_equal json:policy_types?ric=ricsim_g1_10 0 120 + fi api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:???? \ ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:1,2:???? \ @@ -266,7 +340,11 @@ for interface in $TESTED_VARIANTS ; do sleep_wait 120 - api_equal json:policy_ids 0 + if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:policy_instances 0 + else + api_equal json:policy_ids 0 + fi sim_equal ricsim_g1_9 num_instances 0 @@ -278,16 +356,29 @@ for interface in $TESTED_VARIANTS ; do sleep_wait 120 - api_equal json:policy_types?ric=ricsim_g1_1 1 120 - api_equal json:policy_types?ric=ricsim_g1_2 2 120 - api_equal json:policy_types?ric=ricsim_g1_3 3 120 - api_equal json:policy_types?ric=ricsim_g1_4 3 120 - api_equal json:policy_types?ric=ricsim_g1_5 4 120 - api_equal json:policy_types?ric=ricsim_g1_6 3 120 - api_equal json:policy_types?ric=ricsim_g1_7 2 120 - api_equal json:policy_types?ric=ricsim_g1_8 2 120 - api_equal json:policy_types?ric=ricsim_g1_9 1 120 - api_equal json:policy_types?ric=ricsim_g1_10 0 120 + if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:policy-types?ric_id=ricsim_g1_1 1 120 + api_equal json:policy-types?ric_id=ricsim_g1_2 2 120 + api_equal json:policy-types?ric_id=ricsim_g1_3 3 120 + api_equal json:policy-types?ric_id=ricsim_g1_4 3 120 + api_equal json:policy-types?ric_id=ricsim_g1_5 4 120 + api_equal json:policy-types?ric_id=ricsim_g1_6 3 120 + api_equal json:policy-types?ric_id=ricsim_g1_7 2 120 + api_equal json:policy-types?ric_id=ricsim_g1_8 2 120 + api_equal json:policy-types?ric_id=ricsim_g1_9 1 120 + api_equal json:policy-types?ric_id=ricsim_g1_10 0 120 + else + api_equal json:policy_types?ric=ricsim_g1_1 1 120 + api_equal json:policy_types?ric=ricsim_g1_2 2 120 + api_equal json:policy_types?ric=ricsim_g1_3 3 120 + api_equal json:policy_types?ric=ricsim_g1_4 3 120 + api_equal json:policy_types?ric=ricsim_g1_5 4 120 + api_equal json:policy_types?ric=ricsim_g1_6 3 120 + api_equal json:policy_types?ric=ricsim_g1_7 2 120 + api_equal json:policy_types?ric=ricsim_g1_8 2 120 + api_equal json:policy_types?ric=ricsim_g1_9 1 120 + api_equal json:policy_types?ric=ricsim_g1_10 0 120 + fi api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:???? \ ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:1,2:???? \ @@ -302,7 +393,11 @@ for interface in $TESTED_VARIANTS ; do sim_delete_policy_type 204 ricsim_g1_8 4 - api_equal json:policy_types?ric=ricsim_g1_8 1 120 + if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:policy-types?ric_id=ricsim_g1_8 1 120 + else + api_equal json:policy_types?ric=ricsim_g1_8 1 120 + fi api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:???? \ ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:1,2:???? \ diff --git a/test/auto-test/FTC800.sh b/test/auto-test/FTC800.sh index 25678bed..6d25c29b 100755 --- a/test/auto-test/FTC800.sh +++ b/test/auto-test/FTC800.sh @@ -72,6 +72,9 @@ for __httpx in $TESTED_PROTOCOLS ; do start_ric_simulators ricsim_g1 1 OSC_2.1.0 start_ric_simulators ricsim_g2 1 STD_1.1.3 + if [ "$PMS_VERSION" == "V2" ]; then + start_ric_simulators ricsim_g3 1 STD_2.0.0 + fi start_mr @@ -105,13 +108,22 @@ for __httpx in $TESTED_PROTOCOLS ; do sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json - - api_equal json:policy_types 2 120 #Wait for the agent to refresh types from the simulators + if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:policy-types 2 120 #Wait for the agent to refresh types from the simulators + else + api_equal json:policy_types 2 120 #Wait for the agent to refresh types from the simulators + fi api_put_service 201 "serv1" 3600 "$CR_PATH/1" + if [ "$PMS_VERSION" == "V2" ]; then + notificationurl="http://localhost:80" + else + notificationurl="" + fi + start_timer "Create polices in OSC via agent REST and $interface using "$__httpx - api_put_policy 201 "serv1" ricsim_g1_1 1 $START_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_POLICIES + api_put_policy 201 "serv1" ricsim_g1_1 1 $START_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_POLICIES print_timer "Create polices in OSC via agent REST and $interface using "$__httpx sim_equal ricsim_g1_1 num_instances $NUM_POLICIES @@ -119,7 +131,7 @@ for __httpx in $TESTED_PROTOCOLS ; do START_ID=$(($START_ID+$NUM_POLICIES)) start_timer "Create polices in STD via agent REST and $interface using "$__httpx - api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE $START_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_POLICIES + api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE $START_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_POLICIES print_timer "Create polices in STD via agent REST and $interface using "$__httpx sim_equal ricsim_g2_1 num_instances $NUM_POLICIES @@ -135,7 +147,7 @@ for __httpx in $TESTED_PROTOCOLS ; do START_ID=$(($START_ID+$NUM_POLICIES)) start_timer "Create polices in OSC via agent DMAAP, one by one, and $interface using "$__httpx - api_put_policy 201 "serv1" ricsim_g1_1 1 $START_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_POLICIES + api_put_policy 201 "serv1" ricsim_g1_1 1 $START_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_POLICIES print_timer "Create polices in OSC via agent DMAAP, one by one, and $interface using "$__httpx sim_equal ricsim_g1_1 num_instances $((2*$NUM_POLICIES)) @@ -143,7 +155,7 @@ for __httpx in $TESTED_PROTOCOLS ; do START_ID=$(($START_ID+$NUM_POLICIES)) start_timer "Create polices in STD via agent DMAAP, one by one, and $interface using "$__httpx - api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE $START_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_POLICIES + api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE $START_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_POLICIES print_timer "Create polices in STD via agent DMAAP, one by one, and $interface using "$__httpx sim_equal ricsim_g2_1 num_instances $((2*$NUM_POLICIES)) @@ -151,7 +163,7 @@ for __httpx in $TESTED_PROTOCOLS ; do START_ID=$(($START_ID+$NUM_POLICIES)) start_timer "Create polices in OSC via agent DMAAP in batch and $interface using "$__httpx - api_put_policy_batch 201 "serv1" ricsim_g1_1 1 $START_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_POLICIES + api_put_policy_batch 201 "serv1" ricsim_g1_1 1 $START_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_POLICIES print_timer "Create polices in OSC via agent DMAAP in batch and $interface using "$__httpx sim_equal ricsim_g1_1 num_instances $((3*$NUM_POLICIES)) @@ -159,7 +171,7 @@ for __httpx in $TESTED_PROTOCOLS ; do START_ID=$(($START_ID+$NUM_POLICIES)) start_timer "Create polices in STD via agent DMAAP in batch and $interface using "$__httpx - api_put_policy_batch 201 "serv1" ricsim_g2_1 NOTYPE $START_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_POLICIES + api_put_policy_batch 201 "serv1" ricsim_g2_1 NOTYPE $START_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_POLICIES print_timer "Create polices in STD via agent DMAAP in batch and $interface using "$__httpx sim_equal ricsim_g2_1 num_instances $((3*$NUM_POLICIES)) @@ -167,9 +179,15 @@ for __httpx in $TESTED_PROTOCOLS ; do if [ $interface == "SDNC" ]; then sim_contains_str ricsim_g1_1 remote_hosts "a1-controller" sim_contains_str ricsim_g2_1 remote_hosts "a1-controller" + if [ "$PMS_VERSION" == "V2" ]; then + sim_contains_str ricsim_g3_1 remote_hosts "a1-controller" + fi else sim_contains_str ricsim_g1_1 remote_hosts "policy-agent" sim_contains_str ricsim_g2_1 remote_hosts "policy-agent" + if [ "$PMS_VERSION" == "V2" ]; then + sim_contains_str ricsim_g3_1 remote_hosts "policy-agent" + fi fi check_policy_agent_logs diff --git a/test/auto-test/FTC810.sh b/test/auto-test/FTC810.sh index 009efc04..4cc00bd3 100755 --- a/test/auto-test/FTC810.sh +++ b/test/auto-test/FTC810.sh @@ -114,12 +114,20 @@ do done echo "Wait for the agent to refresh types from the simulator" -api_equal json:policy_types 2 120 +if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:policy-types 2 120 +else + api_equal json:policy_types 2 120 +fi echo "Check the number of types in the agent for each ric is 1" for ((i=1; i<=$NUM_RICS; i++)) do - api_equal json:policy_types?ric=ricsim_g1_$i 1 120 + if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:policy-types?ric_id=ricsim_g1_$i 1 120 + else + api_equal json:policy_types?ric=ricsim_g1_$i 1 120 + fi done echo "Register a service" @@ -132,6 +140,12 @@ AGENT_INTERFACES="REST REST_PARALLEL DMAAP DMAAP-BATCH" MR_MESSAGES=0 +if [ "$PMS_VERSION" == "V2" ]; then + notificationurl="http://localhost:80" +else + notificationurl="" +fi + while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do echo "" @@ -166,14 +180,14 @@ while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do INSTANCE_ID=200000 INSTANCES=0 if [ $interface == "REST_PARALLEL" ]; then - api_put_policy_parallel 201 "serv1" ricsim_g1_ $NUM_RICS 1 $INSTANCE_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_INSTANCES 3 + api_put_policy_parallel 201 "serv1" ricsim_g1_ $NUM_RICS 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES 3 fi for ((i=1; i<=$NUM_RICS; i++)) do if [ $interface == "DMAAP-BATCH" ]; then - api_put_policy_batch 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_INSTANCES + api_put_policy_batch 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then - api_put_policy 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_INSTANCES + api_put_policy 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES fi if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES)) @@ -183,18 +197,22 @@ while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do INSTANCES=$(($INSTANCES+$NUM_INSTANCES)) done - api_equal json:policy_ids $INSTANCES + if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:policy_instances $INSTANCES + else + api_equal json:policy_ids $INSTANCES + fi echo "Create $NUM_INSTANCES instances in each STD RIC" if [ $interface == "REST_PARALLEL" ]; then - api_put_policy_parallel 201 "serv1" ricsim_g2_ $NUM_RICS NOTYPE $INSTANCE_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_INSTANCES 3 + api_put_policy_parallel 201 "serv1" ricsim_g2_ $NUM_RICS NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES 3 fi for ((i=1; i<=$NUM_RICS; i++)) do if [ $interface == "DMAAP-BATCH" ]; then - api_put_policy_batch 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_INSTANCES + api_put_policy_batch 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then - api_put_policy 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_INSTANCES + api_put_policy 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES fi if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES)) @@ -204,7 +222,11 @@ while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do INSTANCES=$(($INSTANCES+$NUM_INSTANCES)) done - api_equal json:policy_ids $INSTANCES + if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:policy_instances $INSTANCES + else + api_equal json:policy_ids $INSTANCES + fi echo "Delete all instances in each OSC RIC" @@ -228,7 +250,11 @@ while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES)) done - api_equal json:policy_ids $INSTANCES + if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:policy_instances $INSTANCES + else + api_equal json:policy_ids $INSTANCES + fi echo "Delete all instances in each STD RIC" @@ -250,7 +276,11 @@ while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES)) done - api_equal json:policy_ids 0 + if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:policy_instances $INSTANCES + else + api_equal json:policy_ids $INSTANCES + fi cr_equal received_callbacks 0 diff --git a/test/auto-test/FTC850.sh b/test/auto-test/FTC850.sh index 7391331b..b6376f06 100755 --- a/test/auto-test/FTC850.sh +++ b/test/auto-test/FTC850.sh @@ -20,7 +20,7 @@ TC_ONELINE_DESCR="Create/delete policies in parallel over a number of ric using a number of child process" #App names to include in the test, space separated list -INCLUDED_IMAGES="CBS CONSUL, CP, CR, MR, PA, RICSIM, SDNC" +INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh @@ -42,6 +42,12 @@ NUM_POLICIES_PER_RIC=500 generate_uuid +if [ "$PMS_VERSION" == "V2" ]; then + notificationurl="http://localhost:80" +else + notificationurl="" +fi + for __httpx in $TESTED_PROTOCOLS ; do for interface in $TESTED_VARIANTS ; do @@ -108,22 +114,29 @@ for __httpx in $TESTED_PROTOCOLS ; do sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json done - - api_equal json:policy_types 1 120 #Wait for the agent to refresh types from the simulator + if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:policy-types 1 120 #Wait for the agent to refresh types from the simulator + else + api_equal json:policy_types 1 120 #Wait for the agent to refresh types from the simulator + fi api_put_service 201 "serv1" 600 "$CR_PATH/1" echo "Check the number of types in the agent for each ric is 1" for ((i=1; i<=$NUM_RICS; i++)) do - api_equal json:policy_types?ric=ricsim_g1_$i 1 120 + if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:policy-types?ric_id=ricsim_g1_$i 1 120 + else + api_equal json:policy_types?ric=ricsim_g1_$i 1 120 + fi done START_ID=2000 start_timer "Create $((NUM_POLICIES_PER_RIC*$NUM_RICS)) polices over $interface using "$__httpx - api_put_policy_parallel 201 "serv1" ricsim_g1_ $NUM_RICS 1 $START_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_POLICIES_PER_RIC 7 + api_put_policy_parallel 201 "serv1" ricsim_g1_ $NUM_RICS 1 $START_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_POLICIES_PER_RIC 7 print_timer "Create $((NUM_POLICIES_PER_RIC*$NUM_RICS)) polices over $interface using "$__httpx diff --git a/test/auto-test/FTC900.sh b/test/auto-test/FTC900.sh index 32567973..6dbe5443 100755 --- a/test/auto-test/FTC900.sh +++ b/test/auto-test/FTC900.sh @@ -43,6 +43,10 @@ start_ric_simulators $RIC_SIM_PREFIX"_g1" $OSC_NUM_RICS OSC_2.1.0 start_ric_simulators $RIC_SIM_PREFIX"_g2" $STD_NUM_RICS STD_1.1.3 +if [ "$PMS_VERSION" == "V2" ]; then + start_ric_simulators $RIC_SIM_PREFIX"_g3" $STD_NUM_RICS STD_2.0.0 +fi + start_mr #Just to prevent errors in the agent log... start_control_panel @@ -82,36 +86,58 @@ done #Check the number of schemas and the individual schemas in OSC -api_equal json:policy_types 4 120 - -for ((i=1; i<=$OSC_NUM_RICS; i++)) -do - 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 - +if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:policy-types 4 120 + + for ((i=1; i<=$OSC_NUM_RICS; i++)) + do + api_equal json:policy-types?ric_id=$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_type 200 2 testdata/OSC/hw-agent-modified.json + api_get_policy_type 200 100 testdata/OSC/qos-agent-modified.json + api_get_policy_type 200 20008 testdata/OSC/tsa-agent-modified.json + done +else + api_equal json:policy_types 4 120 + + for ((i=1; i<=$OSC_NUM_RICS; i++)) + do + 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 +fi # Create policies use_agent_rest_http api_put_service 201 "Emergency-response-app" 0 "$CR_PATH/1" +if [ "$PMS_VERSION" == "V2" ]; then + notificationurl="http://localhost:80" +else + notificationurl="" +fi + # Create policies in OSC for ((i=1; i<=$OSC_NUM_RICS; i++)) do generate_uuid - api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g1_"$i 2 $((2000+$i)) NOTRANSIENT testdata/OSC/pihw_template.json 1 + api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g1_"$i 2 $((2000+$i)) NOTRANSIENT $notificationurl 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 + api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g1_"$i 100 $((3000+$i)) NOTRANSIENT $notificationurl 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 + api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g1_"$i 20008 $((4000+$i)) NOTRANSIENT $notificationurl testdata/OSC/pitsa_template.json 1 done @@ -126,7 +152,7 @@ done for ((i=1; i<=$STD_NUM_RICS; i++)) do generate_uuid - api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g2_"$i NOTYPE $((2100+$i)) NOTRANSIENT testdata/STD/pi1_template.json 1 + api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g2_"$i NOTYPE $((2100+$i)) NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1 done diff --git a/test/auto-test/PM_DEMO.sh b/test/auto-test/PM_DEMO.sh index 3696d567..c309ddc6 100755 --- a/test/auto-test/PM_DEMO.sh +++ b/test/auto-test/PM_DEMO.sh @@ -32,6 +32,13 @@ INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" ########################## # Path to callback receiver CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" + +if [ "$PMS_VERSION" == "V2" ]; then + notificationurl="http://localhost:80" +else + notificationurl="" +fi + use_cr_http use_agent_rest_http use_sdnc_http @@ -87,19 +94,35 @@ done #Check the number of schemas and the individual schemas in OSC -api_equal json:policy_types 3 120 - -for ((i=1; i<=$OSC_NUM_RICS; i++)) -do - api_equal json:policy_types?ric=$RIC_SIM_PREFIX"_g1_"$i 2 120 -done - -# Check the schemas in OSC -for ((i=1; i<=$OSC_NUM_RICS; i++)) -do - api_get_policy_schema 200 100 demo-testdata/OSC/qos-agent-modified.json - api_get_policy_schema 200 20008 demo-testdata/OSC/tsa-agent-modified.json -done +if [ "$PMS_VERSION" == "V2" ]; then + api_equal json:policy-types 3 120 + + for ((i=1; i<=$OSC_NUM_RICS; i++)) + do + api_equal json:policy-types?ric_id=$RIC_SIM_PREFIX"_g1_"$i 2 120 + done + + # Check the schemas in OSC + for ((i=1; i<=$OSC_NUM_RICS; i++)) + do + api_get_policy_type 200 100 demo-testdata/OSC/qos-agent-modified.json + api_get_policy_type 200 20008 demo-testdata/OSC/tsa-agent-modified.json + done +else + api_equal json:policy_types 3 120 + + for ((i=1; i<=$OSC_NUM_RICS; i++)) + do + api_equal json:policy_types?ric=$RIC_SIM_PREFIX"_g1_"$i 2 120 + done + + # Check the schemas in OSC + for ((i=1; i<=$OSC_NUM_RICS; i++)) + do + api_get_policy_schema 200 100 demo-testdata/OSC/qos-agent-modified.json + api_get_policy_schema 200 20008 demo-testdata/OSC/tsa-agent-modified.json + done +fi # Create policies @@ -111,9 +134,9 @@ api_put_service 201 "Emergency-response-app" 0 "$CR_PATH/1" for ((i=1; i<=$OSC_NUM_RICS; i++)) do generate_uuid - api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g1_"$i 100 $((3000+$i)) NOTRANSIENT demo-testdata/OSC/piqos_template.json 1 + api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g1_"$i 100 $((3000+$i)) NOTRANSIENT $notificationurl demo-testdata/OSC/piqos_template.json 1 generate_uuid - api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g1_"$i 20008 $((4000+$i)) NOTRANSIENT demo-testdata/OSC/pitsa_template.json 1 + api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g1_"$i 20008 $((4000+$i)) NOTRANSIENT $notificationurl demo-testdata/OSC/pitsa_template.json 1 done @@ -128,7 +151,7 @@ done for ((i=1; i<=$STD_NUM_RICS; i++)) do generate_uuid - api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g2_"$i NOTYPE $((2100+$i)) NOTRANSIENT demo-testdata/STD/pi1_template.json 1 + api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g2_"$i NOTYPE $((2100+$i)) NOTRANSIENT $notificationurl demo-testdata/STD/pi1_template.json 1 done diff --git a/test/auto-test/README.md b/test/auto-test/README.md index 0429e366..95e523cb 100644 --- a/test/auto-test/README.md +++ b/test/auto-test/README.md @@ -4,7 +4,7 @@ A few of the bash scripts are so called 'suites', These suite scripts calls a se ## Automated test scripts There are two types of scripts, filenames in the format FTCXXX.sh test one or more components of the Non-RT RIC. Filenames in the format SuiteZZZZ.sh tests a number of FTCXXX.sh script as one suite. (XXX is an integer selected from the categories described further below). -FTC is short for Function Test Case. +FTC is short for Function Test Case. In addition, there are also other test scripts with other naming format used for demo setup etc (e.g PM_DEMO.sh). The requirements, in terms of the execution enviroment, to run a script or a suite is to have docker, docker-compose and python3 installed (the scripts warns if not installed). The scripts have been tested to work on both MacOS and Ubuntu. They should work also in git bash on windows but not yet verified. @@ -24,7 +24,7 @@ Each test script prints out the overall result of the tests in the end of the ex The test scripts produce quite a number of logs; all container logs, a log of all http/htps calls from the test scripts including the payload, some configuration created during test and also a test case log (same as what is printed on the screen during execution). All these logs are stored in `logs/FTCXXX/`. So each test script is using its own log directory. ## Test case categories -The test script are number using these basic categories. +The test script are number using these basic categories where 0-999 are releated to the policy managment and 1000-1999 are related to enrichment management. 1-99 - Basic sanity tests diff --git a/test/auto-test/Suite-all.sh b/test/auto-test/Suite-policy-all.sh similarity index 77% rename from test/auto-test/Suite-all.sh rename to test/auto-test/Suite-policy-all.sh index 9a51d3bb..c032d2d8 100755 --- a/test/auto-test/Suite-all.sh +++ b/test/auto-test/Suite-policy-all.sh @@ -24,24 +24,17 @@ TS_ONELINE_DESCR="Test suite - all test cases except the stab test(s)" suite_setup ############# TEST CASES ################# -ARG1=$1 - -./FTC1.sh $ARG1 - -if [ $ARG1 == "remote-remove" ]; then - #Prevent image removal for every test case - ARG1="remote" -fi - -./FTC10.sh $ARG1 -./FTC100.sh $ARG1 -./FTC110.sh $ARG1 -./FTC150.sh $ARG1 -./FTC300.sh $ARG1 -./FTC310.sh $ARG1 -./FTC350.sh $ARG1 -./FTC800.sh $ARG1 -./FTC850.sh $ARG1 + +./FTC1.sh $@ +./FTC10.sh $@ +./FTC100.sh $@ +./FTC110.sh $@ +./FTC150.sh $@ +./FTC300.sh $@ +./FTC310.sh $@ +./FTC350.sh $@ +./FTC800.sh $@ +./FTC850.sh $@ ########################################## diff --git a/test/auto-test/Suite-interfaces.sh b/test/auto-test/Suite-policy-interfaces.sh similarity index 86% rename from test/auto-test/Suite-interfaces.sh rename to test/auto-test/Suite-policy-interfaces.sh index 7a216461..afa3b668 100755 --- a/test/auto-test/Suite-interfaces.sh +++ b/test/auto-test/Suite-policy-interfaces.sh @@ -27,15 +27,9 @@ suite_setup ARG1=$1 -./FTC100.sh $ARG1 - -if [ $ARG1 == "remote-remove" ]; then - #Prevent image removal for every test case - ARG1="remote" -fi - -./FTC110.sh $ARG1 -./FTC150.sh $ARG1 +./FTC100.sh $@ +./FTC110.sh $@ +./FTC150.sh $@ ########################################## diff --git a/test/auto-test/testdata/ecs/empty-type.json b/test/auto-test/testdata/ecs/empty-type.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/test/auto-test/testdata/ecs/empty-type.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/test/common/README.md b/test/common/README.md index 74921139..75b16b52 100644 --- a/test/common/README.md +++ b/test/common/README.md @@ -510,12 +510,16 @@ Print out the overall result of the executed test cases. # Description of functions in agent_api_function.sh # +## General ## +Both PMS version 1 and 2 are supported. The version is controlled by the env variable `$PMS_VERSION` set in the test env file. + ## Function: api_equal() ## Tests if the array length of a json array in the Policy Agent simulator is equal to a target value. Without the timeout, the test sets pass or fail immediately depending on if the array length is equal to the target or not. With the timeout, the test waits up to the timeout seconds before setting pass or fail depending on if the array length becomes equal to the target value or not. See the 'cr' dir for more details. + | arg list | |--| | ` [ ]` | @@ -527,13 +531,18 @@ See the 'cr' dir for more details. | `` | Max time to wait for the length to reach the target value | ## Function: api_get_policies() ## -Test of GET '/policies' and optional check of the array of returned policies. +Test of GET '/policies' or V2 GET '/v2/policy_instances' and optional check of the array of returned policies. To test the response code only, provide the response code parameter as well as the following three parameters. -To also test the response payload add the 'NOID' for an expected empty array or repeat the last five parameters for each expected policy. +To also test the response payload add the 'NOID' for an expected empty array or repeat the last five/seven parameters for each expected policy. + | arg list | |--| | ` |NORIC |NOSERVICE |NOTYPE [ NOID | [ EMPTY| ]*]` | +| arg list V2 | +|--| +| ` |NORIC |NOSERVICE |NOTYPE [ NOID | [ EMPTY| ]*]` | + | parameter | description | | --------- | ----------- | | `` | Expected http response code | @@ -546,31 +555,48 @@ To also test the response payload add the 'NOID' for an expected empty array or | `NOID` | Indicator that no policy id is provided - indicate empty list of policies| | `` | Id of the policy | | `EMPTY` | Indicate for the special empty policy type | +| `transient` | Transient, true or false | +| `notification-url` | Url for notifications | | `` | Path to the template file for the policy (same template used when creating the policy) | ## Function: api_get_policy() ## -Test of GET /policy and optional check of the returned json payload. +Test of GET '/policy' or V2 GET '/v2/policies/{policy_id}' and optional check of the returned json payload. To test the the response code only, provide the expected response code and policy id. To test the contents of the returned json payload, add a path to the template file used when creating the policy. + | arg list | |--| | ` []` | +| arg list V2| +|--| +| ` [ |NOTYPE |NOURL ]` | + | parameter | description | | --------- | ----------- | | `` | Expected http response code | | `` | Id of the policy | | `` | Path to the template file for the policy (same template used when creating the policy) | +| `` | Id of the service | +| `` | Id of the ric | +| `` | Id of the policy type | +| `NOTYPE` | Indicator that no type id is provided | +| `transient` | Transient, true or false | +| `notification-url` | Url for notifications | ## Function: api_put_policy() ## -Test of PUT '/policy'. -To test the response code only, provide the response code parameter as well as the following three parameters. -To also test the response payload add the 'NOID' for an expected empty array or repeat the last five parameters for each expected policy. +Test of PUT '/policy' or V2 PUT '/policies'. +If more than one policy shall be created, add a count value to indicate the number of policies to create. Note that if more than one policy shall be created the provided policy-id must be numerical (will be used as the starting id). + | arg list | |--| | ` []` | +| arg list V2 | +|--| +| ` |NOTYPE |NOTRANSIENT |NOURL []` | + | parameter | description | | --------- | ----------- | | `` | Expected http response code | @@ -579,6 +605,8 @@ To also test the response payload add the 'NOID' for an expected empty array or | `` | Id of the policy type | | `` | Id of the policy. This value shall be a numeric value if more than one policy shall be created | | `transient>` | Transient 'true' or 'false'. 'NOTRANSIENT' can be used to indicate using the default value (no transient value provided) | +| `notification-url` | Url for notifications | +|`NOURL`| Indicator for no url | | `` | Path to the template file for the policy | | `` | An optional count (default is 1). If a value greater than 1 is given, the policy ids will use the given policy id as the first id and add 1 to that id for each new policy | @@ -589,10 +617,17 @@ For arg list and parameters, see 'api_put_policy'. ## Function: api_put_policy_parallel() ## This tests the same as function 'api_put_policy' except that the policy create is spread out over a number of processes and it only uses the agent rest API. The total number of policies created is determined by the product of the parameters 'number-of-rics' and 'count'. The parameter 'number-of-threads' shall be selected to be not evenly divisible by the product of the parameters 'number-of-rics' and 'count' - this is to ensure that one process does not handle the creation of all the policies in one ric. + | arg list | |--| | ` ` +| arg list | +|--| +| ` |NOURL ` + +| parameter | description | +| --------- | ----------- | | `` | Expected http response code | | `` | Id of the service | | `` | The base id of the rics, ie ric id without the sequence number. The sequence number is added during processing | @@ -600,12 +635,14 @@ This tests the same as function 'api_put_policy' except that the policy create i | `` | Id of the policy type | | `` | Id of the policy. This value shall be a numeric value and will be the id of the first policy | | `transient>` | Transient 'true' or 'false'. 'NOTRANSIENT' can be used to indicate using the default value (no transient value provide) | +| `notification-url` | Url for notifications | | `` | Path to the template file for the policy | | `` | Number of policies per ric | | `` | Number of threads (processes) to run in parallel | ## Function: api_delete_policy() ## -This tests the DELETE /policy. Removes the indicated policy or a 'count' number of policies starting with 'policy-id' as the first id. +This tests the DELETE '/policy' or V2 DELETE '/v2/policies/{policy_id}'. Removes the indicated policy or a 'count' number of policies starting with 'policy-id' as the first id. + | arg list | |--| | ` []` @@ -623,10 +660,13 @@ For arg list and parameters, see 'api_delete_policy'. ## Function: api_delete_policy_parallel() ## This tests the same as function 'api_delete_policy' except that the policy delete is spread out over a number of processes and it only uses the agent rest API. The total number of policies deleted is determined by the product of the parameters 'number-of-rics' and 'count'. The parameter 'number-of-threads' shall be selected to be not evenly divisible by the product of the parameters 'number-of-rics' and 'count' - this is to ensure that one process does not handle the deletion of all the policies in one ric. + | arg list | |--| | ` ` +| parameter | description | +| --------- | ----------- | | `` | Expected http response code | | `` | The base id of the rics, ie ric id without the sequence number. The sequence number is added during processing | | `` | The number of rics, assuming the first index is '1' | @@ -637,9 +677,10 @@ This tests the same as function 'api_delete_policy' except that the policy delet ## Function: api_get_policy_ids() ## -Test of GET '/policy_ids'. +Test of GET '/policy_ids' or V2 GET '/v2/policies'. To test response code only, provide the response code parameter as well as the following three parameters. To also test the response payload add the 'NOID' for an expected empty array or repeat the 'policy-instance-id' for each expected policy id. + | arg list | |--| | ` |NORIC |NOSERVICE |NOTYPE ([` | Id of the policy | ## Function: api_get_policy_schema() ## -Test of GET /policy_schema and optional check of the returned json schema. +Test of V2 GET '/v2/policy-types/{policyTypeId}' and optional check of the returned json schema. To test the response code only, provide the expected response code and policy type id. To test the contents of the returned json schema, add a path to a schema file to compare with. + +| arg list | +|--| +| ` []` | + +| parameter | description | +| --------- | ----------- | +| `` | Expected http response code | +| `` | Id of the policy type | +| `` | Path to the schema file for the policy type | + +## Function: api_get_policy_schema() ## +Test of GET '/policy_schema' and optional check of the returned json schema. +To test the response code only, provide the expected response code and policy type id. +To test the contents of the returned json schema, add a path to a schema file to compare with. + | arg list | |--| | ` []` | @@ -671,9 +728,10 @@ To test the contents of the returned json schema, add a path to a schema file to | `` | Path to the schema file for the policy type | ## Function: api_get_policy_schemas() ## -Test of GET /policy_schemas and optional check of the returned json schemas. +Test of GET '/policy_schemas' and optional check of the returned json schemas. To test the response code only, provide the expected response code and ric id (or NORIC if no ric is given). To test the contents of the returned json schema, add a path to a schema file to compare with (or NOFILE to represent an empty '{}' type) + | arg list | |--| | ` |NORIC [|NOFILE]*` | @@ -687,7 +745,8 @@ To test the contents of the returned json schema, add a path to a schema file to | `NOFILE` | Indicate the template for an empty type | ## Function: api_get_policy_status() ## -Test of GET /policy_status. +Test of GET '/policy_status' or V2 GET '/policies/{policy_id}/status'. + | arg list | |--| | ` (STD [])|(OSC )` | @@ -704,7 +763,7 @@ Test of GET /policy_status. | `` | Deleted status, true or false | ## Function: api_get_policy_types() ## -Test of GET /policy_types and optional check of the returned ids. +Test of GET '/policy_types' or V2 GET '/v2/policy-types' and optional check of the returned ids. To test the response code only, provide the expected response code and ric id (or NORIC if no ric is given). To test the contents of the returned json payload, add the list of expected policy type id (or 'EMPTY' for the '{}' type) @@ -721,7 +780,8 @@ To test the contents of the returned json payload, add the list of expected poli | `EMPTY` | Indicate the empty type | ## Function: api_get_status() ## -Test of GET /status +Test of GET /status or V2 GET /status + | arg list | |--| | `` | @@ -731,25 +791,34 @@ Test of GET /status | `` | Expected http response code | ## Function: api_get_ric() ## -Test of GET /ric +Test of GET '/ric' or V2 GET '/v2/rics/ric' To test the response code only, provide the expected response code and managed element id. To test the returned ric id, provide the expected ric id. + | arg list | |--| | ` []` | +| arg list V2 | +|--| +| ` |NOME | []` | + | parameter | description | | --------- | ----------- | | `` | Expected http response code | | `` | Id of the managed element | -| `` | Id of the ric | +| `NOME` | Indicator for no ME | +| `ric-id` | Id of the ric | +| `NORIC` | Indicator no RIC | +| `string-of-ricinfo` | String of ric info | ## Function: api_get_rics() ## -Test of GET /rics and optional check of the returned json payload (ricinfo). +Test of GET '/rics' or V2 GET '/v2/rics' and optional check of the returned json payload (ricinfo). To test the response code only, provide the expected response code and policy type id (or NOTYPE if no type is given). To test also the returned payload, add the formatted string of info in the returned payload. Format of ricinfo: '::' Example ` = "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2,4 ricsim_g1_1:me2_........."` + | arg list | |--| | ` |NOTYPE []` | @@ -762,7 +831,7 @@ Example ` = "ricsim_g1_1:me1_ricsim_g1_1,me2_r | `` | A space separated string of ric info - needs to be quoted | ## Function: api_put_service() ## -Test of PUT /service +Test of PUT '/service' or V2 PUT '/service'. | arg list | |--| | ` ` | @@ -775,9 +844,10 @@ Test of PUT /service | `` | Callback url | ## Function: api_get_services() ## -Test of GET /service and optional check of the returned json payload. +Test of GET '/service' or V2 GET '/v2/services' and optional check of the returned json payload. To test only the response code, omit all parameters except the expected response code. To test the returned json, provide the parameters after the response code. + | arg list | |--| | ` [ ( ) | (NOSERVICE [ ]* )]` | @@ -792,7 +862,8 @@ To test the returned json, provide the parameters after the response code. | `NOSERVICE` | Indicator of no target service name | ## Function: api_get_service_ids() ## -Test of GET /services +Test of GET '/services' or V2 GET /'v2/services'. Only check of service ids. + | arg list | |--| | ` []*` | @@ -803,7 +874,8 @@ Test of GET /services | `` | Service name | ## Function: api_delete_services() ## -Test of DELETE /services +Test of DELETE '/services' or V2 DELETE '/v2/services/{serviceId}' + | arg list | |--| | ` []*` | @@ -814,7 +886,8 @@ Test of DELETE /services | `` | Service name | ## Function: api_put_services_keepalive() ## -Test of PUT /services/keepalive +Test of PUT '/services/keepalive' or V2 PUT '/v2/services/{service_id}/keepalive' + | arg list | |--| | ` | @@ -832,6 +905,7 @@ Tests if a variable value in the RIC simulator is equal to a target value. Without the timeout, the test sets pass or fail immediately depending on if the variable is equal to the target or not. With the timeout, the test waits up to the timeout seconds before setting pass or fail depending on if the variable value becomes equal to the target value or not. See the 'a1-interface' repo for more details. + | arg list | |--| | ` [ ]` | @@ -845,6 +919,7 @@ See the 'a1-interface' repo for more details. ## Function: sim_print ## Prints the value of a variable in the RIC simulator. See the 'a1-interface' repo for more details. + | arg list | |--| | `` | @@ -859,6 +934,7 @@ Tests if a variable value in the RIC simulator contains a target string. Without the timeout, the test sets pass or fail immediately depending on if the variable contains the target string or not. With the timeout, the test waits up to the timeout seconds before setting pass or fail depending on if the variable value contains the target string or not. See the 'a1-interface' repo for more details. + | arg list | |--| | ` [ ]` | @@ -871,6 +947,7 @@ See the 'a1-interface' repo for more details. ## Function: sim_put_policy_type ## Loads a policy type to the simulator + | arg list | |--| | ` ` | @@ -884,6 +961,7 @@ Loads a policy type to the simulator ## Function: sim_delete_policy_type ## Deletes a policy type from the simulator + | arg list | |--| | ` ` | @@ -896,6 +974,7 @@ Deletes a policy type from the simulator ## Function: sim_post_delete_instances ## Deletes all instances (and status), for one ric + | arg list | |--| | ` ` | @@ -908,6 +987,7 @@ Deletes all instances (and status), for one ric ## Function: sim_post_delete_all ## Deletes all types, instances (and status), for one ric + | arg list | |--| | ` ` | @@ -920,6 +1000,7 @@ Deletes all types, instances (and status), for one ric ## Function: sim_post_forcedresponse ## Sets (or resets) response code for next (one) A1 message, for one ric. The intention is to simulate error response on the A1 interface. + | arg list | |--| | ` []`| @@ -933,6 +1014,7 @@ The intention is to simulate error response on the A1 interface. ## Function: sim_post_forcedelay ## Sets (or resets) A1 response delay, for one ric The intention is to delay responses on the A1 interface. Setting remains until removed. + | arg list | |--| | ` []`| @@ -951,6 +1033,7 @@ The file contains a selection of the possible API tests towards the a1-controlle Test of GET policy ids towards OSC or STD type simulator. To test response code only, provide the response code, 'OSC' + policy type or 'STD' To test the response payload, include the ids of the expexted response. + | arg list | |--| | ` (OSC [ []* ]) | ( STD [ []* ]` | @@ -967,6 +1050,7 @@ To test the response payload, include the ids of the expexted response. ## Function: controller_api_get_A1_policy_type ## Test of GET a policy type (OSC only) + | arg list | |--| | ` OSC []` | @@ -981,6 +1065,7 @@ Test of GET a policy type (OSC only) ## Function: controller_api_delete_A1_policy ## Deletes a policy instance + | arg list | |--| | `(STD ) | (OSC )` | @@ -997,6 +1082,7 @@ Deletes a policy instance ## Function: controller_api_put_A1_policy ## Creates a policy instance + | arg list | |--| | ` (STD ) | (OSC )` | @@ -1013,6 +1099,7 @@ Creates a policy instance ## Function: controller_api_get_A1_policy_status ## Checks the status of a policy + arg list | |--| | ` (STD []) | (OSC )` | @@ -1039,6 +1126,7 @@ Checks the status of a policy Test of GET '/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs' and optional check of the array of returned job ids. To test the response code only, provide the response code parameter as well as a type id and an owner id. To also test the response payload add the 'EMPTY' for an expected empty array or repeat the last parameter for each expected job id. + | arg list | |--| | ` |NOOWNER [ EMPTY | + ]` | @@ -1056,6 +1144,7 @@ To also test the response payload add the 'EMPTY' for an expected empty array or Test of GET '/A1-EI​/v1​/eitypes​/{eiTypeId}' and optional check of the returned schema. To test the response code only, provide the response code parameter as well as the type-id. To also test the response payload add a path to the expected schema file. + | arg list | |--| | ` []` | @@ -1070,6 +1159,7 @@ To also test the response payload add a path to the expected schema file. Test of GET '/A1-EI​/v1​/eitypes' and optional check of returned list of type ids. To test the response code only, provide the response only. To also test the response payload add the list of expected type ids (or EMPTY if the list is expected to be empty). + | arg list | |--| | ` [ (EMPTY | []+) ]` | @@ -1084,6 +1174,7 @@ To also test the response payload add the list of expected type ids (or EMPTY if Test of GET '/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}​/status' and optional check of the returned status. To test the response code only, provide the response code, type id and job id. To also test the response payload add the expected status. + | arg list | |--| | ` []` | @@ -1099,6 +1190,7 @@ To also test the response payload add the expected status. Test of GET '/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}' and optional check of the returned job. To test the response code only, provide the response code, type id and job id. To also test the response payload add the remaining parameters. + | arg list | |--| | ` [ ]` | @@ -1115,6 +1207,7 @@ To also test the response payload add the remaining parameters. ## Function: ecs_api_a1_delete_job() ## Test of DELETE '/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}'. To test, provide all the specified parameters. + | arg list | |--| | ` | @@ -1128,6 +1221,7 @@ To test, provide all the specified parameters. ## Function: ecs_api_a1_put_job() ## Test of PUT '/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}'. To test, provide all the specified parameters. + | arg list | |--| | ` ` | @@ -1145,6 +1239,7 @@ To test, provide all the specified parameters. Test of GET '/ei-producer/v1/eitypes' and an optional check of the returned list of type ids. To test the response code only, provide the response code. To also test the response payload add list of expected type ids (or EMPTY if the list is expected to be empty). + | arg list | |--| | ` [ EMPTY | +]` | @@ -1159,6 +1254,7 @@ To also test the response payload add list of expected type ids (or EMPTY if the Test of GET '/ei-producer/v1/eiproducers/{eiProducerId}/status' and optional check of the returned status. To test the response code only, provide the response code and producer id. To also test the response payload add the expected status. + | arg list | |--| | ` []` | @@ -1173,6 +1269,7 @@ To also test the response payload add the expected status. Test of GET '/ei-producer/v1/eiproducers' and optional check of the returned producer ids. To test the response code only, provide the response. To also test the response payload add the list of expected producer-ids (or EMPTY if the list of ids is expected to be empty). + | arg list | |--| | ` [ EMPTY | +]` | @@ -1187,6 +1284,7 @@ To also test the response payload add the list of expected producer-ids (or EMPT Test of GET '/ei-producer/v1/eitypes/{eiTypeId}' and optional check of the returned type. To test the response code only, provide the response and the type-id. To also test the response payload add a path to a job schema file and a list expected producer-id (or EMPTY if the list of ids is expected to be empty). + | arg list | |--| | ` [ (EMPTY | []+)]` | @@ -1203,6 +1301,7 @@ To also test the response payload add a path to a job schema file and a list exp Test of GET '/ei-producer/v1/eiproducers/{eiProducerId}' and optional check of the returned producer. To test the response code only, provide the response and the producer-id. To also test the response payload add the remaining parameters defining thee producer. + | arg list | |--| | ` [ (EMPTY | [ ]+) ]` | @@ -1221,6 +1320,7 @@ To also test the response payload add the remaining parameters defining thee pro ## Function: ecs_api_edp_delete_producer() ## Test of DELETE '/ei-producer/v1/eiproducers/{eiProducerId}'. To test, provide all parameters. + | arg list | |--| | ` ` | @@ -1233,6 +1333,7 @@ To test, provide all parameters. ## Function: ecs_api_edp_put_producer() ## Test of PUT '/ei-producer/v1/eiproducers/{eiProducerId}'. To test, provide all parameters. The list of type/schema pair may be empty. + | arg list | |--| | ` (EMPTY | [ ]+)` | @@ -1252,6 +1353,7 @@ To test, provide all parameters. The list of type/schema pair may be empty. Test of GET '/ei-producer/v1/eiproducers/{eiProducerId}/eijobs' and optional check of the returned producer job. To test the response code only, provide the response and the producer-id. To also test the response payload add the remaining parameters. + | arg list | |--| | ` (EMPTY | [ ]+)` | @@ -1268,6 +1370,7 @@ To also test the response payload add the remaining parameters. ## Function: ecs_api_service_status() ## Test of GET '/status'. + | arg list | |--| | `` | @@ -1281,6 +1384,7 @@ Test of GET '/status'. ## Function: prodstub_arm_producer() ## Preconfigure the prodstub with a producer. The producer supervision response code is optional, if not given the response code will be set to 200. + | arg list | |--| | ` []` | @@ -1293,6 +1397,7 @@ Preconfigure the prodstub with a producer. The producer supervision response cod ## Function: prodstub_arm_job_create() ## Preconfigure the prodstub with a job or update an existing job. Optional create/update job response code, if not given the response code will be set to 200/201 depending on if the job has been previously created or not. + | arg list | |--| | ` []` | @@ -1305,6 +1410,7 @@ Preconfigure the prodstub with a job or update an existing job. Optional create/ ## Function: prodstub_arm_job_delete() ## Preconfigure the prodstub with a job. Optional delete job response code, if not given the response code will be set to 204/404 depending on if the job exists or not. + | arg list | |--| | ` []` | @@ -1317,6 +1423,7 @@ Preconfigure the prodstub with a job. Optional delete job response code, if not ## Function: prodstub_arm_type() ## Preconfigure the prodstub with a type for a producer. Can be called multiple times to add more types. + | arg list | |--| | ` ` | @@ -1329,6 +1436,7 @@ Preconfigure the prodstub with a type for a producer. Can be called multiple tim ## Function: prodstub_disarm_type() ## Remove a type for the producer in the rodstub. Can be called multiple times to remove more types. + | arg list | |--| | ` ` | @@ -1341,6 +1449,7 @@ Remove a type for the producer in the rodstub. Can be called multiple times to r ## Function: prodstub_check_jobdata() ## Check a job in the prodstub towards the list of provided parameters. + | arg list | |--| | ` ` | @@ -1358,6 +1467,7 @@ Check a job in the prodstub towards the list of provided parameters. Tests if a variable value in the prodstub is equal to a target value. Without the timeout, the test sets pass or fail immediately depending on if the variable is equal to the target or not. With the timeout, the test waits up to the timeout seconds before setting pass or fail depending on if the variable value becomes equal to the target value or not. + | arg list | |--| | ` [ ]` | diff --git a/test/common/agent_api_functions.sh b/test/common/agent_api_functions.sh index 29e1bf1a..507e011d 100644 --- a/test/common/agent_api_functions.sh +++ b/test/common/agent_api_functions.sh @@ -35,7 +35,11 @@ api_equal() { echo "(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG if [ $# -eq 2 ] || [ $# -eq 3 ]; then if [[ $1 == "json:"* ]]; then - __var_test "Policy Agent" $LOCALHOST$POLICY_AGENT_EXTERNAL_PORT"/" $1 "=" $2 $3 + if [ "$PMS_VERSION" == "V2" ]; then + __var_test "Policy Agent" $LOCALHOST$POLICY_AGENT_EXTERNAL_PORT"/v2/" $1 "=" $2 $3 + else + __var_test "Policy Agent" $LOCALHOST$POLICY_AGENT_EXTERNAL_PORT"/" $1 "=" $2 $3 + fi return 0 fi fi @@ -45,92 +49,184 @@ api_equal() { return 1 } -# API Test function: GET /policies -# args: |NORIC |NOSERVICE |NOTYPE [ NOID | [ EMPTY| ]*] +# API Test function: GET /policies and V2 GET /v2/policy_instances +# args: |NORIC |NOSERVICE |NOTYPE [ NOID | [ EMPTY| ]*] +# args(V2): |NORIC |NOSERVICE |NOTYPE [ NOID | [ EMPTY| ]*] # (Function for test scripts) api_get_policies() { echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG ((RES_TEST++)) - paramError=0 - if [ $# -lt 4 ]; then - paramError=1 - elif [ $# -eq 5 ] && [ $5 != "NOID" ]; then - paramError=1 - elif [ $# -gt 4 ] && [ $(($#%5)) -ne 4 ]; then - paramError=1 + + if [ "$PMS_VERSION" == "V2" ]; then + paramError=0 + variableParams=$(($#-4)) + if [ $# -lt 4 ]; then + paramError=1 + elif [ $# -eq 5 ] && [ $5 != "NOID" ]; then + paramError=1 + elif [ $# -gt 5 ] && [ $(($variableParams%7)) -ne 0 ]; then + paramError=1 + fi + + if [ $paramError -ne 0 ]; then + __print_err " |NORIC |NOSERVICE |NOTYPE [ NOID | [ EMPTY| ]*]" $@ + return 1 + fi + else + paramError=0 + variableParams=$(($#-4)) + if [ $# -lt 4 ]; then + paramError=1 + elif [ $# -eq 5 ] && [ $5 != "NOID" ]; then + paramError=1 + elif [ $# -gt 5 ] && [ $(($variableParams%5)) -ne 0 ]; then + paramError=1 + fi + + if [ $paramError -ne 0 ]; then + __print_err " |NORIC |NOSERVICE |NOTYPE [ NOID | [ EMPTY| ]*]" $@ + return 1 + fi fi - if [ $paramError -ne 0 ]; then - __print_err " |NORIC |NOSERVICE |NOTYPE [ NOID | [ EMPTY| ]*]" $@ - return 1 - fi queryparams="" - if [ $2 != "NORIC" ]; then - queryparams="?ric="$2 - fi - if [ $3 != "NOSERVICE" ]; then - if [ -z $queryparams ]; then - queryparams="?service="$3 - else - queryparams=$queryparams"&service="$3 + if [ "$PMS_VERSION" == "V2" ]; then + if [ $2 != "NORIC" ]; then + queryparams="?ric_id="$2 fi - fi - if [ $4 != "NOTYPE" ]; then - if [ -z $queryparams ]; then - queryparams="?type="$4 - else - queryparams=$queryparams"&type="$4 + if [ $3 != "NOSERVICE" ]; then + if [ -z $queryparams ]; then + queryparams="?service_id="$3 + else + queryparams=$queryparams"&service_id="$3 + fi + fi + if [ $4 != "NOTYPE" ]; then + if [ -z $queryparams ]; then + queryparams="?policytype_id="$4 + else + queryparams=$queryparams"&policytype_id="$4 + fi fi - fi - query="/policies"$queryparams - res="$(__do_curl_to_api PA GET $query)" - status=${res:${#res}-3} + query="/v2/policy_instances"$queryparams + res="$(__do_curl_to_api PA GET $query)" + status=${res:${#res}-3} - if [ $status -ne $1 ]; then - echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED - ((RES_FAIL++)) - __check_stop_at_error - return 1 - fi + if [ $status -ne $1 ]; then + echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED + ((RES_FAIL++)) + __check_stop_at_error + return 1 + fi - if [ $# -gt 4 ]; then - if [ $# -eq 5 ] && [ $5 == "NOID" ]; then - targetJson="[" - else + if [ $# -gt 4 ]; then body=${res:0:${#res}-3} - targetJson="[" - arr=(${@:5}) - - for ((i=0; i<$(($#-4)); i=i+5)); do - - if [ "$targetJson" != "[" ]; then - targetJson=$targetJson"," - fi - 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 - targetJson=$targetJson"\"${arr[$i+3]}\"," - fi - file="./tmp/.p.json" - sed 's/XXX/'${arr[$i]}'/g' ${arr[$i+4]} > $file - json=$(cat $file) - targetJson=$targetJson"\"json\":"$json"}" - done + if [ $# -eq 5 ] && [ $5 == "NOID" ]; then + targetJson="[" + else + targetJson="[" + arr=(${@:5}) + + for ((i=0; i<$(($#-4)); i=i+7)); do + + if [ "$targetJson" != "[" ]; then + targetJson=$targetJson"," + fi + targetJson=$targetJson"{\"policy_id\":\"$UUID${arr[$i]}\",\"ric_id\":\"${arr[$i+1]}\",\"service_id\":\"${arr[$i+2]}\",\"policy_type_id\":" + if [ "${arr[$i+3]}" == "EMPTY" ]; then + targetJson=$targetJson"\"\"," + else + targetJson=$targetJson"\"${arr[$i+3]}\"," + fi + targetJson=$targetJson"\"transient\":${arr[$i+4]},\"status_notification_uri\":\"${arr[$i+5]}\"," + file="./tmp/.p.json" + sed 's/XXX/'${arr[$i]}'/g' ${arr[$i+6]} > $file + json=$(cat $file) + targetJson=$targetJson"\"policy_data\":"$json"}" + done + fi + + targetJson=$targetJson"]" + targetJson="{\"policies\": $targetJson}" + echo "TARGET JSON: $targetJson" >> $HTTPLOG + res=$(python3 ../common/compare_json.py "$targetJson" "$body") + + if [ $res -ne 0 ]; then + echo -e $RED" FAIL, returned body not correct"$ERED + ((RES_FAIL++)) + __check_stop_at_error + return 1 + fi + fi + else + if [ $2 != "NORIC" ]; then + queryparams="?ric="$2 + fi + if [ $3 != "NOSERVICE" ]; then + if [ -z $queryparams ]; then + queryparams="?service="$3 + else + queryparams=$queryparams"&service="$3 + fi + fi + if [ $4 != "NOTYPE" ]; then + if [ -z $queryparams ]; then + queryparams="?type="$4 + else + queryparams=$queryparams"&type="$4 + fi fi - targetJson=$targetJson"]" - echo "TARGET JSON: $targetJson" >> $HTTPLOG - res=$(python3 ../common/compare_json.py "$targetJson" "$body") + query="/policies"$queryparams + res="$(__do_curl_to_api PA GET $query)" + status=${res:${#res}-3} - if [ $res -ne 0 ]; then - echo -e $RED" FAIL, returned body not correct"$ERED + if [ $status -ne $1 ]; then + echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED ((RES_FAIL++)) __check_stop_at_error return 1 fi + + if [ $# -gt 4 ]; then + if [ $# -eq 5 ] && [ $5 == "NOID" ]; then + targetJson="[" + else + body=${res:0:${#res}-3} + targetJson="[" + arr=(${@:5}) + + for ((i=0; i<$(($#-4)); i=i+5)); do + + if [ "$targetJson" != "[" ]; then + targetJson=$targetJson"," + fi + 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 + targetJson=$targetJson"\"${arr[$i+3]}\"," + fi + file="./tmp/.p.json" + sed 's/XXX/'${arr[$i]}'/g' ${arr[$i+4]} > $file + json=$(cat $file) + targetJson=$targetJson"\"json\":"$json"}" + done + fi + + targetJson=$targetJson"]" + echo "TARGET JSON: $targetJson" >> $HTTPLOG + res=$(python3 ../common/compare_json.py "$targetJson" "$body") + + if [ $res -ne 0 ]; then + echo -e $RED" FAIL, returned body not correct"$ERED + ((RES_FAIL++)) + __check_stop_at_error + return 1 + fi + fi fi ((RES_PASS++)) @@ -139,20 +235,31 @@ api_get_policies() { } -# API Test function: GET /policy -#args: [] + +# API Test function: GET /policy and V2 GET /v2/policies/{policy_id} +# args: [] +# args(V2): [ |NOTYPE |NOURL ] + # (Function for test scripts) api_get_policy() { echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG ((RES_TEST++)) - if [ $# -lt 2 ] || [ $# -gt 3 ]; then - __print_err " [] " $@ - return 1 - fi - query="/policy?id=$UUID$2" + if [ "$PMS_VERSION" == "V2" ]; then + if [ $# -ne 2 ] && [ $# -ne 8 ]; then + __print_err " [ |NOTYPE |NOURL ]" $@ + return 1 + fi + query="/v2/policies/$UUID$2" + else + if [ $# -lt 2 ] || [ $# -gt 3 ]; then + __print_err " [] " $@ + return 1 + fi + query="/policy?id=$UUID$2" + fi res="$(__do_curl_to_api PA GET $query)" status=${res:${#res}-3} @@ -163,19 +270,54 @@ api_get_policy() { return 1 fi - if [ $# -eq 3 ]; then - #Create a policy json to compare with - body=${res:0:${#res}-3} - file="./tmp/.p.json" - sed 's/XXX/'${2}'/g' $3 > $file - targetJson=$(< $file) - echo "TARGET JSON: $targetJson" >> $HTTPLOG - res=$(python3 ../common/compare_json.py "$targetJson" "$body") - if [ $res -ne 0 ]; then - echo -e $RED" FAIL, returned body not correct"$ERED - ((RES_FAIL++)) - __check_stop_at_error - return 1 + if [ "$PMS_VERSION" == "V2" ]; then + if [ $# -eq 8 ]; then + + #Create a policy json to compare with + body=${res:0:${#res}-3} + file="./tmp/.p.json" + + targetJson="\"ric_id\":\"$5\",\"policy_id\":\"$UUID$2\",\"service_id\":\"$4\"" + if [ $7 != "NOTRANSIENT" ]; then + targetJson=$targetJson", \"transient\":$7" + fi + if [ $6 != "NOTYPE" ]; then + targetJson=$targetJson", \"policy_type_id\":\"$6\"" + else + targetJson=$targetJson", \"policy_type_id\":\"\"" + fi + if [ $8 != "NOURL" ]; then + targetJson=$targetJson", \"status_notification_uri\":\"$8\"" + fi + + data=$(sed 's/XXX/'${2}'/g' $temp) + targetJson=$targetJson", \"policy_data\":$data" + targetJson="{$targetJson}" + + echo "TARGET JSON: $targetJson" >> $HTTPLOG + res=$(python3 ../common/compare_json.py "$targetJson" "$body") + if [ $res -ne 0 ]; then + echo -e $RED" FAIL, returned body not correct"$ERED + ((RES_FAIL++)) + __check_stop_at_error + return 1 + fi + fi + else + if [ $# -eq 3 ]; then + #Create a policy json to compare with + body=${res:0:${#res}-3} + file="./tmp/.p.json" + sed 's/XXX/'${2}'/g' $3 > $file + targetJson=$(< $file) + echo "TARGET JSON: $targetJson" >> $HTTPLOG + res=$(python3 ../common/compare_json.py "$targetJson" "$body") + if [ $res -ne 0 ]; then + echo -e $RED" FAIL, returned body not correct"$ERED + ((RES_FAIL++)) + __check_stop_at_error + return 1 + fi fi fi @@ -184,43 +326,84 @@ api_get_policy() { return 0 } -# API Test function: PUT /policy -# args: [] +# API Test function: PUT /policy and V2 PUT /policies +# args: |NOTYPE |NOTRANSIENT [] +# args(V2): |NOTYPE |NOTRANSIENT |NOURL [] # (Function for test scripts) api_put_policy() { echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG ((RES_TEST++)) - if [ $# -lt 7 ] || [ $# -gt 8 ]; then - __print_err " |NOTRANSIENT []" $@ - return 1 - fi + if [ "$PMS_VERSION" == "V2" ]; then + if [ $# -lt 8 ] || [ $# -gt 9 ]; then + __print_err " |NOTYPE |NOTRANSIENT |NOURL []" $@ + return 1 + fi + else + if [ $# -lt 7 ] || [ $# -gt 8 ]; then + __print_err " |NOTYPE |NOTRANSIENT []" $@ + return 1 + fi + fi - ric=$3 count=0 max=1 + serv=$2 + ric=$3 + pt=$4 + pid=$5 + trans=$6 - if [ $# -eq 8 ]; then - max=$8 + if [ "$PMS_VERSION" == "V2" ]; then + noti=$7 + temp=$8 + if [ $# -eq 9 ]; then + max=$9 + fi + else + temp=$7 + if [ $# -eq 8 ]; then + max=$8 + fi fi - pid=$5 - file=$7 - while [ $count -lt $max ]; do - query="/policy?id=$UUID$pid&ric=$ric&service=$2" + if [ "$PMS_VERSION" == "V2" ]; then - if [ $4 != "NOTYPE" ]; then - query=$query"&type=$4" - fi + query="/v2/policies" - if [ $6 != NOTRANSIENT ]; then - query=$query"&transient=$6" - fi + inputJson="\"ric_id\":\"$ric\",\"policy_id\":\"$UUID$pid\",\"service_id\":\"$serv\"" + if [ $trans != "NOTRANSIENT" ]; then + inputJson=$inputJson", \"transient\":$trans" + fi + if [ $pt != "NOTYPE" ]; then + inputJson=$inputJson", \"policy_type_id\":$pt" + else + inputJson=$inputJson", \"policy_type_id\":\"\"" + fi + if [ $noti != "NOURL" ]; then + inputJson=$inputJson", \"status_notification_uri\":\"$noti\"" + fi + file="./tmp/.p.json" + data=$(sed 's/XXX/'${pid}'/g' $temp) + inputJson=$inputJson", \"policy_data\":$data" + inputJson="{$inputJson}" + echo $inputJson > $file + else + query="/policy?id=$UUID$pid&ric=$ric&service=$serv" - file="./tmp/.p.json" - sed 's/XXX/'${pid}'/g' $7 > $file + if [ $pt != "NOTYPE" ]; then + query=$query"&type=$pt" + fi + + if [ $trans != NOTRANSIENT ]; then + query=$query"&transient=$trans" + fi + + file="./tmp/.p.json" + sed 's/XXX/'${pid}'/g' $temp > $file + fi res="$(__do_curl_to_api PA PUT $query $file)" status=${res:${#res}-3} echo -ne " Executing "$count"("$max")${SAMELINE}" @@ -243,43 +426,83 @@ api_put_policy() { return 0 } -# API Test function: PUT /policy to run in batch -# args: [] +# API Test function: PUT /policy and V2 PUT /policies, to run in batch +# args: |NOTYPE [] +# args(V2): |NOTYPE |NOURL [] # (Function for test scripts) + api_put_policy_batch() { echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG ((RES_TEST++)) - if [ $# -lt 7 ] || [ $# -gt 8 ]; then - __print_err " []" $@ - return 1 - fi + if [ "$PMS_VERSION" == "V2" ]; then + if [ $# -lt 8 ] || [ $# -gt 9 ]; then + __print_err " |NOTYPE |NOURL []" $@ + return 1 + fi + else + if [ $# -lt 7 ] || [ $# -gt 8 ]; then + __print_err " |NOTYPE []" $@ + return 1 + fi + fi - ric=$3 count=0 max=1 - - if [ $# -eq 8 ]; then - max=$8 + serv=$2 + ric=$3 + pt=$4 + pid=$5 + trans=$6 + if [ "$PMS_VERSION" == "V2" ]; then + noti=$7 + temp=$8 + if [ $# -eq 9 ]; then + max=$9 + fi + else + temp=$7 + if [ $# -eq 8 ]; then + max=$8 + fi fi - pid=$5 - file=$7 ARR="" while [ $count -lt $max ]; do - query="/policy?id=$UUID$pid&ric=$ric&service=$2" + if [ "$PMS_VERSION" == "V2" ]; then + query="/v2/policies" - if [ $4 != "NOTYPE" ]; then - query=$query"&type=$4" - fi + inputJson="\"ric_id\":\"$ric\",\"policy_id\":\"$UUID$pid\",\"service_id\":\"$serv\"" + if [ $trans != "NOTRANSIENT" ]; then + inputJson=$inputJson", \"transient\":$trans" + fi + if [ $pt != "NOTYPE" ]; then + inputJson=$inputJson", \"policy_type_id\":$pt" + else + inputJson=$inputJson", \"policy_type_id\":\"\"" + fi + if [ $noti != "NOURL" ]; then + inputJson=$inputJson", \"status_notification_uri\":\"$noti\"" + fi + file="./tmp/.p.json" + data=$(sed 's/XXX/'${pid}'/g' $temp) + inputJson=$inputJson", \"policy_data\":$data" + inputJson="{$inputJson}" + echo $inputJson > $file + else + query="/policy?id=$UUID$pid&ric=$ric&service=$serv" - if [ $6 != NOTRANSIENT ]; then - query=$query"&transient=$6" - fi + if [ $pt != "NOTYPE" ]; then + query=$query"&type=$pt" + fi - file="./tmp/.p.json" - sed 's/XXX/'${pid}'/g' $7 > $file + if [ $trans != NOTRANSIENT ]; then + query=$query"&transient=$trans" + fi + file="./tmp/.p.json" + sed 's/XXX/'${pid}'/g' $temp > $file + fi res="$(__do_curl_to_api PA PUT_BATCH $query $file)" status=${res:${#res}-3} echo -ne " Requesting(batch) "$count"("$max")${SAMELINE}" @@ -304,10 +527,10 @@ api_put_policy_batch() { res="$(__do_curl_to_api PA RESPONSE $cid)" status=${res:${#res}-3} - echo -ne " Requesting(batch) "$count"("$max")${SAMELINE}" + echo -ne " Accepting(batch) "$count"("$max")${SAMELINE}" if [ $status -ne $1 ]; then - echo " Requested(batch) "$count"?("$max")" + echo " Accepted(batch) "$count"?("$max")" echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED ((RES_FAIL++)) __check_stop_at_error @@ -315,7 +538,7 @@ api_put_policy_batch() { fi let count=$count+1 - echo -ne " Requested(batch) "$count"("$max")${SAMELINE}" + echo -ne " Accepted(batch) "$count"("$max")${SAMELINE}" done echo "" @@ -325,18 +548,26 @@ api_put_policy_batch() { return 0 } -# API Test function: PUT /policy to run in i parallel for a number of rics +# API Test function: PUT /policy and V2 PUT /policies, to run in i parallel for a number of rics # args: +# args(V2): |NOURL # (Function for test scripts) api_put_policy_parallel() { echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG ((RES_TEST++)) - if [ $# -ne 10 ]; then - __print_err " " $@ - return 1 - fi + if [ "$PMS_VERSION" == "V2" ]; then + if [ $# -ne 11 ]; then + __print_err " |NOURL " $@ + return 1 + fi + else + if [ $# -ne 10 ]; then + __print_err " " $@ + return 1 + fi + fi resp_code=$1; shift; serv=$1; shift ric_base=$1; shift; @@ -344,6 +575,11 @@ api_put_policy_parallel() { type=$1; shift; start_id=$1; shift; transient=$1; shift; + if [ "$PMS_VERSION" == "V2" ]; then + noti=$1; shift; + else + noti="" + fi template=$1; shift; count=$1; shift; pids=$1; shift; @@ -352,18 +588,24 @@ api_put_policy_parallel() { echo " Info - api_put_policy_parallel uses only the agent REST interface - create over dmaap in parallel is not supported" echo " Info - will execute over agent REST" fi + if [ "$PMS_VERSION" == "V2" ]; then + if [ $serv == "NOSERVICE" ]; then + serv="" + fi + query="/v2/policies" + else + if [ $serv == "NOSERVICE" ]; then + serv="" + fi + query="/policy?service=$serv" - if [ $serv == "NOSERVICE" ]; then - serv="" - fi - query="/policy?service=$serv" - - if [ $type != "NOTYPE" ]; then - query=$query"&type=$type" - fi + if [ $type != "NOTYPE" ]; then + query=$query"&type=$type" + fi - if [ $transient != NOTRANSIENT ]; then - query=$query"&transient=$transient" + if [ $transient != NOTRANSIENT ]; then + query=$query"&transient=$transient" + fi fi urlbase=${ADAPTER}${query} @@ -375,7 +617,11 @@ api_put_policy_parallel() { uuid="NOUUID" fi echo "" > "./tmp/.pid${i}.res.txt" - echo $resp_code $urlbase $ric_base $num_rics $uuid $start_id $template $count $pids $i > "./tmp/.pid${i}.txt" + if [ "$PMS_VERSION" == "V2" ]; then + echo $resp_code $urlbase $ric_base $num_rics $uuid $start_id $serv $type $transient $noti $template $count $pids $i > "./tmp/.pid${i}.txt" + else + echo $resp_code $urlbase $ric_base $num_rics $uuid $start_id $template $count $pids $i > "./tmp/.pid${i}.txt" + fi echo $i done | xargs -n 1 -I{} -P $pids bash -c '{ arg=$(echo {}) @@ -414,7 +660,7 @@ api_put_policy_parallel() { return 1 } -# API Test function: DELETE /policy +# API Test function: DELETE /policy and V2 DELETE /v2/policies/{policy_id} # args: [count] # (Function for test scripts) api_delete_policy() { @@ -437,7 +683,11 @@ api_delete_policy() { pid=$2 while [ $count -lt $max ]; do - query="/policy?id="$UUID$pid + if [ "$PMS_VERSION" == "V2" ]; then + query="/v2/policies/"$UUID$pid + else + query="/policy?id="$UUID$pid + fi res="$(__do_curl_to_api PA DELETE $query)" status=${res:${#res}-3} echo -ne " Executing "$count"("$max")${SAMELINE}" @@ -460,7 +710,7 @@ api_delete_policy() { return 0 } -# API Test function: DELETE /policy to run in batch +# API Test function: DELETE /policy and V2 DELETE /v2/policies/{policy_id}, to run in batch # args: [count] # (Function for test scripts) api_delete_policy_batch() { @@ -483,7 +733,11 @@ api_delete_policy_batch() { pid=$2 ARR="" while [ $count -lt $max ]; do - query="/policy?id="$UUID$pid + if [ "$PMS_VERSION" == "V2" ]; then + query="/v2/policies/"$UUID$pid + else + query="/policy?id="$UUID$pid + fi res="$(__do_curl_to_api PA DELETE_BATCH $query)" status=${res:${#res}-3} echo -ne " Requesting(batch) "$count"("$max")${SAMELINE}" @@ -509,7 +763,7 @@ api_delete_policy_batch() { res="$(__do_curl_to_api PA RESPONSE $cid)" status=${res:${#res}-3} - echo -ne " Deleted(batch) "$count"("$max")${SAMELINE}" + echo -ne " Deleting(batch) "$count"("$max")${SAMELINE}" if [ $status -ne $1 ]; then echo " Deleted(batch) "$count"?("$max")" @@ -523,12 +777,14 @@ api_delete_policy_batch() { echo -ne " Deleted(batch) "$count"("$max")${SAMELINE}" done + echo "" + ((RES_PASS++)) echo -e $GREEN" PASS"$EGREEN return 0 } -# API Test function: DELETE /policy to run in i parallel for a number of rics +# API Test function: DELETE /policy and V2 DELETE /v2/policies/{policy_id}, to run in i parallel for a number of rics # args: # (Function for test scripts) api_delete_policy_parallel() { @@ -551,7 +807,11 @@ api_delete_policy_parallel() { echo " Info - will execute over agent REST" fi - query="/policy" + if [ "$PMS_VERSION" == "V2" ]; then + query="/v2/policies/" + else + query="/policy" + fi urlbase=${ADAPTER}${query} @@ -567,8 +827,8 @@ api_delete_policy_parallel() { done | xargs -n 1 -I{} -P $pids bash -c '{ arg=$(echo {}) echo " Parallel process $arg started" - tmp=$(< "./tmp/pid${arg}.del.txt") - python3 ../common/delete_policies_process.py $tmp > ./tmp/pid${arg}.del.res.txt + tmp=$(< "./tmp/.pid${arg}.del.txt") + python3 ../common/delete_policies_process.py $tmp > ./tmp/.pid${arg}.del.res.txt }' msg="" for ((i=1; i<=$pids; i++)) @@ -601,7 +861,7 @@ api_delete_policy_parallel() { return 1 } -# API Test function: GET /policy_ids +# API Test function: GET /policy_ids and V2 GET /v2/policies # args: |NORIC |NOSERVICE |NOTYPE ([> $HTTPLOG + res=$(python3 ../common/compare_json.py "$targetJson" "$body") + + if [ $res -ne 0 ]; then + echo -e $RED" FAIL, returned body not correct"$ERED + ((RES_FAIL++)) + __check_stop_at_error + return 1 + fi + fi + + ((RES_PASS++)) + echo -e $GREEN" PASS"$EGREEN + return 0 +} + +# API Test function: V2 GET /v2/policy-types/{policyTypeId} +# args(V2): [] +# (Function for test scripts) +api_get_policy_type() { + echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD + echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG + ((RES_TEST++)) + + if [ "$PMS_VERSION" != "V2" ]; then + echo -e $RED" FAIL, function not supported"$ERED + ((RES_FAIL++)) + __check_stop_at_error + return 1 + fi + + if [ $# -lt 2 ] || [ $# -gt 3 ]; then + __print_err " []" $@ + return 1 + fi + query="/v2/policy-types/$2" + + res="$(__do_curl_to_api PA GET $query)" + status=${res:${#res}-3} + + if [ $status -ne $1 ]; then + echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED + ((RES_FAIL++)) + __check_stop_at_error + return 1 + fi + + if [ $# -eq 3 ]; then + + body=${res:0:${#res}-3} + + targetJson=$(< $3) + targetJson="{\"policy_schema\":$targetJson}" echo "TARGET JSON: $targetJson" >> $HTTPLOG res=$(python3 ../common/compare_json.py "$targetJson" "$body") @@ -684,11 +1024,17 @@ api_get_policy_schema() { echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG ((RES_TEST++)) + if [ "$PMS_VERSION" == "V2" ]; then + echo -e $RED" FAIL, function not supported"$ERED + ((RES_FAIL++)) + __check_stop_at_error + return 1 + fi + if [ $# -lt 2 ] || [ $# -gt 3 ]; then __print_err " []" $@ return 1 fi - query="/policy_schema?id=$2" res="$(__do_curl_to_api PA GET $query)" status=${res:${#res}-3} @@ -705,6 +1051,7 @@ api_get_policy_schema() { body=${res:0:${#res}-3} targetJson=$(< $3) + echo "TARGET JSON: $targetJson" >> $HTTPLOG res=$(python3 ../common/compare_json.py "$targetJson" "$body") @@ -723,20 +1070,31 @@ api_get_policy_schema() { # API Test function: GET /policy_schemas # args: |NORIC [|NOFILE]* +# args(V2): # (Function for test scripts) api_get_policy_schemas() { echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG ((RES_TEST++)) - if [ $# -lt 2 ]; then - __print_err " |NORIC [|NOFILE]*" $@ - return 1 - fi - - query="/policy_schemas" - if [ $2 != "NORIC" ]; then - query=$query"?ric="$2 + if [ "$PMS_VERSION" == "V2" ]; then + if [ $# -ne 1 ]; then + __print_err "" $@ + return 1 + fi + else + if [ $# -lt 2 ]; then + __print_err " |NORIC [|NOFILE]*" $@ + return 1 + fi + fi + if [ "$PMS_VERSION" == "V2" ]; then + query="/v2/policy-schemas" + else + query="/policy_schemas" + if [ $2 != "NORIC" ]; then + query=$query"?ric="$2 + fi fi res="$(__do_curl_to_api PA GET $query)" @@ -765,6 +1123,9 @@ api_get_policy_schemas() { done targetJson=$targetJson"]" + if [ "$PMS_VERSION" == "V2" ]; then + targetJson="{\"policy_schemas\": $targetJson }" + fi echo "TARGET JSON: $targetJson" >> $HTTPLOG res=$(python3 ../common/compare_json.py "$targetJson" "$body") @@ -781,13 +1142,14 @@ api_get_policy_schemas() { return 0 } -# API Test function: GET /policy_status +# API Test function: GET /policy_status and V2 GET /policies/{policy_id}/status # arg: (STD [])|(OSC ) # (Function for test scripts) api_get_policy_status() { echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG ((RES_TEST++)) + if [ $# -lt 4 ] || [ $# -gt 5 ]; then __print_err " (STD [])|(OSC )" $@ return 1 @@ -812,7 +1174,12 @@ api_get_policy_status() { return 1 fi - query="/policy_status?id="$UUID$2 + if [ "$PMS_VERSION" == "V2" ]; then + query="/v2/policies/$UUID$2/status" + targetJson="{\"last_modified\":\"????\",\"status\":$targetJson}" + else + query="/policy_status?id="$UUID$2 + fi res="$(__do_curl_to_api PA GET $query)" status=${res:${#res}-3} @@ -840,7 +1207,7 @@ api_get_policy_status() { return 0 } -# API Test function: GET /policy_types +# API Test function: GET /policy_types and V2 GET /v2/policy-types # args: [|NORIC [|EMPTY []*]] # (Function for test scripts) api_get_policy_types() { @@ -853,12 +1220,22 @@ api_get_policy_types() { return 1 fi - if [ $# -eq 1 ]; then - query="/policy_types" - elif [ $2 == "NORIC" ]; then - query="/policy_types" + if [ "$PMS_VERSION" == "V2" ]; then + if [ $# -eq 1 ]; then + query="/v2/policy-types" + elif [ $2 == "NORIC" ]; then + query="/v2/policy-types" + else + query="/v2/policy-types?ric_id=$2" + fi else - query="/policy_types?ric=$2" + if [ $# -eq 1 ]; then + query="/policy_types" + elif [ $2 == "NORIC" ]; then + query="/policy_types" + else + query="/policy_types?ric=$2" + fi fi res="$(__do_curl_to_api PA GET $query)" @@ -886,6 +1263,9 @@ api_get_policy_types() { done targetJson=$targetJson"]" + if [ "$PMS_VERSION" == "V2" ]; then + targetJson="{\"policy_type_ids\": $targetJson }" + fi echo "TARGET JSON: $targetJson" >> $HTTPLOG res=$(python3 ../common/compare_json.py "$targetJson" "$body") @@ -906,7 +1286,7 @@ api_get_policy_types() { #### Test case functions Health check ######################################################### -# API Test function: GET /status +# API Test function: GET /status and V2 GET /status # args: # (Function for test scripts) api_get_status() { @@ -917,7 +1297,11 @@ api_get_status() { __print_err "" $@ return 1 fi - query="/status" + if [ "$PMS_VERSION" == "V2" ]; then + query="/v2/status" + else + query="/status" + fi res="$(__do_curl_to_api PA GET $query)" status=${res:${#res}-3} @@ -937,46 +1321,102 @@ api_get_status() { #### Test case functions RIC Repository ######################################################### -# API Test function: GET /ric +# API Test function: GET /ric and V2 GET /v2/rics/ric # args: [] +# (V2) args: |NOME | [] +# (V2) example of = "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2,4" +# (V2) format of ric-info: :: + + # (Function for test scripts) api_get_ric() { echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG ((RES_TEST++)) - if [ $# -lt 2 ] || [ $# -gt 3 ]; then - __print_err " []" $@ - return 1 - fi - query="/ric?managedElementId="$2 + if [ "$PMS_VERSION" == "V2" ]; then + if [ $# -lt 3 ]; then + __print_err " |NOME | [string-of-ricinfo>]" $@ + return 1 + fi + search="" + if [ $2 != "NOME" ]; then + search="?managed_element_id="$2 + fi + if [ $3 != "NORIC" ]; then + if [ -z $search ]; then + search="?ric_id="$3 + else + search=$search"&ric_id="$3 + fi + fi + query="/v2/rics/ric"$search - res="$(__do_curl_to_api PA GET $query)" - status=${res:${#res}-3} + res="$(__do_curl_to_api PA GET $query)" + status=${res:${#res}-3} - if [ $status -ne $1 ]; then - echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED - ((RES_FAIL++)) - __check_stop_at_error - return 1 - fi + if [ $status -ne $1 ]; then + echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED + ((RES_FAIL++)) + __check_stop_at_error + return 1 + fi - if [ $# -eq 3 ]; then - body=${res:0:${#res}-3} - if [ "$body" != "$3" ]; then - echo -e $RED" FAIL, returned body not correct"$ERED + if [ $# -gt 3 ]; then + body=${res:0:${#res}-3} + res=$(python3 ../common/create_rics_json.py "./tmp/.tmp_rics.json" "V2" "$4" ) + if [ $res -ne 0 ]; then + echo -e $RED" FAIL, could not create target ric info json"$ERED + ((RES_FAIL++)) + __check_stop_at_error + return 1 + fi + + targetJson=$(<./tmp/.tmp_rics.json) + targetJson=${targetJson:1:${#targetJson}-2} #remove array brackets + echo " TARGET JSON: $targetJson" >> $HTTPLOG + res=$(python3 ../common/compare_json.py "$targetJson" "$body") + if [ $res -ne 0 ]; then + echo -e $RED" FAIL, returned body not correct"$ERED + ((RES_FAIL++)) + __check_stop_at_error + return 1 + fi + fi + else + if [ $# -lt 2 ] || [ $# -gt 3 ]; then + __print_err " []" $@ + return 1 + fi + + query="/ric?managedElementId="$2 + + res="$(__do_curl_to_api PA GET $query)" + status=${res:${#res}-3} + + if [ $status -ne $1 ]; then + echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED ((RES_FAIL++)) __check_stop_at_error return 1 fi - fi + if [ $# -eq 3 ]; then + body=${res:0:${#res}-3} + if [ "$body" != "$3" ]; then + echo -e $RED" FAIL, returned body not correct"$ERED + ((RES_FAIL++)) + __check_stop_at_error + return 1 + fi + fi + fi ((RES_PASS++)) echo -e $GREEN" PASS"$EGREEN return 0 } -# API test function: GET /rics +# API test function: GET /rics and V2 GET /v2/rics # args: |NOTYPE [] # example of = "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2,4 ricsim_g1_1:me2_........." # format of ric-info: :: @@ -991,9 +1431,16 @@ api_get_rics() { return 1 fi - query="/rics" - if [ $2 != "NOTYPE" ]; then - query="/rics?policyType="$2 + if [ "$PMS_VERSION" == "V2" ]; then + query="/v2/rics" + if [ $2 != "NOTYPE" ]; then + query="/v2/rics?policytype_id="$2 + fi + else + query="/rics" + if [ $2 != "NOTYPE" ]; then + query="/rics?policyType="$2 + fi fi res="$(__do_curl_to_api PA GET $query)" @@ -1008,7 +1455,11 @@ api_get_rics() { if [ $# -gt 2 ]; then body=${res:0:${#res}-3} - res=$(python3 ../common/create_rics_json.py "./tmp/.tmp_rics.json" "$3" ) + if [ "$PMS_VERSION" == "V2" ]; then + res=$(python3 ../common/create_rics_json.py "./tmp/.tmp_rics.json" "V2" "$3" ) + else + res=$(python3 ../common/create_rics_json.py "./tmp/.tmp_rics.json" "V1" "$3" ) + fi if [ $res -ne 0 ]; then echo -e $RED" FAIL, could not create target ric info json"$ERED ((RES_FAIL++)) @@ -1017,6 +1468,9 @@ api_get_rics() { fi targetJson=$(<./tmp/.tmp_rics.json) + if [ "$PMS_VERSION" == "V2" ]; then + targetJson="{\"rics\": $targetJson }" + fi echo "TARGET JSON: $targetJson" >> $HTTPLOG res=$(python3 ../common/compare_json.py "$targetJson" "$body") if [ $res -ne 0 ]; then @@ -1036,7 +1490,7 @@ api_get_rics() { #### API Test case functions Service registry and supervision #### ################################################################## -# API test function: PUT /service +# API test function: PUT /service and V2 PUT /service # args: # (Function for test scripts) api_put_service() { @@ -1048,8 +1502,13 @@ api_put_service() { return 1 fi - query="/service" - json="{\"callbackUrl\": \""$4"\",\"keepAliveIntervalSeconds\": \""$3"\",\"serviceName\": \""$2"\"}" + if [ "$PMS_VERSION" == "V2" ]; then + query="/v2/services" + json="{\"callback_url\": \""$4"\",\"keep_alive_interval_seconds\": \""$3"\",\"service_id\": \""$2"\"}" + else + query="/service" + json="{\"callbackUrl\": \""$4"\",\"keepAliveIntervalSeconds\": \""$3"\",\"serviceName\": \""$2"\"}" + fi file="./tmp/.tmp.json" echo "$json" > $file @@ -1068,7 +1527,7 @@ api_put_service() { return 0 } -# API test function: GET /services +# API test function: GET /services and V2 GET /v2/services #args: [ ( ) | (NOSERVICE [ ]* )] # (Function for test scripts) api_get_services() { @@ -1095,12 +1554,19 @@ api_get_services() { return 1 fi - query="/services" + if [ "$PMS_VERSION" == "V2" ]; then + query="/v2/services" - if [ $# -gt 1 ] && [ $2 != "NOSERVICE" ]; then - query="/services?name="$2 - fi + if [ $# -gt 1 ] && [ $2 != "NOSERVICE" ]; then + query="/v2/services?service_id="$2 + fi + else + query="/services" + if [ $# -gt 1 ] && [ $2 != "NOSERVICE" ]; then + query="/services?name="$2 + fi + fi res="$(__do_curl_to_api PA GET $query)" status=${res:${#res}-3} @@ -1125,10 +1591,17 @@ api_get_services() { targetJson=$targetJson"," fi # timeSinceLastActivitySeconds value cannot be checked since value varies - targetJson=$targetJson"{\"serviceName\": \""$servicename"\",\"keepAliveIntervalSeconds\": "$timeout",\"timeSinceLastActivitySeconds\":\"????\",\"callbackUrl\": \""$callback"\"}" + if [ "$PMS_VERSION" == "V2" ]; then + targetJson=$targetJson"{\"service_id\": \""$servicename"\",\"keep_alive_interval_seconds\": "$timeout",\"time_since_last_activity_seconds\":\"????\",\"callback_url\": \""$callback"\"}" + else + targetJson=$targetJson"{\"serviceName\": \""$servicename"\",\"keepAliveIntervalSeconds\": "$timeout",\"timeSinceLastActivitySeconds\":\"????\",\"callbackUrl\": \""$callback"\"}" + fi let cntr=cntr+3 done targetJson=$targetJson"]" + if [ "$PMS_VERSION" == "V2" ]; then + targetJson="{\"service_list\": $targetJson }" + fi echo "TARGET JSON: $targetJson" >> $HTTPLOG res=$(python3 ../common/compare_json.py "$targetJson" "$body") if [ $res -ne 0 ]; then @@ -1144,7 +1617,7 @@ api_get_services() { return 0 } -# API test function: GET /services (only checking service names) +# API test function: GET /services V2 GET /v2/services - (only checking service names) # args: []*" # (Function for test scripts) api_get_service_ids() { @@ -1157,7 +1630,11 @@ api_get_service_ids() { return 1 fi - query="/services" + if [ "$PMS_VERSION" == "V2" ]; then + query="/v2/services" + else + query="/services" + fi res="$(__do_curl_to_api PA GET $query)" status=${res:${#res}-3} @@ -1174,10 +1651,17 @@ api_get_service_ids() { if [ "$targetJson" != "[" ]; then targetJson=$targetJson"," fi - targetJson=$targetJson"{\"callbackUrl\":\"????\",\"keepAliveIntervalSeconds\":\"????\",\"serviceName\":\""$rapp"\",\"timeSinceLastActivitySeconds\":\"????\"}" + if [ "$PMS_VERSION" == "V2" ]; then + targetJson=$targetJson"{\"callback_url\":\"????\",\"keep_alive_interval_seconds\":\"????\",\"service_id\":\""$rapp"\",\"time_since_last_activity_seconds\":\"????\"}" + else + targetJson=$targetJson"{\"callbackUrl\":\"????\",\"keepAliveIntervalSeconds\":\"????\",\"serviceName\":\""$rapp"\",\"timeSinceLastActivitySeconds\":\"????\"}" + fi done targetJson=$targetJson"]" + if [ "$PMS_VERSION" == "V2" ]; then + targetJson="{\"service_list\": $targetJson }" + fi echo "TARGET JSON: $targetJson" >> $HTTPLOG res=$(python3 ../common/compare_json.py "$targetJson" "$body") @@ -1193,7 +1677,7 @@ api_get_service_ids() { return 0 } -# API test function: DELETE /services +# API test function: DELETE /services and V2 DELETE /v2/services/{serviceId} # args: # (Function for test scripts) api_delete_services() { @@ -1205,8 +1689,11 @@ api_delete_services() { __print_err " " $@ return 1 fi - - query="/services?name="$2 + if [ "$PMS_VERSION" == "V2" ]; then + query="/v2/services/"$2 + else + query="/services?name="$2 + fi res="$(__do_curl_to_api PA DELETE $query)" status=${res:${#res}-3} @@ -1222,7 +1709,7 @@ api_delete_services() { return 0 } -# API test function: PUT /services/keepalive +# API test function: PUT /services/keepalive and V2 PUT /v2/services/{service_id}/keepalive # args: # (Function for test scripts) api_put_services_keepalive() { @@ -1234,8 +1721,12 @@ api_put_services_keepalive() { __print_err " " $@ return 1 fi + if [ "$PMS_VERSION" == "V2" ]; then + query="/v2/services/$2/keepalive" + else + query="/services/keepalive?name="$2 + fi - query="/services/keepalive?name="$2 res="$(__do_curl_to_api PA PUT $query)" status=${res:${#res}-3} diff --git a/test/common/count_json_elements.py b/test/common/count_json_elements.py index 936e3f8a..65e32c7e 100644 --- a/test/common/count_json_elements.py +++ b/test/common/count_json_elements.py @@ -20,16 +20,24 @@ import json import sys # Print the length of json array, -1 will be printed in any problem is encountered +# Assumes the top level json is an array. +# If not (and the number of keys on top level is 1) then assumes that key contains the array. +arr_len=-1 try: with open(sys.argv[1]) as json_file: jsonarray = json.load(json_file) - if isinstance(jsonarray, list): - print(len(jsonarray)) - else: - print(-1) + arr_len=len(jsonarray) + elif isinstance(jsonarray, dict) and len(jsonarray) == 1: + key=next(iter(jsonarray)) + jsonarray=jsonarray[key] + if isinstance(jsonarray, list): + arr_len = len(jsonarray) except Exception as e: - print(-1) + print(arr_len) + sys.exit() + +print(arr_len) sys.exit() \ No newline at end of file diff --git a/test/common/create_policies_process.py b/test/common/create_policies_process.py index 8d37678f..d1bfd6f4 100644 --- a/test/common/create_policies_process.py +++ b/test/common/create_policies_process.py @@ -31,21 +31,44 @@ from requests.packages import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) #arg responsecode baseurl ric_base num_rics uuid startid templatepath count pids pid_id +data_out="" +url_out="" try: - 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() + if len(sys.argv) < 11: + print("1Expected 11/14 args, got "+str(len(sys.argv)-1)) + print (sys.argv[1:]) + sys.exit() responsecode=int(sys.argv[1]) - baseurl=sys.argv[2] - ric_base=sys.argv[3] + baseurl=str(sys.argv[2]) + ric_base=str(sys.argv[3]) num_rics=int(sys.argv[4]) - uuid=sys.argv[5] + uuid=str(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 ("/v2/" in baseurl): + if len(sys.argv) != 15: + print("1Expected 14 args, got "+str(len(sys.argv)-1)+ ". Args: responsecode baseurl ric_base num_rics uuid startid service type transient notification-url templatepath count pids pid_id") + print (sys.argv[1:]) + sys.exit() + + serv=str(sys.argv[7]) + pt=str(sys.argv[8]) + trans=str(sys.argv[9]) + noti=str(sys.argv[10]) + templatepath=str(sys.argv[11]) + count=int(sys.argv[12]) + pids=int(sys.argv[13]) + pid_id=int(sys.argv[14]) + else: + 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") + print (sys.argv[1:]) + sys.exit() + + templatepath=str(sys.argv[7]) + count=int(sys.argv[8]) + pids=int(sys.argv[9]) + pid_id=int(sys.argv[10]) if uuid == "NOUUID": uuid="" @@ -61,18 +84,44 @@ try: payload=template.replace("XXX",str(i)) ric_id=(i%num_rics)+1 ric=ric_base+str(ric_id) - 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) + if ("/v2/" in baseurl): + url=baseurl + + data={} + data["ric_id"]=ric + data["policy_id"]=uuid+str(i) + data["service_id"]=serv + if (trans != "NOTRANSIENT"): + data["transient"]=trans + if (pt != "NOTYPE"): + data["policy_type_id"]=pt + else: + data["policy_type_id"]="" + if (noti != "NOURL"): + data["status_notification_uri"]=noti + data["policy_data"]=json.loads(payload) + + url_out=url + data_out=json.dumps(data) + resp=requests.put(url, data_out, headers=headers, verify=False, timeout=90) + else: + url=baseurl+"&id="+uuid+str(i)+"&ric="+str(ric) + url_out=url + data_out=json.dumps(json.loads(payload)) + resp=requests.put(url, data_out, headers=headers, verify=False, timeout=90) except Exception as e1: 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:"+uuid+str(i)+ ", expected response code: "+responsecode+", got: None") + print("1Put failed for id:"+uuid+str(i)+ ", expected response code: "+str(responsecode)+", got: None") sys.exit() if (resp.status_code != responsecode): - print("1Put failed for id:"+uuid+str(i)+ ", expected response code: "+responsecode+", got: "+str(resp.status_code)) + print("1Put failed for id:"+uuid+str(i)+ ", expected response code: "+str(responsecode)+", got: "+str(resp.status_code)) + print(url_out) + print(str(data_out)) sys.exit() print("0") @@ -80,4 +129,6 @@ try: except Exception as e: print("1"+str(e)) + traceback.print_exc() + print(str(data_out)) sys.exit() \ No newline at end of file diff --git a/test/common/create_rics_json.py b/test/common/create_rics_json.py index d6a095bc..b2ad5288 100644 --- a/test/common/create_rics_json.py +++ b/test/common/create_rics_json.py @@ -28,28 +28,41 @@ import re #To indicate that special STD zero length name type, use 'EMPTYTYPE'. Ex. ricsim_g1_1:kista_ricsim_g1_1,stockholm_ricsim_g1_1:EMPTYTYPE #Save in indicated file +#arg: try: file_name = sys.argv[1] - ric_string = sys.argv[2] + api_version=sys.argv[2] + ric_string = sys.argv[3] ric_string=ric_string.strip() ric_string = re.sub(' +',' ',ric_string) ric_arr=[] rics=ric_string.split(' ') + if (api_version == "V2"): + param_ric='ric_id' + param_me='managed_element_ids' + param_policy_type='policy_type_ids' + param_state='state' + else: + param_ric='ricName' + param_me='managedElementIds' + param_policy_type='policyTypes' + param_state='state' + for i in range(len(rics)): ricDict={} items=rics[i].split(':') - ricDict['ricName']=items[0] - ricDict['managedElementIds']=items[1].split(',') + ricDict[param_ric]=items[0] + ricDict[param_me]=items[1].split(',') if (items[2] == "EMPTYTYPE"): empty_arr=[] empty_arr.append("") - ricDict['policyTypes']=empty_arr + ricDict[param_policy_type]=empty_arr elif (items[2] == "NOTYPE"): empty_arr=[] - ricDict['policyTypes']=empty_arr + ricDict[param_policy_type]=empty_arr else: - ricDict['policyTypes']=items[2].split(',') - ricDict['state']=items[3] + ricDict[param_policy_type]=items[2].split(',') + ricDict[param_state]=items[3] ric_arr.append(ricDict) with open(file_name, 'w') as f: diff --git a/test/common/delete_policies_process.py b/test/common/delete_policies_process.py index e647118d..cf293c83 100644 --- a/test/common/delete_policies_process.py +++ b/test/common/delete_policies_process.py @@ -38,9 +38,9 @@ try: sys.exit() responsecode=int(sys.argv[1]) - baseurl=sys.argv[2] + baseurl=str(sys.argv[2]) num_rics=int(sys.argv[3]) - uuid=sys.argv[4] + uuid=str(sys.argv[4]) start=int(sys.argv[5]) count=int(sys.argv[6]) pids=int(sys.argv[7]) @@ -52,17 +52,20 @@ try: stop=count*num_rics+start for i in range(start,stop): if (i%pids == (pid_id-1)): - url=str(baseurl+"?id="+uuid+str(i)) + if ("/v2/policies/" in baseurl): + url=str(baseurl+uuid+str(i)) + else: + 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:"+uuid+str(i)+ ", "+str(e1) + " "+traceback.format_exc()) sys.exit() if (resp.status_code == None): - print("1Delete failed for id:"+uuid+str(i)+ ", expected response code: "+responsecode+", got: None") + print("1Delete failed for id:"+uuid+str(i)+ ", expected response code: "+str(responsecode)+", got: None") sys.exit() if (resp.status_code != responsecode): - print("1Delete failed for id:"+uuid+str(i)+ ", expected response code: "+responsecode+", got: "+str(resp.status_code)) + print("1Delete failed for id:"+uuid+str(i)+ ", expected response code: "+str(responsecode)+", got: "+str(resp.status_code)) sys.exit() print("0") @@ -70,4 +73,5 @@ try: except Exception as e: print("1"+str(e)) + traceback.print_exc() sys.exit() \ No newline at end of file diff --git a/test/common/ecs_api_functions.sh b/test/common/ecs_api_functions.sh index dfa6e4b8..b76d43b7 100644 --- a/test/common/ecs_api_functions.sh +++ b/test/common/ecs_api_functions.sh @@ -34,23 +34,44 @@ # API Test function: GET /A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs # args: |NOOWNER [ EMPTY | + ] +# args (flat uri structure): |NOTYPE |NOOWNER [ EMPTY | + ] # (Function for test scripts) ecs_api_a1_get_job_ids() { echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG ((RES_TEST++)) - # Valid number of parameters 3,4,5,6 etc - if [ $# -lt 1 ]; then - __print_err " |NOOWNER [ EMPTY | + ]" $@ - return 1 + if [ -z "$FLAT_A1_EI" ]; then + # Valid number of parameters 4,5,6 etc + if [ $# -lt 3 ]; then + __print_err " |NOOWNER [ EMPTY | + ]" $@ + return 1 + fi + else + echo -e $YELLOW"USING NOT CONFIRMED INTERFACE - FLAT URI STRUCTURE"$EYELLOW + # Valid number of parameters 4,5,6 etc + if [ $# -lt 3 ]; then + __print_err " |NOTYPE |NOOWNER [ EMPTY | + ]" $@ + return 1 + fi fi - owner="" + search="" if [ $3 != "NOWNER" ]; then - owner="?owner="$3 + search="?owner="$3 fi - query="/A1-EI/v1/eitypes/$2/eijobs$owner" + if [ -z "$FLAT_A1_EI" ]; then + query="/A1-EI/v1/eitypes/$2/eijobs$search" + else + if [ $2 != "NOTYPE" ]; then + if [ -z "$search" ]; then + search="?eiTypeId="$2 + else + search=$search"&eiTypeId="$2 + fi + fi + query="/A1-EI/v1/eijobs$search" + fi res="$(__do_curl_to_api ECS GET $query)" status=${res:${#res}-3} @@ -125,7 +146,11 @@ ecs_api_a1_get_type() { __check_stop_at_error return 1 fi - targetJson="{\"eiJobParametersSchema\":$schema}" + if [ -z "$FLAT_A1_EI" ]; then + targetJson="{\"eiJobParametersSchema\":$schema}" + else + targetJson=$schema + fi echo " TARGET JSON: $targetJson" >> $HTTPLOG res=$(python3 ../common/compare_json.py "$targetJson" "$body") @@ -137,7 +162,6 @@ ecs_api_a1_get_type() { fi fi - ((RES_PASS++)) echo -e $GREEN" PASS"$EGREEN return 0 @@ -196,39 +220,74 @@ ecs_api_a1_get_type_ids() { # API Test function: GET ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}​/status # args: [] +# args (flat uri structure): [] # (Function for test scripts) ecs_api_a1_get_job_status() { echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG ((RES_TEST++)) - if [ $# -ne 3 ] && [ $# -ne 4 ]; then - __print_err " " $@ - return 1 - fi + if [ -z "$FLAT_A1_EI" ]; then + if [ $# -ne 3 ] && [ $# -ne 4 ]; then + __print_err " []" $@ + return 1 + fi - query="/A1-EI/v1/eitypes/$2/eijobs/$3/status" - res="$(__do_curl_to_api ECS GET $query)" - status=${res:${#res}-3} + query="/A1-EI/v1/eitypes/$2/eijobs/$3/status" - if [ $status -ne $1 ]; then - echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED - ((RES_FAIL++)) - __check_stop_at_error - return 1 - fi - if [ $# -eq 4 ]; then - body=${res:0:${#res}-3} - targetJson="{\"operationalState\": \"$4\"}" - echo " TARGET JSON: $targetJson" >> $HTTPLOG - res=$(python3 ../common/compare_json.py "$targetJson" "$body") + res="$(__do_curl_to_api ECS GET $query)" + status=${res:${#res}-3} - if [ $res -ne 0 ]; then - echo -e $RED" FAIL, returned body not correct"$ERED + if [ $status -ne $1 ]; then + echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED ((RES_FAIL++)) __check_stop_at_error return 1 fi + if [ $# -eq 4 ]; then + body=${res:0:${#res}-3} + targetJson="{\"operationalState\": \"$4\"}" + echo " TARGET JSON: $targetJson" >> $HTTPLOG + res=$(python3 ../common/compare_json.py "$targetJson" "$body") + + if [ $res -ne 0 ]; then + echo -e $RED" FAIL, returned body not correct"$ERED + ((RES_FAIL++)) + __check_stop_at_error + return 1 + fi + fi + else + echo -e $YELLOW"USING NOT CONFIRMED INTERFACE - FLAT URI STRUCTURE"$EYELLOW + if [ $# -ne 2 ] && [ $# -ne 3 ]; then + __print_err " []" $@ + return 1 + fi + + query="/A1-EI/v1/eijobs/$2/status" + + res="$(__do_curl_to_api ECS GET $query)" + status=${res:${#res}-3} + + if [ $status -ne $1 ]; then + echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED + ((RES_FAIL++)) + __check_stop_at_error + return 1 + fi + if [ $# -eq 3 ]; then + body=${res:0:${#res}-3} + targetJson="{\"eiJobStatus\": \"$3\"}" + echo " TARGET JSON: $targetJson" >> $HTTPLOG + res=$(python3 ../common/compare_json.py "$targetJson" "$body") + + if [ $res -ne 0 ]; then + echo -e $RED" FAIL, returned body not correct"$ERED + ((RES_FAIL++)) + __check_stop_at_error + return 1 + fi + fi fi ((RES_PASS++)) @@ -238,18 +297,27 @@ ecs_api_a1_get_job_status() { # API Test function: GET ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId} # args: [ ] +# args (flat uri structure): [ ] # (Function for test scripts) ecs_api_a1_get_job() { echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG ((RES_TEST++)) - if [ $# -ne 3 ] && [ $# -ne 6 ]; then - __print_err " [ ]" $@ - return 1 + if [ -z "$FLAT_A1_EI" ]; then + if [ $# -ne 3 ] && [ $# -ne 6 ]; then + __print_err " [ ]" $@ + return 1 + fi + query="/A1-EI/v1/eitypes/$2/eijobs/$3" + else + echo -e $YELLOW"USING NOT CONFIRMED INTERFACE - FLAT URI STRUCTURE"$EYELLOW + if [ $# -ne 2 ] && [ $# -ne 7 ]; then + __print_err " [ ]" $@ + return 1 + fi + query="/A1-EI/v1/eijobs/$2" fi - - query="/A1-EI/v1/eitypes/$2/eijobs/$3" res="$(__do_curl_to_api ECS GET $query)" status=${res:${#res}-3} @@ -260,27 +328,53 @@ ecs_api_a1_get_job() { return 1 fi - if [ $# -eq 6 ]; then - body=${res:0:${#res}-3} + if [ -z "$FLAT_A1_EI" ]; then + if [ $# -eq 6 ]; then + body=${res:0:${#res}-3} - if [ -f $6 ]; then - jobfile=$(cat $6) - jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g") - else - echo -e $RED" FAIL. Job template file "$6", does not exist"$ERED - ((RES_FAIL++)) - __check_stop_at_error - return 1 + if [ -f $6 ]; then + jobfile=$(cat $6) + jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g") + else + echo -e $RED" FAIL. Job template file "$6", does not exist"$ERED + ((RES_FAIL++)) + __check_stop_at_error + return 1 + fi + targetJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}" + echo " TARGET JSON: $targetJson" >> $HTTPLOG + res=$(python3 ../common/compare_json.py "$targetJson" "$body") + + if [ $res -ne 0 ]; then + echo -e $RED" FAIL, returned body not correct"$ERED + ((RES_FAIL++)) + __check_stop_at_error + return 1 + fi fi - targetJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}" - echo " TARGET JSON: $targetJson" >> $HTTPLOG - res=$(python3 ../common/compare_json.py "$targetJson" "$body") + else + if [ $# -eq 7 ]; then + body=${res:0:${#res}-3} - if [ $res -ne 0 ]; then - echo -e $RED" FAIL, returned body not correct"$ERED - ((RES_FAIL++)) - __check_stop_at_error - return 1 + if [ -f $7 ]; then + jobfile=$(cat $7) + jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g") + else + echo -e $RED" FAIL. Job template file "$6", does not exist"$ERED + ((RES_FAIL++)) + __check_stop_at_error + return 1 + fi + targetJson="{\"eiTypeId\": \"$3\", \"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobStatusNotificationUri\": \"$6\",\"jobDefinition\": $jobfile}" + echo " TARGET JSON: $targetJson" >> $HTTPLOG + res=$(python3 ../common/compare_json.py "$targetJson" "$body") + + if [ $res -ne 0 ]; then + echo -e $RED" FAIL, returned body not correct"$ERED + ((RES_FAIL++)) + __check_stop_at_error + return 1 + fi fi fi @@ -291,18 +385,28 @@ ecs_api_a1_get_job() { # API Test function: DELETE ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId} # args: +# args (flat uri structure): # (Function for test scripts) ecs_api_a1_delete_job() { echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG ((RES_TEST++)) - if [ $# -lt 3 ]; then - __print_err " " $@ - return 1 - fi + if [ -z "$FLAT_A1_EI" ]; then + if [ $# -ne 3 ]; then + __print_err " " $@ + return 1 + fi - query="/A1-EI/v1/eitypes/$2/eijobs/$3" + query="/A1-EI/v1/eitypes/$2/eijobs/$3" + else + echo -e $YELLOW"USING NOT CONFIRMED INTERFACE - FLAT URI STRUCTURE"$EYELLOW + if [ $# -ne 2 ]; then + __print_err " " $@ + return 1 + fi + query="/A1-EI/v1/eijobs/$2" + fi res="$(__do_curl_to_api ECS DELETE $query)" status=${res:${#res}-3} @@ -320,31 +424,56 @@ ecs_api_a1_delete_job() { # API Test function: PUT ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId} # args: +# args (flat uri structure): # (Function for test scripts) ecs_api_a1_put_job() { echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG ((RES_TEST++)) - if [ $# -lt 6 ]; then - __print_err " " $@ - return 1 - fi - if [ -f $6 ]; then - jobfile=$(cat $6) - jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g") + if [ -z "$FLAT_A1_EI" ]; then + if [ $# -lt 6 ]; then + __print_err " " $@ + return 1 + fi + if [ -f $6 ]; then + jobfile=$(cat $6) + jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g") + else + echo -e $RED" FAIL. Job template file "$6", does not exist"$ERED + ((RES_FAIL++)) + __check_stop_at_error + return 1 + fi + + inputJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}" + file="./tmp/.p.json" + echo "$inputJson" > $file + + query="/A1-EI/v1/eitypes/$2/eijobs/$3" else - echo -e $RED" FAIL. Job template file "$6", does not exist"$ERED - ((RES_FAIL++)) - __check_stop_at_error - return 1 - fi + echo -e $YELLOW"USING NOT CONFIRMED INTERFACE - FLAT URI STRUCTURE"$EYELLOW + if [ $# -lt 7 ]; then + __print_err " " $@ + return 1 + fi + if [ -f $7 ]; then + jobfile=$(cat $7) + jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g") + else + echo -e $RED" FAIL. Job template file "$7", does not exist"$ERED + ((RES_FAIL++)) + __check_stop_at_error + return 1 + fi - inputJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}" - file="./tmp/.p.json" - echo "$inputJson" > $file + inputJson="{\"eiTypeId\": \"$3\", \"jobResultUri\": \"$4\",\"jobOwner\": \"$5\",\"jobStatusNotificationUri\": \"$6\",\"jobDefinition\": $jobfile}" + file="./tmp/.p.json" + echo "$inputJson" > $file + + query="/A1-EI/v1/eijobs/$2" + fi - query="/A1-EI/v1/eitypes/$2/eijobs/$3" res="$(__do_curl_to_api ECS PUT $query $file)" status=${res:${#res}-3} diff --git a/test/common/test_env-onap-guilin.sh b/test/common/test_env-onap-guilin.sh index e7a90303..f92bf799 100644 --- a/test/common/test_env-onap-guilin.sh +++ b/test/common/test_env-onap-guilin.sh @@ -79,6 +79,7 @@ export POLICY_AGENT_EXTERNAL_PORT=8081 # Policy Agent c export POLICY_AGENT_INTERNAL_PORT=8081 # Policy Agent container internal port (container -> container) export POLICY_AGENT_EXTERNAL_SECURE_PORT=8433 # Policy Agent container external secure port (host -> container) export POLICY_AGENT_INTERNAL_SECURE_PORT=8433 # Policy Agent container internal secure port (container -> container) +export POLICY_AGENT_APIS="V1" # Supported northbound api versions export POLICY_AGENT_APP_NAME="policy-agent" # Name for Policy Agent container POLICY_AGENT_LOGPATH="/var/log/policy-agent/application.log" # Path the application log in the Policy Agent container diff --git a/test/common/test_env-onap-master.sh b/test/common/test_env-onap-master.sh index 7ecd687a..da6906dc 100644 --- a/test/common/test_env-onap-master.sh +++ b/test/common/test_env-onap-master.sh @@ -60,7 +60,7 @@ RIC_SIM_LOCAL_IMAGE="o-ran-sc/a1-simulator" RIC_SIM_LOCAL_IMAGE_TAG="latest" # Near RT RIC Simulator remote image and tag RIC_SIM_REMOTE_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/a1-simulator" -RIC_SIM_REMOTE_IMAGE_TAG="2.0.0" +RIC_SIM_REMOTE_IMAGE_TAG="2.1.0" #Consul remote image and tag @@ -97,6 +97,8 @@ export POLICY_AGENT_EXTERNAL_PORT=8081 # Policy Agent c export POLICY_AGENT_INTERNAL_PORT=8081 # Policy Agent container internal port (container -> container) export POLICY_AGENT_EXTERNAL_SECURE_PORT=8433 # Policy Agent container external secure port (host -> container) export POLICY_AGENT_INTERNAL_SECURE_PORT=8433 # Policy Agent container internal secure port (container -> container) +export POLICY_AGENT_APIS="V1 V2" # Supported northbound api versions +export PMS_VERSION="V2" export POLICY_AGENT_APP_NAME="policy-agent" # Name for Policy Agent container POLICY_AGENT_LOGPATH="/var/log/policy-agent/application.log" # Path the application log in the Policy Agent container diff --git a/test/common/test_env-oran-master.sh b/test/common/test_env-oran-master.sh index b24ecae0..7b8e8f8c 100755 --- a/test/common/test_env-oran-master.sh +++ b/test/common/test_env-oran-master.sh @@ -101,6 +101,7 @@ export POLICY_AGENT_EXTERNAL_PORT=8081 # Policy Agent c export POLICY_AGENT_INTERNAL_PORT=8081 # Policy Agent container internal port (container -> container) export POLICY_AGENT_EXTERNAL_SECURE_PORT=8433 # Policy Agent container external secure port (host -> container) export POLICY_AGENT_INTERNAL_SECURE_PORT=8433 # Policy Agent container internal secure port (container -> container) +export POLICY_AGENT_APIS="V1" # Supported northbound api versions export POLICY_AGENT_APP_NAME="policy-agent" # Name for Policy Agent container POLICY_AGENT_LOGPATH="/var/log/policy-agent/application.log" # Path the application log in the Policy Agent container diff --git a/test/common/testcase_common.sh b/test/common/testcase_common.sh index f8ff19f7..ea940a18 100755 --- a/test/common/testcase_common.sh +++ b/test/common/testcase_common.sh @@ -269,9 +269,13 @@ fi G1_A1_VERSION="" G2_A1_VERSION="" G3_A1_VERSION="" +G4_A1_VERSION="" +G5_A1_VERSION="" G1_COUNT=0 G2_COUNT=0 G3_COUNT=0 +G4_COUNT=0 +G5_COUNT=0 # Vars to switch between http and https. Extra curl flag needed for https export RIC_SIM_HTTPX="http" @@ -1457,9 +1461,9 @@ use_simulator_https() { echo "" } -# Start one group (ricsim_g1, ricsim_g2 or ricsim_g3) with a number of RIC Simulators using a given A interface +# Start one group (ricsim_g1, ricsim_g2 .. ricsim_g5) 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 +# args: ricsim_g1|ricsim_g2|ricsim_g3|ricsim_g4|ricsim_g5 # (Function for test scripts) start_ric_simulators() { @@ -1475,10 +1479,12 @@ start_ric_simulators() { RIC1=$RIC_SIM_PREFIX"_g1" RIC2=$RIC_SIM_PREFIX"_g2" RIC3=$RIC_SIM_PREFIX"_g3" + RIC4=$RIC_SIM_PREFIX"_g4" + RIC5=$RIC_SIM_PREFIX"_g5" if [ $# != 3 ]; then ((RES_CONF_FAIL++)) - __print_err "need three args, $RIC1|$RIC2|$RIC3 " $@ + __print_err "need three args, $RIC1|$RIC2|$RIC3|$RIC4|$RIC5 " $@ exit 1 fi echo " $2 simulators using basename: $1 on interface: $3" @@ -1492,9 +1498,15 @@ start_ric_simulators() { elif [ $1 == "$RIC3" ]; then G3_COUNT=$2 G3_A1_VERSION=$3 + elif [ $1 == "$RIC4" ]; then + G4_COUNT=$2 + G4_A1_VERSION=$3 + elif [ $1 == "$RIC5" ]; then + G5_COUNT=$2 + G5_A1_VERSION=$3 else ((RES_CONF_FAIL++)) - __print_err "need three args, $RIC1|$RIC2|$RIC3 " $@ + __print_err "need three args, $RIC1|$RIC2|$RIC3|$RIC4|$RIC5 " $@ exit 1 fi @@ -1504,8 +1516,10 @@ start_ric_simulators() { export G1_A1_VERSION export G2_A1_VERSION export G3_A1_VERSION + export G4_A1_VERSION + export G5_A1_VERSION - docker_args="--scale g1=$G1_COUNT --scale g2=$G2_COUNT --scale g3=$G3_COUNT" + docker_args="--scale g1=$G1_COUNT --scale g2=$G2_COUNT --scale g3=$G3_COUNT --scale g4=$G4_COUNT --scale g5=$G5_COUNT" app_data="" cntr=1 while [ $cntr -le $2 ]; do diff --git a/test/prodstub/app/prodstub.py b/test/prodstub/app/prodstub.py index df4898dd..7323d3a4 100644 --- a/test/prodstub/app/prodstub.py +++ b/test/prodstub/app/prodstub.py @@ -537,7 +537,7 @@ def datadelivery() : data["job"]=""+key data["sequence_no"]=""+str(job['delivery_attempts']) data["value"]=str(100) - print("Sending "+json.dumps(data)) + print("Sending to "+url+" payload:"+json.dumps(data)) requests.post(url, json=data, verify=False, timeout=2) #NOSONAR job['delivery_attempts'] += 1