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

Cleanup Reconciler Tests in order to pick up Genreconciler updates #706

Merged
merged 2 commits into from
Aug 19, 2020

Conversation

dibyom
Copy link
Member

@dibyom dibyom commented Aug 10, 2020

Changes

This PR has two commits and is needed for #635 :

Merge service and deployment tests into TestReconcile

We had separate tests for reconcileService and reconcileDeployment. These tests
were hard to port with the genreconciler update(#635) which changes the Reconciler
interface. Instead of testing these unexported functions, I merged the test
cases for these into the existing TestReconcile function

Make reconciler tests more readable …

The reconciler tests used variables of the form service1, deployment2 etc.
making it hard to figure out what those objects actually did. This change does
the following:

  1. Adds more descriptive names e.g. eventListenerWithNodeSelector instead of
    eventlistener6

  2. Adds helper functions makeEL, makeDeployment,
    makeService to create the above objects instead of deep-copying and changing
    values

  3. Fixes a bug I found in the process: The tests were setting the
    generatedResourceName in the status of the pre-reconciled resource. Instead it
    should be set by the Reconciler. Without this, we weren't actually testing if
    the status contained the right generatedResourceName

/kind cleanup

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

See the contribution guide for more details.

Release Notes

NONE

@tekton-robot tekton-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels Aug 10, 2020
@tekton-robot tekton-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Aug 10, 2020
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/v1alpha1/eventlistener/eventlistener.go 70.8% 72.5% 1.8

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/v1alpha1/eventlistener/eventlistener.go 70.8% 72.5% 1.8

@dibyom dibyom changed the title WIP: Merge reconciler tests for genreconciler Cleanup Reconciler Tests in order to pick up Genreconciler updates Aug 14, 2020
@dibyom dibyom marked this pull request as ready for review August 14, 2020 19:07
@tekton-robot tekton-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 14, 2020
@dibyom
Copy link
Member Author

dibyom commented Aug 14, 2020

/assign @khrm
/assign @wlynch

We had separate tests for reconcileService and reconcileDeployment. These tests
were hard to port with the genreconciler update(tektoncd#635) which changes the Reconciler
interface. Instead of testing these unexported functions, I merged the test
cases for these into the existing TestReconcile function

Signed-off-by: Dibyo Mukherjee <dibyo@google.com>
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/v1alpha1/eventlistener/eventlistener.go 70.8% 72.5% 1.8

The reconciler tests used variables of the form service1, deployment2 etc.
making it hard to figure out what those objects actually did. This change does
the following:

1. Adds more descriptive names e.g. `eventListenerWithNodeSelector` instead of
`eventlistener6`

2. Adds helper functions `makeEL`, `makeDeployment`,
`makeService` to create the above objects instead of deep-copying and changing
values

3. Fixes a bug I found in the process: The tests were setting the
generatedResourceName in the status of the pre-reconciled resource. Instead it
should be set by the Reconciler. Without this, we weren't actually testing if
the status contained the right `generatedResourceName`.

Signed-off-by: Dibyo Mukherjee <dibyo@google.com>
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/v1alpha1/eventlistener/eventlistener.go 70.8% 72.5% 1.8

@savitaashture
Copy link
Contributor

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 18, 2020
Copy link
Member

@wlynch wlynch left a comment

Choose a reason for hiding this comment

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

Bleh - This is still a bit hard to follow, since the transformation from start to end state are still somewhat obscured since they are not localized with the tests themselves.

That said, this is definitely an improvement from the previous state, so lgtm!

@tekton-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wlynch

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

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 19, 2020
@dibyom
Copy link
Member Author

dibyom commented Aug 19, 2020

Bleh - This is still a bit hard to follow, since the transformation from start to end state are still somewhat obscured since they are not localized with the tests themselves.

Yeap, next PR is to fix that 😄

@dibyom
Copy link
Member Author

dibyom commented Aug 19, 2020

/test tekton-triggers-unit-tests

@tekton-robot tekton-robot merged commit e6db195 into tektoncd:master Aug 19, 2020
@dibyom dibyom deleted the merge branch August 20, 2020 01:24
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. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants