From: Anssi Mannila Date: Tue, 5 Oct 2021 09:47:41 +0000 (+0300) Subject: Temporary fix for UT problem X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F19%2F7019%2F1;p=ric-plt%2Fsubmgr.git Temporary fix for UT problem Change-Id: Idbe5d5f98557b0fc343f2e71690b9fbd493aaa62 Signed-off-by: Anssi Mannila --- diff --git a/pkg/control/control.go b/pkg/control/control.go index 3ebcbcd..f67f4e2 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 @@ -465,6 +467,19 @@ func (c *Control) processSubscriptionRequests(restSubscription *RESTSubscription } } +//------------------------------------------------------------------- +// +//------------------------------------------------------------------ +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") + } +} + //------------------------------------------------------------------- // //------------------------------------------------------------------ diff --git a/pkg/control/ut_ctrl_submgr_test.go b/pkg/control/ut_ctrl_submgr_test.go index ee7bc82..73b26e3 100644 --- a/pkg/control/ut_ctrl_submgr_test.go +++ b/pkg/control/ut_ctrl_submgr_test.go @@ -55,6 +55,7 @@ func createSubmgrControl(srcId teststub.RmrSrcId, rtgSvc teststub.RmrRtgSvc) *te mainCtrl = &testingSubmgrControl{} mainCtrl.RmrControl.Init("SUBMGRCTL", srcId, rtgSvc) mainCtrl.c = NewControl() + mainCtrl.c.UTTesting = true 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