-
Notifications
You must be signed in to change notification settings - Fork 47
OCPCLOUD-1401: refactor to run same test against both mapi and capi #442
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
Open
sunzhaohua2
wants to merge
4
commits into
openshift:master
Choose a base branch
from
sunzhaohua2:interface1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,3 +3,6 @@ | |
| .cache | ||
|
|
||
| _out/ | ||
|
|
||
| # Test binaries | ||
| *.test | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| package backends | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
|
|
||
| configv1 "github.com/openshift/api/config/v1" | ||
| corev1 "k8s.io/api/core/v1" | ||
| runtimeclient "sigs.k8s.io/controller-runtime/pkg/client" | ||
|
|
||
| "github.com/openshift/cluster-api-actuator-pkg/pkg/unified/config" | ||
| ) | ||
|
|
||
| // MachineBackend defines the abstract interface for machine backends. | ||
| type MachineBackend interface { | ||
| GetBackendType() config.BackendType | ||
| GetAuthoritativeAPI() config.BackendType | ||
| CreateMachineTemplate(ctx context.Context, client runtimeclient.Client, platform configv1.PlatformType, params BackendMachineTemplateParams) (interface{}, error) | ||
| DeleteMachineTemplate(ctx context.Context, client runtimeclient.Client, template interface{}) error | ||
| CreateMachineSet(ctx context.Context, client runtimeclient.Client, params BackendMachineSetParams) (interface{}, error) | ||
| DeleteMachineSet(ctx context.Context, client runtimeclient.Client, machineSet interface{}) error | ||
| WaitForMachineSetDeleted(ctx context.Context, client runtimeclient.Client, machineSet interface{}) error | ||
| WaitForMachinesRunning(ctx context.Context, client runtimeclient.Client, machineSet interface{}) error | ||
| GetMachineSetStatus(ctx context.Context, client runtimeclient.Client, machineSet interface{}) (*MachineSetStatus, error) | ||
| GetNodesFromMachineSet(ctx context.Context, client runtimeclient.Client, machineSet interface{}) ([]corev1.Node, error) | ||
| } | ||
|
|
||
| // BackendMachineSetParams defines common parameters for creating machine sets. | ||
| type BackendMachineSetParams struct { | ||
| Name string | ||
| Replicas int32 | ||
| Labels map[string]string | ||
| Annotations map[string]string | ||
| Template interface{} | ||
| FailureDomain string | ||
| // AuthoritativeAPI specifies which API should be authoritative for this MachineSet | ||
| AuthoritativeAPI config.BackendType | ||
| } | ||
|
|
||
| // BackendMachineTemplateParams defines common parameters for creating machine templates. | ||
| type BackendMachineTemplateParams struct { | ||
| Name string | ||
| Platform configv1.PlatformType | ||
| Spec interface{} | ||
| } | ||
|
|
||
| // MachineSetStatus defines common structure for machine set status. | ||
| type MachineSetStatus struct { | ||
| Replicas int32 | ||
| AvailableReplicas int32 | ||
| ReadyReplicas int32 | ||
| AuthoritativeAPI string | ||
| } | ||
|
|
||
| // NewBackend creates appropriate backend instance based on configuration. | ||
| func NewBackend(backendType config.BackendType, authoritativeAPI config.BackendType) (MachineBackend, error) { | ||
| switch backendType { | ||
| case config.BackendTypeMAPI: | ||
| return NewMAPIBackend(authoritativeAPI), nil | ||
| case config.BackendTypeCAPI: | ||
| return NewCAPIBackend(authoritativeAPI), nil | ||
| default: | ||
| return nil, fmt.Errorf("unsupported backend type: %s", backendType) | ||
| } | ||
| } | ||
|
|
||
| // NewMAPIBackend creates a new MAPI backend instance. | ||
| func NewMAPIBackend(authoritativeAPI config.BackendType) MachineBackend { | ||
| return &mapiBackend{backendType: config.BackendTypeMAPI, authoritativeAPI: authoritativeAPI} | ||
| } | ||
|
|
||
| // NewCAPIBackend creates a new CAPI backend instance. | ||
| func NewCAPIBackend(authoritativeAPI config.BackendType) MachineBackend { | ||
| return &capiBackend{backendType: config.BackendTypeCAPI, authoritativeAPI: authoritativeAPI} | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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/cluster-api-actuator-pkg
Length of output: 840
🏁 Script executed:
Repository: openshift/cluster-api-actuator-pkg
Length of output: 8592
🏁 Script executed:
# Check the hack/ci-integration.sh to understand how label-filter is used head -50 hack/ci-integration.shRepository: openshift/cluster-api-actuator-pkg
Length of output: 502
🏁 Script executed:
Repository: openshift/cluster-api-actuator-pkg
Length of output: 180
🏁 Script executed:
Repository: openshift/cluster-api-actuator-pkg
Length of output: 20847
🏁 Script executed:
# Check the ginkgo-labels.go file to understand test labels cat pkg/framework/ginkgo-labels.goRepository: openshift/cluster-api-actuator-pkg
Length of output: 1762
🏁 Script executed:
Repository: openshift/cluster-api-actuator-pkg
Length of output: 2555
🏁 Script executed:
Repository: openshift/cluster-api-actuator-pkg
Length of output: 3860
Keep the backend matrix on the same suite.
test-mapirunsunified||mapiwhiletest-capiandtest-mapi-with-capi-authboth run onlyunified, sotest-alldoes not compare the same test suite across backends. This breaks parity interpretation and allows legacy MAPI-only tests to skew the matrix results.Suggested change
If legacy MAPI coverage is needed, keep it under a separate target instead of including it in this parity matrix.
📝 Committable suggestion
🤖 Prompt for AI Agents
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.
I chose to make test-capi and test-mapi both running unified and backend-specific tests in order to support full backend testing.
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.
@sunzhaohua2, understood — that's a valid design goal. One thing worth noting for consistency: if the intent is full backend coverage per target, thentest-capiwould also need--label-filter='unified||capi'(assuming acapilabel exists or gets added) to achieve the same depth of coverage on the CAPI side. As it stands, MAPI gets more test coverage than CAPI intest-all, which is an asymmetry. If that's intentional (e.g., CAPI doesn't have backend-specific tests yet), it's fine to leave as-is — just worth documenting.Happy to leave this as-is given your explanation.