Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
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
2 changes: 1 addition & 1 deletion application/single_app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
EXECUTOR_MAX_WORKERS = 30
CHAT_STREAM_EXECUTOR_MAX_WORKERS = max(8, int(os.getenv('SIMPLECHAT_CHAT_STREAM_WORKERS', '32') or '32'))
SESSION_TYPE = 'filesystem'
VERSION = "0.261.527"
VERSION = "0.261.530"
IS_DEVELOPMENT = is_development_env_enabled()

# Opt-out for deployments where App Service Easy Auth is active but the platform
Expand Down
36 changes: 23 additions & 13 deletions docs/contributing/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,25 +109,35 @@
files);
* it uses a changed module in `functional_tests/test_support/`, directly or
through another support module;
* it refers to an affected application module, by importing it, quoting its name
(`import_module("x")`, `sys.modules["x"]`) or using its path (`x.py`), **and**
it uses one of that module's changed names, or the URL of a changed route.
An application module is affected when it changed, or when it imports an
affected module and uses one of its changed names. In that case its own
changed names are the functions and classes that use them, and so on through
the imports. A version bump in `config.py` therefore selects the tests that
read `VERSION` (and the tests of `app.py`, which uses it at import), not every
test that stubs `config`;
* it refers to an affected application module **and** uses one of that module's
affected names, or the URL of an affected route.
* An application module is affected when it changed, or when it imports an
affected module and uses one of its affected names. The affected names of a
changed module are the functions, classes and assignments that changed and
the ones in the same module that use them. In an importer they are the
definitions that use them, and so on through the imports.
* A test refers to a module by importing it, quoting its name
(`import_module("x")`, `sys.modules["x"]`) or using its path (`x.py`), in
its own text or in the helper code it imports from other test files and
from `test_support` (a fixture, a harness class and what those use).
* A test uses a name alone or after a dot (`planner.plan_request`), in its own
text or in that helper code.

A version bump in `config.py` therefore selects the tests that read
`VERSION`, the tests of the functions that write it into what they produce,
and the tests of `app.py`, which uses it at import. It does not select every
test that stubs `config`, or the tests that only check a version floor with
`assert_app_version_at_least`;
* it names a changed template, script, stylesheet or V2 UI file by file name;
* or it is `test_functional_suite_ci_runner.py`, which checks the CI itself.

A change to the test infrastructure runs every file. That covers
`functional_tests/conftest.py`, the known-failures plugin, `run_tests.py`,
`select_tests.py`, the requirements files and the workflow. Typical pull requests
select 250–350 of the 2,000 files, which should take about 10 minutes compared
with about 27 for every file. A
change to something much of the application uses, such as `get_settings`,
selects 750 or more.
select 400–450 of the 2,040 files, in five jobs of about 10 minutes, compared
with about 27 minutes for every file. A
change to something much of the application uses, such as `get_settings` or
anything `log_event` reads, selects 1,200 or more.

Check warning on line 140 in docs/contributing/testing.md

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains security control, sanitization, or audit marker. Recommendation%3A Confirm the change does not weaken auth, CSRF, CSP, XSS defenses, settings sanitization, redaction, audit logging, or tests.

The same script answers *which tests cover this file?*:

Expand Down
108 changes: 81 additions & 27 deletions docs/explanation/features/FUNCTIONAL_TEST_SELECTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Implemented in version: **0.261.496**

Updated in **0.261.530**: names are followed inside the changed module, on module
objects (`planner.plan_request`) and through the helper code a test imports. See
[FUNCTIONAL_TEST_SELECTION_INDIRECT_DEPENDENCIES_FIX.md](../fixes/FUNCTIONAL_TEST_SELECTION_INDIRECT_DEPENDENCIES_FIX.md).

## Overview and Purpose

Since 0.261.494, every pull request ran all 2,000 Python functional test files,
Expand All @@ -25,7 +29,7 @@
| Selector | `scripts/select_tests.py` | Prints `all` or the test file names a change can affect; `--github-output` also writes the shard plan for the workflow. |
| Runner | `scripts/run_tests.py` | `--files-from selected.txt` limits `functional` to the listed files; a list that says `all` runs every file. |
| Workflow | `.github/workflows/functional-test-suite.yml` | `plan` runs the selector; `python (shard K of N)` runs the selection in up to eight jobs of about 100 files; `functional tests` summarizes every job as one check. |
| Tests | `functional_tests/test_functional_suite_ci_runner.py` | The infrastructure rule, test-support depth, name-level propagation, route prefixes, shard counts and the workflow's branches. |
| Tests | `functional_tests/test_functional_suite_ci_runner.py` | The infrastructure rule, test-support depth, name-level propagation (inside a module, on module objects, through helper code), route prefixes, shard counts and the workflow's branches. |

### How a test file is selected

Expand All @@ -50,33 +54,69 @@
that defines no name, or a file that cannot be compared, makes the whole
module count as changed: every test that refers to it is selected, and every
name it defines counts as changed for its importers.
* An importer of an affected module is affected when its text uses one of the
changed names. Its own changed names are then its definitions that use them.
This repeats through the import graph, which includes lazy imports and
`import_module("x")`.
* A test is selected for an affected module when it refers to the module
(`import x`, `from x import`, the quoted name `"x"`, or the path `x.py`),
**and** it uses one of the module's changed names or requests the URL
prefix of a changed route handler (`/api/groups/` for
`/api/groups/<group_id>/agents`). When the whole module counts as changed,
referring to it is enough.
* **Inside the module**, the affected names are the changed names and the
module's own definitions that use them, at any depth (0.261.530).
`plan_request` builds its messages from `PLANNER_PROMPT_SECTIONS` through

Check warning on line 59 in docs/explanation/features/FUNCTIONAL_TEST_SELECTION.md

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains AI, plugin, agent, or workspace boundary marker. Recommendation%3A Check whether prompts, chat history, uploaded documents, embeddings, citations, settings, or identity can cross a new boundary.
two other functions, so a change to the prompt affects `plan_request`.

Check warning on line 60 in docs/explanation/features/FUNCTIONAL_TEST_SELECTION.md

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains AI, plugin, agent, or workspace boundary marker. Recommendation%3A Check whether prompts, chat history, uploaded documents, embeddings, citations, settings, or identity can cross a new boundary.
* **An importer** of an affected module is affected when one of its
definitions uses an affected name. Its affected names are those definitions
and its own definitions that use them. This repeats through the import
graph, which includes lazy imports and `import_module("x")`. An importer

Check warning on line 64 in docs/explanation/features/FUNCTIONAL_TEST_SELECTION.md

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains secret or sensitive data source marker. Recommendation%3A Pair this source with any nearby network, logging, serialization, or process execution sink before approving.
that renames what it imports (`from x import name as other`) uses it under
that name. One that holds the module itself (`import x as y`,
`import_module("x")`) uses it as `y.name` (0.261.530).
* **A test** is selected for an affected module when it refers to the module
**and** uses one of its affected names, or requests the URL prefix of an
affected route handler (`/api/groups/` for `/api/groups/<group_id>/agents`).

Check warning on line 70 in docs/explanation/features/FUNCTIONAL_TEST_SELECTION.md

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains AI, plugin, agent, or workspace boundary marker. Recommendation%3A Check whether prompts, chat history, uploaded documents, embeddings, citations, settings, or identity can cross a new boundary.
When the whole module counts as changed, referring to it is enough.
* It refers to the module in its own text (`import x`, `from x import`, the
quoted name `"x"`, or the path `x.py`), or through the helper code it can
run (0.261.530). That is the definitions it imports from other test files
and from `test_support`, the definitions those use in their own file,
what they import in turn, and the module-level code of each file on the
way. A test that imports one fixture from a test file depends on that
fixture, not on the whole file.
* It uses a name in its own text, where the name counts as a whole word
alone or after a dot (`planner.plan_request`, 0.261.530), or through that
helper code. In helper code the name must be one Python resolves when the
code runs: an identifier, an attribute (`module.name`), an imported name,
or a string that is exactly the name (`setattr(module, "name", ...)`). A

Check warning on line 83 in docs/explanation/features/FUNCTIONAL_TEST_SELECTION.md

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Moderate - Changed line contains obfuscation, dynamic loading, or hidden payload marker. Recommendation%3A Confirm the changed code is not hiding behavior, decoding payloads, or bypassing normal review.
word in a comment, a docstring or a longer string does not count there,
because helper code is shared by many tests.
5. **Other changed files under `application/`** (templates, scripts, stylesheets,
V2 UI sources): tests that name the file are selected.
6. `test_functional_suite_ci_runner.py` always runs.

Requiring the test to use a changed name is what keeps a version bump small:
about 580 tests mention `config`, mostly to stub it, but only the ones that read
`VERSION` (and the tests of `app.py`, which uses it at import) are selected.
Requiring a changed name is what keeps a version bump from selecting every test
that mentions `config`. A bump selects the tests that read `VERSION`, the tests
of the functions that write it into what they produce, and the tests of
`app.py`, which uses it at import: about 400 files.

### Limits

* A test that reaches changed code without naming its module, a changed name or
a route URL is not selected. For example, it might only call a function that
calls the changed code in another module. The full run on the pull request into
Staging catches it.
* Name matching is textual: a test that uses an unrelated name equal to a changed
one is selected anyway. That costs time, not correctness.
* Selection takes about 15 seconds; every Python job repeats it, so all jobs run
* The selector reads source text and runs nothing. A test is not selected when
the text does not show the path: a module name built at run time, a function
handed over under another name, a fixture from `conftest.py`. The full run on
the pull request into Staging catches it.
* The version helper is not followed on a version bump.
`test_support/versioning.py` finds `VERSION` in `config.py` with a regular
expression, which is not a name the helper resolves. So a bump does not select
a file only because it checks a version floor with
`assert_app_version_at_least`, as about 830 files do; a test that reads
`config.VERSION` itself is selected. Every pull request bumps the version, so
following the helper would add those files to every run.
`test_selector_does_not_follow_the_version_floor_helper_on_a_version_bump`
holds this in place: if the helper starts importing `config`, that test fails.
* Following every path costs time when widely used code changes. A change to
anything `log_event` or `get_settings` uses selects 1,300–1,700 of the 2,043

Check warning on line 111 in docs/explanation/features/FUNCTIONAL_TEST_SELECTION.md

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains security control, sanitization, or audit marker. Recommendation%3A Confirm the change does not weaken auth, CSRF, CSP, XSS defenses, settings sanitization, redaction, audit logging, or tests.
files, because nearly every module calls them.
* Name matching in a test's own text is textual: a test that uses an unrelated
name equal to a changed one is selected anyway. That costs time, not
correctness.
* A changed decorator on a top-level function is not seen as a change to that
function. If nothing else in the module changed, the whole module counts as
changed; if other names changed too, only those are followed.
* Selection takes 20 to 25 seconds; every Python job repeats it, so all jobs run
the same list.

## Usage
Expand All @@ -103,10 +143,24 @@
## Testing and Validation

* `functional_tests/test_functional_suite_ci_runner.py` covers the rules above.
* Run over the 24 pull requests merged into Development before this change, most
selected 255–360 files (about 15% of the suite). Four that changed widely used
code, such as `get_settings`, selected 760–1,215. Two that changed test
infrastructure ran everything.
The paths added in 0.261.530 are tested on a small application and test suite
written for the purpose, and on the six test files whose omission showed the
gap.
* Run over the 25 pull requests merged into Development up to 0.261.525, one
changed test infrastructure and ran everything. Of the other 24:

| Pull requests | Selected before 0.261.530 | Selected now |
|---|---|---|
| 13 that changed little application code | 251–312 | 407–454 |
| 4 in between | 272–450 | 500–648 |
| 7 that changed widely used code | 349–1,278 | 1,229–1,726 |
| Median of the 24 | 300 | 454 |
| Mean of the 24 | 416 | 766 |

Every file selected before is selected now. The 13 small ones grow by about
155 files: a version bump alone now selects 401 files (245 before), because
the functions that write the version into what they produce, and the functions
that call those, are followed.
* With no base to compare with (`--changed`), all of a file counts as changed:
`functions_yamcs_operations.py` selects 141 files, `route_backend_chats.py`
330, `functions_documents.py` 373 and `config.py` 1,147.
`functions_orchestration_planner.py` selects 387 files,
`functions_orchestration_schema.py` 588 and `config.py` 1,690.
Loading
Loading