Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.4.x]: fix(e2e): Get the most recent pod in e2e tests and add logs #5841

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e/common/misc/files/cron-yaml.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
- from:
uri: "cron:tab"
parameters:
schedule: "* * * * ?"
schedule: "*/2 * * * ?"
steps:
- setHeader:
name: "m"
Expand Down
5 changes: 5 additions & 0 deletions e2e/support/test_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"reflect"
"regexp"
"runtime/debug"
"sort"
"strings"
"sync"
"testing"
Expand Down Expand Up @@ -546,6 +547,10 @@ func IntegrationPod(t *testing.T, ctx context.Context, ns string, name string) f
if len(pods) == 0 {
return nil
}

sort.SliceStable(pods, func(i, j int) bool {
return pods[i].GetCreationTimestamp().Time.After(pods[j].GetCreationTimestamp().Time)
})
return &pods[0]
}
}
Expand Down
15 changes: 15 additions & 0 deletions e2e/support/util/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,21 @@ func Dump(ctx context.Context, c client.Client, ns string, t *testing.T) error {
}
}

// Cronjobs
cronjobs, err := c.BatchV1().CronJobs(ns).List(ctx, metav1.ListOptions{})
if err != nil {
return err
}
t.Logf("\nFound %d cronjobs:\n", len(cronjobs.Items))
for _, cronjobs := range cronjobs.Items {
ref := cronjobs
data, err := kubernetes.ToYAMLNoManagedFields(&ref)
if err != nil {
return err
}
t.Logf("---\n%s\n---\n", string(data))
}

// OLM CSV
csvs := olm.ClusterServiceVersionList{}
err = c.List(ctx, &csvs, ctrl.InNamespace(ns))
Expand Down
Loading