Skip to content

Commit

Permalink
pktmon testing
Browse files Browse the repository at this point in the history
  • Loading branch information
matmerr committed Jan 23, 2025
1 parent 7673d81 commit c6ffaa2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/plugin/pktmon/pktmon_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"go.uber.org/zap/zapio"
"golang.org/x/sync/errgroup"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/status"
)
Expand Down Expand Up @@ -161,11 +162,15 @@ func (p *Plugin) Start(ctx context.Context) error {
g.Go(func() error {
for {
err := p.GetFlow(ctx)
if _, ok := status.FromError(err); ok {
if stat, ok := status.FromError(err); ok {
if stat.Code() == codes.Internal {
p.l.Error("failed to get flow, retriable:", zap.Error(err))
}
p.l.Error("failed to get flow, retriable:", zap.Error(err))
continue
} else {
return errors.Wrapf(err, "failed to get flow")
}
return errors.Wrapf(err, "failed to get flow, unrecoverable")
}
})

Expand Down
22 changes: 22 additions & 0 deletions pkg/plugin/pktmon/pktmon_windows_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package pktmon

import (
"context"
"testing"

"github.com/microsoft/retina/pkg/config"
)

func TestStart(t *testing.T) {
// TestStart tests the Start function.
t.Run("TestStart", func(t *testing.T) {
// Create a new Plugin.
p := New(&config.Config{})
// Start the Plugin.
err := p.Start(context.Background())
// Check if the error is nil.
if err != nil {
t.Errorf("got %v, want nil", err)
}
})
}

0 comments on commit c6ffaa2

Please sign in to comment.