From 08c8fbd6d2d26e17b87aac8438d035813170bc91 Mon Sep 17 00:00:00 2001 From: Anssi Mannila Date: Tue, 5 Oct 2021 12:47:41 +0300 Subject: [PATCH] Temporary fix for UT problem Change-Id: Idbe5d5f98557b0fc343f2e71690b9fbd493aaa62 Signed-off-by: Anssi Mannila --- pkg/control/control.go | 15 +++++++++++++++ pkg/control/ut_ctrl_submgr_test.go | 1 + 2 files changed, 16 insertions(+) diff --git a/pkg/control/control.go b/pkg/control/control.go index 9410925..1bcffc6 100755 --- a/pkg/control/control.go +++ b/pkg/control/control.go @@ -87,6 +87,7 @@ type Control struct { ResetTestFlag bool Counters map[string]xapp.Counter LoggerLevel int + UTTesting bool } type RMRMeid struct { @@ -483,6 +484,7 @@ func (c *Control) GetE2SubscriptionDirectives(p *models.SubscriptionParams) (*E2 func (c *Control) processSubscriptionRequests(restSubscription *RESTSubscription, subReqList *e2ap.SubscriptionRequestList, clientEndpoint *models.SubscriptionParamsClientEndpoint, meid *string, restSubId *string, xAppRmrEndpoint string, md5sum string, e2SubscriptionDirectives *E2SubscriptionDirectives) { + c.SubscriptionProcessingStartDelay() xapp.Logger.Debug("Subscription Request count=%v ", len(subReqList.E2APSubscriptionRequests)) var xAppEventInstanceID int64 @@ -523,6 +525,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 16c69b1..eb6d6d4 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 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") -- 2.16.6