Add some rmr library stats into metrics
[ric-plt/xapp-frame.git] / pkg / xapp / xapp_test.go
index 2c4c4fe..c4aec60 100755 (executable)
@@ -21,6 +21,7 @@ package xapp
 
 import (
        "bytes"
+       "io/ioutil"
        "net/http"
        "net/http/httptest"
        "os"
@@ -33,10 +34,10 @@ import (
        "github.com/stretchr/testify/assert"
 )
 
-//var _ = func() bool {
-//     testing.Init()
-//     return true
-//}()
+var _ = func() bool {
+       testing.Init()
+       return true
+}()
 
 type Consumer struct{}
 
@@ -334,7 +335,7 @@ func TestAddConfigChangeListener(t *testing.T) {
 }
 
 func TestConfigAccess(t *testing.T) {
-       Logger.Info("CASE: AddConfigChangeListener")
+       Logger.Info("CASE: TestConfigAccess")
 
        assert.Equal(t, Config.GetString("name"), "xapp")
        assert.Equal(t, Config.GetInt("controls.logger.level"), 3)
@@ -347,8 +348,9 @@ func TestConfigAccess(t *testing.T) {
 }
 
 func TestPublishConfigChange(t *testing.T) {
-       Logger.Info("CASE: AddConfigChangeListener")
+       Logger.Info("CASE: TestPublishConfigChange")
        PublishConfigChange("testApp", "values")
+       ReadConfig("testApp")
 }
 
 func TestNewSubscriber(t *testing.T) {
@@ -390,11 +392,13 @@ func TestSdlInterfaces(t *testing.T) {
        Sdl.Store("myKey", "Values")
        Sdl.MStore("myKey", "Values")
        Sdl.RegisterMetrics()
+       Sdl.UpdateStatCounter("Stored")
 
        // Misc.
        var NotificationCb = func(ch string, events ...string) {}
        Sdl.Subscribe(NotificationCb, "channel1")
        Sdl.MSubscribe(NotificationCb, "channel1", "channel2")
+       Sdl.StoreAndPublish("channel1", "event", "key1", "data1")
        Sdl.MStoreAndPublish([]string{"channel1"}, "event", "key1", "data1")
 }
 
@@ -434,6 +438,16 @@ func TestappconfigHandler(t *testing.T) {
        executeRequest(req, handleFunc)
 }
 
+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()