Open muyuan0 opened 1 year ago
Pros of the current testdata/*yaml style of unit tests
Cons
Having felt the pain of the changing 100 files, which does take hours to fix, I still prefer the yaml approach because its very easy to share the envoy config with someone so they can repro the entire setup on envoy very easily
is it crazy if we add a utility in gateway-api
and xds-translator
to write out the expected out
yaml 🙃 ? I say this while Im changing 100 files in gateway-api
thanks to https://github.com/envoyproxy/gateway/pull/1153 atm
Yes. We can have the Pros of the current testdata/*yaml style while reducing the Cons, by splitting them according to the listen/route/cluster and more sections. So if a test only wants to check a specific section, it can only write the section into the expected file. In the future, we can provide an expected struct to only compare part of the output data.
This issue has been automatically marked as stale because it has not had activity in the last 30 days.
Description:
The current xds translator test doesn't have corresponding requireXXX settings (though it has requireSecrets): https://github.com/envoyproxy/gateway/blob/73e38e0a2811146671d503bc53ac363a81d29d50/internal/xds/translator/translator_test.go#L148-L156
For each test case, all four xds types need to be specific. This causes lots of duplicate files and a heavier burden to update them later.
lots of duplicate files
Using rdfind shows us a result like that:
We can find out that almost every HTTPFilter test cases share the same listener xds as the http-route case. It's expected as the HTTPFilter doesn't affect the listener.
a heavier burden to update them later
For example, https://github.com/envoyproxy/gateway/pull/1095 needs to update over ten out files. As the number of test cases is growing, maybe the next time we have to update tens of files.
If the refactoring is permitted, I will take on it.
[optional Relevant Links:]