X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fcontrol%2Fut_messaging_test.go;h=538e214dba34014b3d39de1542af26a6032dd9d2;hb=d3fb160ffdb3b1d287facf0cbf4f425801e82bcd;hp=b4edc3f936f2f5bc4a219ce2e8e4bfc57d44622c;hpb=2738517925ce36e7a107bd0779ca998018e78991;p=ric-plt%2Fsubmgr.git diff --git a/pkg/control/ut_messaging_test.go b/pkg/control/ut_messaging_test.go index b4edc3f..538e214 100644 --- a/pkg/control/ut_messaging_test.go +++ b/pkg/control/ut_messaging_test.go @@ -20,6 +20,8 @@ package control import ( + "encoding/json" + "fmt" "strings" "testing" "time" @@ -431,7 +433,7 @@ func TestRESTSubReqAndE1apDeleteReqPackingError(t *testing.T) { } //----------------------------------------------------------------------------- -// TestRESTSubReqAndE1apDeleteRespUnpackingError +// TestRESTSubReqAndE2APDeleteRespUnpackingError // // stub stub stub // +-------+ +---------+ +---------+ +---------+ @@ -475,7 +477,7 @@ func TestRESTSubReqAndE1apDeleteReqPackingError(t *testing.T) { // //----------------------------------------------------------------------------- -func TestRESTSubReqAndE1apDeleteRespUnpackingError(t *testing.T) { +func TestRESTSubReqAndE2APDeleteRespUnpackingError(t *testing.T) { restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil) @@ -879,6 +881,98 @@ func TestSubReqAndSubDelOk(t *testing.T) { mainCtrl.VerifyCounterValues(t) } +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// TestSubReqAndSubDelOkOutofOrderIEs +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | SubReq | | +// |------------->| | +// | | | +// | | SubReq | +// | |------------->| +// | | | +// | | SubResp | (Out of Order IEs) +// | |<-------------| +// | | | +// | SubResp | | +// |<-------------| | +// | | | +// | | | +// | SubDelReq | | +// |------------->| | +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelResp | +// | |<-------------| +// | | | +// | SubDelResp | | +// |<-------------| | +// +//----------------------------------------------------------------------------- + +func TestSubReqAndSubDelOkOutofOrderIEs(t *testing.T) { + CaseBegin("TestSubReqAndSubDelOkOutofOrderIEs") + + mainCtrl.c.e2ap.SetE2IEOrderCheck(0) + // Init counter check + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cSubReqFromXapp, 1}, + Counter{cSubReqToE2, 1}, + Counter{cSubRespFromE2, 1}, + Counter{cSubRespToXapp, 1}, + Counter{cSubDelReqFromXapp, 1}, + Counter{cSubDelReqToE2, 1}, + Counter{cSubDelRespFromE2, 1}, + Counter{cSubDelRespToXapp, 1}, + }) + + cretrans := xappConn1.SendSubsReq(t, nil, nil) + if cretrans == nil { + t.Logf("Could not send SubsReq") + t.FailNow() + } + crereq, cremsg := e2termConn1.RecvSubsReq(t) + if crereq == nil || cremsg == nil { + t.Logf("Could not recieve SubsReq") + t.FailNow() + } + + e2termConn1.SendSubsResp(t, crereq, cremsg) + + e2SubsId := xappConn1.RecvSubsResp(t, cretrans) + resp, _ := xapp.Subscription.QuerySubscriptions() + assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId)) + assert.Equal(t, resp[0].Meid, "RAN_NAME_1") + assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"}) + + deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId) + delreq, delmsg := e2termConn1.RecvSubsDelReq(t) + + e2termConn1.SendSubsDelResp(t, delreq, delmsg) + xappConn1.RecvSubsDelResp(t, deltrans) + + //Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, e2SubsId, 10) + + xappConn1.TestMsgChanEmpty(t) + xappConn2.TestMsgChanEmpty(t) + e2termConn1.TestMsgChanEmpty(t) + mainCtrl.wait_registry_empty(t, 10) + + mainCtrl.VerifyCounterValues(t) + mainCtrl.c.e2ap.SetE2IEOrderCheck(1) +} + +//----------------------------------------------------------------------------- + //----------------------------------------------------------------------------- // TestSubReqRetransmission // @@ -1509,6 +1603,64 @@ func TestSubReqSubFailRespInSubmgr(t *testing.T) { mainCtrl.VerifyCounterValues(t) } +//----------------------------------------------------------------------------- +// TestSubReqSubFailRespInSubmgrOutofOrderIEs +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | SubReq | | +// |------------->| | +// | | | +// | | SubReq | +// | |------------->| +// | | | +// | | SubFail | (Out of Order IEs) +// | |<-------------| +// | | | +// | SubFail | | +// |<-------------| | +// | | | +// +//----------------------------------------------------------------------------- + +func TestSubReqSubFailRespInSubmgrOutofOrderIEs(t *testing.T) { + CaseBegin("TestSubReqSubFailRespInSubmgrOutofOrderIEs start") + + mainCtrl.c.e2ap.SetE2IEOrderCheck(0) + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cSubReqFromXapp, 1}, + Counter{cSubReqToE2, 1}, + Counter{cSubFailFromE2, 1}, + Counter{cSubFailToXapp, 1}, + }) + + // Xapp: Send SubsReq + cretrans := xappConn1.SendSubsReq(t, nil, nil) + + // E2t: Receive SubsReq and send SubsFail (first) + crereq1, cremsg1 := e2termConn1.RecvSubsReq(t) + fparams1 := &teststube2ap.E2StubSubsFailParams{} + fparams1.Set(crereq1) + e2termConn1.SendSubsFail(t, fparams1, cremsg1) + + // Xapp: Receive SubsFail + e2SubsId := xappConn1.RecvSubsFail(t, cretrans) + + // Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, e2SubsId, 10) + + xappConn1.TestMsgChanEmpty(t) + xappConn2.TestMsgChanEmpty(t) + e2termConn1.TestMsgChanEmpty(t) + mainCtrl.wait_registry_empty(t, 10) + + mainCtrl.VerifyCounterValues(t) + mainCtrl.c.e2ap.SetE2IEOrderCheck(1) +} + //----------------------------------------------------------------------------- // TestSubDelReqRetryInSubmgr // @@ -1695,6 +1847,75 @@ func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) { mainCtrl.VerifyCounterValues(t) } +//----------------------------------------------------------------------------- +// TestSubDelReqSubDelFailRespInSubmgrOutofOrderIEs +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | [SUBS CREATE] | +// | | | +// | | | +// | SubDelReq | | +// |------------->| | +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelFail | (Out of Order IEs) +// | |<-------------| +// | | | +// | SubDelResp | | +// |<-------------| | +// | | | +// +//----------------------------------------------------------------------------- + +func TestSubDelReqSubDelFailRespInSubmgrOutofOrderIEs(t *testing.T) { + CaseBegin("TestSubReqSubDelFailRespInSubmgr start") + + mainCtrl.c.e2ap.SetE2IEOrderCheck(0) + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cSubReqFromXapp, 1}, + Counter{cSubReqToE2, 1}, + Counter{cSubRespFromE2, 1}, + Counter{cSubRespToXapp, 1}, + Counter{cSubDelReqFromXapp, 1}, + Counter{cSubDelReqToE2, 1}, + Counter{cSubDelFailFromE2, 1}, + Counter{cSubDelRespToXapp, 1}, + }) + + // Subs Create + cretrans := xappConn1.SendSubsReq(t, nil, nil) + crereq, cremsg := e2termConn1.RecvSubsReq(t) + e2termConn1.SendSubsResp(t, crereq, cremsg) + e2SubsId := xappConn1.RecvSubsResp(t, cretrans) + + // Xapp: Send SubsDelReq + deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId) + + // E2t: Send receive SubsDelReq and send SubsDelFail + delreq, delmsg := e2termConn1.RecvSubsDelReq(t) + e2termConn1.SendSubsDelFail(t, delreq, delmsg) + + // Xapp: Receive SubsDelResp + xappConn1.RecvSubsDelResp(t, deltrans) + + // Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, e2SubsId, 10) + + xappConn1.TestMsgChanEmpty(t) + xappConn2.TestMsgChanEmpty(t) + e2termConn1.TestMsgChanEmpty(t) + mainCtrl.wait_registry_empty(t, 10) + + mainCtrl.VerifyCounterValues(t) + mainCtrl.c.e2ap.SetE2IEOrderCheck(1) +} + //----------------------------------------------------------------------------- // TestSubReqAndSubDelOkSameAction // @@ -2618,41 +2839,329 @@ func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) { //***************************************************************************** //----------------------------------------------------------------------------- -// Test debug GET and POST requests +// Test debug GET and POST requests +// +// curl +// +-------+ +---------+ +// | user | | submgr | +// +-------+ +---------+ +// | | +// | GET/POST Req | +// |------------->| +// | Resp | +// |<-------------| +// | | +func TestGetSubscriptions(t *testing.T) { + + mainCtrl.SendGetRequest(t, "localhost:8088", "/ric/v1/subscriptions") +} + +func TestGetSymptomData(t *testing.T) { + + mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/symptomdata") +} + +func TestPostdeleteSubId(t *testing.T) { + + mainCtrl.SendPostRequest(t, "localhost:8080", "/ric/v1/test/deletesubid=1") +} + +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") +} + +//----------------------------------------------------------------------------- +// TestDelAllE2nodeSubsViaDebugIf +// +// stub stub stub +// +-------+ +---------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | | rtmgr | +// +-------+ +---------+ +---------+ +---------+ +// | | | | +// | RESTSubReq | | | +// |---------------->| | | +// | RESTSubResp | | | +// |<----------------| | | +// | | RouteCreate | | +// | |--------------------------->| +// | | RouteResponse| | +// | |<---------------------------| +// | | SubReq | | +// | |------------->| | +// | | SubResp | | +// | |<-------------| | +// | RESTNotif1 | | | +// |<----------------| | | +// | | | | +// | REST get_all_e2nodes | | +// |---------------->| | | +// | OK 200 | | | +// |<----------------| | | +// | REST delete_all_e2node_subscriptions | ranName = RAN_NAME_1 +// |---------------->| | | +// | OK 200 | | | +// |<----------------| | | +// | | SubDelReq | | +// | |------------->| | +// | | SubDelResp | | +// | |<-------------| | +// | | | | +// | | RouteDelete | | +// | |--------------------------->| +// | | RouteResponse| | +// | |<---------------------------| +// +//----------------------------------------------------------------------------- + +func TestDelAllE2nodeSubsViaDebugIf(t *testing.T) { + + // Init counter check + 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}, + }) + + params := xappConn1.GetRESTSubsReqReportParams(subReqCount) + restSubId := xappConn1.SendRESTSubsReq(t, params) + 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.Debug("REST notification received e2SubsId=%v", e2SubsId) + + e2nodesJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_all_e2nodes") + + var e2nodesList []string + err := json.Unmarshal(e2nodesJson, &e2nodesList) + if err != nil { + t.Errorf("Unmarshal error: %s", err) + } + assert.Equal(t, true, mainCtrl.VerifyStringExistInSlice("RAN_NAME_1", e2nodesList)) + + e2RestSubsJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_e2node_rest_subscriptions/RAN_NAME_1") // RAN_NAME_1 = ranName + var e2RestSubsMap map[string]RESTSubscription + err = json.Unmarshal(e2RestSubsJson, &e2RestSubsMap) + if err != nil { + t.Errorf("Unmarshal error: %s", err) + } + + if len(e2RestSubsMap) != 1 { + t.Errorf("Incorrect e2RestSubsMap length %v", len(e2RestSubsMap)) + } + + // Simulate deletion through REST test and debug interface + mainCtrl.SendDeleteRequest(t, "localhost:8080", "/ric/v1/delete_all_e2node_subscriptions/RAN_NAME_1") // RAN_NAME_1 = ranName + 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) +} + +//----------------------------------------------------------------------------- +// TestDelAllxAppSubsViaDebugIf +// +// stub stub stub +// +-------+ +---------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | | rtmgr | +// +-------+ +---------+ +---------+ +---------+ +// | | | | +// | RESTSubReq | | | +// |---------------->| | | +// | RESTSubResp | | | +// |<----------------| | | +// | | RouteCreate | | +// | |--------------------------->| +// | | RouteResponse| | +// | |<---------------------------| +// | | SubReq | | +// | |------------->| | +// | | SubResp | | +// | |<-------------| | +// | RESTNotif1 | | | +// |<----------------| | | +// | | | | +// | REST get_all_xapps | | +// |---------------->| | | +// | OK 200 | | | +// |<----------------| | | +// | REST delete_all_xapp_subscriptions | xappServiceName = localhost +// |---------------->| | | +// | OK 200 | | | +// |<----------------| | | +// | | SubDelReq | | +// | |------------->| | +// | | SubDelResp | | +// | |<-------------| | +// | | | | +// | | RouteDelete | | +// | |--------------------------->| +// | | RouteResponse| | +// | |<---------------------------| +// +//----------------------------------------------------------------------------- + +func TestDelAllxAppSubsViaDebugIf(t *testing.T) { + + // Init counter check + 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}, + }) + + params := xappConn1.GetRESTSubsReqReportParams(subReqCount) + restSubId := xappConn1.SendRESTSubsReq(t, params) + 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.Debug("REST notification received e2SubsId=%v", e2SubsId) + + xappsJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_all_xapps") + + var xappList []string + err := json.Unmarshal(xappsJson, &xappList) + if err != nil { + t.Errorf("Unmarshal error: %s", err) + } + assert.Equal(t, true, mainCtrl.VerifyStringExistInSlice("localhost", xappList)) + + // Simulate deletion through REST test and debug interface + mainCtrl.SendDeleteRequest(t, "localhost:8080", "/ric/v1/delete_all_xapp_subscriptions/localhost") // localhost = xappServiceName + 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) +} + +//----------------------------------------------------------------------------- +// TestDelViaxAppSubsIf // -// curl -// +-------+ +---------+ -// | user | | submgr | -// +-------+ +---------+ -// | | -// | GET/POST Req | -// |------------->| -// | Resp | -// |<-------------| -// | | -func TestGetSubscriptions(t *testing.T) { +// stub stub stub +// +-------+ +---------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | | rtmgr | +// +-------+ +---------+ +---------+ +---------+ +// | | | | +// | RESTSubReq | | | +// |---------------->| | | +// | RESTSubResp | | | +// |<----------------| | | +// | | RouteCreate | | +// | |--------------------------->| +// | | RouteResponse| | +// | |<---------------------------| +// | | SubReq | | +// | |------------->| | +// | | SubResp | | +// | |<-------------| | +// | RESTNotif1 | | | +// |<----------------| | | +// | | | | +// | REST get_xapp_rest_restsubscriptions | +// |---------------->| | | +// | OK 200 | | | +// |<----------------| | | +// | RESTSudDel | | | +// |---------------->| | | Via user curl command (port 8088) +// | RESTSudDel | | | +// |<----------------| | | +// | | SubDelReq | | +// | |------------->| | +// | | SubDelResp | | +// | |<-------------| | +// | | | | +// | | RouteDelete | | +// | |--------------------------->| +// | | RouteResponse| | +// | |<---------------------------| +// +//----------------------------------------------------------------------------- - mainCtrl.sendGetRequest(t, "localhost:8088", "/ric/v1/subscriptions") -} +func TestDelViaxAppSubsIf(t *testing.T) { -func TestGetSymptomData(t *testing.T) { + // Init counter check + 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}, + }) - mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/symptomdata") -} + params := xappConn1.GetRESTSubsReqReportParams(subReqCount) + restSubId := xappConn1.SendRESTSubsReq(t, params) + xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId) -func TestPostdeleteSubId(t *testing.T) { + 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) - mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/deletesubid=1") -} + restSubsListJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_xapp_rest_restsubscriptions/localhost") // localhost = xappServiceName -func TestPostEmptyDb(t *testing.T) { + var restSubsMap map[string]RESTSubscription + err := json.Unmarshal(restSubsListJson, &restSubsMap) + if err != nil { + t.Errorf("Unmarshal error: %s", err) + } + _, ok := restSubsMap[restSubId] + if !ok { + t.Errorf("REST subscription not found. restSubId=%s", restSubId) + } - mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/emptydb") -} + var e2Subscriptions []Subscription + e2SubscriptionsJson := mainCtrl.SendGetRequest(t, "localhost:8080", "/ric/v1/get_e2subscriptions/"+restSubId) + err = json.Unmarshal(e2SubscriptionsJson, &e2Subscriptions) + if err != nil { + t.Errorf("Unmarshal error: %s", err) + } + if len(e2Subscriptions) != 1 { + t.Errorf("Incorrect e2Subscriptions length %v", len(e2Subscriptions)) + } -func TestGetRestSubscriptions(t *testing.T) { + // Simulate deletion through xapp REST test interface + mainCtrl.SendDeleteRequest(t, "localhost:8088", "/ric/v1/subscriptions/"+restSubId) + delreq, delmsg := e2termConn1.RecvSubsDelReq(t) + e2termConn1.SendSubsDelResp(t, delreq, delmsg) - mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/restsubscriptions") + // Wait that subs is cleaned + waitSubsCleanup(t, e2SubsId, 10) + mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) } //----------------------------------------------------------------------------- @@ -3961,6 +4470,7 @@ func TestRESTSameSubsDiffRan(t *testing.T) { // | RESTSubResp | | // |<----------------| | // | | SubReq | +// | |------------->| // | | | // | | | // | | SubReq | @@ -4325,6 +4835,83 @@ func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) { mainCtrl.VerifyAllClean(t) } +//----------------------------------------------------------------------------- +// TestRESTSubReqPartialResp +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | RESTSubReq | | +// |---------------->| | +// | RESTSubResp | | +// |<----------------| | +// | | SubReq | +// | |------------->| +// | | SubResp | Partially accepted +// | |<-------------| +// | | | +// | RESTNotif | | +// |<----------------| | +// | | | +// | [SUBS DELETE] | +// | | | +// +//----------------------------------------------------------------------------- + +func TestRESTSubReqPartialResp(t *testing.T) { + + // Init counter check + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 1}, + Counter{cRestSubRespToXapp, 1}, + Counter{cSubReqToE2, 1}, + Counter{cSubRespFromE2, 1}, + Counter{cPartialSubRespFromE2, 1}, + Counter{cRestSubNotifToXapp, 1}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cSubDelReqToE2, 1}, + Counter{cSubDelRespFromE2, 1}, + Counter{cRestSubDelRespToXapp, 1}, + }) + + // Req + params := xappConn1.GetRESTSubsReqReportParams(subReqCount) + + actionId := int64(2) + actionType := "report" + actionDefinition := []int64{5678, 1} + subsequestActionType := "continue" + timeToWait := "w10ms" + params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait) + + restSubId := xappConn1.SendRESTSubsReq(t, params) + crereq, cremsg := e2termConn1.RecvSubsReq(t) + xappConn1.ExpectRESTNotification(t, restSubId) + + actionNotAdmittedItem := e2ap.ActionNotAdmittedItem{} + actionNotAdmittedItem.ActionId = 1 + actionNotAdmittedItem.Cause.Content = 1 + actionNotAdmittedItem.Cause.Value = 8 + actionNotAdmittedList := e2ap.ActionNotAdmittedList{} + actionNotAdmittedList.Items = append(actionNotAdmittedList.Items, actionNotAdmittedItem) + e2termConn1.SendPartialSubsResp(t, crereq, cremsg, actionNotAdmittedList) + e2SubsId := xappConn1.WaitRESTNotification(t, restSubId) + + queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"}) + + // Del + deleteSubscription(t, xappConn1, e2termConn1, &restSubId) + + mainCtrl.wait_subs_clean(t, e2SubsId, 10) + //Wait that subs is cleaned + waitSubsCleanup(t, e2SubsId, 10) + + mainCtrl.VerifyCounterValues(t) + mainCtrl.VerifyAllClean(t) +} + //----------------------------------------------------------------------------- // TestRESTSubDelReqRetryInSubmgr // @@ -5076,6 +5663,117 @@ func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) { mainCtrl.VerifyAllClean(t) } +//----------------------------------------------------------------------------- +// TestRESTSubReqPolicyChangeNokAndSubDelOk +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | RESTSubReq | | +// |---------------->| | +// | | | +// | RESTSubResp | | +// |<----------------| | +// | | SubReq | +// | |------------->| +// | | | +// | | SubResp | +// | |<-------------| +// | | | +// | RESTNotif | | +// |<----------------| | +// | | | +// | RESTSubReq | | +// |---------------->| | +// | | | +// | RESTSubResp | | +// |<----------------| | +// | | SubReq | +// | |------------->| +// | | | +// | | SubFail | +// | |<-------------| +// | | | +// | RESTNotif | | +// |<----------------| | +// | | | +// | RESTSubDelReq | | +// |---------------->| | +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelResp | +// | |<-------------| +// | | | +// | RESTSubDelResp | | +// |<----------------| | +// +//----------------------------------------------------------------------------- + +func TestRESTSubReqPolicyChangeNokAndSubDelOk(t *testing.T) { + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 2}, + Counter{cRestSubRespToXapp, 2}, + Counter{cSubReqToE2, 2}, + Counter{cSubRespFromE2, 1}, + Counter{cSubFailFromE2, 1}, + Counter{cRestSubNotifToXapp, 1}, + Counter{cRestSubFailNotifToXapp, 1}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cSubDelReqToE2, 1}, + Counter{cSubDelRespFromE2, 1}, + Counter{cRestSubDelRespToXapp, 1}, + }) + + const subReqCount int = 1 + const e2Timeout int64 = 1 + const e2RetryCount int64 = 0 + const routingNeeded bool = false + + // Req + params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount) + params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded) + restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params) + fmt.Printf("restSubId: %v", restSubId) + + // Policy change + // GetRESTSubsReqPolicyParams sets some counters on tc side. + params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount) + params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded) + params.SetSubscriptionID(&restSubId) + params.SetTimeToWait("w200ms") + + restSubId = xappConn1.SendRESTSubsReq(t, params) + fmt.Printf("restSubId: %v", restSubId) + + crereq, cremsg := e2termConn1.RecvSubsReq(t) + xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail") + + // Gnb sends RICSubscriptionFailure + fparams := &teststube2ap.E2StubSubsFailParams{} + fparams.Set(crereq) + fparams.SetCauseVal(0, 1, 5) // CauseRIC / function-resource-limit + e2termConn1.SendSubsFail(t, fparams, cremsg) + + instanceId := xappConn1.WaitRESTNotification(t, restSubId) + xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId) + + // Del + 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) +} + //----------------------------------------------------------------------------- // TestRESTSubReqPolicyChangeNOk //