X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fcontrol%2Fut_test.go;h=151619d3ed9cf1242912c4c7a9d4382fdd19627b;hb=01a4c49324392003717106267c56126275b9058b;hp=23e4374b8925ed8dc84a06a067a111b6e40e718c;hpb=83ada00338d2c9fa47d48c406b4a46b9d7888aff;p=ric-plt%2Fsubmgr.git diff --git a/pkg/control/ut_test.go b/pkg/control/ut_test.go index 23e4374..151619d 100644 --- a/pkg/control/ut_test.go +++ b/pkg/control/ut_test.go @@ -25,6 +25,7 @@ import ( "io/ioutil" "os" "strings" + "sync" "testing" "time" ) @@ -34,11 +35,24 @@ import ( //----------------------------------------------------------------------------- type testingRmrControl struct { desc string + mutex sync.Mutex syncChan chan struct{} } +func (tc *testingRmrControl) Lock() { + tc.mutex.Lock() +} + +func (tc *testingRmrControl) Unlock() { + tc.mutex.Unlock() +} + +func (tc *testingRmrControl) GetDesc() string { + return tc.desc +} + func (tc *testingRmrControl) ReadyCB(data interface{}) { - xapp.Logger.Info("testingRmrControl(%s) ReadyCB", tc.desc) + xapp.Logger.Info("testingRmrControl(%s) ReadyCB", tc.GetDesc()) tc.syncChan <- struct{}{} return } @@ -83,7 +97,7 @@ func (tc *testingRmrStubControl) DecMsgCnt() { func (tc *testingRmrStubControl) TestMsgCnt(t *testing.T) { if tc.GetMsgCnt() > 0 { - testError(t, "(%s) message count expected 0 but is %d", tc.desc, tc.GetMsgCnt()) + testError(t, "(%s) message count expected 0 but is %d", tc.GetDesc(), tc.GetMsgCnt()) } } @@ -91,18 +105,18 @@ func (tc *testingRmrStubControl) RmrSend(params *RMRParams) (err error) { // //NOTE: Do this way until xapp-frame sending is improved // - xapp.Logger.Info("(%s) RmrSend %s", tc.desc, params.String()) + xapp.Logger.Info("(%s) RmrSend %s", tc.GetDesc(), params.String()) status := false i := 1 for ; i <= 10 && status == false; i++ { status = tc.rmrClientTest.SendMsg(params.RMRParams) if status == false { - xapp.Logger.Info("(%s) RmrSend failed. Retry count %v, %s", tc.desc, i, params.String()) + xapp.Logger.Info("(%s) RmrSend failed. Retry count %v, %s", tc.GetDesc(), i, params.String()) time.Sleep(500 * time.Millisecond) } } if status == false { - err = fmt.Errorf("(%s) RmrSend failed. Retry count %v, %s", tc.desc, i, params.String()) + err = fmt.Errorf("(%s) RmrSend failed. Retry count %v, %s", tc.GetDesc(), i, params.String()) xapp.Rmr.Free(params.Mbuf) } return