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

Integration test for CronJob #66937

Merged
merged 1 commit into from
Sep 24, 2018

Conversation

mortent
Copy link
Member

@mortent mortent commented Aug 2, 2018

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:

test/integration: add a basic test for covering CronJobs

@k8s-ci-robot k8s-ci-robot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 2, 2018
@wgliang
Copy link
Contributor

wgliang commented Aug 2, 2018

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 2, 2018
@neolit123
Copy link
Member

/sig testing

@mortent please add a release note in the first message under Release note: explaining what this change is - e.g. test/integration: add a basic test for covering CronJobs

@k8s-ci-robot k8s-ci-robot added sig/testing Categorizes an issue or PR as relevant to SIG Testing. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Aug 3, 2018
@mortent
Copy link
Member Author

mortent commented Aug 6, 2018

/assign @MrHohn

@MrHohn
Copy link
Member

MrHohn commented Aug 6, 2018

Would be great to have folks from @kubernetes/sig-apps-pr-reviews to review.

@k8s-ci-robot k8s-ci-robot added the sig/apps Categorizes an issue or PR as relevant to SIG Apps. label Aug 6, 2018
Copy link
Contributor

@soltysh soltysh left a 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.
Copy link
Contributor

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"
Copy link
Contributor

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{}) {
Copy link
Contributor

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))
Copy link
Contributor

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()
Copy link
Contributor

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()
Copy link
Contributor

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))
Copy link
Contributor

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.
Copy link
Contributor

Choose a reason for hiding this comment

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

2018

@soltysh soltysh self-assigned this Aug 28, 2018
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 1, 2018
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 1, 2018
@mortent mortent force-pushed the CronJobIntegrationTest branch 2 times, most recently from 87beb5a to 2c56021 Compare September 2, 2018 15:54
@mortent
Copy link
Member Author

mortent commented Sep 3, 2018

/retest

Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

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

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 4, 2018
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel comment for consistent failures.

@k8s-ci-robot k8s-ci-robot merged commit b223e88 into kubernetes:master Sep 24, 2018
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. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/testing Categorizes an issue or PR as relevant to SIG Testing. 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.

None yet

7 participants