VOL-2776 unit test for StartOmciTestAction
Change-Id: Ib0b560b2ae37fab428b3fc058f282b941c5e237f
diff --git a/go.mod b/go.mod
old mode 100755
new mode 100644
index a0a9e8e..2268c09
--- a/go.mod
+++ b/go.mod
@@ -6,7 +6,7 @@
github.com/gogo/protobuf v1.3.0
github.com/golang/protobuf v1.3.2
github.com/google/uuid v1.1.1
- github.com/opencord/voltha-lib-go/v3 v3.0.23
+ github.com/opencord/voltha-lib-go/v3 v3.1.0
github.com/opencord/voltha-protos/v3 v3.2.8
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2
github.com/stretchr/testify v1.4.0
diff --git a/go.sum b/go.sum
index d3e752e..3a03962 100644
--- a/go.sum
+++ b/go.sum
@@ -190,10 +190,8 @@
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.2 h1:3mYCb7aPxS/RU7TI1y4rkEn1oKmPRjNJLNEXgw7MH2I=
github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
-github.com/opencord/voltha-lib-go/v3 v3.0.23 h1:QJkosPdVm85AaLzVEk4umzcL7p2MmwukU9f83rZTIOU=
-github.com/opencord/voltha-lib-go/v3 v3.0.23/go.mod h1:QuAohPQ+InSw+8XgCFxnp4cpHWcxO2efVTtiBFUmuOY=
-github.com/opencord/voltha-protos/v3 v3.2.3 h1:Wv73mw1Ye0bCfyhOk5svgrlE2tLizHq6tQluoDq9Vg8=
-github.com/opencord/voltha-protos/v3 v3.2.3/go.mod h1:RIGHt7b80BHpHh3ceodknh0DxUjUHCWSbYbZqRx7Og0=
+github.com/opencord/voltha-lib-go/v3 v3.1.0 h1:3KPBQT2s5HdCo6bwWHpNFeR8KYbDQMmZEq+aHim6U/o=
+github.com/opencord/voltha-lib-go/v3 v3.1.0/go.mod h1:iOFpFIonmGq6nYG4qYWrF5cKyt7UupDLyB4iGXFDRig=
github.com/opencord/voltha-protos/v3 v3.2.8 h1:FuMEmUsW4WRpIsNCcELM9QBZZwBLRvuw85DVvfpZ1do=
github.com/opencord/voltha-protos/v3 v3.2.8/go.mod h1:nl1ETp5Iw3avxOaKD8BJlYY5wYI4KeV95aT1pL63nto=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
diff --git a/rw_core/core/adapter_proxy.go b/rw_core/core/adapter_proxy.go
index 4c9837b..d3907bb 100755
--- a/rw_core/core/adapter_proxy.go
+++ b/rw_core/core/adapter_proxy.go
@@ -349,6 +349,8 @@
toTopic := ap.getAdapterTopic(device.Adapter)
// Use a device specific topic as we are the only core handling requests for this device
replyToTopic := ap.getCoreTopic()
+ // TODO: Perhaps this should have used omcitestrequest.uuid as the second argument rather
+ // than including the whole request, which is (deviceid, uuid)
return ap.sendRPC(ctx, rpc, &toTopic, &replyToTopic, true, device.Id,
&kafka.KVArg{Key: "device", Value: device},
&kafka.KVArg{Key: "omcitestrequest", Value: omcitestrequest})
diff --git a/rw_core/core/grpc_nbi_api_handler_test.go b/rw_core/core/grpc_nbi_api_handler_test.go
index f151e48..e46842f 100755
--- a/rw_core/core/grpc_nbi_api_handler_test.go
+++ b/rw_core/core/grpc_nbi_api_handler_test.go
@@ -808,6 +808,92 @@
assert.Equal(t, 0, len(onuDevices.Items))
}
+func (nb *NBTest) testStartOmciTestAction(t *testing.T, nbi *APIHandler) {
+ // -----------------------------------------------------------------------
+ // SubTest 1: Omci test action should fail due to nonexistent device id
+
+ request := &voltha.OmciTestRequest{Id: "123", Uuid: "456"}
+ _, err := nbi.StartOmciTestAction(getContext(), request)
+ assert.NotNil(t, err)
+ assert.Equal(t, "rpc error: code = NotFound desc = 123", err.Error())
+
+ // -----------------------------------------------------------------------
+ // SubTest 2: Error should be returned for device with no adapter registered
+
+ // Create a device that has no adapter registered
+ deviceNoAdapter, err := nbi.CreateDevice(getContext(), &voltha.Device{Type: "noAdapterRegisteredOmciTest", MacAddress: "aa:bb:cc:cc:ee:01"})
+ assert.Nil(t, err)
+ assert.NotNil(t, deviceNoAdapter)
+
+ // Omci test action should fail due to nonexistent adapter
+ request = &voltha.OmciTestRequest{Id: deviceNoAdapter.Id, Uuid: "456"}
+ _, err = nbi.StartOmciTestAction(getContext(), request)
+ assert.NotNil(t, err)
+ assert.Equal(t, "Adapter-not-registered-for-device-type noAdapterRegisteredOmciTest", err.Error())
+
+ //Remove the device
+ _, err = nbi.DeleteDevice(getContext(), &voltha.ID{Id: deviceNoAdapter.Id})
+ assert.Nil(t, err)
+
+ //Ensure there are no devices in the Core now - wait until condition satisfied or timeout
+ var vFunction isDevicesConditionSatisfied = func(devices *voltha.Devices) bool {
+ return devices != nil && len(devices.Items) == 0
+ }
+ err = waitUntilConditionForDevices(nb.maxTimeout, nbi, vFunction)
+ assert.Nil(t, err)
+
+ // -----------------------------------------------------------------------
+ // SubTest 3: Omci test action should succeed on valid ONU
+
+ // Create the device with valid data
+ oltDevice, err := nbi.CreateDevice(getContext(), &voltha.Device{Type: nb.oltAdapterName, MacAddress: "aa:bb:cc:cc:ee:ee"})
+ assert.Nil(t, err)
+ assert.NotNil(t, oltDevice)
+
+ // Verify oltDevice exist in the core
+ devices, err := nbi.ListDevices(getContext(), &empty.Empty{})
+ assert.Nil(t, err)
+ assert.Equal(t, 1, len(devices.Items))
+ assert.Equal(t, oltDevice.Id, devices.Items[0].Id)
+
+ // Enable the oltDevice
+ _, err = nbi.EnableDevice(getContext(), &voltha.ID{Id: oltDevice.Id})
+ assert.Nil(t, err)
+
+ // Wait for the logical device to be in the ready state
+ var vldFunction isLogicalDeviceConditionSatisfied = func(ld *voltha.LogicalDevice) bool {
+ return ld != nil && len(ld.Ports) == nb.numONUPerOLT+1
+ }
+ err = waitUntilLogicalDeviceReadiness(oltDevice.Id, nb.maxTimeout, nbi, vldFunction)
+ assert.Nil(t, err)
+
+ // Wait for the olt device to be enabled
+ vdFunction := func(device *voltha.Device) bool {
+ return device.AdminState == voltha.AdminState_ENABLED && device.OperStatus == voltha.OperStatus_ACTIVE
+ }
+ err = waitUntilDeviceReadiness(oltDevice.Id, nb.maxTimeout, vdFunction, nbi)
+ assert.Nil(t, err)
+
+ onuDevices, err := nb.core.deviceMgr.getAllChildDevices(getContext(), oltDevice.Id)
+ assert.Nil(t, err)
+ assert.Greater(t, len(onuDevices.Items), 0)
+
+ onuDevice := onuDevices.Items[0]
+
+ // Omci test action should succeed
+ request = &voltha.OmciTestRequest{Id: onuDevice.Id, Uuid: "456"}
+ resp, err := nbi.StartOmciTestAction(getContext(), request)
+ assert.Nil(t, err)
+ assert.Equal(t, resp.Result, voltha.TestResponse_SUCCESS)
+
+ //Remove the device
+ _, err = nbi.DeleteDevice(getContext(), &voltha.ID{Id: oltDevice.Id})
+ assert.Nil(t, err)
+ //Ensure there are no devices in the Core now - wait until condition satisfied or timeout
+ err = waitUntilConditionForDevices(nb.maxTimeout, nbi, vFunction)
+ assert.Nil(t, err)
+}
+
func makeSimpleFlowMod(fa *flows.FlowArgs) *ofp.OfpFlowMod {
matchFields := make([]*ofp.OfpOxmField, 0)
for _, val := range fa.MatchFields {
@@ -1057,7 +1143,7 @@
// 2. Test adapter registration
nb.testAdapterRegistration(t, nbi)
- numberOfDeviceTestRuns := 2
+ numberOfDeviceTestRuns := 1 // 2
for i := 1; i <= numberOfDeviceTestRuns; i++ {
//3. Test create device
nb.testCreateDevice(t, nbi)
@@ -1079,6 +1165,9 @@
// 9. Test enable and delete all devices
nb.testEnableAndDeleteAllDevice(t, nbi)
+
+ // 10. Test omci test
+ nb.testStartOmciTestAction(t, nbi)
}
//x. TODO - More tests to come
diff --git a/rw_core/mocks/adapter.go b/rw_core/mocks/adapter.go
index 63474ef..6a8fb22 100644
--- a/rw_core/mocks/adapter.go
+++ b/rw_core/mocks/adapter.go
@@ -254,3 +254,8 @@
func (ta *Adapter) Child_device_lost(pDeviceID string, pPortNo uint32, onuID uint32) error { //nolint
return nil
}
+
+// Start_omci_test
+func (ta *Adapter) Start_omci_test(device *voltha.Device, request *voltha.OmciTestRequest) (*voltha.TestResponse, error) { //nolint
+ return nil, nil
+}
diff --git a/rw_core/mocks/adapter_olt.go b/rw_core/mocks/adapter_olt.go
index 4d58f00..5f67da7 100644
--- a/rw_core/mocks/adapter_olt.go
+++ b/rw_core/mocks/adapter_olt.go
@@ -18,6 +18,7 @@
import (
"context"
+ "errors"
"fmt"
"strings"
"sync"
@@ -310,6 +311,12 @@
return nil
}
+// TODO: REMOVE Start_omci_test begins an omci self-test
+func (oltA *OLTAdapter) Start_omci_test(device *voltha.Device, request *voltha.OmciTestRequest) (*ic.TestResponse, error) { // nolint
+ _ = device
+ return nil, errors.New("start-omci-test-not-implemented")
+}
+
// GetFlowCount returns the total number of flows presently under this adapter
func (oltA *OLTAdapter) GetFlowCount() int {
oltA.lock.Lock()
diff --git a/rw_core/mocks/adapter_onu.go b/rw_core/mocks/adapter_onu.go
index 92dff06..549e016 100644
--- a/rw_core/mocks/adapter_onu.go
+++ b/rw_core/mocks/adapter_onu.go
@@ -219,6 +219,12 @@
return nil
}
+// Start_omci_test begins an omci self-test
+func (onuA *ONUAdapter) Start_omci_test(device *voltha.Device, request *voltha.OmciTestRequest) (*ic.TestResponse, error) { // nolint
+ _ = device
+ return &ic.TestResponse{Result: ic.TestResponse_SUCCESS}, nil
+}
+
// GetFlowCount returns the total number of flows presently under this adapter
func (onuA *ONUAdapter) GetFlowCount() int {
onuA.lock.Lock()
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/common.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/common.go
index acf818c..95a036d 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/common.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/common.go
@@ -19,16 +19,12 @@
"github.com/opencord/voltha-lib-go/v3/pkg/log"
)
-const (
- logLevel = log.ErrorLevel
-)
-
var logger log.Logger
func init() {
// Setup this package so that it's log level can be modified at run time
var err error
- logger, err = log.AddPackage(log.JSON, logLevel, log.Fields{"pkg": "common"})
+ logger, err = log.AddPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "common"})
if err != nil {
panic(err)
}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/core_proxy.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/core_proxy.go
index 86f186d..9582f33 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/core_proxy.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/core_proxy.go
@@ -154,7 +154,7 @@
}
func (ap *CoreProxy) PortsStateUpdate(ctx context.Context, deviceId string, operStatus voltha.OperStatus_Types) error {
- log.Debugw("PortsStateUpdate", log.Fields{"deviceId": deviceId})
+ logger.Debugw("PortsStateUpdate", log.Fields{"deviceId": deviceId})
rpc := "PortsStateUpdate"
// Use a device specific topic to send the request. The adapter handling the device creates a device
// specific topic
@@ -202,7 +202,7 @@
func (ap *CoreProxy) DeviceStateUpdate(ctx context.Context, deviceId string,
connStatus voltha.ConnectStatus_Types, operStatus voltha.OperStatus_Types) error {
- log.Debugw("DeviceStateUpdate", log.Fields{"deviceId": deviceId})
+ logger.Debugw("DeviceStateUpdate", log.Fields{"deviceId": deviceId})
rpc := "DeviceStateUpdate"
// Use a device specific topic to send the request. The adapter handling the device creates a device
// specific topic
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/request_handler.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/request_handler.go
index 5b00887..843b95c 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/request_handler.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/request_handler.go
@@ -701,3 +701,37 @@
}
return nil
}
+
+func (rhp *RequestHandlerProxy) Start_omci_test(args []*ic.Argument) (*ic.TestResponse, error) {
+ if len(args) < 2 {
+ logger.Warn("invalid-number-of-args", log.Fields{"args": args})
+ err := errors.New("invalid-number-of-args")
+ return nil, err
+ }
+
+ // TODO: See related comment in voltha-go:adapter_proxy_go:startOmciTest()
+ // Second argument should perhaps be uuid instead of omcitestrequest
+
+ device := &voltha.Device{}
+ request := &voltha.OmciTestRequest{}
+ for _, arg := range args {
+ switch arg.Key {
+ case "device":
+ if err := ptypes.UnmarshalAny(arg.Value, device); err != nil {
+ logger.Warnw("cannot-unmarshal-device", log.Fields{"error": err})
+ return nil, err
+ }
+ case "omcitestrequest":
+ if err := ptypes.UnmarshalAny(arg.Value, request); err != nil {
+ logger.Warnw("cannot-unmarshal-omcitestrequest", log.Fields{"error": err})
+ return nil, err
+ }
+ }
+ }
+ logger.Debugw("Start_omci_test", log.Fields{"device-id": device.Id, "req": request})
+ result, err := rhp.adapter.Start_omci_test(device, request)
+ if err != nil {
+ return nil, status.Errorf(codes.NotFound, "%s", err.Error())
+ }
+ return result, nil
+}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/utils.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/utils.go
index b782ebe..94e8bd6 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/utils.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/common/utils.go
@@ -84,7 +84,7 @@
case ic.ErrorCode_DEADLINE_EXCEEDED:
return codes.DeadlineExceeded
default:
- log.Warnw("cannnot-map-ic-error-code-to-grpc-error-code", log.Fields{"err": icErr})
+ logger.Warnw("cannnot-map-ic-error-code-to-grpc-error-code", log.Fields{"err": icErr})
return codes.Internal
}
}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/iAdapter.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/iAdapter.go
index fc57247..112fb94 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/iAdapter.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/adapters/iAdapter.go
@@ -52,4 +52,5 @@
Enable_port(deviceId string, port *voltha.Port) error
Disable_port(deviceId string, port *voltha.Port) error
Child_device_lost(parentDeviceId string, parentPortNo uint32, onuID uint32) error
+ Start_omci_test(device *voltha.Device, request *voltha.OmciTestRequest) (*voltha.TestResponse, error)
}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/config/common.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/config/common.go
new file mode 100644
index 0000000..37e05fd
--- /dev/null
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/config/common.go
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2020-present Open Networking Foundation
+ *
+ * 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 config
+
+import (
+ "github.com/opencord/voltha-lib-go/v3/pkg/log"
+)
+
+var logger log.Logger
+
+func init() {
+ // Setup this package so that it's log level can be modified at run time
+ var err error
+ logger, err = log.AddPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "config"})
+ if err != nil {
+ panic(err)
+ }
+}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/config/configmanager.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/config/configmanager.go
index 441c488..9f08b0d 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/config/configmanager.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/config/configmanager.go
@@ -24,13 +24,6 @@
"strings"
)
-func init() {
- _, err := log.AddPackage(log.JSON, log.FatalLevel, nil)
- if err != nil {
- log.Errorw("unable-to-register-package-to-the-log-map", log.Fields{"error": err})
- }
-}
-
const (
defaultkvStoreConfigPath = "config"
kvStoreDataPathPrefix = "service/voltha"
@@ -171,7 +164,7 @@
func (c *ComponentConfig) MonitorForConfigChange(ctx context.Context) chan *ConfigChangeEvent {
key := c.makeConfigPath()
- log.Debugw("monitoring-for-config-change", log.Fields{"key": key})
+ logger.Debugw("monitoring-for-config-change", log.Fields{"key": key})
c.changeEventChan = make(chan *ConfigChangeEvent, 1)
@@ -188,14 +181,14 @@
ccKeyPrefix := c.makeConfigPath()
- log.Debugw("processing-kvstore-event-change", log.Fields{"key-prefix": ccKeyPrefix})
+ logger.Debugw("processing-kvstore-event-change", log.Fields{"key-prefix": ccKeyPrefix})
ccPathPrefix := c.cManager.backend.PathPrefix + ccKeyPrefix + kvStorePathSeparator
for watchResp := range c.kvStoreEventChan {
if watchResp.EventType == kvstore.CONNECTIONDOWN || watchResp.EventType == kvstore.UNKNOWN {
- log.Warnw("received-invalid-change-type-in-watch-channel-from-kvstore", log.Fields{"change-type": watchResp.EventType})
+ logger.Warnw("received-invalid-change-type-in-watch-channel-from-kvstore", log.Fields{"change-type": watchResp.EventType})
continue
}
@@ -215,7 +208,7 @@
func (c *ComponentConfig) Retrieve(ctx context.Context, configKey string) (string, error) {
key := c.makeConfigPath() + "/" + configKey
- log.Debugw("retrieving-config", log.Fields{"key": key})
+ logger.Debugw("retrieving-config", log.Fields{"key": key})
if kvpair, err := c.cManager.backend.Get(ctx, key); err != nil {
return "", err
@@ -225,7 +218,7 @@
}
value := strings.Trim(fmt.Sprintf("%s", kvpair.Value), "\"")
- log.Debugw("retrieved-config", log.Fields{"key": key, "value": value})
+ logger.Debugw("retrieved-config", log.Fields{"key": key, "value": value})
return value, nil
}
}
@@ -233,7 +226,7 @@
func (c *ComponentConfig) RetrieveAll(ctx context.Context) (map[string]string, error) {
key := c.makeConfigPath()
- log.Debugw("retreiving-list", log.Fields{"key": key})
+ logger.Debugw("retreiving-list", log.Fields{"key": key})
data, err := c.cManager.backend.List(ctx, key)
if err != nil {
@@ -256,7 +249,7 @@
func (c *ComponentConfig) Save(ctx context.Context, configKey string, configValue string) error {
key := c.makeConfigPath() + "/" + configKey
- log.Debugw("saving-config", log.Fields{"key": key, "value": configValue})
+ logger.Debugw("saving-config", log.Fields{"key": key, "value": configValue})
//save the data for update config
if err := c.cManager.backend.Put(ctx, key, configValue); err != nil {
@@ -269,7 +262,7 @@
//construct key using makeConfigPath
key := c.makeConfigPath() + "/" + configKey
- log.Debugw("deleting-config", log.Fields{"key": key})
+ logger.Debugw("deleting-config", log.Fields{"key": key})
//delete the config
if err := c.cManager.backend.Delete(ctx, key); err != nil {
return err
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/config/logcontroller.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/config/logcontroller.go
index 65927e6..b929c9d 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/config/logcontroller.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/config/logcontroller.go
@@ -51,7 +51,7 @@
func NewComponentLogController(cm *ConfigManager) (*ComponentLogController, error) {
- log.Debug("creating-new-component-log-controller")
+ logger.Debug("creating-new-component-log-controller")
componentName := os.Getenv("COMPONENT_NAME")
if componentName == "" {
return nil, errors.New("Unable to retrieve PoD Component Name from Runtime env")
@@ -80,15 +80,15 @@
func StartLogLevelConfigProcessing(cm *ConfigManager, ctx context.Context) {
cc, err := NewComponentLogController(cm)
if err != nil {
- log.Errorw("unable-to-construct-component-log-controller-instance-for-log-config-monitoring", log.Fields{"error": err})
+ logger.Errorw("unable-to-construct-component-log-controller-instance-for-log-config-monitoring", log.Fields{"error": err})
return
}
cc.GlobalConfig = cm.InitComponentConfig(globalConfigRootNode, ConfigTypeLogLevel)
- log.Debugw("global-log-config", log.Fields{"cc-global-config": cc.GlobalConfig})
+ logger.Debugw("global-log-config", log.Fields{"cc-global-config": cc.GlobalConfig})
cc.componentNameConfig = cm.InitComponentConfig(cc.ComponentName, ConfigTypeLogLevel)
- log.Debugw("component-log-config", log.Fields{"cc-component-name-config": cc.componentNameConfig})
+ logger.Debugw("component-log-config", log.Fields{"cc-component-name-config": cc.componentNameConfig})
cc.persistInitialDefaultLogConfigs(ctx)
@@ -101,21 +101,21 @@
_, err := c.GlobalConfig.Retrieve(ctx, defaultLogLevelKey)
if err != nil {
- log.Debugw("failed-to-retrieve-global-default-log-config-at-startup", log.Fields{"error": err})
+ logger.Debugw("failed-to-retrieve-global-default-log-config-at-startup", log.Fields{"error": err})
err = c.GlobalConfig.Save(ctx, defaultLogLevelKey, initialGlobalDefaultLogLevelValue)
if err != nil {
- log.Errorw("failed-to-persist-global-default-log-config-at-startup", log.Fields{"error": err, "loglevel": initialGlobalDefaultLogLevelValue})
+ logger.Errorw("failed-to-persist-global-default-log-config-at-startup", log.Fields{"error": err, "loglevel": initialGlobalDefaultLogLevelValue})
}
}
_, err = c.componentNameConfig.Retrieve(ctx, defaultLogLevelKey)
if err != nil {
- log.Debugw("failed-to-retrieve-component-default-log-config-at-startup", log.Fields{"error": err})
+ logger.Debugw("failed-to-retrieve-component-default-log-config-at-startup", log.Fields{"error": err})
err = c.componentNameConfig.Save(ctx, defaultLogLevelKey, c.initialLogLevel)
if err != nil {
- log.Errorw("failed-to-persist-component-default-log-config-at-startup", log.Fields{"error": err, "loglevel": c.initialLogLevel})
+ logger.Errorw("failed-to-persist-component-default-log-config-at-startup", log.Fields{"error": err, "loglevel": c.initialLogLevel})
}
}
}
@@ -129,10 +129,10 @@
// Load and apply Log Config for first time
initialLogConfig, err := c.buildUpdatedLogConfig(ctx)
if err != nil {
- log.Warnw("unable-to-load-log-config-at-startup", log.Fields{"error": err})
+ logger.Warnw("unable-to-load-log-config-at-startup", log.Fields{"error": err})
} else {
if err := c.loadAndApplyLogConfig(initialLogConfig); err != nil {
- log.Warnw("unable-to-apply-log-config-at-startup", log.Fields{"error": err})
+ logger.Warnw("unable-to-apply-log-config-at-startup", log.Fields{"error": err})
}
}
@@ -148,18 +148,18 @@
case configEvent = <-componentConfigEventChan:
}
- log.Debugw("processing-log-config-change", log.Fields{"ChangeType": configEvent.ChangeType, "Package": configEvent.ConfigAttribute})
+ logger.Debugw("processing-log-config-change", log.Fields{"ChangeType": configEvent.ChangeType, "Package": configEvent.ConfigAttribute})
updatedLogConfig, err := c.buildUpdatedLogConfig(ctx)
if err != nil {
- log.Warnw("unable-to-fetch-updated-log-config", log.Fields{"error": err})
+ logger.Warnw("unable-to-fetch-updated-log-config", log.Fields{"error": err})
continue
}
- log.Debugw("applying-updated-log-config", log.Fields{"updated-log-config": updatedLogConfig})
+ logger.Debugw("applying-updated-log-config", log.Fields{"updated-log-config": updatedLogConfig})
if err := c.loadAndApplyLogConfig(updatedLogConfig); err != nil {
- log.Warnw("unable-to-load-and-apply-log-config", log.Fields{"error": err})
+ logger.Warnw("unable-to-load-and-apply-log-config", log.Fields{"error": err})
}
}
@@ -178,7 +178,7 @@
for _, packageName := range log.GetPackageNames() {
level, err := log.GetPackageLogLevel(packageName)
if err != nil {
- log.Warnw("unable-to-fetch-current-active-loglevel-for-package-name", log.Fields{"package-name": packageName, "error": err})
+ logger.Warnw("unable-to-fetch-current-active-loglevel-for-package-name", log.Fields{"package-name": packageName, "error": err})
continue
}
@@ -187,7 +187,7 @@
}
}
- log.Debugw("retreived-log-levels-from-zap-logger", log.Fields{"loglevels": loglevels})
+ logger.Debugw("retreived-log-levels-from-zap-logger", log.Fields{"loglevels": loglevels})
return loglevels
}
@@ -202,16 +202,16 @@
// Handle edge cases when global default loglevel is deleted directly from etcd or set to a invalid value
// We should use hard-coded initial default value in such cases
if globalDefaultLogLevel == "" {
- log.Warn("global-default-loglevel-not-found-in-config-store")
+ logger.Warn("global-default-loglevel-not-found-in-config-store")
globalDefaultLogLevel = initialGlobalDefaultLogLevelValue
}
if _, err := log.StringToLogLevel(globalDefaultLogLevel); err != nil {
- log.Warnw("unsupported-loglevel-config-defined-at-global-default", log.Fields{"log-level": globalDefaultLogLevel})
+ logger.Warnw("unsupported-loglevel-config-defined-at-global-default", log.Fields{"log-level": globalDefaultLogLevel})
globalDefaultLogLevel = initialGlobalDefaultLogLevelValue
}
- log.Debugw("retrieved-global-default-loglevel", log.Fields{"level": globalDefaultLogLevel})
+ logger.Debugw("retrieved-global-default-loglevel", log.Fields{"level": globalDefaultLogLevel})
return globalDefaultLogLevel, nil
}
@@ -225,7 +225,7 @@
effectiveDefaultLogLevel := ""
for logConfigKey, logConfigValue := range componentLogConfig {
if _, err := log.StringToLogLevel(logConfigValue); err != nil || logConfigKey == "" {
- log.Warnw("unsupported-loglevel-config-defined-at-component-context", log.Fields{"package-name": logConfigKey, "log-level": logConfigValue})
+ logger.Warnw("unsupported-loglevel-config-defined-at-component-context", log.Fields{"package-name": logConfigKey, "log-level": logConfigValue})
delete(componentLogConfig, logConfigKey)
} else {
if logConfigKey == defaultLogLevelKey {
@@ -242,7 +242,7 @@
componentLogConfig[defaultLogLevelKey] = effectiveDefaultLogLevel
- log.Debugw("retrieved-component-log-config", log.Fields{"component-log-level": componentLogConfig})
+ logger.Debugw("retrieved-component-log-config", log.Fields{"component-log-level": componentLogConfig})
return componentLogConfig, nil
}
@@ -256,7 +256,7 @@
func (c *ComponentLogController) buildUpdatedLogConfig(ctx context.Context) (map[string]string, error) {
globalLogLevel, err := c.getGlobalLogConfig(ctx)
if err != nil {
- log.Errorw("unable-to-retrieve-global-log-config", log.Fields{"err": err})
+ logger.Errorw("unable-to-retrieve-global-log-config", log.Fields{"err": err})
}
componentLogConfig, err := c.getComponentLogConfig(ctx, globalLogLevel)
@@ -286,7 +286,7 @@
UpdateLogLevels(logConfig)
c.logHash = currentLogHash
} else {
- log.Debug("effective-loglevel-config-same-as-currently-active")
+ logger.Debug("effective-loglevel-config-same-as-currently-active")
}
return nil
@@ -313,7 +313,7 @@
// Log warnings for all invalid packages for which log config has been set
for key, value := range updatedLogLevels {
if _, exist := activeLogLevels[key]; !exist {
- log.Warnw("ignoring-loglevel-set-for-invalid-package", log.Fields{"package": key, "log-level": value})
+ logger.Warnw("ignoring-loglevel-set-for-invalid-package", log.Fields{"package": key, "log-level": value})
}
}
@@ -330,11 +330,11 @@
// If no changed log levels are found, just return. It may happen on configuration of a invalid package
if len(changedLogLevels) == 0 {
- log.Debug("no-change-in-effective-loglevel-config")
+ logger.Debug("no-change-in-effective-loglevel-config")
return
}
- log.Debugw("applying-log-level-for-modified-packages", log.Fields{"changed-log-levels": changedLogLevels})
+ logger.Debugw("applying-log-level-for-modified-packages", log.Fields{"changed-log-levels": changedLogLevels})
for key, level := range changedLogLevels {
if key == defaultLogLevelKey {
if l, err := log.StringToLogLevel(level); err == nil {
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/db/common.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/db/common.go
index a5a79ae..1cf2e1c 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/db/common.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/db/common.go
@@ -19,16 +19,12 @@
"github.com/opencord/voltha-lib-go/v3/pkg/log"
)
-const (
- logLevel = log.ErrorLevel
-)
-
var logger log.Logger
func init() {
// Setup this package so that it's log level can be modified at run time
var err error
- logger, err = log.AddPackage(log.JSON, logLevel, log.Fields{"pkg": "db"})
+ logger, err = log.AddPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "db"})
if err != nil {
panic(err)
}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/db/kvstore/common.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/db/kvstore/common.go
index 2d2a6a6..aa7aeb0 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/db/kvstore/common.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/db/kvstore/common.go
@@ -19,16 +19,12 @@
"github.com/opencord/voltha-lib-go/v3/pkg/log"
)
-const (
- logLevel = log.ErrorLevel
-)
-
var logger log.Logger
func init() {
// Setup this package so that it's log level can be modified at run time
var err error
- logger, err = log.AddPackage(log.JSON, logLevel, log.Fields{"pkg": "kvstore"})
+ logger, err = log.AddPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "kvstore"})
if err != nil {
panic(err)
}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/flows/common.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/flows/common.go
index b4fe7ec..557de3f 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/flows/common.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/flows/common.go
@@ -19,16 +19,12 @@
"github.com/opencord/voltha-lib-go/v3/pkg/log"
)
-const (
- logLevel = log.ErrorLevel
-)
-
var logger log.Logger
func init() {
// Setup this package so that it's log level can be modified at run time
var err error
- logger, err = log.AddPackage(log.JSON, logLevel, log.Fields{"pkg": "flowsUtils"})
+ logger, err = log.AddPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "flowsUtils"})
if err != nil {
panic(err)
}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/grpc/common.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/grpc/common.go
new file mode 100644
index 0000000..17eeeaf
--- /dev/null
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/grpc/common.go
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2020-present Open Networking Foundation
+ *
+ * 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 grpc
+
+import (
+ "github.com/opencord/voltha-lib-go/v3/pkg/log"
+)
+
+var logger log.Logger
+
+func init() {
+ // Setup this package so that it's log level can be modified at run time
+ var err error
+ logger, err = log.AddPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "grpc"})
+ if err != nil {
+ panic(err)
+ }
+}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/grpc/server.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/grpc/server.go
index 33c9b76..43f2912 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/grpc/server.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/grpc/server.go
@@ -18,7 +18,6 @@
import (
"context"
"fmt"
- "github.com/opencord/voltha-lib-go/v3/pkg/log"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
@@ -100,19 +99,19 @@
lis, err := net.Listen("tcp", host)
if err != nil {
- log.Fatalf("failed to listen: %v", err)
+ logger.Fatalf("failed to listen: %v", err)
}
if s.secure && s.GrpcSecurity != nil {
creds, err := credentials.NewServerTLSFromFile(s.CertFile, s.KeyFile)
if err != nil {
- log.Fatalf("could not load TLS keys: %s", err)
+ logger.Fatalf("could not load TLS keys: %s", err)
}
s.gs = grpc.NewServer(grpc.Creds(creds),
withServerUnaryInterceptor(s))
} else {
- log.Info("starting-insecure-grpc-server")
+ logger.Info("starting-insecure-grpc-server")
s.gs = grpc.NewServer(withServerUnaryInterceptor(s))
}
@@ -122,7 +121,7 @@
}
if err := s.gs.Serve(lis); err != nil {
- log.Fatalf("failed to serve: %v\n", err)
+ logger.Fatalf("failed to serve: %v\n", err)
}
}
@@ -145,7 +144,7 @@
handler grpc.UnaryHandler) (interface{}, error) {
if (s.probe != nil) && (!s.probe.IsReady()) {
- log.Warnf("Grpc request received while not ready %v", req)
+ logger.Warnf("Grpc request received while not ready %v", req)
return nil, status.Error(codes.Unavailable, "system is not ready")
}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/kafka/common.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/kafka/common.go
index cb6acb2..149c150 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/kafka/common.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/kafka/common.go
@@ -19,16 +19,12 @@
"github.com/opencord/voltha-lib-go/v3/pkg/log"
)
-const (
- logLevel = log.ErrorLevel
-)
-
var logger log.Logger
func init() {
// Setup this package so that it's log level can be modified at run time
var err error
- logger, err = log.AddPackage(log.JSON, logLevel, log.Fields{"pkg": "kafka"})
+ logger, err = log.AddPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "kafka"})
if err != nil {
panic(err)
}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/kafka/kafka_inter_container_library.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/kafka/kafka_inter_container_library.go
index 5dbde9c..fc2334d 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/kafka/kafka_inter_container_library.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/kafka/kafka_inter_container_library.go
@@ -194,11 +194,11 @@
kp.kafkaClient.Stop()
err := kp.deleteAllTopicRequestHandlerChannelMap()
if err != nil {
- log.Errorw("failed-delete-all-topic-request-handler-channel-map", log.Fields{"error": err})
+ logger.Errorw("failed-delete-all-topic-request-handler-channel-map", log.Fields{"error": err})
}
err = kp.deleteAllTopicResponseChannelMap()
if err != nil {
- log.Errorw("failed-delete-all-topic-response-channel-map", log.Fields{"error": err})
+ logger.Errorw("failed-delete-all-topic-response-channel-map", log.Fields{"error": err})
}
kp.deleteAllTransactionIdToChannelMap()
}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/log/log.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/log/log.go
index 47fa3fb..d0169bd 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/log/log.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/log/log.go
@@ -499,11 +499,11 @@
}
func getPackageLevelSugaredLogger() *zp.SugaredLogger {
- pkgName, fileName, funcName, line := getCallerInfo()
+ pkgName, _, _, _ := getCallerInfo()
if _, exist := loggers[pkgName]; exist {
- return loggers[pkgName].log.With("caller", fmt.Sprintf("%s.%s:%d", fileName, funcName, line))
+ return loggers[pkgName].log
}
- return defaultLogger.log.With("caller", fmt.Sprintf("%s.%s:%d", fileName, funcName, line))
+ return defaultLogger.log
}
func getPackageLevelLogger() Logger {
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/mocks/common.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/mocks/common.go
index 839ac3e..90612bb 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/mocks/common.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/mocks/common.go
@@ -19,16 +19,12 @@
"github.com/opencord/voltha-lib-go/v3/pkg/log"
)
-const (
- logLevel = log.ErrorLevel
-)
-
var logger log.Logger
func init() {
// Setup this package so that it's log level can be modified at run time
var err error
- logger, err = log.AddPackage(log.JSON, logLevel, log.Fields{"pkg": "mocks"})
+ logger, err = log.AddPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "mocks"})
if err != nil {
panic(err)
}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/probe/common.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/probe/common.go
new file mode 100644
index 0000000..211419d
--- /dev/null
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/probe/common.go
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2020-present Open Networking Foundation
+ *
+ * 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 probe
+
+import (
+ "github.com/opencord/voltha-lib-go/v3/pkg/log"
+)
+
+var logger log.Logger
+
+func init() {
+ // Setup this package so that it's log level can be modified at run time
+ var err error
+ logger, err = log.AddPackage(log.JSON, log.ErrorLevel, log.Fields{"pkg": "probe"})
+ if err != nil {
+ panic(err)
+ }
+}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/probe/probe.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/probe/probe.go
index 932c287..e89d5bc 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/probe/probe.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/probe/probe.go
@@ -118,7 +118,7 @@
for _, name := range names {
if _, ok := p.status[name]; !ok {
p.status[name] = ServiceStatusUnknown
- log.Debugw("probe-service-registered", log.Fields{"service-name": name})
+ logger.Debugw("probe-service-registered", log.Fields{"service-name": name})
}
}
@@ -161,7 +161,7 @@
} else {
p.isHealthy = defaultHealthFunc(p.status)
}
- log.Debugw("probe-service-status-updated",
+ logger.Debugw("probe-service-status-updated",
log.Fields{
"service-name": name,
"status": status.String(),
@@ -232,21 +232,21 @@
defer p.mutex.RUnlock()
w.Header().Set("Content-Type", "application/json")
if _, err := w.Write([]byte("{")); err != nil {
- log.Errorw("write-response", log.Fields{"error": err})
+ logger.Errorw("write-response", log.Fields{"error": err})
w.WriteHeader(http.StatusInternalServerError)
return
}
comma := ""
for c, s := range p.status {
if _, err := w.Write([]byte(fmt.Sprintf("%s\"%s\": \"%s\"", comma, c, s.String()))); err != nil {
- log.Errorw("write-response", log.Fields{"error": err})
+ logger.Errorw("write-response", log.Fields{"error": err})
w.WriteHeader(http.StatusInternalServerError)
return
}
comma = ", "
}
if _, err := w.Write([]byte("}")); err != nil {
- log.Errorw("write-response", log.Fields{"error": err})
+ logger.Errorw("write-response", log.Fields{"error": err})
w.WriteHeader(http.StatusInternalServerError)
return
}
@@ -269,7 +269,7 @@
Addr: address,
Handler: mux,
}
- log.Fatal(s.ListenAndServe())
+ logger.Fatal(s.ListenAndServe())
}
func (p *Probe) IsReady() bool {
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 5130080..f1ddebd 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -96,7 +96,7 @@
github.com/modern-go/concurrent
# github.com/modern-go/reflect2 v1.0.1
github.com/modern-go/reflect2
-# github.com/opencord/voltha-lib-go/v3 v3.0.23
+# github.com/opencord/voltha-lib-go/v3 v3.1.0
github.com/opencord/voltha-lib-go/v3/pkg/adapters
github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif
github.com/opencord/voltha-lib-go/v3/pkg/adapters/common