-
Notifications
You must be signed in to change notification settings - Fork 38.8k
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
Integration test for CronJob #66937
Integration test for CronJob #66937
Conversation
/ok-to-test |
/sig testing @mortent please add a release note in the first message under |
/assign @MrHohn |
Would be great to have folks from @kubernetes/sig-apps-pr-reviews to review. |
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 left you some comments.
@@ -0,0 +1,205 @@ | |||
/* | |||
Copyright 2017 The Kubernetes Authors. |
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.
2018
import ( | ||
"encoding/json" | ||
"fmt" | ||
"github.com/golang/glog" |
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.
Split the imports into following groups:
- builtin
- else
- all of kubernetes
See other files for how it's done.
return server, closeFn, cjc, jc, informerset, clientSet, config | ||
} | ||
|
||
func setupGarbageCollector(t *testing.T, config rest.Config, clientSet clientset.Interface, informerset informers.SharedInformerFactory, stopCh chan struct{}) { |
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 we need to setup GC for this test? From my pov this only complicates this test code.
for _, object := range jobs { | ||
j = object.(*batchv1.Job) | ||
bytes, _ := json.Marshal(j) | ||
glog.Info(string(bytes)) |
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.
Remove this debug print, not needed here.
|
||
func validateJobAndPod(t *testing.T, informerSet informers.SharedInformerFactory) { | ||
if err := wait.Poll(10*time.Second, 120*time.Second, func() (bool, error) { | ||
jobs := informerSet.Batch().V1().Jobs().Informer().GetIndexer().List() |
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.
Since you are listing jobs, why not just using regular client and list them each time, any particular reason for informer here?
} | ||
} | ||
|
||
pods := informerSet.Core().V1().Pods().Informer().GetIndexer().List() |
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.
Same here, wrt informers vs list?
for _, object := range pods { | ||
pod := object.(*corev1.Pod) | ||
bytes, _ := json.Marshal(pod) | ||
glog.Info(string(bytes)) |
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.
Ditto - remove.
@@ -0,0 +1,26 @@ | |||
/* | |||
Copyright 2017 The Kubernetes Authors. |
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.
2018
0b75e88
to
5f77bc8
Compare
5f77bc8
to
7051be2
Compare
87beb5a
to
2c56021
Compare
2c56021
to
7e62f73
Compare
/retest |
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
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mortent, soltysh 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 |
/retest Review the full test history for this PR. Silence the bot with an |
What this PR does / why we need it: There are no integration tests covering CronJob. This adds a test with the basic use case and we can add additional tests later.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Special notes for your reviewer:
Release note: