Subscription REST interface update
- Error values returned to xApp improved
- Posibility for xApp to set E2 timeout value added
- Posibility for xApp to set E2 retry count added
- Posibility for xApp to set is routing needed for the subscription
- Info log writings changed to debug log writings
Change-Id: Ib8f5c815c4e05b4784c2435de8c38acd41ba07bd
Signed-off-by: Anssi Mannila <anssi.mannila@nokia.com>
diff --git a/pkg/control/control.go b/pkg/control/control.go
index 3ebcbcd..aaad625 100755
--- a/pkg/control/control.go
+++ b/pkg/control/control.go
@@ -30,6 +30,7 @@
"gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
rtmgrclient "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/rtmgr_client"
"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/models"
+ "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/restapi/operations/common"
"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
httptransport "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
@@ -85,7 +86,7 @@
CntRecvMsg uint64
ResetTestFlag bool
Counters map[string]xapp.Counter
- LoggerLevel uint32
+ LoggerLevel int
}
type RMRMeid struct {
@@ -96,9 +97,24 @@
type SubmgrRestartTestEvent struct{}
type SubmgrRestartUpEvent struct{}
+type PackSubscriptionRequestErrortEvent struct {
+ ErrorInfo ErrorInfo
+}
+
+func (p *PackSubscriptionRequestErrortEvent) SetEvent(errorInfo *ErrorInfo) {
+ p.ErrorInfo = *errorInfo
+}
+
+type SDLWriteErrortEvent struct {
+ ErrorInfo ErrorInfo
+}
+
+func (s *SDLWriteErrortEvent) SetEvent(errorInfo *ErrorInfo) {
+ s.ErrorInfo = *errorInfo
+}
func init() {
- xapp.Logger.Info("SUBMGR")
+ xapp.Logger.Debug("SUBMGR")
viper.AutomaticEnv()
viper.SetEnvPrefix("submgr")
viper.AllowEmptyEnv(true)
@@ -131,7 +147,7 @@
xapp.Resource.InjectRoute("/ric/v1/restsubscriptions", c.GetAllRestSubscriptions, "GET")
xapp.Resource.InjectRoute("/ric/v1/symptomdata", c.SymptomDataHandler, "GET")
- go xapp.Subscription.Listen(c.SubscriptionHandler, c.QueryHandler, c.SubscriptionDeleteHandlerCB)
+ go xapp.Subscription.Listen(c.RESTSubscriptionHandler, c.RESTQueryHandler, c.RESTSubscriptionDeleteHandler)
if readSubsFromDb == "false" {
return c
@@ -154,7 +170,7 @@
//
//-------------------------------------------------------------------
func (c *Control) GetAllRestSubscriptions(w http.ResponseWriter, r *http.Request) {
- xapp.Logger.Info("GetAllRestSubscriptions() called")
+ xapp.Logger.Debug("GetAllRestSubscriptions() called")
response := c.registry.GetAllRestSubscriptions()
w.Write(response)
}
@@ -167,7 +183,7 @@
var subIds []uint32
var register map[uint32]*Subscription
for i := 0; dbRetryForever == "true" || i < dbTryCount; i++ {
- xapp.Logger.Info("Reading E2 subscriptions from db")
+ xapp.Logger.Debug("Reading E2 subscriptions from db")
subIds, register, err = c.ReadAllSubscriptionsFromSdl()
if err != nil {
xapp.Logger.Error("%v", err)
@@ -179,7 +195,7 @@
return nil
}
}
- xapp.Logger.Info("Continuing without retring")
+ xapp.Logger.Debug("Continuing without retring")
return err
}
@@ -190,7 +206,7 @@
var err error
var restSubscriptions map[string]*RESTSubscription
for i := 0; dbRetryForever == "true" || i < dbTryCount; i++ {
- xapp.Logger.Info("Reading REST subscriptions from db")
+ xapp.Logger.Debug("Reading REST subscriptions from db")
restSubscriptions, err = c.ReadAllRESTSubscriptionsFromSdl()
if err != nil {
xapp.Logger.Error("%v", err)
@@ -200,7 +216,7 @@
return nil
}
}
- xapp.Logger.Info("Continuing without retring")
+ xapp.Logger.Debug("Continuing without retring")
return err
}
@@ -209,58 +225,56 @@
//-------------------------------------------------------------------
func (c *Control) ReadConfigParameters(f string) {
+ c.LoggerLevel = int(xapp.Logger.GetLevel())
+ xapp.Logger.Debug("LoggerLevel %v", c.LoggerLevel)
+
// viper.GetDuration returns nanoseconds
e2tSubReqTimeout = viper.GetDuration("controls.e2tSubReqTimeout_ms") * 1000000
if e2tSubReqTimeout == 0 {
e2tSubReqTimeout = 2000 * 1000000
}
- xapp.Logger.Info("e2tSubReqTimeout %v", e2tSubReqTimeout)
+ xapp.Logger.Debug("e2tSubReqTimeout %v", e2tSubReqTimeout)
+
e2tSubDelReqTime = viper.GetDuration("controls.e2tSubDelReqTime_ms") * 1000000
if e2tSubDelReqTime == 0 {
e2tSubDelReqTime = 2000 * 1000000
}
- xapp.Logger.Info("e2tSubDelReqTime %v", e2tSubDelReqTime)
+ xapp.Logger.Debug("e2tSubDelReqTime %v", e2tSubDelReqTime)
e2tRecvMsgTimeout = viper.GetDuration("controls.e2tRecvMsgTimeout_ms") * 1000000
if e2tRecvMsgTimeout == 0 {
e2tRecvMsgTimeout = 2000 * 1000000
}
- xapp.Logger.Info("e2tRecvMsgTimeout %v", e2tRecvMsgTimeout)
+ xapp.Logger.Debug("e2tRecvMsgTimeout %v", e2tRecvMsgTimeout)
e2tMaxSubReqTryCount = viper.GetUint64("controls.e2tMaxSubReqTryCount")
if e2tMaxSubReqTryCount == 0 {
e2tMaxSubReqTryCount = 1
}
- xapp.Logger.Info("e2tMaxSubReqTryCount %v", e2tMaxSubReqTryCount)
+ xapp.Logger.Debug("e2tMaxSubReqTryCount %v", e2tMaxSubReqTryCount)
e2tMaxSubDelReqTryCount = viper.GetUint64("controls.e2tMaxSubDelReqTryCount")
if e2tMaxSubDelReqTryCount == 0 {
e2tMaxSubDelReqTryCount = 1
}
- xapp.Logger.Info("e2tMaxSubDelReqTryCount %v", e2tMaxSubDelReqTryCount)
+ xapp.Logger.Debug("e2tMaxSubDelReqTryCount %v", e2tMaxSubDelReqTryCount)
readSubsFromDb = viper.GetString("controls.readSubsFromDb")
if readSubsFromDb == "" {
readSubsFromDb = "true"
}
- xapp.Logger.Info("readSubsFromDb %v", readSubsFromDb)
+ xapp.Logger.Debug("readSubsFromDb %v", readSubsFromDb)
dbTryCount = viper.GetInt("controls.dbTryCount")
if dbTryCount == 0 {
dbTryCount = 200
}
- xapp.Logger.Info("dbTryCount %v", dbTryCount)
+ xapp.Logger.Debug("dbTryCount %v", dbTryCount)
dbRetryForever = viper.GetString("controls.dbRetryForever")
if dbRetryForever == "" {
dbRetryForever = "true"
}
- xapp.Logger.Info("dbRetryForever %v", dbRetryForever)
-
- c.LoggerLevel = viper.GetUint32("logger.level")
- if c.LoggerLevel == 0 {
- c.LoggerLevel = 3
- }
- xapp.Logger.Info("LoggerLevel %v", c.LoggerLevel)
+ xapp.Logger.Debug("dbRetryForever %v", dbRetryForever)
// Internal cfg parameter, used to define a wait time for RMR route clean-up. None default
// value 100ms used currently only in unittests.
@@ -268,7 +282,7 @@
if waitRouteCleanup_ms == 0 {
waitRouteCleanup_ms = 5000 * 1000000
}
- xapp.Logger.Info("waitRouteCleanup %v", waitRouteCleanup_ms)
+ xapp.Logger.Debug("waitRouteCleanup %v", waitRouteCleanup_ms)
}
//-------------------------------------------------------------------
@@ -279,9 +293,12 @@
xapp.Logger.Debug("HandleUncompletedSubscriptions. len(register) = %v", len(register))
for subId, subs := range register {
if subs.SubRespRcvd == false {
- subs.NoRespToXapp = true
- xapp.Logger.Debug("SendSubscriptionDeleteReq. subId = %v", subId)
- c.SendSubscriptionDeleteReq(subs)
+ // If policy subscription has already been made successfully unsuccessful update should not be deleted.
+ if subs.PolicyUpdate == false {
+ subs.NoRespToXapp = true
+ xapp.Logger.Debug("SendSubscriptionDeleteReq. subId = %v", subId)
+ c.SendSubscriptionDeleteReq(subs)
+ }
}
}
}
@@ -301,7 +318,7 @@
//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
-func (c *Control) GetOrCreateRestSubscription(p *models.SubscriptionParams, md5sum string, xAppRmrEndpoint string) (*RESTSubscription, string, error) {
+func (c *Control) GetOrCreateRestSubscription(p *models.SubscriptionParams, md5sum string, xAppRmrEndpoint string) (*RESTSubscription, string, string, error) {
var restSubId string
var restSubscription *RESTSubscription
@@ -309,56 +326,54 @@
prevRestSubsId, exists := restDuplicateCtrl.GetLastKnownRestSubsIdBasedOnMd5sum(md5sum)
if p.SubscriptionID == "" {
+ // Subscription does not contain REST subscription Id
if exists {
restSubscription, err = c.registry.GetRESTSubscription(prevRestSubsId, false)
if restSubscription != nil {
+ // Subscription not found
restSubId = prevRestSubsId
if err == nil {
- xapp.Logger.Info("Existing restSubId %s found by MD5sum %s for a request without subscription ID - using previous subscription", prevRestSubsId, md5sum)
+ xapp.Logger.Debug("Existing restSubId %s found by MD5sum %s for a request without subscription ID - using previous subscription", prevRestSubsId, md5sum)
} else {
- xapp.Logger.Info("Existing restSubId %s found by MD5sum %s for a request without subscription ID - Note: %s", prevRestSubsId, md5sum, err.Error())
+ xapp.Logger.Debug("Existing restSubId %s found by MD5sum %s for a request without subscription ID - Note: %s", prevRestSubsId, md5sum, err.Error())
}
} else {
- xapp.Logger.Info("None existing restSubId %s referred by MD5sum %s for a request without subscription ID - deleting cached entry", prevRestSubsId, md5sum)
+ xapp.Logger.Debug("None existing restSubId %s referred by MD5sum %s for a request without subscription ID - deleting cached entry", prevRestSubsId, md5sum)
restDuplicateCtrl.DeleteLastKnownRestSubsIdBasedOnMd5sum(md5sum)
}
}
if restSubscription == nil {
restSubId = ksuid.New().String()
- restSubscription, err = c.registry.CreateRESTSubscription(&restSubId, &xAppRmrEndpoint, p.Meid)
- if err != nil {
- xapp.Logger.Error("%s", err.Error())
- c.UpdateCounter(cRestSubFailToXapp)
- return nil, "", err
- }
+ restSubscription = c.registry.CreateRESTSubscription(&restSubId, &xAppRmrEndpoint, p.Meid)
}
} else {
+ // Subscription contains REST subscription Id
restSubId = p.SubscriptionID
- xapp.Logger.Info("RestSubscription ID %s provided via REST request", restSubId)
-
+ xapp.Logger.Debug("RestSubscription ID %s provided via REST request", restSubId)
restSubscription, err = c.registry.GetRESTSubscription(restSubId, false)
if err != nil {
+ // Subscription with id in REST request does not exist
xapp.Logger.Error("%s", err.Error())
c.UpdateCounter(cRestSubFailToXapp)
- return nil, "", err
+ return nil, "", models.SubscriptionInstanceRejectCauseRESTSubscriptionWithGivenIDDoesNotExist, err
}
if !exists {
- xapp.Logger.Info("Existing restSubscription found for ID %s, new request based on md5sum", restSubId)
+ xapp.Logger.Debug("Existing restSubscription found for ID %s, new request based on md5sum", restSubId)
} else {
- xapp.Logger.Info("Existing restSubscription found for ID %s(%s), re-transmission based on md5sum match with previous request", prevRestSubsId, restSubId)
+ xapp.Logger.Debug("Existing restSubscription found for ID %s(%s), re-transmission based on md5sum match with previous request", prevRestSubsId, restSubId)
}
}
- return restSubscription, restSubId, nil
+ return restSubscription, restSubId, "", nil
}
//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
-func (c *Control) SubscriptionHandler(params interface{}) (*models.SubscriptionResponse, error) {
+func (c *Control) RESTSubscriptionHandler(params interface{}) (*models.SubscriptionResponse, int) {
c.CntRecvMsg++
c.UpdateCounter(cRestSubReqFromXapp)
@@ -371,16 +386,17 @@
}
if p.ClientEndpoint == nil {
- xapp.Logger.Error("ClientEndpoint == nil")
+ err := fmt.Errorf("ClientEndpoint == nil")
+ xapp.Logger.Error("%v", err)
c.UpdateCounter(cRestSubFailToXapp)
- return nil, fmt.Errorf("")
+ return c.GetSubscriptionResponse(models.SubscriptionInstanceRejectCauseInvalidRESTRequestMessage, err.Error(), "SUBMGR", ""), common.SubscribeBadRequestCode
}
_, xAppRmrEndpoint, err := ConstructEndpointAddresses(*p.ClientEndpoint)
if err != nil {
xapp.Logger.Error("%s", err.Error())
c.UpdateCounter(cRestSubFailToXapp)
- return nil, err
+ return c.GetSubscriptionResponse(models.SubscriptionInstanceRejectCauseInvalidRESTRequestMessage, err.Error(), "SUBMGR", ""), common.SubscribeBadRequestCode
}
md5sum, err := CalculateRequestMd5sum(params)
@@ -388,10 +404,10 @@
xapp.Logger.Error("Failed to generate md5sum from incoming request - %s", err.Error())
}
- restSubscription, restSubId, err := c.GetOrCreateRestSubscription(p, md5sum, xAppRmrEndpoint)
+ restSubscription, restSubId, rejectCause, err := c.GetOrCreateRestSubscription(p, md5sum, xAppRmrEndpoint)
if err != nil {
xapp.Logger.Error("Failed to get/allocate REST subscription")
- return nil, err
+ return c.GetSubscriptionResponse(rejectCause, err.Error(), "SUBMGR", ""), common.SubscribeBadRequestCode
}
subResp.SubscriptionID = &restSubId
@@ -402,22 +418,85 @@
restDuplicateCtrl.DeleteLastKnownRestSubsIdBasedOnMd5sum(md5sum)
c.registry.DeleteRESTSubscription(&restSubId)
c.UpdateCounter(cRestSubFailToXapp)
- return nil, err
+ return c.GetSubscriptionResponse(models.SubscriptionInstanceRejectCauseInvalidRESTRequestMessage, err.Error(), "SUBMGR", ""), common.SubscribeBadRequestCode
}
duplicate := restDuplicateCtrl.IsDuplicateToOngoingTransaction(restSubId, md5sum)
if duplicate {
- xapp.Logger.Info("Retransmission blocker direct ACK for request of restSubsId %s restSubId MD5sum %s as retransmission", restSubId, md5sum)
+ err := fmt.Errorf("Retransmission blocker direct ACK for request of restSubsId %s restSubId MD5sum %s as retransmission", restSubId, md5sum)
+ xapp.Logger.Debug("%s", err)
c.UpdateCounter(cRestSubRespToXapp)
- return &subResp, nil
+ return &subResp, common.SubscribeCreatedCode
}
c.WriteRESTSubscriptionToDb(restSubId, restSubscription)
-
- go c.processSubscriptionRequests(restSubscription, &subReqList, p.ClientEndpoint, p.Meid, &restSubId, xAppRmrEndpoint, md5sum)
+ e2SubscriptionDirectives, err := c.GetE2SubscriptionDirectives(p)
+ if err != nil {
+ xapp.Logger.Error("%s", err)
+ return c.GetSubscriptionResponse(models.SubscriptionInstanceRejectCauseInvalidRESTRequestMessage, err.Error(), "SUBMGR", ""), common.SubscribeBadRequestCode
+ }
+ go c.processSubscriptionRequests(restSubscription, &subReqList, p.ClientEndpoint, p.Meid, &restSubId, xAppRmrEndpoint, md5sum, e2SubscriptionDirectives)
c.UpdateCounter(cRestSubRespToXapp)
- return &subResp, nil
+ return &subResp, common.SubscribeCreatedCode
+}
+
+//-------------------------------------------------------------------
+//
+//-------------------------------------------------------------------
+func (c *Control) GetE2SubscriptionDirectives(p *models.SubscriptionParams) (*E2SubscriptionDirectives, error) {
+
+ e2SubscriptionDirectives := &E2SubscriptionDirectives{}
+ if p == nil || p.E2SubscriptionDirectives == nil {
+ e2SubscriptionDirectives.E2TimeoutTimerValue = e2tSubReqTimeout
+ e2SubscriptionDirectives.E2MaxTryCount = int64(e2tMaxSubReqTryCount)
+ e2SubscriptionDirectives.CreateRMRRoute = true
+ xapp.Logger.Debug("p == nil || p.E2SubscriptionDirectives == nil. Using default values for E2TimeoutTimerValue = %v and E2RetryCount = %v RMRRoutingNeeded = true", e2tSubReqTimeout, e2tMaxSubReqTryCount)
+ } else {
+ if p.E2SubscriptionDirectives.E2TimeoutTimerValue >= 1 && p.E2SubscriptionDirectives.E2TimeoutTimerValue <= 10 {
+ e2SubscriptionDirectives.E2TimeoutTimerValue = time.Duration(p.E2SubscriptionDirectives.E2TimeoutTimerValue) * 1000000000 // Duration type cast returns nano seconds
+ } else {
+ return nil, fmt.Errorf("p.E2SubscriptionDirectives.E2TimeoutTimerValue out of range (1-10 seconds): %v", p.E2SubscriptionDirectives.E2TimeoutTimerValue)
+ }
+ if p.E2SubscriptionDirectives.E2RetryCount == nil {
+ xapp.Logger.Error("p.E2SubscriptionDirectives.E2RetryCount == nil. Using default value")
+ e2SubscriptionDirectives.E2MaxTryCount = int64(e2tMaxSubReqTryCount)
+ } else {
+ if *p.E2SubscriptionDirectives.E2RetryCount >= 0 && *p.E2SubscriptionDirectives.E2RetryCount <= 10 {
+ e2SubscriptionDirectives.E2MaxTryCount = *p.E2SubscriptionDirectives.E2RetryCount + 1 // E2MaxTryCount = First sending plus two retries
+ } else {
+ return nil, fmt.Errorf("p.E2SubscriptionDirectives.E2RetryCount out of range (0-10): %v", *p.E2SubscriptionDirectives.E2RetryCount)
+ }
+ }
+ if p.E2SubscriptionDirectives.RMRRoutingNeeded == nil {
+ xapp.Logger.Error("p.E2SubscriptionDirectives.RMRRoutingNeeded == nil")
+ e2SubscriptionDirectives.CreateRMRRoute = true
+ } else {
+ e2SubscriptionDirectives.CreateRMRRoute = *p.E2SubscriptionDirectives.RMRRoutingNeeded
+ }
+ }
+ xapp.Logger.Debug("e2SubscriptionDirectives.E2TimeoutTimerValue: %v", e2SubscriptionDirectives.E2TimeoutTimerValue)
+ xapp.Logger.Debug("e2SubscriptionDirectives.E2MaxTryCount: %v", e2SubscriptionDirectives.E2MaxTryCount)
+ xapp.Logger.Debug("e2SubscriptionDirectives.CreateRMRRoute: %v", e2SubscriptionDirectives.CreateRMRRoute)
+ return e2SubscriptionDirectives, nil
+}
+
+//-------------------------------------------------------------------
+//
+//-------------------------------------------------------------------
+func (c *Control) GetSubscriptionResponse(rejectCause string, errorCause string, errorSource string, timeoutType string) *models.SubscriptionResponse {
+ subResp := models.SubscriptionResponse{}
+ subscriptionInstance := models.SubscriptionInstance{}
+ subscriptionInstance.RejectCause = &rejectCause
+ subscriptionInstance.ErrorCause = &errorCause
+ subscriptionInstance.ErrorSource = &errorSource
+ if timeoutType != "" {
+ subscriptionInstance.TimeoutType = &timeoutType
+ }
+ subResp.SubscriptionInstances = append(subResp.SubscriptionInstances, &subscriptionInstance)
+ xapp.Logger.Error("etSubscriptionResponse() %+v", subscriptionInstance)
+
+ return &subResp
}
//-------------------------------------------------------------------
@@ -425,12 +504,13 @@
//-------------------------------------------------------------------
func (c *Control) processSubscriptionRequests(restSubscription *RESTSubscription, subReqList *e2ap.SubscriptionRequestList,
- clientEndpoint *models.SubscriptionParamsClientEndpoint, meid *string, restSubId *string, xAppRmrEndpoint string, md5sum string) {
+ clientEndpoint *models.SubscriptionParamsClientEndpoint, meid *string, restSubId *string, xAppRmrEndpoint string, md5sum string, e2SubscriptionDirectives *E2SubscriptionDirectives) {
- xapp.Logger.Info("Subscription Request count=%v ", len(subReqList.E2APSubscriptionRequests))
+ xapp.Logger.Debug("Subscription Request count=%v ", len(subReqList.E2APSubscriptionRequests))
var xAppEventInstanceID int64
var e2EventInstanceID int64
+ errorInfo := &ErrorInfo{}
defer restDuplicateCtrl.SetMd5sumFromLastOkRequest(*restSubId, md5sum)
@@ -442,22 +522,23 @@
if trans == nil {
// Send notification to xApp that prosessing of a Subscription Request has failed.
err := fmt.Errorf("Tracking failure")
- c.sendUnsuccesfullResponseNotification(restSubId, restSubscription, xAppEventInstanceID, err, clientEndpoint, trans)
+ errorInfo.ErrorCause = err.Error()
+ c.sendUnsuccesfullResponseNotification(restSubId, restSubscription, xAppEventInstanceID, err, clientEndpoint, trans, errorInfo)
continue
}
- xapp.Logger.Info("Handle SubscriptionRequest index=%v, %s", index, idstring(nil, trans))
+ xapp.Logger.Debug("Handle SubscriptionRequest index=%v, %s", index, idstring(nil, trans))
- subRespMsg, err := c.handleSubscriptionRequest(trans, &subReqMsg, meid, *restSubId)
+ subRespMsg, errorInfo, err := c.handleSubscriptionRequest(trans, &subReqMsg, meid, *restSubId, e2SubscriptionDirectives)
- xapp.Logger.Info("Handled SubscriptionRequest index=%v, %s", index, idstring(nil, trans))
+ xapp.Logger.Debug("Handled SubscriptionRequest index=%v, %s", index, idstring(nil, trans))
if err != nil {
- c.sendUnsuccesfullResponseNotification(restSubId, restSubscription, xAppEventInstanceID, err, clientEndpoint, trans)
+ c.sendUnsuccesfullResponseNotification(restSubId, restSubscription, xAppEventInstanceID, err, clientEndpoint, trans, errorInfo)
} else {
e2EventInstanceID = (int64)(subRespMsg.RequestId.InstanceId)
restSubscription.AddMd5Sum(md5sum)
- xapp.Logger.Info("SubscriptionRequest index=%v processed successfullyfor %s. endpoint=%v:%v, XappEventInstanceID=%v, E2EventInstanceID=%v, %s",
+ xapp.Logger.Debug("SubscriptionRequest index=%v processed successfullyfor %s. endpoint=%v:%v, XappEventInstanceID=%v, E2EventInstanceID=%v, %s",
index, *restSubId, clientEndpoint.Host, *clientEndpoint.HTTPPort, xAppEventInstanceID, e2EventInstanceID, idstring(nil, trans))
c.sendSuccesfullResponseNotification(restSubId, restSubscription, xAppEventInstanceID, e2EventInstanceID, clientEndpoint, trans)
}
@@ -469,25 +550,28 @@
//
//------------------------------------------------------------------
func (c *Control) handleSubscriptionRequest(trans *TransactionXapp, subReqMsg *e2ap.E2APSubscriptionRequest, meid *string,
- restSubId string) (*e2ap.E2APSubscriptionResponse, error) {
+ restSubId string, e2SubscriptionDirectives *E2SubscriptionDirectives) (*e2ap.E2APSubscriptionResponse, *ErrorInfo, error) {
+
+ errorInfo := ErrorInfo{}
err := c.tracker.Track(trans)
if err != nil {
xapp.Logger.Error("XAPP-SubReq Tracking error: %s", idstring(err, trans))
+ errorInfo.ErrorCause = err.Error()
err = fmt.Errorf("Tracking failure")
- return nil, err
+ return nil, &errorInfo, err
}
- subs, err := c.registry.AssignToSubscription(trans, subReqMsg, c.ResetTestFlag, c)
+ subs, errorInfo, err := c.registry.AssignToSubscription(trans, subReqMsg, c.ResetTestFlag, c, e2SubscriptionDirectives.CreateRMRRoute)
if err != nil {
xapp.Logger.Error("XAPP-SubReq Assign error: %s", idstring(err, trans))
- return nil, err
+ return nil, &errorInfo, err
}
//
// Wake subs request
//
- go c.handleSubscriptionCreate(subs, trans)
+ go c.handleSubscriptionCreate(subs, trans, e2SubscriptionDirectives)
event, _ := trans.WaitEvent(0) //blocked wait as timeout is handled in subs side
err = nil
@@ -495,37 +579,54 @@
switch themsg := event.(type) {
case *e2ap.E2APSubscriptionResponse:
trans.Release()
- return themsg, nil
+ return themsg, &errorInfo, nil
case *e2ap.E2APSubscriptionFailure:
err = fmt.Errorf("E2 SubscriptionFailure received")
- return nil, err
+ errorInfo.SetInfo(err.Error(), models.SubscriptionInstanceErrorSourceE2Node, "")
+ return nil, &errorInfo, err
+ case *PackSubscriptionRequestErrortEvent:
+ err = fmt.Errorf("E2 SubscriptionRequest pack failure")
+ return nil, &themsg.ErrorInfo, err
+ case *SDLWriteErrortEvent:
+ err = fmt.Errorf("SDL write failure")
+ return nil, &themsg.ErrorInfo, err
default:
- err = fmt.Errorf("unexpected E2 subscription response received")
+ err = fmt.Errorf("Unexpected E2 subscription response received")
+ errorInfo.SetInfo(err.Error(), models.SubscriptionInstanceErrorSourceE2Node, "")
break
}
} else {
err = fmt.Errorf("E2 subscription response timeout")
+ errorInfo.SetInfo(err.Error(), "", models.SubscriptionInstanceTimeoutTypeE2Timeout)
+ if subs.PolicyUpdate == true {
+ return nil, &errorInfo, err
+ }
}
xapp.Logger.Error("XAPP-SubReq E2 subscription failed %s", idstring(err, trans, subs))
c.registry.RemoveFromSubscription(subs, trans, waitRouteCleanup_ms, c)
- return nil, err
+ return nil, &errorInfo, err
}
//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
func (c *Control) sendUnsuccesfullResponseNotification(restSubId *string, restSubscription *RESTSubscription, xAppEventInstanceID int64, err error,
- clientEndpoint *models.SubscriptionParamsClientEndpoint, trans *TransactionXapp) {
+ clientEndpoint *models.SubscriptionParamsClientEndpoint, trans *TransactionXapp, errorInfo *ErrorInfo) {
// Send notification to xApp that prosessing of a Subscription Request has failed.
e2EventInstanceID := (int64)(0)
- errorCause := err.Error()
+ if errorInfo.ErrorSource == "" {
+ // Submgr is default source of error
+ errorInfo.ErrorSource = models.SubscriptionInstanceErrorSourceSUBMGR
+ }
resp := &models.SubscriptionResponse{
SubscriptionID: restSubId,
SubscriptionInstances: []*models.SubscriptionInstance{
&models.SubscriptionInstance{E2EventInstanceID: &e2EventInstanceID,
- ErrorCause: &errorCause,
+ ErrorCause: &errorInfo.ErrorCause,
+ ErrorSource: &errorInfo.ErrorSource,
+ TimeoutType: &errorInfo.TimeoutType,
XappEventInstanceID: &xAppEventInstanceID},
},
}
@@ -533,11 +634,11 @@
restSubscription.SetProcessed(err)
c.UpdateRESTSubscriptionInDB(*restSubId, restSubscription, false)
if trans != nil {
- xapp.Logger.Info("Sending unsuccessful REST notification (cause %s) to endpoint=%v:%v, XappEventInstanceID=%v, E2EventInstanceID=%v, %s",
- errorCause, clientEndpoint.Host, *clientEndpoint.HTTPPort, xAppEventInstanceID, e2EventInstanceID, idstring(nil, trans))
+ xapp.Logger.Debug("Sending unsuccessful REST notification (cause %s) to endpoint=%v:%v, XappEventInstanceID=%v, E2EventInstanceID=%v, %s",
+ errorInfo.ErrorCause, clientEndpoint.Host, *clientEndpoint.HTTPPort, xAppEventInstanceID, e2EventInstanceID, idstring(nil, trans))
} else {
- xapp.Logger.Info("Sending unsuccessful REST notification (cause %s) to endpoint=%v:%v, XappEventInstanceID=%v, E2EventInstanceID=%v",
- errorCause, clientEndpoint.Host, *clientEndpoint.HTTPPort, xAppEventInstanceID, e2EventInstanceID)
+ xapp.Logger.Debug("Sending unsuccessful REST notification (cause %s) to endpoint=%v:%v, XappEventInstanceID=%v, E2EventInstanceID=%v",
+ errorInfo.ErrorCause, clientEndpoint.Host, *clientEndpoint.HTTPPort, xAppEventInstanceID, e2EventInstanceID)
}
c.UpdateCounter(cRestSubFailNotifToXapp)
@@ -566,7 +667,7 @@
// Mark REST subscription request processesd.
restSubscription.SetProcessed(nil)
c.UpdateRESTSubscriptionInDB(*restSubId, restSubscription, false)
- xapp.Logger.Info("Sending successful REST notification to endpoint=%v:%v, XappEventInstanceID=%v, E2EventInstanceID=%v, %s",
+ xapp.Logger.Debug("Sending successful REST notification to endpoint=%v:%v, XappEventInstanceID=%v, E2EventInstanceID=%v, %s",
clientEndpoint.Host, *clientEndpoint.HTTPPort, xAppEventInstanceID, e2EventInstanceID, idstring(nil, trans))
c.UpdateCounter(cRestSubNotifToXapp)
@@ -576,42 +677,41 @@
//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
-func (c *Control) SubscriptionDeleteHandlerCB(restSubId string) error {
+func (c *Control) RESTSubscriptionDeleteHandler(restSubId string) int {
c.CntRecvMsg++
c.UpdateCounter(cRestSubDelReqFromXapp)
- xapp.Logger.Info("SubscriptionDeleteRequest from XAPP")
+ xapp.Logger.Debug("SubscriptionDeleteRequest from XAPP")
restSubscription, err := c.registry.GetRESTSubscription(restSubId, true)
if err != nil {
xapp.Logger.Error("%s", err.Error())
if restSubscription == nil {
// Subscription was not found
- return nil
+ return common.UnsubscribeNoContentCode
} else {
if restSubscription.SubReqOngoing == true {
err := fmt.Errorf("Handling of the REST Subscription Request still ongoing %s", restSubId)
xapp.Logger.Error("%s", err.Error())
- return err
+ return common.UnsubscribeBadRequestCode
} else if restSubscription.SubDelReqOngoing == true {
// Previous request for same restSubId still ongoing
- return nil
+ return common.UnsubscribeBadRequestCode
}
}
}
xAppRmrEndPoint := restSubscription.xAppRmrEndPoint
go func() {
- xapp.Logger.Info("Deleteting handler: processing instances = %v", restSubscription.InstanceIds)
+ xapp.Logger.Debug("Deleteting handler: processing instances = %v", restSubscription.InstanceIds)
for _, instanceId := range restSubscription.InstanceIds {
xAppEventInstanceID, err := c.SubscriptionDeleteHandler(&restSubId, &xAppRmrEndPoint, &restSubscription.Meid, instanceId)
if err != nil {
xapp.Logger.Error("%s", err.Error())
- //return err
}
- xapp.Logger.Info("Deleteting instanceId = %v", instanceId)
+ xapp.Logger.Debug("Deleteting instanceId = %v", instanceId)
restSubscription.DeleteXappIdToE2Id(xAppEventInstanceID)
restSubscription.DeleteE2InstanceId(instanceId)
}
@@ -622,7 +722,7 @@
c.UpdateCounter(cRestSubDelRespToXapp)
- return nil
+ return common.UnsubscribeNoContentCode
}
//-------------------------------------------------------------------
@@ -633,7 +733,7 @@
var xAppEventInstanceID int64
subs, err := c.registry.GetSubscriptionFirstMatch([]uint32{instanceId})
if err != nil {
- xapp.Logger.Info("Subscription Delete Handler subscription for restSubId=%v, E2EventInstanceID=%v not found %s",
+ xapp.Logger.Debug("Subscription Delete Handler subscription for restSubId=%v, E2EventInstanceID=%v not found %s",
restSubId, instanceId, idstring(err, nil))
return xAppEventInstanceID, nil
}
@@ -668,8 +768,8 @@
//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
-func (c *Control) QueryHandler() (models.SubscriptionList, error) {
- xapp.Logger.Info("QueryHandler() called")
+func (c *Control) RESTQueryHandler() (models.SubscriptionList, error) {
+ xapp.Logger.Debug("RESTQueryHandler() called")
c.CntRecvMsg++
@@ -677,7 +777,7 @@
}
func (c *Control) TestRestHandler(w http.ResponseWriter, r *http.Request) {
- xapp.Logger.Info("TestRestHandler() called")
+ xapp.Logger.Debug("RESTTestRestHandler() called")
pathParams := mux.Vars(r)
s := pathParams["testId"]
@@ -686,7 +786,7 @@
if contains := strings.Contains(s, "deletesubid="); contains == true {
var splits = strings.Split(s, "=")
if subId, err := strconv.ParseInt(splits[1], 10, 64); err == nil {
- xapp.Logger.Info("RemoveSubscriptionFromSdl() called. subId = %v", subId)
+ xapp.Logger.Debug("RemoveSubscriptionFromSdl() called. subId = %v", subId)
c.RemoveSubscriptionFromSdl(uint32(subId))
return
}
@@ -694,7 +794,7 @@
// This can be used to remove all subscriptions db from
if s == "emptydb" {
- xapp.Logger.Info("RemoveAllSubscriptionsFromSdl() called")
+ xapp.Logger.Debug("RemoveAllSubscriptionsFromSdl() called")
c.RemoveAllSubscriptionsFromSdl()
c.RemoveAllRESTSubscriptionsFromSdl()
return
@@ -702,11 +802,11 @@
// This is meant to cause submgr's restart in testing
if s == "restart" {
- xapp.Logger.Info("os.Exit(1) called")
+ xapp.Logger.Debug("os.Exit(1) called")
os.Exit(1)
}
- xapp.Logger.Info("Unsupported rest command received %s", s)
+ xapp.Logger.Debug("Unsupported rest command received %s", s)
}
//-------------------------------------------------------------------
@@ -723,7 +823,7 @@
params.PayloadLen = len(trans.Payload.Buf)
params.Payload = trans.Payload.Buf
params.Mbuf = nil
- xapp.Logger.Info("MSG to E2T: %s %s %s", desc, trans.String(), params.String())
+ xapp.Logger.Debug("MSG to E2T: %s %s %s", desc, trans.String(), params.String())
err = c.SendWithRetry(params, false, 5)
if err != nil {
xapp.Logger.Error("rmrSendToE2T: Send failed: %+v", err)
@@ -742,7 +842,7 @@
params.PayloadLen = len(trans.Payload.Buf)
params.Payload = trans.Payload.Buf
params.Mbuf = nil
- xapp.Logger.Info("MSG to XAPP: %s %s %s", desc, trans.String(), params.String())
+ xapp.Logger.Debug("MSG to XAPP: %s %s %s", desc, trans.String(), params.String())
err = c.SendWithRetry(params, false, 5)
if err != nil {
xapp.Logger.Error("rmrSendToXapp: Send failed: %+v", err)
@@ -784,7 +884,7 @@
case xapp.RIC_SUB_DEL_FAILURE:
go c.handleE2TSubscriptionDeleteFailure(msg)
default:
- xapp.Logger.Info("Unknown Message Type '%d', discarding", msg.Mtype)
+ xapp.Logger.Debug("Unknown Message Type '%d', discarding", msg.Mtype)
}
return
}
@@ -793,7 +893,7 @@
// handle from XAPP Subscription Request
//------------------------------------------------------------------
func (c *Control) handleXAPPSubscriptionRequest(params *xapp.RMRParams) {
- xapp.Logger.Info("MSG from XAPP: %s", params.String())
+ xapp.Logger.Debug("MSG from XAPP: %s", params.String())
c.UpdateCounter(cSubReqFromXapp)
subReqMsg, err := c.e2ap.UnpackSubscriptionRequest(params.Payload)
@@ -815,7 +915,7 @@
}
//TODO handle subscription toward e2term inside AssignToSubscription / hide handleSubscriptionCreate in it?
- subs, err := c.registry.AssignToSubscription(trans, subReqMsg, c.ResetTestFlag, c)
+ subs, _, err := c.registry.AssignToSubscription(trans, subReqMsg, c.ResetTestFlag, c, true)
if err != nil {
xapp.Logger.Error("XAPP-SubReq: %s", idstring(err, trans))
return
@@ -829,7 +929,8 @@
//------------------------------------------------------------------
func (c *Control) wakeSubscriptionRequest(subs *Subscription, trans *TransactionXapp) {
- go c.handleSubscriptionCreate(subs, trans)
+ e2SubscriptionDirectives, _ := c.GetE2SubscriptionDirectives(nil)
+ go c.handleSubscriptionCreate(subs, trans, e2SubscriptionDirectives)
event, _ := trans.WaitEvent(0) //blocked wait as timeout is handled in subs side
var err error
if event != nil {
@@ -854,7 +955,7 @@
break
}
}
- xapp.Logger.Info("XAPP-SubReq: failed %s", idstring(err, trans, subs))
+ xapp.Logger.Debug("XAPP-SubReq: failed %s", idstring(err, trans, subs))
//c.registry.RemoveFromSubscription(subs, trans, 5*time.Second)
}
@@ -862,7 +963,7 @@
// handle from XAPP Subscription Delete Request
//------------------------------------------------------------------
func (c *Control) handleXAPPSubscriptionDeleteRequest(params *xapp.RMRParams) {
- xapp.Logger.Info("MSG from XAPP: %s", params.String())
+ xapp.Logger.Debug("MSG from XAPP: %s", params.String())
c.UpdateCounter(cSubDelReqFromXapp)
subDelReqMsg, err := c.e2ap.UnpackSubscriptionDeleteRequest(params.Payload)
@@ -900,6 +1001,7 @@
if subs.NoRespToXapp == true {
// Do no send delete responses to xapps due to submgr restart is deleting uncompleted subscriptions
+ xapp.Logger.Debug("XAPP-SubDelReq: subs.NoRespToXapp == true")
return
}
@@ -921,8 +1023,9 @@
//-------------------------------------------------------------------
// SUBS CREATE Handling
//-------------------------------------------------------------------
-func (c *Control) handleSubscriptionCreate(subs *Subscription, parentTrans *TransactionXapp) {
+func (c *Control) handleSubscriptionCreate(subs *Subscription, parentTrans *TransactionXapp, e2SubscriptionDirectives *E2SubscriptionDirectives) {
+ var event interface{} = nil
var removeSubscriptionFromDb bool = false
trans := c.tracker.NewSubsTransaction(subs)
subs.WaitTransactionTurn(trans)
@@ -933,7 +1036,7 @@
subRfMsg, valid := subs.GetCachedResponse()
if subRfMsg == nil && valid == true {
- event := c.sendE2TSubscriptionRequest(subs, trans, parentTrans)
+ event = c.sendE2TSubscriptionRequest(subs, trans, parentTrans, e2SubscriptionDirectives)
switch event.(type) {
case *e2ap.E2APSubscriptionResponse:
subRfMsg, valid = subs.SetCachedResponse(event, true)
@@ -941,29 +1044,37 @@
case *e2ap.E2APSubscriptionFailure:
removeSubscriptionFromDb = true
subRfMsg, valid = subs.SetCachedResponse(event, false)
- xapp.Logger.Info("SUBS-SubReq: internal delete due failure event(%s) %s", typeofSubsMessage(event), idstring(nil, trans, subs, parentTrans))
+ xapp.Logger.Debug("SUBS-SubReq: internal delete due failure 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
+ case *PackSubscriptionRequestErrortEvent, *SDLWriteErrortEvent:
+ subRfMsg, valid = subs.SetCachedResponse(event, false)
default:
- xapp.Logger.Info("SUBS-SubReq: internal delete due default event(%s) %s", typeofSubsMessage(event), idstring(nil, trans, subs, parentTrans))
- removeSubscriptionFromDb = true
- subRfMsg, valid = subs.SetCachedResponse(nil, false)
- c.sendE2TSubscriptionDeleteRequest(subs, trans, parentTrans)
+ if subs.PolicyUpdate == false {
+ xapp.Logger.Debug("SUBS-SubReq: internal delete due default 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 {
xapp.Logger.Debug("SUBS-SubReq: Handling (cached response %s) %s", typeofSubsMessage(subRfMsg), idstring(nil, trans, subs, parentTrans))
}
+ err := c.UpdateSubscriptionInDB(subs, removeSubscriptionFromDb)
+ if err != nil {
+ subRfMsg, valid = subs.SetCachedResponse(event, false)
+ c.sendE2TSubscriptionDeleteRequest(subs, trans, parentTrans)
+ }
+
//Now RemoveFromSubscription in here to avoid race conditions (mostly concerns delete)
if valid == false {
c.registry.RemoveFromSubscription(subs, parentTrans, waitRouteCleanup_ms, c)
}
- c.UpdateSubscriptionInDB(subs, removeSubscriptionFromDb)
parentTrans.SendEvent(subRfMsg, 0)
}
@@ -1000,7 +1111,7 @@
//-------------------------------------------------------------------
// send to E2T Subscription Request
//-------------------------------------------------------------------
-func (c *Control) sendE2TSubscriptionRequest(subs *Subscription, trans *TransactionSubs, parentTrans *TransactionXapp) interface{} {
+func (c *Control) sendE2TSubscriptionRequest(subs *Subscription, trans *TransactionSubs, parentTrans *TransactionXapp, e2SubscriptionDirectives *E2SubscriptionDirectives) interface{} {
var err error
var event interface{} = nil
var timedOut bool = false
@@ -1012,13 +1123,26 @@
trans.Mtype, trans.Payload, err = c.e2ap.PackSubscriptionRequest(subReqMsg)
if err != nil {
xapp.Logger.Error("SUBS-SubReq: %s", idstring(err, trans, subs, parentTrans))
- return event
+ return &PackSubscriptionRequestErrortEvent{
+ ErrorInfo{
+ ErrorSource: models.SubscriptionInstanceErrorSourceASN1,
+ ErrorCause: err.Error(),
+ },
+ }
}
// Write uncompleted subscrition in db. If no response for subscrition it need to be re-processed (deleted) after restart
- c.WriteSubscriptionToDb(subs)
+ err = c.WriteSubscriptionToDb(subs)
+ if err != nil {
+ return &SDLWriteErrortEvent{
+ ErrorInfo{
+ ErrorSource: models.SubscriptionInstanceErrorSourceDBAAS,
+ ErrorCause: err.Error(),
+ },
+ }
+ }
- for retries := uint64(0); retries < e2tMaxSubReqTryCount; retries++ {
+ for retries := int64(0); retries < e2SubscriptionDirectives.E2MaxTryCount; retries++ {
desc := fmt.Sprintf("(retry %d)", retries)
if retries == 0 {
c.UpdateCounter(cSubReqToE2)
@@ -1027,7 +1151,7 @@
}
c.rmrSendToE2T(desc, subs, trans)
if subs.DoNotWaitSubResp == false {
- event, timedOut = trans.WaitEvent(e2tSubReqTimeout)
+ event, timedOut = trans.WaitEvent(e2SubscriptionDirectives.E2TimeoutTimerValue)
if timedOut {
c.UpdateCounter(cSubReqTimerExpiry)
continue
@@ -1035,6 +1159,7 @@
} else {
// Simulating case where subscrition request has been sent but response has not been received before restart
event = &SubmgrRestartTestEvent{}
+ xapp.Logger.Debug("Restart event, DoNotWaitSubResp == true")
}
break
}
@@ -1085,7 +1210,7 @@
// handle from E2T Subscription Response
//-------------------------------------------------------------------
func (c *Control) handleE2TSubscriptionResponse(params *xapp.RMRParams) {
- xapp.Logger.Info("MSG from E2T: %s", params.String())
+ xapp.Logger.Debug("MSG from E2T: %s", params.String())
c.UpdateCounter(cSubRespFromE2)
subRespMsg, err := c.e2ap.UnpackSubscriptionResponse(params.Payload)
@@ -1116,7 +1241,7 @@
// handle from E2T Subscription Failure
//-------------------------------------------------------------------
func (c *Control) handleE2TSubscriptionFailure(params *xapp.RMRParams) {
- xapp.Logger.Info("MSG from E2T: %s", params.String())
+ xapp.Logger.Debug("MSG from E2T: %s", params.String())
c.UpdateCounter(cSubFailFromE2)
subFailMsg, err := c.e2ap.UnpackSubscriptionFailure(params.Payload)
if err != nil {
@@ -1146,7 +1271,7 @@
// handle from E2T Subscription Delete Response
//-------------------------------------------------------------------
func (c *Control) handleE2TSubscriptionDeleteResponse(params *xapp.RMRParams) (err error) {
- xapp.Logger.Info("MSG from E2T: %s", params.String())
+ xapp.Logger.Debug("MSG from E2T: %s", params.String())
c.UpdateCounter(cSubDelRespFromE2)
subDelRespMsg, err := c.e2ap.UnpackSubscriptionDeleteResponse(params.Payload)
if err != nil {
@@ -1176,7 +1301,7 @@
// handle from E2T Subscription Delete Failure
//-------------------------------------------------------------------
func (c *Control) handleE2TSubscriptionDeleteFailure(params *xapp.RMRParams) {
- xapp.Logger.Info("MSG from E2T: %s", params.String())
+ xapp.Logger.Debug("MSG from E2T: %s", params.String())
c.UpdateCounter(cSubDelFailFromE2)
subDelFailMsg, err := c.e2ap.UnpackSubscriptionDeleteFailure(params.Payload)
if err != nil {
@@ -1230,18 +1355,20 @@
//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
-func (c *Control) WriteSubscriptionToDb(subs *Subscription) {
+func (c *Control) WriteSubscriptionToDb(subs *Subscription) error {
xapp.Logger.Debug("WriteSubscriptionToDb() subId = %v", subs.ReqId.InstanceId)
err := c.WriteSubscriptionToSdl(subs.ReqId.InstanceId, subs)
if err != nil {
xapp.Logger.Error("%v", err)
+ return err
}
+ return nil
}
//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
-func (c *Control) UpdateSubscriptionInDB(subs *Subscription, removeSubscriptionFromDb bool) {
+func (c *Control) UpdateSubscriptionInDB(subs *Subscription, removeSubscriptionFromDb bool) error {
if removeSubscriptionFromDb == true {
// Subscription was written in db already when subscription request was sent to BTS, except for merged request
@@ -1249,10 +1376,12 @@
} else {
// Update is needed for successful response and merge case here
if subs.RetryFromXapp == false {
- c.WriteSubscriptionToDb(subs)
+ err := c.WriteSubscriptionToDb(subs)
+ return err
}
}
subs.RetryFromXapp = false
+ return nil
}
//-------------------------------------------------------------------
@@ -1307,27 +1436,29 @@
xapp.Logger.Debug("Sending subscription delete due to restart. subId = %v", subs.ReqId.InstanceId)
// Send delete for every endpoint in the subscription
- subDelReqMsg := &e2ap.E2APSubscriptionDeleteRequest{}
- subDelReqMsg.RequestId = subs.GetReqId().RequestId
- subDelReqMsg.RequestId.Id = ricRequestorId
- subDelReqMsg.FunctionId = subs.SubReqMsg.FunctionId
- mType, payload, err := c.e2ap.PackSubscriptionDeleteRequest(subDelReqMsg)
- if err != nil {
- xapp.Logger.Error("SendSubscriptionDeleteReq() %s", idstring(err))
- return
- }
- for _, endPoint := range subs.EpList.Endpoints {
- params := &xapp.RMRParams{}
- params.Mtype = mType
- params.SubId = int(subs.GetReqId().InstanceId)
- params.Xid = ""
- params.Meid = subs.Meid
- params.Src = endPoint.String()
- params.PayloadLen = len(payload.Buf)
- params.Payload = payload.Buf
- params.Mbuf = nil
- subs.DeleteFromDb = true
- c.handleXAPPSubscriptionDeleteRequest(params)
+ if subs.PolicyUpdate == false {
+ subDelReqMsg := &e2ap.E2APSubscriptionDeleteRequest{}
+ subDelReqMsg.RequestId = subs.GetReqId().RequestId
+ subDelReqMsg.RequestId.Id = ricRequestorId
+ subDelReqMsg.FunctionId = subs.SubReqMsg.FunctionId
+ mType, payload, err := c.e2ap.PackSubscriptionDeleteRequest(subDelReqMsg)
+ if err != nil {
+ xapp.Logger.Error("SendSubscriptionDeleteReq() %s", idstring(err))
+ return
+ }
+ for _, endPoint := range subs.EpList.Endpoints {
+ params := &xapp.RMRParams{}
+ params.Mtype = mType
+ params.SubId = int(subs.GetReqId().InstanceId)
+ params.Xid = ""
+ params.Meid = subs.Meid
+ params.Src = endPoint.String()
+ params.PayloadLen = len(payload.Buf)
+ params.Payload = payload.Buf
+ params.Mbuf = nil
+ subs.DeleteFromDb = true
+ c.handleXAPPSubscriptionDeleteRequest(params)
+ }
}
}
@@ -1365,6 +1496,22 @@
fmt.Println(" Meid = nil")
}
+ if p.E2SubscriptionDirectives == nil {
+ fmt.Println(" E2SubscriptionDirectives = nil")
+ } else {
+ fmt.Println(" E2SubscriptionDirectives")
+ if p.E2SubscriptionDirectives.E2RetryCount == nil {
+ fmt.Println(" E2RetryCount == nil")
+ } else {
+ fmt.Printf(" E2RetryCount = %v\n", *p.E2SubscriptionDirectives.E2RetryCount)
+ }
+ fmt.Printf(" E2TimeoutTimerValue = %v\n", p.E2SubscriptionDirectives.E2TimeoutTimerValue)
+ if p.E2SubscriptionDirectives.RMRRoutingNeeded == nil {
+ fmt.Println(" RMRRoutingNeeded == nil")
+ } else {
+ fmt.Printf(" RMRRoutingNeeded = %v\n", *p.E2SubscriptionDirectives.RMRRoutingNeeded)
+ }
+ }
for _, subscriptionDetail := range p.SubscriptionDetails {
if p.RANFunctionID != nil {
fmt.Printf(" RANFunctionID = %v\n", *p.RANFunctionID)
diff --git a/pkg/control/duplicate.go b/pkg/control/duplicate.go
index 6900941..2110f1f 100644
--- a/pkg/control/duplicate.go
+++ b/pkg/control/duplicate.go
@@ -97,7 +97,7 @@
if !exists {
if md5sum == "" {
- xapp.Logger.Info("Attempted to delete a cached md5sum, md5sum not set yet")
+ xapp.Logger.Debug("Attempted to delete a cached md5sum, md5sum not set yet")
} else {
xapp.Logger.Error("Attempted to delete a cached md5sum %s, but the value was not found", md5sum)
}
@@ -133,7 +133,7 @@
entry, present := d.ongoingRequestMap[md5sum]
if present {
- xapp.Logger.Info("Collision detected. REST subs ID %s has ongoing transaction with md5sum : %s started at %s\n", entry.restSubsId, md5sum, entry.startTime.Format(time.ANSIC))
+ xapp.Logger.Debug("Collision detected. REST subs ID %s has ongoing transaction with md5sum : %s started at %s\n", entry.restSubsId, md5sum, entry.startTime.Format(time.ANSIC))
d.collCount++
return true
}
diff --git a/pkg/control/e2ap.go b/pkg/control/e2ap.go
index 7c2826b..0aa5ebe 100644
--- a/pkg/control/e2ap.go
+++ b/pkg/control/e2ap.go
@@ -51,7 +51,7 @@
//
//-----------------------------------------------------------------------------
func (c *E2ap) FillSubscriptionReqMsgs(params interface{}, subreqList *e2ap.SubscriptionRequestList, restSubscription *RESTSubscription) error {
- xapp.Logger.Info("FillSubscriptionReqMsgs")
+ xapp.Logger.Debug("FillSubscriptionReqMsgs")
p := params.(*models.SubscriptionParams)
diff --git a/pkg/control/registry.go b/pkg/control/registry.go
index 72a2100..4b48687 100644
--- a/pkg/control/registry.go
+++ b/pkg/control/registry.go
@@ -22,6 +22,7 @@
import (
"encoding/json"
"fmt"
+ "strings"
"sync"
"time"
@@ -115,7 +116,7 @@
return restSubscriptionsJson
}
-func (r *Registry) CreateRESTSubscription(restSubId *string, xAppRmrEndPoint *string, maid *string) (*RESTSubscription, error) {
+func (r *Registry) CreateRESTSubscription(restSubId *string, xAppRmrEndPoint *string, maid *string) *RESTSubscription {
r.mutex.Lock()
defer r.mutex.Unlock()
newRestSubscription := RESTSubscription{}
@@ -125,15 +126,15 @@
newRestSubscription.SubDelReqOngoing = false
r.restSubscriptions[*restSubId] = &newRestSubscription
newRestSubscription.xAppIdToE2Id = make(map[int64]int64)
- xapp.Logger.Info("Registry: Created REST subscription successfully. restSubId=%v, subscriptionCount=%v, e2apSubscriptionCount=%v", *restSubId, len(r.restSubscriptions), len(r.register))
- return &newRestSubscription, nil
+ xapp.Logger.Debug("Registry: Created REST subscription successfully. restSubId=%v, subscriptionCount=%v, e2apSubscriptionCount=%v", *restSubId, len(r.restSubscriptions), len(r.register))
+ return &newRestSubscription
}
func (r *Registry) DeleteRESTSubscription(restSubId *string) {
r.mutex.Lock()
defer r.mutex.Unlock()
delete(r.restSubscriptions, *restSubId)
- xapp.Logger.Info("Registry: Deleted REST subscription successfully. restSubId=%v, subscriptionCount=%v", *restSubId, len(r.restSubscriptions))
+ xapp.Logger.Debug("Registry: Deleted REST subscription successfully. restSubId=%v, subscriptionCount=%v", *restSubId, len(r.restSubscriptions))
}
func (r *Registry) GetRESTSubscription(restSubId string, IsDelReqOngoing bool) (*RESTSubscription, error) {
@@ -150,7 +151,6 @@
} else {
return restSubscription, fmt.Errorf("Registry: REST request is still ongoing for the endpoint=%v, restSubId=%v, SubDelReqOngoing=%v, SubReqOngoing=%v", restSubscription, restSubId, restSubscription.SubDelReqOngoing, restSubscription.SubReqOngoing)
}
- return restSubscription, nil
}
return nil, fmt.Errorf("Registry: No valid subscription found with restSubId=%v", restSubId)
}
@@ -168,7 +168,7 @@
return resp, nil
}
-func (r *Registry) allocateSubs(trans *TransactionXapp, subReqMsg *e2ap.E2APSubscriptionRequest, resetTestFlag bool) (*Subscription, error) {
+func (r *Registry) allocateSubs(trans *TransactionXapp, subReqMsg *e2ap.E2APSubscriptionRequest, resetTestFlag bool, rmrRoutecreated bool) (*Subscription, error) {
if len(r.subIds) > 0 {
subId := r.subIds[0]
r.subIds = r.subIds[1:]
@@ -179,8 +179,10 @@
subs := &Subscription{
registry: r,
Meid: trans.Meid,
+ RMRRouteCreated: rmrRoutecreated,
SubReqMsg: subReqMsg,
valid: true,
+ PolicyUpdate: false,
RetryFromXapp: false,
SubRespRcvd: false,
DeleteFromDb: false,
@@ -189,9 +191,7 @@
}
subs.ReqId.Id = subReqMsg.RequestId.Id
subs.ReqId.InstanceId = subId
- if resetTestFlag == true {
- subs.DoNotWaitSubResp = true
- }
+ r.SetResetTestFlag(resetTestFlag, subs)
if subs.EpList.AddEndpoint(trans.GetEndpoint()) == false {
r.subIds = append(r.subIds, subs.ReqId.InstanceId)
@@ -236,9 +236,10 @@
return nil, false
}
-func (r *Registry) AssignToSubscription(trans *TransactionXapp, subReqMsg *e2ap.E2APSubscriptionRequest, resetTestFlag bool, c *Control) (*Subscription, error) {
+func (r *Registry) AssignToSubscription(trans *TransactionXapp, subReqMsg *e2ap.E2APSubscriptionRequest, resetTestFlag bool, c *Control, createRMRRoute bool) (*Subscription, ErrorInfo, error) {
var err error
var newAlloc bool
+ errorInfo := ErrorInfo{}
r.mutex.Lock()
defer r.mutex.Unlock()
@@ -247,9 +248,9 @@
//
actionType, err := r.CheckActionTypes(subReqMsg)
if err != nil {
- xapp.Logger.Info("CREATE %s", err)
+ xapp.Logger.Debug("CREATE %s", err)
err = fmt.Errorf("E2 content validation failed")
- return nil, err
+ return nil, errorInfo, err
}
//
@@ -260,17 +261,19 @@
xapp.Logger.Debug("CREATE %s. Existing subscription for Policy found.", subs.String())
// Update message data to subscription
subs.SubReqMsg = subReqMsg
+ subs.PolicyUpdate = true
subs.SetCachedResponse(nil, true)
- return subs, nil
+ r.SetResetTestFlag(resetTestFlag, subs)
+ return subs, errorInfo, nil
}
}
subs, endPointFound := r.findExistingSubs(trans, subReqMsg)
if subs == nil {
- if subs, err = r.allocateSubs(trans, subReqMsg, resetTestFlag); err != nil {
+ if subs, err = r.allocateSubs(trans, subReqMsg, resetTestFlag, createRMRRoute); err != nil {
xapp.Logger.Error("%s", err.Error())
err = fmt.Errorf("subscription not allocated")
- return nil, err
+ return nil, errorInfo, err
}
newAlloc = true
} else if endPointFound == true {
@@ -278,7 +281,7 @@
subs.RetryFromXapp = true
xapp.Logger.Debug("CREATE subReqMsg.InstanceId=%v. Same subscription %s already exists.", subReqMsg.InstanceId, subs.String())
c.UpdateCounter(cDuplicateE2SubReq)
- return subs, nil
+ return subs, errorInfo, nil
}
//
@@ -288,16 +291,20 @@
defer subs.mutex.Unlock()
epamount := subs.EpList.Size()
- xapp.Logger.Info("AssignToSubscription subs.EpList.Size()=%v", subs.EpList.Size())
+ xapp.Logger.Debug("AssignToSubscription subs.EpList.Size()=%v", subs.EpList.Size())
r.mutex.Unlock()
//
// Subscription route updates
//
- if epamount == 1 {
- err = r.RouteCreate(subs, c)
+ if createRMRRoute == true {
+ if epamount == 1 {
+ errorInfo, err = r.RouteCreate(subs, c)
+ } else {
+ errorInfo, err = r.RouteCreateUpdate(subs, c)
+ }
} else {
- err = r.RouteCreateUpdate(subs, c)
+ xapp.Logger.Debug("RMR route not created: createRMRRoute=%v", createRMRRoute)
}
r.mutex.Lock()
@@ -307,7 +314,7 @@
}
// Delete already added endpoint for the request
subs.EpList.DelEndpoint(trans.GetEndpoint())
- return nil, err
+ return nil, errorInfo, err
}
if newAlloc {
@@ -315,31 +322,45 @@
}
xapp.Logger.Debug("CREATE %s", subs.String())
xapp.Logger.Debug("Registry: substable=%v", r.register)
- return subs, nil
+ return subs, errorInfo, nil
}
-func (r *Registry) RouteCreate(subs *Subscription, c *Control) error {
+func (r *Registry) RouteCreate(subs *Subscription, c *Control) (ErrorInfo, error) {
+ errorInfo := ErrorInfo{}
subRouteAction := SubRouteInfo{subs.EpList, uint16(subs.ReqId.InstanceId)}
err := r.rtmgrClient.SubscriptionRequestCreate(subRouteAction)
if err != nil {
+ if strings.Contains(err.Error(), "status 400") {
+ errorInfo.TimeoutType = models.SubscriptionInstanceTimeoutTypeRTMGRTimeout
+ } else {
+ errorInfo.ErrorSource = models.SubscriptionInstanceErrorSourceRTMGR
+ }
+ errorInfo.ErrorCause = err.Error()
c.UpdateCounter(cRouteCreateFail)
xapp.Logger.Error("%s", err.Error())
err = fmt.Errorf("RTMGR route create failure")
}
- return err
+ return errorInfo, err
}
-func (r *Registry) RouteCreateUpdate(subs *Subscription, c *Control) error {
+func (r *Registry) RouteCreateUpdate(subs *Subscription, c *Control) (ErrorInfo, error) {
+ errorInfo := ErrorInfo{}
subRouteAction := SubRouteInfo{subs.EpList, uint16(subs.ReqId.InstanceId)}
err := r.rtmgrClient.SubscriptionRequestUpdate(subRouteAction)
if err != nil {
+ if strings.Contains(err.Error(), "status 400") {
+ errorInfo.TimeoutType = models.SubscriptionInstanceTimeoutTypeRTMGRTimeout
+ } else {
+ errorInfo.ErrorSource = models.SubscriptionInstanceErrorSourceRTMGR
+ }
+ errorInfo.ErrorCause = err.Error()
c.UpdateCounter(cRouteCreateUpdateFail)
xapp.Logger.Error("%s", err.Error())
err = fmt.Errorf("RTMGR route update failure")
- return err
+ return errorInfo, err
}
c.UpdateCounter(cMergedSubscriptions)
- return err
+ return errorInfo, err
}
func (r *Registry) CheckActionTypes(subReqMsg *e2ap.E2APSubscriptionRequest) (uint64, error) {
@@ -397,13 +418,15 @@
subs.mutex.Lock()
defer subs.mutex.Unlock()
- xapp.Logger.Info("CLEAN %s", subs.String())
+ xapp.Logger.Debug("CLEAN %s", subs.String())
if epamount == 0 {
//
// Subscription route delete
//
- r.RouteDelete(subs, trans, c)
+ if subs.RMRRouteCreated == true {
+ r.RouteDelete(subs, trans, c)
+ }
//
// Subscription release
@@ -421,7 +444,9 @@
//
// Subscription route update
//
- r.RouteDeleteUpdate(subs, c)
+ if subs.RMRRouteCreated == true {
+ r.RouteDeleteUpdate(subs, c)
+ }
}
}()
@@ -483,3 +508,13 @@
}
return nil, fmt.Errorf("No valid subscription found with subIds %v", subIds)
}
+
+func (r *Registry) SetResetTestFlag(resetTestFlag bool, subs *Subscription) {
+ if resetTestFlag == true {
+ // This is used in submgr restart unit tests
+ xapp.Logger.Debug("resetTestFlag == true")
+ subs.DoNotWaitSubResp = true
+ } else {
+ xapp.Logger.Debug("resetTestFlag == false")
+ }
+}
diff --git a/pkg/control/restendpoint.go b/pkg/control/restendpoint.go
index 2e64f05..dc565d4 100644
--- a/pkg/control/restendpoint.go
+++ b/pkg/control/restendpoint.go
@@ -62,7 +62,7 @@
xAppRMREndPoint = host + ":" + strconv.FormatInt(*clientEndpoint.RMRPort, 10)
}
- xapp.Logger.Info("xAppHttpEndPoint=%v, xAppRrmEndPoint=%v", xAppHTTPEndPoint, xAppRMREndPoint)
+ xapp.Logger.Debug("xAppHttpEndPoint=%v, xAppRrmEndPoint=%v", xAppHTTPEndPoint, xAppRMREndPoint)
return xAppHTTPEndPoint, xAppRMREndPoint, nil
}
diff --git a/pkg/control/sdl_e2SubsDb.go b/pkg/control/sdl_e2SubsDb.go
index c2526bc..2afa36e 100644
--- a/pkg/control/sdl_e2SubsDb.go
+++ b/pkg/control/sdl_e2SubsDb.go
@@ -30,13 +30,14 @@
)
type SubscriptionInfo struct {
- Valid bool
- ReqId RequestId
- Meid xapp.RMRMeid
- EpList xapp.RmrEndpointList
- SubReqMsg e2ap.E2APSubscriptionRequest
- SubRespMsg e2ap.E2APSubscriptionResponse
- SubRespRcvd string
+ Valid bool
+ ReqId RequestId
+ Meid xapp.RMRMeid
+ EpList xapp.RmrEndpointList
+ SubReqMsg e2ap.E2APSubscriptionRequest
+ SubRespMsg e2ap.E2APSubscriptionResponse
+ SubRespRcvd string
+ PolicyUpdate bool
}
func CreateSdl() Sdlnterface {
@@ -51,6 +52,7 @@
subscriptionInfo.Meid = *subs.Meid
subscriptionInfo.EpList = subs.EpList
subscriptionInfo.SubReqMsg = *subs.SubReqMsg
+ subscriptionInfo.PolicyUpdate = subs.PolicyUpdate
if typeofSubsMessage(subs.SubRFMsg) == "SubResp" {
subscriptionInfo.SubRespRcvd = "SubResp"
@@ -118,6 +120,7 @@
subReq := e2ap.E2APSubscriptionRequest{}
subReq = subscriptionInfo.SubReqMsg
subs.SubReqMsg = &subReq
+ subs.PolicyUpdate = subscriptionInfo.PolicyUpdate
if subscriptionInfo.SubRespRcvd == "SubResp" {
subs.SubRespRcvd = true
diff --git a/pkg/control/subscription.go b/pkg/control/subscription.go
index 6ea2c1f..1152520 100644
--- a/pkg/control/subscription.go
+++ b/pkg/control/subscription.go
@@ -23,7 +23,6 @@
"gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
- //"reflect"
"sync"
)
@@ -35,15 +34,17 @@
valid bool // valid
registry *Registry // Registry
ReqId RequestId // ReqId (Requestor Id + Seq Nro a.k.a subsid)
- Meid *xapp.RMRMeid // Meid/ RanName
+ Meid *xapp.RMRMeid // Meid/RanName
EpList xapp.RmrEndpointList // Endpoints
+ RMRRouteCreated bool // Does subscription have RMR route
TransLock sync.Mutex // Lock transactions, only one executed per time for subs
TheTrans TransactionIf // Ongoing transaction
SubReqMsg *e2ap.E2APSubscriptionRequest // Subscription information
SubRFMsg interface{} // Subscription information
+ PolicyUpdate bool // This is true when policy subscrition is being updated. Used not to send delete for update after timeout or restart
RetryFromXapp bool // Retry form xApp for subscription that already exist
SubRespRcvd bool // Subscription response received
- DeleteFromDb bool // Delete subscription form db
+ DeleteFromDb bool // Delete subscription from db
NoRespToXapp bool // Send no response for subscription delete to xApp after restart
DoNotWaitSubResp bool // Test flag. Response is not waited for Subscription Request
}
@@ -160,8 +161,6 @@
return false
}
}
- //reflect.DeepEqual(acts.ActionDefinitionChoice, actt.ActionDefinitionChoice)
-
if acts.SubsequentAction.Present != actt.SubsequentAction.Present ||
acts.SubsequentAction.Type != actt.SubsequentAction.Type ||
acts.SubsequentAction.TimetoWait != actt.SubsequentAction.TimetoWait {
@@ -169,6 +168,5 @@
}
}
}
-
return true
}
diff --git a/pkg/control/types.go b/pkg/control/types.go
index c8c09dc..0123357 100644
--- a/pkg/control/types.go
+++ b/pkg/control/types.go
@@ -20,6 +20,8 @@
package control
import (
+ "time"
+
"gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
)
@@ -41,3 +43,31 @@
Remove(keys []string) error
RemoveAll() error
}
+
+type E2SubscriptionDirectives struct {
+ // How many times E2 subscription request is retried
+ // Required: true
+ // Maximum: 10
+ // Minimum: 0
+ E2MaxTryCount int64
+
+ // How long time response is waited from E2 node
+ // Maximum: 10s
+ // Minimum: 1s
+ E2TimeoutTimerValue time.Duration
+
+ // Subscription needs RMR route from E2Term to xApp
+ CreateRMRRoute bool
+}
+
+type ErrorInfo struct {
+ ErrorCause string
+ ErrorSource string
+ TimeoutType string
+}
+
+func (e *ErrorInfo) SetInfo(errorCause string, errorSource string, timeoutType string) {
+ e.ErrorCause = errorCause
+ e.ErrorSource = errorSource
+ e.TimeoutType = timeoutType
+}
diff --git a/pkg/control/ut_ctrl_submgr_test.go b/pkg/control/ut_ctrl_submgr_test.go
index ee7bc82..16c69b1 100644
--- a/pkg/control/ut_ctrl_submgr_test.go
+++ b/pkg/control/ut_ctrl_submgr_test.go
@@ -55,6 +55,8 @@
mainCtrl = &testingSubmgrControl{}
mainCtrl.RmrControl.Init("SUBMGRCTL", srcId, rtgSvc)
mainCtrl.c = NewControl()
+ mainCtrl.c.LoggerLevel = int(xapp.Logger.GetLevel())
+ xapp.Logger.Debug("Test: LoggerLevel %v", mainCtrl.c.LoggerLevel)
xapp.Logger.Debug("Replacing real db with test db")
mainCtrl.c.e2SubsDb = CreateMock() // This overrides real E2 Subscription database for testing
mainCtrl.c.restSubsDb = CreateRestSubsDbMock() // This overrides real REST Subscription database for testing
@@ -76,17 +78,8 @@
if err != nil {
mc.TestError(t, "%v", err)
} else {
- mainCtrl.c.registry.register = nil
mainCtrl.c.registry.subIds = subIds
mainCtrl.c.registry.register = register
-
- mc.TestLog(t, "register:")
- for subId, subs := range register {
- mc.TestLog(t, " subId=%v", subId)
- mc.TestLog(t, " subs.SubRespRcvd=%v", subs.SubRespRcvd)
- mc.TestLog(t, " subs=%v\n", subs)
- }
-
mc.TestLog(t, "mainCtrl.c.registry.register:")
for subId, subs := range mainCtrl.c.registry.register {
mc.TestLog(t, " subId=%v", subId)
@@ -94,6 +87,18 @@
mc.TestLog(t, " subs=%v\n", subs)
}
}
+ restSubscriptions, err := mainCtrl.c.ReadAllRESTSubscriptionsFromSdl()
+ if err != nil {
+ mc.TestError(t, "%v", err)
+ } else {
+ mainCtrl.c.registry.restSubscriptions = restSubscriptions
+ mc.TestLog(t, "mainCtrl.c.registry.restSubscriptions:")
+ for restSubId, restSubs := range mainCtrl.c.registry.restSubscriptions {
+ mc.TestLog(t, " restSubId=%v", restSubId)
+ mc.TestLog(t, " restSubs=%v\n", restSubs)
+ }
+ }
+
go mainCtrl.c.HandleUncompletedSubscriptions(mainCtrl.c.registry.register)
}
@@ -136,7 +141,7 @@
}
time.Sleep(100 * time.Millisecond)
}
- mc.TestError(t, "(submgr) no registry empty within %d secs: %d", secs, cnt)
+ mc.TestError(t, "(submgr) no registry empty within %d secs: %d, register: %v", secs, cnt, mc.c.registry.register)
return false
}
@@ -311,6 +316,8 @@
}
func (mc *testingSubmgrControl) VerifyCounterValues(t *testing.T) {
+
+ // Check that expected counters are added ok
currentCountersMap := mc.GetCurrentCounterValues(t, toBeAddedCountersMap)
for _, toBeAddedCounter := range toBeAddedCountersMap {
if currentCounter, ok := currentCountersMap[toBeAddedCounter.Name]; ok == true {
@@ -329,6 +336,22 @@
}
}
+ // Check that not any unexpected counter are added
+ for _, currentCounter := range currentCountersMap {
+ if _, ok := toBeAddedCountersMap[currentCounter.Name]; ok == false {
+ if beforeCounter, ok := countersBeforeMap[currentCounter.Name]; ok == true {
+ if currentCounter.Value != beforeCounter.Value {
+ mc.TestError(t, "Error: unexpected counter value added: counterName %v, current value %v, expected value %v",
+ currentCounter.Name, beforeCounter.Value, beforeCounter.Value)
+
+ //fmt.Printf("beforeCounter.Value=%v, toBeAddedCounter.Value=%v, \n",beforeCounter.Value, toBeAddedCounter.Value)
+ }
+ } else {
+ mc.TestError(t, "Counter %v not in countersBeforeMap", beforeCounter.Name)
+ }
+ }
+ }
+
// Make map empty
//fmt.Printf("toBeAddedCountersMap=%v\n",toBeAddedCountersMap)
toBeAddedCountersMap = make(map[string]Counter)
diff --git a/pkg/control/ut_messaging_test.go b/pkg/control/ut_messaging_test.go
index bc1b6d3..cd8a832 100644
--- a/pkg/control/ut_messaging_test.go
+++ b/pkg/control/ut_messaging_test.go
@@ -2134,6 +2134,7 @@
mainCtrl.SimulateRestart(t)
xapp.Logger.Debug("mainCtrl.SimulateRestart done")
+ // Submgr send delete for uncompleted subscription
delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
e2termConn1.SendSubsDelResp(t, delreq, delmsg)
@@ -2419,6 +2420,7 @@
})
const subReqCount int = 1
+
// Add delay for rtmgt HTTP handling so that HTTP response is received before notify on XAPP side
waiter := rtmgrHttp.AllocNextSleep(50, false)
newSubsId := mainCtrl.get_registry_next_subid(t)
@@ -2430,7 +2432,7 @@
waiter.WaitResult(t)
e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
- xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
+ xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
// Del
xappConn1.SendRESTSubsDelReq(t, &restSubId)
@@ -2472,7 +2474,7 @@
params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
params.SetMeid("RAN_NAME_1")
restSubId2 := xappConn2.SendRESTSubsReq(t, params)
- xapp.Logger.Info("Send REST subscriber request for second subscriber : %v", restSubId2)
+ xapp.Logger.Debug("Send REST subscriber request for second subscriber : %v", restSubId2)
xappConn2.ExpectRESTNotificationNok(t, restSubId2, "allFail")
waiter.WaitResult(t)
// e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2) - TOD: missing delete
@@ -2617,11 +2619,15 @@
// Subs Create
const subReqCount int = 1
+ // const e2Timeout int64 = 2
+ // const e2RetryCount int64 = 2
+ // const routingNeeded bool = true
// In order to force both XAPP's to create their own subscriptions, force rtmgr to block a while so that 2nd create
// gets into execution before the rtmgrg responds for the first one.
waiter := rtmgrHttp.AllocNextSleep(10, true)
params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
+ // params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
restSubId1 := xappConn1.SendRESTSubsReq(t, params)
xappConn2.SendRESTSubsReq(t, params)
@@ -2635,7 +2641,7 @@
e2termConn1.SendSubsResp(t, crereq, cremsg)
e2SubsIdA := <-xappConn1.ListedRESTNotifications
- xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
+ xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
// Del1
xappConn1.SendRESTSubsDelReq(t, &restSubId1)
@@ -3324,12 +3330,12 @@
//Req1
params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
restSubId1 := xappConn1.SendRESTSubsReq(t, params)
- xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
+ xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
//Req2
params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
restSubId2 := xappConn2.SendRESTSubsReq(t, params)
- xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
+ xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
@@ -3343,9 +3349,9 @@
e2termConn1.SendSubsResp(t, crereq2, cremsg2)
e2SubsIdA := <-xappConn1.ListedRESTNotifications
- xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
+ xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
e2SubsIdB := <-xappConn1.ListedRESTNotifications
- xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
+ xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
//Del1
deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
@@ -3377,12 +3383,12 @@
params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
- xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
+ xapp.Logger.Debug("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
params.SetMeid("RAN_NAME_2")
restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
- xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
+ xapp.Logger.Debug("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
//Del1
deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
@@ -3417,11 +3423,11 @@
params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
restSubId := xappConn1.SendRESTSubsReq(t, params)
- xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
+ xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
// Catch the first message and ignore it
crereq, cremsg := e2termConn1.RecvSubsReq(t)
- xapp.Logger.Info("Ignore REST subscriber request for subscriber : %v", restSubId)
+ xapp.Logger.Debug("Ignore REST subscriber request for subscriber : %v", restSubId)
// The second request is being handled normally
crereq, cremsg = e2termConn1.RecvSubsReq(t)
@@ -3496,13 +3502,13 @@
params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
restSubId := xappConn1.SendRESTSubsReq(t, params)
- xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
+ xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
e2termConn1.RecvSubsReq(t)
- xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
+ xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
e2termConn1.RecvSubsReq(t)
- xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
+ xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
@@ -3531,20 +3537,20 @@
params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
restSubId := xappConn1.SendRESTSubsReq(t, params)
- xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
+ xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
e2termConn1.RecvSubsReq(t)
- xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
+ xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
e2termConn1.RecvSubsReq(t)
- xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
+ xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
e2termConn1.RecvSubsDelReq(t)
- xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
+ xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
e2termConn1.RecvSubsDelReq(t)
- xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
+ xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
@@ -3609,20 +3615,20 @@
params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
restSubId := xappConn1.SendRESTSubsReq(t, params)
- xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
+ xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
e2termConn1.RecvSubsReq(t)
- xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
+ xapp.Logger.Debug("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
e2termConn1.RecvSubsReq(t)
- xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
+ xapp.Logger.Debug("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
e2termConn1.RecvSubsDelReq(t)
- xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
+ xapp.Logger.Debug("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
e2termConn1.RecvSubsDelReq(t)
- xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
+ xapp.Logger.Debug("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
@@ -3690,7 +3696,7 @@
xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
- xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
+ xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
// REST subscription sill there to be deleted
xappConn1.SendRESTSubsDelReq(t, &restSubId)
@@ -3964,9 +3970,9 @@
waiter := rtmgrHttp.AllocNextSleep(10, true)
restSubId2 := xappConn2.SendRESTSubsReq(t, params)
waiter.WaitResult(t)
- xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
+ xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
- xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
+ xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
@@ -4164,9 +4170,9 @@
e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
e2SubsIdA := <-xappConn1.ListedRESTNotifications
- xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
+ xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
e2SubsIdB := <-xappConn1.ListedRESTNotifications
- xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
+ xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
// Del1
xappConn1.SendRESTSubsDelReq(t, &restSubId1)
@@ -4271,9 +4277,9 @@
e2termConn1.SendSubsDelResp(t, delreq, delmsg)
e2SubsIdA := <-xappConn1.ListedRESTNotifications
- xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
+ xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
e2SubsIdB := <-xappConn1.ListedRESTNotifications
- xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
+ xapp.Logger.Debug("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
// Del1
xappConn1.SendRESTSubsDelReq(t, &restSubId1)
@@ -4304,17 +4310,15 @@
Counter{cRestSubDelRespToXapp, 1},
})
- const subReqCount int = 1
-
params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
restSubId := xappConn1.SendRESTSubsReq(t, params)
- xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
+ xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
xappConn1.ExpectRESTNotification(t, restSubId)
e2termConn1.SendSubsResp(t, crereq1, cremsg1)
e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
- xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
+ xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
xappConn1.SendRESTSubsDelReq(t, &restSubId)
delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
@@ -4390,15 +4394,20 @@
})
const subReqCount int = 1
+ const e2Timeout int64 = 1
+ const e2RetryCount int64 = 0
+ const routingNeeded bool = true
// Req
params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
+ params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
// Policy change
- // GetRESTSubsReqPolicyParams sets some coutners on tc side.
+ // GetRESTSubsReqPolicyParams sets some counters on tc side.
params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
+ params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
params.SetSubscriptionID(&restSubId)
params.SetTimeToWait("w200ms")
restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
@@ -4439,7 +4448,7 @@
// | RESTSubReq | |
// |---------------->| |
// | | |
-// | RESTSubUpdateFail |
+// | RESTSubUpdateFail(400 Bad request)
// | | |
// | RESTSubDelReq | |
// |---------------->| |
@@ -4470,17 +4479,14 @@
Counter{cRestSubDelRespToXapp, 1},
})
- const subReqCount int = 1
-
// Req
params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
// Policy change
-
params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
- restSubIdUpd := strings.ToUpper(restSubId)
+ restSubIdUpd := strings.ToUpper(restSubId) // This makes RESTSubReq to fail
params.SetSubscriptionID(&restSubIdUpd)
params.SetTimeToWait("w200ms")
@@ -4574,13 +4580,13 @@
xappConn1.ExpectRESTNotification(t, restSubId1)
e2termConn1.SendSubsResp(t, crereq1, cremsg1)
e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
- xapp.Logger.Info("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
+ xapp.Logger.Debug("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
// Resp2
xappConn2.ExpectRESTNotification(t, restSubId2)
e2termConn2.SendSubsResp(t, crereq2, cremsg2)
e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
- xapp.Logger.Info("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
+ xapp.Logger.Debug("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
// Delete1
xappConn1.SendRESTSubsDelReq(t, &restSubId1)
@@ -4626,7 +4632,7 @@
func TestRESTSubReqAsn1EncodeFail(t *testing.T) {
CaseBegin("TestRESTSubReqAsn1EncodeFail")
- xapp.Logger.Info("Xapp-frame, v0.8.1 sufficient REST API validation")
+ xapp.Logger.Debug("Xapp-frame, v0.8.1 sufficient REST API validation")
}
@@ -4750,7 +4756,7 @@
//Req
mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
restSubId := xappConn1.SendRESTSubsReq(t, params)
- xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
+ xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
e2termConn1.RecvSubsReq(t)
@@ -4831,17 +4837,13 @@
// Create subscription
restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
- xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
+ xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
// Check subscription
queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
- // When SDL support for the REST Interface is added
- // the submgr restart statement below should be removed
- // from the comment.
-
- // mainCtrl.SimulateRestart(t)
- // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
+ mainCtrl.SimulateRestart(t)
+ xapp.Logger.Debug("mainCtrl.SimulateRestart done")
// Check subscription
queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
@@ -4934,7 +4936,7 @@
// Create subscription 1
restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
- xapp.Logger.Info("Send REST subscriber request for subscriber 1 : %v", restSubId1)
+ xapp.Logger.Debug("Send REST subscriber request for subscriber 1 : %v", restSubId1)
// Create subscription 2 with same action
params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
@@ -4942,30 +4944,22 @@
xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
xappConn2.ExpectAnyNotification(t)
restSubId2 := xappConn2.SendRESTSubsReq(t, params)
- xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
+ xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
- xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
+ xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId2)
queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
- // When SDL support for the REST Interface is added
- // the submgr restart statement below should be removed
- // from the comment.
-
- // mainCtrl.SimulateRestart(t)
- // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
+ mainCtrl.SimulateRestart(t)
+ xapp.Logger.Debug("mainCtrl.SimulateRestart done")
// Delete subscription 1, and wait until it has removed the first endpoint
subepcnt := mainCtrl.get_subs_entrypoint_cnt(t, e2SubsId1)
xappConn1.SendRESTSubsDelReq(t, &restSubId1)
mainCtrl.wait_subs_entrypoint_cnt_change(t, e2SubsId1, subepcnt, 10)
- // When SDL support for the REST Interface is added
- // the submgr restart statement below should be removed
- // from the comment.
-
- // mainCtrl.SimulateRestart(t)
- // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
+ mainCtrl.SimulateRestart(t)
+ xapp.Logger.Debug("mainCtrl.SimulateRestart done")
queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
// Delete subscription 2
@@ -5024,13 +5018,13 @@
func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
CaseBegin("TestRESTReportSubReqAndSubDelOk")
- subReqCount := 1
+ const subReqCount int = 1
testIndex := 1
RESTReportSubReqAndSubDelOk(t, subReqCount, testIndex)
}
func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
- xapp.Logger.Info("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
+ xapp.Logger.Debug("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
// Req
params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
@@ -5043,7 +5037,7 @@
e2termConn1.SendSubsResp(t, crereq, cremsg)
instanceId := xappConn1.WaitRESTNotification(t, restSubId)
- xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
+ xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
e2SubsId = append(e2SubsId, instanceId)
resp, _ := xapp.Subscription.QuerySubscriptions()
assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
@@ -5084,13 +5078,11 @@
}
*/
func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
- xapp.Logger.Info("TEST: TestRESTPolicySubReqAndSubDelOk with testIndex %v", testIndex)
+ xapp.Logger.Debug("TEST: TestRESTPolicySubReqAndSubDelOk with testIndex %v", testIndex)
// Req
params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
restSubId := xappConn1.SendRESTSubsReq(t, params)
- //params := xappConn1.GetRESTSubsReqPolicyParams1(subReqCount)
- //restSubId := xappConn1.SendRESTPolicySubsReq(t, params)
var e2SubsId []uint32
for i := 0; i < subReqCount; i++ {
@@ -5098,7 +5090,7 @@
xappConn1.ExpectRESTNotification(t, restSubId)
e2termConn1.SendSubsResp(t, crereq, cremsg)
instanceId := xappConn1.WaitRESTNotification(t, restSubId)
- xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
+ xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
e2SubsId = append(e2SubsId, instanceId)
}
@@ -5121,8 +5113,6 @@
func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
- subReqCount := 2
-
mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Counter{cRestSubReqFromXapp, 1},
Counter{cRestSubRespToXapp, 1},
@@ -5135,6 +5125,8 @@
Counter{cRestSubDelRespToXapp, 1},
})
+ const subReqCount int = 2
+
// Req
params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
restSubId := xappConn1.SendRESTSubsReq(t, params)
@@ -5154,8 +5146,6 @@
}
func TestRESTPolicySubReqAndSubDelOkFullAmount(t *testing.T) {
- subReqCount := 19
-
mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Counter{cRestSubReqFromXapp, 1},
Counter{cRestSubRespToXapp, 1},
@@ -5168,6 +5158,7 @@
Counter{cRestSubDelRespToXapp, 1},
})
+ const subReqCount int = 19
// Req
params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
restSubId := xappConn1.SendRESTSubsReq(t, params)
@@ -5184,6 +5175,7 @@
mainCtrl.VerifyCounterValues(t)
}
+
func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
subReqCount := 2
@@ -5306,7 +5298,7 @@
//Subs Create
restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
- xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
+ xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
@@ -5317,7 +5309,7 @@
params.SetSubEventTriggerDefinition(eventTriggerDefinition)
restSubId2 := xappConn2.SendRESTSubsReq(t, params)
- xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
+ xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
crereq, cremsg := e2termConn1.RecvSubsReq(t)
xappConn2.ExpectRESTNotification(t, restSubId2)
e2termConn1.SendSubsResp(t, crereq, cremsg)
@@ -5353,7 +5345,7 @@
//Subs Create
restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
- xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
+ xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
@@ -5369,7 +5361,7 @@
params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
restSubId2 := xappConn2.SendRESTSubsReq(t, params)
- xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
+ xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
crereq, cremsg := e2termConn1.RecvSubsReq(t)
xappConn2.ExpectRESTNotification(t, restSubId2)
e2termConn1.SendSubsResp(t, crereq, cremsg)
@@ -5405,7 +5397,7 @@
//Subs Create
restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
- xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
+ xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
@@ -5415,7 +5407,7 @@
params.SetSubActionIDs(int64(2))
restSubId2 := xappConn2.SendRESTSubsReq(t, params)
- xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
+ xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
crereq, cremsg := e2termConn1.RecvSubsReq(t)
xappConn2.ExpectRESTNotification(t, restSubId2)
e2termConn1.SendSubsResp(t, crereq, cremsg)
@@ -5446,21 +5438,27 @@
Counter{cRestSubDelRespToXapp, 2},
})
+ const e2Timeout int64 = 2
+ const e2RetryCount int64 = 2
+ const routingNeeded bool = true
+
// Req1
params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
+ params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
//Subs Create
restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
- xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
+ xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
// Req2
params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
+ params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
params.SetMeid("RAN_NAME_1")
restSubId2 := xappConn2.SendRESTSubsReq(t, params)
- xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
+ xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
crereq, cremsg := e2termConn1.RecvSubsReq(t)
xappConn2.ExpectRESTNotification(t, restSubId2)
e2termConn1.SendSubsResp(t, crereq, cremsg)
@@ -5491,21 +5489,27 @@
Counter{cRestSubDelRespToXapp, 2},
})
+ const e2Timeout int64 = 2
+ const e2RetryCount int64 = 2
+ const routingNeeded bool = true
+
// Req1
params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
+ params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
//Subs Create
restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
- xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
+ xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
// Req2
params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount)
+ params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
params.SetMeid("RAN_NAME_1")
restSubId2 := xappConn2.SendRESTSubsReq(t, params)
- xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
+ xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
crereq, cremsg := e2termConn1.RecvSubsReq(t)
xappConn2.ExpectRESTNotification(t, restSubId2)
e2termConn1.SendSubsResp(t, crereq, cremsg)
@@ -5541,7 +5545,7 @@
//Subs Create
restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
- xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
+ xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
@@ -5552,7 +5556,7 @@
params.SetSubActionDefinition(actionDefinition)
restSubId2 := xappConn2.SendRESTSubsReq(t, params)
- xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
+ xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
crereq, cremsg := e2termConn1.RecvSubsReq(t)
xappConn2.ExpectRESTNotification(t, restSubId2)
e2termConn1.SendSubsResp(t, crereq, cremsg)
@@ -5588,7 +5592,7 @@
//Subs Create
restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
- xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
+ xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
@@ -5599,7 +5603,7 @@
params.SetSubActionDefinition(actionDefinition)
restSubId2 := xappConn2.SendRESTSubsReq(t, params)
- xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
+ xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
crereq, cremsg := e2termConn1.RecvSubsReq(t)
xappConn2.ExpectRESTNotification(t, restSubId2)
e2termConn1.SendSubsResp(t, crereq, cremsg)
@@ -5635,7 +5639,7 @@
//Subs Create
restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
- xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
+ xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId1)
queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
@@ -5644,7 +5648,7 @@
params.SetMeid("RAN_NAME_1")
params.SetTimeToWait("w200ms")
restSubId2 := xappConn2.SendRESTSubsReq(t, params)
- xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
+ xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId2)
crereq, cremsg := e2termConn1.RecvSubsReq(t)
xappConn2.ExpectRESTNotification(t, restSubId2)
e2termConn1.SendSubsResp(t, crereq, cremsg)
@@ -5696,8 +5700,8 @@
//-----------------------------------------------------------------------------
func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
- xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseDecodeFail")
- subReqCount := 1
+ xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseDecodeFail")
+ const subReqCount int = 1
// Req
params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
@@ -5721,7 +5725,7 @@
e2termConn1.SendSubsDelResp(t, delreq, delmsg)
instanceId := xappConn1.WaitRESTNotification(t, restSubId)
- xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
+ xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
// Wait that subs is cleaned
mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
@@ -5767,8 +5771,8 @@
//-----------------------------------------------------------------------------
func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
- xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId")
- subReqCount := 1
+ xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId")
+ const subReqCount int = 1
// Req
params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
@@ -5795,7 +5799,7 @@
e2termConn1.SendSubsDelResp(t, delreq, delmsg)
instanceId := xappConn1.WaitRESTNotification(t, restSubId)
- xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
+ xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
// Wait that subs is cleaned
mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
@@ -5846,8 +5850,8 @@
//
//-----------------------------------------------------------------------------
func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
- xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseNoTransaction")
- subReqCount := 1
+ xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseNoTransaction")
+ const subReqCount int = 1
// Req
params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
@@ -5877,7 +5881,7 @@
e2termConn1.SendSubsDelResp(t, delreq, delmsg)
instanceId := xappConn1.WaitRESTNotification(t, restSubId)
- xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
+ xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
// Wait that subs is cleaned
mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
@@ -5923,8 +5927,8 @@
//
//-----------------------------------------------------------------------------
func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
- xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureDecodeFail")
- subReqCount := 1
+ xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureDecodeFail")
+ const subReqCount int = 1
// Req
params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
@@ -5949,7 +5953,7 @@
e2termConn1.SendSubsDelResp(t, delreq, delmsg)
instanceId := xappConn1.WaitRESTNotification(t, restSubId)
- xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
+ xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
// Wait that subs is cleaned
mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
@@ -5994,8 +5998,8 @@
//
//-----------------------------------------------------------------------------
func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
- xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureUnknownInstanceId")
- subReqCount := 1
+ xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureUnknownInstanceId")
+ const subReqCount int = 1
// Req
params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
@@ -6021,7 +6025,7 @@
e2termConn1.SendSubsDelResp(t, delreq, delmsg)
instanceId := xappConn1.WaitRESTNotification(t, restSubId)
- xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
+ xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
// Wait that subs is cleaned
mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
@@ -6066,8 +6070,8 @@
//
//-----------------------------------------------------------------------------
func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
- xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureNoTransaction")
- subReqCount := 1
+ xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureNoTransaction")
+ const subReqCount int = 1
// Req
params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
@@ -6098,7 +6102,7 @@
e2termConn1.SendSubsDelResp(t, delreq, delmsg)
instanceId := xappConn1.WaitRESTNotification(t, restSubId)
- xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
+ xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
// Wait that subs is cleaned
mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
@@ -6140,7 +6144,7 @@
//
//-----------------------------------------------------------------------------
func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
- xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseDecodeFail")
+ xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseDecodeFail")
// Req
var params *teststube2ap.RESTSubsReqParams = nil
@@ -6200,7 +6204,7 @@
//
//-----------------------------------------------------------------------------
func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
- xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId")
+ xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId")
// Req
var params *teststube2ap.RESTSubsReqParams = nil
@@ -6261,7 +6265,7 @@
//
//-----------------------------------------------------------------------------
func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
- xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseNoTransaction")
+ xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseNoTransaction")
// Req
var params *teststube2ap.RESTSubsReqParams = nil
@@ -6323,7 +6327,7 @@
//
//-----------------------------------------------------------------------------
func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
- xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteFailureDecodeFail")
+ xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteFailureDecodeFail")
// Req
var params *teststube2ap.RESTSubsReqParams = nil
@@ -6383,7 +6387,7 @@
//
//-----------------------------------------------------------------------------
func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
- xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId")
+ xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId")
// Req
var params *teststube2ap.RESTSubsReqParams = nil
@@ -6444,7 +6448,7 @@
//
//-----------------------------------------------------------------------------
func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
- xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteFailureNoTransaction")
+ xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteFailureNoTransaction")
// Req
var params *teststube2ap.RESTSubsReqParams = nil
@@ -6510,12 +6514,10 @@
mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Counter{cRestSubReqFromXapp, 1},
Counter{cRestSubRespToXapp, 1},
- Counter{cSubDelReqToE2, 1},
- Counter{cSubDelFailFromE2, 1},
Counter{cRestSubFailNotifToXapp, 1},
})
- subReqCount := 1
+ const subReqCount int = 1
var params *teststube2ap.RESTSubsReqParams = nil
params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
@@ -6523,17 +6525,13 @@
// Req
restSubId := xappConn1.SendRESTSubsReq(t, params)
- xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
+ xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
// E2t: Receive SubsDelReq
- delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
- // Subscription does not exist in in E2 Node.
- e2termConn1.SendSubsDelFail(t, delreq, delmsg)
-
e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
- xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
+ xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
// Wait that subs is cleaned
@@ -6541,6 +6539,183 @@
mainCtrl.VerifyCounterValues(t)
}
+func TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction(t *testing.T) {
+ CaseBegin("TestRESTSubReqPolicyUpdateTimeoutAndSubDelOkSameAction")
+
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cRestSubReqFromXapp, 2},
+ Counter{cRestSubRespToXapp, 2},
+ Counter{cSubReqToE2, 2},
+ Counter{cSubRespFromE2, 1},
+ Counter{cRestSubNotifToXapp, 1},
+ Counter{cRestSubFailNotifToXapp, 1},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cSubDelReqToE2, 1},
+ Counter{cSubDelRespFromE2, 1},
+ Counter{cRestSubDelRespToXapp, 1},
+ })
+
+ const e2Timeout int64 = 1
+ const e2RetryCount int64 = 0
+ const routingNeeded bool = false
+
+ // Req1
+ params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
+ params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
+
+ // Subs Create
+ restSubId := xappConn1.SendRESTSubsReq(t, params)
+ xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
+
+ crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
+ xappConn1.ExpectRESTNotification(t, restSubId)
+ e2termConn1.SendSubsResp(t, crereq1, cremsg1)
+ e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
+ xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
+
+ // Policy change
+ params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
+ params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
+ params.SetSubscriptionID(&restSubId)
+ params.SetTimeToWait("w200ms")
+ restSubId = xappConn1.SendRESTSubsReq(t, params)
+ xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
+
+ crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
+ xappConn1.ExpectRESTNotification(t, restSubId)
+ // SubsResp is missing
+ e2SubsId = xappConn1.WaitRESTNotification(t, restSubId)
+ xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
+
+ // Del
+ xappConn1.SendRESTSubsDelReq(t, &restSubId)
+ delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+ e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+
+ waitSubsCleanup(t, e2SubsId, 10)
+
+ mainCtrl.VerifyCounterValues(t)
+}
+
+//-----------------------------------------------------------------------------
+// TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle
+//
+// stub stub
+// +-------+ +---------+ +---------+
+// | xapp | | submgr | | e2term |
+// +-------+ +---------+ +---------+
+// | | |
+// | RESTSubReq | |
+// |---------------->| |
+// | | |
+// | RESTSubResp | |
+// |<----------------| |
+// | | SubReq |
+// | |------------->|
+// | | |
+// | | SubResp |
+// | |<-------------|
+// | | |
+// | RESTNotif | |
+// |<----------------| |
+// | | |
+// | RESTSubReq | |
+// |---------------->| |
+// | | |
+// | RESTSubResp | |
+// |<----------------| |
+// | | SubReq |
+// | |------------->|
+// | |
+// | Submgr restart |
+// | | |
+// | RESTSubDelReq | |
+// |---------------->| |
+// | | |
+// | | SubDelReq |
+// | |------------->|
+// | | |
+// | | SubDelResp |
+// | |<-------------|
+// | | |
+// | RESTSubDelResp | |
+// |<----------------| |
+//
+//-----------------------------------------------------------------------------
+
+func TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
+ CaseBegin("TestPolicyUpdateRESTSubReqAndSubDelOkWithRestartInMiddle")
+
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cRestSubReqFromXapp, 2},
+ Counter{cRestSubRespToXapp, 2},
+ Counter{cSubReqToE2, 2},
+ Counter{cSubRespFromE2, 1},
+ Counter{cRestSubNotifToXapp, 1},
+ Counter{cRestSubNotifToXapp, 1},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cSubDelReqToE2, 1},
+ Counter{cRestSubDelRespToXapp, 1},
+ })
+
+ // Remove possible existing subscription
+ mainCtrl.removeExistingSubscriptions(t)
+
+ const e2Timeout int64 = 1
+ const e2RetryCount int64 = 0
+ const routingNeeded bool = false
+
+ // Req1
+ params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
+ params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
+ // Create subscription
+ restSubId := xappConn1.SendRESTSubsReq(t, params)
+ xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
+
+ crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
+ xappConn1.ExpectRESTNotification(t, restSubId)
+ e2termConn1.SendSubsResp(t, crereq1, cremsg1)
+ e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
+ xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
+
+ // Check subscription
+ queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
+
+ // Policy change
+ params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
+ params.SetSubscriptionDirectives(e2Timeout, e2RetryCount, routingNeeded)
+ params.SetSubscriptionID(&restSubId)
+ params.SetTimeToWait("w200ms")
+ mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
+ restSubId = xappConn1.SendRESTSubsReq(t, params)
+ xapp.Logger.Debug("Send REST subscribe request for subscriberId : %v", restSubId)
+
+ crereq1, cremsg1 = e2termConn1.RecvSubsReq(t)
+ mainCtrl.SetResetTestFlag(t, false)
+
+ // SubsResp is missing due to submgr restart
+
+ mainCtrl.SimulateRestart(t)
+ xapp.Logger.Debug("mainCtrl.SimulateRestart done")
+
+ // Check subscription
+ queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
+
+ xapp.Logger.Debug("Here 1")
+ //<-time.After(3 * time.Second)
+ xapp.Logger.Debug("Here 2")
+
+ // Delete subscription
+ 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)
+}
+
////////////////////////////////////////////////////////////////////////////////////
// Services for UT cases
////////////////////////////////////////////////////////////////////////////////////
@@ -6552,13 +6727,13 @@
params = fromXappConn.GetRESTSubsReqReportParams(subReqCount)
}
restSubId := fromXappConn.SendRESTSubsReq(t, params)
- xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
+ xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
fromXappConn.ExpectRESTNotification(t, restSubId)
toE2termConn.SendSubsResp(t, crereq1, cremsg1)
e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
- xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
+ xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
return restSubId, e2SubsId
}
@@ -6572,23 +6747,24 @@
xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
restSubId := xappConn2.SendRESTSubsReq(t, params)
xappConn2.ExpectRESTNotification(t, restSubId)
- xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
+ xapp.Logger.Debug("Send REST subscriber request for subscriberId : %v", restSubId)
e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
- xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
+ xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
return restSubId, e2SubsId
}
func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
+
params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
restSubId := xappConn1.SendRESTSubsReq(t, params)
- xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
+ xapp.Logger.Debug("Send REST Policy subscriber request for subscriberId : %v", restSubId)
crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
xappConn1.ExpectRESTNotification(t, restSubId)
e2termConn1.SendSubsResp(t, crereq1, cremsg1)
e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
- xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
+ xapp.Logger.Debug("REST notification received e2SubsId=%v", e2SubsId)
return restSubId, e2SubsId
}
@@ -6606,7 +6782,7 @@
xappConn1.ExpectRESTNotification(t, restSubId)
e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
- xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
+ xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
return restSubId, e2SubsId
}
@@ -6651,14 +6827,14 @@
var e2SubsId []uint32
for i := 0; i < count; i++ {
- xapp.Logger.Info("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
+ xapp.Logger.Debug("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
crereq, cremsg := toE2termConn.RecvSubsReq(t)
fromXappConn.ExpectRESTNotification(t, restSubId)
toE2termConn.SendSubsResp(t, crereq, cremsg)
instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
e2SubsId = append(e2SubsId, instanceId)
- xapp.Logger.Info("TEST: %v", e2SubsId)
- xapp.Logger.Info("TEST: %d ===================================== END CRE ============================================", i+1)
+ xapp.Logger.Debug("TEST: %v", e2SubsId)
+ xapp.Logger.Debug("TEST: %d ===================================== END CRE ============================================", i+1)
<-time.After(100 * time.Millisecond)
}
return e2SubsId
@@ -6667,11 +6843,11 @@
func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
for i := 0; i < len(e2SubsIds); i++ {
- xapp.Logger.Info("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
+ xapp.Logger.Debug("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
toE2termConn.SendSubsDelResp(t, delreq, delmsg)
<-time.After(1 * time.Second)
- xapp.Logger.Info("TEST: %d ===================================== END DEL ============================================", i+1)
+ xapp.Logger.Debug("TEST: %d ===================================== END DEL ============================================", i+1)
<-time.After(100 * time.Millisecond)
}
diff --git a/pkg/control/ut_stub_rtmgr_test.go b/pkg/control/ut_stub_rtmgr_test.go
index cc09efd..91a8fd8 100644
--- a/pkg/control/ut_stub_rtmgr_test.go
+++ b/pkg/control/ut_stub_rtmgr_test.go
@@ -106,7 +106,7 @@
if err != nil {
tc.Error("%s", err.Error())
}
- tc.Info("handling SubscriptionID=%d Address=%s Port=%d", *req.SubscriptionID, *req.Address, *req.Port)
+ tc.Debug("handling SubscriptionID=%d Address=%s Port=%d", *req.SubscriptionID, *req.Address, *req.Port)
id = *req.SubscriptionID
}
if r.Method == http.MethodPut {
@@ -115,7 +115,7 @@
if err != nil {
tc.Error("%s", err.Error())
}
- tc.Info("handling put")
+ tc.Debug("handling put")
}
var code int = 0
@@ -128,7 +128,7 @@
}
if tc.eventWaiter.sleep != 0 {
<-time.After(time.Duration(tc.eventWaiter.sleep) * time.Millisecond)
- tc.Info("sleeping done, %v", id)
+ tc.Debug("sleeping done, %v", id)
}
}
case http.MethodDelete:
@@ -154,7 +154,7 @@
if waiter != nil {
waiter.SetResult(true)
}
- tc.Info("Method=%s Reply with code %d", r.Method, code)
+ tc.Debug("Method=%s Reply with code %d", r.Method, code)
w.WriteHeader(code)
}
diff --git a/pkg/control/ut_test.go b/pkg/control/ut_test.go
index 5072cf4..8656d5d 100644
--- a/pkg/control/ut_test.go
+++ b/pkg/control/ut_test.go
@@ -35,7 +35,7 @@
//-----------------------------------------------------------------------------
func CaseBegin(desc string) *teststub.TestWrapper {
tent := teststub.NewTestWrapper(desc)
- tent.Info(desc)
+ tent.Debug(desc)
return tent
}
@@ -104,7 +104,7 @@
defer os.Remove(cfgfilename)
os.Setenv("CFG_FILE", cfgfilename)
*/
- tent.Info("Using cfg file %s", os.Getenv("CFG_FILE"))
+ tent.Debug("Using cfg file %s", os.Getenv("CFG_FILE"))
//---------------------------------
// Static routetable for rmr
@@ -152,12 +152,12 @@
rt.AddMeid(e2term2src.String(), []string{"RAN_NAME_11", "RAN_NAME_12"})
rt.Enable()
- tent.Info("rttable[%s]", rt.Table())
+ tent.Debug("rttable[%s]", rt.Table())
//---------------------------------
//
//---------------------------------
- tent.Info("### submgr ctrl run ###")
+ tent.Debug("### submgr ctrl run ###")
mainCtrl = createSubmgrControl(mainsrc, teststub.RmrRtgSvc{})
//
@@ -168,13 +168,13 @@
//env variables. Re-create rt info.
for i := 0; i < int(10)*2; i++ {
if os.Getenv("RMR_SEED_RT") == rt.FileName() {
- tent.Info("Waiting that alarm alternates RMR_SEED_RT=%s", os.Getenv("RMR_SEED_RT"))
+ tent.Debug("Waiting that alarm alternates RMR_SEED_RT=%s", os.Getenv("RMR_SEED_RT"))
time.Sleep(500 * time.Millisecond)
} else {
- tent.Info("Alarm has alternated RMR_SEED_RT=%s, so waiting 0.5 secs before restoring it", os.Getenv("RMR_SEED_RT"))
+ tent.Debug("Alarm has alternated RMR_SEED_RT=%s, so waiting 0.5 secs before restoring it", os.Getenv("RMR_SEED_RT"))
time.Sleep(500 * time.Millisecond)
rt.Enable()
- tent.Info("rttable[%s]", rt.Table())
+ tent.Debug("rttable[%s]", rt.Table())
break
}
}
@@ -187,31 +187,31 @@
//---------------------------------
//
//---------------------------------
- tent.Info("### xapp1 stub run ###")
+ tent.Debug("### xapp1 stub run ###")
xappConn1 = teststube2ap.CreateNewE2Stub("xappstub1", xapp1src, teststub.RmrRtgSvc{}, "RMRXAPP1STUB", teststubPortSeed, "RAN_NAME_1", "localhost", 13560, 8080)
//---------------------------------
//
//---------------------------------
- tent.Info("### xapp2 stub run ###")
+ tent.Debug("### xapp2 stub run ###")
xappConn2 = teststube2ap.CreateNewE2Stub("xappstub2", xapp2src, teststub.RmrRtgSvc{}, "RMRXAPP2STUB", teststubPortSeed, "RAN_NAME_2", "localhost", 13660, 8080)
//---------------------------------
//
//---------------------------------
- tent.Info("### e2term1 stub run ###")
+ tent.Debug("### e2term1 stub run ###")
e2termConn1 = teststube2ap.CreateNewE2termStub("e2termstub1", e2term1src, teststub.RmrRtgSvc{}, "RMRE2TERMSTUB1", teststubPortSeed)
//---------------------------------
//
//---------------------------------
- tent.Info("### e2term2 stub run ###")
+ tent.Debug("### e2term2 stub run ###")
e2termConn2 = teststube2ap.CreateNewE2termStub("e2termstub2", e2term2src, teststub.RmrRtgSvc{}, "RMRE2TERMSTUB2", teststubPortSeed)
//---------------------------------
// Just to test dummy stub
//---------------------------------
- tent.Info("### dummy stub run ###")
+ tent.Debug("### dummy stub run ###")
dummystub = teststubdummy.CreateNewRmrDummyStub("dummystub", dummysrc, teststub.RmrRtgSvc{}, "DUMMYSTUB", teststubPortSeed)
//---------------------------------