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

Increase testability of Reconcilers in Lifecycle-Manager #1852

Open
1 of 2 tasks
Tomasz-Smelcerz-SAP opened this issue Sep 10, 2024 · 1 comment
Open
1 of 2 tasks
Labels
area/quality Related to all activites around quality kind/feature Categorizes issue or PR as related to a new feature.

Comments

@Tomasz-Smelcerz-SAP
Copy link
Member

Tomasz-Smelcerz-SAP commented Sep 10, 2024

Description

Currently the majority of the code involved in the reconciliation loops cannot be unit tested.
We need to find out a way to make them testable.
The outcome of this issue should be:

  • An idea what to do to make our reconcilers unit-testable. It should be applicable to all reconcilers, so that we don't end up with three different approaches for three different reconcilers.
  • A proof of concept: refactoring the Purge Reconciler.

We should be pragmatic: Because reconciliation is coupled to the controller-runtime library and, ultimately, to the K8s environment, it's unlikely that we can unit-test everything. Probably some small amount code used for object lookup, object updates etc. can't be easily unit tested. This is fine - this will be tested by the integration and E2E suites.
What we should aim for is to have the business logic split into many independent functions/methods. Every function should be unit-testable. All behaviors that cannot be tested directly, like client-go functions, should be extracted out as explicit dependencies.

Reasons

Lack of unit tests for the reconciliation means we have to rely on integration and E2E tests. The problem is that these tests are verbose, long-running and slow - in comparison with unit tests.
We also cannot test all required scenarios and corner cases in this way because our test suites would take too much time to execute.
This is causing, among other things, the following problems:

  • we don't have the "support" provided by proper unit tests: clearly documenting expected behaviors vs incorrect ones.
  • all sorts of "code smells" are now visible: tight coupling, low cohesion, blurry responsibilities etc.

All of the above make extending and debugging reconciler's code very hard, especially in the complex cases like the Manifest Reconciler.

Acceptance Criteria

  • Find out a systematic way to refactor the reconciliation code so that it can be unit tested.
  • Verify the approach by refactoring the Purge Reconciler

Feature Testing

No response

Testing approach

No response

Attachments

No response

@Tomasz-Smelcerz-SAP Tomasz-Smelcerz-SAP added kind/feature Categorizes issue or PR as related to a new feature. area/quality Related to all activites around quality labels Sep 10, 2024
@Tomasz-Smelcerz-SAP Tomasz-Smelcerz-SAP changed the title quality: Increase testability of reconcilers Increase testability of Reconcilers in Lifecycle-Manager Sep 10, 2024
@Tomasz-Smelcerz-SAP
Copy link
Member Author

For the systematic way to refactor the code, see:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/quality Related to all activites around quality kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

No branches or pull requests

1 participant