Repository navigation
Differential testing/fuzz testing for comparing python and rust - #396
prestomation wants to merge 2 commits into
Conversation
…tions Run the same inputs through openjd.model and openjd.model._v1 and compare the results: the openjd-specifications samples, its conformance cases, and a seeded set of generated templates. known_differences.yaml lists the known differences; any other difference fails the tests. Run: hatch run test-subset test/openjd/differential, or python scripts/run_differential.py --generated N --seed S for a report. Signed-off-by: prestomation <prestomation@users.noreply.github.com>
…ntial The generator now draws 2^63 as an INT spelling and adds a NONCONTIGUOUS CHUNK[INT] parameter to some steps (with TASK_CHUNKING declared). Two new known-difference classes describe what that finds: - int-2^63: v0 keeps 9223372036854775808, v1 clamps it to 9223372036854775807. Expression Language 1.2.1 makes int a 64-bit signed integer, so both sides are wrong. - noncontiguous-chunk-split: v0 and v1 put the leftover values in other chunks (10 values at 3: v0 3,2,3,2, v1 3,3,2,2). Template Schemas 3.4.1.5 does not decide the split. Matchers can now compare the integers that two range texts list (values: same/differ), and match the template or the definition of the differing task parameter. Both new classes come before range-expr-spelling, whose patterns match any two range texts. Run against openjd-specifications f2de506, 5000 generated cases (seed 1): 6364 cases, 4968 agree, 1396 differ, 0 new, no stale class. Signed-off-by: prestomation <prestomation@users.noreply.github.com>
| wrong: spec | ||
| evidence: Template Schemas 3.4.1 says the written form is not part of the value, but it reaches {{Param.X}} | ||
| match: | ||
| - v0: "^[-0-9,: ]+$" |
There was a problem hiding this comment.
Should fix: The range-expr-spelling matcher accepts any two strings made of digits, -, ,, : and spaces. That covers every INT job or task parameter value, because v0 and v1 both carry those as strings.
Example: v1 regresses and writes task value "4" where v0 writes "3", or a job INT parameter is off by one. Both cases get classified as range-expr-spelling instead of NEW, so the differential misses the exact bug class it exists to catch. The planted-change test only checks .tasks.count, so it can't detect this hole.
Fix: limit the class to texts that list the same integers, which the matcher already supports:
- v0: "^[-0-9,: ]+$"
v1: "^[-0-9,: ]+$"
values: same| assert not stale, f"known classes that no case shows any more (delete them): {stale}" | ||
|
|
||
|
|
||
| @pytest.mark.fuzz |
There was a problem hiding this comment.
Should fix: The README and the module docstring say this Hypothesis test only runs with -m fuzz. Nothing deselects the fuzz marker, though: addopts has no -m "not fuzz" and there is no conftest hook. So hatch run test and CI run it on every PR.
It draws 300 random seeds on each run. Any seed that hits an unclassified difference fails an unrelated PR at random, and the run also adds full v0+v1 pipeline time under the 30 s --timeout.
Fix: skip it unless the marker is selected, e.g. a conftest.py hook that skips fuzz items when config.option.markexpr lacks fuzz. Or add -m 'not fuzz' to the default test command.
| assert all(c.summary()["path"].endswith(".tasks.count") for c in new) | ||
|
|
||
|
|
||
| @pytest.mark.xfail( |
There was a problem hiding this comment.
Nit: This strict-xfail test records a v1-vs-v0 behaviour gap, but it lives in the differential suite. The repo convention (AGENTS.md) puts gap tests in test/openjd/model_v1/test_known_gaps.py, so they are tracked in one place and get moved out when fixed. Move it there.
|
Claude review · advisory Reviewed Open: 0 blocking · 2 should-fix · 1 nit. ❌ Address or reply to the open threads. Fix or reply to each thread; the next revision's review re-checks open threads and resolves those it agrees are handled. Resolving a thread yourself also closes it. Later revisions review only what changed. |
What was the problem/requirement? (What/Why)
I've found some more differences between python and rust implementation of openjd and wanted to find a more mechanized way to root out the rest of these differences
What was the solution? (How)
This PR proposes an additional test suite to compare parameter spaces between python and rust implementations to find differences. It compares the sample jobs, the conformance suite, as well as a fuzz suite to find differences not otherwise covered by our static data set
This change is in the python repo as this is the current dependency direction, the python version already has access to both implementations.
What is the impact of this change?
We will have more confidence that we are identifying the long-tail of differences between these two implementations
How was this change tested?
I ran it locally to find differences which are ignored for now so we can fix the backlog of found issues.
n/a
n/a
Is this a breaking change?
n/a
Does this change impact security?
no
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.