Skip to content

Conversation

camilamacedo86
Copy link
Contributor

@camilamacedo86 camilamacedo86 commented Jul 16, 2025

Simplify and fix render regression test

  • Old test made it easy to overwrite expected files via make verify.
  • In all Operator Framework projects, make verify is used for codegen (go fmt, controller-gen, etc), not for regenerating testdata that should never change.
    See context
  • Expected manifests should only change when renderer logic changes on purpose.

This PR:

  • Moves bundles and expected output under testdata/, following Go test conventions.
  • Makes it clear the ArgoCD bundle is used only for this regression test.
  • Adds a proper test that runs the renderer and checks the output matches the expected YAMLs.

Safer, clearer, and avoids mistakes in reviews.

@camilamacedo86 camilamacedo86 requested a review from a team as a code owner July 16, 2025 02:10
@openshift-ci openshift-ci bot requested review from bentito and oceanc80 July 16, 2025 02:11
Copy link

netlify bot commented Jul 16, 2025

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit 5a007e9
🔍 Latest deploy log https://app.netlify.com/projects/olmv1/deploys/688b0da68a37f300081a8564
😎 Deploy Preview https://deploy-preview-2103--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 project configuration.

Copy link

codecov bot commented Jul 16, 2025

Codecov Report

❌ Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.84%. Comparing base (4382db6) to head (5a007e9).
⚠️ Report is 13 commits behind head on main.

Files with missing lines Patch % Lines
test/regression/convert/generate-manifests.go 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2103      +/-   ##
==========================================
- Coverage   73.59%   72.84%   -0.75%     
==========================================
  Files          78       79       +1     
  Lines        7260     7340      +80     
==========================================
+ Hits         5343     5347       +4     
- Misses       1567     1644      +77     
+ Partials      350      349       -1     
Flag Coverage Δ
e2e 43.50% <ø> (+0.04%) ⬆️
experimental-e2e 56.21% <ø> (+0.04%) ⬆️
unit 58.22% <0.00%> (-0.61%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@camilamacedo86 camilamacedo86 force-pushed the remove-bundles-argo branch 7 times, most recently from 311dab9 to 36ae501 Compare July 16, 2025 07:17
@camilamacedo86 camilamacedo86 force-pushed the remove-bundles-argo branch 3 times, most recently from f7a2e82 to 0abdf8f Compare July 16, 2025 13:12
@camilamacedo86 camilamacedo86 changed the title (NOT MERGE) - Test 🌱 test: replace ArgoCD manifest regression test with mock-based resource validation Jul 16, 2025
@camilamacedo86 camilamacedo86 changed the title 🌱 test: replace ArgoCD manifest regression test with mock-based resource validation 🌱 test: Improve registry+v1 render regression test Jul 22, 2025
@@ -1,7 +0,0 @@
## registry+v1 bundle generation regression tests
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we do not need the readme anymore
now, the code is documented and we can clarify on it directly to simplify

@camilamacedo86 camilamacedo86 force-pushed the remove-bundles-argo branch 2 times, most recently from 6d713af to 8a66074 Compare July 22, 2025 00:46
Makefile Outdated
@@ -252,6 +246,10 @@ test-unit: $(SETUP_ENVTEST) envtest-k8s-bins #HELP Run the unit tests
$(UNIT_TEST_DIRS) \
-test.gocoverdir=$(COVERAGE_UNIT_DIR)

.PHONY: test-regression
test-regression: #HELP Run regression test
go test -count=1 -v ./test/regression/...
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We now have a dedicated directory for regression tests, so it's easy to add more cases in the future.
It also makes it very clear what this test does and why it's there.

Copy link
Contributor

Choose a reason for hiding this comment

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

This does not appear to be invoked in any CI, specifically, this is only included in test, which is something we only do locally.

Copy link
Contributor Author

@camilamacedo86 camilamacedo86 Jul 24, 2025

Choose a reason for hiding this comment

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

I did not realise that we did not call make test in the CI :-(
Good catcher 💯

Since we have a specific action for unit tests and can, in the future, expand the regression tests to cover other scenarios, I added a new action to call this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tmshort could we move forward with this one now?

@@ -172,15 +172,9 @@ generate: $(CONTROLLER_GEN) #EXHELP Generate code containing DeepCopy, DeepCopyI
$(CONTROLLER_GEN) --load-build-tags=$(GO_BUILD_TAGS) object:headerFile="hack/boilerplate.go.txt" paths="./..."

.PHONY: verify
verify: k8s-pin kind-verify-versions fmt generate manifests crd-ref-docs generate-test-data #HELP Verify all generated code is up-to-date. Runs k8s-pin instead of just tidy.
Copy link
Contributor Author

@camilamacedo86 camilamacedo86 Jul 22, 2025

Choose a reason for hiding this comment

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

If make verify failed in CI, most people would just run it locally and push the changes — that’s normal since verify usually runs things like go fmt, vet, and controller-gen (as in all OF projects). But it was also re-generating regression test output — which should never change or at least very unlikely change. Then:

  • If that output changed because of a bug, we could accidentally miss it and merge a regression.
  • It also wasn’t clear to reviewers that files in testdata/expected-manifests/ should never be edited or auto-regenerated.
  • Expecting everyone to remember to check that manually is risky and easy to miss.

@perdasilva
Copy link
Contributor

/approve

Copy link

openshift-ci bot commented Jul 22, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: perdasilva

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 22, 2025
cmd.Stdout = os.Stdout

err := cmd.Run()
require.NoError(t, err, "failed to generate manifests")
Copy link
Contributor

Choose a reason for hiding this comment

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

Spawning go run generate-manifests.go inside your test will recompile the whole helper and is fairly slow. You could factor the logic in generate-manifests.go into a package and call that from the test binary. This will surface compile-time errors directly in the test binary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback!

You're right — using go run generate-manifests.go is a bit slower since it recompiles the helper. I timed it, and it's around ~500ms to 2 seconds faster, but feels fine for this test since it only runs once, not per test case.

We now have a stronger check in place for renderer output, and I think it's solid enough to move forward with this version. I do agree that may have hall for improvements, but it might be more effort than it's worth at the moment.

That said, I’d be happy if someone wants to improve it later!

WDYT — okay to move forward for now?


if err := os.RemoveAll(outputRootDir); err != nil {
if err := os.RemoveAll(*outputRootDir); err != nil {
fmt.Printf("error removing output directory: %v\n", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

should this direct to stderr so it doesn't mix with stdout at some point, or maybe even import log and log.Fatalf

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test was failing because it couldn't remove a temporary directory.

I don’t think that should be a hard failure — if this happens in CI, the container will be cleaned up anyway when the job ends. It’s not critical to the test result itself.

I also added the directory to .gitignore to make sure we don’t accidentally commit it in any case.

@camilamacedo86 camilamacedo86 force-pushed the remove-bundles-argo branch 2 times, most recently from 557687a to 588183d Compare July 22, 2025 18:15
@camilamacedo86 camilamacedo86 force-pushed the remove-bundles-argo branch 3 times, most recently from 6a69f7c to ad34d8d Compare July 24, 2025 20:59
Comment on lines 26 to 31
- uses: codecov/codecov-action@v5.4.3
with:
disable_search: true
files: coverage/unit.out
flags: unit
token: ${{ secrets.CODECOV_TOKEN }}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need the codecov action here. This could inadvertently trigger codecov to think it's received all its data before the (real) tests complete. If you want this here, you should increase the value here:

after_n_builds: 3

Copy link
Contributor

Choose a reason for hiding this comment

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

The number 3 corresponds to test-unit, test-e2e and test-experimental-e2e.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting now, I think I understand better why codev instead of the old coveralls :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should either use it if we are covering more within

Screenshot 2025-07-31 at 07 25 17

All done !

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually interesting, the experimental-e2e isn't creating it's own directory, it's sharing it with e2e, so I there' still 3 files, which I'm not sure if it corresponds to three pushes...

However, I'm not sure it's a good idea to code cover the test harness, as that gives a false impression of code coverage (either positive or negative).
Regardless, I'll let this pass.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we add more tests here, will we not be covering more scenarios and more areas of the code each time?
I think we need to fix the experimental-e2e. I can look at that in a follow-up.
Could you LGTM this one for we get it merged?

@camilamacedo86 camilamacedo86 force-pushed the remove-bundles-argo branch 3 times, most recently from d561cd1 to f90c10b Compare July 31, 2025 06:29
@tmshort
Copy link
Contributor

tmshort commented Jul 31, 2025

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 31, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit 1e513ca into operator-framework:main Jul 31, 2025
22 checks passed
@camilamacedo86 camilamacedo86 deleted the remove-bundles-argo branch July 31, 2025 20:15
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. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants