Running tests » History » Version 67
Stephen Smith, 09/23/2025 03:41 PM
Improve wording of docker section
| 1 | 1 | Tom Clegg | h1. Running tests |
|---|---|---|---|
| 2 | |||
| 3 | 3 | Tom Clegg | {{toc}} |
| 4 | |||
| 5 | 64 | Brett Smith | The arvados git repository has a @run-tests.sh@ script which tests (nearly) all of the components in the source tree. Jenkins at https://ci.arvados.org uses this exact script, so running it _before pushing a new main_ is a good way to predict whether Jenkins will fail your build and start pestering you by IRC. |
| 6 | 1 | Tom Clegg | |
| 7 | h2. Background |
||
| 8 | |||
| 9 | You have the arvados source tree at @~/arvados@ and you might have local modifications. |
||
| 10 | |||
| 11 | h2. Install prerequisites |
||
| 12 | |||
| 13 | 29 | Tom Clegg | Follow instructions at [[Hacking prerequisites]]: "Install dev environment", etc. Don't miss creating the Postgres database, docker groups, etc. |
| 14 | 1 | Tom Clegg | |
| 15 | 32 | Tom Clegg | h2. Environment |
| 16 | |||
| 17 | Your locale must use utf-8. Set environment variable LANG=C.UTF-8 if necessary to ensure the "locale" command reports UTF-8. |
||
| 18 | |||
| 19 | 29 | Tom Clegg | h2. If you're Jenkins |
| 20 | |||
| 21 | Run all tests from a clean slate (slow, but more immune to leaks) |
||
| 22 | |||
| 23 | <pre> |
||
| 24 | 65 | Tom Clegg | WORKSPACE=~/arvados ~/arvados/build/run-tests.sh |
| 25 | 1 | Tom Clegg | </pre> |
| 26 | |||
| 27 | 29 | Tom Clegg | h2. If you're a developer |
| 28 | 1 | Tom Clegg | |
| 29 | 29 | Tom Clegg | Cache everything needed to run test suites: |
| 30 | 1 | Tom Clegg | |
| 31 | 29 | Tom Clegg | <pre> |
| 32 | mkdir ~/.cache/arvados-build |
||
| 33 | 65 | Tom Clegg | WORKSPACE=~/arvados ~/arvados/build/run-tests.sh --temp ~/.cache/arvados-build --only install |
| 34 | 29 | Tom Clegg | </pre> |
| 35 | 1 | Tom Clegg | |
| 36 | 29 | Tom Clegg | Start interactive mode: |
| 37 | |||
| 38 | 1 | Tom Clegg | <pre> |
| 39 | 65 | Tom Clegg | $ WORKSPACE=~/arvados ~/arvados/build/run-tests.sh --temp ~/.cache/arvados-build --interactive |
| 40 | 1 | Tom Clegg | </pre> |
| 41 | |||
| 42 | 34 | Ward Vandewege | Start interactive mode and enabled debug output: |
| 43 | |||
| 44 | <pre> |
||
| 45 | 65 | Tom Clegg | $ WORKSPACE=~/arvados ~/arvados/build/run-tests.sh ARVADOS_DEBUG=1 --temp ~/.cache/arvados-build --interactive |
| 46 | 34 | Ward Vandewege | </pre> |
| 47 | |||
| 48 | |||
| 49 | 29 | Tom Clegg | When prompted, choose a test suite to run: |
| 50 | 1 | Tom Clegg | |
| 51 | 29 | Tom Clegg | <pre> |
| 52 | == Interactive commands: |
||
| 53 | test TARGET |
||
| 54 | test TARGET:py3 (test with python3) |
||
| 55 | test TARGET -check.vv (pass arguments to test) |
||
| 56 | install TARGET |
||
| 57 | install env (go/python libs) |
||
| 58 | install deps (go/python libs + arvados components needed for integration tests) |
||
| 59 | reset (...services used by integration tests) |
||
| 60 | exit |
||
| 61 | == Test targets: |
||
| 62 | cmd/arvados-client lib/dispatchcloud/container sdk/go/auth sdk/pam:py3 services/fuse tools/crunchstat-summary |
||
| 63 | cmd/arvados-server lib/dispatchcloud/scheduler sdk/go/blockdigest sdk/python services/fuse:py3 tools/crunchstat-summary:py3 |
||
| 64 | lib/cli lib/dispatchcloud/ssh_executor sdk/go/crunchrunner sdk/python:py3 services/health tools/keep-block-check |
||
| 65 | lib/cloud lib/dispatchcloud/worker sdk/go/dispatch services/arv-git-httpd services/keep-balance tools/keep-exercise |
||
| 66 | lib/cloud/azure lib/service sdk/go/health services/crunch-dispatch-local services/keepproxy tools/keep-rsync |
||
| 67 | lib/cloud/ec2 sdk/cwl sdk/go/httpserver services/crunch-dispatch-slurm services/keepstore tools/sync-groups |
||
| 68 | lib/cmd sdk/cwl:py3 sdk/go/keepclient services/crunch-run services/keep-web |
||
| 69 | lib/controller sdk/go/arvados sdk/go/manifest services/crunchstat services/nodemanager |
||
| 70 | lib/crunchstat sdk/go/arvadosclient sdk/go/stats services/dockercleaner services/nodemanager:py3 |
||
| 71 | lib/dispatchcloud sdk/go/asyncbuf sdk/pam services/dockercleaner:py3 services/ws |
||
| 72 | What next? |
||
| 73 | </pre> |
||
| 74 | 1 | Tom Clegg | |
| 75 | 29 | Tom Clegg | Example: testing lib/dispatchcloud/container, showing verbose/debug logs: |
| 76 | 1 | Tom Clegg | |
| 77 | <pre> |
||
| 78 | 29 | Tom Clegg | What next? test lib/dispatchcloud/container/ -check.vv |
| 79 | ======= test lib/dispatchcloud/container |
||
| 80 | START: queue_test.go:99: IntegrationSuite.TestCancelIfNoInstanceType |
||
| 81 | WARN[0000] cancel container with no suitable instance type ContainerUUID=zzzzz-dz642-queuedcontainer error="no suitable instance type" |
||
| 82 | WARN[0000] cancel container with no suitable instance type ContainerUUID=zzzzz-dz642-queuedcontainer error="no suitable instance type" |
||
| 83 | START: queue_test.go:37: IntegrationSuite.TearDownTest |
||
| 84 | PASS: queue_test.go:37: IntegrationSuite.TearDownTest 0.846s |
||
| 85 | |||
| 86 | PASS: queue_test.go:99: IntegrationSuite.TestCancelIfNoInstanceType 0.223s |
||
| 87 | |||
| 88 | START: queue_test.go:42: IntegrationSuite.TestGetLockUnlockCancel |
||
| 89 | INFO[0001] adding container to queue ContainerUUID=zzzzz-dz642-queuedcontainer InstanceType=testType Priority=1 State=Queued |
||
| 90 | START: queue_test.go:37: IntegrationSuite.TearDownTest |
||
| 91 | PASS: queue_test.go:37: IntegrationSuite.TearDownTest 0.901s |
||
| 92 | |||
| 93 | PASS: queue_test.go:42: IntegrationSuite.TestGetLockUnlockCancel 0.177s |
||
| 94 | |||
| 95 | OK: 2 passed |
||
| 96 | PASS |
||
| 97 | 33 | Ward Vandewege | ok git.arvados.org/arvados.git/lib/dispatchcloud/container 2.150s |
| 98 | 29 | Tom Clegg | ======= test lib/dispatchcloud/container -- 3s |
| 99 | Pass: lib/dispatchcloud/container tests (3s) |
||
| 100 | All test suites passed. |
||
| 101 | 1 | Tom Clegg | </pre> |
| 102 | |||
| 103 | 29 | Tom Clegg | h3. Running individual test cases |
| 104 | 1 | Tom Clegg | |
| 105 | 62 | Brett Smith | h4. Golang |
| 106 | |||
| 107 | 29 | Tom Clegg | Most Go packages use gocheck. Use gocheck command line args like -check.f. |
| 108 | |||
| 109 | 1 | Tom Clegg | <pre> |
| 110 | 29 | Tom Clegg | What next? test lib/dispatchcloud/container -check.vv -check.f=LockUnlock |
| 111 | ======= test lib/dispatchcloud/container |
||
| 112 | START: queue_test.go:42: IntegrationSuite.TestGetLockUnlockCancel |
||
| 113 | INFO[0000] adding container to queue ContainerUUID=zzzzz-dz642-queuedcontainer InstanceType=testType Priority=1 State=Queued |
||
| 114 | START: queue_test.go:37: IntegrationSuite.TearDownTest |
||
| 115 | PASS: queue_test.go:37: IntegrationSuite.TearDownTest 0.812s |
||
| 116 | |||
| 117 | PASS: queue_test.go:42: IntegrationSuite.TestGetLockUnlockCancel 0.184s |
||
| 118 | |||
| 119 | OK: 1 passed |
||
| 120 | PASS |
||
| 121 | 33 | Ward Vandewege | ok git.arvados.org/arvados.git/lib/dispatchcloud/container 1.000s |
| 122 | 29 | Tom Clegg | ======= test lib/dispatchcloud/container -- 2s |
| 123 | 1 | Tom Clegg | </pre> |
| 124 | |||
| 125 | 62 | Brett Smith | h4. Python |
| 126 | 1 | Tom Clegg | |
| 127 | 63 | Brett Smith | If what you really want to do is focus on failing or newly-added tests, consider passing the appropriate switches to do that: |
| 128 | |||
| 129 | 1 | Tom Clegg | <pre> |
| 130 | 63 | Brett Smith | -x, --exitfirst Exit instantly on first error or failed test |
| 131 | --lf, --last-failed Rerun only the tests that failed at the last run (or |
||
| 132 | all if none failed) |
||
| 133 | --ff, --failed-first Run all tests, but run the last failures first. This |
||
| 134 | may re-order tests and thus lead to repeated fixture |
||
| 135 | setup/teardown. |
||
| 136 | --nf, --new-first Run tests from new files first, then the rest of the |
||
| 137 | tests sorted by file mtime |
||
| 138 | </pre> |
||
| 139 | |||
| 140 | If you want to manually select tests: |
||
| 141 | |||
| 142 | <pre> |
||
| 143 | FILENAME Run tests from FILENAME, relative to the source root |
||
| 144 | FILENAME::CLASSNAME Run tests from CLASSNAME |
||
| 145 | FILENAME::FUNCNAME, FILENAME::CLASSNAME::FUNCNAME |
||
| 146 | Run only the named test function |
||
| 147 | -k EXPRESSION Only run tests which match the given substring |
||
| 148 | expression. An expression is a Python evaluable |
||
| 149 | expression where all names are substring-matched |
||
| 150 | against test names and their parent classes. |
||
| 151 | Example: -k 'test_method or test_other' matches all |
||
| 152 | test functions and classes whose name contains |
||
| 153 | 'test_method' or 'test_other', while -k 'not |
||
| 154 | test_method' matches those that don't contain |
||
| 155 | 'test_method' in their names. -k 'not test_method |
||
| 156 | and not test_other' will eliminate the matches. |
||
| 157 | Additionally keywords are matched to classes and |
||
| 158 | functions containing extra names in their |
||
| 159 | 'extra_keyword_matches' set, as well as functions |
||
| 160 | which have names assigned directly to them. The |
||
| 161 | matching is case-insensitive. |
||
| 162 | -m MARKEXPR Only run tests matching given mark expression. For |
||
| 163 | example: -m 'mark1 and not mark2'. |
||
| 164 | </pre> |
||
| 165 | |||
| 166 | For even more options, refer to the "pytest command line reference":https://docs.pytest.org/en/stable/reference/reference.html#command-line-flags. |
||
| 167 | |||
| 168 | Example: |
||
| 169 | |||
| 170 | <pre> |
||
| 171 | What next? test sdk/python:py3 --disable-warnings --tb=no --no-showlocals tests/test_keep_client.py::KeepDiskCacheTestCase |
||
| 172 | 1 | Tom Clegg | ======= test sdk/python |
| 173 | 63 | Brett Smith | […pip output…] |
| 174 | ========================================================== test session starts ========================================================== |
||
| 175 | platform linux -- Python 3.8.19, pytest-8.2.0, pluggy-1.5.0 |
||
| 176 | rootdir: /home/brett/Curii/arvados/sdk/python |
||
| 177 | configfile: pytest.ini |
||
| 178 | collected 9 items |
||
| 179 | 1 | Tom Clegg | |
| 180 | 63 | Brett Smith | tests/test_keep_client.py F........ [100%] |
| 181 | 1 | Tom Clegg | |
| 182 | 63 | Brett Smith | ======================================================== short test summary info ======================================================== |
| 183 | FAILED tests/test_keep_client.py::KeepDiskCacheTestCase::test_disk_cache_cap - AssertionError: True is not false |
||
| 184 | ====================================================== 1 failed, 8 passed in 0.16s ====================================================== |
||
| 185 | ======= sdk/python tests -- FAILED |
||
| 186 | ======= test sdk/python -- 2s |
||
| 187 | Failures (1): |
||
| 188 | Fail: sdk/python tests (2s) |
||
| 189 | What next? test sdk/python:py3 --disable-warnings --tb=no --no-showlocals --lf |
||
| 190 | ======= test sdk/python |
||
| 191 | […pip output…] |
||
| 192 | ========================================================== test session starts ========================================================== |
||
| 193 | platform linux -- Python 3.8.19, pytest-8.2.0, pluggy-1.5.0 |
||
| 194 | rootdir: /home/brett/Curii/arvados/sdk/python |
||
| 195 | configfile: pytest.ini |
||
| 196 | testpaths: tests |
||
| 197 | collected 964 items / 963 deselected / 1 selected |
||
| 198 | run-last-failure: rerun previous 1 failure |
||
| 199 | |||
| 200 | tests/test_keep_client.py F [100%] |
||
| 201 | |||
| 202 | ======================================================== short test summary info ======================================================== |
||
| 203 | FAILED tests/test_keep_client.py::KeepDiskCacheTestCase::test_disk_cache_cap - AssertionError: True is not false |
||
| 204 | ============================================= 1 failed, 963 deselected, 1 warning in 0.43s ============================================== |
||
| 205 | ======= sdk/python tests -- FAILED |
||
| 206 | ======= test sdk/python -- 2s |
||
| 207 | Failures (1): |
||
| 208 | Fail: sdk/python tests (2s) |
||
| 209 | 20 | Tom Clegg | </pre> |
| 210 | 29 | Tom Clegg | |
| 211 | 20 | Tom Clegg | h4. RailsAPI |
| 212 | 29 | Tom Clegg | |
| 213 | 20 | Tom Clegg | <pre> |
| 214 | 29 | Tom Clegg | What next? test services/api TESTOPTS=--name=/.*signed.locators.*/ |
| 215 | [...] |
||
| 216 | # Running: |
||
| 217 | |||
| 218 | .... |
||
| 219 | |||
| 220 | 20 | Tom Clegg | Finished in 1.080084s, 3.7034 runs/s, 461.0751 assertions/s. |
| 221 | 29 | Tom Clegg | </pre> |
| 222 | 3 | Tom Clegg | |
| 223 | 29 | Tom Clegg | h3. Restarting services for integration tests |
| 224 | 3 | Tom Clegg | |
| 225 | 29 | Tom Clegg | If you have changed services/api code, and you want to check whether it breaks the lib/dispatchcloud/container integration tests: |
| 226 | 3 | Tom Clegg | |
| 227 | 29 | Tom Clegg | <pre> |
| 228 | What next? reset # teardown the integration-testing environment |
||
| 229 | 35 | Tom Clegg | What next? install services/api # (only needed if you've updated dependencies) |
| 230 | What next? test lib/dispatchcloud/container # bring up the integration-testing environment and run tests |
||
| 231 | What next? test lib/dispatchcloud/container # leave the integration-testing environment up and run tests |
||
| 232 | </pre> |
||
| 233 | |||
| 234 | 64 | Brett Smith | h3. Updating cache after pulling main |
| 235 | 35 | Tom Clegg | |
| 236 | Always quit interactive mode and restart after modifying run-tests.sh (via git-pull, git-checkout, editing, etc). |
||
| 237 | |||
| 238 | When you start, run "install all" to get the latest gem/python dependencies, install updated versions of Arvados services used by integration tests, etc. |
||
| 239 | |||
| 240 | Then you can resume your cycle of "test lib/controller", etc. |
||
| 241 | |||
| 242 | h3. Controlling test order (Rails) |
||
| 243 | |||
| 244 | 29 | Tom Clegg | Rails tests start off with a line like this |
| 245 | |||
| 246 | 24 | Radhika Chippada | <pre> |
| 247 | Run options: -v -d --seed 57089 |
||
| 248 | </pre> |
||
| 249 | 26 | Radhika Chippada | |
| 250 | 24 | Radhika Chippada | The seed value determines the order tests are run. To reproduce reproduce an order-dependent test failure, specify the same seed as a previous failed run: |
| 251 | |||
| 252 | <pre> |
||
| 253 | What next? test services/api TESTOPTS="-v -d --seed 57089" |
||
| 254 | </pre> |
||
| 255 | |||
| 256 | 26 | Radhika Chippada | |
| 257 | 24 | Radhika Chippada | h3. Other options |
| 258 | |||
| 259 | For more usage info, try: |
||
| 260 | |||
| 261 | <pre> |
||
| 262 | ~/arvados/build/run-tests.sh --help |
||
| 263 | </pre> |
||
| 264 | 26 | Radhika Chippada | |
| 265 | 24 | Radhika Chippada | h2. Running workbench diagnostics tests |
| 266 | |||
| 267 | 25 | Radhika Chippada | You can run workbench diagnostics tests against any production server. |
| 268 | 24 | Radhika Chippada | |
| 269 | Update your workbench application.yml to add a "diagnostics" section with the login token and pipeline details. The below example configuration is to run the "qr1hi-p5p6p-ftcb0o61u4yd2zr" pipeline in "qr1hi" environment. |
||
| 270 | 5 | Tom Clegg | |
| 271 | <pre> |
||
| 272 | diagnostics: |
||
| 273 | secret_token: useanicelongrandomlygeneratedsecrettokenstring |
||
| 274 | arvados_workbench_url: https://workbench.qr1hi.arvadosapi.com |
||
| 275 | user_tokens: |
||
| 276 | 37 | Ward Vandewege | active: yourcurrenttokenintheenvironmenttowhichyouarepointing |
| 277 | pipelines_to_test: |
||
| 278 | pipeline_1: |
||
| 279 | 54 | Ward Vandewege | template_uuid: qr1hi-p5p6p-ftcb0o61u4yd2zr |
| 280 | 53 | Ward Vandewege | input_paths: [] |
| 281 | max_wait_seconds: 300 |
||
| 282 | </pre> |
||
| 283 | 58 | Stephen Smith | |
| 284 | 1 | Tom Clegg | You can now run the "qr1hi" diagnostics tests using the following command: |
| 285 | 58 | Stephen Smith | <pre> |
| 286 | cd $ARVADOS_HOME |
||
| 287 | 59 | Stephen Smith | RAILS_ENV=diagnostics bundle exec rake TEST=test/diagnostics/pipeline_test.rb |
| 288 | 58 | Stephen Smith | </pre> |
| 289 | 1 | Tom Clegg | |
| 290 | 59 | Stephen Smith | h2. Running workbench2 tests |
| 291 | 58 | Stephen Smith | |
| 292 | React uses a lot of filesystem watchers (via inotify). The default number of watched files is relatively low at 8192. Increase that with: |
||
| 293 | |||
| 294 | echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p |
||
| 295 | |||
| 296 | 1 | Tom Clegg | h3. Docker |
| 297 | 49 | Ward Vandewege | |
| 298 | 67 | Stephen Smith | The integration tests can be run on non-debian based systems using docker. The workbench2 subfolder includes a Makefile target that preinstalls the necessary dependencies in a docker container using Ansible. |
| 299 | 46 | Ward Vandewege | |
| 300 | 67 | Stephen Smith | With Docker and Ansible installed, run this command from within the @arvados/services/workbench2@ directory: |
| 301 | 60 | Stephen Smith | |
| 302 | <pre> |
||
| 303 | 66 | Stephen Smith | make workbench-docker-image |
| 304 | 1 | Tom Clegg | </pre> |
| 305 | |||
| 306 | 66 | Stephen Smith | You can verify the docker image was built by looking for @arvados/workbench@ in @docker image ls@ |
| 307 | 58 | Stephen Smith | |
| 308 | 66 | Stephen Smith | Then, start the interactive tests with this command: |
| 309 | |||
| 310 | 58 | Stephen Smith | <pre> |
| 311 | 66 | Stephen Smith | make interactive-tests-in-docker |
| 312 | 1 | Tom Clegg | </pre> |
| 313 | |||
| 314 | h4. Docker Troubleshooting |
||
| 315 | |||
| 316 | 67 | Stephen Smith | h5. No version of Cypress is installed / other error starting Cypress |
| 317 | 45 | Ward Vandewege | |
| 318 | 67 | Stephen Smith | Recreate the home volume which re-installs Cypress and other persisted dependencies by running: |
| 319 | 66 | Stephen Smith | |
| 320 | <pre> |
||
| 321 | make clean-docker-volume |
||
| 322 | make workbench-docker-volume |
||
| 323 | </pre> |
||
| 324 | 45 | Ward Vandewege | |
| 325 | h3. Debian Host System |
||
| 326 | 37 | Ward Vandewege | |
| 327 | These instructions assume a Debian 10 (buster) host system. |
||
| 328 | 39 | Ward Vandewege | |
| 329 | 40 | Ward Vandewege | Install the Arvados test dependencies: |
| 330 | 37 | Ward Vandewege | |
| 331 | <pre> |
||
| 332 | 52 | Ward Vandewege | echo "deb http://deb.debian.org/debian buster-backports main" > /etc/apt/sources.list.d/backports.list |
| 333 | 51 | Ward Vandewege | apt-get update |
| 334 | apt-get install -y --no-install-recommends golang -t buster-backports |
||
| 335 | apt-get install -y --no-install-recommends build-essential ca-certificates git libpam0g-dev |
||
| 336 | </pre> |
||
| 337 | |||
| 338 | 55 | Ward Vandewege | Install a few more dependencies for workbench2: |
| 339 | 51 | Ward Vandewege | |
| 340 | <pre> |
||
| 341 | apt-get update |
||
| 342 | 56 | Ward Vandewege | apt-get install -y --no-install-recommends gnupg2 sudo curl |
| 343 | 1 | Tom Clegg | curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - |
| 344 | 38 | Ward Vandewege | echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list |
| 345 | 1 | Tom Clegg | apt-get update |
| 346 | apt-get install -y --no-install-recommends yarn libgbm-dev |
||
| 347 | 58 | Stephen Smith | # we need the correct version of node to install cypress |
| 348 | 37 | Ward Vandewege | # use arvados-server install to get it (and all other dependencies) |
| 349 | 58 | Stephen Smith | # All this will then not need to be repeated by ./tools/run-integration-tests.sh |
| 350 | # so we are not doing double work. |
||
| 351 | cd /usr/src/arvados |
||
| 352 | 1 | Tom Clegg | go mod download |
| 353 | cd cmd/arvados-server |
||
| 354 | 58 | Stephen Smith | go install |
| 355 | ~/go/bin/arvados-server install -type test |
||
| 356 | cd <your-wb2-directory> |
||
| 357 | yarn run cypress install |
||
| 358 | </pre> |
||
| 359 | |||
| 360 | Make sure you have both the arvados and arvados-workbench2 source trees available, and then use the following commands (adjust path for the arvados source tree, if necessary) from your workbench2 source tree. |
||
| 361 | 48 | Ward Vandewege | |
| 362 | 37 | Ward Vandewege | h3. Running Tests |
| 363 | 1 | Tom Clegg | |
| 364 | Run the unit tests with: |
||
| 365 | <pre> |
||
| 366 | make unit-tests |
||
| 367 | # or |
||
| 368 | yarn test |
||
| 369 | </pre> |
||
| 370 | |||
| 371 | Run the cypress integration tests with: |
||
| 372 | |||
| 373 | <pre> |
||
| 374 | ./tools/run-integration-tests.sh -i -a /usr/src/arvados |
||
| 375 | </pre> |