-
Notifications
You must be signed in to change notification settings - Fork 65
🌱 test: Improve registry+v1 render regression test #2103
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
base: main
Are you sure you want to change the base?
🌱 test: Improve registry+v1 render regression test #2103
Conversation
✅ Deploy Preview for olmv1 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
9be93c2
to
f32fc0e
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2103 +/- ##
==========================================
+ Coverage 73.59% 73.60% +0.01%
==========================================
Files 78 78
Lines 7260 7260
==========================================
+ Hits 5343 5344 +1
+ Misses 1567 1566 -1
Partials 350 350
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
311dab9
to
36ae501
Compare
f7a2e82
to
0abdf8f
Compare
0abdf8f
to
1ea2527
Compare
@@ -1,7 +0,0 @@ | |||
## registry+v1 bundle generation regression tests |
There was a problem hiding this comment.
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
6d713af
to
8a66074
Compare
@@ -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/... |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
// go run generate-manifests.go -output-dir=./testdata/expected-manifests/ | ||
// | ||
// Note: Expected output should never change unless the renderer changes which is unlikely. | ||
// If the covert_test.go test fails, it likely means a regression was introduced in the renderer. | ||
func main() { | ||
bundleRootDir := "testdata/bundles/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we move testdata/bundle and testdata/expected-manifests under testdata/regression-test or something like that? Just keep those two directories grouped under the same heading/purpose
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should keep this test data in test/regression/convert/.
This way, it's clear the data is only for the convert test.
If one day we have another regression test that also needs this data (which seems unlikely; it is very specific use case), then we can move it to the main regression/ folder.
That would show it's shared by more than one test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's all good - I thought it was in the /testdata. This is perfect!
8a66074
to
53bc28d
Compare
/approve |
[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 |
cmd.Stdout = os.Stdout | ||
|
||
err := cmd.Run() | ||
require.NoError(t, err, "failed to generate manifests") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
557687a
to
588183d
Compare
81ab25f
to
6a69f7c
Compare
6a69f7c
to
ad34d8d
Compare
Simplify and fix render regression test
make verify
.make verify
is used for codegen (go fmt
,controller-gen
, etc), not for regenerating testdata that should never change.See context
This PR:
testdata/
, following Go test conventions.Safer, clearer, and avoids mistakes in reviews.