-
Notifications
You must be signed in to change notification settings - Fork 37
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
[OCPCLOUD-1706] Migrate test utils from CPMSO repository #265
Conversation
c35dbf2
to
ca770ea
Compare
FYI: I got some more resourcebuilders in this PR, we might want to include them there too, openshift/cluster-control-plane-machine-set-operator#156 |
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.
What is the effect on CPMS of importing these changes? Do we need to make a separate go module to confine the imports to just the testutils module or does it work well as is?
Do we have appropriate linting rules on the testutils?
Do we want to keep the resource builders as a flat structure, or group them by API group/versions as you'd expect for other helpers?
// Machine API namespace. | ||
OpenshiftMachineAPINamespaceName = "openshift-machine-api" | ||
|
||
testClusterIDValue = "cpms-cluster-test-id" |
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.
We probably don't want this to be cpms
anymore, where else is it used?
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.
As machine label, machine selector. I have dropped the cpms prefix.
I was able to import from CPMSO without issues.
The linter is running on the files. (with slightly different settings)
Probably good idea to structure it now that it will be imported from other repositories. I have restructured it. Let me know if it looks good to you. |
399c89b
to
502e870
Compare
@RadekManak this PR is merged now FYI, if you want to pull in also those builders. |
Yes, thanks already done. :) |
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.
Couple of nits, otherwise LGTM
pkg/testutils/resourcebuilder/machine/v1beta1/openshift_machine_v1beta1_template.go
Outdated
Show resolved
Hide resolved
4cf2025
to
5308e45
Compare
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.
looks mostly good to me, just a question
Makefile
Outdated
@@ -69,6 +73,10 @@ vet: ## Apply go vet to all go files | |||
build-e2e: | |||
$(DOCKER_CMD) go test -c -o "$(BUILD_DEST)" github.com/openshift/cluster-api-actuator-pkg/pkg/ | |||
|
|||
.PHONY: unit | |||
unit: ## Run unit tests |
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.
do we need to add a prow configuration to exercise this new target?
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.
Yes, this needs to be set up. The tests do pass locally right now.
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.
Can we get that set up before we merge this? Should be a PR to the release repo to add it right?
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 have openshift/release@09ee970 prepared, but we need to merge this first. There is no unit target on master, so it won't pass until this PR adds it.
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.
Generally LGTM. Thanks for putting this together.
Left mainly a comment regarding importing.
5308e45
to
f2ca228
Compare
f2ca228
to
d4cd1b2
Compare
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 think I would advise considering the testutils
module as if it were a completely independent repository. Set up its own makefile and hack scripts for running the tests, and then link to those targets from the top level using make -C testutils
, it will simplify a lot of the bash/makefile logic and keep them better isolated
Makefile
Outdated
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. | ||
ENVTEST_K8S_VERSION = 1.26 | ||
|
||
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
ENVTEST = go run ${PROJECT_DIR}/vendor/sigs.k8s.io/controller-runtime/tools/setup-envtest |
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.
Are these new additions used now we've moved things to a separate makefile?
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.
Forgot to remove this. Thanks
testutils/Makefile
Outdated
.PHONY: fmt | ||
fmt: ## Go fmt your code | ||
$(DOCKER_CMD) hack/go-fmt.sh . | ||
|
||
.PHONY: goimports | ||
goimports: ## run goimports | ||
$(DOCKER_CMD) hack/goimports.sh . |
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.
Are these not covered by GolangCI Lint? My understanding was they are both run as part of its suite
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.
You are correct. I have kept them because, they were being executed by CI. There are currently two targets that run on this repo. (excluding E2Es). check
that on main branch runs fmt and vet, and goimports. The golanCI lint has been added recently and is not being executed by CI. If you want, we can remove these and only keep golangci lint and unit.
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.
If that's the case, then yep, lets keep them for now but I think we should migrate to golangci-lint as the single source moving forward, that can be a follow up PR though
go.mod
Outdated
k8s.io/klog v1.0.0 | ||
k8s.io/utils v0.0.0-20220823124924-e9cbc92d1a73 | ||
sigs.k8s.io/controller-runtime v0.13.0 | ||
sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20221222054525-3c4deba74e5c |
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.
Is this correct? I didn't think setup-entest was needed at this level anymore?
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.
Forgot to remove this. Thanks
fmt and goimports are now executed as part of the golangci lint suite
4923bc3
to
02f6689
Compare
/retest-required |
@RadekManak: all tests passed! Full PR test history. Your PR dashboard. 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. I understand the commands that are listed here. |
/approve /assign @damdo Dam for LGTM on this as we talked about it during standup |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: JoelSpeed 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 |
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.
Thanks for putting this together Radek.
/lgtm
This PR moves test utilities and resource builders from CPMSO repository into this repository. This will allow us to reuse them in other test suites.
Tooling for unit test is created as this repo currently only has e2e tests. This will need to be enabled in openshift/release after this PR merges.
The MachineInfoBuilder is kept in the CPMSO repo. MachineInfo's are used only in CPMSO. Moving the builder over would create cyclic dependency.