-
Notifications
You must be signed in to change notification settings - Fork 292
Add record_util backwards compatibility test #5349
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
Add record_util backwards compatibility test #5349
Conversation
:: test_of_string ~name all_enum old_to_string of_string_opt | ||
|
||
(* | ||
Created by: |
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.
Maybe include this as a small script?
This will be useful for testing record_util.ml Signed-off-by: Edwin Török <edwin.torok@cloud.com>
…ed case Other enums here accept mixed case, not just lower case. Fixes: 638f58e ("CP-38020: add HOST.set_numa_affinity_policy") Signed-off-by: Edwin Török <edwin.torok@cloud.com>
There are some inconsistencies between enum string values and their declarations, e.g. `balance-slb` (which has special handling in the API generator), or `depth-first` (which does not). We want to automatically generate record_util.ml, but we must ensure backwards compatibility, and the only way to do that is to exhaustively test all the old values in a unit test. This test won't need to be updated when new enum values are introduced: we'll use the automatically generated ones for those already. The `old*` files were created using the following command: ``` cp ocaml/xapi-cli-server/record_util.ml ocaml/tests/record_util/old_record_util.ml && dune build @check --profile=release && grep 'let all_' _build/o\default/ocaml/xapi-types/aPI.ml >|ocaml/tests/record_util/old_enum_all.ml && dune fmt --auto-promote ``` Signed-off-by: Edwin Török <edwin.torok@cloud.com>
Signed-off-by: Edwin Török <edwin.torok@cloud.com>
f0cf193
to
f209e3e
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## feature/perf #5349 +/- ##
=============================================
Coverage 49.07% 49.07%
=============================================
Files 18 18
Lines 2319 2319
=============================================
Hits 1138 1138
Misses 1181 1181
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Rebased on latest master, will merge to feature branch once CI passes. |
pytype_reporter extracted 50 problem reports from pytype output. You can check the results of the job here |
This is a followup on this review comment on the NUMA PR:
#5226 (comment)
It doesn't yet auto-generate record_util, but adds a test that checks that any changes to record_util are fully backwards compatible by exhaustively testing all enum value conversions to and from string.
Exception checks are less strict: if they raise an exception then it must be the same type, but we allow its string argument (and obviously its module name) to be different: this will allow us to improve the error messages in the future without breaking the test.
Last time we tried to auto-generate this (I think by @psafont ) it was difficult to test that it was backwards compatible so lets do test first this time.