X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=RSM%2Frmrcgo%2Frmr_c_go_api_test.go;fp=RSM%2Frmrcgo%2Frmr_c_go_api_test.go;h=426bea36e6c6767e1791fcaf5ff8d99032268023;hb=60652d98d51ee23c1eaca2e8bc2bf19c74c57658;hp=ef5938771cd2cd05b9396af884e1cb3b3fd8883d;hpb=b8d3ff3abf409da49ecab244cd6d2c2124dbce7c;p=ric-plt%2Fresource-status-manager.git diff --git a/RSM/rmrcgo/rmr_c_go_api_test.go b/RSM/rmrcgo/rmr_c_go_api_test.go index ef59387..426bea3 100644 --- a/RSM/rmrcgo/rmr_c_go_api_test.go +++ b/RSM/rmrcgo/rmr_c_go_api_test.go @@ -29,7 +29,6 @@ import ( "rsm/tests" "strconv" "testing" - "time" ) var ( @@ -55,28 +54,12 @@ func TestNewMBufSuccess(t *testing.T) { assert.Equal(t, msg.Meid, "RanName") assert.Equal(t, msg.Len, len(tests.DummyPayload)) } -//TODO check why test failure and TestIsReadySuccess success -func TestInitFailure(t *testing.T) { - log := initLog(t) - go initRmr(tests.ReadyIntervalSec, tests.GetPort(), tests.MaxMsgSize, tests.Flags, log) - time.Sleep(time.Second) - if msgr != nil { - t.Errorf("The rmr router is ready, should be not ready") - } -} - -func TestIsReadyFailure(t *testing.T) { - log := initLog(t) - go initRmr(tests.ReadyIntervalSec, tests.GetPort(), tests.MaxMsgSize, tests.Flags, log) - assert.True(t, msgr == nil || !msgr.IsReady()) -} func TestSendRecvMsgSuccess(t *testing.T) { log := initLog(t) - go initRmr(tests.ReadyIntervalSec, tests.GetPort(), tests.MaxMsgSize, tests.Flags, log) - time.Sleep(time.Duration(2) * time.Second) - if msgr == nil || !msgr.IsReady() { + initRmr(tests.ReadyIntervalSec, tests.GetPort(), tests.MaxMsgSize, tests.Flags, log) + if msgr == nil || !msgr.IsReady() { t.Errorf("#rmr_c_go_api_test.TestSendRecvMsgSuccess - The rmr router is not ready") } @@ -97,9 +80,8 @@ func TestSendRecvMsgSuccess(t *testing.T) { func TestSendMsgRmrInvalidPortError(t *testing.T) { log := initLog(t) - go initRmr(tests.ReadyIntervalSec, "tcp:" + strconv.Itoa(5555), tests.MaxMsgSize, tests.Flags, log) - time.Sleep(time.Duration(2) * time.Second) - if msgr == nil || !msgr.IsReady() { + initRmr(tests.ReadyIntervalSec, "tcp:"+strconv.Itoa(5555), tests.MaxMsgSize, tests.Flags, log) + if msgr == nil || !msgr.IsReady() { t.Errorf("#rmr_c_go_api_test.TestSendMsgRmrInvalidPortError - The rmr router is not ready") } @@ -116,9 +98,8 @@ func TestSendMsgRmrInvalidPortError(t *testing.T) { func TestSendMsgRmrInvalidMsgNumError(t *testing.T) { log := initLog(t) - go initRmr(tests.ReadyIntervalSec, tests.GetPort(), tests.MaxMsgSize, tests.Flags, log) - time.Sleep(time.Duration(2) * time.Second) - if msgr == nil || !msgr.IsReady() { + initRmr(tests.ReadyIntervalSec, tests.GetPort(), tests.MaxMsgSize, tests.Flags, log) + if msgr == nil || !msgr.IsReady() { t.Errorf("#rmr_c_go_api_test.TestSendMsgRmrInvalidMsgNumError - The rmr router is not ready") } @@ -135,14 +116,15 @@ func TestSendMsgRmrInvalidMsgNumError(t *testing.T) { func TestIsReadySuccess(t *testing.T) { log := initLog(t) - go initRmr(tests.ReadyIntervalSec, tests.GetPort(), tests.MaxMsgSize, tests.Flags, log) - time.Sleep(time.Duration(tests.ReadyIntervalSec)) - if msgr == nil || !msgr.IsReady() { + initRmr(tests.ReadyIntervalSec, tests.GetPort(), tests.MaxMsgSize, tests.Flags, log) + if msgr == nil || !msgr.IsReady() { t.Errorf("#rmr_c_go_api_test.TestIsReadySuccess - The rmr router is not ready") } + + msgr.Close() } -func initRmr(readyIntervalSec int, port string, maxMsgSize int, flags int, log *logger.Logger){ +func initRmr(readyIntervalSec int, port string, maxMsgSize int, flags int, log *logger.Logger) { var ctx *Context msgr = ctx.Init(readyIntervalSec, port, maxMsgSize, flags, log) } @@ -153,4 +135,4 @@ func initLog(t *testing.T) *logger.Logger { t.Errorf("#rmr_c_go_api_test.initLog - failed to initialize logger, error: %s", err) } return log -} \ No newline at end of file +}