X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fcontrol%2Fmessaging_test.go;h=1b50c8b9c52fa8cd0eb689dccf30c2cd0807536c;hb=refs%2Fchanges%2F97%2F2197%2F6;hp=b8ed6e6296d18713bb1559407e6c6fdd197cbbf4;hpb=bf2f4122f6bf89fc572f6c4cad5f0c4108a996e0;p=ric-plt%2Fsubmgr.git diff --git a/pkg/control/messaging_test.go b/pkg/control/messaging_test.go index b8ed6e6..1b50c8b 100644 --- a/pkg/control/messaging_test.go +++ b/pkg/control/messaging_test.go @@ -31,28 +31,13 @@ import ( //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- - var e2asnpacker e2ap.E2APPackerIf = e2ap_wrapper.NewAsn1E2Packer() //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- -type xappTransaction struct { - xappConn *testingXappControl - xid string -} - -func newXappTransaction(xappConn *testingXappControl) { - trans := &xappTransaction{} - trans.xappConn = xappConn - trans.xid = xappConn.newXid() -} - -//----------------------------------------------------------------------------- -// -//----------------------------------------------------------------------------- -func (xappConn *testingXappControl) handle_xapp_subs_req(t *testing.T, updseq bool) { - xapp.Logger.Info("handle_xapp_subs_req") +func (xappConn *testingXappControl) handle_xapp_subs_req(t *testing.T, oldTrans *xappTransaction) *xappTransaction { + xapp.Logger.Info("(%s) handle_xapp_subs_req", xappConn.desc) e2SubsReq := e2asnpacker.NewPackerSubscriptionRequest() //--------------------------------- @@ -93,30 +78,35 @@ func (xappConn *testingXappControl) handle_xapp_subs_req(t *testing.T, updseq bo err, packedMsg := e2SubsReq.Pack(nil) if err != nil { testError(t, "(%s) pack NOK %s", xappConn.desc, err.Error()) + return nil } - params := &xapp.RMRParams{} + var trans *xappTransaction = oldTrans + if trans == nil { + trans = xappConn.newXappTransaction(nil, "RAN_NAME_1") + } + + params := &RMRParams{&xapp.RMRParams{}} params.Mtype = xapp.RIC_SUB_REQ params.SubId = -1 params.Payload = packedMsg.Buf - params.Meid = xappConn.meid - if updseq { - xappConn.newXid() - } - params.Xid = xappConn.xid + params.Meid = trans.meid + params.Xid = trans.xid params.Mbuf = nil snderr := xappConn.RmrSend(params) if snderr != nil { testError(t, "(%s) RMR SEND FAILED: %s", xappConn.desc, snderr.Error()) + return nil } + return trans } //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- -func (xappConn *testingXappControl) handle_xapp_subs_resp(t *testing.T) int { - xapp.Logger.Info("handle_xapp_subs_resp") +func (xappConn *testingXappControl) handle_xapp_subs_resp(t *testing.T, trans *xappTransaction) int { + xapp.Logger.Info("(%s) handle_xapp_subs_resp", xappConn.desc) e2SubsResp := e2asnpacker.NewPackerSubscriptionResponse() var e2SubsId int @@ -126,7 +116,10 @@ func (xappConn *testingXappControl) handle_xapp_subs_resp(t *testing.T) int { select { case msg := <-xappConn.rmrConChan: if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_RESP"] { - testError(t, "(%s) Received wrong mtype expected %s got %s, error", xappConn.desc, "RIC_SUB_RESP", xapp.RicMessageTypeToName[msg.Mtype]) + 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 + } else if msg.Xid != trans.xid { + testError(t, "(%s) Received RIC_SUB_RESP wrong xid expected %s got %s, error", xappConn.desc, trans.xid, msg.Xid) return -1 } else { packedData := &packer.PackedData{} @@ -155,8 +148,51 @@ func (xappConn *testingXappControl) handle_xapp_subs_resp(t *testing.T) int { //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- -func (xappConn *testingXappControl) handle_xapp_subs_del_req(t *testing.T, updseq bool, e2SubsId int) { - xapp.Logger.Info("handle_xapp_subs_del_req") +func (xappConn *testingXappControl) handle_xapp_subs_fail(t *testing.T, trans *xappTransaction) int { + xapp.Logger.Info("(%s) handle_xapp_subs_fail", xappConn.desc) + e2SubsFail := e2asnpacker.NewPackerSubscriptionFailure() + var e2SubsId int + + //------------------------------- + // xapp activity: Recv Subs Fail + //------------------------------- + select { + case msg := <-xappConn.rmrConChan: + 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 + } else if msg.Xid != trans.xid { + testError(t, "(%s) Received RIC_SUB_FAILURE wrong xid expected %s got %s, error", xappConn.desc, trans.xid, msg.Xid) + return -1 + } else { + packedData := &packer.PackedData{} + packedData.Buf = msg.Payload + e2SubsId = msg.SubId + unpackerr := e2SubsFail.UnPack(packedData) + + if unpackerr != nil { + testError(t, "(%s) RIC_SUB_FAILURE unpack failed err: %s", xappConn.desc, unpackerr.Error()) + } + geterr, resp := e2SubsFail.Get() + if geterr != nil { + testError(t, "(%s) RIC_SUB_FAILURE get failed err: %s", xappConn.desc, geterr.Error()) + } + + xapp.Logger.Info("(%s) Recv Subs Fail rmr: xid=%s subid=%d, asn: seqnro=%d", xappConn.desc, msg.Xid, msg.SubId, resp.RequestId.Seq) + return e2SubsId + } + case <-time.After(15 * time.Second): + testError(t, "(%s) Not Received RIC_SUB_FAILURE within 15 secs", xappConn.desc) + return -1 + } + return -1 +} + +//----------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------- +func (xappConn *testingXappControl) handle_xapp_subs_del_req(t *testing.T, oldTrans *xappTransaction, e2SubsId int) *xappTransaction { + xapp.Logger.Info("(%s) handle_xapp_subs_del_req", xappConn.desc) e2SubsDelReq := e2asnpacker.NewPackerSubscriptionDeleteRequest() //--------------------------------- @@ -174,30 +210,35 @@ func (xappConn *testingXappControl) handle_xapp_subs_del_req(t *testing.T, updse err, packedMsg := e2SubsDelReq.Pack(nil) if err != nil { testError(t, "(%s) pack NOK %s", xappConn.desc, err.Error()) + return nil } - params := &xapp.RMRParams{} + var trans *xappTransaction = oldTrans + if trans == nil { + trans = xappConn.newXappTransaction(nil, "RAN_NAME_1") + } + + params := &RMRParams{&xapp.RMRParams{}} params.Mtype = xapp.RIC_SUB_DEL_REQ params.SubId = e2SubsId params.Payload = packedMsg.Buf - params.Meid = xappConn.meid - if updseq { - xappConn.newXid() - } - params.Xid = xappConn.xid + params.Meid = trans.meid + params.Xid = trans.xid params.Mbuf = nil snderr := xappConn.RmrSend(params) if snderr != nil { testError(t, "(%s) RMR SEND FAILED: %s", xappConn.desc, snderr.Error()) + return nil } + return trans } //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- -func (xappConn *testingXappControl) handle_xapp_subs_del_resp(t *testing.T) { - xapp.Logger.Info("handle_xapp_subs_del_resp") +func (xappConn *testingXappControl) handle_xapp_subs_del_resp(t *testing.T, trans *xappTransaction) { + xapp.Logger.Info("(%s) handle_xapp_subs_del_resp", xappConn.desc) e2SubsDelResp := e2asnpacker.NewPackerSubscriptionDeleteResponse() //--------------------------------- @@ -206,7 +247,10 @@ func (xappConn *testingXappControl) handle_xapp_subs_del_resp(t *testing.T) { select { case msg := <-xappConn.rmrConChan: if msg.Mtype != xapp.RICMessageTypes["RIC_SUB_DEL_RESP"] { - testError(t, "(%s) Received wrong mtype expected %s got %s, error", xappConn.desc, "RIC_SUB_DEL_RESP", xapp.RicMessageTypeToName[msg.Mtype]) + 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 + } else if msg.Xid != trans.xid { + testError(t, "(%s) Received RIC_SUB_DEL_RESP wrong xid expected %s got %s, error", xappConn.desc, trans.xid, msg.Xid) return } else { packedData := &packer.PackedData{} @@ -230,8 +274,8 @@ func (xappConn *testingXappControl) handle_xapp_subs_del_resp(t *testing.T) { //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- -func (e2termConn *testingE2termControl) handle_e2term_subs_req(t *testing.T) (*e2ap.E2APSubscriptionRequest, *xapp.RMRParams) { - xapp.Logger.Info("handle_e2term_subs_req") +func (e2termConn *testingE2termControl) handle_e2term_subs_req(t *testing.T) (*e2ap.E2APSubscriptionRequest, *RMRParams) { + xapp.Logger.Info("(%s) handle_e2term_subs_req", e2termConn.desc) e2SubsReq := e2asnpacker.NewPackerSubscriptionRequest() //--------------------------------- @@ -261,8 +305,8 @@ func (e2termConn *testingE2termControl) handle_e2term_subs_req(t *testing.T) (*e return nil, nil } -func (e2termConn *testingE2termControl) handle_e2term_subs_resp(t *testing.T, req *e2ap.E2APSubscriptionRequest, msg *xapp.RMRParams) { - xapp.Logger.Info("handle_e2term_subs_resp") +func (e2termConn *testingE2termControl) handle_e2term_subs_resp(t *testing.T, req *e2ap.E2APSubscriptionRequest, msg *RMRParams) { + xapp.Logger.Info("(%s) handle_e2term_subs_resp", e2termConn.desc) e2SubsResp := e2asnpacker.NewPackerSubscriptionResponse() //--------------------------------- @@ -296,7 +340,7 @@ func (e2termConn *testingE2termControl) handle_e2term_subs_resp(t *testing.T, re testError(t, "(%s) pack NOK %s", e2termConn.desc, packerr.Error()) } - params := &xapp.RMRParams{} + params := &RMRParams{&xapp.RMRParams{}} params.Mtype = xapp.RIC_SUB_RESP params.SubId = msg.SubId params.Payload = packedMsg.Buf @@ -313,8 +357,53 @@ func (e2termConn *testingE2termControl) handle_e2term_subs_resp(t *testing.T, re //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- -func (e2termConn *testingE2termControl) handle_e2term_subs_del_req(t *testing.T) (*e2ap.E2APSubscriptionDeleteRequest, *xapp.RMRParams) { - xapp.Logger.Info("handle_e2term_subs_del_req") +func (e2termConn *testingE2termControl) handle_e2term_subs_fail(t *testing.T, req *e2ap.E2APSubscriptionRequest, msg *RMRParams) { + xapp.Logger.Info("(%s) handle_e2term_subs_fail", e2termConn.desc) + e2SubsFail := e2asnpacker.NewPackerSubscriptionFailure() + + //--------------------------------- + // e2term activity: Send Subs Fail + //--------------------------------- + xapp.Logger.Info("(%s) Send Subs Fail", e2termConn.desc) + + resp := &e2ap.E2APSubscriptionFailure{} + resp.RequestId.Id = req.RequestId.Id + resp.RequestId.Seq = req.RequestId.Seq + resp.FunctionId = req.FunctionId + + resp.ActionNotAdmittedList.Items = make([]e2ap.ActionNotAdmittedItem, len(resp.ActionNotAdmittedList.Items)) + for index := int(0); index < len(resp.ActionNotAdmittedList.Items); index++ { + resp.ActionNotAdmittedList.Items[index].ActionId = req.ActionSetups[index].ActionId + resp.ActionNotAdmittedList.Items[index].Cause.Content = 3 // CauseMisc + resp.ActionNotAdmittedList.Items[index].Cause.CauseVal = 4 // unspecified + } + + e2SubsFail.Set(resp) + xapp.Logger.Debug("%s", e2SubsFail.String()) + packerr, packedMsg := e2SubsFail.Pack(nil) + if packerr != nil { + testError(t, "(%s) pack NOK %s", e2termConn.desc, packerr.Error()) + } + + params := &RMRParams{&xapp.RMRParams{}} + params.Mtype = xapp.RIC_SUB_FAILURE + params.SubId = msg.SubId + params.Payload = packedMsg.Buf + params.Meid = msg.Meid + params.Xid = msg.Xid + params.Mbuf = nil + + snderr := e2termConn.RmrSend(params) + if snderr != nil { + testError(t, "(%s) RMR SEND FAILED: %s", e2termConn.desc, snderr.Error()) + } +} + +//----------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------- +func (e2termConn *testingE2termControl) handle_e2term_subs_del_req(t *testing.T) (*e2ap.E2APSubscriptionDeleteRequest, *RMRParams) { + xapp.Logger.Info("(%s) handle_e2term_subs_del_req", e2termConn.desc) e2SubsDelReq := e2asnpacker.NewPackerSubscriptionDeleteRequest() //--------------------------------- @@ -352,8 +441,8 @@ func handle_e2term_recv_empty() bool { return true } -func (e2termConn *testingE2termControl) handle_e2term_subs_del_resp(t *testing.T, req *e2ap.E2APSubscriptionDeleteRequest, msg *xapp.RMRParams) { - xapp.Logger.Info("handle_e2term_subs_del_resp") +func (e2termConn *testingE2termControl) handle_e2term_subs_del_resp(t *testing.T, req *e2ap.E2APSubscriptionDeleteRequest, msg *RMRParams) { + xapp.Logger.Info("(%s) handle_e2term_subs_del_resp", e2termConn.desc) e2SubsDelResp := e2asnpacker.NewPackerSubscriptionDeleteResponse() //--------------------------------- @@ -373,7 +462,7 @@ func (e2termConn *testingE2termControl) handle_e2term_subs_del_resp(t *testing.T testError(t, "(%s) pack NOK %s", e2termConn.desc, packerr.Error()) } - params := &xapp.RMRParams{} + params := &RMRParams{&xapp.RMRParams{}} params.Mtype = xapp.RIC_SUB_DEL_RESP params.SubId = msg.SubId params.Payload = packedMsg.Buf @@ -385,7 +474,46 @@ func (e2termConn *testingE2termControl) handle_e2term_subs_del_resp(t *testing.T if snderr != nil { testError(t, "(%s) RMR SEND FAILED: %s", e2termConn.desc, snderr.Error()) } +} + +//----------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------- +func (e2termConn *testingE2termControl) handle_e2term_subs_del_fail(t *testing.T, req *e2ap.E2APSubscriptionDeleteRequest, msg *RMRParams) { + xapp.Logger.Info("(%s) handle_e2term_del_subs_fail", e2termConn.desc) + e2SubsDelFail := e2asnpacker.NewPackerSubscriptionDeleteFailure() + //--------------------------------- + // e2term activity: Send Subs Del Fail + //--------------------------------- + xapp.Logger.Info("(%s) Send Subs Del Fail", e2termConn.desc) + + resp := &e2ap.E2APSubscriptionDeleteFailure{} + resp.RequestId.Id = req.RequestId.Id + resp.RequestId.Seq = req.RequestId.Seq + resp.FunctionId = req.FunctionId + resp.Cause.Content = 3 // CauseMisc + resp.Cause.CauseVal = 4 // unspecified + + e2SubsDelFail.Set(resp) + xapp.Logger.Debug("%s", e2SubsDelFail.String()) + packerr, packedMsg := e2SubsDelFail.Pack(nil) + if packerr != nil { + testError(t, "(%s) pack NOK %s", e2termConn.desc, packerr.Error()) + } + + params := &RMRParams{&xapp.RMRParams{}} + params.Mtype = xapp.RIC_SUB_DEL_FAILURE + params.SubId = msg.SubId + params.Payload = packedMsg.Buf + params.Meid = msg.Meid + params.Xid = msg.Xid + params.Mbuf = nil + + snderr := e2termConn.RmrSend(params) + if snderr != nil { + testError(t, "(%s) RMR SEND FAILED: %s", e2termConn.desc, snderr.Error()) + } } //----------------------------------------------------------------------------- @@ -394,7 +522,24 @@ func (e2termConn *testingE2termControl) handle_e2term_subs_del_resp(t *testing.T func (mc *testingMainControl) wait_subs_clean(t *testing.T, e2SubsId int, secs int) bool { i := 1 for ; i <= secs*2; i++ { - if mc.c.registry.IsValidSequenceNumber(uint16(e2SubsId)) == false { + if mc.c.registry.GetSubscription(uint16(e2SubsId)) == nil { + return true + } + time.Sleep(500 * time.Millisecond) + } + testError(t, "(general) no clean within %d secs", secs) + return false +} + +func (mc *testingMainControl) wait_subs_trans_clean(t *testing.T, e2SubsId int, secs int) bool { + i := 1 + for ; i <= secs*2; i++ { + subs := mc.c.registry.GetSubscription(uint16(e2SubsId)) + if subs == nil { + return true + } + trans := subs.GetTransaction() + if trans == nil { return true } time.Sleep(500 * time.Millisecond) @@ -403,6 +548,44 @@ func (mc *testingMainControl) wait_subs_clean(t *testing.T, e2SubsId int, secs i return false } +func (mc *testingMainControl) get_seqcnt(t *testing.T) uint16 { + mc.c.registry.mutex.Lock() + defer mc.c.registry.mutex.Unlock() + return mc.c.registry.counter +} + +func (mc *testingMainControl) wait_seqcnt_change(t *testing.T, orig uint16, secs int) (uint16, bool) { + i := 1 + for ; i <= secs*2; i++ { + mc.c.registry.mutex.Lock() + curr := mc.c.registry.counter + mc.c.registry.mutex.Unlock() + if curr != orig { + return curr, true + } + time.Sleep(500 * time.Millisecond) + } + testError(t, "(general) no seq change within %d secs", secs) + return 0, false +} + +func (mc *testingMainControl) get_msgcounter(t *testing.T) uint64 { + return mc.c.msgCounter +} + +func (mc *testingMainControl) wait_msgcounter_change(t *testing.T, orig uint64, secs int) (uint64, bool) { + i := 1 + for ; i <= secs*2; i++ { + curr := mc.c.msgCounter + if curr != orig { + return curr, true + } + time.Sleep(500 * time.Millisecond) + } + testError(t, "(general) no msg counter change within %d secs", secs) + return 0, false +} + //----------------------------------------------------------------------------- // TestSubReqAndSubDelOk // @@ -440,15 +623,15 @@ func (mc *testingMainControl) wait_subs_clean(t *testing.T, e2SubsId int, secs i func TestSubReqAndSubDelOk(t *testing.T) { xapp.Logger.Info("TestSubReqAndSubDelOk") - xappConn1.handle_xapp_subs_req(t, true) + cretrans := xappConn1.handle_xapp_subs_req(t, nil) crereq, cremsg := e2termConn.handle_e2term_subs_req(t) e2termConn.handle_e2term_subs_resp(t, crereq, cremsg) - e2SubsId := xappConn1.handle_xapp_subs_resp(t) + e2SubsId := xappConn1.handle_xapp_subs_resp(t, cretrans) - xappConn1.handle_xapp_subs_del_req(t, true, e2SubsId) + deltrans := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId) delreq, delmsg := e2termConn.handle_e2term_subs_del_req(t) e2termConn.handle_e2term_subs_del_resp(t, delreq, delmsg) - xappConn1.handle_xapp_subs_del_resp(t) + xappConn1.handle_xapp_subs_del_resp(t, deltrans) //Wait that subs is cleaned mainCtrl.wait_subs_clean(t, e2SubsId, 10) @@ -486,19 +669,21 @@ func TestSubReqRetransmission(t *testing.T) { xapp.Logger.Info("TestSubReqRetransmission") //Subs Create - xappConn1.handle_xapp_subs_req(t, true) + cretrans := xappConn1.handle_xapp_subs_req(t, nil) crereq, cremsg := e2termConn.handle_e2term_subs_req(t) - xappConn1.handle_xapp_subs_req(t, false) - e2termConn.handle_e2term_subs_resp(t, crereq, cremsg) + seqBef := mainCtrl.get_msgcounter(t) + xappConn1.handle_xapp_subs_req(t, cretrans) //Retransmitted SubReq + mainCtrl.wait_msgcounter_change(t, seqBef, 10) - e2SubsId := xappConn1.handle_xapp_subs_resp(t) + e2termConn.handle_e2term_subs_resp(t, crereq, cremsg) + e2SubsId := xappConn1.handle_xapp_subs_resp(t, cretrans) //Subs Delete - xappConn1.handle_xapp_subs_del_req(t, true, e2SubsId) + deltrans := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId) delreq, delmsg := e2termConn.handle_e2term_subs_del_req(t) e2termConn.handle_e2term_subs_del_resp(t, delreq, delmsg) - xappConn1.handle_xapp_subs_del_resp(t) + xappConn1.handle_xapp_subs_del_resp(t, deltrans) //Wait that subs is cleaned mainCtrl.wait_subs_clean(t, e2SubsId, 10) @@ -522,6 +707,8 @@ func TestSubReqRetransmission(t *testing.T) { // | |------------->| // | | | // | SubDelReq | | +// | (same sub) | | +// | (same xid) | | // |------------->| | // | | | // | | SubDelResp | @@ -535,20 +722,75 @@ func TestSubDelReqRetransmission(t *testing.T) { xapp.Logger.Info("TestSubDelReqRetransmission") //Subs Create - xappConn1.handle_xapp_subs_req(t, true) + cretrans := xappConn1.handle_xapp_subs_req(t, nil) crereq, cremsg := e2termConn.handle_e2term_subs_req(t) e2termConn.handle_e2term_subs_resp(t, crereq, cremsg) - e2SubsId := xappConn1.handle_xapp_subs_resp(t) + e2SubsId := xappConn1.handle_xapp_subs_resp(t, cretrans) //Subs Delete - xappConn1.handle_xapp_subs_del_req(t, true, e2SubsId) + deltrans := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId) delreq, delmsg := e2termConn.handle_e2term_subs_del_req(t) - <-time.After(2 * time.Second) - xappConn1.handle_xapp_subs_del_req(t, false, e2SubsId) + seqBef := mainCtrl.get_msgcounter(t) + xappConn1.handle_xapp_subs_del_req(t, deltrans, e2SubsId) //Retransmitted SubDelReq + mainCtrl.wait_msgcounter_change(t, seqBef, 10) e2termConn.handle_e2term_subs_del_resp(t, delreq, delmsg) - xappConn1.handle_xapp_subs_del_resp(t) + xappConn1.handle_xapp_subs_del_resp(t, deltrans) + + //Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, e2SubsId, 10) +} + +//----------------------------------------------------------------------------- +// TestSubDelReqCollision +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | [SUBS CREATE] | +// | | | +// | | | +// | SubDelReq | | +// |------------->| | +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | SubDelReq | | +// | (same sub) | | +// | (diff xid) | | +// |------------->| | +// | | | +// | | SubDelResp | +// | |<-------------| +// | | | +// | SubDelResp | | +// |<-------------| | +// +//----------------------------------------------------------------------------- +func TestSubDelReqCollision(t *testing.T) { + xapp.Logger.Info("TestSubDelReqCollision") + + //Subs Create + cretrans := xappConn1.handle_xapp_subs_req(t, nil) + crereq, cremsg := e2termConn.handle_e2term_subs_req(t) + e2termConn.handle_e2term_subs_resp(t, crereq, cremsg) + e2SubsId := xappConn1.handle_xapp_subs_resp(t, cretrans) + + //Subs Delete + deltrans := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId) + delreq, delmsg := e2termConn.handle_e2term_subs_del_req(t) + + seqBef := mainCtrl.get_msgcounter(t) + deltranscol := xappConn1.newXappTransaction(nil, "RAN_NAME_1") + xappConn1.handle_xapp_subs_del_req(t, deltranscol, e2SubsId) //Colliding SubDelReq + mainCtrl.wait_msgcounter_change(t, seqBef, 10) + + e2termConn.handle_e2term_subs_del_resp(t, delreq, delmsg) + xappConn1.handle_xapp_subs_del_resp(t, deltrans) //Wait that subs is cleaned mainCtrl.wait_subs_clean(t, e2SubsId, 10) @@ -596,34 +838,473 @@ func TestSubReqAndSubDelOkTwoParallel(t *testing.T) { xapp.Logger.Info("TestSubReqAndSubDelOkTwoParallel") //Req1 - xappConn1.handle_xapp_subs_req(t, true) + cretrans1 := xappConn1.handle_xapp_subs_req(t, nil) crereq1, cremsg1 := e2termConn.handle_e2term_subs_req(t) //Req2 - xappConn2.handle_xapp_subs_req(t, true) + cretrans2 := xappConn2.handle_xapp_subs_req(t, nil) crereq2, cremsg2 := e2termConn.handle_e2term_subs_req(t) //Resp1 e2termConn.handle_e2term_subs_resp(t, crereq1, cremsg1) - e2SubsId1 := xappConn1.handle_xapp_subs_resp(t) + e2SubsId1 := xappConn1.handle_xapp_subs_resp(t, cretrans1) //Resp2 e2termConn.handle_e2term_subs_resp(t, crereq2, cremsg2) - e2SubsId2 := xappConn2.handle_xapp_subs_resp(t) + e2SubsId2 := xappConn2.handle_xapp_subs_resp(t, cretrans2) //Del1 - xappConn1.handle_xapp_subs_del_req(t, true, e2SubsId1) + deltrans1 := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId1) delreq1, delmsg1 := e2termConn.handle_e2term_subs_del_req(t) e2termConn.handle_e2term_subs_del_resp(t, delreq1, delmsg1) - xappConn1.handle_xapp_subs_del_resp(t) + xappConn1.handle_xapp_subs_del_resp(t, deltrans1) //Wait that subs is cleaned mainCtrl.wait_subs_clean(t, e2SubsId1, 10) //Del2 - xappConn2.handle_xapp_subs_del_req(t, true, e2SubsId2) + deltrans2 := xappConn2.handle_xapp_subs_del_req(t, nil, e2SubsId2) delreq2, delmsg2 := e2termConn.handle_e2term_subs_del_req(t) e2termConn.handle_e2term_subs_del_resp(t, delreq2, delmsg2) - xappConn2.handle_xapp_subs_del_resp(t) + xappConn2.handle_xapp_subs_del_resp(t, deltrans2) //Wait that subs is cleaned mainCtrl.wait_subs_clean(t, e2SubsId2, 10) } + +//----------------------------------------------------------------------------- +// TestSameSubsDiffRan +// Same subscription to different RANs +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | | | +// | | | +// | SubReq(r1) | | +// |------------->| | +// | | | +// | | SubReq(r1) | +// | |------------->| +// | | | +// | | SubResp(r1) | +// | |<-------------| +// | | | +// | SubResp(r1) | | +// |<-------------| | +// | | | +// | SubReq(r2) | | +// |------------->| | +// | | | +// | | SubReq(r2) | +// | |------------->| +// | | | +// | | SubResp(r2) | +// | |<-------------| +// | | | +// | SubResp(r2) | | +// |<-------------| | +// | | | +// | [SUBS r1 DELETE] | +// | | | +// | [SUBS r2 DELETE] | +// | | | +// +//----------------------------------------------------------------------------- +func TestSameSubsDiffRan(t *testing.T) { + xapp.Logger.Info("TestSameSubsDiffRan") + + //Req1 + cretrans1 := xappConn1.newXappTransaction(nil, "RAN_NAME_1") + xappConn1.handle_xapp_subs_req(t, cretrans1) + crereq1, cremsg1 := e2termConn.handle_e2term_subs_req(t) + e2termConn.handle_e2term_subs_resp(t, crereq1, cremsg1) + e2SubsId1 := xappConn1.handle_xapp_subs_resp(t, cretrans1) + + //Req2 + cretrans2 := xappConn1.newXappTransaction(nil, "RAN_NAME_2") + xappConn1.handle_xapp_subs_req(t, cretrans2) + crereq2, cremsg2 := e2termConn.handle_e2term_subs_req(t) + e2termConn.handle_e2term_subs_resp(t, crereq2, cremsg2) + e2SubsId2 := xappConn1.handle_xapp_subs_resp(t, cretrans2) + + //Del1 + deltrans1 := xappConn1.newXappTransaction(nil, "RAN_NAME_1") + xappConn1.handle_xapp_subs_del_req(t, deltrans1, e2SubsId1) + delreq1, delmsg1 := e2termConn.handle_e2term_subs_del_req(t) + e2termConn.handle_e2term_subs_del_resp(t, delreq1, delmsg1) + xappConn1.handle_xapp_subs_del_resp(t, deltrans1) + //Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, e2SubsId1, 10) + + //Del2 + deltrans2 := xappConn1.newXappTransaction(nil, "RAN_NAME_2") + xappConn1.handle_xapp_subs_del_req(t, deltrans2, e2SubsId2) + delreq2, delmsg2 := e2termConn.handle_e2term_subs_del_req(t) + e2termConn.handle_e2term_subs_del_resp(t, delreq2, delmsg2) + xappConn1.handle_xapp_subs_del_resp(t, deltrans2) + //Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, e2SubsId2, 10) +} + +//----------------------------------------------------------------------------- +// TestSubReqRetryInSubmgr +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | SubReq | | +// |------------->| | +// | | | +// | | SubReq | +// | |------------->| +// | | | +// | | | +// | | SubReq | +// | |------------->| +// | | | +// | | SubResp | +// | |<-------------| +// | | | +// | SubResp | | +// |<-------------| | +// | | | +// | [SUBS DELETE] | +// | | | +// +//----------------------------------------------------------------------------- + +func TestSubReqRetryInSubmgr(t *testing.T) { + + xapp.Logger.Info("TestSubReqRetryInSubmgr start") + + // Xapp: Send SubsReq + cretrans := xappConn1.handle_xapp_subs_req(t, nil) + + // E2t: Receive 1st SubsReq + e2termConn.handle_e2term_subs_req(t) + + // E2t: Receive 2nd SubsReq and send SubsResp + crereq, cremsg := e2termConn.handle_e2term_subs_req(t) + e2termConn.handle_e2term_subs_resp(t, crereq, cremsg) + + // Xapp: Receive SubsResp + 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) + e2termConn.handle_e2term_subs_del_resp(t, delreq, delmsg) + xappConn1.handle_xapp_subs_del_resp(t, deltrans) + + // Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, e2SubsId, 10) +} + +//----------------------------------------------------------------------------- +// TestSubReqTwoRetriesNoRespSubDelRespInSubmgr +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | SubReq | | +// |------------->| | +// | | | +// | | SubReq | +// | |------------->| +// | | | +// | | | +// | | SubReq | +// | |------------->| +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | | +// | | SubDelResp | +// | |<-------------| +// | | | +// +//----------------------------------------------------------------------------- + +func TestSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) { + + xapp.Logger.Info("TestSubReqTwoRetriesNoRespSubDelRespInSubmgr start") + + // Xapp: Send SubsReq + xappConn1.handle_xapp_subs_req(t, nil) + + // E2t: Receive 1st SubsReq + e2termConn.handle_e2term_subs_req(t) + + // E2t: Receive 2nd SubsReq + e2termConn.handle_e2term_subs_req(t) + + // E2t: Send receive SubsDelReq and send SubsResp + delreq, delmsg := e2termConn.handle_e2term_subs_del_req(t) + e2termConn.handle_e2term_subs_del_resp(t, delreq, delmsg) + + // Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, int(delreq.RequestId.Seq), 10) +} + +//----------------------------------------------------------------------------- +// TestSubReqTwoRetriesNoRespAtAllInSubmgr +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | SubReq | | +// |------------->| | +// | | | +// | | SubReq | +// | |------------->| +// | | | +// | | | +// | | SubReq | +// | |------------->| +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | | +// +//----------------------------------------------------------------------------- + +func TestSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) { + + xapp.Logger.Info("TestSubReqTwoRetriesNoRespAtAllInSubmgr start") + + // Xapp: Send SubsReq + xappConn1.handle_xapp_subs_req(t, nil) + + // E2t: Receive 1st SubsReq + e2termConn.handle_e2term_subs_req(t) + + // E2t: Receive 2nd SubsReq + e2termConn.handle_e2term_subs_req(t) + + // E2t: Receive 1st SubsDelReq + e2termConn.handle_e2term_subs_del_req(t) + + // E2t: Receive 2nd SubsDelReq + delreq, _ := e2termConn.handle_e2term_subs_del_req(t) + + // Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, int(delreq.RequestId.Seq), 10) +} + +//----------------------------------------------------------------------------- +// TestSubReqSubFailRespInSubmgr +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | SubReq | | +// |------------->| | +// | | | +// | | SubReq | +// | |------------->| +// | | | +// | | SubFail | +// | |<-------------| +// | | | +// | SubFail | | +// |<-------------| | +// | | | +// +//----------------------------------------------------------------------------- + +func TestSubReqSubFailRespInSubmgr(t *testing.T) { + + xapp.Logger.Info("TestSubReqSubFailRespInSubmgr start") + + // Xapp: Send SubsReq + cretrans := xappConn1.handle_xapp_subs_req(t, nil) + + // E2t: Receive SubsReq and send SubsFail + crereq, cremsg := e2termConn.handle_e2term_subs_req(t) + e2termConn.handle_e2term_subs_fail(t, crereq, cremsg) + + // Xapp: Receive SubsFail + e2SubsId := xappConn1.handle_xapp_subs_fail(t, cretrans) + + // Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, e2SubsId, 10) +} + +//----------------------------------------------------------------------------- +// TestSubDelReqRetryInSubmgr +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | [SUBS CREATE] | +// | | | +// | | | +// | SubDelReq | | +// |------------->| | +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelResp | +// | |<-------------| +// | | | +// | SubDelResp | | +// |<-------------| | +// +//----------------------------------------------------------------------------- + +func TestSubDelReqRetryInSubmgr(t *testing.T) { + + xapp.Logger.Info("TestSubDelReqRetryInSubmgr start") + + // Subs Create + cretrans := xappConn1.handle_xapp_subs_req(t, nil) + crereq, cremsg := e2termConn.handle_e2term_subs_req(t) + e2termConn.handle_e2term_subs_resp(t, crereq, cremsg) + e2SubsId := xappConn1.handle_xapp_subs_resp(t, cretrans) + + // Subs Delete + // Xapp: Send SubsDelReq + deltrans := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId) + + // E2t: Receive 1st SubsDelReq + e2termConn.handle_e2term_subs_del_req(t) + + // E2t: Receive 2nd SubsDelReq and send SubsDelResp + delreq, delmsg := e2termConn.handle_e2term_subs_del_req(t) + e2termConn.handle_e2term_subs_del_resp(t, delreq, delmsg) + + // Xapp: Receive SubsDelResp + xappConn1.handle_xapp_subs_del_resp(t, deltrans) + + // Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, e2SubsId, 10) +} + +//----------------------------------------------------------------------------- +// TestSubDelReqTwoRetriesNoRespInSubmgr +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | [SUBS CREATE] | +// | | | +// | | | +// | SubDelReq | | +// |------------->| | +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | | +// | SubDelResp | | +// |<-------------| | +// +//----------------------------------------------------------------------------- + +func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) { + + xapp.Logger.Info("TestSubDelReTwoRetriesNoRespInSubmgr start") + + // Subs Create + cretrans := xappConn1.handle_xapp_subs_req(t, nil) + crereq, cremsg := e2termConn.handle_e2term_subs_req(t) + e2termConn.handle_e2term_subs_resp(t, crereq, cremsg) + e2SubsId := xappConn1.handle_xapp_subs_resp(t, cretrans) + + // Subs Delete + // Xapp: Send SubsDelReq + deltrans := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId) + + // E2t: Receive 1st SubsDelReq + e2termConn.handle_e2term_subs_del_req(t) + + // E2t: Receive 2nd SubsDelReq + e2termConn.handle_e2term_subs_del_req(t) + + // Xapp: Receive SubsDelResp + xappConn1.handle_xapp_subs_del_resp(t, deltrans) + + // Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, e2SubsId, 10) +} + +//----------------------------------------------------------------------------- +// TestSubDelReqSubDelFailRespInSubmgr +// +// stub stub +// +-------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | +// +-------+ +---------+ +---------+ +// | | | +// | [SUBS CREATE] | +// | | | +// | | | +// | SubDelReq | | +// |------------->| | +// | | | +// | | SubDelReq | +// | |------------->| +// | | | +// | | SubDelFail | +// | |<-------------| +// | | | +// | SubDelResp | | +// |<-------------| | +// | | | +// +//----------------------------------------------------------------------------- + +func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) { + + xapp.Logger.Info("TestSubReqSubDelFailRespInSubmgr start") + + // Subs Create + cretrans := xappConn1.handle_xapp_subs_req(t, nil) + crereq, cremsg := e2termConn.handle_e2term_subs_req(t) + e2termConn.handle_e2term_subs_resp(t, crereq, cremsg) + e2SubsId := xappConn1.handle_xapp_subs_resp(t, cretrans) + + // Xapp: Send SubsDelReq + deltrans := xappConn1.handle_xapp_subs_del_req(t, nil, e2SubsId) + + // E2t: Send receive SubsDelReq and send SubsDelFail + delreq, delmsg := e2termConn.handle_e2term_subs_del_req(t) + e2termConn.handle_e2term_subs_del_fail(t, delreq, delmsg) + + // Xapp: Receive SubsDelResp + xappConn1.handle_xapp_subs_del_resp(t, deltrans) + + // Wait that subs is cleaned + mainCtrl.wait_subs_clean(t, e2SubsId, 10) +} + +/* */