-
Notifications
You must be signed in to change notification settings - Fork 22
ESO-424:Added e2e test cases from openshift test private. #160
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -30,21 +30,27 @@ import ( | |||||
| appsv1 "k8s.io/api/apps/v1" | ||||||
| k8serrors "k8s.io/apimachinery/pkg/api/errors" | ||||||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| "k8s.io/apimachinery/pkg/util/wait" | ||||||
| "k8s.io/client-go/kubernetes" | ||||||
| "sigs.k8s.io/controller-runtime/pkg/client" | ||||||
|
|
||||||
| operatorv1alpha1 "github.com/openshift/external-secrets-operator/api/v1alpha1" | ||||||
| "github.com/openshift/external-secrets-operator/pkg/controller/common" | ||||||
| externalsecrets "github.com/openshift/external-secrets-operator/pkg/controller/external_secrets" | ||||||
| "github.com/openshift/external-secrets-operator/test/utils" | ||||||
| ) | ||||||
|
|
||||||
| // ensureExternalSecretsConfigReady creates the cluster ExternalSecretsConfig CR when missing | ||||||
| // and waits until Ready=True. Shared by suite Describes that may run before e2e_test BeforeAll. | ||||||
| func ensureExternalSecretsConfigReady(ctx context.Context) error { | ||||||
| if suiteRuntimeClient == nil || suiteDynamicClient == nil { | ||||||
| if suiteRuntimeClient == nil || suiteDynamicClient == nil || suiteClientset == nil { | ||||||
| return fmt.Errorf("suite clients not initialized") | ||||||
| } | ||||||
|
|
||||||
| if err := waitForNamespaceTermination(ctx, suiteClientset, externalsecrets.OperandDefaultNamespace, 2*time.Minute); err != nil { | ||||||
| return fmt.Errorf("waiting for operand namespace to finish terminating: %w", err) | ||||||
| } | ||||||
|
|
||||||
| esc := &operatorv1alpha1.ExternalSecretsConfig{} | ||||||
| err := suiteRuntimeClient.Get(ctx, client.ObjectKey{Name: common.ExternalSecretsConfigObjectName}, esc) | ||||||
| if err != nil { | ||||||
|
|
@@ -58,6 +64,29 @@ func ensureExternalSecretsConfigReady(ctx context.Context) error { | |||||
| return utils.WaitForExternalSecretsConfigReady(ctx, suiteDynamicClient, common.ExternalSecretsConfigObjectName, 2*time.Minute) | ||||||
| } | ||||||
|
|
||||||
| func waitForNamespaceTermination(ctx context.Context, clientset *kubernetes.Clientset, namespace string, timeout time.Duration) error { | ||||||
| ns, err := clientset.CoreV1().Namespaces().Get(ctx, namespace, metav1.GetOptions{}) | ||||||
|
Contributor
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. Shouldn't this initial elaborate check be wrapped in |
||||||
| if k8serrors.IsNotFound(err) { | ||||||
| return nil | ||||||
| } | ||||||
| if err != nil { | ||||||
| return err | ||||||
| } | ||||||
| if ns.Status.Phase != "Terminating" { | ||||||
|
Contributor
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.
Suggested change
|
||||||
| return nil | ||||||
|
Comment on lines
+68
to
+76
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. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: sed -n '1,140p' test/e2e/helpers_test.go
printf '\n--- usages ---\n'
rg -n "Terminating|DeletionTimestamp|is.*terminating|namespace.*terminating|helpers_test.go" test/e2e -g '*.go'Repository: openshift/external-secrets-operator Length of output: 5754 🏁 Script executed: sed -n '2050,2110p' test/e2e/e2e_test.go
python3 - <<'PY'
from pathlib import Path
text = Path('test/e2e/helpers_test.go').read_text()
start = text.index('func waitForNamespaceTermination')
print(text[start:text.index('// resourceType defines', start)])
PYRepository: openshift/external-secrets-operator Length of output: 3179 🏁 Script executed: rg -n "ensureExternalSecretsConfigReady|waitForNamespaceTermination|OperandDefaultNamespace" test/e2e -g '*.go'
sed -n '1,90p' test/e2e/helpers_test.goRepository: openshift/external-secrets-operator Length of output: 4188 🌐 Web query:
💡 Result: In Kubernetes, the interaction between the Citations:
Treat a non-nil 🤖 Prompt for AI Agents |
||||||
| } | ||||||
| return wait.PollUntilContextTimeout(ctx, 5*time.Second, timeout, true, func(ctx context.Context) (bool, error) { | ||||||
| _, err := clientset.CoreV1().Namespaces().Get(ctx, namespace, metav1.GetOptions{}) | ||||||
| if k8serrors.IsNotFound(err) { | ||||||
| return true, nil | ||||||
| } | ||||||
| if err != nil { | ||||||
| return false, err | ||||||
| } | ||||||
| return false, nil | ||||||
| }) | ||||||
| } | ||||||
|
|
||||||
| // resourceType defines a Kubernetes resource type to verify annotations on | ||||||
| type resourceType struct { | ||||||
| name string | ||||||
|
|
||||||
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.
nit: already present at line 32