Skip to content

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

Conversation

edwintorok
Copy link
Contributor

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.

:: test_of_string ~name all_enum old_to_string of_string_opt

(*
Created by:
Copy link
Contributor

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?

@edwintorok edwintorok changed the base branch from master to feature/epoll February 15, 2024 10:57
@edwintorok edwintorok changed the base branch from feature/epoll to feature/perf February 15, 2024 14:20
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>
@edwintorok edwintorok force-pushed the private/edvint/record_util_test branch from f0cf193 to f209e3e Compare February 16, 2024 11:19
Copy link

codecov bot commented Feb 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (13258e5) 49.07% compared to head (f209e3e) 49.07%.

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           
Flag Coverage Δ
python2.7 53.38% <ø> (ø)
python3.11 55.85% <ø> (ø)

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.

@edwintorok
Copy link
Contributor Author

Rebased on latest master, will merge to feature branch once CI passes.

@edwintorok edwintorok merged commit 0605d24 into xapi-project:feature/perf Feb 16, 2024
Copy link

pytype_reporter extracted 50 problem reports from pytype output

.

You can check the results of the job here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants