diff --git a/go.yml b/.github/workflows/go.yml similarity index 60% rename from go.yml rename to .github/workflows/go.yml index 3ab87a9..ff05a81 100644 --- a/go.yml +++ b/.github/workflows/go.yml @@ -10,3 +10,7 @@ on: jobs: go: uses: openconfig/common-ci/.github/workflows/basic_go.yml@125b6b58286d116b216e45c33cb859f547965d61 + with: + tests-excludes-regex: integration + race-tests-excludes-regex: integration + coverage-excludes-regex: integration diff --git a/gnmi/gnmi.go b/gnmi/gnmi.go index 552c911..3f49051 100644 --- a/gnmi/gnmi.go +++ b/gnmi/gnmi.go @@ -24,7 +24,6 @@ import ( ompb "go.opentelemetry.io/proto/otlp/metrics/v1" anypb "google.golang.org/protobuf/types/known/anypb" - "github.com/golang/protobuf/proto" "github.com/openconfig/magna/lwotgtelem" "github.com/openconfig/magna/lwotgtelem/gnmit" "go.opentelemetry.io/collector/component" @@ -33,6 +32,7 @@ import ( "go.uber.org/zap" "google.golang.org/grpc" "google.golang.org/grpc/reflection" + "google.golang.org/protobuf/proto" "k8s.io/klog/v2" ) @@ -53,7 +53,7 @@ func NewGNMIExporter(logger *zap.Logger, cfg *Config) (*GNMI, error) { return nil, err } - gnmiLis, err := net.Listen("tcp", fmt.Sprintf("%s", cfg.Addr)) + gnmiLis, err := net.Listen("tcp", cfg.Addr) if err != nil { klog.Exitf("cannot listen on %s, err: %v", cfg.Addr, err) } diff --git a/gnmi/gnmi_test.go b/gnmi/gnmi_test.go index 223a447..4ce6f0a 100644 --- a/gnmi/gnmi_test.go +++ b/gnmi/gnmi_test.go @@ -16,6 +16,7 @@ package gnmi import ( "context" + "sync" "testing" "time" @@ -73,7 +74,10 @@ func TestHandleMetrics(t *testing.T) { } n := &gpb.Notification{} + var nMu sync.Mutex updateFn := func(notif *gpb.Notification) error { + nMu.Lock() + defer nMu.Unlock() n.Update = append(n.Update, notif.Update...) return nil } @@ -86,6 +90,8 @@ func TestHandleMetrics(t *testing.T) { close(g.metricCh) time.Sleep(time.Second) + nMu.Lock() + defer nMu.Unlock() if len(n.Update) != tc.wantCnt { t.Errorf("missing updates: want %d got %d", tc.wantCnt, len(n.Update)) } diff --git a/gnmipath/pather_test.go b/gnmipath/pather_test.go index c7c90b1..60469a6 100644 --- a/gnmipath/pather_test.go +++ b/gnmipath/pather_test.go @@ -101,19 +101,5 @@ func metricName(t *testing.T, ms pmetric.Metrics) string { t.Helper() rms := ms.ResourceMetrics() - for i := 0; i < rms.Len(); i++ { - rm := rms.At(i) - ilms := rm.ScopeMetrics() - for j := 0; j < ilms.Len(); j++ { - ilm := ilms.At(j) - ms := ilm.Metrics() - for k := 0; k < ms.Len(); k++ { - m := ms.At(k) - return m.Name() - } - } - } - - t.Error("metric has no name") - return "" + return rms.At(0).ScopeMetrics().At(0).Metrics().At(0).Name() } diff --git a/go.mod b/go.mod index ea158f3..cdfde5e 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module github.com/openconfig/clio go 1.22 require ( - github.com/golang/protobuf v1.5.4 github.com/google/go-cmp v0.6.0 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/dockerstatsreceiver v0.102.0 github.com/openconfig/gnmi v0.11.0 diff --git a/go.sum b/go.sum index b9b8769..3c9e039 100644 --- a/go.sum +++ b/go.sum @@ -1521,7 +1521,6 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= diff --git a/integration/docker_stats_e2e/docker_stats_e2e_test.go b/integration/docker_stats_e2e/docker_stats_e2e_test.go index 39d053b..de1b850 100644 --- a/integration/docker_stats_e2e/docker_stats_e2e_test.go +++ b/integration/docker_stats_e2e/docker_stats_e2e_test.go @@ -80,7 +80,7 @@ func startCollectorPipeline(t *testing.T, ctx context.Context) (*sync.WaitGroup, go func() { defer wg.Done() if err := col.Run(ctx); err != nil { - t.Fatalf("%v", err) + t.Errorf("%v", err) } }() return wg, col @@ -134,9 +134,7 @@ func validateNotifications(t *testing.T, gotNoti []*gpb.Notification) { for _, n := range gotNoti { for _, u := range n.GetUpdate() { path := elems2path(u.GetPath().GetElem()) - if _, ok := wantPathSet[path]; ok { - delete(wantPathSet, path) - } + delete(wantPathSet, path) } } diff --git a/integration/oltp_e2e/e2e_test.go b/integration/oltp_e2e/e2e_test.go index a0d9ca5..5164869 100644 --- a/integration/oltp_e2e/e2e_test.go +++ b/integration/oltp_e2e/e2e_test.go @@ -87,7 +87,7 @@ func startCollectorPipeline(t *testing.T, ctx context.Context) (*sync.WaitGroup, go func() { defer wg.Done() if err := col.Run(ctx); err != nil { - t.Fatalf("%v", err) + t.Errorf("%v", err) } }() return wg, col diff --git a/linter.yml b/linter.yml deleted file mode 100644 index 2320d40..0000000 --- a/linter.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Lint Code Base - -on: - push: - branches-ignore: [main] - # Remove the line above to run when pushing to master - pull_request: - branches: [main] - -jobs: - build: - name: Lint Code Base - runs-on: ubuntu-latest - - steps: - - name: Checkout Code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Lint protobuf - uses: plexsystems/protolint-action@v0.7.0 - with: - configDirectory: .github