-
Notifications
You must be signed in to change notification settings - Fork 486
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
tests: introduce golden tests in kong chart #953
Conversation
90186ba
to
c1e6ef8
Compare
587b96d
to
e2c8cc6
Compare
1f547f3
to
ef1689d
Compare
Is there a way to have it run automatically and add the diff set (either as an actual commit or as a PR comment)? Or trigger it on demand? KIC changes often don't result in a change to the end output Kong configuration, but changes to the templates almost always do unless they're outside test coverage. Refactors that aren't expected to result in changes (such as the consolidation of Services into a shared function) are more the exception than the rule. |
Do you mean some workflow that would automatically commit changes when golden tests fail so that no one has to run I wouldn't like to block #947 on it. |
I would suggest us not try to automate this to an extent where no developer action is necessary to update the golden files because that IMHO defeats the purpose of those. Having a manual target like |
Yeah, that was the initial idea to make it work the same way it works in KIC. That is basically what this PR introduces. I understand that Travis' point is that it will be too much to remember to run |
I agree with this approach, which can indeed help us move forward more safely. I am considering another possibility, whether introducing tools like helm-unittest can achieve the same effect. |
This looks interesting 🤔 One major difference that I can see immediately between helm-unittest and this PR is that here we'd be diffing and asserting on the full contents of generated templates where in the former we'd only be testing what we define in our test cases. This has both pros and cons. I'd love to hear @czeslavo's thoughts on this as he's the one that invested his time in proposing this framework. |
I didn't consider |
I tried using I also discovered we're not the first to bump into the same limitations - there's I'd suggest going with the solution we have in this PR (it's not that much code in the end) and considering switching to |
That makes sense. Thanks for checking those @czeslavo! 🙇 In that case let's go with the approach proposed in this PR and see how it works for us in the long run. |
// invoking this test (or using `make test.golden.update`). | ||
func TestGolden(t *testing.T) { | ||
helm.AddRepo(t, &helm.Options{}, "bitnami", "https://charts.bitnami.com/bitnami") | ||
_, err := helm.RunHelmCommandAndGetOutputE(t, &helm.Options{}, "dependencies", "build", "../", "--skip-refresh") |
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 would be nice to include the mention of helm dependencies build
being called and the reason for that.
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.
Yes, good point. Added a comment. 👍
bff7684
to
44c13bd
Compare
44c13bd
to
fe6e2e7
Compare
Co-authored-by: Patryk Małek <[email protected]>
fe6e2e7
to
dd28ce6
Compare
In the meantime, our issue in the |
Closed in favor of #978. |
What this PR does / why we need it:
Introduces golden test case that renders
kong/kong
chart templates using testci/*-values.yaml
and compares them with golden outputs stored incharts/kong/test/testdata/golden
directory. The golden files can be regenerated withmake test.golden.update
.It should allow us to easily inspect changes in the output manifests that we make by introducing changes to templating, default values, etc., and catch potential mistakes.
Which issue this PR fixes
Follow up to #947.
Special notes for your reviewer:
Checklist
[Place an '[x]' (no spaces) in all applicable fields. Please remove unrelated fields.]
main
branch.