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
10 changes: 9 additions & 1 deletion .evergreen/generated_configs/tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,14 @@ tasks:
UV_PYTHON: "3.13"
tags: [fuzz, fuzz-regression, pr]
- name: fuzz
commands:
- func: run tests
vars:
TEST_NAME: fuzz
SUB_TEST_NAME: fuzz
UV_PYTHON: "3.13"
tags: [fuzz, fuzz-nightly]
- name: fuzz-capture
commands:
- func: run tests
vars:
Expand All @@ -234,7 +242,7 @@ tasks:
- AWS_SECRET_ACCESS_KEY
- AWS_SESSION_TOKEN
type: test
tags: [fuzz, fuzz-nightly]
tags: [fuzz, fuzz-weekly]

# Getdata tests
- name: getdata
Expand Down
7 changes: 7 additions & 0 deletions .evergreen/generated_configs/variants.yml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,13 @@ buildvariants:
run_on:
- rhel8.10-small
batchtime: 1440
- name: fuzz-capture-rhel8
tasks:
- name: .fuzz-weekly
display_name: Fuzz Capture RHEL8
run_on:
- rhel8.10-small
batchtime: 10080

# Green framework tests
- name: green-gevent-rhel8
Expand Down
10 changes: 5 additions & 5 deletions .evergreen/scripts/capture-fuzz-corpus.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/bin/bash
# PYTHON-6178: capture coverage-increasing inputs from a fuzz run and open
# an automated PR growing fuzz/corpus/. Runs as the last command of the
# nightly "fuzz" task, while the scratch corpus exists; manual
# `evergreen patch --variant fuzz-rhel8 --task fuzz` runs capture too.
# weekly "fuzz-capture" task, while the scratch corpus exists; manual
# `evergreen patch --variant fuzz-capture-rhel8 --task fuzz-capture` runs
# capture too.
set -eu

# Same environment as just.sh: venv on PATH for a modern Python.
Expand All @@ -15,12 +16,11 @@ if [ -z "$(ls -A fuzz-scratch/capture 2>/dev/null || true)" ]; then
exit 0
fi

# A unit found by a later target never ran through the earlier ones, so
# replay every unit through all targets before publishing.
# The replay runs the atheris targets, so it must request the fuzz group.
replay=(fuzz-scratch/capture/*)
for target in fuzz_decode fuzz_decode_all fuzz_is_valid; do
echo "Replaying captured units against ${target}..."
if ! uv run --no-sync python "fuzz/${target}.py" "${replay[@]}" \
if ! uv run --group fuzz python "fuzz/${target}.py" "${replay[@]}" \
-artifact_prefix="$PWD/fuzz-scratch/" -atheris_runs="${#replay[@]}"
then
echo "Captured unit fails ${target}; no corpus PR." >&2
Expand Down
31 changes: 23 additions & 8 deletions .evergreen/scripts/generate_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,13 @@ def create_doctests_variants():


def create_fuzz_variants():
# Two variants for the two fuzz flows: the regression reproducers run
# on every PR, the time-boxed fuzzing runs nightly. The nightly variant
# carries no "pr" tag, so PR patch builds never select it, while its
# default patchability keeps it manually runnable
# (`evergreen patch --variant fuzz-rhel8 --task fuzz`). The host needs
# CPython, which the rhel8 toolchain provides.
# Three variants for the three fuzz flows: the regression reproducers run
# on every PR, the time-boxed fuzzing for crash discovery runs nightly,
# and the weekly variant also captures the corpus (opens the automated
# [Fuzz Corpus] PR). The non-pr variants carry no "pr" tag, so PR patch
# builds never select them, while their default patchability keeps them
# manually runnable (`evergreen patch --variant fuzz-rhel8 --task fuzz`).
# The host needs CPython, which the rhel8 toolchain provides.
host = HOSTS["rhel8"]
return [
create_variant(
Expand All @@ -403,6 +404,12 @@ def create_fuzz_variants():
create_variant(
[".fuzz-nightly"], get_variant_name("Fuzz", host), host=host, batchtime=BATCHTIME_DAY
),
create_variant(
[".fuzz-weekly"],
get_variant_name("Fuzz Capture", host),
host=host,
batchtime=BATCHTIME_WEEK,
),
]


Expand Down Expand Up @@ -722,10 +729,18 @@ def create_fuzz_tasks():
test_func = FunctionCall(func="run tests", vars=test_vars)
tasks = [EvgTask(name="fuzz-regression", tags=tags, commands=[test_func])]

# Time-boxed fuzzing against the generated seed corpus.
# Time-boxed fuzzing against the generated seed corpus, for crash
# discovery; corpus capture moved to the weekly fuzz-capture task.
tags = ["fuzz", "fuzz-nightly"]
test_vars = dict(TEST_NAME="fuzz", SUB_TEST_NAME="fuzz", UV_PYTHON="3.13")
test_func = FunctionCall(func="run tests", vars=test_vars)
tasks.append(EvgTask(name="fuzz", tags=tags, commands=[test_func]))

# The weekly capture task fuzzes too (the capture reads the task-local
# fuzz-scratch/ corpus, so it must stay attached to a fuzzing run).
tags = ["fuzz", "fuzz-weekly"]
test_vars = dict(TEST_NAME="fuzz", SUB_TEST_NAME="fuzz", UV_PYTHON="3.13")
test_func = FunctionCall(func="run tests", vars=test_vars)
# PYTHON-6178: while the scratch corpus still exists, capture the new
# coverage-increasing inputs, replay them through every target so a
# unit that fails one is never published, and open an automated PR
Expand All @@ -743,7 +758,7 @@ def create_fuzz_tasks():
"AWS_SESSION_TOKEN",
],
)
tasks.append(EvgTask(name="fuzz", tags=tags, commands=[test_func, capture_cmd]))
tasks.append(EvgTask(name="fuzz-capture", tags=tags, commands=[test_func, capture_cmd]))
return tasks


Expand Down
12 changes: 9 additions & 3 deletions .evergreen/scripts/setup_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,9 +600,10 @@ def handle_test_env() -> None:
zip_path.unlink()
if sub_test_name == "fuzz":
# PYTHON-6178 Also seed from the committed corpus of previously
# captured inputs, so the nightly builds on prior discoveries
# instead of the spec seeds alone. Regression runs (PRs) keep
# running only the reproducers and the spec seed corpus.
# captured inputs, so the nightly and weekly runs build on prior
# discoveries instead of the spec seeds alone. Regression runs
# (PRs) keep running only the reproducers and the spec seed
# corpus.
committed_dir = ROOT / "fuzz" / "corpus"
if committed_dir.is_dir():
for path in sorted(committed_dir.iterdir()):
Expand Down Expand Up @@ -679,6 +680,11 @@ def handle_test_env() -> None:
elif opts.sync == "sync":
TEST_ARGS = f"--ignore=test/asynchronous {TEST_ARGS}"

# pytest>=9.2 caches rewritten modules as hash-based pycs; importlib
# rejects them on FIPS hosts (PYTHON-6287).
if is_set("REQUIRE_FIPS"):
TEST_ARGS = f"--assert=plain {TEST_ARGS}"

write_env("TEST_ARGS", TEST_ARGS)
write_env("UV_ARGS", " ".join(UV_ARGS))

Expand Down
5 changes: 2 additions & 3 deletions .evergreen/scripts/setup_uv.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
elsewhere on PATH may be invisible to later steps, so setup never accepts it
as-is.

This runs under the host's system python3, which may be older than our minimum supported version.
This runs under the host's system python3, which may be as old as Python 3.6 (RHEL 8).
Keep it free of __future__ imports and other 3.7+ syntax. test_setup_uv.py checks this.
"""

from __future__ import annotations

import os
import re
import shlex
Expand Down
29 changes: 20 additions & 9 deletions .evergreen/scripts/test_generate_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,32 +443,43 @@ def test_non_standard_cov_tasks_have_no_cov_companions():
def test_fuzz_task_wiring():
"""Test the fuzz task wiring.
Two fuzz variants: the pr-tagged regression variant runs the reproducers on
every PR; the nightly variant (which also captures the corpus) carries no
"pr" tag, so PR patch builds never select it, while its default patchability
keeps it manually runnable (`evergreen patch --variant fuzz-rhel8 --task fuzz`).
Three fuzz flows: the pr-tagged regression variant runs the reproducers
on every PR; the nightly variant fuzzes for crash discovery; the weekly
variant also captures the corpus. The non-pr variants carry no "pr" tag,
so PR patch builds never select them, while their default patchability
keeps them manually runnable
(`evergreen patch --variant fuzz-rhel8 --task fuzz`).
"""
tasks = [task for task in all_tasks() if "fuzz" in (task.tags or [])]
assert [task.name for task in tasks if "pr" in (task.tags or [])] == ["fuzz-regression"]
assert [task.name for task in tasks if "pr" not in (task.tags or [])] == ["fuzz"]
assert [task.name for task in tasks if "pr" not in (task.tags or [])] == [
"fuzz",
"fuzz-capture",
]
variants = generate_config.create_fuzz_variants()
assert len(variants) == 2
regression, nightly = variants
assert len(variants) == 3
regression, nightly, capture_variant = variants
assert variant_selects(regression, tasks[0])
assert "pr" in (regression.tags or [])
assert variant_selects(nightly, tasks[1])
assert nightly.batchtime == generate_config_utils.BATCHTIME_DAY
assert variant_selects(capture_variant, tasks[2])
assert capture_variant.batchtime == generate_config_utils.BATCHTIME_WEEK
# Webhook PR patch builds only select pr-tagged variants.
assert not nightly.tags
assert not capture_variant.tags
# The nightly fuzz task is crash discovery only: its last command is
# the "run tests" FunctionCall, with no capture command.
assert tasks[1].commands[-1].func == "run tests"
# The capture subprocess bootstraps the comment-bot github app, whose
# secrets live in AWS Secrets Manager: it needs the assumed-role
# credentials (as resync_specs and backport-pr also pass them).
capture = tasks[1].commands[-1]
capture = tasks[2].commands[-1]
env_vars = capture.params["include_expansions_in_env"]
for var in ("AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"):
assert var in env_vars, f"capture subprocess missing {var}"
# The capture no longer keys off is_patch: manual patch runs must
# capture too, and the nightly variant never runs in a PR build.
# capture too, and the weekly variant never runs in a PR build.
assert "is_patch" not in env_vars


Expand Down
15 changes: 15 additions & 0 deletions .evergreen/scripts/test_setup_uv.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from __future__ import annotations

import ast
import importlib.util
import os
import shutil
Expand Down Expand Up @@ -521,3 +522,17 @@ def test_main_pinned_self_overwrite_runs_from_copy(tmp_path, project):
assert proc.returncode == 0, proc.stderr
assert (bin_dir / "uv").exists()
assert f"installed-from=uv{PIN}\n" in log.read_text()


def test_setup_uv_supports_python_36():
"""setup_uv.py runs under the host's system python3, 3.6 on RHEL8 (PYTHON-6286)."""
# feature_version checks grammar only; it does not validate __future__
# feature names, so scan for those imports explicitly.
tree = ast.parse(SETUP_UV.read_text(), filename=str(SETUP_UV), feature_version=(3, 6))
futures = [
alias.name
for node in ast.walk(tree)
if isinstance(node, ast.ImportFrom) and node.module == "__future__"
for alias in node.names
]
assert not futures, f"Python 3.6 rejects these __future__ imports: {futures}"
Loading
Loading