Take golog v0.0.2 into use 50/5150/2 v0.6.6
authorMohamed Abukar <abukar.mohamed@nokia.com>
Wed, 25 Nov 2020 07:41:01 +0000 (09:41 +0200)
committerMohamed Abukar <abukar.mohamed@nokia.com>
Wed, 25 Nov 2020 07:55:31 +0000 (09:55 +0200)
Change-Id: Ie73e96da2146b38581ab58c07a29927a6e6edc98
Signed-off-by: Mohamed Abukar <abukar.mohamed@nokia.com>
go.mod
go.sum
pkg/xapp/alarm_test.go [new file with mode: 0755]
pkg/xapp/logger.go
pkg/xapp/xapp.go

diff --git a/go.mod b/go.mod
index 2cbbc5d..2b0e6a5 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -3,7 +3,7 @@ module gerrit.o-ran-sc.org/r/ric-plt/xapp-frame
 go 1.12
 
 require (
-       gerrit.o-ran-sc.org/r/com/golog v0.0.1
+       gerrit.o-ran-sc.org/r/com/golog v0.0.2
        gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm v0.4.2
        gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.35
        gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.35
@@ -24,11 +24,12 @@ require (
        github.com/spf13/viper v1.4.0
        github.com/stretchr/testify v1.5.1
        golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297
+       k8s.io/utils v0.0.0-20201110183641-67b214c5f920 // indirect
 )
 
 replace gerrit.o-ran-sc.org/r/ric-plt/sdlgo => gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.5.2
 
-replace gerrit.o-ran-sc.org/r/com/golog => gerrit.o-ran-sc.org/r/com/golog.git v0.0.0-20190604083303-aaffc8ebe3f1
+replace gerrit.o-ran-sc.org/r/com/golog => gerrit.o-ran-sc.org/r/com/golog.git v0.0.2
 
 replace gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common => gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.35
 
diff --git a/go.sum b/go.sum
index 3f68dcb..6b34683 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -1,6 +1,8 @@
 cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
 gerrit.o-ran-sc.org/r/com/golog.git v0.0.0-20190604083303-aaffc8ebe3f1 h1:WAB8G/FFaUjRkpLuUhIo0EfbeBOY7xjkcFAFkpe3Xns=
 gerrit.o-ran-sc.org/r/com/golog.git v0.0.0-20190604083303-aaffc8ebe3f1/go.mod h1:b8YB31U8/4iRpABioeSzGi/YMzOQ/Zq7hrJmmXKqlJk=
+gerrit.o-ran-sc.org/r/com/golog.git v0.0.2 h1:Ix6SgFuzd6yW6Ur6+qDlGhDO65UYs8PiIkeAL1VaQ2o=
+gerrit.o-ran-sc.org/r/com/golog.git v0.0.2/go.mod h1:A7hUL52YQSO4dFIZNcj76XQ09C9PftAe3LyL7kqBnok=
 gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm v0.4.2 h1:XNfkp3PwZ7pfkPszX7NaX6DzToCGjcWTLbIHYqCFNu0=
 gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm v0.4.2/go.mod h1:AdEWKtERGvOQy9ybLhyhrb9w9LLVn8i9xzTwoR5n4BY=
 gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.35 h1:TGXHb4DNY8on+ej4S9VUnk2HibIC/5chDy64OE+bQBQ=
@@ -53,6 +55,7 @@ github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0
 github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
 github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
 github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
+github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
 github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI=
 github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik=
 github.com/go-openapi/analysis v0.18.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik=
@@ -196,6 +199,8 @@ github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4k
 github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
 github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
 github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
+github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc=
+github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
 github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
 github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
 github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
@@ -293,3 +298,6 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
 gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
+k8s.io/utils v0.0.0-20201110183641-67b214c5f920 h1:CbnUZsM497iRC5QMVkHwyl8s2tB3g7yaSHkYPkpgelw=
+k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
diff --git a/pkg/xapp/alarm_test.go b/pkg/xapp/alarm_test.go
new file mode 100755 (executable)
index 0000000..b72c319
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+==================================================================================
+  Copyright (c) 2019 AT&T Intellectual Property.
+  Copyright (c) 2019 Nokia
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================================
+*/
+
+package xapp
+
+import (
+       "testing"
+       "github.com/stretchr/testify/assert"
+
+       "gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm"
+)
+
+func TestNewAlarmClient(t *testing.T) {
+       Logger.Info("TestNewAlarmClient")
+
+       a := NewAlarmClient("", "")
+       assert.NotNil(t, a, "NewAlarmClient failed")
+}
+
+func TestAlarmRaise(t *testing.T) {
+       Logger.Info("TestAlarmRaise")
+
+       a := NewAlarmClient("", "")
+       assert.NotNil(t, a, "NewAlarmClient failed")
+
+       a.Raise(1234, alarm.SeverityCritical, "Some App data", "eth 0 1")
+}
+
+func TestAlarmClear(t *testing.T) {
+       Logger.Info("TestAlarmClear")
+
+       a := NewAlarmClient("", "")
+       assert.NotNil(t, a, "NewAlarmClient failed")
+
+       a.Clear(1234, alarm.SeverityCritical, "Some App data", "eth 0 1")
+}
+
+func TestAlarmReraise(t *testing.T) {
+       Logger.Info("TestAlarmReraise")
+
+       a := NewAlarmClient("", "")
+       assert.NotNil(t, a, "NewAlarmClient failed")
+
+       a.Reraise(1234, alarm.SeverityCritical, "Some App data", "eth 0 1")
+}
+
+func TestAlarmClearall(t *testing.T) {
+       Logger.Info("TestAlarmClearall")
+
+       a := NewAlarmClient("", "")
+       assert.NotNil(t, a, "NewAlarmClient failed")
+
+       a.ClearAll()
+}
\ No newline at end of file
index 5009354..69bed09 100755 (executable)
@@ -36,6 +36,10 @@ func NewLogger(name string) *Log {
        }
 }
 
+func (l *Log) SetFormat(logMonitor int) {
+       l.logger.Mdclog_format_initialize(logMonitor)
+}
+
 func (l *Log) SetLevel(level int) {
        l.logger.LevelSet(mdclog.Level(level))
 }
index a9a130e..1ab7ee0 100755 (executable)
@@ -128,6 +128,8 @@ func init() {
        } else {
                Logger.SetLevel(viper.GetInt("logger.level"))
        }
+       Logger.SetFormat(0)
+
        Resource = NewRouter()
        Config = Configurator{}
        Metric = NewMetrics(viper.GetString("metrics.url"), viper.GetString("metrics.namespace"), Resource.router)