From b0ed782cb2d684e80fe27004869750e58f166d48 Mon Sep 17 00:00:00 2001 From: Yann Garcia Date: Thu, 18 Jun 2020 16:10:19 +0200 Subject: [PATCH] Big fixed on MEC-011 Codec --- .../AtsMec_AppEnablementAPI_TestCases.ttcn | 248 +++++++++++++++--- ttcn/LibIts | 2 +- .../AppEna/ttcn/AppEnablementAPI_Pixits.ttcn | 8 +- .../ttcn/AppEnablementAPI_Templates.ttcn | 10 +- .../ttcn/AppEnablementAPI_TypesAndValues.ttcn | 24 +- 5 files changed, 239 insertions(+), 53 deletions(-) diff --git a/ttcn/AtsMec/AtsMec_AppEnablementAPI_TestCases.ttcn b/ttcn/AtsMec/AtsMec_AppEnablementAPI_TestCases.ttcn index 40ecc70..5627311 100644 --- a/ttcn/AtsMec/AtsMec_AppEnablementAPI_TestCases.ttcn +++ b/ttcn/AtsMec/AtsMec_AppEnablementAPI_TestCases.ttcn @@ -23,6 +23,7 @@ module AtsMec_AppEnablementAPI_TestCases { import from LibItsHttp_TestSystem all; // LibMec/AppEnablementAPI + import from AppEnablementAPI_TypesAndValues all; import from AppEnablementAPI_Templates all; import from AppEnablementAPI_Pics all; import from AppEnablementAPI_Pixits all; @@ -158,6 +159,7 @@ module AtsMec_AppEnablementAPI_TestCases { // Local variables var Headers v_headers; var HttpMessage v_response; + var universal charstring v_service_name; // Test control if (not(PICS_MEC_PLAT) or not (PICS_SERVICES) or not (PICS_NOTIFICATIONS) or not(PICS_APP_ENABLEMENT_API_SUPPORTED)) { @@ -173,16 +175,17 @@ module AtsMec_AppEnablementAPI_TestCases { // Preamble f_init_default_headers_list(-, -, v_headers); + v_service_name := oct2unichar(char2oct("service_" & int2str(f_get_current_timestamp_utc()))); httpPort.send( m_http_request( m_http_request_post( - "/" & PICS_ROOT_API & PX_MEC_SVC_MGMT_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services", + "/" & PICS_ROOT_API & PX_MEC_SVC_MGMT_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services", v_headers, m_http_message_body_json( m_body_json_service_info( m_service_info( - PX_SERVICE_NAME, - -, -, -, -, -, + v_service_name, + -, -, -, -, -, //-, m_transport_info( "transportId1", "TC_MEC_SRV_APPSAQ_002_OK", @@ -209,7 +212,7 @@ module AtsMec_AppEnablementAPI_TestCases { mw_http_message_body_json( mw_body_json_service_info( mw_service_info( - PX_SERVICE_NAME //serName + v_service_name //serName )))))) -> value v_response { tc_ac.stop; @@ -254,6 +257,7 @@ module AtsMec_AppEnablementAPI_TestCases { testcase TC_MEC_SRV_APPSAQ_002_BR() runs on HttpComponent system HttpTestAdapter { // Local variables var Headers v_headers; + var universal charstring v_service_name; // Test control if (not(PICS_MEC_PLAT) or not (PICS_SERVICES) or not(PICS_APP_ENABLEMENT_API_SUPPORTED)) { @@ -269,7 +273,7 @@ module AtsMec_AppEnablementAPI_TestCases { // Preamble f_init_default_headers_list(-, -, v_headers); - + v_service_name := oct2unichar(char2oct("service_" & int2str(f_get_current_timestamp_utc()))); httpPort.send( m_http_request( m_http_request_post( @@ -278,7 +282,10 @@ module AtsMec_AppEnablementAPI_TestCases { m_http_message_body_json( m_body_json_service_info( m_service_info( - PX_NON_EXISTENT_SERVICE_NAME + v_service_name, + -, + UNKNOWN, + RAW ) ) ) @@ -411,7 +418,7 @@ module AtsMec_AppEnablementAPI_TestCases { mw_http_message_body_json( mw_body_json_service_info( mw_service_info( - -, -, -, -, + -, -, -, -, //-, PX_SERVICE_ID )))))) { tc_ac.stop; @@ -483,13 +490,121 @@ module AtsMec_AppEnablementAPI_TestCases { f_cf_01_http_down(); } // End of testcase TC_MEC_SRV_APPSAQ_003_NF + group f_TC_MEC_SRV_APPSAQ_004 { + + /** + * @desc This function request the createion of a new service + * @param p_service_name Indicates the name of the new serivce + * @return 0 on success, -1 otherwise + */ + function f_create_service( + out universal charstring p_service_name, + out ServiceInfo p_service_info + ) runs on HttpComponent return integer { + var universal charstring v_service_name; + var Headers v_headers; + var integer v_result := -1; + var HttpMessage v_response; + + f_init_default_headers_list(-, -, v_headers); + v_service_name := oct2unichar(char2oct("service_" & int2str(f_get_current_timestamp_utc()))); + httpPort.send( + m_http_request( + m_http_request_post( + "/" & PICS_ROOT_API & PX_MEC_SVC_MGMT_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services", + v_headers, + m_http_message_body_json( + m_body_json_service_info( + m_service_info( + v_service_name, + -, -, -, -, -, //-, + m_transport_info( + "transportId1", + "TC_MEC_SRV_APPSAQ_002_OK", + REST_HTTP, + "HTTP", + "2.0", + m_end_point_uris({"/meMp1/service/MyEntryPoint"}), + m_security_info + ) + ) + ) + ) + ) + ) + ); + tc_ac.start; + alt { + [] httpPort.receive( + mw_http_response( + mw_http_response_201_created( + mw_http_message_body_json( + mw_body_json_service_info( + mw_service_info( + v_service_name //serName + )))))) -> value v_response { + tc_ac.stop; + p_service_name := v_service_name; + p_service_info := v_response.response.body.json_body.serviceInfo; + v_result := 0; + } + [] tc_ac.timeout { + log("*** " & testcasename() & ": INCONC: Expected message not received ***"); + } + } // End of 'alt' statement + + return v_result; + } // End of function f_create_service_info + + /** + * @desc This function request the deletion of a service + * @param p_service_name Indicates the name of the serivce to delete + * @return 0 on success, -1 otherwise + */ + function f_delete_service( + in universal charstring p_service_name + ) runs on HttpComponent return integer { + var Headers v_headers; + var integer v_result := -1; + + f_init_default_headers_list(-, -, v_headers); + httpPort.send( + m_http_request( + m_http_request_delete( + "/" & PICS_ROOT_API & PX_MEC_SVC_MGMT_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services/" & oct2char(unichar2oct(p_service_name)), + v_headers + ) + ) + ); + tc_ac.start; + alt { + [] httpPort.receive( + mw_http_response( + mw_http_response_204_no_content + )) { + tc_ac.stop; + v_result := 0; + } + [] tc_ac.timeout { + log("*** " & testcasename() & ": INCONC: Expected message not received ***"); + } + } // End of 'alt' statement + + return v_result; + } // End of function f_delete_service_info + + } // End of group f_TC_MEC_SRV_APPSAQ_004 + /** * @desc Check that the IUT updates a service information for a given application instance when commanded by a MEC Application * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/APPSAQ/PlatAppServices.tplan2 */ + testcase TC_MEC_SRV_APPSAQ_004_OK() runs on HttpComponent system HttpTestAdapter { // Local variables var Headers v_headers; + var universal charstring v_service_name; + var ServiceInfo v_service_info; // Test control if (not(PICS_MEC_PLAT) or not(PICS_SERVICES) or not(PICS_APP_ENABLEMENT_API_SUPPORTED)) { @@ -504,22 +619,29 @@ module AtsMec_AppEnablementAPI_TestCases { // Test adapter configuration // Preamble + if(f_create_service(v_service_name, v_service_info) == -1) { + log("*** " & testcasename() & ": INCONC: Expected message not received ***"); + f_selfOrClientSyncAndVerdict(c_prDone, e_timeout); + } + log("*** " & testcasename() & ": INFO: New servie created: ", v_service_name, ", transportID=", v_service_info.transportInfo.id); // TODO If-Match header needs to have a PROPER_ETAG f_init_default_headers_list(-, -, v_headers); httpPort.send( m_http_request( m_http_request_put( - "/" & PICS_ROOT_API & PX_MEC_SVC_MGMT_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services/" & oct2char(unichar2oct(PX_SERVICE_ID, "UTF-8")), - v_headers, - m_http_message_body_json( - m_body_json_service_info( - m_service_info( - PX_SERVICE_NAME, - PX_NEW_SERVICE_INFO_VERSION - ) - ) - ) - ) + "/" & PICS_ROOT_API & PX_MEC_SVC_MGMT_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services/" & oct2char(unichar2oct(v_service_name, "UTF-8")), + v_headers, + m_http_message_body_json( + m_body_json_service_info( + m_service_info( + v_service_name, + PX_NEW_SERVICE_INFO_VERSION, + -, -, -, -, + v_service_info.transportInfo + ) + ) + ) + ) ) ); f_selfOrClientSyncAndVerdict(c_prDone, e_success); @@ -533,7 +655,7 @@ module AtsMec_AppEnablementAPI_TestCases { mw_http_message_body_json( mw_body_json_service_info( mw_service_info( - PX_SERVICE_NAME, + v_service_name, PX_NEW_SERVICE_INFO_VERSION )))))) { tc_ac.stop; @@ -548,6 +670,7 @@ module AtsMec_AppEnablementAPI_TestCases { } // End of 'alt' statement // Postamble + // TODO Delete service created f_cf_01_http_down(); } // End of testcase TC_MEC_SRV_APPSAQ_004_OK @@ -558,6 +681,8 @@ module AtsMec_AppEnablementAPI_TestCases { testcase TC_MEC_SRV_APPSAQ_004_BR() runs on HttpComponent system HttpTestAdapter { // Local variables var Headers v_headers; + var universal charstring v_service_name := ""; + var ServiceInfo v_service_info; // Test control if (not(PICS_MEC_PLAT) or not (PICS_SERVICES) or not(PICS_APP_ENABLEMENT_API_SUPPORTED)) { @@ -572,19 +697,24 @@ module AtsMec_AppEnablementAPI_TestCases { // Test adapter configuration // Preamble + if(f_create_service(v_service_name, v_service_info) == -1) { + log("*** " & testcasename() & ": INCONC: Expected message not received ***"); + f_selfOrClientSyncAndVerdict(c_prDone, e_timeout); + } + log("*** " & testcasename() & ": INFO: New servie created: ", v_service_name, ", transportID=", v_service_info.transportInfo.id); // TODO If-Match header needs to have a PROPER_ETAG f_init_default_headers_list(-, -, v_headers); httpPort.send( m_http_request( m_http_request_put( - "/" & PICS_ROOT_API & PX_MEC_SVC_MGMT_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services/" & oct2char(unichar2oct(PX_SERVICE_ID, "UTF-8")), + "/" & PICS_ROOT_API & PX_MEC_SVC_MGMT_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services/" & oct2char(unichar2oct(v_service_name, "UTF-8")), v_headers, m_http_message_body_json( m_body_json_service_info( m_service_info( - PX_SERVICE_NAME, - PX_NEW_SERVICE_INFO_VERSION // TODO the parameter name should be an invalid one to trigger the error. How to do it? + v_service_name & char(0, 0, 1, 111), + PX_NEW_SERVICE_INFO_VERSION ) ) ) @@ -685,6 +815,8 @@ module AtsMec_AppEnablementAPI_TestCases { testcase TC_MEC_SRV_APPSAQ_004_PF() runs on HttpComponent system HttpTestAdapter { // Local variables var Headers v_headers; + var universal charstring v_service_name; + var ServiceInfo v_service_info; // Test control if (not(PICS_MEC_PLAT) or not(PICS_SERVICES) or not(PICS_APP_ENABLEMENT_API_SUPPORTED)) { @@ -699,22 +831,30 @@ module AtsMec_AppEnablementAPI_TestCases { // Test adapter configuration // Preamble + if(f_create_service(v_service_name, v_service_info) == -1) { + log("*** " & testcasename() & ": INCONC: Expected message not received ***"); + f_selfOrClientSyncAndVerdict(c_prDone, e_timeout); + } + log("*** " & testcasename() & ": INFO: New servie created: ", v_service_name, ", transportID=", v_service_info.transportInfo.id); // TODO If-Match header needs to have an INVALID_ETAG f_init_default_headers_list(-, -, v_headers); + f_set_headers_list({ "ETag" }, { int2str(f_get_current_timestamp_utc()) }, v_headers); httpPort.send( m_http_request( m_http_request_put( - "/" & PICS_ROOT_API & PX_MEC_SVC_MGMT_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services/" & oct2char(unichar2oct(PX_SERVICE_ID, "UTF-8")), - v_headers, - m_http_message_body_json( - m_body_json_service_info( - m_service_info( - PX_SERVICE_NAME, - PX_NEW_SERVICE_INFO_VERSION - ) - ) - ) - ) + "/" & PICS_ROOT_API & PX_MEC_SVC_MGMT_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services/" & oct2char(unichar2oct(v_service_name, "UTF-8")), + v_headers, + m_http_message_body_json( + m_body_json_service_info( + m_service_info( + v_service_name, + PX_NEW_SERVICE_INFO_VERSION, + -, -, -, -, + v_service_info.transportInfo + ) + ) + ) + ) ) ); f_selfOrClientSyncAndVerdict(c_prDone, e_success); @@ -867,6 +1007,8 @@ module AtsMec_AppEnablementAPI_TestCases { // Local variables var Headers v_headers; var HttpMessage v_response; + var universal charstring v_service_name; + var ServiceInfo v_service_info; // Test control if (not(PICS_MEC_PLAT) or not (PICS_SERVICES) or not(PICS_APP_ENABLEMENT_API_SUPPORTED)) { @@ -882,20 +1024,40 @@ module AtsMec_AppEnablementAPI_TestCases { // Preamble f_init_default_headers_list(-, -, v_headers); + f_create_service(v_service_name, v_service_info); + //v_service_name := oct2unichar(char2oct("service_" & int2str(f_get_current_timestamp_utc()))); httpPort.send( m_http_request( m_http_request_post( "/" & PICS_ROOT_API & PX_ME_APP_SUPPORT_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/subscriptions", v_headers, m_http_message_body_json( - m_body_json_app_termination_notif_subscription( - m_app_termination_notif_subscription( + m_body_json_srv_avail_notif_subscription/*m_body_json_app_termination_notif_subscription*/( + m_srv_avail_notif_subscription( + PX_APP_TERM_NOTIF_CALLBACK_URI, + m_self( + { href := PX_HREF } + ), + m_service_info( + v_service_name, + -, -, -, -, -, //-, + m_transport_info( + "transportId1", + "TC_MEC_SRV_APPSUB_002_OK", + REST_HTTP, + "HTTP", + "2.0", + m_end_point_uris({"/meMp1/service/MyEntryPoint"}), + m_security_info + ) + ) ) + /*m_app_termination_notif_subscription( PX_APP_TERM_NOTIF_CALLBACK_URI, m_self( { href := PX_HREF } ), PX_APP_INSTANCE_ID - ) + )*/ ) ) ) @@ -909,11 +1071,11 @@ module AtsMec_AppEnablementAPI_TestCases { [] httpPort.receive( mw_http_response( mw_http_response_201_created( - mw_http_message_body_json( - mw_body_json_app_termination_notif_subscription( - mw_app_termination_notif_subscription( - PX_APP_TERM_NOTIF_CALLBACK_URI - )))))) -> value v_response { + mw_http_message_body_json( + mw_body_json_app_termination_notif_subscription( + mw_app_termination_notif_subscription( + PX_APP_TERM_NOTIF_CALLBACK_URI + )))))) -> value v_response { tc_ac.stop; if (f_check_headers(valueof(v_response.response.header)) == true) { @@ -1745,7 +1907,7 @@ module AtsMec_AppEnablementAPI_TestCases { httpPort.send( m_http_request( m_http_request_get( - "/" & PICS_ROOT_API & PX_MEC_SVC_MGMT_SVC_URI, + "/" & PICS_ROOT_API & PX_MEC_SVC_MGMT_SVC_URI & "?instance_id=" & oct2char(unichar2oct(PX_NON_EXISTENT_APP_INSTANCE_ID, "UTF-8")), v_headers ) ) @@ -1799,7 +1961,7 @@ module AtsMec_AppEnablementAPI_TestCases { httpPort.send( m_http_request( m_http_request_get( - "/" & PICS_ROOT_API & PX_MEC_SVC_MGMT_SVC_URI & oct2char(unichar2oct(PX_SERVICE_ID, "UTF-8")), + "/" & PICS_ROOT_API & PX_MEC_SVC_MGMT_SVC_URI & "/" & oct2char(unichar2oct(PX_SERVICE_ID, "UTF-8")), v_headers ) ) diff --git a/ttcn/LibIts b/ttcn/LibIts index 05da1c7..a305e3b 160000 --- a/ttcn/LibIts +++ b/ttcn/LibIts @@ -1 +1 @@ -Subproject commit 05da1c7eb2266da50cbee511c01fb59623187412 +Subproject commit a305e3b07ed8b0955a28f25bd3fd0346f97562a8 diff --git a/ttcn/LibMec/AppEna/ttcn/AppEnablementAPI_Pixits.ttcn b/ttcn/LibMec/AppEna/ttcn/AppEnablementAPI_Pixits.ttcn index 65796d0..ead6a81 100644 --- a/ttcn/LibMec/AppEna/ttcn/AppEnablementAPI_Pixits.ttcn +++ b/ttcn/LibMec/AppEna/ttcn/AppEnablementAPI_Pixits.ttcn @@ -17,15 +17,17 @@ module AppEnablementAPI_Pixits { modulepar ServiceInfo_Version PX_SERVICE_INFO_VERSION := "1.0.0"; - modulepar ServiceInfo_Version PX_NEW_SERVICE_INFO_VERSION := "1.0.0"; + modulepar ServiceInfo_Version PX_NEW_SERVICE_INFO_VERSION := "2.0.0"; modulepar ServiceInfo_State PX_SERVICE_INFO_STATE := ACTIVE; modulepar SerializerTypes PX_SERIALIZER := JSON; + + modulepar ServiceInfo_Link PX_LINKS_SERVICE_INFO := { self_ := { href := "http://example.com/exampleAPI/location/v1/serviceinfo" }, liveness := omit }; - modulepar SubscriptionType PX_NON_EXISTENT_APP_TERM_NOTIF_SUBSCRIPTION := ""; + modulepar SubscriptionType PX_NON_EXISTENT_APP_TERM_NOTIF_SUBSCRIPTION := "subscription666"; - modulepar AppTerminationNotificationSubscription_CallbackReference PX_APP_TERM_NOTIF_CALLBACK_URI := "http://www.etsi.org"; + modulepar AppTerminationNotificationSubscription_CallbackReference PX_APP_TERM_NOTIF_CALLBACK_URI := "http://example.com/exampleAPI/location/v1/app_termination"; modulepar Href PX_HREF := "http://www.etsi.org"; diff --git a/ttcn/LibMec/AppEna/ttcn/AppEnablementAPI_Templates.ttcn b/ttcn/LibMec/AppEna/ttcn/AppEnablementAPI_Templates.ttcn index eb0d0f1..98bea79 100644 --- a/ttcn/LibMec/AppEna/ttcn/AppEnablementAPI_Templates.ttcn +++ b/ttcn/LibMec/AppEna/ttcn/AppEnablementAPI_Templates.ttcn @@ -51,6 +51,7 @@ module AppEnablementAPI_Templates { in ServiceInfo_Version p_version := PX_SERVICE_INFO_VERSION, in ServiceInfo_State p_state := PX_SERVICE_INFO_STATE, in SerializerTypes p_serializer := PX_SERIALIZER, + //in ServiceInfo_Link p_links := PX_LINKS_SERVICE_INFO, in template (omit) SerInstanceId p_serInstanceId := omit, in template (omit) TransportId p_transportId := omit, in template (omit) TransportInfo p_transportInfo := omit, @@ -66,7 +67,9 @@ module AppEnablementAPI_Templates { serializer := p_serializer, scopeOfLocality := omit, consumedLocalOnly := omit, - isLocal := omit + isLocal := omit/*, + livenessInterval := omit, + links := p_links*/ } // End of template m_service_info template ServiceInfo mw_service_info( @@ -74,6 +77,7 @@ module AppEnablementAPI_Templates { template (present) ServiceInfo_Version p_version := ?, template (present) ServiceInfo_State p_state := ?, template (present) SerializerTypes p_serializer := ?, + //template (present) ServiceInfo_Link p_links := ?, template SerInstanceId p_serInstanceId := *, template TransportId p_transportId := *, template TransportInfo p_transportInfo := *, @@ -89,7 +93,9 @@ module AppEnablementAPI_Templates { serializer := p_serializer, scopeOfLocality := *, consumedLocalOnly := *, - isLocal := * + isLocal := */*, + livenessInterval := *, + links := p_links*/ } // End of template mw_service_info template (value) SubscriptionLinkList m_subscription_link_list( diff --git a/ttcn/LibMec/AppEna/ttcn/AppEnablementAPI_TypesAndValues.ttcn b/ttcn/LibMec/AppEna/ttcn/AppEnablementAPI_TypesAndValues.ttcn index 79a7b88..9a4a26a 100644 --- a/ttcn/LibMec/AppEna/ttcn/AppEnablementAPI_TypesAndValues.ttcn +++ b/ttcn/LibMec/AppEna/ttcn/AppEnablementAPI_TypesAndValues.ttcn @@ -395,7 +395,8 @@ module AppEnablementAPI_TypesAndValues { type enumerated SerializerTypes { JSON, XML, - PROTOBUF3 + PROTOBUF3, + RAW // Used for invalid behavior } /** @@ -413,7 +414,18 @@ module AppEnablementAPI_TypesAndValues { */ type enumerated ServiceInfo_State { ACTIVE, - INACTIVE + INACTIVE, + UNKNOWN // Used for invalid behavior tests + } + + /** + * @desc Link to the "Individual mecServiceLiveness" resource where the MEC platform expects the service instance to send the liveness information. + */ + type record ServiceInfo_Link { + LinkType self_, + LinkType liveness optional + } with { + variant (self_) "name as 'self'"; } /** @@ -451,8 +463,12 @@ module AppEnablementAPI_TypesAndValues { TransportInfo transportInfo optional, SerializerTypes serializer, LocalityType scopeOfLocality optional, - boolean consumedLocalOnly optional, - boolean isLocal optional + JSON.Bool consumedLocalOnly optional, + JSON.Bool isLocal optional/*, + UInt32 livenessInterval optional, + ServiceInfo_Link links + } with { + variant (links) "name as '_links'";*/ } type record of ServiceInfo ServiceInfoList; -- GitLab