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

✨ Add controllers tests for real Reconcile loop running with setup-envtest #150

Merged

Conversation

dmvolod
Copy link
Contributor

@dmvolod dmvolod commented Jan 26, 2024

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 #146

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 26, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @dmvolod. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jan 26, 2024
@Jont828
Copy link
Contributor

Jont828 commented Feb 1, 2024

/ok-to-test

Still working on e2e tests (like in #163) so please be patient!

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 1, 2024
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 1, 2024
Copy link
Contributor

@Jont828 Jont828 left a comment

Choose a reason for hiding this comment

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

Nice contribution! Here's a first pass with comments, will circle back for a more thorough review.

internal/kubeconfig.go Outdated Show resolved Hide resolved
controllers/controllers_test.go Show resolved Hide resolved
controllers/testdata/crd/cluster.x-k8s.io_clusters.yaml Outdated Show resolved Hide resolved
Makefile Outdated
@@ -264,6 +264,11 @@ generate-modules: ## Run go mod tidy to ensure modules are up to date
go mod tidy
cd $(TOOLS_DIR); go mod tidy

.PHONY: download-cluster-api-crd
download-cluster-api-crd: generate-modules ## Run to download Cluster API CRDs for tests
cp -r $(shell go env GOPATH)/pkg/mod/sigs.k8s.io/cluster-api@$(shell go list -f "{{.Version}}" -m sigs.k8s.io/cluster-api)/config/crd/bases/cluster.x-k8s.io_clusters.yaml ./controllers/testdata/crd
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a CAPI version pin in the Makefile since the CAPI version is already pinned in go.mod?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, originally I used this approach (CLUSTER_API_VERSION variable in Makefile), but current approach avoids to keep it and changing every time Clusrer API changing in go.mod

Copy link
Contributor Author

@dmvolod dmvolod Feb 6, 2024

Choose a reason for hiding this comment

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

Fixed it with introducing CLUSTER_API_VERSION := $(call get_go_version,sigs.k8s.io/cluster-api) variable. Also tune get_go_version a bit without awk utilization and native golang format approach.

Makefile Outdated Show resolved Hide resolved
@@ -438,3 +444,9 @@ func TestReconcileDelete(t *testing.T) {
})
}
}

func init() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this needed in for the unit tests in this file?

Copy link
Contributor Author

@dmvolod dmvolod Feb 7, 2024

Choose a reason for hiding this comment

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

As unit-tests utilizingfake.NewClientBuilder() it requires scheme's to be registered.

@dmvolod dmvolod force-pushed the issue-146-integration-tests branch 4 times, most recently from 42bb1a1 to 1b6fae3 Compare February 7, 2024 07:51
@Jont828
Copy link
Contributor

Jont828 commented Feb 9, 2024

Thanks for the contribution!

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dmvolod, Jont828

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 Feb 9, 2024
@k8s-ci-robot k8s-ci-robot merged commit 2ab4e1a into kubernetes-sigs:main Feb 9, 2024
12 checks passed
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add controllers tests for real Reconcile loop running with setup-envtest
3 participants