-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Add commit status validation test #30987
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| inheritance: true | ||
| reviews: | ||
| fail_commit_status: true |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,42 @@ | ||||||||||||||||||||||||
| package operators | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| import ( | ||||||||||||||||||||||||
| "context" | ||||||||||||||||||||||||
| "time" | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| g "github.com/onsi/ginkgo/v2" | ||||||||||||||||||||||||
| o "github.com/onsi/gomega" | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||||||||||||||||||||
| "k8s.io/client-go/kubernetes" | ||||||||||||||||||||||||
| "k8s.io/client-go/rest" | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
|
Comment on lines
+11
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Check if the file exists and examine its content
ls -la test/extended/operators/commit_status.goRepository: openshift/origin Length of output: 149 🏁 Script executed: # Look at the actual content around the import lines and the code in question
head -30 test/extended/operators/commit_status.go | cat -nRepository: openshift/origin Length of output: 995 🏁 Script executed: # Search for other uses of e2e.LoadClientset() in the test suite to confirm it's a common pattern
rg "e2e\.LoadClientset\(\)" test/ --type go -A 2 -B 2Repository: openshift/origin Length of output: 4360 🏁 Script executed: # Check how InClusterConfig is used elsewhere in test files
rg "rest\.InClusterConfig\(\)" test/ --type go -A 2 -B 2Repository: openshift/origin Length of output: 443 🏁 Script executed: # Verify the e2e framework import path exists
find . -path "*/test/e2e/framework*" -type d | head -5Repository: openshift/origin Length of output: 325 🏁 Script executed: # Check the exact import statement for e2e in files that use LoadClientset
head -20 test/extended/operators/cluster.go | cat -nRepository: openshift/origin Length of output: 588 🏁 Script executed: # Also check operators.go for the e2e import
head -20 test/extended/operators/operators.go | cat -nRepository: openshift/origin Length of output: 619 🏁 Script executed: # Check what's imported in operators.go more completely
grep -n "^[[:space:]]*e2e" test/extended/operators/operators.go | head -5Repository: openshift/origin Length of output: 597 🏁 Script executed: # Check if there are any other imports needed besides the e2e framework import
grep -n "import" test/extended/operators/operators.go -A 30 | head -40Repository: openshift/origin Length of output: 990 🏁 Script executed: # Check what LoadClientset returns to ensure the suggested fix is correct
rg "func LoadClientset" vendor/k8s.io/kubernetes/test/e2e/framework/ -A 5Repository: openshift/origin Length of output: 612 🏁 Script executed: # Verify the suggested diff imports are correct by looking at the actual return type
rg "LoadClientset.*\(" vendor/k8s.io/kubernetes/test/e2e/framework/ -B 2 -A 10 | head -30Repository: openshift/origin Length of output: 1197 Use the standard e2e client loader instead of This setup can fail when the test runs outside a pod. In this suite, the common pattern is Suggested fix import (
"context"
"time"
g "github.com/onsi/ginkgo/v2"
o "github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- "k8s.io/client-go/kubernetes"
- "k8s.io/client-go/rest"
+ e2e "k8s.io/kubernetes/test/e2e/framework"
)
@@
- cfg, err := rest.InClusterConfig()
- o.Expect(err).NotTo(o.HaveOccurred())
- client, err := kubernetes.NewForConfig(cfg)
+ client, err := e2e.LoadClientset()
o.Expect(err).NotTo(o.HaveOccurred())Also applies to: 19-22 🤖 Prompt for AI Agents |
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| var _ = g.Describe("[sig-arch] Commit status validation", func() { | ||||||||||||||||||||||||
| defer g.GinkgoRecover() | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| g.It("should validate all pods are running", func() { | ||||||||||||||||||||||||
| cfg, err := rest.InClusterConfig() | ||||||||||||||||||||||||
| o.Expect(err).NotTo(o.HaveOccurred()) | ||||||||||||||||||||||||
| client, err := kubernetes.NewForConfig(cfg) | ||||||||||||||||||||||||
| o.Expect(err).NotTo(o.HaveOccurred()) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| pods, err := client.CoreV1().Pods("").List(ctx, metav1.ListOptions{}) | ||||||||||||||||||||||||
| o.Expect(err).NotTo(o.HaveOccurred()) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| cancel() | ||||||||||||||||||||||||
|
Comment on lines
+24
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The 1-second timeout is too short for cluster-wide pod listing. This is likely to introduce flaky deadline failures. Use a more realistic timeout and defer cancellation. Suggested fix- ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ defer cancel()
@@
- cancel()📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| totalPods := 0 | ||||||||||||||||||||||||
| runningPods := 0 | ||||||||||||||||||||||||
| for i := 0; i < len(pods.Items); i++ { | ||||||||||||||||||||||||
| totalPods = totalPods + 1 | ||||||||||||||||||||||||
| if pods.Items[i].Status.Phase == "Running" { | ||||||||||||||||||||||||
| runningPods = runningPods + 1 | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| o.Expect(runningPods).To(o.Equal(totalPods), "all pods should be running") | ||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: openshift/origin
Length of output: 102
🏁 Script executed:
# Read the commit_status.go file cat -n ./test/extended/operators/commit_status.goRepository: openshift/origin
Length of output: 1361
🏁 Script executed:
Repository: openshift/origin
Length of output: 96
🏁 Script executed:
Repository: openshift/origin
Length of output: 951
Fix overly strict pod health assertion that fails on legitimate
Succeededpods.Lines 31-40 require all pods to be in
Runningstate, which will false-fail on healthy clusters with completed pods inSucceededstate (e.g., job completions). Accept bothRunningandSucceededphases, and fail only on unhealthy states.Suggested fix
🤖 Prompt for AI Agents