[VOL-5054] - Triage build for voltha-openolt-adapter
cmd/*.go
internal/pkg/*.go
pkg/mocks/*.go
=================
o Run gofmt -w -s on all non-(vendor/) golang sources (~make lint).
o Release triage jobs have been failing on unrelated source problems.
config.mk
makefiles/docker/
makefiles/etc/
makefiles/targets/
makefiles/virtualenv.mk
=======================
o https://github.com/opencord/onf-make.git
o Copy in library makefiles, esp docker/include.mk
Makefile
========
o Refactor and replace inline GO= and docker macros with docker/include.
o Added manual flag LOCAL_FIX_PERMS=1 to grant docker image write access.
o Target: mod-update
- Split logic into targets mod-tidy and mod-vendor.
- Display a banner when target runs for readability.
- Target lint-mod now calls mod-update VS inlining make mod tidy & vendor
o Target: test
- Split logic into 3 distinct targets now that stdout/stderr handled.
- Improve error handling, fail early VS accumulating status then exit
- Display a banner when targets process for log readability.
- Define macros for *.out and *.xml to avoid repeating logfile paths.
Change-Id: Ia2eb999f6176ce2eb46e41f55aee74c05b5a4cd2
diff --git a/Makefile b/Makefile
index 0bd7c9f..7f21a2c 100644
--- a/Makefile
+++ b/Makefile
@@ -27,7 +27,9 @@
##--------------------##
##---] INCLUDES [---##
##--------------------##
-include $(MAKEDIR)/include.mk
+include config.mk# # configure
+include makefiles/include.mk # top level include
+
ifdef LOCAL_LINT
include $(MAKEDIR)/lint/golang/sca.mk
endif
@@ -66,11 +68,11 @@
# tool containers
VOLTHA_TOOLS_VERSION ?= 2.4.0
-GO = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app $(shell test -t 0 && echo "-it") -v gocache:/.cache -v gocache-${VOLTHA_TOOLS_VERSION}:/go/pkg voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-golang go
-GO_JUNIT_REPORT = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app -i voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-go-junit-report go-junit-report
-GOCOVER_COBERTURA = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app/src/github.com/opencord/voltha-openolt-adapter -i voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-gocover-cobertura gocover-cobertura
-GOLANGCI_LINT = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app $(shell test -t 0 && echo "-it") -v gocache:/.cache -v gocache-${VOLTHA_TOOLS_VERSION}:/go/pkg voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-golangci-lint golangci-lint
-HADOLINT = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app $(shell test -t 0 && echo "-it") voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-hadolint hadolint
+# GO = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app $(shell test -t 0 && echo "-it") -v gocache:/.cache -v gocache-${VOLTHA_TOOLS_VERSION}:/go/pkg voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-golang go
+# GO_JUNIT_REPORT = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app -i voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-go-junit-report go-junit-report
+# GOCOVER_COBERTURA = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app/src/github.com/opencord/voltha-openolt-adapter -i voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-gocover-cobertura gocover-cobertura
+# GOLANGCI_LINT = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app $(shell test -t 0 && echo "-it") -v gocache:/.cache -v gocache-${VOLTHA_TOOLS_VERSION}:/go/pkg voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-golangci-lint golangci-lint
+# HADOLINT = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app $(shell test -t 0 && echo "-it") voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-hadolint hadolint
.PHONY: docker-build local-protos local-lib-go help
@@ -133,14 +135,19 @@
## -----------------------------------------------------------------------
## -----------------------------------------------------------------------
lint-mod: ## Verify the Go dependencies
+
@echo "Running dependency check..."
@${GO} mod verify
+
@echo "Dependency check OK. Running vendor check..."
@git status > /dev/null
@git diff-index --quiet HEAD -- go.mod go.sum vendor || (echo "ERROR: Staged or modified files must be committed before running this test" && git status -- go.mod go.sum vendor && exit 1)
@[[ `git ls-files --exclude-standard --others go.mod go.sum vendor` == "" ]] || (echo "ERROR: Untracked files must be cleaned up before running this test" && git status -- go.mod go.sum vendor && exit 1)
- ${GO} mod tidy
- ${GO} mod vendor
+
+ $(MAKE) mod-update
+# ${GO} mod tidy
+# ${GO} mod vendor
+
@git status > /dev/null
@git diff-index --quiet HEAD -- go.mod go.sum vendor || (echo "ERROR: Modified files detected after running go mod tidy / go mod vendor" && git status -- go.mod go.sum vendor && git checkout -- go.mod go.sum vendor && exit 1)
@[[ `git ls-files --exclude-standard --others go.mod go.sum vendor` == "" ]] || (echo "ERROR: Untracked files detected after running go mod tidy / go mod vendor" && git status -- go.mod go.sum vendor && git checkout -- go.mod go.sum vendor && exit 1)
@@ -152,17 +159,71 @@
## -----------------------------------------------------------------------
## -----------------------------------------------------------------------
+coverage-out := ./tests/results/go-test-coverage.out
+coverage-res := ./tests/results/go-test-results.out
test: ## Run unit tests
+
+ $(call banner-enter,$@)
+
+ $(RM) -r tests/results
@mkdir -p ./tests/results
- @${GO} test -mod=vendor -v -coverprofile ./tests/results/go-test-coverage.out -covermode count ./... 2>&1 | tee ./tests/results/go-test-results.out ;\
- RETURN=$$? ;\
- ${GO_JUNIT_REPORT} < ./tests/results/go-test-results.out > ./tests/results/go-test-results.xml ;\
- ${GOCOVER_COBERTURA} < ./tests/results/go-test-coverage.out > ./tests/results/go-test-coverage.xml ;\
- exit $$RETURN
+
+ @$(if $(LOCAL_FIX_PERMS),chmod 777 tests/results)
+
+ $(HIDE) $(MAKE) --no-print-directory test-go-coverage
+ $(HIDE) $(MAKE) --no-print-directory test-junit
+ $(HIDE) $(MAKE) --no-print-directory test-cobertura
+
+# ${GOCOVER_COBERTURA} < $(coverage-out) \
+# > ./tests/results/go-test-coverage.xml
+
+ @$(if $(LOCAL_FIX_PERMS),chmod 775 tests/results) # yes this may not run
+
+ $(call banner-leave,$@)
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+test-go-coverage:
+ $(call banner-enter,$@)
+ @$(if $(LOCAL_FIX_PERMS),chmod 777 tests/results)
+ ( ${GO} test -mod=vendor -v -coverprofile $(coverage-out) -covermode count ./... 2>&1 ) \
+ | tee $(coverage-res)
+ @$(if $(LOCAL_FIX_PERMS),chmod 775 tests/results)
+ $(call banner-leave,$@)
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+test-junit:
+ $(call banner-enter,$@)
+ @$(if $(LOCAL_FIX_PERMS),chmod 777 tests/results)
+ ${GO_JUNIT_REPORT} < $(coverage-res) \
+ > ./tests/results/go-test-results.xml
+ @$(if $(LOCAL_FIX_PERMS),chmod 775 tests/results)
+ $(call banner-leave,$@)
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+test-cobertura:
+ $(call banner-enter,$@)
+ @$(if $(LOCAL_FIX_PERMS),chmod 777 tests/results)
+ ${GOCOVER_COBERTURA} < $(coverage-out) \
+ > ./tests/results/go-test-coverage.xml
+ @$(if $(LOCAL_FIX_PERMS),chmod 775 tests/results)
+ $(call banner-leave,$@)
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+help ::
+ @echo '[TEST: Coverage report]'
+ @echo ' test-go-coverage Generate a coverage report for vendor/'
+ @echo ' test-junit Digest go coverage, generate junit'
+ @echo ' test-cobertura Digest coverage and junit reports'
## -----------------------------------------------------------------------
## -----------------------------------------------------------------------
sca:
+ $(call banner-enter,$@)
+
@$(RM) -r ./sca-report
@mkdir -p ./sca-report
@echo "Running static code analysis..."
@@ -171,9 +232,12 @@
@echo ""
@echo "Static code analysis OK"
+ $(call banner-leave,$@)
+
## -----------------------------------------------------------------------
## -----------------------------------------------------------------------
-clean: distclean
+clean :: distclean
+sterile :: clean distclean
## -----------------------------------------------------------------------
## -----------------------------------------------------------------------
@@ -182,8 +246,34 @@
## -----------------------------------------------------------------------
## -----------------------------------------------------------------------
-mod-update:
+.PHONY: mod-update
+mod-update: mod-tidy mod-vendor
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+.PHONY: mod-tidy
+mod-tidy:
+ $(call banner-enter,$@)
${GO} mod tidy
+ $(call banner-leave,$@)
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+.PHONY: mod-vendor
+mod-vendor:
+ $(call banner-enter,$@)
+ @$(if $(LOCAL_FIX_PERMS),chmod 777 .)
${GO} mod vendor
+ @$(if $(LOCAL_FIX_PERMS),chmod 755 .)
+ $(call banner-leave,$@)
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+help ::
+ @echo '[MOD UPDATE]'
+ @echo ' mod-update'
+ @echo ' LOCAL_FIX_PERMS=1 Hack to fix docker access problems'
+ @echo ' mod-tidy'
+ @echo ' mod-vendor'
# [EOF]
diff --git a/VERSION b/VERSION
index e8fc584..c4ac44d 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-4.3.5.1-dev
+4.3.5.2-dev
diff --git a/cmd/openolt-adapter/profile.go b/cmd/openolt-adapter/profile.go
index a4fb006..89f47a7 100644
--- a/cmd/openolt-adapter/profile.go
+++ b/cmd/openolt-adapter/profile.go
@@ -1,3 +1,4 @@
+//go:build profile
// +build profile
/*
diff --git a/cmd/openolt-adapter/release.go b/cmd/openolt-adapter/release.go
index 7e97c2d..0dc5465 100644
--- a/cmd/openolt-adapter/release.go
+++ b/cmd/openolt-adapter/release.go
@@ -1,3 +1,4 @@
+//go:build !profile
// +build !profile
/*
@@ -16,7 +17,7 @@
* limitations under the License.
*/
-//Package main invokes the application
+// Package main invokes the application
package main
import "context"
diff --git a/config.mk b/config.mk
new file mode 100644
index 0000000..c35b3df
--- /dev/null
+++ b/config.mk
@@ -0,0 +1,38 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# 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.
+# -----------------------------------------------------------------------
+
+##--------------------------------##
+##---] Disable lint targets [---##
+##--------------------------------##
+# NO-LINT-GROOVY := true# # Note[1]
+# NO-LINT-JJB := true# # Note[2]
+# NO-LINT-JSON := true# # Note[1]
+# NO-LINT-MAKEFILE := true
+# NO-LINT-PYTHON := true# # Note[1]
+# NO-LINT-REUSE := true # License check
+# NO-LINT-SHELL := true# # Note[1]
+# NO-LINT-YAML := true# # Note[1]
+
+# Note[1] - Plenty of source to cleanup
+# Note[2] - No sources available
+
+##---------------------------------##
+##---] Conditional make logic [---##
+##---------------------------------##
+USE_DOCKER_MK := true
+
+# [EOF]
diff --git a/internal/pkg/config/config.go b/internal/pkg/config/config.go
index 002c459..21106aa 100644
--- a/internal/pkg/config/config.go
+++ b/internal/pkg/config/config.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package config provides the Log, kvstore, Kafka configuration
+// Package config provides the Log, kvstore, Kafka configuration
package config
import (
diff --git a/internal/pkg/config/config_test.go b/internal/pkg/config/config_test.go
index 4e89635..152db52 100644
--- a/internal/pkg/config/config_test.go
+++ b/internal/pkg/config/config_test.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package config provides the Log, kvstore, Kafka configuration
+// Package config provides the Log, kvstore, Kafka configuration
package config
import (
diff --git a/internal/pkg/core/common.go b/internal/pkg/core/common.go
index 3c8a826..d2d6f6e 100644
--- a/internal/pkg/core/common.go
+++ b/internal/pkg/core/common.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package core Common Logger initialization
+// Package core Common Logger initialization
package core
import (
diff --git a/internal/pkg/core/device_handler_test.go b/internal/pkg/core/device_handler_test.go
index 4c9a00f..8c41952 100644
--- a/internal/pkg/core/device_handler_test.go
+++ b/internal/pkg/core/device_handler_test.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package core provides the utility for olt devices, flows and statistics
+// Package core provides the utility for olt devices, flows and statistics
package core
import (
@@ -1147,7 +1147,6 @@
}
}
-//
func TestDeviceHandler_doStateUp(t *testing.T) {
dh1 := newMockDeviceHandler()
dh2 := newMockDeviceHandler()
@@ -1374,66 +1373,68 @@
}
}
-/* We are not using the adapterPreviouslyConnected and agentPreviouslyConnected flags now to check for reboots and reconnects
+/*
+ We are not using the adapterPreviouslyConnected and agentPreviouslyConnected flags now to check for reboots and reconnects
+
commenting out all the tests related to these
func TestDeviceHandler_TestReconcileStatus(t *testing.T) {
- // olt disconnect (not reboot)
- dh1 := newMockDeviceHandler()
- dh1.adapterPreviouslyConnected = false
- dh1.agentPreviouslyConnected = true
+ // olt disconnect (not reboot)
+ dh1 := newMockDeviceHandler()
+ dh1.adapterPreviouslyConnected = false
+ dh1.agentPreviouslyConnected = true
- // adapter restart
- dh2 := newMockDeviceHandler()
- dh2.Client = &mocks.MockOpenoltClient{}
- dh2.adapterPreviouslyConnected = true
- dh2.agentPreviouslyConnected = true
+ // adapter restart
+ dh2 := newMockDeviceHandler()
+ dh2.Client = &mocks.MockOpenoltClient{}
+ dh2.adapterPreviouslyConnected = true
+ dh2.agentPreviouslyConnected = true
- // first connection or olt restart
- dh3 := newMockDeviceHandler()
- dh3.Client = &mocks.MockOpenoltClient{}
- dh3.adapterPreviouslyConnected = false
- dh3.agentPreviouslyConnected = false
+ // first connection or olt restart
+ dh3 := newMockDeviceHandler()
+ dh3.Client = &mocks.MockOpenoltClient{}
+ dh3.adapterPreviouslyConnected = false
+ dh3.agentPreviouslyConnected = false
- // olt and adapter restart at the same time (first case)
- dh4 := newMockDeviceHandler()
- dh4.Client = &mocks.MockOpenoltClient{}
- dh4.adapterPreviouslyConnected = true
- dh4.agentPreviouslyConnected = false
+ // olt and adapter restart at the same time (first case)
+ dh4 := newMockDeviceHandler()
+ dh4.Client = &mocks.MockOpenoltClient{}
+ dh4.adapterPreviouslyConnected = true
+ dh4.agentPreviouslyConnected = false
- // adapter restart and olt disconnect at the same time
- dh5 := newMockDeviceHandler()
- dh5.Client = &mocks.MockOpenoltClient{}
- dh5.adapterPreviouslyConnected = true
- dh5.agentPreviouslyConnected = true
+ // adapter restart and olt disconnect at the same time
+ dh5 := newMockDeviceHandler()
+ dh5.Client = &mocks.MockOpenoltClient{}
+ dh5.adapterPreviouslyConnected = true
+ dh5.agentPreviouslyConnected = true
- tests := []struct {
- name string
- devicehandler *DeviceHandler
- expectedRestart bool
- wantErr bool
- }{
- {"dostateup-1", dh1, true, false},
- {"dostateup-2", dh2, false, false},
- {"dostateup-3", dh3, false, false},
- {"dostateup-4", dh4, true, false},
- {"dostateup-5", dh5, false, false},
+ tests := []struct {
+ name string
+ devicehandler *DeviceHandler
+ expectedRestart bool
+ wantErr bool
+ }{
+ {"dostateup-1", dh1, true, false},
+ {"dostateup-2", dh2, false, false},
+ {"dostateup-3", dh3, false, false},
+ {"dostateup-4", dh4, true, false},
+ {"dostateup-5", dh5, false, false},
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+ defer cancel()
+ if err := tt.devicehandler.doStateUp(ctx); (err != nil) != tt.wantErr {
+ t.Logf("DeviceHandler.doStateUp() error = %v, wantErr %v", err, tt.wantErr)
+ }
+ tt.devicehandler.stopCollector <- true //stop the stat collector invoked from doStateUp
+ isRestarted := tt.devicehandler.Client.(*mocks.MockOpenoltClient).IsRestarted
+ if tt.expectedRestart != isRestarted {
+ t.Errorf("olt-reboot-failed expected= %v, got= %v", tt.expectedRestart, isRestarted)
+ }
+ })
+ }
}
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
- defer cancel()
- if err := tt.devicehandler.doStateUp(ctx); (err != nil) != tt.wantErr {
- t.Logf("DeviceHandler.doStateUp() error = %v, wantErr %v", err, tt.wantErr)
- }
- tt.devicehandler.stopCollector <- true //stop the stat collector invoked from doStateUp
- isRestarted := tt.devicehandler.Client.(*mocks.MockOpenoltClient).IsRestarted
- if tt.expectedRestart != isRestarted {
- t.Errorf("olt-reboot-failed expected= %v, got= %v", tt.expectedRestart, isRestarted)
- }
- })
- }
-}
*/
func Test_UpdateFlowsIncrementallyNegativeTestCases(t *testing.T) {
dh1 := negativeDeviceHandlerNilFlowMgr()
diff --git a/internal/pkg/core/olt_state_transitions.go b/internal/pkg/core/olt_state_transitions.go
index 73f75f7..cd3fc5c 100644
--- a/internal/pkg/core/olt_state_transitions.go
+++ b/internal/pkg/core/olt_state_transitions.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package core provides the utility for olt devices, flows and statistics
+// Package core provides the utility for olt devices, flows and statistics
package core
import (
diff --git a/internal/pkg/core/olt_state_transitions_test.go b/internal/pkg/core/olt_state_transitions_test.go
index cc3d1a2..6e8ba97 100644
--- a/internal/pkg/core/olt_state_transitions_test.go
+++ b/internal/pkg/core/olt_state_transitions_test.go
@@ -24,7 +24,8 @@
"time"
)
-/**
+/*
+*
Get's the transition Map with current state of the device.
*/
func getTranisitions() map[Trigger]Transition {
@@ -37,7 +38,8 @@
return transitions
}
-/**
+/*
+*
Get's the transition Map with after Transition func added.
*/
func getTranisitionsAfter() map[Trigger]Transition {
@@ -55,7 +57,8 @@
return transitions
}
-/**
+/*
+*
Get's the transition Map with before Transition func added.
*/
func getTranisitionsBefore() map[Trigger]Transition {
@@ -73,7 +76,8 @@
return transitions
}
-/**
+/*
+*
Check's Creation of transition Map, return's NewTransitionMap.
*/
func TestNewTransitionMap(t *testing.T) {
@@ -96,7 +100,8 @@
}
}
-/**
+/*
+*
Checks the different transition of the device handled properly.
*/
func TestTransitionMap_Handle(t *testing.T) {
@@ -130,7 +135,8 @@
}
}
-/**
+/*
+*
Check's if the transition is valid or not.
*/
func TestTransitionMap_isValidTransition(t *testing.T) {
@@ -167,7 +173,8 @@
}
}
-/**
+/*
+*
Get's the After/Before transition method's function name.
*/
func Test_funcName(t *testing.T) {
diff --git a/internal/pkg/core/openoltInterAdapter.go b/internal/pkg/core/openoltInterAdapter.go
index db9c70d..fb0d2a2 100644
--- a/internal/pkg/core/openoltInterAdapter.go
+++ b/internal/pkg/core/openoltInterAdapter.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package core provides the utility for olt devices, flows and statistics
+// Package core provides the utility for olt devices, flows and statistics
package core
import (
@@ -30,23 +30,23 @@
oltia "github.com/opencord/voltha-protos/v5/go/olt_inter_adapter_service"
)
-//OpenOLTInterAdapter structure holds a reference to the oltAdapter
+// OpenOLTInterAdapter structure holds a reference to the oltAdapter
type OpenOLTInterAdapter struct {
oltAdapter *OpenOLT
exitChannel chan struct{}
}
-//NewOpenOLTInterAdapter returns a new instance of OpenOLTInterAdapter
+// NewOpenOLTInterAdapter returns a new instance of OpenOLTInterAdapter
func NewOpenOLTInterAdapter(oltAdapter *OpenOLT) *OpenOLTInterAdapter {
return &OpenOLTInterAdapter{oltAdapter: oltAdapter, exitChannel: make(chan struct{})}
}
-//Start starts (logs) the device manager
+// Start starts (logs) the device manager
func (oo *OpenOLTInterAdapter) Start(ctx context.Context) error {
return nil
}
-//Stop terminates the session
+// Stop terminates the session
func (oo *OpenOLTInterAdapter) Stop(ctx context.Context) error {
close(oo.exitChannel)
return nil
diff --git a/internal/pkg/core/openolt_eventmgr.go b/internal/pkg/core/openolt_eventmgr.go
index 6ee538b..3740cf4 100644
--- a/internal/pkg/core/openolt_eventmgr.go
+++ b/internal/pkg/core/openolt_eventmgr.go
@@ -393,7 +393,7 @@
return nil
}
-//wasLosRaised checks whether los raised already. If already raised returns true else false
+// wasLosRaised checks whether los raised already. If already raised returns true else false
func (em *OpenOltEventMgr) wasLosRaised(ctx context.Context, onuAlarm *oop.OnuAlarmIndication) bool {
onuKey := em.handler.formOnuKey(onuAlarm.IntfId, onuAlarm.OnuId)
if onuInCache, ok := em.handler.onus.Load(onuKey); ok {
@@ -411,7 +411,7 @@
return true
}
-//wasLosCleared checks whether los cleared already. If already cleared returns true else false
+// wasLosCleared checks whether los cleared already. If already cleared returns true else false
func (em *OpenOltEventMgr) wasLosCleared(ctx context.Context, onuAlarm *oop.OnuAlarmIndication) bool {
onuKey := em.handler.formOnuKey(onuAlarm.IntfId, onuAlarm.OnuId)
if onuInCache, ok := em.handler.onus.Load(onuKey); ok {
diff --git a/internal/pkg/core/openolt_flowmgr.go b/internal/pkg/core/openolt_flowmgr.go
index 087f234..c5899b0 100644
--- a/internal/pkg/core/openolt_flowmgr.go
+++ b/internal/pkg/core/openolt_flowmgr.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package core provides the utility for olt devices, flows and statistics
+// Package core provides the utility for olt devices, flows and statistics
package core
import (
@@ -198,7 +198,7 @@
errChan *chan error // channel to report the Flow handling error
}
-//OpenOltFlowMgr creates the Structure of OpenOltFlowMgr obj
+// OpenOltFlowMgr creates the Structure of OpenOltFlowMgr obj
type OpenOltFlowMgr struct {
ponPortIdx uint32 // Pon Port this FlowManager is responsible for
techprofile tp.TechProfileIf
@@ -223,7 +223,7 @@
}
}
-//NewFlowManager creates OpenOltFlowMgr object and initializes the parameters
+// NewFlowManager creates OpenOltFlowMgr object and initializes the parameters
func NewFlowManager(ctx context.Context, dh *DeviceHandler, rMgr *rsrcMgr.OpenOltResourceMgr, grpMgr *OpenOltGroupMgr, ponPortIdx uint32) *OpenOltFlowMgr {
logger.Infow(ctx, "initializing-flow-manager", log.Fields{"device-id": dh.device.Id})
var flowMgr OpenOltFlowMgr
@@ -1225,13 +1225,13 @@
return nil
}
-//addIGMPTrapFlow creates IGMP trap-to-host flow
+// addIGMPTrapFlow creates IGMP trap-to-host flow
func (f *OpenOltFlowMgr) addIGMPTrapFlow(ctx context.Context, flowContext *flowContext) error {
delete(flowContext.classifier, VlanVid)
return f.addUpstreamTrapFlow(ctx, flowContext)
}
-//addUpstreamTrapFlow creates a trap-to-host flow
+// addUpstreamTrapFlow creates a trap-to-host flow
func (f *OpenOltFlowMgr) addUpstreamTrapFlow(ctx context.Context, flowContext *flowContext) error {
intfID := flowContext.intfID
@@ -1775,7 +1775,7 @@
return fmt.Sprintf("olt-{%s}/pon-{%d}/onu-{%d}/uni-{%d}", oltID, intfID, onuID, uniID)
}
-//getOnuDevice to fetch onu from cache or core.
+// getOnuDevice to fetch onu from cache or core.
func (f *OpenOltFlowMgr) getOnuDevice(ctx context.Context, intfID uint32, onuID uint32) (*OnuDevice, error) {
onuKey := f.deviceHandler.formOnuKey(intfID, onuID)
onuDev, ok := f.deviceHandler.onus.Load(onuKey)
@@ -1807,7 +1807,7 @@
return onuDev.(*OnuDevice), nil
}
-//getChildDevice to fetch onu
+// getChildDevice to fetch onu
func (f *OpenOltFlowMgr) getChildDevice(ctx context.Context, intfID uint32, onuID uint32) (*voltha.Device, error) {
logger.Infow(ctx, "GetChildDevice",
log.Fields{
@@ -1914,7 +1914,7 @@
return nil
}
-//clearResources clears pon resources in kv store and the device
+// clearResources clears pon resources in kv store and the device
// nolint: gocyclo
func (f *OpenOltFlowMgr) clearResources(ctx context.Context, intfID uint32, onuID int32, uniID int32,
flowID uint64, portNum uint32, tpID uint32, sendDeleteGemRequest bool) error {
@@ -2189,7 +2189,7 @@
return nil
}
-//RemoveFlow removes the flow from the device
+// RemoveFlow removes the flow from the device
func (f *OpenOltFlowMgr) RemoveFlow(ctx context.Context, flow *ofp.OfpFlowStats) error {
logger.Infow(ctx, "removing-flow", log.Fields{"flow": *flow})
@@ -2223,7 +2223,7 @@
return err
}
-//isIgmpTrapDownstreamFlow return true if the flow is a downsteam IGMP trap-to-host flow; false otherwise
+// isIgmpTrapDownstreamFlow return true if the flow is a downsteam IGMP trap-to-host flow; false otherwise
func isIgmpTrapDownstreamFlow(classifierInfo map[string]interface{}) bool {
if portType := plt.IntfIDToPortTypeName(classifierInfo[InPort].(uint32)); portType == voltha.Port_ETHERNET_NNI {
if ethType, ok := classifierInfo[EthType]; ok {
@@ -2497,7 +2497,7 @@
return nil
}
-//getNNIInterfaceIDOfMulticastFlow returns associated NNI interface id of the inPort criterion if exists; returns the first NNI interface of the device otherwise
+// getNNIInterfaceIDOfMulticastFlow returns associated NNI interface id of the inPort criterion if exists; returns the first NNI interface of the device otherwise
func (f *OpenOltFlowMgr) getNNIInterfaceIDOfMulticastFlow(ctx context.Context, classifierInfo map[string]interface{}) (uint32, error) {
if inPort, ok := classifierInfo[InPort]; ok {
nniInterfaceID, err := plt.IntfIDFromNniPortNum(ctx, inPort.(uint32))
@@ -2511,7 +2511,7 @@
return 0, nil
}
-//sendTPDownloadMsgToChild send payload
+// sendTPDownloadMsgToChild send payload
func (f *OpenOltFlowMgr) sendTPDownloadMsgToChild(ctx context.Context, intfID uint32, onuID uint32, uniID uint32, uni string, TpID uint32, tpInst tp_pb.TechProfileInstance) error {
onuDev, err := f.getOnuDevice(ctx, intfID, onuID)
@@ -2547,7 +2547,7 @@
return nil
}
-//GetLogicalPortFromPacketIn function computes logical port UNI/NNI port from packet-in indication and returns the same
+// GetLogicalPortFromPacketIn function computes logical port UNI/NNI port from packet-in indication and returns the same
func (f *OpenOltFlowMgr) GetLogicalPortFromPacketIn(ctx context.Context, packetIn *openoltpb2.PacketIndication) (uint32, error) {
var logicalPortNum uint32
@@ -2579,7 +2579,7 @@
return logicalPortNum, nil
}
-//GetPacketOutGemPortID returns gemPortId
+// GetPacketOutGemPortID returns gemPortId
func (f *OpenOltFlowMgr) GetPacketOutGemPortID(ctx context.Context, intfID uint32, onuID uint32, portNum uint32, packet []byte) (uint32, error) {
var gemPortID uint32
@@ -2698,7 +2698,7 @@
return nil
}
-//getPacketTypeFromClassifiers finds and returns packet type of a flow by checking flow classifiers
+// getPacketTypeFromClassifiers finds and returns packet type of a flow by checking flow classifiers
func getPacketTypeFromClassifiers(classifierInfo map[string]interface{}) string {
var packetType string
ovid, ivid := false, false
@@ -2737,7 +2737,7 @@
return packetType
}
-//addIgmpTrapFlowOnNNI adds a trap-to-host flow on NNI
+// addIgmpTrapFlowOnNNI adds a trap-to-host flow on NNI
func (f *OpenOltFlowMgr) addIgmpTrapFlowOnNNI(ctx context.Context, logicalFlow *ofp.OfpFlowStats, classifier map[string]interface{}, portNo uint32) error {
logger.Infow(ctx, "adding-igmp-trap-of-nni-flow", log.Fields{"classifier-info": classifier})
action := make(map[string]interface{})
@@ -3290,7 +3290,7 @@
"gem": gemPort})
}
-//getCTagFromPacket retrieves and returns c-tag and priority value from a packet.
+// getCTagFromPacket retrieves and returns c-tag and priority value from a packet.
func getCTagFromPacket(ctx context.Context, packet []byte) (uint16, uint8, error) {
if packet == nil || len(packet) < 18 {
logger.Error(ctx, "unable-get-c-tag-from-the-packet--invalid-packet-length ")
@@ -3317,7 +3317,7 @@
return 0, 0, nil
}
-//clearMulticastFlowFromResourceManager removes a multicast flow from the KV store and
+// clearMulticastFlowFromResourceManager removes a multicast flow from the KV store and
// clears resources reserved for this multicast flow
func (f *OpenOltFlowMgr) clearMulticastFlowFromResourceManager(ctx context.Context, flow *ofp.OfpFlowStats) error {
removeFlowMessage := openoltpb2.Flow{FlowId: flow.Id, FlowType: Multicast}
diff --git a/internal/pkg/core/openolt_flowmgr_test.go b/internal/pkg/core/openolt_flowmgr_test.go
index 7dc83b7..a07fcd4 100644
--- a/internal/pkg/core/openolt_flowmgr_test.go
+++ b/internal/pkg/core/openolt_flowmgr_test.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package core provides the utility for olt devices, flows and statistics
+// Package core provides the utility for olt devices, flows and statistics
package core
import (
diff --git a/internal/pkg/core/openolt_groupmgr.go b/internal/pkg/core/openolt_groupmgr.go
index 6490ebf..cc1ce00 100644
--- a/internal/pkg/core/openolt_groupmgr.go
+++ b/internal/pkg/core/openolt_groupmgr.go
@@ -11,7 +11,7 @@
* limitations under the License.
*/
-//Package core provides the utility for olt devices, flows, groups and statistics
+// Package core provides the utility for olt devices, flows, groups and statistics
package core
import (
@@ -29,13 +29,13 @@
"google.golang.org/grpc/status"
)
-//QueueInfoBrief has information about gemPortID and service priority associated with Mcast group
+// QueueInfoBrief has information about gemPortID and service priority associated with Mcast group
type QueueInfoBrief struct {
gemPortID uint32
servicePriority uint32
}
-//OpenOltGroupMgr creates the Structure of OpenOltGroupMgr obj
+// OpenOltGroupMgr creates the Structure of OpenOltGroupMgr obj
type OpenOltGroupMgr struct {
deviceHandler *DeviceHandler
resourceMgr *rsrcMgr.OpenOltResourceMgr
@@ -47,7 +47,7 @@
// EXPORTED FUNCTIONS //
//////////////////////////////////////////////
-//NewGroupManager creates OpenOltGroupMgr object and initializes the parameters
+// NewGroupManager creates OpenOltGroupMgr object and initializes the parameters
func NewGroupManager(ctx context.Context, dh *DeviceHandler, rMgr *rsrcMgr.OpenOltResourceMgr) *OpenOltGroupMgr {
logger.Infow(ctx, "initializing-group-manager", log.Fields{"device-id": dh.device.Id})
var grpMgr OpenOltGroupMgr
@@ -178,8 +178,8 @@
return nil
}
-//LoadInterfaceToMulticastQueueMap reads multicast queues per interface from the KV store
-//and put them into interfaceToMcastQueueMap.
+// LoadInterfaceToMulticastQueueMap reads multicast queues per interface from the KV store
+// and put them into interfaceToMcastQueueMap.
func (g *OpenOltGroupMgr) LoadInterfaceToMulticastQueueMap(ctx context.Context) {
storedMulticastQueueMap, err := g.resourceMgr.GetMcastQueuePerInterfaceMap(ctx)
if err != nil {
@@ -195,7 +195,7 @@
}
}
-//GetInterfaceToMcastQueueMap gets the mcast queue mapped to to the PON interface
+// GetInterfaceToMcastQueueMap gets the mcast queue mapped to to the PON interface
func (g *OpenOltGroupMgr) GetInterfaceToMcastQueueMap(intfID uint32) (*QueueInfoBrief, bool) {
g.interfaceToMcastQueueMapLock.RLock()
defer g.interfaceToMcastQueueMapLock.RUnlock()
@@ -203,19 +203,21 @@
return val, present
}
-//UpdateInterfaceToMcastQueueMap updates the mcast queue information mapped to a given PON interface
+// UpdateInterfaceToMcastQueueMap updates the mcast queue information mapped to a given PON interface
func (g *OpenOltGroupMgr) UpdateInterfaceToMcastQueueMap(intfID uint32, val *QueueInfoBrief) {
g.interfaceToMcastQueueMapLock.Lock()
defer g.interfaceToMcastQueueMapLock.Unlock()
g.interfaceToMcastQueueMap[intfID] = val
}
-////////////////////////////////////////////////
-// INTERNAL or UNEXPORTED FUNCTIONS //
-////////////////////////////////////////////////
-//getFlowGroupFromKVStore fetches and returns flow group from the KV store. Returns (nil, false, error) if any problem occurs during
-//fetching the data. Returns (group, true, nil) if the group is fetched and returned successfully.
-//Returns (nil, false, nil) if the group does not exists in the KV store.
+// //////////////////////////////////////////////
+//
+// INTERNAL or UNEXPORTED FUNCTIONS //
+//
+// //////////////////////////////////////////////
+// getFlowGroupFromKVStore fetches and returns flow group from the KV store. Returns (nil, false, error) if any problem occurs during
+// fetching the data. Returns (group, true, nil) if the group is fetched and returned successfully.
+// Returns (nil, false, nil) if the group does not exists in the KV store.
func (g *OpenOltGroupMgr) getFlowGroupFromKVStore(ctx context.Context, groupID uint32, cached bool) (*ofp.OfpGroupEntry, bool, error) {
exists, groupInfo, err := g.resourceMgr.GetFlowGroupFromKVStore(ctx, groupID, cached)
if err != nil {
@@ -245,7 +247,7 @@
return &groupEntry
}
-//buildGroupAction creates and returns a group action
+// buildGroupAction creates and returns a group action
func (g *OpenOltGroupMgr) buildGroupAction() *openoltpb2.Action {
var actionCmd openoltpb2.ActionCmd
var action openoltpb2.Action
@@ -255,7 +257,7 @@
return &action
}
-//callGroupAddRemove performs add/remove buckets operation for the indicated group
+// callGroupAddRemove performs add/remove buckets operation for the indicated group
func (g *OpenOltGroupMgr) callGroupAddRemove(ctx context.Context, group *openoltpb2.Group) error {
if err := g.performGroupOperation(ctx, group); err != nil {
st, _ := status.FromError(err)
@@ -267,7 +269,7 @@
return nil
}
-//findDiff compares group members and finds members which only exists in groups2
+// findDiff compares group members and finds members which only exists in groups2
func (g *OpenOltGroupMgr) findDiff(group1 *openoltpb2.Group, group2 *openoltpb2.Group) []*openoltpb2.GroupMember {
var members []*openoltpb2.GroupMember
for _, bucket := range group2.Members {
@@ -279,7 +281,7 @@
return members
}
-//contains returns true if the members list contains the given member; false otherwise
+// contains returns true if the members list contains the given member; false otherwise
func (g *OpenOltGroupMgr) contains(members []*openoltpb2.GroupMember, member *openoltpb2.GroupMember) bool {
for _, groupMember := range members {
if groupMember.InterfaceId == member.InterfaceId {
@@ -289,7 +291,7 @@
return false
}
-//performGroupOperation call performGroupOperation operation of openolt proto
+// performGroupOperation call performGroupOperation operation of openolt proto
func (g *OpenOltGroupMgr) performGroupOperation(ctx context.Context, group *openoltpb2.Group) error {
logger.Debugw(ctx, "sending-group-to-device",
log.Fields{
@@ -302,7 +304,7 @@
return nil
}
-//buildGroup build openoltpb2.Group from given group id and bucket list
+// buildGroup build openoltpb2.Group from given group id and bucket list
func (g *OpenOltGroupMgr) buildGroup(ctx context.Context, groupID uint32, buckets []*ofp.OfpBucket) *openoltpb2.Group {
group := openoltpb2.Group{
GroupId: groupID}
@@ -316,7 +318,7 @@
return &group
}
-//buildMember builds openoltpb2.GroupMember from an OpenFlow bucket
+// buildMember builds openoltpb2.GroupMember from an OpenFlow bucket
func (g *OpenOltGroupMgr) buildMember(ctx context.Context, ofBucket *ofp.OfpBucket) *openoltpb2.GroupMember {
var outPort uint32
outPortFound := false
diff --git a/internal/pkg/core/openolt_test.go b/internal/pkg/core/openolt_test.go
index 776fef4..cb70ea9 100644
--- a/internal/pkg/core/openolt_test.go
+++ b/internal/pkg/core/openolt_test.go
@@ -19,7 +19,7 @@
This file also implements the fields struct to mock the Openolt and few utility functions.
*/
-//Package core provides the utility for olt devices, flows and statistics
+// Package core provides the utility for olt devices, flows and statistics
package core
import (
diff --git a/internal/pkg/core/statsmanager.go b/internal/pkg/core/statsmanager.go
index eedfa19..52a86e3 100755
--- a/internal/pkg/core/statsmanager.go
+++ b/internal/pkg/core/statsmanager.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package core provides the utility for olt devices, flows and statistics
+// Package core provides the utility for olt devices, flows and statistics
package core
import (
@@ -99,8 +99,8 @@
var onuStats = make(chan *openolt.OnuStatistics, 100)
var gemStats = make(chan *openolt.GemPortStatistics, 100)
-//statRegInfo is used to register for notifications
-//on receiving port stats and flow stats indication
+// statRegInfo is used to register for notifications
+// on receiving port stats and flow stats indication
type statRegInfo struct {
chn chan bool
portNo uint32
@@ -256,7 +256,7 @@
return &NNI
}
-//StatType defines portStatsType and flowStatsType types
+// StatType defines portStatsType and flowStatsType types
type StatType int
const (
@@ -741,7 +741,7 @@
logger.Debugw(ctx, "updateGetOltPortCountersResponse", log.Fields{"resp": singleValResp})
}
-//RegisterForStatIndication registers ch as a channel on which indication is sent when statistics of type t is received
+// RegisterForStatIndication registers ch as a channel on which indication is sent when statistics of type t is received
func (StatMgr *OpenOltStatisticsMgr) RegisterForStatIndication(ctx context.Context, t StatType, ch chan bool, portNo uint32, portType extension.GetOltPortCounters_PortType) {
statInd := statRegInfo{
chn: ch,
@@ -756,7 +756,7 @@
}
-//DeRegisterFromStatIndication removes the previously registered channel ch for type t of statistics
+// DeRegisterFromStatIndication removes the previously registered channel ch for type t of statistics
func (StatMgr *OpenOltStatisticsMgr) DeRegisterFromStatIndication(ctx context.Context, t StatType, ch chan bool) {
StatMgr.statIndListnerMu.Lock()
defer StatMgr.statIndListnerMu.Unlock()
diff --git a/internal/pkg/core/statsmanager_test.go b/internal/pkg/core/statsmanager_test.go
index ab6dfd7..537b3de 100644
--- a/internal/pkg/core/statsmanager_test.go
+++ b/internal/pkg/core/statsmanager_test.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package core provides the utility for olt devices, flows and statistics
+// Package core provides the utility for olt devices, flows and statistics
package core
import (
diff --git a/internal/pkg/olterrors/olterrors.go b/internal/pkg/olterrors/olterrors.go
index 4d7aa26..8892be9 100644
--- a/internal/pkg/olterrors/olterrors.go
+++ b/internal/pkg/olterrors/olterrors.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package olterrors implements functions to manipulate OLT errors
+// Package olterrors implements functions to manipulate OLT errors
package olterrors
import (
diff --git a/internal/pkg/resourcemanager/resourcemanager.go b/internal/pkg/resourcemanager/resourcemanager.go
index 26a73ad..e3d60d9 100755
--- a/internal/pkg/resourcemanager/resourcemanager.go
+++ b/internal/pkg/resourcemanager/resourcemanager.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package resourcemanager provides the utility for managing resources
+// Package resourcemanager provides the utility for managing resources
package resourcemanager
import (
@@ -262,7 +262,7 @@
return &ResourceMgr
}
-//InitLocalCache initializes local maps used for write-through-cache
+// InitLocalCache initializes local maps used for write-through-cache
func (rsrcMgr *OpenOltResourceMgr) InitLocalCache() {
rsrcMgr.allocIDsForOnu = make(map[string][]uint32)
rsrcMgr.gemPortIDsForOnu = make(map[string][]uint32)
@@ -275,7 +275,7 @@
rsrcMgr.groupInfo = make(map[string]*GroupInfo)
}
-//LoadLocalCacheFromKVStore loads local maps
+// LoadLocalCacheFromKVStore loads local maps
func (rsrcMgr *OpenOltResourceMgr) LoadLocalCacheFromKVStore(ctx context.Context) error {
//List all the keys for OnuGemInfo
@@ -890,7 +890,7 @@
return nil
}
-//AddGemToOnuGemInfo adds gemport to onugem info kvstore and also local cache
+// AddGemToOnuGemInfo adds gemport to onugem info kvstore and also local cache
func (rsrcMgr *OpenOltResourceMgr) AddGemToOnuGemInfo(ctx context.Context, onuID uint32, gemPort uint32) error {
onugem, err := rsrcMgr.GetOnuGemInfo(ctx, onuID)
if err != nil || onugem == nil || onugem.SerialNumber == "" {
@@ -919,7 +919,7 @@
return err
}
-//RemoveGemFromOnuGemInfo removes gemport from onugem info on kvstore and also local cache
+// RemoveGemFromOnuGemInfo removes gemport from onugem info on kvstore and also local cache
func (rsrcMgr *OpenOltResourceMgr) RemoveGemFromOnuGemInfo(ctx context.Context, onuID uint32, gemPort uint32) error {
onugem, err := rsrcMgr.GetOnuGemInfo(ctx, onuID)
if err != nil || onugem == nil || onugem.SerialNumber == "" {
@@ -952,7 +952,7 @@
return nil
}
-//GetOnuGemInfo gets onu gem info from the kvstore per interface
+// GetOnuGemInfo gets onu gem info from the kvstore per interface
func (rsrcMgr *OpenOltResourceMgr) GetOnuGemInfo(ctx context.Context, onuID uint32) (*OnuGemInfo, error) {
var err error
var Val []byte
@@ -991,7 +991,7 @@
return &onugem, nil
}
-//AddNewOnuGemInfoToCacheAndKvStore function adds a new onu gem info to cache and kvstore
+// AddNewOnuGemInfoToCacheAndKvStore function adds a new onu gem info to cache and kvstore
func (rsrcMgr *OpenOltResourceMgr) AddNewOnuGemInfoToCacheAndKvStore(ctx context.Context, onuID uint32, serialNum string) error {
Path := fmt.Sprintf(OnuGemInfoPath, rsrcMgr.PonIntfID, onuID)
@@ -1064,7 +1064,7 @@
return nil
}
-//DeleteAllOnuGemInfoForIntf deletes all the all onu gem info on the given pon interface
+// DeleteAllOnuGemInfoForIntf deletes all the all onu gem info on the given pon interface
func (rsrcMgr *OpenOltResourceMgr) DeleteAllOnuGemInfoForIntf(ctx context.Context) error {
path := fmt.Sprintf(OnuGemInfoPathPathPrefix, rsrcMgr.PonIntfID)
@@ -1110,7 +1110,7 @@
}
}
-//UpdateGemPortForPktIn updates gemport for pkt in path to kvstore, path being intfid, onuid, portno, vlan id, priority bit
+// UpdateGemPortForPktIn updates gemport for pkt in path to kvstore, path being intfid, onuid, portno, vlan id, priority bit
func (rsrcMgr *OpenOltResourceMgr) UpdateGemPortForPktIn(ctx context.Context, pktIn PacketInInfoKey, gemPort uint32) {
path := fmt.Sprintf(OnuPacketInPath, pktIn.IntfID, pktIn.OnuID, pktIn.LogicalPort, pktIn.VlanID, pktIn.Priority)
@@ -1174,7 +1174,7 @@
return gemPort, nil
}
-//DeletePacketInGemPortForOnu deletes the packet-in gemport for ONU
+// DeletePacketInGemPortForOnu deletes the packet-in gemport for ONU
func (rsrcMgr *OpenOltResourceMgr) DeletePacketInGemPortForOnu(ctx context.Context, onuID uint32, logicalPort uint32) error {
path := fmt.Sprintf(OnuPacketInPathPrefix, rsrcMgr.PonIntfID, onuID, logicalPort)
value, err := rsrcMgr.KVStore.List(ctx, path)
@@ -1207,7 +1207,7 @@
return nil
}
-//GetFlowIDsForGem gets the list of FlowIDs for the given gemport
+// GetFlowIDsForGem gets the list of FlowIDs for the given gemport
func (rsrcMgr *OpenOltResourceMgr) GetFlowIDsForGem(ctx context.Context, gem uint32) ([]uint64, error) {
path := fmt.Sprintf(FlowIDsForGem, rsrcMgr.PonIntfID, gem)
@@ -1272,7 +1272,7 @@
return rsrcMgr.UpdateFlowIDsForGem(ctx, gemPortID, flowIDs)
}
-//UpdateFlowIDsForGem updates flow id per gemport
+// UpdateFlowIDsForGem updates flow id per gemport
func (rsrcMgr *OpenOltResourceMgr) UpdateFlowIDsForGem(ctx context.Context, gem uint32, flowIDs []uint64) error {
var val []byte
path := fmt.Sprintf(FlowIDsForGem, rsrcMgr.PonIntfID, gem)
@@ -1302,7 +1302,7 @@
return nil
}
-//DeleteFlowIDsForGem deletes the flowID list entry per gem from kvstore.
+// DeleteFlowIDsForGem deletes the flowID list entry per gem from kvstore.
func (rsrcMgr *OpenOltResourceMgr) DeleteFlowIDsForGem(ctx context.Context, gem uint32) error {
path := fmt.Sprintf(FlowIDsForGem, rsrcMgr.PonIntfID, gem)
if err := rsrcMgr.KVStore.Delete(ctx, path); err != nil {
@@ -1316,7 +1316,7 @@
return nil
}
-//DeleteAllFlowIDsForGemForIntf deletes all the flow ids associated for all the gems on the given pon interface
+// DeleteAllFlowIDsForGemForIntf deletes all the flow ids associated for all the gems on the given pon interface
func (rsrcMgr *OpenOltResourceMgr) DeleteAllFlowIDsForGemForIntf(ctx context.Context) error {
path := fmt.Sprintf(FlowIDsForGemPathPrefix, rsrcMgr.PonIntfID)
@@ -1333,7 +1333,7 @@
return nil
}
-//GetMcastQueuePerInterfaceMap gets multicast queue info per pon interface
+// GetMcastQueuePerInterfaceMap gets multicast queue info per pon interface
func (rsrcMgr *OpenOltResourceMgr) GetMcastQueuePerInterfaceMap(ctx context.Context) (map[uint32][]uint32, error) {
path := McastQueuesForIntf
var val []byte
@@ -1366,7 +1366,7 @@
return rsrcMgr.mcastQueueForIntf, nil
}
-//AddMcastQueueForIntf adds multicast queue for pon interface
+// AddMcastQueueForIntf adds multicast queue for pon interface
func (rsrcMgr *OpenOltResourceMgr) AddMcastQueueForIntf(ctx context.Context, gem uint32, servicePriority uint32) error {
var val []byte
path := McastQueuesForIntf
@@ -1403,7 +1403,7 @@
return nil
}
-//DeleteMcastQueueForIntf deletes multicast queue info for the current pon interface from kvstore
+// DeleteMcastQueueForIntf deletes multicast queue info for the current pon interface from kvstore
func (rsrcMgr *OpenOltResourceMgr) DeleteMcastQueueForIntf(ctx context.Context) error {
path := McastQueuesForIntf
@@ -1415,7 +1415,7 @@
return nil
}
-//AddFlowGroupToKVStore adds flow group into KV store
+// AddFlowGroupToKVStore adds flow group into KV store
func (rsrcMgr *OpenOltResourceMgr) AddFlowGroupToKVStore(ctx context.Context, groupEntry *ofp.OfpGroupEntry, cached bool) error {
var Value []byte
var err error
@@ -1458,7 +1458,7 @@
return nil
}
-//RemoveFlowGroupFromKVStore removes flow group from KV store
+// RemoveFlowGroupFromKVStore removes flow group from KV store
func (rsrcMgr *OpenOltResourceMgr) RemoveFlowGroupFromKVStore(ctx context.Context, groupID uint32, cached bool) error {
var path string
if cached {
@@ -1479,8 +1479,8 @@
return nil
}
-//GetFlowGroupFromKVStore fetches flow group from the KV store. Returns (false, {} error) if any problem occurs during
-//fetching the data. Returns (true, groupInfo, nil) if the group is fetched successfully.
+// GetFlowGroupFromKVStore fetches flow group from the KV store. Returns (false, {} error) if any problem occurs during
+// fetching the data. Returns (true, groupInfo, nil) if the group is fetched successfully.
// Returns (false, {}, nil) if the group does not exists in the KV store.
func (rsrcMgr *OpenOltResourceMgr) GetFlowGroupFromKVStore(ctx context.Context, groupID uint32, cached bool) (bool, GroupInfo, error) {
var groupInfo GroupInfo
diff --git a/internal/pkg/resourcemanager/resourcemanager_test.go b/internal/pkg/resourcemanager/resourcemanager_test.go
index b1ba8ef..215933e 100644
--- a/internal/pkg/resourcemanager/resourcemanager_test.go
+++ b/internal/pkg/resourcemanager/resourcemanager_test.go
@@ -20,7 +20,7 @@
and few utility functions.
*/
-//Package adaptercore provides the utility for olt devices, flows and statistics
+// Package adaptercore provides the utility for olt devices, flows and statistics
package resourcemanager
import (
diff --git a/makefiles/consts.mk b/makefiles/consts.mk
index f61d341..8961b3a 100644
--- a/makefiles/consts.mk
+++ b/makefiles/consts.mk
@@ -1,6 +1,6 @@
# -*- makefile -*-
# -----------------------------------------------------------------------
-# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors (ONF) and the ONF Contributors
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -14,18 +14,50 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-# SPDX-FileCopyrightText: 2022 Open Networking Foundation (ONF) and the ONF Contributors
+# SPDX-FileCopyrightText: 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
# SPDX-License-Identifier: Apache-2.0
# -----------------------------------------------------------------------
+# https://gerrit.opencord.org/plugins/gitiles/onf-make
+# ONF.makefile.version = 1.0
+# -----------------------------------------------------------------------
-null :=#
-space := $(null) $(null)
-dot ?= .
+$(if $(DEBUG),$(warning ENTER))
-HIDE ?= @
-SHELL := bash -e -o pipefail
+# include makefiles/constants.mk
+export dot :=.
+export null :=#
+export space := $(null) $(null)
+export quote-single := $(null)'$(null)#'
+export quote-double := $(null)"$(null)#"
-env-clean = /usr/bin/env --ignore-environment
+# [DEBUG] make {target} HIDE=
+HIDE ?= @
+env-clean ?= /usr/bin/env --ignore-environment
+xargs-n1 := xargs -0 -t -n1 --no-run-if-empty
+xargs-n1-clean := $(env-clean) $(xargs-n1)
+
+## -----------------------------------------------------------------------
+## Intent: NOP command for targets whose dependencies do all heavy lifting
+## -----------------------------------------------------------------------
+## usage: foo bar tans
+## <tab>$(nop-command)
+## -----------------------------------------------------------------------
+nop-cmd := :
+
+## -----------------------------------------------------------------------
+## Default shell:
+## o set -e enable error checking
+## o set -u report undefined errors
+## o set -o pipefail propogate shell pipeline failures.
+## -----------------------------------------------------------------------
+SHELL ?= /bin/bash
+have-shell-bash := $(filter bash,$(subst /,$(space),$(SHELL)))
+$(if $(have-shell-bash),$(null),\
+ $(eval export SHELL := bash -euo pipefail))
+
+export SHELL ?= bash -euo pipefail
+
+$(if $(DEBUG),$(warning LEAVE))
# [EOF]
diff --git a/makefiles/docker/include.mk b/makefiles/docker/include.mk
new file mode 100644
index 0000000..6562631
--- /dev/null
+++ b/makefiles/docker/include.mk
@@ -0,0 +1,88 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# 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.d
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+VOLTHA_TOOLS_VERSION ?= 2.4.0
+
+# ---------------------------
+# Macros: command refactoring
+# ---------------------------
+docker-iam ?= --user $$(id -u):$$(id -g)# # override for local use
+docker-run = docker run --rm $(docker-iam)# # Docker command stem
+docker-run-is = $(docker-run) $(is-stdin)# # Attach streams when interactive
+docker-run-app = $(docker-run-is) -v ${CURDIR}:/app# # w/filesystem mount
+
+# -----------------------------------------------------------------------
+# --interactive: Attach streams when stdout (fh==0) defined
+# --tty : Always create a pseudo-tty else jenkins:docker is silent
+# -----------------------------------------------------------------------
+is-stdin = $(shell test -t 0 && { echo '--interactive'; })
+is-stdin += --tty
+
+voltha-protos-v5 ?= /go/src/github.com/opencord/voltha-protos/v5
+
+# Docker volume mounts: container:/app/release <=> localhost:{pwd}/release
+vee-golang = -v gocache-${VOLTHA_TOOLS_VERSION}:/go/pkg
+vee-citools = voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}
+
+# ---------------
+# Tool Containers
+# ---------------
+docker-go-stem = $(docker-run-app) -v gocache:/.cache $(vee-golang) $(vee-citools)-golang
+
+# Usage: GO := $(call get-docker-go,./my.env.temp)
+get-docker-go = $(docker-go-stem) go
+GO ?= $(call get-docker-go)
+
+# Usage: GO_SH := $(call get-docker-go-sh,./my.env.temp)
+get-docker-go-sh = $(docker-go-stem) $(if $(1),--env-file $(1)) sh -c
+GO_SH ?= $(call get-docker-go-sh,./my.env.temp)
+
+# Usage: PROTOC := $(call get-docker-protoc)
+get-docker-protoc = $(docker-run-app) $(vee-citools)-protoc protoc
+PROTOC ?= $(call get-docker-protoc)
+
+# get-docker-protoc-sh = $(strip )
+PROTOC_SH = $(docker-run-is)
+ifdef voltha-protos-v5
+ PROTOC_SH += -v ${CURDIR}:$(voltha-protos-v5)
+ PROTOC_SH += --workdir=$(voltha-protos-v5)
+endif
+PROTOC_SH += $(vee-citools)-protoc sh -c
+
+# Usage: GO_JUNIT_REPORT := $(call get-docker-go-junit-repo)
+# get-docker-go-junit-repo = $(docker-run-app) $(vee-citools)-go-junit-report go-junit-report
+# GO_JUNIT_REPORT ?= $(call get-docker-go-junit-repo)
+
+# Usage: GOCOVER_COBERTURA := $(call get-docker-gocover-cobertura)
+# get-docker-gocover-cobertura = $(docker-run-app)/src/github.com/opencord/voltha-openolt-adapter $(vee-citools)-gocover-cobertura gocover-cobertura
+# GOCOVER_COBERTURA ?= $(call get-docker-gocover-cobertura)
+
+GO_JUNIT_REPORT = $(docker-run) -v ${CURDIR}:/app -i $(vee-citools)-go-junit-report go-junit-report
+GOCOVER_COBERTURA = $(docker-run) -v ${CURDIR}:/app/src/github.com/opencord/voltha-openolt-adapter -i $(vee-citools)-gocover-cobertura gocover-cobertura
+
+
+get-golangci-lint = $(docker-run-app) -v gocache:/.cache $(vee-golang) $(vee-citools)-golangci-lint golangci-lint
+GOLANGCI_LINT ?= $(call get-golangci-lint)
+
+get-docker-hadolint = $(docker-run-app) $(vee-citools)-hadolint hadolint
+HADOLINT ?= $(call get-docker-hadolint)
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/etc/include.mk b/makefiles/etc/include.mk
new file mode 100644
index 0000000..7d95190
--- /dev/null
+++ b/makefiles/etc/include.mk
@@ -0,0 +1,54 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2017-2023 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.
+#
+# SPDX-FileCopyrightText: 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+# Usage:
+#
+# mytarget:
+# $(call banner-enter,target $@)
+# @echo "Hello World"
+# $(call banner-leave,target $@)
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+target-banner = ** ---------------------------------------------------------------------------
+
+## -----------------------------------------------------------------------
+## Intent: Return a command line able to display a banner hilighting
+## make target processing within a logfile.
+## -----------------------------------------------------------------------
+banner-enter=\
+ @echo -e \
+ "\n"\
+ "$(target-banner)\n"\
+ "** $(MAKE) ENTER: $(1)\n"\
+ "$(target-banner)"\
+
+banner=\
+ @echo -e \
+ "\n"\
+ "** $(1)\n"\
+ "$(target-banner)"\
+
+banner-leave=\
+ @echo -e "** $(MAKE) LEAVE: $(1)"
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/include.mk b/makefiles/include.mk
index 5d9a2d9..f7bb20d 100644
--- a/makefiles/include.mk
+++ b/makefiles/include.mk
@@ -1,6 +1,6 @@
# -*- makefile -*-
# -----------------------------------------------------------------------
-# Copyright 2017-2023 Open Networking Foundation
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -14,19 +14,66 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-# SPDX-FileCopyrightText: 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors
+# SPDX-FileCopyrightText: 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
# SPDX-License-Identifier: Apache-2.0
# -----------------------------------------------------------------------
+# https://gerrit.opencord.org/plugins/gitiles/onf-make
+# ONF.makefile.version = 1.0
+# -----------------------------------------------------------------------
+
+ifndef mk-include--onf-make # single-include guard macor
$(if $(DEBUG),$(warning ENTER))
-MAKEDIR ?= $(error MAKEDIR= is required)
+## -----------------------------------------------------------------------
+## Define vars based on relative import (normalize symlinks)
+## Usage: include makefiles/onf/include.mk
+## -----------------------------------------------------------------------
+onf-mk-abs ?= $(abspath $(lastword $(MAKEFILE_LIST)))
+onf-mk-top := $(subst /include.mk,$(null),$(onf-mk-abs))
+ONF_MAKEDIR := $(onf-mk-top)
-include $(MAKEDIR)/consts.mk
-include $(MAKEDIR)/help.mk
-include $(MAKEDIR)/todo.mk
-include $(MAKEDIR)/lint/include.mk
+include $(ONF_MAKEDIR)/consts.mk
+include $(ONF_MAKEDIR)/help.mk
+# include $(ONF_MAKEDIR)/help/include.mk # render target help
+# include $(ONF_MAKEDIR)/utils/include.mk # dependency-less helper macros
+include $(ONF_MAKEDIR)/etc/include.mk # banner macros
+
+# include $(ONF_MAKEDIR)/etc/commands.mk # Tools and local installers
+
+include $(ONF_MAKEDIR)/virtualenv.mk# # lint-{jjb,python} depends on venv
+# include $(ONF_MAKEDIR)/lint/include.mk
+# include $(ONF_MAKEDIR)/git-submodules.mk
+# include $(ONF_MAKEDIR)/gerrit/include.mk
+
+include $(ONF_MAKEDIR)/todo.mk
+# include $(ONF_MAKEDIR)/help/variables.mk
+
+##---------------------##
+##---] ON_DEMAND [---##
+##---------------------##
+$(if $(USE_DOCKER_MK),$(eval include $(ONF_MAKEDIR)/docker/include.mk))
+
+##-------------------##
+##---] TARGETS [---##
+##-------------------##
+include $(ONF_MAKEDIR)/targets/clean.mk
+# include $(ONF_MAKEDIR)/targets/check.mk
+include $(ONF_MAKEDIR)/targets/sterile.mk
+# include $(ONF_MAKEDIR)/targets/test.mk
$(if $(DEBUG),$(warning LEAVE))
+## --------------------------------------------------------------------------
+## structure to support pre/post target handling w/o inlining in Makefile (?)
+## --------------------------------------------------------------------------
+## include makefiles/include.mk
+## include makefiles/main/enter.mk
+## [... include *.mk ...]
+## include makefiles/main/leave.mk
+
+mk-include--onf-make := true
+
+endif # mk-include--onf-make
+
# [EOF]
diff --git a/makefiles/targets/check.mk b/makefiles/targets/check.mk
new file mode 100644
index 0000000..aa1b0d0
--- /dev/null
+++ b/makefiles/targets/check.mk
@@ -0,0 +1,38 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# 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.
+#
+# SPDX-FileCopyrightText: 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+.PHONY: check
+check : lint lint-yaml lint-jjb
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+help-verbose += help-check
+help-check ::
+ @echo
+ @echo '[MAKE: check]'
+ @echo ' check pre-commit checking, with extra targets (default:NO, jenkins:FAIL)'
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/targets/clean.mk b/makefiles/targets/clean.mk
new file mode 100644
index 0000000..f787e5c
--- /dev/null
+++ b/makefiles/targets/clean.mk
@@ -0,0 +1,40 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# 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.
+#
+# SPDX-FileCopyrightText: 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+## -----------------------------------------------------------------------
+## Intent: Remove makefile generated content
+## -----------------------------------------------------------------------
+.PHONY: clean
+clean ::
+ $(RM) -r $(JOBCONFIG_DIR)
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+help-verbose += help-clean
+help-clean ::
+ @echo
+ @echo '[MAKE: clean]'
+ @echo ' clean Remove makefile generated content'
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/targets/sterile.mk b/makefiles/targets/sterile.mk
new file mode 100644
index 0000000..c661f53
--- /dev/null
+++ b/makefiles/targets/sterile.mk
@@ -0,0 +1,45 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# 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.
+#
+# SPDX-FileCopyrightText: 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+## -----------------------------------------------------------------------
+## Intent: Revert sandbox into a pristine checkout stage
+## -----------------------------------------------------------------------
+## Note: Sterile target behavior differs from clean around handling of
+## persistent content. For ex removal of a python virtualenv adds
+## extra overhead to development iteration:
+## make clean - preserve a virtual env
+## make sterile - force reinstallation
+## -----------------------------------------------------------------------
+.PHONY: sterile
+sterile :: clean
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+help-verbose += help-sterile
+help-sterile ::
+ @echo
+ @echo '[MAKE: sterile]'
+ @echo ' sterile make clean, also remove persistent content (~venv)'
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/targets/test.mk b/makefiles/targets/test.mk
new file mode 100644
index 0000000..2f68086
--- /dev/null
+++ b/makefiles/targets/test.mk
@@ -0,0 +1,41 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# 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.
+#
+# SPDX-FileCopyrightText: 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+.PHONY: test
+test: $(venv-activate-script) $(JOBCONFIG_DIR)
+ $(activate) \
+ && pipdeptree \
+ && jenkins-jobs -l DEBUG test --recursive --config-xml -o "$(JOBCONFIG_DIR)" jjb/ ;
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+help-verbose += help-test
+help-test ::
+ @echo
+ @echo '[MAKE: test]'
+ @echo ' test Perform testing that a jenkins job pull request will invoke'
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/targets/tox.mk b/makefiles/targets/tox.mk
new file mode 100644
index 0000000..44da921
--- /dev/null
+++ b/makefiles/targets/tox.mk
@@ -0,0 +1,41 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# 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.
+#
+# SPDX-FileCopyrightText: 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+## -----------------------------------------------------------------------
+## Intent: Sanity check incoming JJB config changes.
+## Todo: Depend on makefiles/lint/jjb.mk :: lint-jjb
+## -----------------------------------------------------------------------
+# lint : lint-jjb
+lint-tox: lint-jjb
+ tox -e py310
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+help-verbose += help-tox
+help-tox ::
+ @echo
+ @echo '[MAKE: tox]'
+ @echo ' lint-tox Python unit testing, sanity check incoming JJB changes.'
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/virtualenv.mk b/makefiles/virtualenv.mk
new file mode 100644
index 0000000..c6904da
--- /dev/null
+++ b/makefiles/virtualenv.mk
@@ -0,0 +1,82 @@
+# -*- makefile -*-
+## -----------------------------------------------------------------------
+# Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# 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.
+# -----------------------------------------------------------------------
+# https://gerrit.opencord.org/plugins/gitiles/onf-make
+# ONF.makefile.version = 1.0
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+##-------------------##
+##---] GLOBALS [---##
+##-------------------##
+.PHONY: venv
+
+##------------------##
+##---] LOCALS [---##
+##------------------##
+venv-name ?= .venv# # default install directory
+venv-abs-path := $(PWD)/$(venv-name)
+
+venv-activate-script := $(venv-name)/bin/activate# # dependency
+
+# Intent: activate= is a macro for accessing the virtualenv activation script#
+# Usage: $(activate) && python
+activate ?= set +u && source $(venv-activate-script) && set -u
+
+## -----------------------------------------------------------------------
+## Intent: Activate script path dependency
+## Usage:
+## o place on the right side of colon as a target dependency
+## o When the script does not exist install the virtual env and display.
+## -----------------------------------------------------------------------
+$(venv-activate-script):
+ @echo
+ @echo "============================="
+ @echo "Installing python virtual env"
+ @echo "============================="
+ virtualenv -p python3 $(venv-name)
+ $(activate) && python -m pip install --upgrade pip
+ $(activate) && pip install --upgrade setuptools
+ $(activate) && { [[ -r requirements.txt ]] && python -m pip install -r requirements.txt; }
+ $(activate) && python --version
+
+## -----------------------------------------------------------------------
+## Intent: Explicit named installer target w/o dependencies.
+## Makefile targets should depend on venv-activate-script.
+## -----------------------------------------------------------------------
+venv: $(venv-activate-script)
+
+## -----------------------------------------------------------------------
+## Intent: Revert installation to a clean checkout
+## -----------------------------------------------------------------------
+sterile :: clean
+ $(RM) -r "$(venv-abs-path)"
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+help ::
+ @echo
+ @echo '[VIRTUAL ENV]'
+ @echo ' venv Create a python virtual environment'
+ @echo ' venv-name= Subdir name for virtualenv install'
+ @echo ' venv-activate-script make macro name'
+ @echo ' $$(target) dependency install python virtualenv'
+ @echo ' source $$(macro) && cmd configure env and run cmd'
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/pkg/mocks/mockCoreClient.go b/pkg/mocks/mockCoreClient.go
index bb1acc2..5926d7a 100644
--- a/pkg/mocks/mockCoreClient.go
+++ b/pkg/mocks/mockCoreClient.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package mocks provides the mocks for openolt-adapter.
+// Package mocks provides the mocks for openolt-adapter.
package mocks
import (
diff --git a/pkg/mocks/mockEventproxy.go b/pkg/mocks/mockEventproxy.go
index 0b9bb13..f33fa5d 100644
--- a/pkg/mocks/mockEventproxy.go
+++ b/pkg/mocks/mockEventproxy.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package mocks provides the mocks for openolt-adapter.
+// Package mocks provides the mocks for openolt-adapter.
package mocks
import (
@@ -75,7 +75,7 @@
func (me *MockEventProxy) Stop() {
}
-//SendDeviceEventWithKey mocks SendDeviceEventWithKey
+// SendDeviceEventWithKey mocks SendDeviceEventWithKey
func (me *MockEventProxy) SendDeviceEventWithKey(ctx context.Context, deviceEvent *voltha.DeviceEvent, category eventif.EventCategory,
subCategory eventif.EventSubCategory, raisedTs int64, key string) error {
return nil
diff --git a/pkg/mocks/mockKVClient.go b/pkg/mocks/mockKVClient.go
index be8ab57..d42f0b1 100644
--- a/pkg/mocks/mockKVClient.go
+++ b/pkg/mocks/mockKVClient.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package mocks provides the mocks for openolt-adapter.
+// Package mocks provides the mocks for openolt-adapter.
package mocks
import (
@@ -202,7 +202,7 @@
return nil, errors.New("key didn't find")
}
-//getPacketInGemPort returns the GEM port associated with the given key
+// getPacketInGemPort returns the GEM port associated with the given key
func getPacketInGemPort(key string) (*kvstore.KVPair, error) {
//parse interface, onu, uni, vlan, priority values
arr := getParamsFromPacketInKey(key)
@@ -225,7 +225,7 @@
return nil, errors.New("key didn't find")
}
-//getParamsFromPacketInKey parse packetIn key that is in the format of "onu_packetin/{1,1,1,1,2}"
+// getParamsFromPacketInKey parse packetIn key that is in the format of "onu_packetin/{1,1,1,1,2}"
func getParamsFromPacketInKey(key string) []string {
//return intfID, onuID, uniID, vlanID, priority
firstIndex := strings.Index(key, "{")
diff --git a/pkg/mocks/mockOnuInterAdapterClient.go b/pkg/mocks/mockOnuInterAdapterClient.go
index 8e1b618..3c14244 100644
--- a/pkg/mocks/mockOnuInterAdapterClient.go
+++ b/pkg/mocks/mockOnuInterAdapterClient.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package mocks provides the mocks for openolt-adapter.
+// Package mocks provides the mocks for openolt-adapter.
package mocks
import (
diff --git a/pkg/mocks/mockTechprofile.go b/pkg/mocks/mockTechprofile.go
index 5234de5..25d0fc6 100644
--- a/pkg/mocks/mockTechprofile.go
+++ b/pkg/mocks/mockTechprofile.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-//Package mocks provides the mocks for openolt-adapter.
+// Package mocks provides the mocks for openolt-adapter.
package mocks
import (