X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=pkg%2Fcontrol%2Fcontrol.go;h=5dedb1e37919c8c99e53e74d2c61092ba2a42046;hb=568d260371fd14454e5a3e41133e65bc7099a1b9;hp=3ebcbcd4789280ac83915ddd5f09519f395b94a9;hpb=0c67ea2d9517c84996886363a9975f55ea693c72;p=ric-plt%2Fsubmgr.git diff --git a/pkg/control/control.go b/pkg/control/control.go index 3ebcbcd..5dedb1e 100755 --- a/pkg/control/control.go +++ b/pkg/control/control.go @@ -86,6 +86,7 @@ type Control struct { ResetTestFlag bool Counters map[string]xapp.Counter LoggerLevel uint32 + UTTesting bool } type RMRMeid struct { @@ -427,7 +428,8 @@ func (c *Control) SubscriptionHandler(params interface{}) (*models.SubscriptionR func (c *Control) processSubscriptionRequests(restSubscription *RESTSubscription, subReqList *e2ap.SubscriptionRequestList, clientEndpoint *models.SubscriptionParamsClientEndpoint, meid *string, restSubId *string, xAppRmrEndpoint string, md5sum string) { - xapp.Logger.Info("Subscription Request count=%v ", len(subReqList.E2APSubscriptionRequests)) + c.SubscriptionProcessingStartDelay() + xapp.Logger.Debug("Subscription Request count=%v ", len(subReqList.E2APSubscriptionRequests)) var xAppEventInstanceID int64 var e2EventInstanceID int64 @@ -450,7 +452,8 @@ func (c *Control) processSubscriptionRequests(restSubscription *RESTSubscription subRespMsg, err := c.handleSubscriptionRequest(trans, &subReqMsg, meid, *restSubId) - xapp.Logger.Info("Handled SubscriptionRequest index=%v, %s", index, idstring(nil, trans)) + xapp.Logger.Debug("Handled SubscriptionRequest index=%v, %s", index, idstring(nil, trans)) + trans.Release() if err != nil { c.sendUnsuccesfullResponseNotification(restSubId, restSubscription, xAppEventInstanceID, err, clientEndpoint, trans) @@ -461,7 +464,19 @@ func (c *Control) processSubscriptionRequests(restSubscription *RESTSubscription index, *restSubId, clientEndpoint.Host, *clientEndpoint.HTTPPort, xAppEventInstanceID, e2EventInstanceID, idstring(nil, trans)) c.sendSuccesfullResponseNotification(restSubId, restSubscription, xAppEventInstanceID, e2EventInstanceID, clientEndpoint, trans) } - trans.Release() + } +} + +//------------------------------------------------------------------- +// +//------------------------------------------------------------------ +func (c *Control) SubscriptionProcessingStartDelay() { + if c.UTTesting == true { + // This is temporary fix for the UT problem that notification arrives before subscription response + // Correct fix would be to allow notification come before response and process it correctly + xapp.Logger.Debug("Setting 50 ms delay before starting processing Subscriptions") + <-time.After(time.Millisecond * 50) + xapp.Logger.Debug("Continuing after delay") } }