//
//-----------------------------------------------------------------------------
func (xappConn *testingXappControl) handle_xapp_subs_req(t *testing.T, oldTrans *xappTransaction) *xappTransaction {
- xapp.Logger.Info("handle_xapp_subs_req")
+ xapp.Logger.Info("(%s) handle_xapp_subs_req", xappConn.desc)
e2SubsReq := e2asnpacker.NewPackerSubscriptionRequest()
//---------------------------------
trans = xappConn.newXappTransaction(nil, "RAN_NAME_1")
}
- params := &xapp.RMRParams{}
+ params := &RMRParams{&xapp.RMRParams{}}
params.Mtype = xapp.RIC_SUB_REQ
params.SubId = -1
params.Payload = packedMsg.Buf
//
//-----------------------------------------------------------------------------
func (xappConn *testingXappControl) handle_xapp_subs_resp(t *testing.T, trans *xappTransaction) int {
- xapp.Logger.Info("handle_xapp_subs_resp")
+ xapp.Logger.Info("(%s) handle_xapp_subs_resp", xappConn.desc)
e2SubsResp := e2asnpacker.NewPackerSubscriptionResponse()
var e2SubsId int
//---------------------------------
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
//
//-----------------------------------------------------------------------------
func (xappConn *testingXappControl) handle_xapp_subs_fail(t *testing.T, trans *xappTransaction) int {
- xapp.Logger.Info("handle_xapp_subs_fail")
+ xapp.Logger.Info("(%s) handle_xapp_subs_fail", xappConn.desc)
e2SubsFail := e2asnpacker.NewPackerSubscriptionFailure()
var e2SubsId int
//-------------------------------
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
//
//-----------------------------------------------------------------------------
func (xappConn *testingXappControl) handle_xapp_subs_del_req(t *testing.T, oldTrans *xappTransaction, e2SubsId int) *xappTransaction {
- xapp.Logger.Info("handle_xapp_subs_del_req")
+ xapp.Logger.Info("(%s) handle_xapp_subs_del_req", xappConn.desc)
e2SubsDelReq := e2asnpacker.NewPackerSubscriptionDeleteRequest()
//---------------------------------
trans = xappConn.newXappTransaction(nil, "RAN_NAME_1")
}
- params := &xapp.RMRParams{}
+ params := &RMRParams{&xapp.RMRParams{}}
params.Mtype = xapp.RIC_SUB_DEL_REQ
params.SubId = e2SubsId
params.Payload = packedMsg.Buf
//
//-----------------------------------------------------------------------------
func (xappConn *testingXappControl) handle_xapp_subs_del_resp(t *testing.T, trans *xappTransaction) {
- xapp.Logger.Info("handle_xapp_subs_del_resp")
+ xapp.Logger.Info("(%s) handle_xapp_subs_del_resp", xappConn.desc)
e2SubsDelResp := e2asnpacker.NewPackerSubscriptionDeleteResponse()
//---------------------------------
//---------------------------------
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
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
-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()
//---------------------------------
//---------------------------------
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 {
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()
//---------------------------------
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.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)
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
-func (e2termConn *testingE2termControl) handle_e2term_subs_fail(t *testing.T, req *e2ap.E2APSubscriptionRequest, msg *xapp.RMRParams) {
- xapp.Logger.Info("handle_e2term_subs_fail")
+type test_subs_fail_params struct {
+ req *e2ap.E2APSubscriptionRequest
+ fail *e2ap.E2APSubscriptionFailure
+}
+
+func (p *test_subs_fail_params) Set(req *e2ap.E2APSubscriptionRequest) {
+ p.req = req
+
+ p.fail = &e2ap.E2APSubscriptionFailure{}
+ p.fail.RequestId.Id = p.req.RequestId.Id
+ p.fail.RequestId.Seq = p.req.RequestId.Seq
+ p.fail.FunctionId = p.req.FunctionId
+ p.fail.ActionNotAdmittedList.Items = make([]e2ap.ActionNotAdmittedItem, len(p.req.ActionSetups))
+ for index := int(0); index < len(p.fail.ActionNotAdmittedList.Items); index++ {
+ p.fail.ActionNotAdmittedList.Items[index].ActionId = p.req.ActionSetups[index].ActionId
+ p.SetCauseVal(index, 5, 1)
+ }
+}
+
+func (p *test_subs_fail_params) SetCauseVal(ind int, content uint8, causeval uint8) {
+
+ if ind < 0 {
+ for index := int(0); index < len(p.fail.ActionNotAdmittedList.Items); index++ {
+ p.fail.ActionNotAdmittedList.Items[index].Cause.Content = content
+ p.fail.ActionNotAdmittedList.Items[index].Cause.CauseVal = causeval
+ }
+ return
+ }
+ p.fail.ActionNotAdmittedList.Items[ind].Cause.Content = content
+ p.fail.ActionNotAdmittedList.Items[ind].Cause.CauseVal = causeval
+}
+
+func (e2termConn *testingE2termControl) handle_e2term_subs_fail(t *testing.T, fparams *test_subs_fail_params, msg *RMRParams) {
+ xapp.Logger.Info("(%s) handle_e2term_subs_fail", e2termConn.desc)
e2SubsFail := e2asnpacker.NewPackerSubscriptionFailure()
//---------------------------------
//---------------------------------
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)
+ e2SubsFail.Set(fparams.fail)
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 := &xapp.RMRParams{}
+ params := &RMRParams{&xapp.RMRParams{}}
params.Mtype = xapp.RIC_SUB_FAILURE
params.SubId = msg.SubId
params.Payload = packedMsg.Buf
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
-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_del_req(t *testing.T) (*e2ap.E2APSubscriptionDeleteRequest, *RMRParams) {
+ xapp.Logger.Info("(%s) handle_e2term_subs_del_req", e2termConn.desc)
e2SubsDelReq := e2asnpacker.NewPackerSubscriptionDeleteRequest()
//---------------------------------
//---------------------------------
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 {
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()
//---------------------------------
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
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
-func (e2termConn *testingE2termControl) handle_e2term_subs_del_fail(t *testing.T, req *e2ap.E2APSubscriptionDeleteRequest, msg *xapp.RMRParams) {
- xapp.Logger.Info("handle_e2term_del_subs_fail")
+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()
//---------------------------------
testError(t, "(%s) pack NOK %s", e2termConn.desc, packerr.Error())
}
- params := &xapp.RMRParams{}
+ params := &RMRParams{&xapp.RMRParams{}}
params.Mtype = xapp.RIC_SUB_DEL_FAILURE
params.SubId = msg.SubId
params.Payload = packedMsg.Buf
//
//-----------------------------------------------------------------------------
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
}
-func (mc *testingMainControl) get_seqcnt(t *testing.T) uint16 {
+func (mc *testingMainControl) get_subid(t *testing.T) uint16 {
mc.c.registry.mutex.Lock()
defer mc.c.registry.mutex.Unlock()
- return mc.c.registry.counter
+ return mc.c.registry.subIds[0]
}
-func (mc *testingMainControl) wait_seqcnt_change(t *testing.T, orig uint16, secs int) (uint16, bool) {
+func (mc *testingMainControl) wait_subid_change(t *testing.T, origSubId uint16, secs int) (uint16, bool) {
i := 1
for ; i <= secs*2; i++ {
mc.c.registry.mutex.Lock()
- curr := mc.c.registry.counter
+ currSubId := mc.c.registry.subIds[0]
mc.c.registry.mutex.Unlock()
- if curr != orig {
- return curr, true
+ if currSubId != origSubId {
+ return currSubId, true
}
time.Sleep(500 * time.Millisecond)
}
- testError(t, "(general) no seq change within %d secs", secs)
+ testError(t, "(general) no subId change within %d secs", secs)
return 0, false
}
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
//
func TestSubReqAndSubDelOk(t *testing.T) {
xapp.Logger.Info("TestSubReqAndSubDelOk")
+ waiter := rtmgrHttp.AllocNextEvent(true)
cretrans := xappConn1.handle_xapp_subs_req(t, nil)
+ 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)
+ waiter.WaitResult(t)
//Wait that subs is cleaned
mainCtrl.wait_subs_clean(t, e2SubsId, 10)
+
+ xappConn1.TestMsgCnt(t)
+ xappConn2.TestMsgCnt(t)
+ e2termConn.TestMsgCnt(t)
}
//-----------------------------------------------------------------------------
//Wait that subs is cleaned
mainCtrl.wait_subs_clean(t, e2SubsId, 10)
+
+ xappConn1.TestMsgCnt(t)
+ xappConn2.TestMsgCnt(t)
+ e2termConn.TestMsgCnt(t)
}
//-----------------------------------------------------------------------------
//Wait that subs is cleaned
mainCtrl.wait_subs_clean(t, e2SubsId, 10)
+
+ xappConn1.TestMsgCnt(t)
+ xappConn2.TestMsgCnt(t)
+ e2termConn.TestMsgCnt(t)
}
//-----------------------------------------------------------------------------
//Wait that subs is cleaned
mainCtrl.wait_subs_clean(t, e2SubsId, 10)
+
+ xappConn1.TestMsgCnt(t)
+ xappConn2.TestMsgCnt(t)
+ e2termConn.TestMsgCnt(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)
}
//-----------------------------------------------------------------------------
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)
}
//-----------------------------------------------------------------------------
// Wait that subs is cleaned
mainCtrl.wait_subs_clean(t, e2SubsId, 10)
+
+ xappConn1.TestMsgCnt(t)
+ xappConn2.TestMsgCnt(t)
+ e2termConn.TestMsgCnt(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)
}
//-----------------------------------------------------------------------------
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)
}
//-----------------------------------------------------------------------------
// E2t: Receive SubsReq and send SubsFail
crereq, cremsg := e2termConn.handle_e2term_subs_req(t)
- e2termConn.handle_e2term_subs_fail(t, crereq, cremsg)
+ fparams := &test_subs_fail_params{}
+ fparams.Set(crereq)
+ e2termConn.handle_e2term_subs_fail(t, fparams, cremsg)
// Xapp: Receive SubsFail
e2SubsId := xappConn1.handle_xapp_subs_fail(t, cretrans)
// Wait that subs is cleaned
mainCtrl.wait_subs_clean(t, e2SubsId, 10)
+
+ xappConn1.TestMsgCnt(t)
+ xappConn2.TestMsgCnt(t)
+ e2termConn.TestMsgCnt(t)
}
//-----------------------------------------------------------------------------
// Wait that subs is cleaned
mainCtrl.wait_subs_clean(t, e2SubsId, 10)
+
+ xappConn1.TestMsgCnt(t)
+ xappConn2.TestMsgCnt(t)
+ e2termConn.TestMsgCnt(t)
}
//-----------------------------------------------------------------------------
// Wait that subs is cleaned
mainCtrl.wait_subs_clean(t, e2SubsId, 10)
+
+ xappConn1.TestMsgCnt(t)
+ xappConn2.TestMsgCnt(t)
+ e2termConn.TestMsgCnt(t)
}
//-----------------------------------------------------------------------------
// Wait that subs is cleaned
mainCtrl.wait_subs_clean(t, e2SubsId, 10)
-}
-/* */
+ xappConn1.TestMsgCnt(t)
+ xappConn2.TestMsgCnt(t)
+ e2termConn.TestMsgCnt(t)
+}