//---------------------------------
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
//-------------------------------
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
//---------------------------------
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
//---------------------------------
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 {
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 *RMRParams) {
+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 {
//---------------------------------
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 {
//
//-----------------------------------------------------------------------------
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
}
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")
- 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)
}
//-----------------------------------------------------------------------------
//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)
}