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

📖 Define testing guidelines and standards #3349

Merged

Conversation

fabriziopandini
Copy link
Member

What this PR does / why we need it:
Cluster API maintainers would like to improve consistency and maintainability of tests, in order to support the future growth of the project, avoid regressions and improve the developer experience and the overall quality of the code base.

This PR kick off this work following discussion on #3287 with the goal to reach an agreement at the community level about the direction we want to take for improving tests.

Which issue(s) this PR fixes:
Fixes #3287

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 15, 2020
@fabriziopandini
Copy link
Member Author

/hold
for community feedback

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 15, 2020
@fabriziopandini
Copy link
Member Author

/retest

@fejta-bot
Copy link

Unknown CLA label state. Rechecking for CLA labels.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/check-cla

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

@wfernandes wfernandes left a comment

Choose a reason for hiding this comment

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

Just added some notes. Overall I'm ok with using envtest since fakeclient is being deprecated (sigh...) and I'd prefer to not use things that are out of date and not maintained.

My concern with using envtest for unit tests is the possible increase of time it takes to run all the test suites. Are we going to have an envtest spun up per package or TestBlock?
Also, do we currently run our tests in parallel in CI? Sharing instances of envtest will definitely add more overhead to contributors to ensure they are creating and cleaning up resources correctly.

I'm working on writing a unit test using envtest and have some comments regarding cleanup of resources, etc...
#3350

Comment on lines 92 to 97
Please note that, because [envtest] uses a real kube-apiserver that is shared across many tests, the developer
should take care of ensuring each test run in isolation from the others, by:

- Creating objects in separated namespaces.
- Avoiding object name conflict.
- Cleaning up objects created by each test.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm guessing initially we will have an area of the codebase with tests written in the preferred style. This will probably result in creation of additional helpers that will help manage this overhead. These helpers should then be used everywhere else in order to provide a consistent test codebase.

Copy link
Member Author

Choose a reason for hiding this comment

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

This makes totally sense

docs/book/src/developer/testing.md Outdated Show resolved Hide resolved
Copy link
Contributor

@wfernandes wfernandes left a comment

Choose a reason for hiding this comment

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

Nice! This example is going to be really helpful to folks!

docs/book/src/developer/testing.md Outdated Show resolved Hide resolved
docs/book/src/developer/testing.md Outdated Show resolved Hide resolved
docs/book/src/developer/testing.md Outdated Show resolved Hide resolved
@vincepri
Copy link
Member

vincepri commented Aug 3, 2020

/milestone v0.3.9

@k8s-ci-robot k8s-ci-robot added this to the v0.3.9 milestone Aug 3, 2020
@wfernandes
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 5, 2020
@vincepri
Copy link
Member

vincepri commented Aug 5, 2020

Approval pending squash

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 6, 2020
@fabriziopandini
Copy link
Member Author

Commit squashed

@wfernandes
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 6, 2020
Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

/approve
/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 7, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vincepri

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 Aug 7, 2020
@k8s-ci-robot k8s-ci-robot merged commit 4df8035 into kubernetes-sigs:master Aug 7, 2020
@fabriziopandini fabriziopandini deleted the standardize-test branch August 10, 2020 09:07
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. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Standardize CAPI tests
6 participants