-
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
🌱 Added e2e tests for alpha generate command for scaffolded data #4554
base: master
Are you sure you want to change the base?
🌱 Added e2e tests for alpha generate command for scaffolded data #4554
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: manalilatkar The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Welcome @manalilatkar! |
Hi @manalilatkar. 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-sigs/prow repository. |
test/e2e/alphagenerate/ci.sh
Outdated
kind export kubeconfig --kubeconfig $tmp_root/kubeconfig --name $KIND_CLUSTER | ||
export KUBECONFIG=$tmp_root/kubeconfig | ||
|
||
test_cluster -v -ginkgo.v |
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 tests under test/e2e have already been executed in the prow, so we do not need a GitHub action or a new script for those.
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.
Removed file.
2101761
to
de4c4c7
Compare
/ok-to-test |
It is nice; It seems that your changes passed the tests. |
@camilamacedo86 Thanks. Working on the CLA. Have to get internal approval from my organization. Will try to finish it asap. |
Thank you a lot |
@camilamacedo86 My CLA is done. Can you please review and let me know if any changes need to be done? |
test/e2e/utils/test_context.go
Outdated
@@ -246,6 +246,29 @@ func (t *TestContext) Destroy() { | |||
} | |||
} | |||
|
|||
// DestroyOutputDir is written separately to ensure the deletion | |||
// of the output directory in case of scaffolded projects | |||
func (t *TestContext) DestroyOutputDir() { |
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 have already:
kubebuilder/test/e2e/utils/test_context.go
Lines 229 to 247 in de4c4c7
func (t *TestContext) Destroy() { | |
//nolint:gosec | |
// if image name is not present or not provided skip execution of docker command | |
if t.ImageName != "" { | |
// Check white space from image name | |
if len(strings.TrimSpace(t.ImageName)) == 0 { | |
log.Println("Image not set, skip cleaning up of docker image") | |
} else { | |
cmd := exec.Command("docker", "rmi", "-f", t.ImageName) | |
if _, err := t.Run(cmd); err != nil { | |
warnError(err) | |
} | |
} | |
} | |
if err := os.RemoveAll(t.Dir); err != nil { | |
warnError(err) | |
} | |
} |
Could we not use what we have?
Then, due to the "output" dir being specific for those tests, do we call the removal on the tests specifically?
Expect(err).NotTo(HaveOccurred()) | ||
Expect(kbc.Prepare()).To(Succeed()) | ||
|
||
projectOutputDir = filepath.Join(kbc.Dir, outputDir) |
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.
Why do we need to create the outputDir?
Can we not call the re-generation in the dir where the project is?
Then we also test it out?
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.
@camilamacedo86 Then should I copy the contents of the scaffolded project to the Kbc.Dir temp directory and let it destroy with the original method. Is that acceptable?
Is it ok if I use https://github.com/otiai10/copy to copy the contents of the scaffolded project or should I write a custom function for that?
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.
Creating the output Dir because I picked up the convention from the test/e2e/generate_test.go file:
projectFilePath = filepath.Join(projectOutputDir, "PROJECT") |
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! 🥇🎉
Just a couple of small nits:
- We can simplify by not creating another directory.
- Running the tests will already create a temp directory stored at kbc.Dir.
- No need to create a new Destroy method since we already have one.
Otherwise, all good LGTM
Can you try to simplify by addressing those nits?
Then, I think after that we can get this one merged.
WDYT?
@@ -0,0 +1,431 @@ | |||
/* |
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.
Because this change does not impact end users ( we are not changing the scaffolds ) we use :🌱:
To know more about see: https://github.com/kubernetes-sigs/kubebuilder/blob/master/CONTRIBUTING.md#pr-process
I hope that you do not mind, I updated the title accordingly.
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. Will keep in mind.
de4c4c7
to
3d5d2eb
Compare
@camilamacedo86 Thanks. Removed the DestroyOutputDir method. Still regenerating the project in the output directory in the testdata project directories as that is the convention used in the tests in est/e2e/generate_test.go file. If I regenerate the project in the same directory, there will be unwanted changes after running the |
creation of TestContext for scaffolded data anddestruction of the regenerated directory
added a makefile entry for running all these commandsadded a github workflow to run these tests on specific changes