X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fcontrol%2Fut_messaging_test.go;h=e6d6646b2900a7359bae8dc0dc5c546debdec10c;hb=ac8bde486e4453d613db6ae05f6839661068a4ab;hp=d20b8726361911dab6ff3f2e095577b8098e00ab;hpb=e5e672c043d80c7a531b9d6d640ca8879d9bf01b;p=ric-plt%2Fsubmgr.git diff --git a/pkg/control/ut_messaging_test.go b/pkg/control/ut_messaging_test.go index d20b872..e6d6646 100644 --- a/pkg/control/ut_messaging_test.go +++ b/pkg/control/ut_messaging_test.go @@ -30,14 +30,56 @@ import ( "github.com/stretchr/testify/assert" ) -func TestRESTSubReqAndDeleteOkWithE2apUtWrapper(t *testing.T) { - +func TestSuiteSetup(t *testing.T) { // The effect of this call shall endure thgough the UT suite! // If this causes any issues, the previout interface can be restored - // like this: + // like this:git log // SetPackerIf(e2ap_wrapper.NewAsn1E2APPacker()) SetPackerIf(e2ap_wrapper.NewUtAsn1E2APPacker()) +} + +//----------------------------------------------------------------------------- +// TestRESTSubReqAndDeleteOkWithE2apUtWrapper +// +// stub stub stub +// +-------+ +---------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | | rtmgr | +// +-------+ +---------+ +---------+ +---------+ +// | | | | +// | RESTSubReq | | | +// |---------------->| | | +// | | RouteCreate | | +// | |--------------------------->| // The order of these events may vary +// | | | | +// | RESTSubResp | | | // The order of these events may vary +// |<----------------| | | +// | | RouteResponse| | +// | |<---------------------------| // The order of these events may vary +// | | | | +// | | SubReq | | +// | |------------->| | // The order of these events may vary +// | | | | +// | | SubResp | | +// | |<-------------| | +// | RESTNotif1 | | | +// |<----------------| | | +// | | | | +// | RESTSubDelReq | | | +// |---------------->| | | +// | | SubDelReq | | +// | |------------->| | +// | | | | +// | RESTSubDelResp| | | +// |<----------------| | | +// | | | | +// | | SubDelResp | | +// | |<-------------| | +// | | | | +// | | | | +// +//----------------------------------------------------------------------------- +func TestRESTSubReqAndDeleteOkWithE2apUtWrapper(t *testing.T) { restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil) @@ -46,6 +88,114 @@ func TestRESTSubReqAndDeleteOkWithE2apUtWrapper(t *testing.T) { waitSubsCleanup(t, e2SubsId, 10) } +//----------------------------------------------------------------------------- +// TestRESTSubReqAndE1apDeleteReqPackingError +// +// stub stub stub +// +-------+ +---------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | | rtmgr | +// +-------+ +---------+ +---------+ +---------+ +// | | | | +// | RESTSubReq | | | +// |---------------->| | | +// | | RouteCreate | | +// | |--------------------------->| // The order of these events may vary +// | | | | +// | RESTSubResp | | | // The order of these events may vary +// |<----------------| | | +// | | RouteResponse| | +// | |<---------------------------| // The order of these events may vary +// | | | | +// | | SubReq | | +// | |------------->| | // The order of these events may vary +// | | | | +// | | SubResp | | +// | |<-------------| | +// | RESTNotif1 | | | +// |<----------------| | | +// | | | | +// | RESTSubDelReq | | | +// |---------------->| | | +// | | | | +// | RESTSubDelResp| | | +// |<----------------| | | +// | | | | +// | | | | +// +//----------------------------------------------------------------------------- +func TestRESTSubReqAndE1apDeleteReqPackingError(t *testing.T) { + + restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil) + + e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, false) + xappConn1.SendRESTSubsDelReq(t, &restSubId) + defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, true) + + waitSubsCleanup(t, e2SubsId, 10) +} + +//----------------------------------------------------------------------------- +// TestRESTSubReqAndE1apDeleteRespUnpackingError +// +// stub stub stub +// +-------+ +---------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | | rtmgr | +// +-------+ +---------+ +---------+ +---------+ +// | | | | +// | RESTSubReq | | | +// |---------------->| | | +// | | RouteCreate | | +// | |--------------------------->| // The order of these events may vary +// | | | | +// | RESTSubResp | | | // The order of these events may vary +// |<----------------| | | +// | | RouteResponse| | +// | |<---------------------------| // The order of these events may vary +// | | | | +// | | SubReq | | +// | |------------->| | // The order of these events may vary +// | | | | +// | | SubResp | | +// | |<-------------| | +// | RESTNotif1 | | | +// |<----------------| | | +// | | | | +// | RESTSubDelReq | | | +// |---------------->| | | +// | | SubDelReq | | +// | |------------->| | +// | | | | +// | RESTSubDelResp| | | +// |<----------------| | | // The order of these events may vary +// | | | | +// | | SubDelResp | | +// | |<-------------| | // 1.st NOK +// | | | | +// | | SubDelReq | | +// | |------------->| | +// | | | | +// | | SubDelResp | | +// | |<-------------| | // 2.nd NOK +// +//----------------------------------------------------------------------------- + +func TestRESTSubReqAndE1apDeleteRespUnpackingError(t *testing.T) { + + restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil) + + xappConn1.SendRESTSubsDelReq(t, &restSubId) + e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, false) + delreq, delmsg := e2termConn1.RecvSubsDelReq(t) + e2termConn1.SendSubsDelResp(t, delreq, delmsg) + + delreq, delmsg = e2termConn1.RecvSubsDelReq(t) + e2termConn1.SendSubsDelResp(t, delreq, delmsg) + + defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, true) + + waitSubsCleanup(t, e2SubsId, 10) +} + //----------------------------------------------------------------------------- // TestSubReqAndRouteNok // @@ -4891,6 +5041,837 @@ func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) { } +//----------------------------------------------------------------------------- +// TestRESTUnpackSubscriptionResponseDecodeFail +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | RestSubReq | | +// |---------------->| | +// | | | +// | RESTSubResp | | +// |<----------------| | +// | | | +// | | SubReq | +// | |------------->| +// | | | +// | | SubResp | ASN.1 decode fails +// | |<-------------| +// | | | +// | | SubReq | +// | |------------->| +// | | | +// | | SubFail | Duplicated action +// | |<-------------| +// | RESTNotif (fail)| | +// |<----------------| | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelResp | +// | |<-------------| +// +//----------------------------------------------------------------------------- +func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) { + xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseDecodeFail") + subReqCount := 1 + parameterSet := 1 // E2SM-gNB-X2 + actionDefinitionPresent := true + actionParamCount := 1 + + // Req + params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount) + restSubId := xappConn1.SendRESTSubsReq(t, params) + + crereq, cremsg := e2termConn1.RecvSubsReq(t) + // Decode of this response fails which will result resending original request + e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP) + + _, cremsg = e2termConn1.RecvSubsReq(t) + + xappConn1.ExpectRESTNotification(t, restSubId) + + // Subscription already created in E2 Node. + fparams := &teststube2ap.E2StubSubsFailParams{} + fparams.Set(crereq) + fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action + e2termConn1.SendSubsFail(t, fparams, cremsg) + + delreq, delmsg := e2termConn1.RecvSubsDelReq(t) + e2termConn1.SendSubsDelResp(t, delreq, delmsg) + + instanceId := xappConn1.WaitRESTNotification(t, restSubId) + xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId) + + // Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10) + + xappConn1.TestMsgChanEmpty(t) + e2termConn1.TestMsgChanEmpty(t) + mainCtrl.wait_registry_empty(t, 10) +} + +//----------------------------------------------------------------------------- +// TestRESTUnpackSubscriptionResponseUnknownInstanceId +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | RestSubReq | | +// |---------------->| | +// | | | +// | RESTSubResp | | +// |<----------------| | +// | | | +// | | SubReq | +// | |------------->| +// | | | +// | | SubResp | Unknown instanceId +// | |<-------------| +// | | | +// | | SubReq | +// | |------------->| +// | | | +// | | SubFail | Duplicated action +// | |<-------------| +// | RESTNotif (fail)| | +// |<----------------| | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelResp | +// | |<-------------| +// +//----------------------------------------------------------------------------- +func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) { + xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId") + subReqCount := 1 + parameterSet := 1 // E2SM-gNB-X2 + actionDefinitionPresent := true + actionParamCount := 1 + + // Req + params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount) + restSubId := xappConn1.SendRESTSubsReq(t, params) + + crereq, cremsg := e2termConn1.RecvSubsReq(t) + + // Unknown instanceId in this response which will result resending original request + orgInstanceId := crereq.RequestId.InstanceId + crereq.RequestId.InstanceId = 0 + e2termConn1.SendSubsResp(t, crereq, cremsg) + + _, cremsg = e2termConn1.RecvSubsReq(t) + + xappConn1.ExpectRESTNotification(t, restSubId) + + // Subscription already created in E2 Node. + fparams := &teststube2ap.E2StubSubsFailParams{} + fparams.Set(crereq) + fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action + e2termConn1.SendSubsFail(t, fparams, cremsg) + + delreq, delmsg := e2termConn1.RecvSubsDelReq(t) + e2termConn1.SendSubsDelResp(t, delreq, delmsg) + + instanceId := xappConn1.WaitRESTNotification(t, restSubId) + xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId) + + // Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, orgInstanceId, 10) + + xappConn1.TestMsgChanEmpty(t) + e2termConn1.TestMsgChanEmpty(t) + mainCtrl.wait_registry_empty(t, 10) +} + +//----------------------------------------------------------------------------- +// TestRESTUnpackSubscriptionResponseNoTransaction +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | RestSubReq | | +// |---------------->| | +// | | | +// | RESTSubResp | | +// |<----------------| | +// | | | +// | | SubReq | +// | |------------->| +// | | | +// | | SubResp | No transaction for the response +// | |<-------------| +// | | | +// | | SubReq | +// | |------------->| +// | | | +// | | SubFail | Duplicated action +// | |<-------------| +// | RESTNotif (fail)| | +// |<----------------| | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelResp | +// | |<-------------| +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelResp | +// | |<-------------| +// +//----------------------------------------------------------------------------- +func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) { + xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseNoTransaction") + subReqCount := 1 + parameterSet := 1 // E2SM-gNB-X2 + actionDefinitionPresent := true + actionParamCount := 1 + + // Req + params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount) + restSubId := xappConn1.SendRESTSubsReq(t, params) + + crereq, cremsg := e2termConn1.RecvSubsReq(t) + + mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId) + // No transaction exist for this response which will result resending original request + e2termConn1.SendSubsResp(t, crereq, cremsg) + + _, cremsg = e2termConn1.RecvSubsReq(t) + + xappConn1.ExpectRESTNotification(t, restSubId) + + // Subscription already created in E2 Node. + fparams := &teststube2ap.E2StubSubsFailParams{} + fparams.Set(crereq) + fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action + e2termConn1.SendSubsFail(t, fparams, cremsg) + + delreq, delmsg := e2termConn1.RecvSubsDelReq(t) + e2termConn1.SendSubsDelResp(t, delreq, delmsg) + + // Resending happens because there no transaction + delreq, delmsg = e2termConn1.RecvSubsDelReq(t) + e2termConn1.SendSubsDelResp(t, delreq, delmsg) + + instanceId := xappConn1.WaitRESTNotification(t, restSubId) + xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId) + + // Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10) + + xappConn1.TestMsgChanEmpty(t) + e2termConn1.TestMsgChanEmpty(t) + mainCtrl.wait_registry_empty(t, 10) + +} + +//----------------------------------------------------------------------------- +// TestRESTUnpackSubscriptionFailureDecodeFail +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | RestSubReq | | +// |---------------->| | +// | | | +// | RESTSubResp | | +// |<----------------| | +// | | | +// | | SubReq | +// | |------------->| +// | | | +// | | SubFail | ASN.1 decode fails +// | |<-------------| +// | | | +// | | SubReq | +// | |------------->| +// | | | +// | | SubFail | Duplicated action +// | |<-------------| +// | RESTNotif (fail)| | +// |<----------------| | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelResp | +// | |<-------------| +// +//----------------------------------------------------------------------------- +func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) { + xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureDecodeFail") + subReqCount := 1 + parameterSet := 1 // E2SM-gNB-X2 + actionDefinitionPresent := true + actionParamCount := 1 + + // Req + params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount) + restSubId := xappConn1.SendRESTSubsReq(t, params) + + crereq, cremsg := e2termConn1.RecvSubsReq(t) + + // Decode of this response fails which will result resending original request + e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE) + + _, cremsg = e2termConn1.RecvSubsReq(t) + + xappConn1.ExpectRESTNotification(t, restSubId) + + // Subscription already created in E2 Node. + fparams := &teststube2ap.E2StubSubsFailParams{} + fparams.Set(crereq) + fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action + e2termConn1.SendSubsFail(t, fparams, cremsg) + + delreq, delmsg := e2termConn1.RecvSubsDelReq(t) + e2termConn1.SendSubsDelResp(t, delreq, delmsg) + + instanceId := xappConn1.WaitRESTNotification(t, restSubId) + xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId) + + // Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10) + + xappConn1.TestMsgChanEmpty(t) + e2termConn1.TestMsgChanEmpty(t) + mainCtrl.wait_registry_empty(t, 10) +} + +//----------------------------------------------------------------------------- +// TestRESTUnpackSubscriptionResponseUnknownInstanceId +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | RestSubReq | | +// |---------------->| | +// | | | +// | RESTSubResp | | +// |<----------------| | +// | | | +// | | SubReq | +// | |------------->| +// | | | +// | | SubFail | Unknown instanceId +// | |<-------------| +// | | | +// | | SubReq | +// | |------------->| +// | | | +// | | SubFail | Duplicated action +// | |<-------------| +// | RESTNotif (fail)| | +// |<----------------| | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelResp | +// | |<-------------| +// +//----------------------------------------------------------------------------- +func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) { + xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureUnknownInstanceId") + subReqCount := 1 + parameterSet := 1 // E2SM-gNB-X2 + actionDefinitionPresent := true + actionParamCount := 1 + + // Req + params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount) + restSubId := xappConn1.SendRESTSubsReq(t, params) + + crereq, cremsg := e2termConn1.RecvSubsReq(t) + + // Unknown instanceId in this response which will result resending original request + fparams := &teststube2ap.E2StubSubsFailParams{} + fparams.Set(crereq) + fparams.Fail.RequestId.InstanceId = 0 + e2termConn1.SendSubsFail(t, fparams, cremsg) + + _, cremsg = e2termConn1.RecvSubsReq(t) + + xappConn1.ExpectRESTNotification(t, restSubId) + + // Subscription already created in E2 Node. + fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action + e2termConn1.SendSubsFail(t, fparams, cremsg) + + delreq, delmsg := e2termConn1.RecvSubsDelReq(t) + e2termConn1.SendSubsDelResp(t, delreq, delmsg) + + instanceId := xappConn1.WaitRESTNotification(t, restSubId) + xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId) + + // Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10) + + xappConn1.TestMsgChanEmpty(t) + e2termConn1.TestMsgChanEmpty(t) + mainCtrl.wait_registry_empty(t, 10) +} + +//----------------------------------------------------------------------------- +// TestRESTUnpackSubscriptionFailureNoTransaction +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | RestSubReq | | +// |---------------->| | +// | | | +// | RESTSubResp | | +// |<----------------| | +// | | | +// | | SubReq | +// | |------------->| +// | | | +// | | SubFail | No transaction for the response +// | |<-------------| +// | | | +// | | SubReq | +// | |------------->| +// | | | +// | | SubFail | Duplicated action +// | |<-------------| +// | RESTNotif (fail)| | +// |<----------------| | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelResp | +// | |<-------------| +// +//----------------------------------------------------------------------------- +func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) { + xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureNoTransaction") + subReqCount := 1 + parameterSet := 1 // E2SM-gNB-X2 + actionDefinitionPresent := true + actionParamCount := 1 + + // Req + params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount) + restSubId := xappConn1.SendRESTSubsReq(t, params) + + crereq, cremsg := e2termConn1.RecvSubsReq(t) + + mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId) + + // No transaction exist for this response which will result resending original request + fparams := &teststube2ap.E2StubSubsFailParams{} + fparams.Set(crereq) + e2termConn1.SendSubsFail(t, fparams, cremsg) + + _, cremsg = e2termConn1.RecvSubsReq(t) + + xappConn1.ExpectRESTNotification(t, restSubId) + + // Subscription already created in E2 Node. + fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action + e2termConn1.SendSubsFail(t, fparams, cremsg) + + delreq, delmsg := e2termConn1.RecvSubsDelReq(t) + e2termConn1.SendSubsDelResp(t, delreq, delmsg) + + // Resending happens because there no transaction + delreq, delmsg = e2termConn1.RecvSubsDelReq(t) + e2termConn1.SendSubsDelResp(t, delreq, delmsg) + + instanceId := xappConn1.WaitRESTNotification(t, restSubId) + xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId) + + // Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10) + + xappConn1.TestMsgChanEmpty(t) + e2termConn1.TestMsgChanEmpty(t) + mainCtrl.wait_registry_empty(t, 10) +} + +//----------------------------------------------------------------------------- +// TestRESTUnpackSubscriptionDeleteResponseDecodeFail +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | [SUBS CREATE] | +// | | | +// | | | +// | RESTSubDelReq | | +// |---------------->| | +// | | | +// | RESTSubDelResp | | +// |<----------------| | +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelResp | ASN.1 decode fails +// | |<-------------| +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelFail | Subscription does exist any more +// | |<-------------| +// | | | +// +//----------------------------------------------------------------------------- +func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) { + xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseDecodeFail") + + // Req + var params *teststube2ap.RESTSubsReqParams = nil + restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params) + + // Del + xappConn1.SendRESTSubsDelReq(t, &restSubId) + + // E2t: Receive 1st SubsDelReq + delreq, delmsg := e2termConn1.RecvSubsDelReq(t) + + // Decode of this response fails which will result resending original request + e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_REQ) + + // E2t: Receive 2nd SubsDelReq and send SubsDelResp + delreq, delmsg = e2termConn1.RecvSubsDelReq(t) + + // Subscription does not exist in in E2 Node. + e2termConn1.SendSubsDelFail(t, delreq, delmsg) + + // Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, e2SubsId, 10) + + xappConn1.TestMsgChanEmpty(t) + e2termConn1.TestMsgChanEmpty(t) + mainCtrl.wait_registry_empty(t, 10) +} + +//----------------------------------------------------------------------------- +// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | [SUBS CREATE] | +// | | | +// | | | +// | RESTSubDelReq | | +// |---------------->| | +// | | | +// | RESTSubDelResp | | +// |<----------------| | +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelResp | Unknown instanceId +// | |<-------------| +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelFail | Subscription does exist any more +// | |<-------------| +// +//----------------------------------------------------------------------------- +func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) { + xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId") + + // Req + var params *teststube2ap.RESTSubsReqParams = nil + restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params) + + // Del + xappConn1.SendRESTSubsDelReq(t, &restSubId) + + // E2t: Receive 1st SubsDelReq + delreq, delmsg := e2termConn1.RecvSubsDelReq(t) + + // Unknown instanceId in this response which will result resending original request + delreq.RequestId.InstanceId = 0 + e2termConn1.SendSubsDelResp(t, delreq, delmsg) + + // E2t: Receive 2nd SubsDelReq + delreq, delmsg = e2termConn1.RecvSubsDelReq(t) + + // Subscription does not exist in in E2 Node. + e2termConn1.SendSubsDelFail(t, delreq, delmsg) + + // Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, e2SubsId, 10) + + xappConn1.TestMsgChanEmpty(t) + e2termConn1.TestMsgChanEmpty(t) + mainCtrl.wait_registry_empty(t, 10) +} + +//----------------------------------------------------------------------------- +// TestRESTUnpackSubscriptionDeleteResponseNoTransaction +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | [SUBS CREATE] | +// | | | +// | | | +// | RESTSubDelReq | | +// |---------------->| | +// | | | +// | RESTSubDelResp | | +// |<----------------| | +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelResp | No transaction for the response +// | |<-------------| +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelFail | Subscription does exist any more +// | |<-------------| +// +//----------------------------------------------------------------------------- +func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) { + xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseNoTransaction") + + // Req + var params *teststube2ap.RESTSubsReqParams = nil + restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params) + + // Del + xappConn1.SendRESTSubsDelReq(t, &restSubId) + + // E2t: Receive 1st SubsDelReq + delreq, delmsg := e2termConn1.RecvSubsDelReq(t) + + mainCtrl.MakeTransactionNil(t, e2SubsId) + + // No transaction exist for this response which will result resending original request + e2termConn1.SendSubsDelResp(t, delreq, delmsg) + + // E2t: Receive 2nd SubsDelReq + delreq, delmsg = e2termConn1.RecvSubsDelReq(t) + + // Subscription does not exist in in E2 Node. + e2termConn1.SendSubsDelFail(t, delreq, delmsg) + + // Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, e2SubsId, 10) + + xappConn1.TestMsgChanEmpty(t) + e2termConn1.TestMsgChanEmpty(t) + mainCtrl.wait_registry_empty(t, 10) +} + +//----------------------------------------------------------------------------- +// TestRESTUnpackSubscriptionDeleteFailureDecodeFail +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | [SUBS CREATE] | +// | | | +// | | | +// | RESTSubDelReq | | +// |---------------->| | +// | | | +// | RESTSubDelResp | | +// |<----------------| | +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelFail | ASN.1 decode fails +// | |<-------------| +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelFail | Subscription does exist any more +// | |<-------------| +// +//----------------------------------------------------------------------------- +func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) { + xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteFailureDecodeFail") + + // Req + var params *teststube2ap.RESTSubsReqParams = nil + restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params) + + // Del + xappConn1.SendRESTSubsDelReq(t, &restSubId) + + // E2t: Receive 1st SubsDelReq + delreq, delmsg := e2termConn1.RecvSubsDelReq(t) + + // Decode of this response fails which will result resending original request + e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE) + + // E2t: Receive 2nd SubsDelReq and send SubsDelResp + delreq, delmsg = e2termConn1.RecvSubsDelReq(t) + + // Subscription does not exist in in E2 Node. + e2termConn1.SendSubsDelFail(t, delreq, delmsg) + + // Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, e2SubsId, 10) + + xappConn1.TestMsgChanEmpty(t) + e2termConn1.TestMsgChanEmpty(t) + mainCtrl.wait_registry_empty(t, 10) +} + +//----------------------------------------------------------------------------- +// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | [SUBS CREATE] | +// | | | +// | | | +// | RESTSubDelReq | | +// |---------------->| | +// | | | +// | RESTSubDelResp | | +// |<----------------| | +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelFail | Unknown instanceId +// | |<-------------| +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelFail | Subscription does exist any more +// | |<-------------| +// +//----------------------------------------------------------------------------- +func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) { + xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId") + + // Req + var params *teststube2ap.RESTSubsReqParams = nil + restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params) + + // Del + xappConn1.SendRESTSubsDelReq(t, &restSubId) + + // E2t: Receive 1st SubsDelReq + delreq, delmsg := e2termConn1.RecvSubsDelReq(t) + + // Unknown instanceId in this response which will result resending original request + delreq.RequestId.InstanceId = 0 + e2termConn1.SendSubsDelFail(t, delreq, delmsg) + + // E2t: Receive 2nd SubsDelReq + delreq, delmsg = e2termConn1.RecvSubsDelReq(t) + + // Subscription does not exist in in E2 Node. + e2termConn1.SendSubsDelFail(t, delreq, delmsg) + + // Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, e2SubsId, 10) + + xappConn1.TestMsgChanEmpty(t) + e2termConn1.TestMsgChanEmpty(t) + mainCtrl.wait_registry_empty(t, 10) +} + +//----------------------------------------------------------------------------- +// TestRESTUnpackSubscriptionDeleteFailureNoTransaction +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | [SUBS CREATE] | +// | | | +// | | | +// | RESTSubDelReq | | +// |---------------->| | +// | | | +// | RESTSubDelResp | | +// |<----------------| | +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelFail | No transaction for the response +// | |<-------------| +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelFail | Subscription does exist any more +// | |<-------------| +// +//----------------------------------------------------------------------------- +func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) { + xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteFailureNoTransaction") + + // Req + var params *teststube2ap.RESTSubsReqParams = nil + restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params) + + // Del + xappConn1.SendRESTSubsDelReq(t, &restSubId) + + // E2t: Receive 1st SubsDelReq + delreq, delmsg := e2termConn1.RecvSubsDelReq(t) + + mainCtrl.MakeTransactionNil(t, e2SubsId) + + // No transaction exist for this response which will result resending original request + e2termConn1.SendSubsDelFail(t, delreq, delmsg) + + // E2t: Receive 2nd SubsDelReq + delreq, delmsg = e2termConn1.RecvSubsDelReq(t) + + // Subscription does not exist in in E2 Node. + e2termConn1.SendSubsDelFail(t, delreq, delmsg) + + // Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, e2SubsId, 10) + + xappConn1.TestMsgChanEmpty(t) + e2termConn1.TestMsgChanEmpty(t) + mainCtrl.wait_registry_empty(t, 10) +} + //////////////////////////////////////////////////////////////////////////////////// // Services for UT cases ////////////////////////////////////////////////////////////////////////////////////