X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fxapp%2Fxapp_test.go;h=8b2a9524c54a95365ce41466ec2fbffb72d01d1a;hb=c2c130d71f20e44119f356f7ab4df92882f92c9d;hp=173b57f991b4b6e7c3996f56012ff1ae27ef3044;hpb=413abf5f6de7c1808a2dd716ef52ed586c04d8f6;p=ric-plt%2Fxapp-frame.git diff --git a/pkg/xapp/xapp_test.go b/pkg/xapp/xapp_test.go index 173b57f..8b2a952 100755 --- a/pkg/xapp/xapp_test.go +++ b/pkg/xapp/xapp_test.go @@ -21,15 +21,17 @@ package xapp import ( "bytes" - "github.com/gorilla/mux" - "github.com/spf13/viper" - "github.com/stretchr/testify/assert" + "io/ioutil" "net/http" "net/http/httptest" "os" "strings" "testing" "time" + + "github.com/gorilla/mux" + "github.com/spf13/viper" + "github.com/stretchr/testify/assert" ) //var _ = func() bool { @@ -46,6 +48,8 @@ func (m Consumer) Consume(params *RMRParams) (err error) { // Test cases func TestMain(m *testing.M) { + os.Setenv("SERVICE_RICXAPP_UEEC_HTTP_PORT", "tcp://localhost:8080") + os.Setenv("SERVICE_RICXAPP_UEEC_RMR_PORT", "tcp://localhost:4561") go RunWithParams(Consumer{}, viper.GetBool("controls.waitForSdl")) time.Sleep(time.Duration(5) * time.Second) code := m.Run() @@ -377,6 +381,7 @@ func TestInjectStatusCb(t *testing.T) { return true } Resource.InjectStatusCb(f) + Resource.CheckStatus() } func TestSdlInterfaces(t *testing.T) { @@ -430,23 +435,46 @@ func TestappconfigHandler(t *testing.T) { executeRequest(req, handleFunc) } -func TestSendRegistermsg(t *testing.T) { - Logger.Error("CASE: TestSendRegistermsg") - SendRegistermsg() +func TestConfigChange(t *testing.T) { + Logger.Error("CASE: TestConfigChange: %s", os.Getenv("CFG_FILE")) + + input, err := ioutil.ReadFile(os.Getenv("CFG_FILE")) + assert.Equal(t, err, nil) + + err = ioutil.WriteFile(os.Getenv("CFG_FILE"), input, 0644) + assert.Equal(t, err, nil) +} + +func TestRegisterXapp(t *testing.T) { + Logger.Error("CASE: TestRegisterXapp") + doRegister() } -func TestSendDeregistermsg(t *testing.T) { - Logger.Error("CASE: TestSendDeregistermsg") - SendDeregistermsg() +func TestDeregisterXapp(t *testing.T) { + Logger.Error("CASE: TestDeregisterXapp") + doDeregister() } func TestMisc(t *testing.T) { Logger.Info("CASE: TestMisc") - + var cb = func() {} IsReady() SetReadyCB(func(interface{}) {}, "") XappReadyCb("") - SetShutdownCB(func() {}) + SetShutdownCB(cb) + XappShutdownCb() + getService("ueec", SERVICE_HTTP) + + Logger.SetFormat(1) + Logger.SetLevel(0) + Logger.Error("...") + Logger.Warn("...") + Logger.Info("...") + + mb := Rmr.Allocate(100) + Rmr.ReAllocate(mb, 200) + + NewMetrics("", "", Resource.router) } func TestTeardown(t *testing.T) { @@ -455,6 +483,10 @@ func TestTeardown(t *testing.T) { Sdl.Clear() Sdl.IsReady() Sdl.GetStat() + Rnib.GetNodebByGlobalNbId(1, &RNIBGlobalNbId{}) + Rnib.SaveNodeb(&RNIBNbIdentity{}, &RNIBNodebInfo{}) + go Sdl.TestConnection() + time.Sleep(time.Duration(2) * time.Second) } // Helper functions