var readSubsFromDb string
var dbRetryForever string
var dbTryCount int
+ var e2IEOrderCheckValue uint8
type Control struct {
*xapp.RMRClient
xapp.Logger.Debug("WARNING: Using hard coded default value for waitRouteCleanup_ms")
}
xapp.Logger.Debug("waitRouteCleanup= %v", waitRouteCleanup_ms)
+
+ viper.SetDefault("controls.checkE2IEOrder", 1)
+ e2IEOrderCheckValue = uint8(viper.GetUint("controls.checkE2IEOrder"))
+ c.e2ap.SetE2IEOrderCheck(e2IEOrderCheckValue)
+ xapp.Logger.Debug("e2IEOrderCheck= %v", e2IEOrderCheckValue)
}
//-------------------------------------------------------------------
}
xapp.Logger.Error("XAPP-SubReq E2 subscription failed: %s", idstring(err, trans, subs))
- c.registry.RemoveFromSubscription(subs, trans, waitRouteCleanup_ms, c)
+ // If policy type subscription fails we cannot remove it only internally. Once subscription has been created
+ // successfully, it must be deleted on both sides.
+ if subs.PolicyUpdate == false {
+ c.registry.RemoveFromSubscription(subs, trans, waitRouteCleanup_ms, c)
+ }
return nil, &errorInfo, err
}
subRfMsg, valid = subs.SetCachedResponse(event, true)
subs.SubRespRcvd = true
case *e2ap.E2APSubscriptionFailure:
- subRfMsg, valid = subs.SetCachedResponse(event, false)
+ if subs.PolicyUpdate == false {
+ subRfMsg, valid = subs.SetCachedResponse(event, false)
+ } else {
+ // In policy update case where subscription has already been created successfully in Gnb
+ // we cannot delete subscription internally in submgr
+ subRfMsg, valid = subs.SetCachedResponse(event, true)
+ }
xapp.Logger.Debug("SUBS-SubReq: internal delete due failure event(%s) %s", typeofSubsMessage(event), idstring(nil, trans, subs, parentTrans))
case *SubmgrRestartTestEvent:
// This is used to simulate that no response has been received and after restart, subscriptions are restored from db
} else {
xapp.Logger.Debug("SUBS-SubReq: Handling (cached response %s) %s", typeofSubsMessage(subRfMsg), idstring(nil, trans, subs, parentTrans))
}
+ xapp.Logger.Debug("subs.PolicyUpdate: %v", subs.PolicyUpdate)
+ xapp.Logger.Debug("subs: %v", subs)
+
if valid == false {
removeSubscriptionFromDb = true
}
import (
"encoding/json"
+ "fmt"
"strings"
"testing"
"time"
}
//-----------------------------------------------------------------------------
+
+ //-----------------------------------------------------------------------------
+ // TestSubReqAndSubDelOkOutofOrderIEs
+ //
+ // stub stub
+ // +-------+ +---------+ +---------+
+ // | xapp | | submgr | | e2term |
+ // +-------+ +---------+ +---------+
+ // | | |
+ // | SubReq | |
+ // |------------->| |
+ // | | |
+ // | | SubReq |
+ // | |------------->|
+ // | | |
+ // | | SubResp | (Out of Order IEs)
+ // | |<-------------|
+ // | | |
+ // | SubResp | |
+ // |<-------------| |
+ // | | |
+ // | | |
+ // | SubDelReq | |
+ // |------------->| |
+ // | | |
+ // | | SubDelReq |
+ // | |------------->|
+ // | | |
+ // | | SubDelResp |
+ // | |<-------------|
+ // | | |
+ // | SubDelResp | |
+ // |<-------------| |
+ //
+ //-----------------------------------------------------------------------------
+
+ func TestSubReqAndSubDelOkOutofOrderIEs(t *testing.T) {
+ CaseBegin("TestSubReqAndSubDelOkOutofOrderIEs")
+
+ mainCtrl.c.e2ap.SetE2IEOrderCheck(0)
+ // Init counter check
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cSubReqFromXapp, 1},
+ Counter{cSubReqToE2, 1},
+ Counter{cSubRespFromE2, 1},
+ Counter{cSubRespToXapp, 1},
+ Counter{cSubDelReqFromXapp, 1},
+ Counter{cSubDelReqToE2, 1},
+ Counter{cSubDelRespFromE2, 1},
+ Counter{cSubDelRespToXapp, 1},
+ })
+
+ cretrans := xappConn1.SendSubsReq(t, nil, nil)
+ if cretrans == nil {
+ t.Logf("Could not send SubsReq")
+ t.FailNow()
+ }
+ crereq, cremsg := e2termConn1.RecvSubsReq(t)
+ if crereq == nil || cremsg == nil {
+ t.Logf("Could not recieve SubsReq")
+ t.FailNow()
+ }
+
+ e2termConn1.SendSubsResp(t, crereq, cremsg)
+
+ mainCtrl.c.e2ap.SetE2IEOrderCheck(0)
+
+ e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
+ resp, _ := xapp.Subscription.QuerySubscriptions()
+ assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
+ assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
+ assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
+
+ deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
+ delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+
+ e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+ xappConn1.RecvSubsDelResp(t, deltrans)
+
+ //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)
+
+ mainCtrl.VerifyCounterValues(t)
+ mainCtrl.c.e2ap.SetE2IEOrderCheck(1)
+ }
+
+ //-----------------------------------------------------------------------------
+
+ //-----------------------------------------------------------------------------
// TestSubReqRetransmission
//
// stub stub
restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
// Del
+ xappConn1.SendRESTSubsDelReq(t, &restSubId)
+
+ delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+ e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+
+ // Wait that subs is cleaned
+ waitSubsCleanup(t, e2SubsId, 10)
+ mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
+}
+
+//-----------------------------------------------------------------------------
+// TestRESTSubReqPolicyChangeNokAndSubDelOk
+//
+// stub stub
+// +-------+ +---------+ +---------+
+// | xapp | | submgr | | e2term |
+// +-------+ +---------+ +---------+
+// | | |
+// | RESTSubReq | |
+// |---------------->| |
+// | | |
+// | RESTSubResp | |
+// |<----------------| |
+// | | SubReq |
+// | |------------->|
+// | | |
+// | | SubResp |
+// | |<-------------|
+// | | |
+// | RESTNotif | |
+// |<----------------| |
+// | | |
+// | RESTSubReq | |
+// |---------------->| |
+// | | |
+// | RESTSubResp | |
+// |<----------------| |
+// | | SubReq |
+// | |------------->|
+// | | |
+// | | SubFail |
+// | |<-------------|
+// | | |
+// | RESTNotif | |
+// |<----------------| |
+// | | |
+// | RESTSubDelReq | |
+// |---------------->| |
+// | | |
+// | | SubDelReq |
+// | |------------->|
+// | | |
+// | | SubDelResp |
+// | |<-------------|
+// | | |
+// | RESTSubDelResp | |
+// |<----------------| |
+//
+//-----------------------------------------------------------------------------
+
+func TestRESTSubReqPolicyChangeNokAndSubDelOk(t *testing.T) {
+
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cRestSubReqFromXapp, 2},
+ Counter{cRestSubRespToXapp, 2},
+ Counter{cSubReqToE2, 2},
+ Counter{cSubRespFromE2, 1},
+ Counter{cSubFailFromE2, 1},
+ Counter{cRestSubNotifToXapp, 1},
+ Counter{cRestSubFailNotifToXapp, 1},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cSubDelReqToE2, 1},
+ Counter{cSubDelRespFromE2, 1},
+ Counter{cRestSubDelRespToXapp, 1},
+ })
+
+ const subReqCount int = 1
+ const e2Timeout int64 = 1
+ const e2RetryCount int64 = 0
+ const routingNeeded bool = false
+
+ // Req
+ params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
+ params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
+ restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
+ fmt.Printf("restSubId: %v", restSubId)
+
+ // Policy change
+ // GetRESTSubsReqPolicyParams sets some counters on tc side.
+ params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
+ params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
+ params.SetSubscriptionID(&restSubId)
+ params.SetTimeToWait("w200ms")
+
+ restSubId = xappConn1.SendRESTSubsReq(t, params)
+ fmt.Printf("restSubId: %v", restSubId)
+
+ crereq, cremsg := e2termConn1.RecvSubsReq(t)
+ xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
+
+ // Gnb sends RICSubscriptionFailure
+ fparams := &teststube2ap.E2StubSubsFailParams{}
+ fparams.Set(crereq)
+ fparams.SetCauseVal(0, 1, 5) // CauseRIC / function-resource-limit
+ e2termConn1.SendSubsFail(t, fparams, cremsg)
+
+ instanceId := xappConn1.WaitRESTNotification(t, restSubId)
+ xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
+
+ // Del
xappConn1.SendRESTSubsDelReq(t, &restSubId)
delreq, delmsg := e2termConn1.RecvSubsDelReq(t)