Skip to content

Add runtime test #34

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

Merged
merged 1 commit into from
Jun 16, 2018
Merged

Add runtime test #34

merged 1 commit into from
Jun 16, 2018

Conversation

fanzhangio
Copy link

@fanzhangio fanzhangio commented Jun 13, 2018

  • inject
  • log
  • signals

issue #16

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. 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. labels Jun 13, 2018
@pwittrock
Copy link
Contributor

@fanzhangio please run test.sh and address the failures.


var _ = BeforeSuite(func(done Done) {

testenv = &test.Environment{}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is expensive to bring up just to get a* rest.Config that isn't used for anything.

Instead just create a dummy config with some values filled in.

@fanzhangio
Copy link
Author

@pwittrock I simplified the test suites, and removed the redundant codes.

@fanzhangio fanzhangio changed the title (WIP) Add runtime test Add runtime test Jun 14, 2018
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 14, 2018
It("should set informers", func() {
instance := testSource{
cache: func(c cache.Cache) error {
if c != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should validate that the injected argument is the same as the one you provided.

if s.cache != nil {
return s.cache(c)
}
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably Fail("unexpected call") or something right?

res, err := CacheInto(&informertest.FakeInformers{}, instance)
Expect(err).NotTo(HaveOccurred())
Expect(res).To(Equal(true))
res, err = CacheInto(&informertest.FakeInformers{}, neg)
Copy link
Contributor

@pwittrock pwittrock Jun 14, 2018

Choose a reason for hiding this comment

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

Make it clear what htis is testing with a By("returning false if the type doesn't implement inject.Cache")

Expect(res).To(Equal(true))
res, err = CacheInto(&informertest.FakeInformers{}, neg)
Expect(err).NotTo(HaveOccurred())
Expect(res).To(Equal(false))
Copy link
Contributor

Choose a reason for hiding this comment

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

We should check an error case for when an error is returned.

It("should close stop channel by signal", func() {

stop := SetupSignalHandler()
p, err := os.FindProcess(syscall.Getpid())
Copy link
Contributor

Choose a reason for hiding this comment

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

This is cool, but the handlers aren't setup right it might doing something weird. It also changes the signal handler for the whole process.

How about

  1. write a small program and exec it
  2. mock out the signal.Notify and os.Exit calls as functions that we re-assign.

@pwittrock
Copy link
Contributor

@fanzhangio just did another pass. ptal

@pwittrock
Copy link
Contributor

@fanzhangio FYI, you'll have to do a small rebase with the package name changes.

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 15, 2018
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 15, 2018
@fanzhangio
Copy link
Author

Needs to run dep ensure after the package rebased.
Updated the vendor and deps

@pwittrock pwittrock closed this Jun 16, 2018
@pwittrock pwittrock reopened this Jun 16, 2018
@pwittrock pwittrock added approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Jun 16, 2018
@k8s-ci-robot k8s-ci-robot merged commit e06131a into kubernetes-sigs:master Jun 16, 2018
justinsb pushed a commit to justinsb/controller-runtime that referenced this pull request Dec 7, 2018
DirectXMan12 pushed a commit that referenced this pull request Jan 31, 2020
"kubebuilder create config" not "installer containers"
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. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants