X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fxapp%2Fxapp_test.go;h=baafa16e9b0a6d266f2a18b40e7947eb944b8741;hb=827a6410631045b503ce098de6683c6916c09842;hp=f0e30701535949bbd011c0d494ba416b4f5fdc7e;hpb=9568a2d73b96516b27f54650e309f0d157fb97d9;p=ric-plt%2Fxapp-frame.git diff --git a/pkg/xapp/xapp_test.go b/pkg/xapp/xapp_test.go index f0e3070..baafa16 100755 --- a/pkg/xapp/xapp_test.go +++ b/pkg/xapp/xapp_test.go @@ -44,13 +44,14 @@ func (m Consumer) Consume(params *RMRParams) (err error) { // Test cases func TestMain(m *testing.M) { - go RunWithParams(Consumer{}, viper.GetBool("db.waitForSdl")) + go RunWithParams(Consumer{}, viper.GetBool("controls.waitForSdl")) time.Sleep(time.Duration(5) * time.Second) code := m.Run() os.Exit(code) } func TestGetHealthCheckRetursServiceUnavailableError(t *testing.T) { + Logger.Info("CASE: TestGetHealthCheckRetursServiceUnavailableError") req, _ := http.NewRequest("GET", "/ric/v1/health/ready", nil) /*response :=*/ executeRequest(req) @@ -58,6 +59,7 @@ func TestGetHealthCheckRetursServiceUnavailableError(t *testing.T) { } func TestGetHealthCheckReturnsSuccess(t *testing.T) { + Logger.Info("CASE: TestGetHealthCheckReturnsSuccess") for Rmr.IsReady() == false { time.Sleep(time.Duration(2) * time.Second) } @@ -69,6 +71,7 @@ func TestGetHealthCheckReturnsSuccess(t *testing.T) { } func TestInjectQuerySinglePath(t *testing.T) { + Logger.Info("CASE: TestInjectQuerySinglePath") var handler = func(w http.ResponseWriter, r *http.Request) { } @@ -80,6 +83,7 @@ func TestInjectQuerySinglePath(t *testing.T) { } func TestInjectQueryMultiplePaths(t *testing.T) { + Logger.Info("CASE: TestInjectQueryMultiplePaths") var handler = func(w http.ResponseWriter, r *http.Request) { } @@ -91,6 +95,7 @@ func TestInjectQueryMultiplePaths(t *testing.T) { } func TestInjectQueryFailures(t *testing.T) { + Logger.Info("CASE: TestInjectQueryFailures") var handler = func(w http.ResponseWriter, r *http.Request) { } @@ -102,6 +107,7 @@ func TestInjectQueryFailures(t *testing.T) { } func TestMessagesReceivedSuccessfully(t *testing.T) { + Logger.Info("CASE: TestMessagesReceivedSuccessfully") time.Sleep(time.Duration(5) * time.Second) for i := 0; i < 100; i++ { params := &RMRParams{} @@ -114,9 +120,9 @@ func TestMessagesReceivedSuccessfully(t *testing.T) { } // Allow time to process the messages - time.Sleep(time.Duration(2) * time.Second) + time.Sleep(time.Duration(5) * time.Second) - waitForSdl := viper.GetBool("db.waitForSdl") + waitForSdl := viper.GetBool("controls.waitForSdl") stats := getMetrics(t) if !strings.Contains(stats, "ricxapp_RMR_Transmitted 100") { t.Errorf("Error: ricxapp_RMR_Transmitted value incorrect: %v", stats) @@ -143,8 +149,98 @@ func TestMessagesReceivedSuccessfully(t *testing.T) { } } +func TestMessagesReceivedSuccessfullyUsingWh(t *testing.T) { + Logger.Info("CASE: TestMessagesReceivedSuccessfullyUsingWh") + time.Sleep(time.Duration(5) * time.Second) + whid := Rmr.Openwh("localhost:4560") + time.Sleep(time.Duration(1) * time.Second) + for i := 0; i < 100; i++ { + params := &RMRParams{} + params.Mtype = 10004 + params.SubId = -1 + params.Payload = []byte{1, 2, 3, 4, 5, 6} + params.Meid = &RMRMeid{PlmnID: "1234", EnbID: "7788", RanName: "RanName-1234"} + params.Xid = "TestXID" + params.Whid = int(whid) + Rmr.SendMsg(params) + } + + // Allow time to process the messages + time.Sleep(time.Duration(5) * time.Second) + + waitForSdl := viper.GetBool("controls.waitForSdl") + stats := getMetrics(t) + if !strings.Contains(stats, "ricxapp_RMR_Transmitted 200") { + t.Errorf("Error: ricxapp_RMR_Transmitted value incorrect: %v", stats) + } + + if !strings.Contains(stats, "ricxapp_RMR_Received 200") { + t.Errorf("Error: ricxapp_RMR_Received value incorrect: %v", stats) + } + + if !strings.Contains(stats, "ricxapp_RMR_TransmitError 0") { + t.Errorf("Error: ricxapp_RMR_TransmitError value incorrect") + } + + if !strings.Contains(stats, "ricxapp_RMR_ReceiveError 0") { + t.Errorf("Error: ricxapp_RMR_ReceiveError value incorrect") + } + + if waitForSdl && !strings.Contains(stats, "ricxapp_SDL_Stored 200") { + t.Errorf("Error: ricxapp_SDL_Stored value incorrect") + } + + if waitForSdl && !strings.Contains(stats, "ricxapp_SDL_StoreError 0") { + t.Errorf("Error: ricxapp_SDL_StoreError value incorrect") + } + Rmr.Closewh(int(whid)) +} + +func TestMessagesReceivedSuccessfullyUsingWhCall(t *testing.T) { + Logger.Info("CASE: TestMessagesReceivedSuccessfullyUsingWhCall") + time.Sleep(time.Duration(5) * time.Second) + whid := Rmr.Openwh("localhost:4560") + params := &RMRParams{} + params.Payload = []byte("newrt|start\nnewrt|end\n") + params.Whid = int(whid) + params.Callid = 4 + params.Timeout = 1000 + Rmr.SendCallMsg(params) + + // Allow time to process the messages + time.Sleep(time.Duration(2) * time.Second) + + waitForSdl := viper.GetBool("controls.waitForSdl") + stats := getMetrics(t) + if !strings.Contains(stats, "ricxapp_RMR_Transmitted 200") { + t.Errorf("Error: ricxapp_RMR_Transmitted value incorrect: %v", stats) + } + + if !strings.Contains(stats, "ricxapp_RMR_Received 201") { + t.Errorf("Error: ricxapp_RMR_Received value incorrect: %v", stats) + } + + if !strings.Contains(stats, "ricxapp_RMR_TransmitError 1") { + t.Errorf("Error: ricxapp_RMR_TransmitError value incorrect") + } + + if !strings.Contains(stats, "ricxapp_RMR_ReceiveError 0") { + t.Errorf("Error: ricxapp_RMR_ReceiveError value incorrect") + } + + if waitForSdl && !strings.Contains(stats, "ricxapp_SDL_Stored 201") { + t.Errorf("Error: ricxapp_SDL_Stored value incorrect") + } + + if waitForSdl && !strings.Contains(stats, "ricxapp_SDL_StoreError 0") { + t.Errorf("Error: ricxapp_SDL_StoreError value incorrect") + } + Rmr.Closewh(int(whid)) +} + func TestSubscribeChannels(t *testing.T) { - if !viper.GetBool("db.waitForSdl") { + Logger.Info("CASE: TestSubscribeChannels") + if !viper.GetBool("controls.waitForSdl") { return } @@ -165,6 +261,7 @@ func TestSubscribeChannels(t *testing.T) { } func TestGetRicMessageSuccess(t *testing.T) { + Logger.Info("CASE: TestGetRicMessageSuccess") id, ok := Rmr.GetRicMessageId("RIC_SUB_REQ") if !ok || id != 12010 { t.Errorf("Error: GetRicMessageId failed: id=%d", id) @@ -177,6 +274,7 @@ func TestGetRicMessageSuccess(t *testing.T) { } func TestGetRicMessageFails(t *testing.T) { + Logger.Info("CASE: TestGetRicMessageFails") ok := Rmr.IsRetryError(&RMRParams{status: 0}) if ok { t.Errorf("Error: IsRetryError returned wrong value") @@ -199,6 +297,7 @@ func TestGetRicMessageFails(t *testing.T) { } func TestIsErrorFunctions(t *testing.T) { + Logger.Info("CASE: TestIsErrorFunctions") id, ok := Rmr.GetRicMessageId("RIC_SUB_REQ") if !ok || id != 12010 { t.Errorf("Error: GetRicMessageId failed: id=%d", id) @@ -211,6 +310,7 @@ func TestIsErrorFunctions(t *testing.T) { } func TestTeardown(t *testing.T) { + Logger.Info("CASE: TestTeardown") Sdl.Clear() }