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 .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ For new tutorials or tutorial cases:
- [ ] I followed the [tutorial folder structure](https://precice.org/community-contribute-to-precice.html#contributing-tutorials)
- [ ] I added/updated the tutorial `README.md`
- [ ] I added/updated the tutorial `metadata.yaml`
- [ ] I added tests in `tools/tests/tests.yaml`
- [ ] I added tests in `tests/tests.yaml`
- [ ] I submitted a pull request to the website with:
- An entry in [`_config.yaml`](https://github.com/precice/precice.github.io/blob/master/_config.yml)
- A [sidebar entry](https://github.com/precice/precice.github.io/blob/master/_data/sidebars/tutorial_sidebar.yml)
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/generate-reference-results.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ jobs:
rm -rf ./*
rm -rf ./.??*
ls -la ./
- name: Check out Tutorials for the system tests (tools/tests/)
- name: Check out Tutorials for the system tests (tests/)
uses: actions/checkout@v7
with:
ref: ${{ inputs.from_ref }}
lfs: true
fetch-depth: 0
- name: Install Python dependencies
run: |
pip install --user -r tools/tests/requirements.txt
pip install --user -r tests/requirements.txt
- name: Cleanup Docker cache
if: ${{ inputs.clean_docker == 'TRUE' }}
# Remove all Docker containers, images, and build caches
Expand All @@ -80,7 +80,7 @@ jobs:
docker system prune --all --force
- name: Run tests
run: |
cd tools/tests
cd tests
SUITES_ARGS=()
if [ -n "${{ inputs.suites }}" ]; then
SUITES_ARGS+=(--suites "${{ inputs.suites }}")
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/system-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ jobs:
run: |
echo "Initiated by: ${{ github.actor }}"
echo "Test suites: ${{ inputs.suites}}"
echo "System tests branch (tools/): ${{ inputs.system_tests_branch }}"
echo "System tests branch (tests/): ${{ inputs.system_tests_branch }}"
echo "System tests log level: ${{ inputs.log_level }}"
echo "Uploading the runs folder on success: ${{ inputs.upload_artifacts }}"
echo "Running the following command inside tutorials/tools/tests/:"
echo "Running the following command inside tutorials/tests/:"
echo "python3 systemtests.py --build_args=${{inputs.build_args}} --suites=${{ inputs.suites}}"
echo "All workflow inputs: ${{ toJSON(github.event.inputs) }}"
- name: Prepare the Markdown step summary
Expand All @@ -41,11 +41,11 @@ jobs:
echo "Job inputs:"
echo "- Initiated by: @${{ github.actor }}"
echo "- Test suites: \`${{ inputs.suites}}\`"
echo "- System tests branch (\`tools/\`): [\`${{ inputs.system_tests_branch }}\`](https://github.com/precice/tutorials/tree/${{ inputs.system_tests_branch }})"
echo "- System tests branch (\`tests/\`): [\`${{ inputs.system_tests_branch }}\`](https://github.com/precice/tutorials/tree/${{ inputs.system_tests_branch }})"
echo "- System tests log level: \`${{ inputs.log_level }}\`"
echo "- Uploading the runs folder on success: \`${{ inputs.upload_artifacts }}\`"
echo ""
echo "Running the following command inside \`tutorials/tools/tests/\`:"
echo "Running the following command inside \`tutorials/tests/\`:"
echo "\`\`\`"
echo "python3 systemtests.py --build_args=${{inputs.build_args}} --suites=${{ inputs.suites}}"
echo "\`\`\`"
Expand All @@ -63,7 +63,7 @@ jobs:
rm -rf ./*
rm -rf ./.??*
ls -la ./
- name: Check out Tutorials for the system tests (tools/tests/)
- name: Check out Tutorials for the system tests (tests/)
uses: actions/checkout@v7
with:
repository: precice/tutorials
Expand All @@ -75,10 +75,10 @@ jobs:
/home/precice/runners_root/scripts/map_origin_to_local.sh ./
- name: Install Python dependencies
run: |
pip install --user -r tools/tests/requirements.txt
pip install --user -r tests/requirements.txt
- name: Run tests
run: |
cd tools/tests
cd tests
python systemtests.py --build_args=${{ inputs.build_args}} --suites=${{ inputs.suites}} --log_level=${{ inputs.log_level}}
cd ../../
- name: Archive system test logs
Expand Down
22 changes: 11 additions & 11 deletions tools/tests/README.md → tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The [System tests (manual)](https://github.com/precice/tutorials/actions/workflo

On the workflow page, click `Run workflow`. The default values will execute the `release` test suite using the latest `develop` branches of every component. If you want to override the version of some component, specify it in the respective field. Commit hashes, branches, and tags are all accepted. Branches and tags will get automatically resolved to their current commit on GitHub before starting any test, and all tests will use the same version of any common component.

The available test suites are found in [`tests.yaml`](https://github.com/precice/tutorials/blob/develop/tools/tests/tests.yaml) and common values are:
The available test suites are found in [`tests.yaml`](https://github.com/precice/tutorials/blob/develop/tests/tests.yaml) and common values are:

- `quickstart`, `elastic-tube-1d`, or any other tutorial (see [exceptions](https://github.com/precice/tutorials/issues/448))
- `openfoam-adapter`, `micro-manager`, `fmi-runner`, or similar test cases involving the respective component
Expand Down Expand Up @@ -53,13 +53,13 @@ More arguments are available, for example:
gh workflow run system-tests-manual.yml -f suites=release -f build_args="PLATFORM:ubuntu2404,PRECICE_REF:develop" -f log_level="DEBUG" --ref=develop
```

The `build_args` override the defaults set in `tools/tests/components.yaml`.
The `build_args` override the defaults set in `tests/components.yaml`.

### Running locally

To run locally, you will need Docker, Docker Compose, and Python 3.

Navigate into the directory `tools/tests/` of the tutorials, make a Python virtual environment, and install the dependencies:
Navigate into the directory `tests/` of the tutorials, make a Python virtual environment, and install the dependencies:

```bash
python -m venv .venv && source .venv/bin/activate
Expand Down Expand Up @@ -102,7 +102,7 @@ When the tests fail at the results comparison step, this typically means that th
- `diff-results/`: Numerical difference of the results in the two directories (computed with `fieldcompare dir --diff precice-exports/ reference/`). These are only present on failed comparisons.
- `iterations-logs/`: The `precice-*-iterations.log` files of the test run. Only present in test cases using implicit coupling. The comparisons to references only take into account the file SHA-256 checksums.

To reproduce the comparison locally, use the [same fieldcompare command](https://github.com/precice/tutorials/blob/develop/tools/tests/docker-compose.field_compare.template.yaml):
To reproduce the comparison locally, use the [same fieldcompare command](https://github.com/precice/tutorials/blob/develop/tests/docker-compose.field_compare.template.yaml):

```bash
fieldcompare dir \
Expand Down Expand Up @@ -130,7 +130,7 @@ When a system test fails in CI, download the **full** artifact:

```text
runs/
├── tools/ # Dockerfiles and helpers (shared)
├── tests/ # Dockerfiles and helpers (shared)
└── <tutorial>_<cases>_<timestamp>/ # one folder per system test
├── docker-compose.tutorial.yaml
├── docker-compose.field_compare.yaml # written at build time when compare is configured
Expand All @@ -143,7 +143,7 @@ runs/

To re-run one test locally:

1. Extract the zip and keep the `runs/` layout (the test folder needs the sibling `tools/` directory).
1. Extract the zip and keep the `runs/` layout (the test folder needs the sibling `tests/` directory).
2. `cd` into the test folder.
3. Run `./rerun-system-test.sh` (or `sh rerun-system-test.sh`).

Expand All @@ -157,7 +157,7 @@ Fieldcompare requires reference results in the artifact. If not already unpacked

### Adding new tests

Tests and test suites are defined in [`tests.yaml`](https://github.com/precice/tutorials/blob/develop/tools/tests/tests.yaml). By convention, every tutorial defines a test suite with the same name as its directory, and several test cases using combinations of the available participants. These test cases are later referenced by other test suites: these are typically the `release` and the test suites of different tested components.
Tests and test suites are defined in [`tests.yaml`](https://github.com/precice/tutorials/blob/develop/tests/tests.yaml). By convention, every tutorial defines a test suite with the same name as its directory, and several test cases using combinations of the available participants. These test cases are later referenced by other test suites: these are typically the `release` and the test suites of different tested components.

The available cases are listed in the `metadata.yaml` of each tutorial. To add a new tutorial case as a test, add it to `metadata.yaml` and then define a test using it. Include that test in the relevant test suites.

Expand All @@ -171,7 +171,7 @@ run-before: ./set-case.sh 1d3d

You will need to define a reference results file. The reference results can and should be generated on GitHub using the [Generate reference results (manual)](https://github.com/precice/tutorials/actions/workflows/generate-reference-results-manual.yml) workflow for the respective test suite. You might want to temporarily set the `selected` test suite for requesting results only for a subset of test cases.

By default, the [Generate reference results (manual)](https://github.com/precice/tutorials/actions/workflows/generate-reference-results-manual.yml) workflow uses `TUTORIALS_REF` from [`reference_versions.yaml`](https://github.com/precice/tutorials/blob/develop/tools/tests/reference_versions.yaml). For a feature branch, set Use tutorials from to `workflow branch`, or pass `TUTORIALS_REF` via `--build_args` (locally) or the optional `build_args` workflow input.
By default, the [Generate reference results (manual)](https://github.com/precice/tutorials/actions/workflows/generate-reference-results-manual.yml) workflow uses `TUTORIALS_REF` from [`reference_versions.yaml`](https://github.com/precice/tutorials/blob/develop/tests/reference_versions.yaml). For a feature branch, set Use tutorials from to `workflow branch`, or pass `TUTORIALS_REF` via `--build_args` (locally) or the optional `build_args` workflow input.

{% note %}
The two options cannot be combined: defining any overrides to `reference_versions.yaml` will ignore the option to use the tutorials from the workflow branch.
Expand Down Expand Up @@ -280,7 +280,7 @@ Metadata and workflow/script files:
- `solid-openfoam/`
- ...
- `metadata.yml`: describes each case directory (which participant, which component, which script to run, ...)
- `tools/tests/`
- `tests/`
- `component-templates/`: jinja2 templates for Docker Compose services for the components
- `calculix-adapter.yaml`
- `fenics-adapter.yaml`
Expand All @@ -297,7 +297,7 @@ Metadata and workflow/script files:

User-facing tools:

- `tools/tests/`
- `tests/`
- `systemtests.py`: Executes the system tests, starting Docker Compose services of each required component (after building them), running each test, and comparing the results to reference results.
- `print_test_suites.py`: Prints the available tests.
- `print_metadata.py`: Prints the metadata of each tutorial that contains a `metadata.yaml` file.
Expand All @@ -308,7 +308,7 @@ User-facing tools:

Implementation scripts:

- `tools/tests/`
- `tests/`
- `systemtests.py`: Main entry point
- `requirements.txt`: Dependencies (jinja2, pyyaml)
- `metadata_parser/`: Reads the YAML files into Python objects (defines the schema)
Expand Down
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions tests/paths.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from pathlib import Path
PRECICE_TUTORIAL_DIR = Path(__file__).parent.parent
PRECICE_TESTS_RUN_DIR = Path(__file__).parent.parent / "runs"
PRECICE_TESTS_DIR = Path(__file__).parent
PRECICE_TOOLS_DIR = Path(__file__).parent.parent / "tools"
PRECICE_REL_OUTPUT_DIR = "precice-exports"
PRECICE_REL_REFERENCE_DIR = "reference-results-unpacked"
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Pinned Python dependency versions for this tutorial participant.
# Reference only: run scripts keep using loose requirements.txt constraints.
# Generated by tools/releasing/update-requirements-reference.py — do not edit manually.
# Source: tools/tests/requirements.txt
# Source: tests/requirements.txt
# Generated: 2026-07-13T16:48:40Z

jinja2==3.1.6
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -333,14 +333,14 @@ def __get_docker_services(self) -> Dict[str, str]:

def render_service_template_per_case(case: Case, params_to_use: Dict[str, str]) -> str:
# Inside the individual system test directory (`self.system_test_dir`)
# we copy a full `tools/` tree into the parent run directory
# (see __copy_tools). From the point of view of the system test
# we copy a full `tests/` tree into the parent run directory
# (see __copy_tools_and_tests). From the point of view of the system test
# directory we therefore need to go one level up to reach the
# shared `tools/` folder:
# <run_directory>/tools/tests/dockerfiles/<PLATFORM>
# shared `tests/` folder:
# <run_directory>/tests/dockerfiles/<PLATFORM>
# ^-------------^ parent of self.system_test_dir
dockerfile_context_relative = (
Path("..") / "tools" / "tests" / "dockerfiles" / Path(plaform_requested)
Path("..") / "tests" / "dockerfiles" / Path(plaform_requested)
)

render_dict = {
Expand Down Expand Up @@ -381,7 +381,7 @@ def __get_docker_compose_file(self):
# absolute – it will be resolved relative to the system test
# directory.
'dockerfile_context': (
Path("..") / "tools" / "tests" / "dockerfiles" / Path(self.params_to_use.get("PLATFORM"))
Path("..") / "tests" / "dockerfiles" / Path(self.params_to_use.get("PLATFORM"))
),
'precice_output_folder': PRECICE_REL_OUTPUT_DIR,
}
Expand All @@ -404,7 +404,7 @@ def __get_field_compare_compose_file(self):
# absolute – it will be resolved relative to the system test
# directory.
'dockerfile_context': (
Path("..") / "tools" / "tests" / "dockerfiles" / Path(self.params_to_use.get("PLATFORM"))
Path("..") / "tests" / "dockerfiles" / Path(self.params_to_use.get("PLATFORM"))
),
}
jinja_env = Environment(loader=FileSystemLoader(PRECICE_TESTS_DIR))
Expand Down Expand Up @@ -531,16 +531,27 @@ def __copy_tutorial_into_directory(self, run_directory: Path):
file.write(ref_requested)
self._checkout_ref_in_subfolder(PRECICE_TUTORIAL_DIR, self.tutorial.path, current_ref)

def __copy_tools(self, run_directory: Path):
destination = run_directory / "tools"
def __copy_tools_and_tests(self, run_directory: Path):
src = PRECICE_TOOLS_DIR
destination = run_directory / "tools"
logging.debug(f"Copying tools from {src} to {destination}")
try:
shutil.copytree(src, destination)
except FileExistsError as e:
logging.debug(f"Tools directory has already been copied to the workspace - skipping.")
except Exception as e:
logging.warning(f"Something went wrong while copying the tools directory to the workspace: {e}")

src = PRECICE_TESTS_DIR
destination = run_directory / "tests"
logging.debug(f"Copying tests from {src} to {destination}")
try:
shutil.copytree(src, destination)
except FileExistsError as e:
logging.debug(f"Tests directory has already been copied to the workspace - skipping.")
except Exception as e:
logging.warning(f"Something went wrong while copying the tests directory to the workspace: {e}")

def __put_gitignore(self, run_directory: Path):
# Create the .gitignore file with a single asterisk
gitignore_file = run_directory / ".gitignore"
Expand Down Expand Up @@ -798,7 +809,7 @@ def __archive_fieldcompare_diffs(self) -> None:
)

def __copy_rerun_system_test_script(self) -> None:
"""Copy tools/tests/rerun-system-test.sh into the run directory for artifact replay."""
"""Copy tests/rerun-system-test.sh into the run directory for artifact replay."""
rerun_src = PRECICE_TESTS_DIR / "rerun-system-test.sh"
if not rerun_src.is_file():
raise FileNotFoundError(
Expand Down Expand Up @@ -1062,7 +1073,7 @@ def __prepare_for_run(self, run_directory: Path):
if not self._run_hook('run-before', self.run_before):
raise RuntimeError(f"run-before hook failed for {self}")
self.__apply_max_time_override()
self.__copy_tools(run_directory)
self.__copy_tools_and_tests(run_directory)
self.__put_gitignore(run_directory)
host_uid, host_gid = self.__get_uid_gid()
self.params_to_use['PRECICE_UID'] = host_uid
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tools/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
CODE=0

# Check tutorials
IGNORE="tools|quickstart"
IGNORE="tests|tools|quickstart"
tutorials=$(find . -maxdepth 1 -type d -not -name ".*" | grep -vE $IGNORE | sed "s/^.\///")

for tutorial in $tutorials; do
Expand Down
7 changes: 0 additions & 7 deletions tools/tests/paths.py

This file was deleted.