Skip to content

Commit 6d1470c

Browse files
committed
test: How to run python tests with custom CPU templates
Add documentation explaining how to run python integration tests with custom CPU templates. Signed-off-by: Takahiro Itazuri <[email protected]>
1 parent 078be2a commit 6d1470c

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

tests/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,3 +646,49 @@ sudo env PYTHONPATH=tests HOME=$HOME ~/.local/bin/ipython3 -i tools/sandbox.py -
646646
> \[!WARNING\]
647647
>
648648
> **Notice this runs as root!**
649+
650+
## How to run python tests with custom CPU templates
651+
652+
By placing custom CPU templates under `tests/data/custom_cpu_templates/`
653+
directory, you can run the CI with them for testing / debugging purposes.
654+
655+
Using the pytest keyword filtering option `-k`, you can run only python tests
656+
that use a specific CPU template. For example:
657+
658+
```sh
659+
tools/devtool -y test -- integration_tests/functional -k unique_template_name
660+
```
661+
662+
You can also do it from buildkite using the scripts under `.buildkite/`
663+
directory. The easiest way is to commit custom CPU template JSON files in
664+
question to your forked repo. Note that you should specify platforms on which
665+
the custom CPU templates are expected to work. For example:
666+
667+
```yaml
668+
steps:
669+
- label: "Run test with custom CPU templates"
670+
command: |
671+
.buildkite/pipeline_pr.py \
672+
--instances m6g.metal m7g.metal \
673+
-k unique_template_name \
674+
| buildkite-agent pipeline upload
675+
```
676+
677+
Even without making any commit, you can inject the custom CPU template at
678+
runtime via `--additional-prepend` option of the buildkite step generation
679+
scripts. For example:
680+
681+
```yaml
682+
steps:
683+
- label: "Run test with custom CPU templates"
684+
command: |
685+
.buildkite/pipeline_pr.py \
686+
--instances m6g.metal m7g.metal \
687+
-k unique_template_name \
688+
--additional-prepend 'echo "{\"kvm_capabilities\": [\"170\", \"171\", \"172\"], \"vcpu_features\": [{\"index\": 0, \"bitmap\": \"0b111xxxx\"}]}" > tests/data/custom_cpu_templates/unique_template_name.json \
689+
| buildkite-agent pipeline upload
690+
```
691+
692+
In case that a CPU template written directly looks ugly or too lengthy, an
693+
alternative way is to download or copy it from somewhere at runtime also via the
694+
prepended command, although it is almost same as committing to your forked repo.

0 commit comments

Comments
 (0)