X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fcontrol%2Fut_messaging_test.go;h=2c905137e3a761e8a8e8154a0ca47b06702e1087;hb=93a5f9e27a6803adce055811c222632bfd69d11c;hp=f95855e26e1f9c10939720ba7f757a763a0a97da;hpb=e93b00fe97d7f1f4a0a687df1403494ad06b8c9a;p=ric-plt%2Fsubmgr.git diff --git a/pkg/control/ut_messaging_test.go b/pkg/control/ut_messaging_test.go index f95855e..2c90513 100644 --- a/pkg/control/ut_messaging_test.go +++ b/pkg/control/ut_messaging_test.go @@ -20,24 +20,304 @@ package control import ( + //"os" "strings" "testing" "time" "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap" "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper" + "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities" "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststube2ap" "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp" "github.com/stretchr/testify/assert" ) 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 + // The effect of this call shall endure though the UT suite! + // If this causes any issues, the previous interface can be restored // like this:git log // SetPackerIf(e2ap_wrapper.NewAsn1E2APPacker()) + mainCtrl.InitAllCounterMap() SetPackerIf(e2ap_wrapper.NewUtAsn1E2APPacker()) + mainCtrl.c.restDuplicateCtrl.Init() + +} +func TestRanStatusChangeViaSDLNotification(t *testing.T) { + + // Current UT test cases use these ran names + xappRnibMock.CreateGnb("RAN_NAME_1", entities.ConnectionStatus_DISCONNECTED) + xappRnibMock.CreateGnb("RAN_NAME_11", entities.ConnectionStatus_DISCONNECTED) + xappRnibMock.CreateGnb("RAN_NAME_2", entities.ConnectionStatus_DISCONNECTED) + + mainCtrl.c.e2IfState.ReadE2ConfigurationFromRnib() + mainCtrl.c.e2IfState.SubscribeChannels() + + mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED") + mainCtrl.SetE2State(t, "RAN_NAME_2_CONNECTED") + mainCtrl.SetE2State(t, "RAN_NAME_11_CONNECTED") +} + +//----------------------------------------------------------------------------- +// TestRESTSubReqAfterE2ConnBreak +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | [E2 Conn. DOWN] | +// | | | +// | RESTSubReq | | +// |---------------->| | +// | RESTSubFail | | +// |<----------------| | +// | | | +// +//----------------------------------------------------------------------------- + +func TestRESTSubReqAfterE2ConnBreak(t *testing.T) { + CaseBegin("TestRESTSubReqAfterE2ConnBreak") + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 1}, + Counter{cRestReqRejDueE2Down, 1}, + }) + + // E2 disconnect after E2term has received response + mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED") + // Req + const subReqCount int = 1 + params := xappConn1.GetRESTSubsReqReportParams(subReqCount) + xappConn1.SendRESTSubsReq(t, params) + + // Restore E2 connection for following test cases + mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED") + + mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) + //os.Exit(0) +} + +//----------------------------------------------------------------------------- +// TestRESTSubReqE2ConnBreak +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | RESTSubReq | | +// |---------------->| | +// | RESTSubResp | | +// |<----------------| | +// | | SubReq | +// | |------------->| +// | | SubResp | +// | |<-------------| +// | | | +// | [E2 Conn. DOWN] | +// | [Int. SUBS DELETE] | +// | | | +// | RESTNotif(unsuccessful) | +// |<----------------| | +// | | | +// | | | +// +//----------------------------------------------------------------------------- +func TestRESTSubReqE2ConnBreak(t *testing.T) { + CaseBegin("TestRESTSubReqE2ConnBreak") + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 1}, + Counter{cRestSubRespToXapp, 1}, + Counter{cSubReqToE2, 1}, + Counter{cSubRespFromE2, 1}, + Counter{cRestSubFailNotifToXapp, 1}, + }) + + // Req + const subReqCount int = 1 + params := xappConn1.GetRESTSubsReqReportParams(subReqCount) + restSubId := xappConn1.SendRESTSubsReq(t, params) + + crereq, cremsg := e2termConn1.RecvSubsReq(t) + xappConn1.ExpectRESTNotification(t, restSubId) + + // E2 disconnect after E2term has received response + mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED") + + e2termConn1.SendSubsResp(t, crereq, cremsg) + e2SubsId := xappConn1.WaitRESTNotification(t, restSubId) + + <-time.After(time.Second * 1) + assert.Equal(t, 0, len(mainCtrl.c.registry.register)) + assert.Equal(t, 0, len(mainCtrl.c.registry.restSubscriptions)) + + subIds, register, err := mainCtrl.c.ReadAllSubscriptionsFromSdl() + if err != nil { + xapp.Logger.Error("%v", err) + } else { + assert.Equal(t, 65534, len(subIds)) // range 1-65535 , FFFF = 65535 + assert.Equal(t, 0, len(register)) + } + + restSubscriptions, err := mainCtrl.c.ReadAllRESTSubscriptionsFromSdl() + if err != nil { + xapp.Logger.Error("%v", err) + } else { + assert.Equal(t, 0, len(restSubscriptions)) + } + + // Restore E2 connection for following test cases + mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED") + + // Wait that subs is cleaned + waitSubsCleanup(t, e2SubsId, 10) + mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) +} + +//----------------------------------------------------------------------------- +// TestRESTSubscriptionDeleteAfterE2ConnectionBreak +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | [SUBS CREATE] | +// | | | +// | [E2 Conn. DOWN] | +// | | | +// | RESTSubDelReq | | +// |---------------->| | +// | | | +// | RESTSubDelResp | | +// |<----------------| | +// | | | +// | [No valid subscription found] | +// | | | +// +//----------------------------------------------------------------------------- +func TestRESTSubscriptionDeleteAfterE2ConnectionBreak(t *testing.T) { + xapp.Logger.Debug("TEST: TestRESTSubscriptionDeleteAfterE2ConnectionBreak") + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 1}, + Counter{cRestSubRespToXapp, 1}, + Counter{cSubReqToE2, 1}, + Counter{cSubRespFromE2, 1}, + Counter{cRestSubNotifToXapp, 1}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cRestSubDelRespToXapp, 1}, + }) + + // Req + var params *teststube2ap.RESTSubsReqParams = nil + restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params) + + // E2 disconnect after E2term has received response + mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED") + + // Del + xappConn1.SendRESTSubsDelReq(t, &restSubId) + + <-time.After(time.Second * 1) + assert.Equal(t, 0, len(mainCtrl.c.registry.register)) + assert.Equal(t, 0, len(mainCtrl.c.registry.restSubscriptions)) + + subIds, register, err := mainCtrl.c.ReadAllSubscriptionsFromSdl() + if err != nil { + xapp.Logger.Error("%v", err) + } else { + assert.Equal(t, 65534, len(subIds)) // range 1-65535 , FFFF = 65535 + assert.Equal(t, 0, len(register)) + } + + restSubscriptions, err := mainCtrl.c.ReadAllRESTSubscriptionsFromSdl() + if err != nil { + xapp.Logger.Error("%v", err) + } else { + assert.Equal(t, 0, len(restSubscriptions)) + } + + // Restore E2 connection for following test cases + mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED") + + // Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, e2SubsId, 10) + + xappConn1.TestMsgChanEmpty(t) + e2termConn1.TestMsgChanEmpty(t) + mainCtrl.wait_registry_empty(t, 10) + mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) +} + +//----------------------------------------------------------------------------- +// TestRESTOtherE2ConnectionChanges +// + +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | [SUBS CREATE] | +// | | | +// | [E2 CONNECTED_SETUP_FAILED] | +// | [E2 CONNECTING] | +// | [E2 SHUTTING_DOWN] | +// | [E2 SHUT_DOWN] | +// | | | +// | [SUBS DELETE] | +// | | | +// +//----------------------------------------------------------------------------- +func TestRESTOtherE2ConnectionChanges(t *testing.T) { + xapp.Logger.Debug("TEST: TestRESTOtherE2ConnectionChanges") + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 1}, + Counter{cRestSubRespToXapp, 1}, + Counter{cSubReqToE2, 1}, + Counter{cSubRespFromE2, 1}, + Counter{cRestSubNotifToXapp, 1}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cSubDelReqToE2, 1}, + Counter{cSubDelRespFromE2, 1}, + Counter{cRestSubDelRespToXapp, 1}, + }) + + // Req + params := xappConn1.GetRESTSubsReqReportParams(subReqCount) + restSubId := xappConn1.SendRESTSubsReq(t, params) + + crereq, cremsg := e2termConn1.RecvSubsReq(t) + xappConn1.ExpectRESTNotification(t, restSubId) + e2termConn1.SendSubsResp(t, crereq, cremsg) + e2SubsId := xappConn1.WaitRESTNotification(t, restSubId) + + // Submgr should not react any other connection state changes than CONNECTED and DISCONNECTED + mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED_SETUP_FAILED") + mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTING") + mainCtrl.SetE2State(t, "RAN_NAME_1_SHUTTING_DOWN") + mainCtrl.SetE2State(t, "RAN_NAME_1_SHUT_DOWN") + + // Del + xappConn1.SendRESTSubsDelReq(t, &restSubId) + delreq, delmsg := e2termConn1.RecvSubsDelReq(t) + e2termConn1.SendSubsDelResp(t, delreq, delmsg) + + // Restore E2 connection for following test cases + mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED") + + // Wait that subs is cleaned + waitSubsCleanup(t, e2SubsId, 10) + mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } //----------------------------------------------------------------------------- @@ -87,6 +367,7 @@ func TestRESTSubReqAndDeleteOkWithE2apUtWrapper(t *testing.T) { deleteSubscription(t, xappConn1, e2termConn1, &restSubId) waitSubsCleanup(t, e2SubsId, 10) + mainCtrl.VerifyAllClean(t) } //----------------------------------------------------------------------------- @@ -133,6 +414,7 @@ func TestRESTSubReqAndE1apDeleteReqPackingError(t *testing.T) { defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, true) waitSubsCleanup(t, e2SubsId, 10) + mainCtrl.VerifyAllClean(t) } //----------------------------------------------------------------------------- @@ -195,6 +477,7 @@ func TestRESTSubReqAndE1apDeleteRespUnpackingError(t *testing.T) { defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, true) waitSubsCleanup(t, e2SubsId, 10) + mainCtrl.VerifyAllClean(t) } //----------------------------------------------------------------------------- @@ -392,7 +675,6 @@ func TestSubDelReqAndRouteDeleteNok(t *testing.T) { xappConn2.TestMsgChanEmpty(t) e2termConn1.TestMsgChanEmpty(t) mainCtrl.wait_registry_empty(t, 10) - mainCtrl.VerifyCounterValues(t) } @@ -452,6 +734,7 @@ func TestSubMergeDelAndRouteUpdateNok(t *testing.T) { // Init counter check mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ Counter{cSubReqFromXapp, 2}, + Counter{cMergedSubscriptions, 1}, Counter{cSubReqToE2, 1}, Counter{cSubRespFromE2, 1}, Counter{cSubRespToXapp, 2}, @@ -460,6 +743,7 @@ func TestSubMergeDelAndRouteUpdateNok(t *testing.T) { Counter{cSubDelReqToE2, 1}, Counter{cSubDelRespFromE2, 1}, Counter{cSubDelRespToXapp, 2}, + Counter{cUnmergedSubscriptions, 1}, }) //Req1 @@ -986,6 +1270,7 @@ func TestSubReqRetryInSubmgr(t *testing.T) { mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ Counter{cSubReqFromXapp, 1}, Counter{cSubReqToE2, 1}, + Counter{cSubReqTimerExpiry, 1}, Counter{cSubReReqToE2, 1}, Counter{cSubRespFromE2, 1}, Counter{cSubRespToXapp, 1}, @@ -1172,12 +1457,6 @@ func TestSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) { // | | SubFail | // | |<-------------| // | | | -// | | SubDelReq | -// | |------------->| -// | | | -// | | SubDelResp | -// | |<-------------| -// | | | // | SubFail | | // |<-------------| | // | | | @@ -1203,10 +1482,6 @@ func TestSubReqSubFailRespInSubmgr(t *testing.T) { fparams1.Set(crereq1) e2termConn1.SendSubsFail(t, fparams1, cremsg1) - // E2t: Receive SubsDelReq and send SubsDelResp (internal first) - delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t) - e2termConn1.SendSubsDelResp(t, delreq1, delmsg1) - // Xapp: Receive SubsFail e2SubsId := xappConn1.RecvSubsFail(t, cretrans) @@ -1481,8 +1756,6 @@ func TestSubReqAndSubDelOkSameAction(t *testing.T) { rparams2 := &teststube2ap.E2StubSubsReqParams{} rparams2.Init() cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil) - //crereq2, cremsg2 := e2termConn1.RecvSubsReq(t) - //e2termConn1.SendSubsResp(t, crereq2, cremsg2) e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2) resp, _ := xapp.Subscription.QuerySubscriptions() @@ -1492,11 +1765,7 @@ func TestSubReqAndSubDelOkSameAction(t *testing.T) { //Del1 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1) - //e2termConn1.RecvSubsDelReq(t) - //e2termConn1.SendSubsDelResp(t, delreq1, delmsg1) xappConn1.RecvSubsDelResp(t, deltrans1) - //Wait that subs is cleaned - //mainCtrl.wait_subs_clean(t, e2SubsId1, 10) //Del2 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2) @@ -1618,11 +1887,6 @@ func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) { // | | | SubFail1 | // | | |<-------------| // | | | | -// | | | SubDelReq | -// | | |------------->| -// | | | SubDelResp | -// | | |<-------------| -// | | | | // | | SubFail1 | | // | |<-------------| | // | | | | @@ -1653,10 +1917,6 @@ func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) { fparams1.Set(crereq1) e2termConn1.SendSubsFail(t, fparams1, cremsg1) - // E2t: internal delete - delreq, delmsg := e2termConn1.RecvSubsDelReq(t) - e2termConn1.SendSubsDelResp(t, delreq, delmsg) - //Fail1 e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1) //Fail2 @@ -2114,9 +2374,6 @@ func TestSubReqRetransmissionWithSameSubIdDiffXid(t *testing.T) { func TestSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) { CaseBegin("TestSubReqNokAndSubDelOkWithRestartInMiddle") - // Remove possible existing subscrition - mainCtrl.removeExistingSubscriptions(t) - mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription xappConn1.SendSubsReq(t, nil, nil) e2termConn1.RecvSubsReq(t) @@ -2131,6 +2388,7 @@ func TestSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) { mainCtrl.SimulateRestart(t) xapp.Logger.Debug("mainCtrl.SimulateRestart done") + // Submgr send delete for uncompleted subscription delreq, delmsg := e2termConn1.RecvSubsDelReq(t) e2termConn1.SendSubsDelResp(t, delreq, delmsg) @@ -2197,6 +2455,10 @@ func TestSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) { mainCtrl.SimulateRestart(t) xapp.Logger.Debug("mainCtrl.SimulateRestart done") + // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions()) + // That needs to be completed before successful subscription query is possible + <-time.After(time.Second * 1) + // Check that subscription is restored correctly after restart resp, _ = xapp.Subscription.QuerySubscriptions() assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId)) @@ -2291,7 +2553,7 @@ func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) { e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2) // Check subscription - resp, _ := xapp.Subscription.QuerySubscriptions() //////////////////////////////// + resp, _ := xapp.Subscription.QuerySubscriptions() assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1)) assert.Equal(t, resp[0].Meid, "RAN_NAME_1") assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"}) @@ -2299,6 +2561,10 @@ func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) { mainCtrl.SimulateRestart(t) xapp.Logger.Debug("mainCtrl.SimulateRestart done") + // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions()) + // That needs to be completed before successful subscription query is possible + <-time.After(time.Second * 1) + // Check that subscription is restored correctly after restart resp, _ = xapp.Subscription.QuerySubscriptions() assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1)) @@ -2314,6 +2580,10 @@ func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) { mainCtrl.SimulateRestart(t) xapp.Logger.Debug("mainCtrl.SimulateRestart done") + // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions()) + // Submgr need be ready before successful subscription deletion is possible + <-time.After(time.Second * 1) + //Del2 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2) delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t) @@ -2367,6 +2637,11 @@ func TestPostEmptyDb(t *testing.T) { mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/emptydb") } +func TestGetRestSubscriptions(t *testing.T) { + + mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/restsubscriptions") +} + //----------------------------------------------------------------------------- // TestRESTSubReqAndRouteNok // @@ -2411,6 +2686,7 @@ func TestRESTSubReqAndRouteNok(t *testing.T) { }) const subReqCount int = 1 + // Add delay for rtmgt HTTP handling so that HTTP response is received before notify on XAPP side waiter := rtmgrHttp.AllocNextSleep(50, false) newSubsId := mainCtrl.get_registry_next_subid(t) @@ -2418,11 +2694,11 @@ func TestRESTSubReqAndRouteNok(t *testing.T) { // Req params := xappConn1.GetRESTSubsReqReportParams(subReqCount) restSubId := xappConn1.SendRESTSubsReq(t, params) - xappConn1.ExpectRESTNotification(t, restSubId) + xappConn1.ExpectRESTNotificationNok(t, restSubId, "failAll") waiter.WaitResult(t) e2SubsId := xappConn1.WaitRESTNotification(t, restSubId) - xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId) + xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId) // Del xappConn1.SendRESTSubsDelReq(t, &restSubId) @@ -2431,6 +2707,7 @@ func TestRESTSubReqAndRouteNok(t *testing.T) { mainCtrl.wait_subs_clean(t, newSubsId, 10) waitSubsCleanup(t, e2SubsId, 10) mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } func TestRESTSubReqAndRouteUpdateNok(t *testing.T) { @@ -2445,10 +2722,10 @@ func TestRESTSubReqAndRouteUpdateNok(t *testing.T) { Counter{cRestSubNotifToXapp, 1}, Counter{cRestSubFailNotifToXapp, 1}, Counter{cRouteCreateUpdateFail, 1}, - Counter{cRestSubDelReqFromXapp, 1}, + Counter{cRestSubDelReqFromXapp, 2}, Counter{cSubDelReqToE2, 1}, Counter{cSubDelRespFromE2, 1}, - Counter{cRestSubDelRespToXapp, 1}, + Counter{cRestSubDelRespToXapp, 2}, }) var params *teststube2ap.RESTSubsReqParams = nil @@ -2464,21 +2741,22 @@ func TestRESTSubReqAndRouteUpdateNok(t *testing.T) { params = xappConn2.GetRESTSubsReqReportParams(subReqCount) params.SetMeid("RAN_NAME_1") restSubId2 := xappConn2.SendRESTSubsReq(t, params) - xapp.Logger.Info("Send REST subscriber request for second subscriber : %v", restSubId2) - xappConn2.ExpectRESTNotification(t, restSubId2) + xapp.Logger.Debug("Send REST subscriber request for second subscriber : %v", restSubId2) + xappConn2.ExpectRESTNotificationNok(t, restSubId2, "allFail") waiter.WaitResult(t) - // e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2) - TOD: missing delete xappConn2.WaitRESTNotification(t, restSubId2) queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"}) deleteSubscription(t, xappConn1, e2termConn1, &restSubId) + xappConn2.SendRESTSubsDelReq(t, &restSubId2) mainCtrl.wait_subs_clean(t, newSubsId, 10) //Wait that subs is cleaned waitSubsCleanup(t, e2SubsId, 10) mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } func TestRESTSubDelReqAndRouteDeleteNok(t *testing.T) { @@ -2512,8 +2790,8 @@ func TestRESTSubDelReqAndRouteDeleteNok(t *testing.T) { waiter.WaitResult(t) waitSubsCleanup(t, e2SubsId, 10) - mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) { @@ -2521,6 +2799,7 @@ func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) { mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ Counter{cRestSubReqFromXapp, 2}, + Counter{cMergedSubscriptions, 1}, Counter{cRestSubRespToXapp, 2}, Counter{cSubReqToE2, 1}, Counter{cSubRespFromE2, 1}, @@ -2530,6 +2809,7 @@ func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) { Counter{cSubDelReqToE2, 1}, Counter{cSubDelRespFromE2, 1}, Counter{cRestSubDelRespToXapp, 2}, + Counter{cUnmergedSubscriptions, 1}, }) var params *teststube2ap.RESTSubsReqParams = nil @@ -2553,8 +2833,8 @@ func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) { deleteXapp2Subscription(t, &restSubId2) waitSubsCleanup(t, e2SubsId2, 10) - mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } //----------------------------------------------------------------------------- @@ -2576,19 +2856,13 @@ func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) { // | RESTSubReq2 | | // | (retrans) | | // |---------------->| | -// | | | -// | | SubReq2 | -// | |------------->| -// | RESTSubResp2 | | +// | RESTSubResp(201)| | // |<----------------| | +// | | | // | | SubResp1 | // | |<-------------| // | RESTNotif1 | | // |<----------------| | -// | | SubResp1 | -// | |<-------------| -// | RESTNotif2 | | -// |<----------------| | // | | | // | [SUBS DELETE] | // | | | @@ -2601,59 +2875,600 @@ func TestRESTSubReqRetransmission(t *testing.T) { mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ Counter{cRestSubReqFromXapp, 2}, Counter{cRestSubRespToXapp, 2}, - Counter{cSubReqToE2, 2}, - Counter{cSubRespFromE2, 2}, - Counter{cRestSubNotifToXapp, 2}, - Counter{cRestSubDelReqFromXapp, 2}, - Counter{cSubDelReqToE2, 2}, - Counter{cSubDelRespFromE2, 2}, - Counter{cRestSubDelRespToXapp, 2}, + Counter{cSubReqToE2, 1}, + Counter{cSubRespFromE2, 1}, + Counter{cRestSubNotifToXapp, 1}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cSubDelReqToE2, 1}, + Counter{cSubDelRespFromE2, 1}, + Counter{cRestSubDelRespToXapp, 1}, }) - // Retry/duplicate will get the same way as the first request. Submgr cannot detect duplicate RESTRequests + // Retry/duplicate will get the same way as the first request. // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending // second request from same xapp as doing it from xappConn1 would not work as notification would not be received // Subs Create const subReqCount int = 1 - // In order to force both XAPP's to create their own subscriptions, force rtmgr to block a while so that 2nd create - // gets into execution before the rtmgrg responds for the first one. - waiter := rtmgrHttp.AllocNextSleep(10, true) params := xappConn1.GetRESTSubsReqReportParams(subReqCount) - restSubId1 := xappConn1.SendRESTSubsReq(t, params) - restSubId2 := xappConn2.SendRESTSubsReq(t, params) + restSubId := xappConn1.SendRESTSubsReq(t, params) - waiter.WaitResult(t) + xappConn1.SendRESTSubsReq(t, params) + <-time.After(time.Second * 1) - xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2}) + xappConn1.WaitListedRestNotifications(t, []string{restSubId}) // Depending one goroutine scheduling order, we cannot say for sure which xapp reaches e2term first. Thus - // the order is not significant he6re. + // the order is not significant here. crereq, cremsg := e2termConn1.RecvSubsReq(t) e2termConn1.SendSubsResp(t, crereq, cremsg) - crereq, cremsg = e2termConn1.RecvSubsReq(t) - e2termConn1.SendSubsResp(t, crereq, cremsg) - e2SubsIdA := <-xappConn1.ListedRESTNotifications - xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA) - e2SubsIdB := <-xappConn1.ListedRESTNotifications - xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB) + e2SubsId := <-xappConn1.ListedRESTNotifications + + xapp.Logger.Debug("TEST: XAPP notification received e2SubsId=%v", e2SubsId) // Del1 - xappConn1.SendRESTSubsDelReq(t, &restSubId1) + xappConn1.SendRESTSubsDelReq(t, &restSubId) delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t) e2termConn1.SendSubsDelResp(t, delreq1, delmsg1) - // Del2 - xappConn2.SendRESTSubsDelReq(t, &restSubId2) - delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t) - e2termConn1.SendSubsDelResp(t, delreq2, delmsg2) + mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsId.E2SubsId}, 10) - mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10) + mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) +} - waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10) +//----------------------------------------------------------------------------- +// stub stub stub +// +-------+ +---------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | | rtmgr | +// +-------+ +---------+ +---------+ +---------+ +// | | | | +// | RESTSubReq | | | +// |---------------->| | | +// | RESTSubResp | | | +// |<----------------| | | +// | | RouteCreate | | +// | |--------------------------->| +// | | RouteResponse| | +// | |<---------------------------| // The order of these events may vary +// | | SubReq | | +// | |------------->| | // The order of these events may vary +// | | SubResp | | +// | |<-------------| | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubReq | | | +// | [RETRANS1] | | | +// |---------------->| | | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubReq | | | +// | [RETRANS2] | | | +// |---------------->| | | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubDelReq | | | +// |---------------->| | | +// | | SubDelReq | | +// | |------------->| | +// | RESTSubDelResp| | | +// |<----------------| | | +// | | SubDelResp | | +// | |<-------------| | +// | | | | +// +//----------------------------------------------------------------------------- + +func TestRESTSubReqRetransmissionV2(t *testing.T) { + CaseBegin("TestRESTSubReqRetransmissionV2") + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 3}, + Counter{cDuplicateE2SubReq, 2}, + Counter{cRestSubRespToXapp, 3}, + Counter{cSubReqToE2, 1}, + Counter{cSubRespFromE2, 1}, + Counter{cRestSubNotifToXapp, 3}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cSubDelReqToE2, 1}, + Counter{cSubDelRespFromE2, 1}, + Counter{cRestSubDelRespToXapp, 1}, + }) + + params := xappConn1.GetRESTSubsReqReportParams(subReqCount) + + restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params) + + queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"}) + + mainCtrl.WaitOngoingRequestMapEmpty() + + //1.st resend + restSubId_resend := xappConn1.SendRESTSubsReq(t, params) + + assert.Equal(t, restSubId_resend, restSubId) + + mainCtrl.WaitOngoingRequestMapEmpty() + + //2.nd resend + restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params) + + assert.Equal(t, restSubId_resend2, restSubId) + mainCtrl.WaitOngoingRequestMapEmpty() + + deleteSubscription(t, xappConn1, e2termConn1, &restSubId) + + waitSubsCleanup(t, e2SubsId, 10) mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) +} + +//----------------------------------------------------------------------------- +// stub stub stub +// +-------+ +---------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | | rtmgr | +// +-------+ +---------+ +---------+ +---------+ +// | | | | +// | RESTSubReq | | | +// |---------------->| | | +// | RESTSubResp | | | +// |<----------------| | | +// | | RouteCreate | | +// | |--------------------------->| +// | | RouteResponse| | +// | |<---------------------------| // The order of these events may vary +// | | SubReq | | +// | |------------->| | // The order of these events may vary +// | | SubResp | | +// | |<-------------| | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubReq | | | +// | [RETRANS, with RESTsubsId] | | +// |---------------->| | | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubReq | | | +// | [RETRANS, without RESTsubsId] | | +// |---------------->| | | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubDelReq | | | +// |---------------->| | | +// | | SubDelReq | | +// | |------------->| | +// | RESTSubDelResp| | | +// |<----------------| | | +// | | SubDelResp | | +// | |<-------------| | +// | | | | +// +//----------------------------------------------------------------------------- +func TestRESTSubReqRetransmissionV3(t *testing.T) { + CaseBegin("TestRESTSubReqRetransmissionV3") + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 3}, + Counter{cDuplicateE2SubReq, 2}, + Counter{cRestSubRespToXapp, 3}, + Counter{cSubReqToE2, 1}, + Counter{cSubRespFromE2, 1}, + Counter{cRestSubNotifToXapp, 3}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cSubDelReqToE2, 1}, + Counter{cSubDelRespFromE2, 1}, + Counter{cRestSubDelRespToXapp, 1}, + }) + + params := xappConn1.GetRESTSubsReqReportParams(subReqCount) + + restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params) + + queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"}) + + mainCtrl.WaitOngoingRequestMapEmpty() + + //1.st resend with subscription ID + params.SetSubscriptionID(&restSubId) + restSubId_resend := xappConn1.SendRESTSubsReq(t, params) + + assert.Equal(t, restSubId_resend, restSubId) + + mainCtrl.WaitOngoingRequestMapEmpty() + + //2.nd resend without subscription ID (faking app restart) + params = xappConn1.GetRESTSubsReqReportParams(subReqCount) + restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params) + + assert.Equal(t, restSubId_resend2, restSubId) + + mainCtrl.WaitOngoingRequestMapEmpty() + + deleteSubscription(t, xappConn1, e2termConn1, &restSubId) + + waitSubsCleanup(t, e2SubsId, 10) + mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) +} + +//----------------------------------------------------------------------------- +// stub stub stub +// +-------+ +---------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | | rtmgr | +// +-------+ +---------+ +---------+ +---------+ +// | | | | +// | RESTSubReq | | | +// |---------------->| | | +// | RESTSubResp | | | +// |<----------------| | | +// | | RouteCreate | | +// | |--------------------------->| +// | | RouteResponse| | +// | |<---------------------------| +// | | SubReq | | +// | |------------->| | +// | | SubResp | | +// | |<-------------| | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubReq | | | +// | [with RestSUbsId + one additional e2 subDetail] +// |---------------->| | | +// | RESTNotif1 | | | +// | [for initial e2 subDetail] | | +// |<----------------| | | +// | | RouteCreate | | +// | |--------------------------->| +// | | RouteResponse| | +// | |<---------------------------| +// | | SubReq | | +// | |------------->| | +// | | SubResp | | +// | |<-------------| | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubReq | | | +// | [with RESTsubsId initial request] | +// |---------------->| | | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubDelReq | | | +// |---------------->| | | +// | RESTSubDelResp| | | +// |<----------------| | | +// | | SubDelReq | | +// | |------------->| | +// | | SubDelResp | | +// | |<-------------| | +// | | SubDelReq | | +// | |------------->| | +// | | SubDelResp | | +// | |<-------------| | +// | | | | +// +//----------------------------------------------------------------------------- + +func TestRESTSubReqRetransmissionV4(t *testing.T) { + CaseBegin("TestRESTSubReqRetransmissionV4") + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 3}, + Counter{cDuplicateE2SubReq, 2}, + Counter{cRestSubRespToXapp, 3}, + Counter{cSubReqToE2, 2}, + Counter{cSubRespFromE2, 2}, + Counter{cRestSubNotifToXapp, 4}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cSubDelReqToE2, 2}, + Counter{cSubDelRespFromE2, 2}, + Counter{cRestSubDelRespToXapp, 1}, + }) + + params := xappConn1.GetRESTSubsReqReportParams(subReqCount) + + restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params) + + mainCtrl.WaitOngoingRequestMapEmpty() + + // Send modified requst, this time with e2 subscriptions. + params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1) + params2.SetSubscriptionID(&restSubId) + + xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler) + xappConn1.ExpectAnyNotification(t) + // Resend the original request with an additional e2 subscription (detail), this time with restsubsid + restSubId_resend := xappConn1.SendRESTSubsReq(t, params2) + e2SubsId1 := xappConn1.WaitAnyRESTNotification(t) + assert.Equal(t, e2SubsId, e2SubsId1) + + crereq2, cremsg2 := e2termConn1.RecvSubsReq(t) + + xappConn1.DecrementRequestCount() + xappConn1.ExpectRESTNotification(t, restSubId_resend) + e2termConn1.SendSubsResp(t, crereq2, cremsg2) + e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend) + assert.NotEqual(t, e2SubsId2, 0) + + mainCtrl.WaitOngoingRequestMapEmpty() + + xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler) + params = xappConn1.GetRESTSubsReqReportParams(subReqCount) + params.SetSubscriptionID(&restSubId) + xappConn1.ExpectAnyNotification(t) + // Resend the original request again with only one e2 subscription (detail), this time with restsubsid + restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params) + assert.Equal(t, restSubId_resend, restSubId_resend2) + + e2SubsId1 = xappConn1.WaitAnyRESTNotification(t) + assert.Equal(t, e2SubsId, e2SubsId1) + + mainCtrl.WaitOngoingRequestMapEmpty() + + // Delete both e2 subscriptions + xappConn1.SendRESTSubsDelReq(t, &restSubId) + e2SubsIds := []uint32{e2SubsId, e2SubsId2} + sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1) + + waitSubsCleanup(t, e2SubsId, 10) + mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) +} + +//----------------------------------------------------------------------------- +// stub stub stub +// +-------+ +---------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | | rtmgr | +// +-------+ +---------+ +---------+ +---------+ +// | | | | +// | RESTSubReq | | | +// |---------------->| | | +// | RESTSubResp | | | +// |<----------------| | | +// | | RouteCreate | | +// | |--------------------------->| +// | | RouteResponse| | +// | |<---------------------------| +// | | SubReq | | +// | |------------->| | +// | | SubResp | | +// | |<-------------| | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubReq | | | +// | [with RestSUbsId + one additional e2 subDetail] +// |---------------->| | | +// | RESTNotif1 | | | +// | [for initial e2 subDetail] | | +// |<----------------| | | +// | | RouteCreate | | +// | |--------------------------->| +// | | RouteResponse| | +// | |<---------------------------| +// | | SubReq | | +// | |------------->| | +// | | SubResp | | +// | |<-------------| | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubReq | | | +// | [without RESTsubsId initial request] | +// |---------------->| | | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubDelReq | | | +// |---------------->| | | +// | RESTSubDelResp| | | +// |<----------------| | | +// | | SubDelReq | | +// | |------------->| | +// | | SubDelResp | | +// | |<-------------| | +// | | SubDelReq | | +// | |------------->| | +// | | SubDelResp | | +// | |<-------------| | +// | | | | +// +//----------------------------------------------------------------------------- + +func TestRESTSubReqRetransmissionV5(t *testing.T) { + CaseBegin("TestRESTSubReqRetransmissionV5") + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 3}, + Counter{cDuplicateE2SubReq, 2}, + Counter{cRestSubRespToXapp, 3}, + Counter{cSubReqToE2, 2}, + Counter{cSubRespFromE2, 2}, + Counter{cRestSubNotifToXapp, 4}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cSubDelReqToE2, 2}, + Counter{cSubDelRespFromE2, 2}, + Counter{cRestSubDelRespToXapp, 1}, + }) + + params := xappConn1.GetRESTSubsReqReportParams(subReqCount) + + restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params) + + mainCtrl.WaitOngoingRequestMapEmpty() + + // Send modified request, this time with e2 subscriptions. + params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1) + params2.SetSubscriptionID(&restSubId) + + xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler) + xappConn1.ExpectAnyNotification(t) + // Resend the original request with an additional e2 subscription (detail), this time with restsubsid + restSubId_resend := xappConn1.SendRESTSubsReq(t, params2) + + e2SubsId1 := xappConn1.WaitAnyRESTNotification(t) + assert.Equal(t, e2SubsId, e2SubsId1) + // The first E2 subscription returns immediately, manually decrement expected request count for the remaining request handling + xappConn1.DecrementRequestCount() + + crereq2, cremsg2 := e2termConn1.RecvSubsReq(t) + + xappConn1.ExpectRESTNotification(t, restSubId_resend) + e2termConn1.SendSubsResp(t, crereq2, cremsg2) + e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend) + assert.NotEqual(t, e2SubsId2, 0) + + mainCtrl.WaitOngoingRequestMapEmpty() + + xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler) + params = xappConn1.GetRESTSubsReqReportParams(subReqCount) + xappConn1.ExpectAnyNotification(t) + // Resend the original request again with only one e2 subscription (detail), WITHOUT restsubsid + // md5sum shall find the original request + restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params) + assert.Equal(t, restSubId_resend, restSubId_resend2) + + e2SubsId1 = xappConn1.WaitAnyRESTNotification(t) + assert.Equal(t, e2SubsId, e2SubsId1) + + mainCtrl.WaitOngoingRequestMapEmpty() + + // Delete both e2 subscriptions + xappConn1.SendRESTSubsDelReq(t, &restSubId) + e2SubsIds := []uint32{e2SubsId, e2SubsId2} + sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1) + + waitSubsCleanup(t, e2SubsId, 10) + mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) +} + +//----------------------------------------------------------------------------- +// stub stub stub +// +-------+ +---------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | | rtmgr | +// +-------+ +---------+ +---------+ +---------+ +// | | | | +// | RESTSubReq | | | +// |---------------->| | | +// | RESTSubResp | | | +// |<----------------| | | +// | | RouteCreate | | +// | |--------------------------->| +// | | RouteResponse| | +// | |<---------------------------| +// | | SubReq | | +// | |------------->| | +// | | SubResp | | +// | |<-------------| | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubReq | | | +// | [with RestSUbsId + one additional e2 subDetail] +// |---------------->| | | +// | RESTNotif1 | | | +// | [for initial e2 subDetail] | | +// |<----------------| | | +// | | RouteCreate | | +// | |--------------------------->| +// | | RouteResponse| | +// | |<---------------------------| +// | | SubReq | | +// | |------------->| | +// | | SubResp | | +// | |<-------------| | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubDelReq | | | +// |---------------->| | | +// | RESTSubDelResp| | | +// |<----------------| | | +// | | SubDelReq | | +// | |------------->| | +// | | SubDelResp | | +// | |<-------------| | +// | | SubDelReq | | +// | |------------->| | +// | | SubDelResp | | +// | |<-------------| | +// | RESTSubReq | | | +// | [with RESTsubsId initial request] | +// |---------------->| | | +// | RESTSubResp | | | +// |<----------------| | | +// | | RouteCreate | | +// | |--------------------------->| +// | | RouteResponse| | +// | |<---------------------------| +// | | SubReq | | +// | |------------->| | +// | | SubResp | | +// | |<-------------| | +// | RESTNotif1 | | | +// |<----------------| | | +// | | | | +// +//----------------------------------------------------------------------------- +func TestRESTSubReqRetransmissionV6(t *testing.T) { + CaseBegin("TestRESTSubReqRetransmissionV6") + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 3}, + Counter{cDuplicateE2SubReq, 1}, + Counter{cRestSubRespToXapp, 3}, + Counter{cSubReqToE2, 3}, + Counter{cSubRespFromE2, 3}, + Counter{cRestSubNotifToXapp, 4}, + Counter{cRestSubDelReqFromXapp, 2}, + Counter{cSubDelReqToE2, 3}, + Counter{cSubDelRespFromE2, 3}, + Counter{cRestSubDelRespToXapp, 2}, + }) + + params := xappConn1.GetRESTSubsReqReportParams(subReqCount) + + restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params) + + mainCtrl.WaitOngoingRequestMapEmpty() + + // Send modified requst, this time with e2 subscriptions. + params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1) + params2.SetSubscriptionID(&restSubId) + + xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler) + xappConn1.ExpectAnyNotification(t) + // Resend the original request with an additional e2 subscription (detail), this time with restsubsid + restSubId_resend := xappConn1.SendRESTSubsReq(t, params2) + + e2SubsId1 := xappConn1.WaitAnyRESTNotification(t) + assert.Equal(t, e2SubsId, e2SubsId1) + + crereq2, cremsg2 := e2termConn1.RecvSubsReq(t) + + xappConn1.ExpectRESTNotification(t, restSubId_resend) + e2termConn1.SendSubsResp(t, crereq2, cremsg2) + e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend) + assert.NotEqual(t, e2SubsId2, 0) + + mainCtrl.WaitOngoingRequestMapEmpty() + + // Delete both e2 subscriptions + xappConn1.SendRESTSubsDelReq(t, &restSubId) + e2SubsIds := []uint32{e2SubsId, e2SubsId2} + sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1) + + waitSubsCleanup(t, e2SubsId, 10) + + // Resend the original request, we shall find it's previous md5sum/restsubs + // but the restsubscription has been already removed. This shall trigger a + // fresh create. + restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params) + + mainCtrl.WaitOngoingRequestMapEmpty() + + deleteSubscription(t, xappConn1, e2termConn1, &restSubId) + + waitSubsCleanup(t, e2SubsId, 10) + mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } func TestRESTSubDelReqRetransmission(t *testing.T) { @@ -2668,7 +3483,7 @@ func TestRESTSubDelReqRetransmission(t *testing.T) { Counter{cRestSubDelReqFromXapp, 2}, Counter{cSubDelReqToE2, 1}, Counter{cSubDelRespFromE2, 1}, - Counter{cRestSubDelRespToXapp, 1}, + Counter{cRestSubDelRespToXapp, 2}, }) var params *teststube2ap.RESTSubsReqParams = nil @@ -2689,8 +3504,8 @@ func TestRESTSubDelReqRetransmission(t *testing.T) { e2termConn1.SendSubsDelResp(t, delreq, delmsg) waitSubsCleanup(t, e2SubsId, 10) - mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } //----------------------------------------------------------------------------- @@ -2732,6 +3547,7 @@ func TestRESTSubReqDelReq(t *testing.T) { Counter{cSubRespFromE2, 1}, Counter{cRestSubNotifToXapp, 1}, Counter{cRestSubDelReqFromXapp, 2}, + Counter{cRestSubDelFailToXapp, 1}, Counter{cSubDelReqToE2, 1}, Counter{cSubDelRespFromE2, 1}, Counter{cRestSubDelRespToXapp, 1}, @@ -2761,7 +3577,7 @@ func TestRESTSubReqDelReq(t *testing.T) { // Wait that subs is cleaned waitSubsCleanup(t, e2SubsId, 10) mainCtrl.VerifyCounterValues(t) - + mainCtrl.VerifyAllClean(t) } func TestRESTSubDelReqCollision(t *testing.T) { @@ -2786,12 +3602,12 @@ func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) { //Req1 params := xappConn1.GetRESTSubsReqReportParams(subReqCount) restSubId1 := xappConn1.SendRESTSubsReq(t, params) - xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1) + xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1) //Req2 params = xappConn2.GetRESTSubsReqReportParams(subReqCount) restSubId2 := xappConn2.SendRESTSubsReq(t, params) - xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2) + xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2) crereq1, cremsg1 := e2termConn1.RecvSubsReq(t) crereq2, cremsg2 := e2termConn1.RecvSubsReq(t) @@ -2805,9 +3621,9 @@ func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) { e2termConn1.SendSubsResp(t, crereq2, cremsg2) e2SubsIdA := <-xappConn1.ListedRESTNotifications - xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA) + xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA) e2SubsIdB := <-xappConn1.ListedRESTNotifications - xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB) + xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB) //Del1 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1) @@ -2819,7 +3635,7 @@ func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) { waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10) mainCtrl.VerifyCounterValues(t) - + mainCtrl.VerifyAllClean(t) } func TestRESTSameSubsDiffRan(t *testing.T) { @@ -2839,12 +3655,12 @@ func TestRESTSameSubsDiffRan(t *testing.T) { params := xappConn1.GetRESTSubsReqReportParams(subReqCount) restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params) - xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1) + xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1) params = xappConn1.GetRESTSubsReqReportParams(subReqCount) params.SetMeid("RAN_NAME_2") restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params) - xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2) + xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2) //Del1 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1) @@ -2856,7 +3672,7 @@ func TestRESTSameSubsDiffRan(t *testing.T) { waitSubsCleanup(t, e2SubsId2, 10) mainCtrl.VerifyCounterValues(t) - + mainCtrl.VerifyAllClean(t) } func TestRESTSubReqRetryInSubmgr(t *testing.T) { @@ -2867,6 +3683,7 @@ func TestRESTSubReqRetryInSubmgr(t *testing.T) { Counter{cRestSubReqFromXapp, 1}, Counter{cRestSubRespToXapp, 1}, Counter{cSubReqToE2, 1}, + Counter{cSubReqTimerExpiry, 1}, Counter{cSubReReqToE2, 1}, Counter{cSubRespFromE2, 1}, Counter{cRestSubNotifToXapp, 1}, @@ -2879,11 +3696,11 @@ func TestRESTSubReqRetryInSubmgr(t *testing.T) { params := xappConn1.GetRESTSubsReqReportParams(subReqCount) restSubId := xappConn1.SendRESTSubsReq(t, params) - xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId) + xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId) // Catch the first message and ignore it crereq, cremsg := e2termConn1.RecvSubsReq(t) - xapp.Logger.Info("Ignore REST subscriber request for subscriber : %v", restSubId) + xapp.Logger.Debug("Ignore REST subscriber request for subscriber : %v", restSubId) // The second request is being handled normally crereq, cremsg = e2termConn1.RecvSubsReq(t) @@ -2900,7 +3717,7 @@ func TestRESTSubReqRetryInSubmgr(t *testing.T) { waitSubsCleanup(t, e2SubsId, 10) mainCtrl.VerifyCounterValues(t) - + mainCtrl.VerifyAllClean(t) } //----------------------------------------------------------------------------- @@ -2941,6 +3758,7 @@ func TestRESTSubReqRetryInSubmgr(t *testing.T) { // | | | // //----------------------------------------------------------------------------- + func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) { CaseBegin("TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr start") @@ -2951,30 +3769,34 @@ func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) { Counter{cSubReqToE2, 1}, Counter{cSubReReqToE2, 1}, Counter{cSubReqTimerExpiry, 2}, + Counter{cRestSubFailNotifToXapp, 1}, Counter{cSubDelReqToE2, 1}, Counter{cSubDelRespFromE2, 1}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cRestSubDelRespToXapp, 1}, }) params := xappConn1.GetRESTSubsReqReportParams(subReqCount) restSubId := xappConn1.SendRESTSubsReq(t, params) - xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId) + xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId) e2termConn1.RecvSubsReq(t) - xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId) + xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId) e2termConn1.RecvSubsReq(t) - xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId) + xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId) delreq, delmsg := e2termConn1.RecvSubsDelReq(t) - xappConn1.ExpectRESTNotification(t, restSubId) + xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail") e2termConn1.SendSubsDelResp(t, delreq, delmsg) - // e2SubsId := xappConn1.WaitRESTNotification(t, restSubId) - TODO: Should we delete this? xappConn1.WaitRESTNotification(t, restSubId) + xappConn1.SendRESTSubsDelReq(t, &restSubId) + // Wait that subs is cleaned waitSubsCleanup(t, delreq.RequestId.InstanceId, 10) - mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } func TestREST2eTermNotRespondingToSubReq(t *testing.T) { @@ -2987,33 +3809,38 @@ func TestREST2eTermNotRespondingToSubReq(t *testing.T) { Counter{cSubReqToE2, 1}, Counter{cSubReReqToE2, 1}, Counter{cSubReqTimerExpiry, 2}, + Counter{cSubDelReReqToE2, 1}, + Counter{cRestSubFailNotifToXapp, 1}, Counter{cSubDelReqToE2, 1}, Counter{cSubDelReqTimerExpiry, 2}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cRestSubDelRespToXapp, 1}, }) params := xappConn1.GetRESTSubsReqReportParams(subReqCount) restSubId := xappConn1.SendRESTSubsReq(t, params) - xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId) + xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId) e2termConn1.RecvSubsReq(t) - xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId) + xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId) e2termConn1.RecvSubsReq(t) - xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId) + xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId) e2termConn1.RecvSubsDelReq(t) - xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId) + xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId) - xappConn1.ExpectRESTNotification(t, restSubId) + xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail") e2termConn1.RecvSubsDelReq(t) - xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId) + xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId) e2SubsId := xappConn1.WaitRESTNotification(t, restSubId) - waitSubsCleanup(t, e2SubsId, 10) + xappConn1.SendRESTSubsDelReq(t, &restSubId) + waitSubsCleanup(t, e2SubsId, 10) mainCtrl.VerifyCounterValues(t) - + mainCtrl.VerifyAllClean(t) } //----------------------------------------------------------------------------- @@ -3064,33 +3891,38 @@ func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) { Counter{cSubReqToE2, 1}, Counter{cSubReReqToE2, 1}, Counter{cSubReqTimerExpiry, 2}, + Counter{cRestSubFailNotifToXapp, 1}, Counter{cSubDelReqToE2, 1}, Counter{cSubDelReReqToE2, 1}, Counter{cSubDelReqTimerExpiry, 2}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cRestSubDelRespToXapp, 1}, }) params := xappConn1.GetRESTSubsReqReportParams(subReqCount) restSubId := xappConn1.SendRESTSubsReq(t, params) - xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId) + xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId) e2termConn1.RecvSubsReq(t) - xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId) + xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId) e2termConn1.RecvSubsReq(t) - xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId) + xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId) e2termConn1.RecvSubsDelReq(t) - xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId) + xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId) - xappConn1.ExpectRESTNotification(t, restSubId) + xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail") e2termConn1.RecvSubsDelReq(t) - xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId) + xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId) e2SubsId := xappConn1.WaitRESTNotification(t, restSubId) - waitSubsCleanup(t, e2SubsId, 10) + xappConn1.SendRESTSubsDelReq(t, &restSubId) + waitSubsCleanup(t, e2SubsId, 10) mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } //----------------------------------------------------------------------------- @@ -3112,12 +3944,6 @@ func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) { // | | SubFail | // | |<-------------| // | | | -// | | SubDelReq | -// | |------------->| -// | | | -// | | SubDelResp | -// | |<-------------| -// | | | // | RESTNotif | | // | unsuccess | | // |<----------------| | @@ -3136,23 +3962,26 @@ func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) { Counter{cSubFailFromE2, 1}, Counter{cRestSubFailNotifToXapp, 1}, Counter{cRestSubDelReqFromXapp, 1}, + Counter{cRestSubDelRespToXapp, 1}, }) const subReqCount int = 1 + const e2Timeout int64 = 2 + const e2RetryCount int64 = 1 + const routingNeeded bool = true params := xappConn1.GetRESTSubsReqReportParams(subReqCount) + params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded) restSubId := xappConn1.SendRESTSubsReq(t, params) crereq1, cremsg1 := e2termConn1.RecvSubsReq(t) fparams1 := &teststube2ap.E2StubSubsFailParams{} fparams1.Set(crereq1) + xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail") e2termConn1.SendSubsFail(t, fparams1, cremsg1) - delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t) - xappConn1.ExpectRESTNotification(t, restSubId) - e2termConn1.SendSubsDelResp(t, delreq1, delmsg1) e2SubsId := xappConn1.WaitRESTNotification(t, restSubId) - xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId) + xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId) // REST subscription sill there to be deleted xappConn1.SendRESTSubsDelReq(t, &restSubId) @@ -3161,7 +3990,7 @@ func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) { waitSubsCleanup(t, e2SubsId, 10) mainCtrl.VerifyCounterValues(t) - + mainCtrl.VerifyAllClean(t) } //----------------------------------------------------------------------------- @@ -3202,6 +4031,7 @@ func TestRESTSubDelReqRetryInSubmgr(t *testing.T) { Counter{cRestSubNotifToXapp, 1}, Counter{cRestSubDelReqFromXapp, 1}, Counter{cSubDelReqToE2, 1}, + Counter{cSubDelReqTimerExpiry, 1}, Counter{cSubDelReReqToE2, 1}, Counter{cSubDelRespFromE2, 1}, Counter{cRestSubDelRespToXapp, 1}, @@ -3224,6 +4054,7 @@ func TestRESTSubDelReqRetryInSubmgr(t *testing.T) { waitSubsCleanup(t, e2SubsId, 10) mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } //----------------------------------------------------------------------------- @@ -3262,6 +4093,7 @@ func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) { Counter{cRestSubNotifToXapp, 1}, Counter{cRestSubDelReqFromXapp, 1}, Counter{cSubDelReqToE2, 1}, + Counter{cSubDelReqTimerExpiry, 1}, Counter{cSubDelReReqToE2, 1}, Counter{cSubDelRespFromE2, 1}, Counter{cRestSubDelRespToXapp, 1}, @@ -3285,6 +4117,7 @@ func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) { waitSubsCleanup(t, e2SubsId, 10) mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } //----------------------------------------------------------------------------- @@ -3341,6 +4174,7 @@ func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) { waitSubsCleanup(t, e2SubsId, 10) mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } //----------------------------------------------------------------------------- @@ -3422,13 +4256,13 @@ func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) { params.SetMeid("RAN_NAME_1") xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler) - xappConn2.WaitRESTNotificationForAnySubscriptionId(t) + xappConn2.ExpectAnyNotification(t) waiter := rtmgrHttp.AllocNextSleep(10, true) restSubId2 := xappConn2.SendRESTSubsReq(t, params) waiter.WaitResult(t) - xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2) - e2SubsId2 := <-xappConn2.RESTNotification - xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2) + xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2) + e2SubsId2 := xappConn2.WaitAnyRESTNotification(t) + xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2) queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"}) @@ -3440,8 +4274,8 @@ func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) { //Wait that subs is cleaned waitSubsCleanup(t, e2SubsId2, 10) - mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } //----------------------------------------------------------------------------- @@ -3534,8 +4368,8 @@ func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) { e2termConn1.SendSubsDelResp(t, delreq2, delmsg2) waitSubsCleanup(t, e2SubsId2, 10) - mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } //----------------------------------------------------------------------------- @@ -3558,7 +4392,7 @@ func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) { // | RESTSubReq2 | | // |------------------------------>| | // | | | | -// | RESTSubDelResp2 | | +// | RESTSubResp2 | | // |<------------------------------| | // | | | SubReq1 | // | | |------------->| @@ -3594,15 +4428,18 @@ func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) { mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ Counter{cRestSubReqFromXapp, 2}, + Counter{cMergedSubscriptions, 1}, Counter{cRestSubRespToXapp, 2}, Counter{cSubReqToE2, 1}, + Counter{cSubReqTimerExpiry, 2}, + Counter{cSubReReqToE2, 1}, Counter{cRestSubFailNotifToXapp, 2}, + Counter{cUnmergedSubscriptions, 1}, Counter{cRestSubDelReqFromXapp, 2}, Counter{cSubDelReqToE2, 1}, Counter{cSubDelRespFromE2, 1}, Counter{cRestSubDelRespToXapp, 2}, }) - const subReqCount int = 1 // Req1 @@ -3626,9 +4463,9 @@ func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) { e2termConn1.SendSubsDelResp(t, delreq1, delmsg1) e2SubsIdA := <-xappConn1.ListedRESTNotifications - xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA) + xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA) e2SubsIdB := <-xappConn1.ListedRESTNotifications - xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB) + xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB) // Del1 xappConn1.SendRESTSubsDelReq(t, &restSubId1) @@ -3640,8 +4477,8 @@ func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) { //Wait that subs is cleaned waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10) - mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } //----------------------------------------------------------------------------- @@ -3675,12 +4512,8 @@ func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) { // | RESTNotif2 | | // | | unsuccess | | // |<------------------------------| | -// | | | SubDelReq | -// | | |------------->| -// | | | SubDelResp | -// | | |<-------------| // | | | | -// | | RESTSubDelReq1 | | +// | | RESTSubDelReq1 | | There is no need for xApp to send delete for failed subscriptions but some xApp might do so. // | |---------------->| | // | | | | // | | RESTSubDelResp1 | | @@ -3698,13 +4531,13 @@ func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) { mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ Counter{cRestSubReqFromXapp, 2}, + Counter{cMergedSubscriptions, 1}, Counter{cRestSubRespToXapp, 2}, Counter{cSubReqToE2, 1}, Counter{cSubFailFromE2, 1}, Counter{cRestSubFailNotifToXapp, 2}, + Counter{cUnmergedSubscriptions, 1}, Counter{cRestSubDelReqFromXapp, 2}, - Counter{cSubDelReqToE2, 1}, - Counter{cSubDelRespFromE2, 1}, Counter{cRestSubDelRespToXapp, 2}, }) @@ -3727,15 +4560,11 @@ func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) { fparams1.Set(crereq1) e2termConn1.SendSubsFail(t, fparams1, cremsg1) - // E2t: internal delete - delreq, delmsg := e2termConn1.RecvSubsDelReq(t) xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2}) - e2termConn1.SendSubsDelResp(t, delreq, delmsg) - e2SubsIdA := <-xappConn1.ListedRESTNotifications - xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA) + xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA) e2SubsIdB := <-xappConn1.ListedRESTNotifications - xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB) + xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB) // Del1 xappConn1.SendRESTSubsDelReq(t, &restSubId1) @@ -3746,8 +4575,8 @@ func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) { //Wait that subs is cleaned waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10) waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10) - mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) { @@ -3766,17 +4595,15 @@ func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) { Counter{cRestSubDelRespToXapp, 1}, }) - const subReqCount int = 1 - params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount) restSubId := xappConn1.SendRESTSubsReq(t, params) - xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId) + xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId) crereq1, cremsg1 := e2termConn1.RecvSubsReq(t) xappConn1.ExpectRESTNotification(t, restSubId) e2termConn1.SendSubsResp(t, crereq1, cremsg1) e2SubsId := xappConn1.WaitRESTNotification(t, restSubId) - xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId) + xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId) xappConn1.SendRESTSubsDelReq(t, &restSubId) delreq, delmsg := e2termConn1.RecvSubsDelReq(t) @@ -3785,6 +4612,7 @@ func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) { // Wait that subs is cleaned waitSubsCleanup(t, e2SubsId, 10) mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } //----------------------------------------------------------------------------- @@ -3852,15 +4680,20 @@ func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) { }) const subReqCount int = 1 + const e2Timeout int64 = 1 + const e2RetryCount int64 = 0 + const routingNeeded bool = true // Req params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount) + params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded) restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params) // Policy change - // GetRESTSubsReqPolicyParams sets some coutners on tc side. + // GetRESTSubsReqPolicyParams sets some counters on tc side. params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount) + params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded) params.SetSubscriptionID(&restSubId) params.SetTimeToWait("w200ms") restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params) @@ -3874,6 +4707,7 @@ func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) { // Wait that subs is cleaned waitSubsCleanup(t, e2SubsId, 10) mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } //----------------------------------------------------------------------------- @@ -3901,7 +4735,7 @@ func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) { // | RESTSubReq | | // |---------------->| | // | | | -// | RESTSubUpdateFail | +// | RESTSubUpdateFail(400 Bad request) // | | | // | RESTSubDelReq | | // |---------------->| | @@ -3930,19 +4764,16 @@ func TestRESTSubReqPolicyChangeNOk(t *testing.T) { Counter{cSubDelReqToE2, 1}, Counter{cSubDelRespFromE2, 1}, Counter{cRestSubDelRespToXapp, 1}, - }) - - const subReqCount int = 1 + }) // Req params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount) restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params) // Policy change - params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount) - restSubIdUpd := strings.ToUpper(restSubId) + restSubIdUpd := strings.ToUpper(restSubId) // This makes RESTSubReq to fail params.SetSubscriptionID(&restSubIdUpd) params.SetTimeToWait("w200ms") @@ -3958,6 +4789,7 @@ func TestRESTSubReqPolicyChangeNOk(t *testing.T) { // Wait that subs is cleaned waitSubsCleanup(t, e2SubsId, 10) mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } //----------------------------------------------------------------------------- @@ -4036,13 +4868,13 @@ func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) { xappConn1.ExpectRESTNotification(t, restSubId1) e2termConn1.SendSubsResp(t, crereq1, cremsg1) e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1) - xapp.Logger.Info("TEST: REST notification received e2SubsId1=%v", e2SubsId1) + xapp.Logger.Debug("TEST: REST notification received e2SubsId1=%v", e2SubsId1) // Resp2 xappConn2.ExpectRESTNotification(t, restSubId2) e2termConn2.SendSubsResp(t, crereq2, cremsg2) e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2) - xapp.Logger.Info("TEST: REST notification received e2SubsId2=%v", e2SubsId2) + xapp.Logger.Debug("TEST: REST notification received e2SubsId2=%v", e2SubsId2) // Delete1 xappConn1.SendRESTSubsDelReq(t, &restSubId1) @@ -4061,6 +4893,7 @@ func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) { waitSubsCleanup(t, e2SubsId2, 10) mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } //----------------------------------------------------------------------------- @@ -4088,7 +4921,7 @@ func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) { func TestRESTSubReqAsn1EncodeFail(t *testing.T) { CaseBegin("TestRESTSubReqAsn1EncodeFail") - xapp.Logger.Info("Xapp-frame, v0.8.1 sufficient REST API validation") + xapp.Logger.Debug("Xapp-frame, v0.8.1 sufficient REST API validation") } @@ -4160,6 +4993,7 @@ func TestRESTSubReqInsertAndSubDelOk(t *testing.T) { // Wait that subs is cleaned waitSubsCleanup(t, e2SubsId, 10) mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } //----------------------------------------------------------------------------- @@ -4173,6 +5007,8 @@ func TestRESTSubReqInsertAndSubDelOk(t *testing.T) { // | RESTSubReq | | // |------------->| | // | | | +// | RESTSubResp | | +// |<-------------| | // | | SubReq | // | |------------->| // | | | @@ -4188,6 +5024,15 @@ func TestRESTSubReqInsertAndSubDelOk(t *testing.T) { // | | SubDelResp | // | |<-------------| // | | | +// | RESTNotif | | +// | unsuccess | | +// |<-------------| | +// | | | +// | RESTSubDelReq| | +// |------------->| | +// | | | +// |RESTSubDelResp| | +// |<-------------| | // //----------------------------------------------------------------------------- func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) { @@ -4200,19 +5045,18 @@ func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) { Counter{cSubDelReqFromXapp, 1}, Counter{cSubDelReqToE2, 1}, Counter{cSubDelRespFromE2, 1}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cRestSubDelRespToXapp, 1}, }) const subReqCount int = 1 - // Remove possible existing subscription - mainCtrl.removeExistingSubscriptions(t) - params := xappConn1.GetRESTSubsReqReportParams(subReqCount) //Req mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription restSubId := xappConn1.SendRESTSubsReq(t, params) - xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId) + xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId) e2termConn1.RecvSubsReq(t) @@ -4221,16 +5065,19 @@ func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) { mainCtrl.SimulateRestart(t) xapp.Logger.Debug("mainCtrl.SimulateRestart done") - //Del + // Deleletion of uncompleted subscription delreq, delmsg := e2termConn1.RecvSubsDelReq(t) e2termConn1.SendSubsDelResp(t, delreq, delmsg) + //Del + xappConn1.SendRESTSubsDelReq(t, &restSubId) + xappConn1.TestMsgChanEmpty(t) - xappConn2.TestMsgChanEmpty(t) e2termConn1.TestMsgChanEmpty(t) mainCtrl.wait_registry_empty(t, 10) mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } //----------------------------------------------------------------------------- @@ -4271,6 +5118,7 @@ func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) { // |<----------------| | // //----------------------------------------------------------------------------- + func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) { CaseBegin("TestRESTSubReqAndSubDelOkWithRestartInMiddle") @@ -4282,27 +5130,24 @@ func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) { Counter{cRestSubNotifToXapp, 1}, Counter{cRestSubDelReqFromXapp, 1}, Counter{cSubDelReqToE2, 1}, + Counter{cSubDelRespFromE2, 1}, Counter{cRestSubDelRespToXapp, 1}, }) - // Remove possible existing subscription - mainCtrl.removeExistingSubscriptions(t) - - var params *teststube2ap.RESTSubsReqParams = nil - // Create subscription + var params *teststube2ap.RESTSubsReqParams = nil restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params) - xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId) + xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId) // Check subscription queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"}) - // When SDL support for the REST Interface is added - // the submgr restart statement below should be removed - // from the comment. + mainCtrl.SimulateRestart(t) + xapp.Logger.Debug("mainCtrl.SimulateRestart done") - // mainCtrl.SimulateRestart(t) - // xapp.Logger.Debug("mainCtrl.SimulateRestart done") + // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions()) + // That needs to be completed before successful subscription query is possible + <-time.After(time.Second * 1) // Check subscription queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"}) @@ -4314,6 +5159,7 @@ func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) { waitSubsCleanup(t, e2SubsId, 10) mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } //----------------------------------------------------------------------------- @@ -4387,45 +5233,42 @@ func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) { Counter{cRestSubDelRespToXapp, 2}, }) - // Remove possible existing subscription - mainCtrl.removeExistingSubscriptions(t) - - var params *teststube2ap.RESTSubsReqParams = nil - // Create subscription 1 + var params *teststube2ap.RESTSubsReqParams = nil restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params) - xapp.Logger.Info("Send REST subscriber request for subscriber 1 : %v", restSubId1) + xapp.Logger.Debug("Send REST subscriber request for subscriber 1 : %v", restSubId1) // Create subscription 2 with same action params = xappConn2.GetRESTSubsReqReportParams(subReqCount) params.SetMeid("RAN_NAME_1") xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler) - xappConn2.WaitRESTNotificationForAnySubscriptionId(t) + xappConn2.ExpectAnyNotification(t) restSubId2 := xappConn2.SendRESTSubsReq(t, params) - xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2) - e2SubsId2 := <-xappConn2.RESTNotification - xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2) + xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2) + e2SubsId2 := xappConn2.WaitAnyRESTNotification(t) + xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2) queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"}) - // When SDL support for the REST Interface is added - // the submgr restart statement below should be removed - // from the comment. + mainCtrl.SimulateRestart(t) + xapp.Logger.Debug("mainCtrl.SimulateRestart done 1") - // mainCtrl.SimulateRestart(t) - // xapp.Logger.Debug("mainCtrl.SimulateRestart done") + // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions()) + // That needs to be completed before successful subscription delete is possible + <-time.After(time.Second * 1) // Delete subscription 1, and wait until it has removed the first endpoint - subepcnt := mainCtrl.get_subs_entrypoint_cnt(t, e2SubsId1) xappConn1.SendRESTSubsDelReq(t, &restSubId1) - mainCtrl.wait_subs_entrypoint_cnt_change(t, e2SubsId1, subepcnt, 10) + mainCtrl.WaitRESTSubscriptionDelete(restSubId1) + // Above wait does not work correctly anymore as this delay makes this test case work + + mainCtrl.SimulateRestart(t) + xapp.Logger.Debug("mainCtrl.SimulateRestart done 2") - // When SDL support for the REST Interface is added - // the submgr restart statement below should be removed - // from the comment. + // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions()) + // That needs to be completed before successful subscription query is possible + <-time.After(time.Second * 1) - // mainCtrl.SimulateRestart(t) - // xapp.Logger.Debug("mainCtrl.SimulateRestart done") queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"}) // Delete subscription 2 @@ -4435,6 +5278,7 @@ func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) { waitSubsCleanup(t, e2SubsId2, 10) mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } //----------------------------------------------------------------------------- @@ -4471,25 +5315,38 @@ func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) { // | RESTSubDelReq | | // |---------------->| | // | | | +// | RESTSubDelResp| | +// |<----------------| | // | | SubDelReq | // | |------------->| // | | | // | | SubDelResp | // | |<-------------| // | | | -// | RESTSubDelResp| | -// |<----------------| | // //----------------------------------------------------------------------------- + func TestRESTReportSubReqAndSubDelOk(t *testing.T) { CaseBegin("TestRESTReportSubReqAndSubDelOk") - subReqCount := 1 + const subReqCount int = 1 testIndex := 1 RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex) } func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) { - xapp.Logger.Info("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex) + xapp.Logger.Debug("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex) + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 1}, + Counter{cRestSubRespToXapp, 1}, + Counter{cSubReqToE2, uint64(subReqCount)}, + Counter{cSubRespFromE2, uint64(subReqCount)}, + Counter{cRestSubNotifToXapp, 1}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cRestSubDelRespToXapp, 1}, + Counter{cSubDelReqToE2, uint64(subReqCount)}, + Counter{cSubDelRespFromE2, uint64(subReqCount)}, + }) // Req params := xappConn1.GetRESTSubsReqReportParams(subReqCount) @@ -4502,7 +5359,7 @@ func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) { e2termConn1.SendSubsResp(t, crereq, cremsg) instanceId := xappConn1.WaitRESTNotification(t, restSubId) - xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId) + xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId) e2SubsId = append(e2SubsId, instanceId) resp, _ := xapp.Subscription.QuerySubscriptions() assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId)) @@ -4527,10 +5384,12 @@ func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) { xappConn1.TestMsgChanEmpty(t) e2termConn1.TestMsgChanEmpty(t) mainCtrl.wait_registry_empty(t, 10) + mainCtrl.VerifyAllClean(t) + mainCtrl.VerifyCounterValues(t) } /* -func TestRESTPolicySubReqAndSubDelOk(t *testing.T) { +func TestRESTPolicySubReqAndSubDelOk(t *testing.T) { //Was in comments already. Next case is not run! CaseBegin("TestRESTPolicySubReqAndSubDelOk") subReqCount := 2 @@ -4543,13 +5402,23 @@ func TestRESTPolicySubReqAndSubDelOk(t *testing.T) { } */ func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) { - xapp.Logger.Info("TEST: TestRESTPolicySubReqAndSubDelOk with testIndex %v", testIndex) + xapp.Logger.Debug("TEST: TestRESTPolicySubReqAndSubDelOk with testIndex %v", testIndex) + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 1}, + Counter{cRestSubRespToXapp, 1}, + Counter{cSubReqToE2, uint64(subReqCount)}, + Counter{cSubRespFromE2, uint64(subReqCount)}, + Counter{cRestSubNotifToXapp, 1}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cRestSubDelRespToXapp, 1}, + Counter{cSubDelReqToE2, uint64(subReqCount)}, + Counter{cSubDelRespFromE2, uint64(subReqCount)}, + }) // Req params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount) restSubId := xappConn1.SendRESTSubsReq(t, params) - //params := xappConn1.GetRESTSubsReqPolicyParams1(subReqCount) - //restSubId := xappConn1.SendRESTPolicySubsReq(t, params) var e2SubsId []uint32 for i := 0; i < subReqCount; i++ { @@ -4557,7 +5426,7 @@ func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) { xappConn1.ExpectRESTNotification(t, restSubId) e2termConn1.SendSubsResp(t, crereq, cremsg) instanceId := xappConn1.WaitRESTNotification(t, restSubId) - xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId) + xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId) e2SubsId = append(e2SubsId, instanceId) } @@ -4576,12 +5445,12 @@ func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) { xappConn1.TestMsgChanEmpty(t) e2termConn1.TestMsgChanEmpty(t) mainCtrl.wait_registry_empty(t, 10) + mainCtrl.VerifyAllClean(t) + mainCtrl.VerifyCounterValues(t) } func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) { - subReqCount := 2 - mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ Counter{cRestSubReqFromXapp, 1}, Counter{cRestSubRespToXapp, 1}, @@ -4594,6 +5463,8 @@ func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) { Counter{cRestSubDelRespToXapp, 1}, }) + const subReqCount int = 2 + // Req params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount) restSubId := xappConn1.SendRESTSubsReq(t, params) @@ -4610,11 +5481,10 @@ func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) { mainCtrl.wait_registry_empty(t, 10) mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } func TestRESTPolicySubReqAndSubDelOkFullAmount(t *testing.T) { - subReqCount := 19 - mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ Counter{cRestSubReqFromXapp, 1}, Counter{cRestSubRespToXapp, 1}, @@ -4627,6 +5497,7 @@ func TestRESTPolicySubReqAndSubDelOkFullAmount(t *testing.T) { Counter{cRestSubDelRespToXapp, 1}, }) + const subReqCount int = 19 // Req params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount) restSubId := xappConn1.SendRESTSubsReq(t, params) @@ -4642,7 +5513,9 @@ func TestRESTPolicySubReqAndSubDelOkFullAmount(t *testing.T) { mainCtrl.wait_registry_empty(t, 10) mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } + func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) { subReqCount := 2 @@ -4675,6 +5548,7 @@ func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) { mainCtrl.wait_registry_empty(t, 10) mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) { @@ -4709,6 +5583,7 @@ func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) { mainCtrl.wait_registry_empty(t, 10) mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } func TestRESTFullAmountReportSubReqAndSubDelOk(t *testing.T) { @@ -4743,6 +5618,7 @@ func TestRESTFullAmountReportSubReqAndSubDelOk(t *testing.T) { mainCtrl.wait_registry_empty(t, 10) mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) { @@ -4765,18 +5641,18 @@ func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) { //Subs Create restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params) - xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1) + xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1) queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"}) // Req2 params = xappConn2.GetRESTSubsReqReportParams(subReqCount) params.SetMeid("RAN_NAME_1") - eventTriggerDefinition := "1234" + eventTriggerDefinition := []int64{1234, 1} params.SetSubEventTriggerDefinition(eventTriggerDefinition) restSubId2 := xappConn2.SendRESTSubsReq(t, params) - xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2) + xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2) crereq, cremsg := e2termConn1.RecvSubsReq(t) xappConn2.ExpectRESTNotification(t, restSubId2) e2termConn1.SendSubsResp(t, crereq, cremsg) @@ -4789,7 +5665,7 @@ func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) { waitSubsCleanup(t, e2SubsId2, 10) mainCtrl.VerifyCounterValues(t) - + mainCtrl.VerifyAllClean(t) } func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) { @@ -4812,7 +5688,7 @@ func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) { //Subs Create restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params) - xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1) + xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1) queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"}) @@ -4822,13 +5698,13 @@ func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) { actionId := int64(1) actionType := "report" - actionDefinition := "56781" + actionDefinition := []int64{5678, 1} subsequestActionType := "continue" timeToWait := "w10ms" params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait) restSubId2 := xappConn2.SendRESTSubsReq(t, params) - xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2) + xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2) crereq, cremsg := e2termConn1.RecvSubsReq(t) xappConn2.ExpectRESTNotification(t, restSubId2) e2termConn1.SendSubsResp(t, crereq, cremsg) @@ -4841,7 +5717,7 @@ func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) { waitSubsCleanup(t, e2SubsId2, 10) mainCtrl.VerifyCounterValues(t) - + mainCtrl.VerifyAllClean(t) } func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) { @@ -4864,7 +5740,7 @@ func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) { //Subs Create restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params) - xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1) + xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1) queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"}) @@ -4874,7 +5750,7 @@ func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) { params.SetSubActionIDs(int64(2)) restSubId2 := xappConn2.SendRESTSubsReq(t, params) - xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2) + xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2) crereq, cremsg := e2termConn1.RecvSubsReq(t) xappConn2.ExpectRESTNotification(t, restSubId2) e2termConn1.SendSubsResp(t, crereq, cremsg) @@ -4887,7 +5763,7 @@ func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) { waitSubsCleanup(t, e2SubsId2, 10) mainCtrl.VerifyCounterValues(t) - + mainCtrl.VerifyAllClean(t) } func TestRESTSubReqDiffActionType(t *testing.T) { @@ -4905,21 +5781,27 @@ func TestRESTSubReqDiffActionType(t *testing.T) { Counter{cRestSubDelRespToXapp, 2}, }) + const e2Timeout int64 = 2 + const e2RetryCount int64 = 2 + const routingNeeded bool = true + // Req1 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount) + params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded) //Subs Create restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params) - xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1) + xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1) queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"}) // Req2 params = xappConn2.GetRESTSubsReqReportParams(subReqCount) + params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded) params.SetMeid("RAN_NAME_1") restSubId2 := xappConn2.SendRESTSubsReq(t, params) - xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2) + xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2) crereq, cremsg := e2termConn1.RecvSubsReq(t) xappConn2.ExpectRESTNotification(t, restSubId2) e2termConn1.SendSubsResp(t, crereq, cremsg) @@ -4932,7 +5814,7 @@ func TestRESTSubReqDiffActionType(t *testing.T) { waitSubsCleanup(t, e2SubsId2, 10) mainCtrl.VerifyCounterValues(t) - + mainCtrl.VerifyAllClean(t) } func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) { @@ -4950,21 +5832,27 @@ func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) { Counter{cRestSubDelRespToXapp, 2}, }) + const e2Timeout int64 = 2 + const e2RetryCount int64 = 2 + const routingNeeded bool = true + // Req1 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount) + params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded) //Subs Create restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params) - xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1) + xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1) queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"}) // Req2 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount) + params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded) params.SetMeid("RAN_NAME_1") restSubId2 := xappConn2.SendRESTSubsReq(t, params) - xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2) + xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2) crereq, cremsg := e2termConn1.RecvSubsReq(t) xappConn2.ExpectRESTNotification(t, restSubId2) e2termConn1.SendSubsResp(t, crereq, cremsg) @@ -4977,7 +5865,7 @@ func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) { waitSubsCleanup(t, e2SubsId2, 10) mainCtrl.VerifyCounterValues(t) - + mainCtrl.VerifyAllClean(t) } func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) { @@ -5000,18 +5888,18 @@ func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) { //Subs Create restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params) - xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1) + xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1) queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"}) // Req2 params = xappConn2.GetRESTSubsReqReportParams(subReqCount) params.SetMeid("RAN_NAME_1") - actionDefinition := "5678" + actionDefinition := []int64{5678, 1} params.SetSubActionDefinition(actionDefinition) restSubId2 := xappConn2.SendRESTSubsReq(t, params) - xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2) + xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2) crereq, cremsg := e2termConn1.RecvSubsReq(t) xappConn2.ExpectRESTNotification(t, restSubId2) e2termConn1.SendSubsResp(t, crereq, cremsg) @@ -5024,7 +5912,7 @@ func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) { waitSubsCleanup(t, e2SubsId2, 10) mainCtrl.VerifyCounterValues(t) - + mainCtrl.VerifyAllClean(t) } func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) { @@ -5047,18 +5935,18 @@ func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) { //Subs Create restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params) - xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1) + xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1) queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"}) // Req2 params = xappConn2.GetRESTSubsReqReportParams(subReqCount) params.SetMeid("RAN_NAME_1") - actionDefinition := "56782" + actionDefinition := []int64{56782} params.SetSubActionDefinition(actionDefinition) restSubId2 := xappConn2.SendRESTSubsReq(t, params) - xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2) + xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2) crereq, cremsg := e2termConn1.RecvSubsReq(t) xappConn2.ExpectRESTNotification(t, restSubId2) e2termConn1.SendSubsResp(t, crereq, cremsg) @@ -5071,7 +5959,7 @@ func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) { waitSubsCleanup(t, e2SubsId2, 10) mainCtrl.VerifyCounterValues(t) - + mainCtrl.VerifyAllClean(t) } func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) { @@ -5094,7 +5982,7 @@ func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) { //Subs Create restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params) - xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1) + xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1) queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"}) @@ -5103,7 +5991,7 @@ func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) { params.SetMeid("RAN_NAME_1") params.SetTimeToWait("w200ms") restSubId2 := xappConn2.SendRESTSubsReq(t, params) - xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2) + xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2) crereq, cremsg := e2termConn1.RecvSubsReq(t) xappConn2.ExpectRESTNotification(t, restSubId2) e2termConn1.SendSubsResp(t, crereq, cremsg) @@ -5116,7 +6004,7 @@ func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) { waitSubsCleanup(t, e2SubsId2, 10) mainCtrl.VerifyCounterValues(t) - + mainCtrl.VerifyAllClean(t) } //----------------------------------------------------------------------------- @@ -5137,7 +6025,7 @@ func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) { // | |------------->| // | | | // | | SubResp | ASN.1 decode fails -// | |<-------------| +// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending // | | | // | | SubReq | // | |------------->| @@ -5146,16 +6034,29 @@ func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) { // | |<-------------| // | RESTNotif (fail)| | // |<----------------| | -// | | SubDelReq | -// | |------------->| // | | | -// | | SubDelResp | -// | |<-------------| +// | [SUBS DELETE] | +// | | | // //----------------------------------------------------------------------------- + func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) { - xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseDecodeFail") - subReqCount := 1 + xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseDecodeFail") + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 1}, + Counter{cRestSubRespToXapp, 1}, + Counter{cSubReqToE2, 1}, + Counter{cSubReqTimerExpiry, 1}, + Counter{cSubReReqToE2, 1}, + Counter{cSubRespFromE2, 1}, + Counter{cSubFailFromE2, 1}, + Counter{cRestSubFailNotifToXapp, 1}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cRestSubDelRespToXapp, 1}, + }) + + const subReqCount int = 1 // Req params := xappConn1.GetRESTSubsReqReportParams(subReqCount) @@ -5167,7 +6068,7 @@ func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) { _, cremsg = e2termConn1.RecvSubsReq(t) - xappConn1.ExpectRESTNotification(t, restSubId) + xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail") // Subscription already created in E2 Node. fparams := &teststube2ap.E2StubSubsFailParams{} @@ -5175,11 +6076,10 @@ func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) { 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) + xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId) + + xappConn1.SendRESTSubsDelReq(t, &restSubId) // Wait that subs is cleaned mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10) @@ -5187,6 +6087,8 @@ func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) { xappConn1.TestMsgChanEmpty(t) e2termConn1.TestMsgChanEmpty(t) mainCtrl.wait_registry_empty(t, 10) + mainCtrl.VerifyAllClean(t) + mainCtrl.VerifyCounterValues(t) } //----------------------------------------------------------------------------- @@ -5207,13 +6109,13 @@ func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) { // | |------------->| // | | | // | | SubResp | Unknown instanceId -// | |<-------------| +// | |<-------------| No valid subscription found with subIds [0] // | | | // | | SubReq | // | |------------->| // | | | // | | SubFail | Duplicated action -// | |<-------------| +// | |<-------------| No valid subscription found with subIds [0] // | RESTNotif (fail)| | // |<----------------| | // | | SubDelReq | @@ -5221,11 +6123,31 @@ func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) { // | | | // | | SubDelResp | // | |<-------------| +// | | | +// | [SUBS DELETE] | +// | | | // //----------------------------------------------------------------------------- + func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) { - xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId") - subReqCount := 1 + xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId") + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 1}, + Counter{cRestSubRespToXapp, 1}, + Counter{cSubReqToE2, 1}, + Counter{cSubReqTimerExpiry, 2}, + Counter{cSubReReqToE2, 1}, + Counter{cSubRespFromE2, 1}, + Counter{cSubFailFromE2, 1}, + Counter{cRestSubFailNotifToXapp, 1}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cRestSubDelRespToXapp, 1}, + Counter{cSubDelReqToE2, 1}, + Counter{cSubDelRespFromE2, 1}, + }) + + const subReqCount int = 1 // Req params := xappConn1.GetRESTSubsReqReportParams(subReqCount) @@ -5233,16 +6155,16 @@ func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) { crereq, cremsg := e2termConn1.RecvSubsReq(t) - // Unknown instanceId in this response which will result resending original request + // Unknown instanceId 0 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) + xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail") - // Subscription already created in E2 Node. + // Subscription already created in E2 Node. E2 Node responds with failure but there is also same unknown instanceId 0 fparams := &teststube2ap.E2StubSubsFailParams{} fparams.Set(crereq) fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action @@ -5252,7 +6174,9 @@ func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) { e2termConn1.SendSubsDelResp(t, delreq, delmsg) instanceId := xappConn1.WaitRESTNotification(t, restSubId) - xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId) + xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId) + + xappConn1.SendRESTSubsDelReq(t, &restSubId) // Wait that subs is cleaned mainCtrl.wait_subs_clean(t, orgInstanceId, 10) @@ -5260,6 +6184,8 @@ func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) { xappConn1.TestMsgChanEmpty(t) e2termConn1.TestMsgChanEmpty(t) mainCtrl.wait_registry_empty(t, 10) + mainCtrl.VerifyAllClean(t) + mainCtrl.VerifyCounterValues(t) } //----------------------------------------------------------------------------- @@ -5280,31 +6206,52 @@ func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) { // | |------------->| // | | | // | | SubResp | No transaction for the response -// | |<-------------| +// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending // | | | // | | SubReq | // | |------------->| // | | | // | | SubFail | Duplicated action -// | |<-------------| +// | |<-------------|Ongoing transaction not found. This will result timer expiry and sending delete // | RESTNotif (fail)| | // |<----------------| | // | | SubDelReq | // | |------------->| // | | | // | | SubDelResp | -// | |<-------------| +// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending // | | | // | | SubDelReq | // | |------------->| // | | | // | | SubDelResp | -// | |<-------------| +// | |<-------------| Ongoing transaction not found. +// | | | +// | [SUBS DELETE] | +// | | | // //----------------------------------------------------------------------------- func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) { - xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseNoTransaction") - subReqCount := 1 + xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseNoTransaction") + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 1}, + Counter{cRestSubRespToXapp, 1}, + Counter{cSubReqToE2, 1}, + Counter{cSubReqTimerExpiry, 2}, + Counter{cSubReReqToE2, 1}, + Counter{cSubRespFromE2, 1}, + Counter{cSubFailFromE2, 1}, + Counter{cRestSubFailNotifToXapp, 1}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cRestSubDelRespToXapp, 1}, + Counter{cSubDelReqToE2, 1}, + Counter{cSubDelReqTimerExpiry, 2}, + Counter{cSubDelReReqToE2, 1}, + Counter{cSubDelRespFromE2, 2}, + }) + + const subReqCount int = 1 // Req params := xappConn1.GetRESTSubsReqReportParams(subReqCount) @@ -5318,7 +6265,7 @@ func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) { _, cremsg = e2termConn1.RecvSubsReq(t) - xappConn1.ExpectRESTNotification(t, restSubId) + xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail") // Subscription already created in E2 Node. fparams := &teststube2ap.E2StubSubsFailParams{} @@ -5334,7 +6281,9 @@ func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) { e2termConn1.SendSubsDelResp(t, delreq, delmsg) instanceId := xappConn1.WaitRESTNotification(t, restSubId) - xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId) + xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId) + + xappConn1.SendRESTSubsDelReq(t, &restSubId) // Wait that subs is cleaned mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10) @@ -5342,7 +6291,8 @@ func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) { xappConn1.TestMsgChanEmpty(t) e2termConn1.TestMsgChanEmpty(t) mainCtrl.wait_registry_empty(t, 10) - + mainCtrl.VerifyAllClean(t) + mainCtrl.VerifyCounterValues(t) } //----------------------------------------------------------------------------- @@ -5363,7 +6313,7 @@ func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) { // | |------------->| // | | | // | | SubFail | ASN.1 decode fails -// | |<-------------| +// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending // | | | // | | SubReq | // | |------------->| @@ -5372,16 +6322,27 @@ func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) { // | |<-------------| // | RESTNotif (fail)| | // |<----------------| | -// | | SubDelReq | -// | |------------->| // | | | -// | | SubDelResp | -// | |<-------------| +// | [SUBS DELETE] | +// | | | // //----------------------------------------------------------------------------- func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) { - xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureDecodeFail") - subReqCount := 1 + xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureDecodeFail") + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 1}, + Counter{cRestSubRespToXapp, 1}, + Counter{cSubReqToE2, 1}, + Counter{cSubReqTimerExpiry, 1}, + Counter{cSubReReqToE2, 1}, + Counter{cSubFailFromE2, 2}, + Counter{cRestSubFailNotifToXapp, 1}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cRestSubDelRespToXapp, 1}, + }) + + const subReqCount int = 1 // Req params := xappConn1.GetRESTSubsReqReportParams(subReqCount) @@ -5394,7 +6355,7 @@ func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) { _, cremsg = e2termConn1.RecvSubsReq(t) - xappConn1.ExpectRESTNotification(t, restSubId) + xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail") // Subscription already created in E2 Node. fparams := &teststube2ap.E2StubSubsFailParams{} @@ -5402,11 +6363,10 @@ func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) { 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) + xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId) + + xappConn1.SendRESTSubsDelReq(t, &restSubId) // Wait that subs is cleaned mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10) @@ -5414,6 +6374,8 @@ func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) { xappConn1.TestMsgChanEmpty(t) e2termConn1.TestMsgChanEmpty(t) mainCtrl.wait_registry_empty(t, 10) + mainCtrl.VerifyAllClean(t) + mainCtrl.VerifyCounterValues(t) } //----------------------------------------------------------------------------- @@ -5434,13 +6396,13 @@ func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) { // | |------------->| // | | | // | | SubFail | Unknown instanceId -// | |<-------------| +// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending // | | | // | | SubReq | // | |------------->| // | | | // | | SubFail | Duplicated action -// | |<-------------| +// | |<-------------|No valid subscription found with subIds [0]. This will result timer expiry and sending delete // | RESTNotif (fail)| | // |<----------------| | // | | SubDelReq | @@ -5448,11 +6410,28 @@ func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) { // | | | // | | SubDelResp | // | |<-------------| +// | | | +// | [SUBS DELETE] | +// | | | // //----------------------------------------------------------------------------- func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) { - xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureUnknownInstanceId") - subReqCount := 1 + xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureUnknownInstanceId") + const subReqCount int = 1 + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 1}, + Counter{cRestSubRespToXapp, 1}, + Counter{cSubReqToE2, 1}, + Counter{cSubReqTimerExpiry, 2}, + Counter{cSubReReqToE2, 1}, + Counter{cSubFailFromE2, 2}, + Counter{cRestSubFailNotifToXapp, 1}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cRestSubDelRespToXapp, 1}, + Counter{cSubDelReqToE2, 1}, + Counter{cSubDelRespFromE2, 1}, + }) // Req params := xappConn1.GetRESTSubsReqReportParams(subReqCount) @@ -5460,7 +6439,7 @@ func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) { crereq, cremsg := e2termConn1.RecvSubsReq(t) - // Unknown instanceId in this response which will result resending original request + // Unknown instanceId 0 in this response which will result resending original request fparams := &teststube2ap.E2StubSubsFailParams{} fparams.Set(crereq) fparams.Fail.RequestId.InstanceId = 0 @@ -5468,9 +6447,9 @@ func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) { _, cremsg = e2termConn1.RecvSubsReq(t) - xappConn1.ExpectRESTNotification(t, restSubId) + xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail") - // Subscription already created in E2 Node. + // Subscription already created in E2 Node. E2 Node responds with failure but there is also same unknown instanceId 0 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action e2termConn1.SendSubsFail(t, fparams, cremsg) @@ -5478,7 +6457,9 @@ func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) { e2termConn1.SendSubsDelResp(t, delreq, delmsg) instanceId := xappConn1.WaitRESTNotification(t, restSubId) - xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId) + xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId) + + xappConn1.SendRESTSubsDelReq(t, &restSubId) // Wait that subs is cleaned mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10) @@ -5486,6 +6467,8 @@ func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) { xappConn1.TestMsgChanEmpty(t) e2termConn1.TestMsgChanEmpty(t) mainCtrl.wait_registry_empty(t, 10) + mainCtrl.VerifyAllClean(t) + mainCtrl.VerifyCounterValues(t) } //----------------------------------------------------------------------------- @@ -5506,25 +6489,50 @@ func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) { // | |------------->| // | | | // | | SubFail | No transaction for the response -// | |<-------------| +// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending // | | | // | | SubReq | // | |------------->| // | | | // | | SubFail | Duplicated action -// | |<-------------| +// | |<-------------| Ongoing transaction not found. This will result timer expiry and sending delete // | RESTNotif (fail)| | // |<----------------| | // | | SubDelReq | // | |------------->| // | | | // | | SubDelResp | -// | |<-------------| +// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelResp | +// | |<-------------| Ongoing transaction not found. +// | | | +// | [SUBS DELETE] | +// | | | // //----------------------------------------------------------------------------- func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) { - xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureNoTransaction") - subReqCount := 1 + xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureNoTransaction") + const subReqCount int = 1 + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 1}, + Counter{cRestSubRespToXapp, 1}, + Counter{cSubReqToE2, 1}, + Counter{cSubReqTimerExpiry, 2}, + Counter{cSubReReqToE2, 1}, + Counter{cSubFailFromE2, 2}, + Counter{cRestSubFailNotifToXapp, 1}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cRestSubDelRespToXapp, 1}, + Counter{cSubDelReqToE2, 1}, + Counter{cSubDelReqTimerExpiry, 2}, + Counter{cSubDelReReqToE2, 1}, + Counter{cSubDelRespFromE2, 2}, + }) // Req params := xappConn1.GetRESTSubsReqReportParams(subReqCount) @@ -5541,7 +6549,7 @@ func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) { _, cremsg = e2termConn1.RecvSubsReq(t) - xappConn1.ExpectRESTNotification(t, restSubId) + xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail") // Subscription already created in E2 Node. fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action @@ -5555,7 +6563,9 @@ func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) { e2termConn1.SendSubsDelResp(t, delreq, delmsg) instanceId := xappConn1.WaitRESTNotification(t, restSubId) - xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId) + xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId) + + xappConn1.SendRESTSubsDelReq(t, &restSubId) // Wait that subs is cleaned mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10) @@ -5563,6 +6573,8 @@ func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) { xappConn1.TestMsgChanEmpty(t) e2termConn1.TestMsgChanEmpty(t) mainCtrl.wait_registry_empty(t, 10) + mainCtrl.VerifyAllClean(t) + mainCtrl.VerifyCounterValues(t) } //----------------------------------------------------------------------------- @@ -5585,19 +6597,36 @@ func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) { // | | SubDelReq | // | |------------->| // | | | -// | | SubDelResp | ASN.1 decode fails -// | |<-------------| +// | | SubDelResp | ASN.1 decode fails. +// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending // | | | // | | SubDelReq | // | |------------->| // | | | -// | | SubDelFail | Subscription does exist any more +// | | SubDelFail | Subscription does exist any more in E2 node // | |<-------------| // | | | +// | [SUBS DELETE] | +// | | | // //----------------------------------------------------------------------------- func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) { - xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseDecodeFail") + xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseDecodeFail") + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 1}, + Counter{cRestSubRespToXapp, 1}, + Counter{cSubReqToE2, 1}, + Counter{cSubRespFromE2, 1}, + Counter{cRestSubNotifToXapp, 1}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cRestSubDelRespToXapp, 1}, + Counter{cSubDelReqToE2, 1}, + Counter{cSubDelReqTimerExpiry, 1}, + Counter{cSubDelReReqToE2, 1}, + Counter{cSubDelFailFromE2, 1}, + Counter{cSubDelRespFromE2, 1}, + }) // Req var params *teststube2ap.RESTSubsReqParams = nil @@ -5610,7 +6639,7 @@ func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) { 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) + e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_RESP) // E2t: Receive 2nd SubsDelReq and send SubsDelResp delreq, delmsg = e2termConn1.RecvSubsDelReq(t) @@ -5624,6 +6653,8 @@ func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) { xappConn1.TestMsgChanEmpty(t) e2termConn1.TestMsgChanEmpty(t) mainCtrl.wait_registry_empty(t, 10) + mainCtrl.VerifyAllClean(t) + mainCtrl.VerifyCounterValues(t) } //----------------------------------------------------------------------------- @@ -5647,17 +6678,34 @@ func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) { // | |------------->| // | | | // | | SubDelResp | Unknown instanceId -// | |<-------------| +// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending // | | | // | | SubDelReq | // | |------------->| // | | | -// | | SubDelFail | Subscription does exist any more +// | | SubDelFail | Subscription does exist any more in E2 node // | |<-------------| -// +// | | | +// | [SUBS DELETE] | +// | | | //----------------------------------------------------------------------------- func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) { - xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId") + xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId") + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 1}, + Counter{cRestSubRespToXapp, 1}, + Counter{cSubReqToE2, 1}, + Counter{cSubRespFromE2, 1}, + Counter{cRestSubNotifToXapp, 1}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cRestSubDelRespToXapp, 1}, + Counter{cSubDelReqToE2, 1}, + Counter{cSubDelReqTimerExpiry, 1}, + Counter{cSubDelReReqToE2, 1}, + Counter{cSubDelRespFromE2, 1}, + Counter{cSubDelFailFromE2, 1}, + }) // Req var params *teststube2ap.RESTSubsReqParams = nil @@ -5685,6 +6733,8 @@ func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) { xappConn1.TestMsgChanEmpty(t) e2termConn1.TestMsgChanEmpty(t) mainCtrl.wait_registry_empty(t, 10) + mainCtrl.VerifyAllClean(t) + mainCtrl.VerifyCounterValues(t) } //----------------------------------------------------------------------------- @@ -5708,17 +6758,34 @@ func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) { // | |------------->| // | | | // | | SubDelResp | No transaction for the response -// | |<-------------| +// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending // | | | // | | SubDelReq | // | |------------->| // | | | -// | | SubDelFail | Subscription does exist any more -// | |<-------------| -// +// | | SubDelFail | Subscription does exist any more in E2 node +// | |<-------------| Ongoing transaction not found. This will result timer expiry +// | | | +// | [SUBS DELETE] | +// | | | //----------------------------------------------------------------------------- func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) { - xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseNoTransaction") + xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseNoTransaction") + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 1}, + Counter{cRestSubRespToXapp, 1}, + Counter{cSubReqToE2, 1}, + Counter{cSubRespFromE2, 1}, + Counter{cRestSubNotifToXapp, 1}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cRestSubDelRespToXapp, 1}, + Counter{cSubDelReqToE2, 1}, + Counter{cSubDelReqTimerExpiry, 2}, + Counter{cSubDelReReqToE2, 1}, + Counter{cSubDelRespFromE2, 1}, + Counter{cSubDelFailFromE2, 1}, + }) // Req var params *teststube2ap.RESTSubsReqParams = nil @@ -5747,6 +6814,8 @@ func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) { xappConn1.TestMsgChanEmpty(t) e2termConn1.TestMsgChanEmpty(t) mainCtrl.wait_registry_empty(t, 10) + mainCtrl.VerifyAllClean(t) + mainCtrl.VerifyCounterValues(t) } //----------------------------------------------------------------------------- @@ -5770,17 +6839,33 @@ func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) { // | |------------->| // | | | // | | SubDelFail | ASN.1 decode fails -// | |<-------------| +// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending // | | | // | | SubDelReq | // | |------------->| // | | | -// | | SubDelFail | Subscription does exist any more +// | | SubDelFail | Subscription does exist any more in E2 node // | |<-------------| -// +// | | | +// | [SUBS DELETE] | +// | | | //----------------------------------------------------------------------------- func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) { - xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteFailureDecodeFail") + xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteFailureDecodeFail") + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 1}, + Counter{cRestSubRespToXapp, 1}, + Counter{cSubReqToE2, 1}, + Counter{cSubRespFromE2, 1}, + Counter{cRestSubNotifToXapp, 1}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cRestSubDelRespToXapp, 1}, + Counter{cSubDelReqToE2, 1}, + Counter{cSubDelReqTimerExpiry, 1}, + Counter{cSubDelReReqToE2, 1}, + Counter{cSubDelFailFromE2, 2}, + }) // Req var params *teststube2ap.RESTSubsReqParams = nil @@ -5807,6 +6892,8 @@ func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) { xappConn1.TestMsgChanEmpty(t) e2termConn1.TestMsgChanEmpty(t) mainCtrl.wait_registry_empty(t, 10) + mainCtrl.VerifyAllClean(t) + mainCtrl.VerifyCounterValues(t) } //----------------------------------------------------------------------------- @@ -5830,17 +6917,33 @@ func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) { // | |------------->| // | | | // | | SubDelFail | Unknown instanceId -// | |<-------------| +// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending // | | | // | | SubDelReq | // | |------------->| // | | | -// | | SubDelFail | Subscription does exist any more -// | |<-------------| -// +// | | SubDelFail | Subscription does exist any more in E2 node +// | |<-------------| No valid subscription found with subIds [0]. +// | | | +// | [SUBS DELETE] | +// | | | //----------------------------------------------------------------------------- func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) { - xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId") + xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId") + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 1}, + Counter{cRestSubRespToXapp, 1}, + Counter{cSubReqToE2, 1}, + Counter{cSubRespFromE2, 1}, + Counter{cRestSubNotifToXapp, 1}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cRestSubDelRespToXapp, 1}, + Counter{cSubDelReqToE2, 1}, + Counter{cSubDelReqTimerExpiry, 1}, + Counter{cSubDelReReqToE2, 1}, + Counter{cSubDelFailFromE2, 2}, + }) // Req var params *teststube2ap.RESTSubsReqParams = nil @@ -5852,14 +6955,14 @@ func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) { // E2t: Receive 1st SubsDelReq delreq, delmsg := e2termConn1.RecvSubsDelReq(t) - // Unknown instanceId in this response which will result resending original request + // Unknown instanceId 0 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. + // Subscription does not exist in in E2 Node. E2 Node responds with failure but there is also same unknown instanceId 0 e2termConn1.SendSubsDelFail(t, delreq, delmsg) // Wait that subs is cleaned @@ -5868,6 +6971,8 @@ func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) { xappConn1.TestMsgChanEmpty(t) e2termConn1.TestMsgChanEmpty(t) mainCtrl.wait_registry_empty(t, 10) + mainCtrl.VerifyAllClean(t) + mainCtrl.VerifyCounterValues(t) } //----------------------------------------------------------------------------- @@ -5891,17 +6996,33 @@ func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) { // | |------------->| // | | | // | | SubDelFail | No transaction for the response -// | |<-------------| +// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending // | | | // | | SubDelReq | // | |------------->| // | | | -// | | SubDelFail | Subscription does exist any more -// | |<-------------| -// +// | | SubDelFail | Subscription does exist any more in E2 node +// | |<-------------| Ongoing transaction not found. This will result timer expiry +// | | | +// | [SUBS DELETE] | +// | | | //----------------------------------------------------------------------------- func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) { - xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteFailureNoTransaction") + xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteFailureNoTransaction") + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 1}, + Counter{cRestSubRespToXapp, 1}, + Counter{cSubReqToE2, 1}, + Counter{cSubRespFromE2, 1}, + Counter{cRestSubNotifToXapp, 1}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cRestSubDelRespToXapp, 1}, + Counter{cSubDelReqToE2, 1}, + Counter{cSubDelReqTimerExpiry, 2}, + Counter{cSubDelReReqToE2, 1}, + Counter{cSubDelFailFromE2, 2}, + }) // Req var params *teststube2ap.RESTSubsReqParams = nil @@ -5930,6 +7051,8 @@ func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) { xappConn1.TestMsgChanEmpty(t) e2termConn1.TestMsgChanEmpty(t) mainCtrl.wait_registry_empty(t, 10) + mainCtrl.VerifyAllClean(t) + mainCtrl.VerifyCounterValues(t) } //----------------------------------------------------------------------------- @@ -5967,12 +7090,12 @@ func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) { mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ Counter{cRestSubReqFromXapp, 1}, Counter{cRestSubRespToXapp, 1}, - Counter{cSubDelReqToE2, 1}, - Counter{cSubDelFailFromE2, 1}, Counter{cRestSubFailNotifToXapp, 1}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cRestSubDelRespToXapp, 1}, }) - subReqCount := 1 + const subReqCount int = 1 var params *teststube2ap.RESTSubsReqParams = nil params = xappConn1.GetRESTSubsReqReportParams(subReqCount) @@ -5980,22 +7103,198 @@ func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) { // Req restSubId := xappConn1.SendRESTSubsReq(t, params) - xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId) + xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId) // E2t: Receive SubsDelReq - delreq, delmsg := e2termConn1.RecvSubsDelReq(t) - xappConn1.ExpectRESTNotification(t, restSubId) - - // Subscription does not exist in in E2 Node. - e2termConn1.SendSubsDelFail(t, delreq, delmsg) + xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail") e2SubsId := xappConn1.WaitRESTNotification(t, restSubId) - xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId) + xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId) e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true) + + xappConn1.SendRESTSubsDelReq(t, &restSubId) + // Wait that subs is cleaned waitSubsCleanup(t, e2SubsId, 10) + mainCtrl.VerifyAllClean(t) + mainCtrl.VerifyCounterValues(t) +} + +func TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction(t *testing.T) { + CaseBegin("TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction") + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 2}, + Counter{cRestSubRespToXapp, 2}, + Counter{cSubReqToE2, 2}, + Counter{cSubReqTimerExpiry, 1}, + Counter{cSubRespFromE2, 1}, + Counter{cRestSubNotifToXapp, 1}, + Counter{cRestSubFailNotifToXapp, 1}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cSubDelReqToE2, 1}, + Counter{cSubDelRespFromE2, 1}, + Counter{cRestSubDelRespToXapp, 1}, + }) + + const e2Timeout int64 = 1 + const e2RetryCount int64 = 0 + const routingNeeded bool = false + + // Req1 + params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount) + params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded) + + // Subs Create + restSubId := xappConn1.SendRESTSubsReq(t, params) + xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId) + + crereq1, cremsg1 := e2termConn1.RecvSubsReq(t) + xappConn1.ExpectRESTNotification(t, restSubId) + e2termConn1.SendSubsResp(t, crereq1, cremsg1) + e2SubsId := xappConn1.WaitRESTNotification(t, restSubId) + xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId) + + // Policy change + params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount) + params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded) + params.SetSubscriptionID(&restSubId) + params.SetTimeToWait("w200ms") + restSubId = xappConn1.SendRESTSubsReq(t, params) + xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId) + + crereq1, cremsg1 = e2termConn1.RecvSubsReq(t) + xappConn1.ExpectRESTNotification(t, restSubId) + // SubsResp is missing, e2SubsId will be 0 + zeroE2SubsId := xappConn1.WaitRESTNotification(t, restSubId) + xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", zeroE2SubsId) + + // Del + xappConn1.SendRESTSubsDelReq(t, &restSubId) + delreq, delmsg := e2termConn1.RecvSubsDelReq(t) + e2termConn1.SendSubsDelResp(t, delreq, delmsg) + + waitSubsCleanup(t, e2SubsId, 10) + mainCtrl.VerifyAllClean(t) + mainCtrl.VerifyCounterValues(t) +} + +//----------------------------------------------------------------------------- +// TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | RESTSubReq | | +// |---------------->| | +// | | | +// | RESTSubResp | | +// |<----------------| | +// | | SubReq | +// | |------------->| +// | | | +// | | SubResp | +// | |<-------------| +// | | | +// | RESTNotif | | +// |<----------------| | +// | | | +// | RESTSubReq | | +// |---------------->| | +// | | | +// | RESTSubResp | | +// |<----------------| | +// | | SubReq | +// | |------------->| +// | | +// | Submgr restart | +// | | | +// | RESTSubDelReq | | +// |---------------->| | +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelResp | +// | |<-------------| +// | | | +// | RESTSubDelResp | | +// |<----------------| | +// +//----------------------------------------------------------------------------- + +func TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) { + CaseBegin("TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle") + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 2}, + Counter{cRestSubRespToXapp, 2}, + Counter{cSubReqToE2, 2}, + Counter{cSubRespFromE2, 1}, + Counter{cRestSubNotifToXapp, 1}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cSubDelReqToE2, 1}, + Counter{cSubDelRespFromE2, 1}, + Counter{cRestSubDelRespToXapp, 1}, + }) + + const e2Timeout int64 = 1 + const e2RetryCount int64 = 0 + const routingNeeded bool = false + + // Req1 + params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount) + params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded) + // Create subscription + restSubId := xappConn1.SendRESTSubsReq(t, params) + xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId) + + crereq1, cremsg1 := e2termConn1.RecvSubsReq(t) + xappConn1.ExpectRESTNotification(t, restSubId) + e2termConn1.SendSubsResp(t, crereq1, cremsg1) + e2SubsId := xappConn1.WaitRESTNotification(t, restSubId) + xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId) + + // Check subscription + queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"}) + + // Policy change + params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount) + params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded) + params.SetSubscriptionID(&restSubId) + params.SetTimeToWait("w200ms") + mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription + restSubId = xappConn1.SendRESTSubsReq(t, params) + xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId) + + crereq1, cremsg1 = e2termConn1.RecvSubsReq(t) + mainCtrl.SetResetTestFlag(t, false) + + // SubsResp is missing due to submgr restart + + mainCtrl.SimulateRestart(t) + xapp.Logger.Debug("mainCtrl.SimulateRestart done") + + // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions()) + // That needs to be completed before successful subscription query is possible + <-time.After(time.Second * 1) + + // Check subscription + queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"}) + + // Delete subscription + xappConn1.SendRESTSubsDelReq(t, &restSubId) + delreq, delmsg := e2termConn1.RecvSubsDelReq(t) + e2termConn1.SendSubsDelResp(t, delreq, delmsg) + + //Wait that subs is cleaned + waitSubsCleanup(t, e2SubsId, 10) + mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } //////////////////////////////////////////////////////////////////////////////////// @@ -6009,13 +7308,13 @@ func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2ter params = fromXappConn.GetRESTSubsReqReportParams(subReqCount) } restSubId := fromXappConn.SendRESTSubsReq(t, params) - xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId) + xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId) crereq1, cremsg1 := toE2termConn.RecvSubsReq(t) fromXappConn.ExpectRESTNotification(t, restSubId) toE2termConn.SendSubsResp(t, crereq1, cremsg1) e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId) - xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId) + xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId) return restSubId, e2SubsId } @@ -6029,23 +7328,24 @@ func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) { xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler) restSubId := xappConn2.SendRESTSubsReq(t, params) xappConn2.ExpectRESTNotification(t, restSubId) - xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId) + xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId) e2SubsId := xappConn2.WaitRESTNotification(t, restSubId) - xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId) + xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId) return restSubId, e2SubsId } func createXapp1PolicySubscription(t *testing.T) (string, uint32) { + params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount) restSubId := xappConn1.SendRESTSubsReq(t, params) - xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId) + xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId) crereq1, cremsg1 := e2termConn1.RecvSubsReq(t) xappConn1.ExpectRESTNotification(t, restSubId) e2termConn1.SendSubsResp(t, crereq1, cremsg1) e2SubsId := xappConn1.WaitRESTNotification(t, restSubId) - xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId) + xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId) return restSubId, e2SubsId } @@ -6063,7 +7363,7 @@ func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) { xappConn1.ExpectRESTNotification(t, restSubId) e2termConn1.SendSubsDelResp(t, delreq1, delmsg1) e2SubsId := xappConn1.WaitRESTNotification(t, restSubId) - xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId) + xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId) return restSubId, e2SubsId } @@ -6088,9 +7388,9 @@ func deleteXapp2Subscription(t *testing.T, restSubId *string) { func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) { resp, _ := xapp.Subscription.QuerySubscriptions() - assert.Equal(t, resp[0].SubscriptionID, e2SubsId) - assert.Equal(t, resp[0].Meid, meid) - assert.Equal(t, resp[0].ClientEndpoint, endpoint) + assert.Equal(t, e2SubsId, resp[0].SubscriptionID) + assert.Equal(t, meid, resp[0].Meid) + assert.Equal(t, endpoint, resp[0].ClientEndpoint) } func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) { @@ -6108,14 +7408,14 @@ func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *test var e2SubsId []uint32 for i := 0; i < count; i++ { - xapp.Logger.Info("TEST: %d ===================================== BEGIN CRE ============================================", i+1) + xapp.Logger.Debug("TEST: %d ===================================== BEGIN CRE ============================================", i+1) crereq, cremsg := toE2termConn.RecvSubsReq(t) fromXappConn.ExpectRESTNotification(t, restSubId) toE2termConn.SendSubsResp(t, crereq, cremsg) instanceId := fromXappConn.WaitRESTNotification(t, restSubId) e2SubsId = append(e2SubsId, instanceId) - xapp.Logger.Info("TEST: %v", e2SubsId) - xapp.Logger.Info("TEST: %d ===================================== END CRE ============================================", i+1) + xapp.Logger.Debug("TEST: %v", e2SubsId) + xapp.Logger.Debug("TEST: %d ===================================== END CRE ============================================", i+1) <-time.After(100 * time.Millisecond) } return e2SubsId @@ -6124,11 +7424,11 @@ func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *test func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) { for i := 0; i < len(e2SubsIds); i++ { - xapp.Logger.Info("TEST: %d ===================================== BEGIN DEL ============================================", i+1) + xapp.Logger.Debug("TEST: %d ===================================== BEGIN DEL ============================================", i+1) delreq, delmsg := toE2termConn.RecvSubsDelReq(t) toE2termConn.SendSubsDelResp(t, delreq, delmsg) <-time.After(1 * time.Second) - xapp.Logger.Info("TEST: %d ===================================== END DEL ============================================", i+1) + xapp.Logger.Debug("TEST: %d ===================================== END DEL ============================================", i+1) <-time.After(100 * time.Millisecond) }