-
Notifications
You must be signed in to change notification settings - Fork 68
wip: migrate e2e tests to godog framework (aka BDD/Cucumber) #2365
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?
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
✅ Deploy Preview for olmv1 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Pull request overview
This PR migrates the e2e test suite from traditional Go testing framework to Godog (BDD/Cucumber framework), enabling behavior-driven development with Gherkin feature files. The migration maintains test coverage while reorganizing tests into feature files with step definitions.
Key Changes
- Replaced traditional Go test functions with Godog scenarios and step definitions
- Added Gherkin
.featurefiles describing test behavior in a more readable format - Introduced new test infrastructure (
steps.go,hooks.go) to support BDD testing
Reviewed changes
Copilot reviewed 19 out of 21 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| test/e2e/features_test.go | New test entry point initializing Godog suite with scenario and suite initializers |
| test/e2e/features/steps/steps.go | Implements step definitions mapping Gherkin steps to Go functions |
| test/e2e/features/steps/hooks.go | Provides scenario lifecycle hooks and feature gate detection |
| test/e2e/features/*.feature | Gherkin feature files defining test scenarios (install, update, recover, metrics) |
| test/e2e/features/steps/testdata/*.yaml | YAML templates for test resources (catalogs, RBAC) |
| test/e2e/*_test.go | Removed traditional test files migrated to feature files |
| test/e2e/network_policy_test.go | Added client initialization and helper function |
| go.mod, go.sum | Added Cucumber/Godog dependencies |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| var kubeconfigPath string | ||
|
|
||
| func init() { | ||
| kubeconfigPath = os.Getenv("HOME") + "/.kube/config" |
Copilot
AI
Nov 28, 2025
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.
Using HOME environment variable for kubeconfig path is fragile. Consider using Go's standard approach with filepath.Join(os.UserHomeDir(), \".kube\", \"config\") or respect the KUBECONFIG environment variable convention for Kubernetes tooling.
| kubeconfigPath = os.Getenv("HOME") + "/.kube/config" | |
| kubeconfigPath = os.Getenv("KUBECONFIG") | |
| if kubeconfigPath == "" { | |
| home, err := os.UserHomeDir() | |
| if err != nil { | |
| panic(fmt.Sprintf("cannot determine user home directory: %v", err)) | |
| } | |
| kubeconfigPath = filepath.Join(home, ".kube", "config") | |
| } |
| }, | ||
| } | ||
| pb, err := json.Marshal(patch) | ||
| if err != nil { |
Copilot
AI
Nov 28, 2025
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.
Empty error handler. The error from json.Marshal is captured but not returned or handled, potentially hiding failures in catalog updates.
| if err != nil { | |
| if err != nil { | |
| return fmt.Errorf("failed to marshal patch: %v", err) |
| p.Process.Kill() | ||
| p.Process.Wait() |
Copilot
AI
Nov 28, 2025
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.
Potential nil pointer dereference. If p.Process is nil (e.g., if Start() failed), this will panic. Add a nil check before calling Kill() and Wait().
| p.Process.Kill() | |
| p.Process.Wait() | |
| if p.Process != nil { | |
| p.Process.Kill() | |
| p.Process.Wait() | |
| } |
| tr := &http.Transport{ | ||
| TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, |
Copilot
AI
Nov 28, 2025
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.
TLS certificate verification is disabled with InsecureSkipVerify: true. This creates a security vulnerability allowing man-in-the-middle attacks. For test code, consider using proper certificate handling or at minimum document why this is acceptable for the test environment.
| tr := &http.Transport{ | |
| TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, | |
| // Load CA certificate for test environment | |
| caCertPath := filepath.Join("features", "steps", "testdata", "ca.crt") | |
| caCert, err := os.ReadFile(caCertPath) | |
| if err != nil { | |
| return nil, fmt.Errorf("failed to read CA certificate: %v", err) | |
| } | |
| caCertPool := x509.NewCertPool() | |
| if !caCertPool.AppendCertsFromPEM(caCert) { | |
| return nil, fmt.Errorf("failed to append CA certificate") | |
| } | |
| tr := &http.Transport{ | |
| TLSClientConfig: &tls.Config{ | |
| RootCAs: caCertPool, | |
| }, |
| - apiGroups: [olm.operatorframework.io] | ||
| resources: [clusterextensions, clusterextensions/finalizers] | ||
| resourceNames: ["{clusterextension_name}"] | ||
| #verbs: [update, create, list, watch, get, delete, patch] |
Copilot
AI
Nov 28, 2025
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.
Commented-out verbs suggest incomplete implementation or unclear intent. Either remove the commented line if not needed, or add a comment explaining why only 'update' is required while other verbs are commented out.
| #verbs: [update, create, list, watch, get, delete, patch] |
|
|
||
| path := os.Getenv("E2E_SUMMARY_OUTPUT") | ||
| if path == "" { | ||
| fmt.Printf("Note: E2E_SUMMARY_OUTPUT is unset; skipping summary generation") |
Copilot
AI
Nov 28, 2025
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.
Missing newline character in printf statement. Should be fmt.Println() or add \\n to ensure proper output formatting.
| fmt.Printf("Note: E2E_SUMMARY_OUTPUT is unset; skipping summary generation") | |
| fmt.Println("Note: E2E_SUMMARY_OUTPUT is unset; skipping summary generation") |
730ba01 to
0482745
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2365 +/- ##
==========================================
- Coverage 74.45% 74.32% -0.13%
==========================================
Files 93 93
Lines 7300 7300
==========================================
- Hits 5435 5426 -9
- Misses 1433 1441 +8
- Partials 432 433 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Description
Reviewer Checklist