-
Notifications
You must be signed in to change notification settings - Fork 4.2k
chore: add recommender vpa-object-namespace integration test #8348
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
base: master
Are you sure you want to change the base?
chore: add recommender vpa-object-namespace integration test #8348
Conversation
Hi @phuhung273. Thanks for your PR. I'm waiting for a kubernetes 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. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: phuhung273 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 |
038a8b6
to
b123353
Compare
/ok-to-test |
Hey Would it be possible to split this PR into multiple commits for easier review? |
Sure @adrianmoisey, im thinking about:
How do you think ? |
Sounds good to me |
b123353
to
656d363
Compare
I've splitted into 2 commits. Please help take a look @adrianmoisey. Thanks |
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 comments from my side. regarding the integration tests only
// Run a test container to try and contact the Kubernetes api-server from a pod, wait for it | ||
// to flip to Ready, log its output and delete it. | ||
func runKubernetesServiceTestContainer(c clientset.Interface, ns string) { | ||
path := "test/images/clusterapi-tester/pod.yaml" |
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 this path?
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 no idea actually... This file was copied from e2e/v1
. Should I also move these functions to utils ?
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 was the reason for copying it, rather than reusing 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.
No reason, I forgot this file at first 😅 Sorry for this.
IMO, we should reuse it.
By reusing, i mean moving it to utils. We cannot just making it public as importing e2e/v1
will trigger all tests.
|
||
// Run a test container to try and contact the Kubernetes api-server from a pod, wait for it | ||
// to flip to Ready, log its output and delete it. | ||
func runKubernetesServiceTestContainer(c clientset.Interface, ns string) { |
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 don't understand why we need this test. can you please elaborate?
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 file was copied from e2e/v1
. Can we discuss in #8348 (comment) ?
if framework.TestContext.ListImages { | ||
for _, v := range image.GetImageConfigs() { | ||
fmt.Println(v.GetE2EImage()) | ||
} | ||
os.Exit(0) | ||
} |
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'm not sure why this is here. Actually, I don't really understand what's happening in this whole file. Can you please explain?
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 tried to remove this and the test still work. Will remove it.
About the whole file, I can confirm that we need TestMain
and handleFlags
since it will fail parsing params like --disable-log-dump
in go test
command https://github.com/phuhung273/autoscaler/blob/e90e2f377cb8ab74948e287817a79cb5636dff16/vertical-pod-autoscaler/hack/run-integration-locally.sh#L114
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.
Understood. we can just remove this section then
}) | ||
|
||
ginkgo.AfterEach(func() { | ||
f.ClientSet.AppsV1().Deployments(utils.RecommenderNamespace).Delete(context.TODO(), utils.RecommenderDeploymentName, metav1.DeleteOptions{}) |
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.
Don't we need to delete the namespaces we are creating in every test?
like we have in line 54:
ignoredNamespace, err := f.CreateNamespace(context.TODO(), "ignored-namespace", nil)
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.
From what i've seen, namespaces created by f.CreateNamespace
are automatically cleaned up after every test.
I added delete deployment
here since VPA (kube-system) is not automatically cleaned.
ginkgo.By("Ignored namespace should not be recommended") | ||
ignoredVpa, err := vpaClientSet.AutoscalingV1().VerticalPodAutoscalers(ignoredNamespace).Get(context.TODO(), ignoredVpaCRD.Name, metav1.GetOptions{}) | ||
gomega.Expect(err).NotTo(gomega.HaveOccurred()) | ||
gomega.Expect(ignoredVpa.Status.Conditions).Should(gomega.HaveLen(0)) |
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 you please add a comment explaining the logic of this test? It looks like you're creating two namespaces and two VPAs with the same targetRef
. One VPA uses the --ignore-namespace
flag, so it shouldn't generate any recommendations, while the other should. A short comment would help make this more understandable.
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 your summary is correct. Two VPAs have the same targetRef
but theyre in different namespaces.
I just added a comment to the function. Please let me know if it is clear enough. Thanks man.
@@ -145,6 +145,25 @@ func PatchVpaRecommendation(f *framework.Framework, vpa *vpa_types.VerticalPodAu | |||
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "Failed to patch VPA.") | |||
} | |||
|
|||
// NewVPADeployment creates a VPA deployment with n containers | |||
// for e2e test purposes. | |||
func NewVPADeployment(f *framework.Framework, flags []string) *appsv1.Deployment { |
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.
TODO (future PRs)- update this function to receive args as well
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.
Absolutely, right now i have no special config.
|
||
vpa_types "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1" | ||
vpa_clientset "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned" | ||
framework_deployment "k8s.io/kubernetes/test/e2e/framework/deployment" |
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.
Nit: this should be in the section above
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.
Sure i've moved it to above section. Hope I understand your point correctly ?
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 whole file already lives in e2e/v1/e2e.go
with a few minor changes
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 you're correct. Can we discuss in #8348 (comment) to also move functions in this file to utils ?
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Which issue(s) this PR fixes:
Relates #7723
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: