MCPcopy
hub / github.com/microsoft/retina / main

Function main

test/plugin/packetforward/main_linux.go:21–76  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19)
20
21func main() {
22 log.SetupZapLogger(log.GetDefaultLogOpts())
23 l := log.Logger().Named("test-packetforward")
24
25 metrics.InitializeMetrics(slog.Default())
26
27 ctx := context.Background()
28
29 cfg := &kcfg.Config{
30 MetricsInterval: 1 * time.Second,
31 EnablePodLevel: true,
32 }
33 tt := packetforward.New(cfg)
34
35 err := tt.Stop()
36 if err != nil {
37 l.Error("Failed to stop packetforward plugin", zap.Error(err))
38 return
39 }
40
41 ctxTimeout, cancel := context.WithTimeout(ctx, time.Second*10)
42 defer cancel()
43 err = tt.Generate(ctxTimeout)
44 if err != nil {
45 l.Error("Failed to generate the plugin specific header files", zap.Error(err))
46 return
47 }
48
49 err = tt.Compile(ctxTimeout)
50 if err != nil {
51 l.Error("Failed to compile the ebpf to generate bpf object", zap.Error(err))
52 return
53 }
54
55 err = tt.Init()
56 if err != nil {
57 l.Error("Failed to initialize plugin specific objects", zap.Error(err))
58 return
59 }
60
61 err = tt.Start(ctx)
62 if err != nil {
63 l.Error("Failed to start packetforward plugin", zap.Error(err))
64 return
65 }
66 l.Info("Started packetforward")
67
68 defer func() {
69 if err := tt.Stop(); err != nil {
70 l.Error("Failed to stop packetforward plugin", zap.Error(err))
71 }
72 }()
73
74 for range ctx.Done() {
75 }
76}

Callers

nothing calls this directly

Calls 13

SetupZapLoggerFunction · 0.92
GetDefaultLogOptsFunction · 0.92
LoggerFunction · 0.92
InitializeMetricsFunction · 0.92
NewFunction · 0.92
NamedMethod · 0.80
InfoMethod · 0.80
StopMethod · 0.65
GenerateMethod · 0.65
CompileMethod · 0.65
InitMethod · 0.65
StartMethod · 0.65

Tested by

no test coverage detected