operator-framework / operator-controller

A new and improved management framework for extending Kubernetes with Operators
https://operator-framework.github.io/operator-controller/
Apache License 2.0
61 stars 53 forks source link

🌱 Bundle + CRD Upgrade Safety Tests #1084

Closed dtfranz closed 2 months ago

dtfranz commented 2 months ago

Adds unit test coverage to the bundleutil and crdupgradesafety packages. Also prunes some unused code.

Reviewer Checklist

netlify[bot] commented 2 months ago

Deploy Preview for olmv1 ready!

Name Link
Latest commit 2f877e6836e7f0a37d308f81d799f34f4838d0bf
Latest deploy log https://app.netlify.com/sites/olmv1/deploys/66a7c02d0f003100080f32c6
Deploy Preview https://deploy-preview-1084--olmv1.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 75.31%. Comparing base (ea9ebca) to head (2f877e6). Report is 7 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1084 +/- ## ========================================== + Coverage 72.74% 75.31% +2.57% ========================================== Files 33 31 -2 Lines 1948 1904 -44 ========================================== + Hits 1417 1434 +17 + Misses 381 327 -54 + Partials 150 143 -7 ``` | [Flag](https://app.codecov.io/gh/operator-framework/operator-controller/pull/1084/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=operator-framework) | Coverage Ξ” | | |---|---|---| | [e2e](https://app.codecov.io/gh/operator-framework/operator-controller/pull/1084/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=operator-framework) | `57.72% <ΓΈ> (+1.61%)` | :arrow_up: | | [unit](https://app.codecov.io/gh/operator-framework/operator-controller/pull/1084/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=operator-framework) | `49.68% <ΓΈ> (+4.35%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=operator-framework#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

tmshort commented 2 months ago

Any missed error conditions?

dtfranz commented 2 months ago

Any missed error conditions?

I haven't found a good way to cover the errors from ToUnstructured and FromUnstructured yet.

everettraven commented 2 months ago

I haven't found a good way to cover the errors from ToUnstructured and FromUnstructured yet.

@dtfranz You might be able to create an interface that the CRD Upgrade Safety preflight type takes in as an exported, configurable field and then mock it for testing

dtfranz commented 2 months ago

I haven't found a good way to cover the errors from ToUnstructured and FromUnstructured yet.

@dtfranz You might be able to create an interface that the CRD Upgrade Safety preflight type takes in as an exported, configurable field and then mock it for testing

Was thinking about this but do you think it's worthwhile? It doesn't really buy us that much and would require us to hack up the preflight type just to cover two lines.

The other thing was I could never get those errors to trigger with the json I provided. If the json is invalid, we hit an earlier error, and if the CRD schema inside is invalid it doesn't care at all (it ignores unknown fields by default).

everettraven commented 2 months ago

Was thinking about this but do you think it's worthwhile?

@dtfranz probably not. Covering those 2 lines isn't going to block me from approving