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

clean up scope unit tests #5143

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

nojnhuh
Copy link
Contributor

@nojnhuh nojnhuh commented Sep 23, 2024

What type of PR is this?

What this PR does / why we need it:

This PR removes most usage of our constructor wrappers to create Scope objects in unit tests in order to avoid the extra setup that requires to create a valid reference to an existing AzureClusterIdentity. That adds quite a few moving parts when all we are trying to test is a function like this that doesn't actually use the identity at all:

// Subnet returns the subnet with the provided name.
func (s *ClusterScope) Subnet(name string) infrav1.SubnetSpec {
for _, sn := range s.AzureCluster.Spec.NetworkSpec.Subnets {
if sn.Name == name {
return sn
}
}
return infrav1.SubnetSpec{}
}

I'm planning to make some changes to the identity stuff soon for #5017 and #1077 that would require some change to all of these tests, but with this change it shouldn't need any extra changes. Hopefully this prevents us from needing other sweeping changes to these tests for unrelated changes like this:

https://github.com/kubernetes-sigs/cluster-api-provider-azure/pull/4208/files#diff-bae329736fc788cebbe920f1680bfd39eb52e6f1bdaaa0a620c60037d3840462

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer:

  • cherry-pick candidate

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests

Release note:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Sep 23, 2024
@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Sep 23, 2024
Copy link

codecov bot commented Sep 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 51.25%. Comparing base (9eaaadc) to head (a752b27).
Report is 14 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5143   +/-   ##
=======================================
  Coverage   51.25%   51.25%           
=======================================
  Files         273      273           
  Lines       24651    24651           
=======================================
  Hits        12636    12636           
  Misses      11229    11229           
  Partials      786      786           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mboersma
Copy link
Contributor

/retest

Copy link
Contributor

@mboersma mboersma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@@ -272,28 +265,10 @@ func TestManagedControlPlaneScope_PoolVersion(t *testing.T) {
}

for _, c := range cases {
c := c
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can ditch this now with Go 1.22?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change was probably safe even before that since these tests aren't running in parallel.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 30, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 186123818041bf58a5cfccde1b627792b2646105

@mboersma
Copy link
Contributor

/assign @willie-yao

Copy link
Contributor

@willie-yao willie-yao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: willie-yao

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 30, 2024
@k8s-ci-robot k8s-ci-robot merged commit 0cf44e7 into kubernetes-sigs:main Oct 1, 2024
21 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.18 milestone Oct 1, 2024
@nojnhuh nojnhuh deleted the scope-ut-cleanup branch October 2, 2024 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants