Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/test-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -688,14 +688,16 @@ jobs:
# the pyver job has a copy of this awk: keep the two in sync
awk -F'\t' '
NR == 1 { next }
$1 == "TOTAL" { passed = $2; failed = $3; err = $4; notyet = $5; na = $6; skipped = $7; tot = 1; next }
$1 == "TOTAL" { passed = $2; failed = $3; err = $4; notyet = $5; na = $6; skipped = $7; tot = 1; if (match($8, /flaky_race=[0-9]+/)) race = substr($8, RSTART + 11, RLENGTH - 11); next }
$8 ~ /^FLAKY-CRASH/ { flaky = flaky " " $1 "(" $8 ")"; next }
$8 != "" { bad = bad " " $1 "(" $8 ")" }
END {
if (!tot) { print "no TOTAL row" > "/dev/stderr"; exit 1 }
printf "parity %s py%s: passed=%s failed=%s error=%s notyet=%s na_jvm=%s skipped=%s\n", ENVIRON["KEY"], ENVIRON["PY"], passed, failed, err, notyet, na, skipped
# a file that crashed and passed when run once more: the leg may pass, the summary says it did only because of the retry
if (flaky != "") printf "FLAKY-CRASH (died without a result, passed on the one retry; first exit code in brackets):%s\n", flaky
# tests that passed only after the rerun of the known engine race (issue 409): printed, never a failure
if (race + 0 != 0) printf "FLAKY-RACE (tests that passed only after a rerun of the known engine race of ArcadeData/arcadedb-python#409): %s\n", race
if (bad != "") { print "files with a status:" bad > "/dev/stderr"; exit 1 }
if (passed + 0 == 0 || failed + 0 != 0 || err + 0 != 0) exit 1
# this repository accepts no skips; NOTYET and NA-JVM are the two counted kinds of the native build
Expand Down Expand Up @@ -1102,14 +1104,16 @@ jobs:
# the same awk as the gate of the test job: keep the two in sync
awk -F'\t' '
NR == 1 { next }
$1 == "TOTAL" { passed = $2; failed = $3; err = $4; notyet = $5; na = $6; skipped = $7; tot = 1; next }
$1 == "TOTAL" { passed = $2; failed = $3; err = $4; notyet = $5; na = $6; skipped = $7; tot = 1; if (match($8, /flaky_race=[0-9]+/)) race = substr($8, RSTART + 11, RLENGTH - 11); next }
$8 ~ /^FLAKY-CRASH/ { flaky = flaky " " $1 "(" $8 ")"; next }
$8 != "" { bad = bad " " $1 "(" $8 ")" }
END {
if (!tot) { print "no TOTAL row" > "/dev/stderr"; exit 1 }
printf "parity %s py%s: passed=%s failed=%s error=%s notyet=%s na_jvm=%s skipped=%s\n", ENVIRON["KEY"], ENVIRON["PY"], passed, failed, err, notyet, na, skipped
# a file that crashed and passed when run once more: the leg may pass, the summary says it did only because of the retry
if (flaky != "") printf "FLAKY-CRASH (died without a result, passed on the one retry; first exit code in brackets):%s\n", flaky
# tests that passed only after the rerun of the known engine race (issue 409): printed, never a failure
if (race + 0 != 0) printf "FLAKY-RACE (tests that passed only after a rerun of the known engine race of ArcadeData/arcadedb-python#409): %s\n", race
if (bad != "") { print "files with a status:" bad > "/dev/stderr"; exit 1 }
if (passed + 0 == 0 || failed + 0 != 0 || err + 0 != 0) exit 1
# this repository accepts no skips; NOTYET and NA-JVM are the two counted kinds of the native build
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/development/ci.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ The workflow `test-native.yml` builds the native image of the `arcadedb` package
* A push to `main` (only when a native path changed, same filter as a pull request), the nightly run (skipped when nothing changed in the last 25 hours, except on Mondays) and a manual run (dispatch) run all four platforms: `linux-x86_64`, `linux-aarch64`, `macos-arm64` and `windows-x64` (Python 3.12 and 3.14). A release (`release-native.yml` calls the workflow with `release: true`) runs the same four platforms on all four Python versions, 16 legs.
* The `pyver` job installs the already built `linux-x86_64` wheel (no rebuild) into the Pythons that the full parity runs of the event leave out (3.11 and 3.13 on a push to `main`, the nightly run and a dispatch; none on a release) into 3.15 and into the free-threaded 3.14t, and runs 13 test files there (14 where polars installs; 3.15 has no jpype1 wheel, so it leaves out the two files that need jpype1), about 20 seconds of tests per Python. A release needs it: a `pyver` leg that passes uploads the marker `native-passed-pyver-py<version>` (it holds the file name of the wheel the leg installed), and `Verify what may be published` in `release-native.yml` requires the markers of 3.15 and 3.14t, the two legs of a release, and that both tested the `linux-x86_64` wheel that is published. A red leg stops a release before anything reaches PyPI. A pull request runs only two legs of this job, Python 3.11 and 3.14 (the oldest and the newest): 3.13, 3.15 and 3.14t run in the full tier. In the 30 days before issue 442 no `pyver` leg was red on a commit where the parity suite on Linux x86-64 was green. Only `linux-x86_64` is checked on these two Pythons: the other platforms are not tested on 3.15 and 3.14t, and the JVM package has no such job. The 3.14t leg has no polars (no free-threaded wheel exists), so it skips `test_dataframe_ingest.py`. `scripts/select_native_matrix.py` decides its legs, and `tests/test_select_native_matrix.py` and `tests/test_release_native_verify.py` pin the gate.
* Every test file runs in its own process (`native/wheel/parity_wheel.py`). A process that dies without writing its result is a `CRASH` row in `parity-wheel.tsv` with its exit code, for example `CRASH(rc=0xC0000005,3221225477)`, and it fails the leg. On the Windows legs only (the crashes of issue 295 happen there), the harness runs such a file once more in a fresh process (`--retry-crash`). A retry that produces a result is a `FLAKY-CRASH` row: the gate lets the leg pass, the job summary lists the file with the first exit code, and on a release or a dispatch the `crash-report` job adds one comment to issue 295 (run URL, Python, wheel version, exit codes). A second crash, a failing test, a timeout and every crash on Linux or macOS stay failures. A process that wrote its result and then died in shutdown is a `DIRTY-EXIT` record (exit code, file, attempt) in the metadata, the job summary and the issue comment: it is not retried and does not fail the leg. Each Windows test process also writes a faulthandler trace, `parity-wheel-xml/<file>.attemptN.fault.txt`, into the parity artifact of the leg. Only a retry hides a crash, so treat a `FLAKY-CRASH` as an open bug: read the trace in the artifact before a release is announced.
* The four tests of `tests/test_vector_read_your_writes.py` run again when they hit a known engine race, on both packages (issue 409). The engine of 26.11.1 can miss a vector that a commit has just returned: a graph rebuild trims it between the two phases of its commit. The fix is pull request 12087 of ArcadeData/arcadedb, which is in no release yet, and the test must keep detecting the race, so it is not skipped. The rerun is in the tests (`run_with_known_race_rerun` in `tests/conftest.py`), not in a workflow, so every job that runs the file has it: the parity harness and the plain runs of the JVM build. A test body runs again on a fresh database, at most twice, and only when it failed with one of the three messages of the race (`committed vectors were not found`, `Vector search failed`, `+Record #<rid> not found+`). Any other failure, and a test that fails all three runs, fails the job. Each rerun is a `UserWarning` that names issue 409 in the warnings summary of the log. A test that passed only after a rerun carries the junit property `flaky_race`: the `TOTAL` row of `parity-wheel.tsv` counts it as `flaky_race=N`, the gate step prints a `FLAKY-RACE` line, and the `crash-report` job lists the tests in the job summary. A count never fails a leg. The rerun goes when the engine release that contains the fix is out and the file has passed 100 consecutive scheduled runs; then issue 409 is closed.
* The `examples` job runs every script of `examples/` against the installed wheel of each platform (Python 3.12 and 3.14; a pull request: no leg, or `linux-x86_64` on Python 3.12 when it changes the examples or their runner) through `scripts/run_examples.sh`, the runner that `test-python-examples.yml` uses too. `scripts/native_examples_skip.txt` lists, with a reason, the examples that need the JVM package. `Examples summary` is the one check for all its legs. These legs do not decide what a release publishes.
* A native image build takes about 5 to 30 minutes for each platform (macOS is the slowest). The organisation shares one runner limit with upstream ArcadeDB, so do not add runs lightly. Change the paths or the matrix of `test-native.yml` only for a reason that you can write down.

Expand Down
54 changes: 49 additions & 5 deletions native/wheel/parity_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
crash stays CRASH and fails the leg. A failing test, a TIMEOUT and a BADXML are never retried. The decision is native/wheel/parity_crash.py.
On Windows each process also writes a faulthandler trace to <name>.attemptN.fault.txt next to its XML (tests/conftest.py,
ARCADEDB_TEST_FAULTHANDLER_FILE); an empty one is deleted. Beside the table, <out stem>.meta.json lists the wheel, the Python and every crash.
A test that passed only after tests/conftest.py's rerun of the known engine race (issue 409) carries the junit property `flaky_race`: the TOTAL line
counts those tests as flaky_race=N, the log prints a ::warning:: for each, and the metadata lists them. A count, never a failure.
"""

import argparse
Expand All @@ -33,6 +35,9 @@
# On Windows the test process writes a faulthandler trace to this file (tests/conftest.py, native backend only).
FAULT_FILE_ENV = "ARCADEDB_TEST_FAULTHANDLER_FILE"

# The junit property of a test that passed after a rerun of the known engine race (tests/conftest.py KNOWN_RACE_PROPERTY); the value is the reruns it took.
RACE_PROPERTY = "flaky_race"


def parse_args(argv=None):
p = argparse.ArgumentParser()
Expand Down Expand Up @@ -134,6 +139,35 @@ def count_xml(xml):
return c, fails


def race_events(xml, name):
"""One record per test of a junit XML that passed only after the known engine race rerun (the property `flaky_race`); [] when the XML does not parse."""
found = []
try:
for tc in ET.parse(xml).getroot().iter("testcase"):
if tc.find("failure") is not None or tc.find("error") is not None:
continue
for prop in tc.iter("property"):
if prop.get("name") == RACE_PROPERTY:
found.append(
{
"file": name,
"test": tc.get("name"),
"reruns": prop.get("value"),
}
)
except ET.ParseError:
return []
return found


def total_row(tot):
"""The TOTAL line of the table: the counts, then the status column (timeouts, flaky_crash, crash, flaky_race; the gate reads only the counts)."""
return (
f"TOTAL\t{tot['passed']}\t{tot['failed']}\t{tot['error']}\t{tot['notyet']}\t{tot['na_jvm']}\t{tot['skipped']}\t"
f"timeouts={tot['timeout']} flaky_crash={tot['flaky_crash']} crash={tot['crash']} flaky_race={tot['flaky_race']}\t\t\t\n"
)


def main(argv=None):
a = parse_args(argv)
pkg = os.path.abspath(a.repo)
Expand Down Expand Up @@ -196,8 +230,10 @@ def main(argv=None):
f"CRASH RETRY: on, a file that dies without a result is run once more (at most {policy.budget} files)",
flush=True,
)
rows, events = [], []
tot = dict.fromkeys([*COUNT_KEYS, "timeout", "flaky_crash", "crash"], 0)
rows, events, races = [], [], []
tot = dict.fromkeys(
[*COUNT_KEYS, "timeout", "flaky_crash", "crash", "flaky_race"], 0
)

for f in files:
name = os.path.basename(f)
Expand Down Expand Up @@ -300,6 +336,10 @@ def attempt(n):
tot["timeout"] += out.timed_out
tot["flaky_crash"] += out.flaky
tot["crash"] += out.hard_crash
# the XML on disk is the one of the last attempt, which is the one that counts
file_races = race_events(xml, name) if out.final.result else []
tot["flaky_race"] += len(file_races)
races.extend(file_races)
ev = pc.event_of(name, out, c["failed"] + c["error"])
if ev:
ev.update(traces_of(name, xmldir, range(1, len(out.attempts) + 1)))
Expand All @@ -319,6 +359,11 @@ def attempt(n):
f"the run once more: {'a result' if out.final.result else 'no result again'} ({pc.format_rc(out.final.rc)})",
flush=True,
)
for race in file_races:
print(
f"::warning::{name}: {race['test']} passed only after {race['reruns']} rerun(s) of the known engine race (ArcadeData/arcadedb-python#409)",
flush=True,
)
for n, at in enumerate(out.attempts, 1):
if pc.dirty_exit(at):
print(
Expand All @@ -333,9 +378,7 @@ def attempt(n):
fh.write(
f"{name}\t{c['passed']}\t{c['failed']}\t{c['error']}\t{c['notyet']}\t{c['na_jvm']}\t{c['skipped']}\t{status}\t{';'.join(fails[:40])}\t{attempts}\t{pc.format_rc(rc)}\n"
)
fh.write(
f"TOTAL\t{tot['passed']}\t{tot['failed']}\t{tot['error']}\t{tot['notyet']}\t{tot['na_jvm']}\t{tot['skipped']}\ttimeouts={tot['timeout']} flaky_crash={tot['flaky_crash']} crash={tot['crash']}\t\t\t\n"
)
fh.write(total_row(tot))
with open(os.path.splitext(a.out)[0] + ".meta.json", "w") as fh:
json.dump(
{
Expand All @@ -347,6 +390,7 @@ def attempt(n):
"source_commit": ident.get("source_commit", ""),
"retry_crash": policy.enabled,
"crash_events": events,
"race_events": races,
},
fh,
indent=1,
Expand Down
69 changes: 66 additions & 3 deletions native/wheel/report_flaky_crash.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
The comment is a log, not a gate: when the token cannot write issues, or gh fails for any other reason, the script prints a `::warning::`
line and still exits 0. It never fails the run. The text carries no em dash.

The same meta files list the tests that passed only after the rerun of the known engine race (`race_events`, issue 409). Those are a count, not a
crash: the summary gets one table for them, nothing is posted on any issue, and a run with such tests and no crash still ends green.

python native/wheel/report_flaky_crash.py --artifacts <dir with the downloaded artifacts> [--summary <file>] [--dry-run]
"""

Expand Down Expand Up @@ -56,6 +59,49 @@ def load_events(root: str) -> list[dict]:
return events


def load_race_events(root: str) -> list[dict]:
"""Every test of every leg under `root` that passed only after the rerun of the known engine race, each with its leg's identity."""
races = []
for path in sorted(glob.glob(os.path.join(root, "**", META), recursive=True)):
try:
with open(path, encoding="utf-8") as fh:
meta = json.load(fh)
except (OSError, ValueError):
continue # load_events has already printed the warning for this file
artifact = os.path.basename(os.path.dirname(path))
for ev in meta.get("race_events", []):
races.append(
{
**ev,
"leg": meta.get("key") or artifact,
"python": meta.get("python", ""),
"wheel": meta.get("wheel_version", ""),
}
)
return races


def race_md(races: list[dict]) -> str:
"""The job summary block for the known engine race (issue 409); empty when no test needed a rerun."""
if not races:
return ""
out = [
"### Known engine race reruns",
"",
f"**FLAKY-RACE: {len(races)} test(s) passed only after a rerun of the known engine race of ArcadeData/arcadedb-python#409.** "
"The rerun is in tests/conftest.py (at most two reruns, only for the three messages of the race); it is a count, not a failure. "
"Each rerun is also a UserWarning in the log of its test file.",
"",
"| leg | Python | wheel | file | test | reruns |",
"|---|---|---|---|---|---|",
]
for r in races:
out.append(
f"| {r['leg']} | {r['python']} | {r['wheel']} | `{r['file']}` | `{r['test']}` | {r['reruns']} |"
)
return "\n".join(out) + "\n"


def _table(events: list[dict]) -> list[str]:
lines = [
"| leg | Python | wheel | file | first exit code | retry |",
Expand Down Expand Up @@ -179,8 +225,19 @@ def post_comment(body: str, run=subprocess.run) -> tuple[bool, str]:
return True, ""


def report(events, env, summary_path="", dry_run=False, run=subprocess.run) -> int:
"""Write the summary, post the comment when allowed. Returns 0: a log is never a gate."""
def report(
events, env, summary_path="", dry_run=False, run=subprocess.run, races=()
) -> int:
"""Write the summary, post the comment when allowed. Returns 0: a log is never a gate.

`races` (the tests that passed after a rerun of the known engine race) only add a block to the summary; they never post anything.
"""
if races:
race_text = race_md(list(races))
print(race_text, flush=True)
if summary_path:
with open(summary_path, "a", encoding="utf-8") as fh:
fh.write(race_text)
if not events:
print("no crash event in this run", flush=True)
return 0
Expand Down Expand Up @@ -232,7 +289,13 @@ def main(argv=None) -> int:
ap.add_argument("--dry-run", action="store_true")
a = ap.parse_args(argv)
try:
return report(load_events(a.artifacts), os.environ, a.summary, a.dry_run)
return report(
load_events(a.artifacts),
os.environ,
a.summary,
a.dry_run,
races=load_race_events(a.artifacts),
)
except Exception as err: # noqa: BLE001 - a log is never a gate
print(
f"::warning::the crash report failed: {type(err).__name__}: {err}",
Expand Down
Loading
Loading