X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fcontrol%2Fmessaging_test.go;h=007a432de621d710142a2f0f34b2f54f42628512;hb=422d018f94aedd9f4c001176b5ff06c786de28eb;hp=2f7bc4a580614d2f591d0e861e45433dae716412;hpb=8527f3b2ba74bd7bccb8d67acc952e23f5664e6c;p=ric-plt%2Fsubmgr.git diff --git a/pkg/control/messaging_test.go b/pkg/control/messaging_test.go index 2f7bc4a..007a432 100644 --- a/pkg/control/messaging_test.go +++ b/pkg/control/messaging_test.go @@ -115,6 +115,7 @@ func (xappConn *testingXappControl) handle_xapp_subs_resp(t *testing.T, trans *x //--------------------------------- select { case msg := <-xappConn.rmrConChan: + xappConn.DecMsgCnt() if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_RESP"] { testError(t, "(%s) Received RIC_SUB_RESP wrong mtype expected %s got %s, error", xappConn.desc, "RIC_SUB_RESP", xapp.RicMessageTypeToName[msg.Mtype]) return -1 @@ -158,6 +159,7 @@ func (xappConn *testingXappControl) handle_xapp_subs_fail(t *testing.T, trans *x //------------------------------- select { case msg := <-xappConn.rmrConChan: + xappConn.DecMsgCnt() if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_FAILURE"] { testError(t, "(%s) Received RIC_SUB_FAILURE wrong mtype expected %s got %s, error", xappConn.desc, "RIC_SUB_FAILURE", xapp.RicMessageTypeToName[msg.Mtype]) return -1 @@ -246,6 +248,7 @@ func (xappConn *testingXappControl) handle_xapp_subs_del_resp(t *testing.T, tran //--------------------------------- select { case msg := <-xappConn.rmrConChan: + xappConn.DecMsgCnt() if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_DEL_RESP"] { testError(t, "(%s) Received RIC_SUB_DEL_RESP wrong mtype expected %s got %s, error", xappConn.desc, "RIC_SUB_DEL_RESP", xapp.RicMessageTypeToName[msg.Mtype]) return @@ -283,6 +286,7 @@ func (e2termConn *testingE2termControl) handle_e2term_subs_req(t *testing.T) (*e //--------------------------------- select { case msg := <-e2termConn.rmrConChan: + e2termConn.DecMsgCnt() if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_REQ"] { testError(t, "(%s) Received wrong mtype expected %s got %s, error", e2termConn.desc, "RIC_SUB_REQ", xapp.RicMessageTypeToName[msg.Mtype]) } else { @@ -342,10 +346,11 @@ func (e2termConn *testingE2termControl) handle_e2term_subs_resp(t *testing.T, re params := &RMRParams{&xapp.RMRParams{}} params.Mtype = xapp.RIC_SUB_RESP - params.SubId = msg.SubId + //params.SubId = msg.SubId + params.SubId = -1 params.Payload = packedMsg.Buf params.Meid = msg.Meid - params.Xid = msg.Xid + //params.Xid = msg.Xid params.Mbuf = nil snderr := e2termConn.RmrSend(params) @@ -411,6 +416,7 @@ func (e2termConn *testingE2termControl) handle_e2term_subs_del_req(t *testing.T) //--------------------------------- select { case msg := <-e2termConn.rmrConChan: + e2termConn.DecMsgCnt() if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_DEL_REQ"] { testError(t, "(%s) Received wrong mtype expected %s got %s, error", e2termConn.desc, "RIC_SUB_DEL_REQ", xapp.RicMessageTypeToName[msg.Mtype]) } else { @@ -520,31 +526,42 @@ func (e2termConn *testingE2termControl) handle_e2term_subs_del_fail(t *testing.T // //----------------------------------------------------------------------------- func (mc *testingMainControl) wait_subs_clean(t *testing.T, e2SubsId int, secs int) bool { + var subs *Subscription i := 1 for ; i <= secs*2; i++ { - if mc.c.registry.GetSubscription(uint16(e2SubsId)) == nil { + subs = mc.c.registry.GetSubscription(uint16(e2SubsId)) + if subs == nil { return true } time.Sleep(500 * time.Millisecond) } - testError(t, "(general) no clean within %d secs", secs) + if subs != nil { + testError(t, "(general) no clean within %d secs: %s", secs, subs.String()) + } else { + testError(t, "(general) no clean within %d secs: subs(N/A)", secs) + } return false } func (mc *testingMainControl) wait_subs_trans_clean(t *testing.T, e2SubsId int, secs int) bool { + var trans *Transaction i := 1 for ; i <= secs*2; i++ { subs := mc.c.registry.GetSubscription(uint16(e2SubsId)) if subs == nil { return true } - trans := subs.GetTransaction() + trans = subs.GetTransaction() if trans == nil { return true } time.Sleep(500 * time.Millisecond) } - testError(t, "(general) no clean within %d secs", secs) + if trans != nil { + testError(t, "(general) no clean within %d secs: %s", secs, trans.String()) + } else { + testError(t, "(general) no clean within %d secs: trans(N/A)", secs) + } return false } @@ -586,6 +603,45 @@ func (mc *testingMainControl) wait_msgcounter_change(t *testing.T, orig uint64, return 0, false } +//----------------------------------------------------------------------------- +// TestSubReqAndRouteNok +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | rtmgr | +// +-------+ +---------+ +---------+ +// | | | +// | SubReq | | +// |------------->| | +// | | | +// | | RouteCreate | +// | |------------->| +// | | | +// | | RouteCreate | +// | | status:400 | +// | |<-------------| +// | | | +// | [SUBS INT DELETE] | +// | | | +// +//----------------------------------------------------------------------------- + +func TestSubReqAndRouteNok(t *testing.T) { + xapp.Logger.Info("TestSubReqAndRouteNok") + + waiter := rtmgrHttp.AllocNextEvent(false) + newSubsId := mainCtrl.get_subid(t) + xappConn1.handle_xapp_subs_req(t, nil) + waiter.WaitResult(t) + + //Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, int(newSubsId), 10) + + xappConn1.TestMsgCnt(t) + xappConn2.TestMsgCnt(t) + e2termConn.TestMsgCnt(t) +} + //----------------------------------------------------------------------------- // TestSubReqAndSubDelOk // @@ -622,26 +678,28 @@ func (mc *testingMainControl) wait_msgcounter_change(t *testing.T, orig uint64, //----------------------------------------------------------------------------- func TestSubReqAndSubDelOk(t *testing.T) { xapp.Logger.Info("TestSubReqAndSubDelOk") - rtmgrHttp.UseChannel(true) + waiter := rtmgrHttp.AllocNextEvent(true) cretrans := xappConn1.handle_xapp_subs_req(t, nil) - msg := rtmgrHttp.WaitReq(t) - msg.RetOk() + waiter.WaitResult(t) + crereq, cremsg := e2termConn.handle_e2term_subs_req(t) e2termConn.handle_e2term_subs_resp(t, crereq, cremsg) e2SubsId := xappConn1.handle_xapp_subs_resp(t, cretrans) - deltrans := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId) delreq, delmsg := e2termConn.handle_e2term_subs_del_req(t) + + waiter = rtmgrHttp.AllocNextEvent(true) e2termConn.handle_e2term_subs_del_resp(t, delreq, delmsg) xappConn1.handle_xapp_subs_del_resp(t, deltrans) - - msg = rtmgrHttp.WaitReq(t) - msg.RetOk() + waiter.WaitResult(t) //Wait that subs is cleaned mainCtrl.wait_subs_clean(t, e2SubsId, 10) - rtmgrHttp.UseChannel(false) + + xappConn1.TestMsgCnt(t) + xappConn2.TestMsgCnt(t) + e2termConn.TestMsgCnt(t) } //----------------------------------------------------------------------------- @@ -694,6 +752,10 @@ func TestSubReqRetransmission(t *testing.T) { //Wait that subs is cleaned mainCtrl.wait_subs_clean(t, e2SubsId, 10) + + xappConn1.TestMsgCnt(t) + xappConn2.TestMsgCnt(t) + e2termConn.TestMsgCnt(t) } //----------------------------------------------------------------------------- @@ -747,6 +809,10 @@ func TestSubDelReqRetransmission(t *testing.T) { //Wait that subs is cleaned mainCtrl.wait_subs_clean(t, e2SubsId, 10) + + xappConn1.TestMsgCnt(t) + xappConn2.TestMsgCnt(t) + e2termConn.TestMsgCnt(t) } //----------------------------------------------------------------------------- @@ -801,6 +867,10 @@ func TestSubDelReqCollision(t *testing.T) { //Wait that subs is cleaned mainCtrl.wait_subs_clean(t, e2SubsId, 10) + + xappConn1.TestMsgCnt(t) + xappConn2.TestMsgCnt(t) + e2termConn.TestMsgCnt(t) } //----------------------------------------------------------------------------- @@ -875,6 +945,10 @@ func TestSubReqAndSubDelOkTwoParallel(t *testing.T) { xappConn2.handle_xapp_subs_del_resp(t, deltrans2) //Wait that subs is cleaned mainCtrl.wait_subs_clean(t, e2SubsId2, 10) + + xappConn1.TestMsgCnt(t) + xappConn2.TestMsgCnt(t) + e2termConn.TestMsgCnt(t) } //----------------------------------------------------------------------------- @@ -952,6 +1026,10 @@ func TestSameSubsDiffRan(t *testing.T) { xappConn1.handle_xapp_subs_del_resp(t, deltrans2) //Wait that subs is cleaned mainCtrl.wait_subs_clean(t, e2SubsId2, 10) + + xappConn1.TestMsgCnt(t) + xappConn2.TestMsgCnt(t) + e2termConn.TestMsgCnt(t) } //----------------------------------------------------------------------------- @@ -1007,6 +1085,10 @@ func TestSubReqRetryInSubmgr(t *testing.T) { // Wait that subs is cleaned mainCtrl.wait_subs_clean(t, e2SubsId, 10) + + xappConn1.TestMsgCnt(t) + xappConn2.TestMsgCnt(t) + e2termConn.TestMsgCnt(t) } //----------------------------------------------------------------------------- @@ -1060,6 +1142,10 @@ func TestSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) { // Wait that subs is cleaned mainCtrl.wait_subs_clean(t, int(delreq.RequestId.Seq), 10) + + xappConn1.TestMsgCnt(t) + xappConn2.TestMsgCnt(t) + e2termConn.TestMsgCnt(t) } //----------------------------------------------------------------------------- @@ -1111,7 +1197,11 @@ func TestSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) { delreq, _ := e2termConn.handle_e2term_subs_del_req(t) // Wait that subs is cleaned - mainCtrl.wait_subs_clean(t, int(delreq.RequestId.Seq), 10) + mainCtrl.wait_subs_clean(t, int(delreq.RequestId.Seq), 15) + + xappConn1.TestMsgCnt(t) + xappConn2.TestMsgCnt(t) + e2termConn.TestMsgCnt(t) } //----------------------------------------------------------------------------- @@ -1153,6 +1243,10 @@ func TestSubReqSubFailRespInSubmgr(t *testing.T) { // Wait that subs is cleaned mainCtrl.wait_subs_clean(t, e2SubsId, 10) + + xappConn1.TestMsgCnt(t) + xappConn2.TestMsgCnt(t) + e2termConn.TestMsgCnt(t) } //----------------------------------------------------------------------------- @@ -1209,6 +1303,10 @@ func TestSubDelReqRetryInSubmgr(t *testing.T) { // Wait that subs is cleaned mainCtrl.wait_subs_clean(t, e2SubsId, 10) + + xappConn1.TestMsgCnt(t) + xappConn2.TestMsgCnt(t) + e2termConn.TestMsgCnt(t) } //----------------------------------------------------------------------------- @@ -1262,6 +1360,10 @@ func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) { // Wait that subs is cleaned mainCtrl.wait_subs_clean(t, e2SubsId, 10) + + xappConn1.TestMsgCnt(t) + xappConn2.TestMsgCnt(t) + e2termConn.TestMsgCnt(t) } //----------------------------------------------------------------------------- @@ -1312,4 +1414,8 @@ func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) { // Wait that subs is cleaned mainCtrl.wait_subs_clean(t, e2SubsId, 10) + + xappConn1.TestMsgCnt(t) + xappConn2.TestMsgCnt(t) + e2termConn.TestMsgCnt(t) }