subRfMsg, valid := subs.GetCachedResponse()
if subRfMsg == nil && valid == true {
-
- //
- // In case of failure
- // - make internal delete
- // - in case duplicate cause, retry (currently max 1 retry)
- //
- maxRetries := uint64(1)
- doRetry := true
- for retries := uint64(0); retries <= maxRetries && doRetry; retries++ {
- doRetry = false
-
- event := c.sendE2TSubscriptionRequest(subs, trans, parentTrans)
- switch themsg := event.(type) {
- case *e2ap.E2APSubscriptionResponse:
- subRfMsg, valid = subs.SetCachedResponse(event, true)
- subs.SubRespRcvd = true
- case *e2ap.E2APSubscriptionFailure:
- removeSubscriptionFromDb = true
- subRfMsg, valid = subs.SetCachedResponse(event, false)
- doRetry = true
- for _, item := range themsg.ActionNotAdmittedList.Items {
- if item.Cause.Content != e2ap.E2AP_CauseContent_Ric || (item.Cause.Value != e2ap.E2AP_CauseValue_Ric_duplicate_action && item.Cause.Value != e2ap.E2AP_CauseValue_Ric_duplicate_event) {
- doRetry = false
- break
- }
- }
- xapp.Logger.Info("SUBS-SubReq: internal delete and possible retry due event(%s) retry(%t,%d/%d) %s", typeofSubsMessage(event), doRetry, retries, maxRetries, idstring(nil, trans, subs, parentTrans))
- c.sendE2TSubscriptionDeleteRequest(subs, trans, parentTrans)
- case *SubmgrRestartTestEvent:
- // This simulates that no response has been received and after restart subscriptions are restored from db
- xapp.Logger.Debug("Test restart flag is active. Dropping this transaction to test restart case")
- return
- default:
- xapp.Logger.Info("SUBS-SubReq: internal delete due event(%s) %s", typeofSubsMessage(event), idstring(nil, trans, subs, parentTrans))
- removeSubscriptionFromDb = true
- subRfMsg, valid = subs.SetCachedResponse(nil, false)
- c.sendE2TSubscriptionDeleteRequest(subs, trans, parentTrans)
- }
+ event := c.sendE2TSubscriptionRequest(subs, trans, parentTrans)
+ switch event.(type) {
+ case *e2ap.E2APSubscriptionResponse:
+ subRfMsg, valid = subs.SetCachedResponse(event, true)
+ subs.SubRespRcvd = true
+ case *e2ap.E2APSubscriptionFailure:
+ removeSubscriptionFromDb = true
+ subRfMsg, valid = subs.SetCachedResponse(event, false)
+ xapp.Logger.Info("SUBS-SubReq: internal delete due event(%s) %s", typeofSubsMessage(event), idstring(nil, trans, subs, parentTrans))
+ c.sendE2TSubscriptionDeleteRequest(subs, trans, parentTrans)
+ case *SubmgrRestartTestEvent:
+ // This simulates that no response has been received and after restart subscriptions are restored from db
+ xapp.Logger.Debug("Test restart flag is active. Dropping this transaction to test restart case")
+ return
+ default:
+ xapp.Logger.Info("SUBS-SubReq: internal delete due event(%s) %s", typeofSubsMessage(event), idstring(nil, trans, subs, parentTrans))
+ removeSubscriptionFromDb = true
+ subRfMsg, valid = subs.SetCachedResponse(nil, false)
+ c.sendE2TSubscriptionDeleteRequest(subs, trans, parentTrans)
}
xapp.Logger.Debug("SUBS-SubReq: Handling (e2t response %s) %s", typeofSubsMessage(subRfMsg), idstring(nil, trans, subs, parentTrans))
} else {
return fmt.Errorf("SDL: WriteSubscriptionToSdl() json.Marshal error: %s", err.Error())
}
- err = c.db.Set(strconv.FormatUint(uint64(subId), 10), jsonData)
- if err != nil {
+ if err = c.db.Set(strconv.FormatUint(uint64(subId), 10), jsonData); err != nil {
return fmt.Errorf("SDL: WriteSubscriptionToSdl(): %s", err.Error())
} else {
xapp.Logger.Debug("SDL: Subscription written in db. subId = %v", subId)
subscriptionInfo := &SubscriptionInfo{}
jsonSubscriptionInfo := iSubscriptionInfo.(string)
- err := json.Unmarshal([]byte(jsonSubscriptionInfo), subscriptionInfo)
- if err != nil {
+ if err := json.Unmarshal([]byte(jsonSubscriptionInfo), subscriptionInfo); err != nil {
return nil, fmt.Errorf("SDL: ReadSubscriptionFromSdl() json.unmarshal error: %s\n", err.Error())
}
func (c *Control) RemoveSubscriptionFromSdl(subId uint32) error {
key := strconv.FormatUint(uint64(subId), 10)
- err := c.db.Remove([]string{key})
- if err != nil {
+ if err := c.db.Remove([]string{key}); err != nil {
return fmt.Errorf("SDL: RemoveSubscriptionfromSdl(): %s\n", err.Error())
} else {
xapp.Logger.Debug("SDL: Subscription removed from db. subId = %v", subId)
subscriptionInfo := &SubscriptionInfo{}
jsonSubscriptionInfo := iSubscriptionInfo.(string)
- err := json.Unmarshal([]byte(jsonSubscriptionInfo), subscriptionInfo)
- if err != nil {
+ if err := json.Unmarshal([]byte(jsonSubscriptionInfo), subscriptionInfo); err != nil {
return nil, nil, fmt.Errorf("SDL: ReadAllSubscriptionsFromSdl() json.unmarshal error: %s\n", err.Error())
}
}
func (c *Control) RemoveAllSubscriptionsFromSdl() error {
- err := c.db.RemoveAll()
- if err != nil {
+ if err := c.db.RemoveAll(); err != nil {
return fmt.Errorf("SDL: RemoveAllSubscriptionsFromSdl(): %s\n", err.Error())
} else {
xapp.Logger.Debug("SDL: All subscriptions removed from db")
mainCtrl.wait_registry_empty(t, 10)
}
-//-----------------------------------------------------------------------------
-// TestSubReqSubFailRespInSubmgrWithDuplicate
-//
-// stub stub
-// +-------+ +---------+ +---------+
-// | xapp | | submgr | | e2term |
-// +-------+ +---------+ +---------+
-// | | |
-// | SubReq | |
-// |------------->| |
-// | | |
-// | | SubReq |
-// | |------------->|
-// | | |
-// | | SubFail |
-// | |<-------------|
-// | | |
-// | | SubDelReq |
-// | |------------->|
-// | | |
-// | | SubDelResp |
-// | |<-------------|
-// | | |
-// | | SubReq |
-// | |------------->|
-// | | |
-// | | SubResp |
-// | |<-------------|
-// | | |
-// | SubResp | |
-// |<-------------| |
-// | | |
-// | [SUBS DELETE] |
-// | | |
-//
-//-----------------------------------------------------------------------------
-
-func TestSubReqSubFailRespInSubmgrWithDuplicate(t *testing.T) {
-
- CaseBegin("TestSubReqSubFailRespInSubmgrWithDuplicate start")
-
- // 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)
- fparams1.SetCauseVal(-1, 5, 3)
- e2termConn1.SendSubsFail(t, fparams1, cremsg1)
-
- // E2t: Receive SubsDelReq and send SubsDelResp (internal)
- delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
- e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
-
- // E2t: Receive SubsReq and send SubsResp (second)
- crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
- e2termConn1.SendSubsResp(t, crereq2, cremsg2)
-
- // XAPP: Receive SubsResp
- e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
-
- // Delete
- deltrans2 := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
- delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
- e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
- xappConn1.RecvSubsDelResp(t, deltrans2)
-
- // 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)
-}
-
-//-----------------------------------------------------------------------------
-// TestSubReqSubFailRespInSubmgrWithDuplicateFail
-//
-// stub stub
-// +-------+ +---------+ +---------+
-// | xapp | | submgr | | e2term |
-// +-------+ +---------+ +---------+
-// | | |
-// | SubReq | |
-// |------------->| |
-// | | |
-// | | SubReq |
-// | |------------->|
-// | | |
-// | | SubFail |
-// | |<-------------|
-// | | |
-// | | SubDelReq |
-// | |------------->|
-// | | |
-// | | SubDelResp |
-// | |<-------------|
-// | | |
-// | | SubReq |
-// | |------------->|
-// | | |
-// | | SubFail |
-// | |<-------------|
-// | | |
-// | | SubDelReq |
-// | |------------->|
-// | | |
-// | | SubDelResp |
-// | |<-------------|
-// | SubFail | |
-// |<-------------| |
-// | | |
-//
-//-----------------------------------------------------------------------------
-
-func TestSubReqSubFailRespInSubmgrWithDuplicateFail(t *testing.T) {
-
- CaseBegin("TestSubReqSubFailRespInSubmgrWithDuplicateFail start")
-
- // 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)
- fparams1.SetCauseVal(-1, 5, 3)
- e2termConn1.SendSubsFail(t, fparams1, cremsg1)
-
- // E2t: Receive SubsDelReq and send SubsDelResp (internal first)
- delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
- e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
-
- // E2t: Receive SubsReq and send SubsFail (second)
- crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
- fparams2 := &teststube2ap.E2StubSubsFailParams{}
- fparams2.Set(crereq2)
- fparams2.SetCauseVal(-1, 5, 3)
- e2termConn1.SendSubsFail(t, fparams2, cremsg2)
-
- // E2t: Receive SubsDelReq and send SubsDelResp (internal second)
- delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
- e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
-
- // 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)
-}
-
//-----------------------------------------------------------------------------
// TestSubDelReqRetryInSubmgr
//