()
| 19 | ) |
| 20 | |
| 21 | func 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 | } |
nothing calls this directly
no test coverage detected