|
2 | 2 |
|
3 | 3 | ## Usage |
4 | 4 |
|
5 | | -Invoke `make bats` in the root of this repository. |
| 5 | +Review the `TEST_*` variables [at around the top of the Makefile](https://github.com/NVIDIA/k8s-dra-driver-gpu/blob/main/tests/bats/Makefile#L22). Most of them can be overridden via environment. |
| 6 | +Use this configuration interface to customize your test run. |
6 | 7 |
|
| 8 | +Then invoke `make bats` in the root of the repository. |
7 | 9 |
|
8 | | -### Test local dev state (artifacts not pushed) |
| 10 | +Some examples are shown below. |
9 | 11 |
|
10 | | -Not yet supported. |
11 | | -Let's change this ASAP. |
| 12 | +### Test a specific GHCR chart version |
12 | 13 |
|
13 | | -This test suite for now assumes public availability of a Helm chart on GHCR or NGC, pointing to a container image publicly available on GHCR or NGC. |
| 14 | +Example: |
14 | 15 |
|
15 | | -### Test Helm chart from registery |
| 16 | +```console |
| 17 | +$ export TEST_CHART_VERSION="25.8.0-dev-b823882b-chart" |
| 18 | +$ make bats |
| 19 | +... |
| 20 | +12 tests, 0 failures in 166 seconds |
| 21 | +``` |
16 | 22 |
|
17 | | -#### Default versions |
| 23 | +Note: by default, the test suite assumes availability of a Helm chart on `oci://ghcr.io/nvidia/k8s-dra-driver-gpu`, pointing to a container image also publicly available in that registry. |
18 | 24 |
|
19 | | -Say, this is the current local git revision: |
20 | 25 |
|
21 | | -```console |
22 | | -$ git rev-parse --short=8 HEAD |
23 | | -e6e1dde4 |
24 | | -``` |
| 26 | +### Test local dev state (artifacts not pushed) |
| 27 | + |
| 28 | +To test the Helm chart currently specified in `deployments/helm/nvidia-dra-driver-gpu` in the local checkout, run |
25 | 29 |
|
26 | | -Then the test suite runs with the default configuration, for example: |
27 | 30 | ```console |
28 | | -$ make bats |
29 | | -... |
30 | | - --env TEST_CHART_REPO="oci://ghcr.io/nvidia/k8s-dra-driver-gpu" \ |
31 | | - --env TEST_CHART_VERSION=25.8.0-dev-e6e1dde4-chart \ |
32 | | - --env TEST_CHART_LASTSTABLE_REPO="oci://ghcr.io/nvidia/k8s-dra-driver-gpu" \ |
33 | | - --env TEST_CHART_LASTSTABLE_VERSION="25.3.2-7020737a-chart" \ |
34 | | - --env TEST_CRD_UPGRADE_TARGET_GIT_REF=e6e1dde4 \ |
35 | | -... |
36 | | -12 tests, 0 failures in 166 seconds |
| 31 | +TEST_CHART_LOCAL=1 make bats |
37 | 32 | ``` |
38 | 33 |
|
39 | | -As you can see, this currently requires a Helm chart corresponding to the local revision to be available on GHCR. |
| 34 | +This overrides `TEST_CHART_REPO` and `TEST_CHART_VERSION`. |
40 | 35 |
|
41 | | -#### Test specific versions |
| 36 | +Make sure (out-of-band) that the container images that the local chart refers to are available to all nodes in the Kubernetes cluster -- placed directly (TODO: how-to) or pullable. |
42 | 37 |
|
43 | | -Set the correponding `TEST_*` environment variables before invoking the Makefile target. |
| 38 | +### Defaults |
44 | 39 |
|
45 | | -For example: |
| 40 | +By default, `make bats` tries to install a Helm chart from `oci://ghcr.io/nvidia/k8s-dra-driver-gpu` corresponding to the git revision of the local checkout: |
46 | 41 |
|
47 | 42 | ```console |
48 | | -$ export TEST_CHART_VERSION="25.8.0-dev-b823882b-chart" |
49 | | -$ export TEST_CRD_UPGRADE_TARGET_GIT_REF="main" |
| 43 | +$ git rev-parse --short=8 HEAD |
| 44 | +e6e1dde4 |
50 | 45 | $ make bats |
51 | 46 | ... |
52 | | -12 tests, 0 failures in 166 seconds |
| 47 | + --env TEST_CHART_REPO="oci://ghcr.io/nvidia/k8s-dra-driver-gpu" \ |
| 48 | + --env TEST_CHART_VERSION=25.8.0-dev-e6e1dde4-chart \ |
| 49 | + --env TEST_CRD_UPGRADE_TARGET_GIT_REF=e6e1dde4 \ |
| 50 | +... |
53 | 51 | ``` |
54 | 52 |
|
| 53 | +That's CI-oriented. |
| 54 | +We may want to change that. |
| 55 | + |
55 | 56 |
|
56 | 57 | ## Development |
57 | 58 |
|
58 | 59 | Bats is a workable solution. |
59 | 60 | Developing new tests might however probe your patience. |
60 | 61 | Make wise usage of |
61 | 62 |
|
| 63 | +* bats' [`run`](https://bats-core.readthedocs.io/en/stable/writing-tests.html#run-test-other-commands) command. |
62 | 64 | * [skipping tests](https://bats-core.readthedocs.io/en/stable/writing-tests.html#skip-easily-skip-tests) |
63 | 65 | * [tagging tests with `bats:focus`](https://bats-core.readthedocs.io/en/stable/writing-tests.html#special-tags) |
64 | 66 | * [CLI args](https://bats-core.readthedocs.io/en/stable/usage.html) such as `--verbose-run`, `--show-output-of-passing-tests`. |
65 | 67 |
|
| 68 | +Misc notes: |
66 | 69 |
|
67 | | -Also, familiarize yourself with bat's [`run`](https://bats-core.readthedocs.io/en/stable/writing-tests.html#run-test-other-commands) command. |
68 | | - |
69 | | -Don't skip the section about when [not to use `run`](https://bats-core.readthedocs.io/en/stable/writing-tests.html#when-not-to-use-run). |
70 | | - |
71 | | -Take inspiration from [cri-o tests](https://github.com/cri-o/cri-o/tree/81e69a58c7e6ec8699b3bdd8696b1d0e25e32bfb/test). |
| 70 | +* Don't skip the section about when [not to use `run`](https://bats-core.readthedocs.io/en/stable/writing-tests.html#when-not-to-use-run). |
| 71 | +* Take inspiration from [cri-o tests](https://github.com/cri-o/cri-o/tree/81e69a58c7e6ec8699b3bdd8696b1d0e25e32bfb/test). |
| 72 | +* Stop test suite on first failure? No first-class support in bats. See [this](https://github.com/bats-core/bats-core/issues/209) discussion. |
| 73 | +* We can and should radically iterate on the test suite's config interface to satisfy our needs. |
0 commit comments