Skip to content

Commit

Permalink
fix: Start E2E montitioning controllers at the start of the test suite (
Browse files Browse the repository at this point in the history
  • Loading branch information
engedaam authored Jan 17, 2025
1 parent 93ddb70 commit ff44f73
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
18 changes: 13 additions & 5 deletions test/pkg/debug/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,29 @@ const (
var m *Monitor
var e *EventClient

func BeforeSuite(ctx context.Context, config *rest.Config, kubeClient client.Client) {
m = New(ctx, config, kubeClient)
m.MustStart()
}

func AfterSuite(ctx context.Context, config *rest.Config, kubeClient client.Client) {
m.Stop()
}

func BeforeEach(ctx context.Context, config *rest.Config, kubeClient client.Client) {
// If the test is labeled as NoWatch, then the node/pod monitor will just list at the beginning
// of the test rather than perform a watch during it
if !lo.Contains(ginkgo.CurrentSpecReport().Labels(), NoWatch) {
m = New(ctx, config, kubeClient)
m.MustStart()
if lo.Contains(ginkgo.CurrentSpecReport().Labels(), NoWatch) {
m.Stop()
}
if !lo.Contains(ginkgo.CurrentSpecReport().Labels(), NoEvents) {
e = NewEventClient(kubeClient)
}
}

func AfterEach(ctx context.Context) {
if !lo.Contains(ginkgo.CurrentSpecReport().Labels(), NoWatch) {
m.Stop()
if lo.Contains(ginkgo.CurrentSpecReport().Labels(), NoWatch) {
m.MustStart()
}
if !lo.Contains(ginkgo.CurrentSpecReport().Labels(), NoEvents) {
Expect(e.DumpEvents(ctx)).To(Succeed())
Expand Down
2 changes: 2 additions & 0 deletions test/suites/perf/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ func TestPerf(t *testing.T) {
RegisterFailHandler(Fail)
BeforeSuite(func() {
env = common.NewEnvironment(t)
debug.BeforeSuite(env.Context, env.Config, env.Client)
})
AfterSuite(func() {
// Write out the timestamps from our tests
if err := debug.WriteTimestamps(env.OutputDir, env.TimeIntervalCollector); err != nil {
log.FromContext(env).Info(fmt.Sprintf("Failed to write timestamps to files, %s", err))
}
debug.AfterSuite(env.Context, env.Config, env.Client)
env.Stop()
})
RunSpecs(t, "Perf")
Expand Down

0 comments on commit ff44f73

Please sign in to comment.