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

test/e2e: more flexible pod spec generation #964

Merged
merged 1 commit into from
Nov 23, 2022

Conversation

marquiz
Copy link
Contributor

@marquiz marquiz commented Nov 22, 2022

Change the pod spec generator functions to accept parameterization in
the form of more generic "mutator functions". This makes the addition of
new test specific pod spec customizations a lot cleaner. Plus, hopefully
makes the code a bit more readable as well.

Also, slightly simplify the SpecWithConfigMap() but dropping one
redundant argument.

Inspired by latest contributions by Talor Itzhak (titzhak@redhat.com).

@netlify
Copy link

netlify bot commented Nov 22, 2022

Deploy Preview for kubernetes-sigs-nfd ready!

Name Link
🔨 Latest commit 1719ce6
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-nfd/deploys/637dcdd45a0cbc0009faf23b
😎 Deploy Preview https://deploy-preview-964--kubernetes-sigs-nfd.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 22, 2022
@marquiz
Copy link
Contributor Author

marquiz commented Nov 22, 2022

/assign @ArangoGutierrez @fmuyassarov

ping @Tal-or

Copy link
Contributor

@Tal-or Tal-or left a comment

Choose a reason for hiding this comment

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

Very nice.
A small enhancement proposal from me about readability:
You can have a separate package named pod or podspec under utils and place NFDWorkerPod NFDMasterPod, etc. functions there.

Then you can rename the functions and call them from the tests in the following manner:
instead of:

testutils.NFDWorkerPod(opts...)
testutils.NFDMasterPod(opts...)
testutils.SpecWithContainerImage(...)

You'll have:

pod.NFDWorker(opts...)
pod.NFDMaster(opts...)
pod.SpecWithContainerImage(...)

It will keep the names shorter, clearer, and make the package more isolated and portable

test/e2e/utils/pod.go Show resolved Hide resolved
@marquiz
Copy link
Contributor Author

marquiz commented Nov 22, 2022

Thanks for the review @Tal-or

A small enhancement proposal from me about readability:
You can have a separate package named pod or podspec under utils and place NFDWorkerPod NFDMasterPod, etc. functions there.

Good note, I agree.

How about doing this refactoring in a separate PR? I think there are other things to be done on this front, e.g. separating the daemonset functionality in a separate package (or a separate file at least). Another thing that I spotted was that we could simplify the "sleeper pod" creation, basically set resource limits with a dedicated PodSpecOption. We could track these in a separate issue

@Tal-or
Copy link
Contributor

Tal-or commented Nov 22, 2022

Thanks for the review @Tal-or

A small enhancement proposal from me about readability:
You can have a separate package named pod or podspec under utils and place NFDWorkerPod NFDMasterPod, etc. functions there.

Good note, I agree.

How about doing this refactoring in a separate PR? I think there are other things to be done on this front, e.g. separating the daemonset functionality in a separate package (or a separate file at least). Another thing that I spotted was that we could simplify the "sleeper pod" creation, basically set resource limits with a dedicated PodSpecOption. We could track these in a separate issue

Sure. I can handle it if you want.

@k8s-triage-robot
Copy link

Unknown CLA label state. Rechecking for CLA labels.

Send feedback to sig-contributor-experience at kubernetes/community.

/check-cla
/easycla

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 22, 2022
@marquiz
Copy link
Contributor Author

marquiz commented Nov 23, 2022

Sure. I can handle it if you want.

Yeah, sure go ahead. Would be appreciated 👍

Change the pod spec generator functions to accept parameterization in
the form of more generic "mutator functions". This makes the addition of
new test specific pod spec customizations a lot cleaner. Plus, hopefully
makes the code a bit more readable as well.

Also, slightly simplify the SpecWithConfigMap() but dropping one
redundant argument.

Inspired by latest contributions by Talor Itzhak (titzhak@redhat.com).
@marquiz
Copy link
Contributor Author

marquiz commented Nov 23, 2022

Updated the PR, converting nfd-worker tests to also use SpecWithConfigMap()

@marquiz
Copy link
Contributor Author

marquiz commented Nov 23, 2022

@Tal-or so I suggest to merge this PR with its current scope/content and submit further enhancements as separate PRs? Makes also review easier as smaller diffstat per PR.

@Tal-or
Copy link
Contributor

Tal-or commented Nov 23, 2022

Sure, go ahead

@marquiz
Copy link
Contributor Author

marquiz commented Nov 23, 2022

ping @ArangoGutierrez @fmuyassarov

Copy link
Contributor

@ArangoGutierrez ArangoGutierrez left a comment

Choose a reason for hiding this comment

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

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ArangoGutierrez, marquiz

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 merged commit 213bbdc into kubernetes-sigs:master Nov 23, 2022
@marquiz marquiz deleted the devel/e2e-pod-opts branch November 24, 2022 08:50
@marquiz marquiz mentioned this pull request Dec 20, 2022
22 tasks
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.

6 participants