-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
🐛 Fix issue found to re-generate the scaffolds with the new alpha command and adding e2e tests #3461
Conversation
Hi @yyy1000. 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 Once the patch is verified, the new status will be reflected by the 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. |
/ok-to-test |
PLease squash the commits and rebase it with master so that we can move forward with this one |
// Run e2e tests using the Ginkgo runner. | ||
func TestE2E(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
fmt.Fprintf(GinkgoWriter, "Starting kubebuilder alpha generate suite\n") |
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.
fmt.Fprintf(GinkgoWriter, "Starting kubebuilder alpha generate suite\n") | |
fmt.Fprintf(GinkgoWriter, "Starting kubebuilder suite test for the alpha command generate\n") |
kbc.Destroy() | ||
}) | ||
|
||
It("should generate a runnable project with alpha generate", func() { |
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.
It("should generate a runnable project with alpha generate", func() { | |
It("should regenerate the project with success", func() { |
We are not testing that the result is runnable so I think we need to change the test description
I seems that the e2e tests in CI indicate other error not related to the change in this PR. |
/retest |
) | ||
ExpectWithOffset(1, err).NotTo(HaveOccurred()) | ||
|
||
fileContainsExpr, err := pluginutil.HasFileContentWith( |
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.
fileContainsExpr, err := pluginutil.HasFileContentWith( | |
By("checking if the project file was generated with the expected content") | |
fileContainsExpr, err := pluginutil.HasFileContentWith( |
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.
Let's add a description so we have further info when fails to know where it failed
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.
That's a good idea.
- go.kubebuilder.io/v4 | ||
projectName: testdir | ||
repo: my.domain/hello | ||
version: "3"`) |
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 it is easier to keep maintained if we create a const could we use a const instead?
See the other places for example.
It might be failing due missing spaces and etc.
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 added so comments but you are doing great !!!
) | ||
ExpectWithOffset(1, err).NotTo(HaveOccurred()) | ||
|
||
fileContainsExpr, err := pluginutil.HasFileContentWith( |
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.
Let's add a description so we have further info when fails to know where it failed
layout: | ||
- go.kubebuilder.io/v4 | ||
projectName: testdir | ||
repo: my.domain/hello |
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.
The repo, domain will not be this one since when we use the testContext and generate the project we create a domain and etc for the test. Therefore, see that
- The domain will be kbc.Domain so you can use format string to pass the const with %s and replace the domain with the expected value
- I would suggest you remove the
repo: my.domain/hello
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.
Sorry for this problem. I set domain to this because I tested in local, and whatever the old PROJECT file is. The domain of the new PROJECT file is always 'my.domain'. Maybe there's some problem with my implementation of 'alpha generate'.
b45192b
to
c81f978
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 just change the title but it seems great for me 🥇
Good work !!
It has my approval,
Lets see if @varshaprasad96 and @Kavinjsir has none any extra considerations and if we have their lgtm as well.
Thank you
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: camilamacedo86, yyy1000 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.
Great work @yyy1000. Just a few nit questions.
args = append(args, "--plugins") | ||
args = append(args, plugins...) |
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.
could we do all the appends together?
args = append(args, "--plugins") | |
args = append(args, plugins...) | |
args = append(args, "--plugins", plugins...) |
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.
No, I tried this and it will not compile:
too many arguments in call to append
have ([]string, string, []string)
want ([]string, ...string)
make: *** [Makefile:57: build] Error 1
pkg/rescaffold/migrate.go
Outdated
args = append(args, "--domain") | ||
args = append(args, domain) |
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.
Similarly, does this work?
args = append(args, "--domain") | |
args = append(args, domain) | |
args = append(args, "--domain", domain) |
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.
This works! I think it's because when using append
method, you either append multiple single element or a slice of elements. But can't mix them. :)
//nolint:golint | ||
//nolint:revive |
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 disable the linters here? Looks like we don't in other places and it works (https://github.com/kubernetes-sigs/kubebuilder/blob/47e6cab305336e1a7a5d577dc3c1500a445a70d1/pkg/cli/version_test.go#L20C1-L21)?
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.
Ah, I just copy the code from other e2e tests code. I removed them, ran 'make lint' command and it was OK. I think I can also remove other unnecessary linters in another PR. :)
feat: add test data fix: add test in setup fix: change the file to PROJECT fix: test file update fix: doc nit and test data feat: Add By to check and project file feat: separate fields feat: use domain when scafflod feat: add plugin arg when re-scaffold fix: function name feat: refactor plugins fix: remove lint fix: domain append
All seems most addressed so moving forward here for @yyy1000 does not get blocked.
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.
/lgtm
/pull-kubebuilder-e2e-k8s-1-27-1 |
/retest |
/test pull-kubebuilder-e2e-k8s-1-27-1 |
Description:
Add e2e tests for kubebuilder alpha generate command.
Motivation:
Validate the functionality and the behavior of the new alpha command that has been merged.