Running tests » History » Version 62
Brett Smith, 05/22/2024 08:07 PM
organize individual tests section
| 1 | 1 | Tom Clegg | h1. Running tests |
|---|---|---|---|
| 2 | |||
| 3 | 3 | Tom Clegg | {{toc}} |
| 4 | |||
| 5 | 33 | Ward Vandewege | 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 master_ 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 | ~/arvados/build/run-tests.sh WORKSPACE=~/arvados |
||
| 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 | ~/arvados/build/run-tests.sh WORKSPACE=~/arvados --temp ~/.cache/arvados-build --only install |
||
| 34 | </pre> |
||
| 35 | 1 | Tom Clegg | |
| 36 | 29 | Tom Clegg | Start interactive mode: |
| 37 | |||
| 38 | 1 | Tom Clegg | <pre> |
| 39 | 29 | Tom Clegg | $ ~/arvados/build/run-tests.sh WORKSPACE=~/arvados --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 | $ ~/arvados/build/run-tests.sh WORKSPACE=~/arvados ARVADOS_DEBUG=1 --temp ~/.cache/arvados-build --interactive |
||
| 46 | </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 | <pre> |
||
| 128 | 29 | Tom Clegg | What next? test sdk/python --test-suite=tests.test_collections.TextModes.test_read_sailboat_across_block_boundary |
| 129 | ======= test sdk/python |
||
| 130 | running test |
||
| 131 | running egg_info |
||
| 132 | writing requirements to arvados_python_client.egg-info/requires.txt |
||
| 133 | writing arvados_python_client.egg-info/PKG-INFO |
||
| 134 | writing top-level names to arvados_python_client.egg-info/top_level.txt |
||
| 135 | writing dependency_links to arvados_python_client.egg-info/dependency_links.txt |
||
| 136 | writing pbr to arvados_python_client.egg-info/pbr.json |
||
| 137 | reading manifest file 'arvados_python_client.egg-info/SOURCES.txt' |
||
| 138 | reading manifest template 'MANIFEST.in' |
||
| 139 | writing manifest file 'arvados_python_client.egg-info/SOURCES.txt' |
||
| 140 | running build_ext |
||
| 141 | test_read_sailboat_across_block_boundary (tests.test_collections.TextModes) ... ok |
||
| 142 | |||
| 143 | ---------------------------------------------------------------------- |
||
| 144 | Ran 1 test in 0.014s |
||
| 145 | |||
| 146 | OK |
||
| 147 | 1 | Tom Clegg | ======= test sdk/python -- 1s |
| 148 | </pre> |
||
| 149 | |||
| 150 | 62 | Brett Smith | h4. RailsAPI |
| 151 | 23 | Ward Vandewege | |
| 152 | 29 | Tom Clegg | <pre> |
| 153 | 31 | Tom Clegg | What next? test services/api TESTOPTS=--name=/.*signed.locators.*/ |
| 154 | [...] |
||
| 155 | # Running: |
||
| 156 | 32 | Tom Clegg | |
| 157 | .... |
||
| 158 | |||
| 159 | Finished in 1.080084s, 3.7034 runs/s, 461.0751 assertions/s. |
||
| 160 | </pre> |
||
| 161 | 20 | Tom Clegg | |
| 162 | 29 | Tom Clegg | h3. Restarting services for integration tests |
| 163 | 20 | Tom Clegg | |
| 164 | 29 | Tom Clegg | If you have changed services/api code, and you want to check whether it breaks the lib/dispatchcloud/container integration tests: |
| 165 | 20 | Tom Clegg | |
| 166 | 29 | Tom Clegg | <pre> |
| 167 | What next? reset # teardown the integration-testing environment |
||
| 168 | What next? install services/api # (only needed if you've updated dependencies) |
||
| 169 | What next? test lib/dispatchcloud/container # bring up the integration-testing environment and run tests |
||
| 170 | What next? test lib/dispatchcloud/container # leave the integration-testing environment up and run tests |
||
| 171 | </pre> |
||
| 172 | 20 | Tom Clegg | |
| 173 | 29 | Tom Clegg | h3. Updating cache after pulling master |
| 174 | 3 | Tom Clegg | |
| 175 | 29 | Tom Clegg | Always quit interactive mode and restart after modifying run-tests.sh (via git-pull, git-checkout, editing, etc). |
| 176 | 3 | Tom Clegg | |
| 177 | 29 | Tom Clegg | When you start, run "install all" to get the latest gem/python dependencies, install updated versions of Arvados services used by integration tests, etc. |
| 178 | 3 | Tom Clegg | |
| 179 | 29 | Tom Clegg | Then you can resume your cycle of "test lib/controller", etc. |
| 180 | |||
| 181 | 35 | Tom Clegg | h3. Controlling test order (Rails) |
| 182 | |||
| 183 | Rails tests start off with a line like this |
||
| 184 | |||
| 185 | <pre> |
||
| 186 | Run options: -v -d --seed 57089 |
||
| 187 | </pre> |
||
| 188 | |||
| 189 | 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: |
||
| 190 | |||
| 191 | <pre> |
||
| 192 | What next? test services/api TESTOPTS="-v -d --seed 57089" |
||
| 193 | </pre> |
||
| 194 | |||
| 195 | |||
| 196 | 29 | Tom Clegg | h3. Other options |
| 197 | |||
| 198 | 24 | Radhika Chippada | For more usage info, try: |
| 199 | |||
| 200 | <pre> |
||
| 201 | 26 | Radhika Chippada | ~/arvados/build/run-tests.sh --help |
| 202 | 24 | Radhika Chippada | </pre> |
| 203 | |||
| 204 | h2. Running workbench diagnostics tests |
||
| 205 | |||
| 206 | You can run workbench diagnostics tests against any production server. |
||
| 207 | |||
| 208 | 26 | Radhika Chippada | 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. |
| 209 | 24 | Radhika Chippada | |
| 210 | <pre> |
||
| 211 | diagnostics: |
||
| 212 | secret_token: useanicelongrandomlygeneratedsecrettokenstring |
||
| 213 | arvados_workbench_url: https://workbench.qr1hi.arvadosapi.com |
||
| 214 | user_tokens: |
||
| 215 | active: yourcurrenttokenintheenvironmenttowhichyouarepointing |
||
| 216 | 26 | Radhika Chippada | pipelines_to_test: |
| 217 | 24 | Radhika Chippada | pipeline_1: |
| 218 | template_uuid: qr1hi-p5p6p-ftcb0o61u4yd2zr |
||
| 219 | 25 | Radhika Chippada | input_paths: [] |
| 220 | 24 | Radhika Chippada | max_wait_seconds: 300 |
| 221 | </pre> |
||
| 222 | 5 | Tom Clegg | |
| 223 | You can now run the "qr1hi" diagnostics tests using the following command: |
||
| 224 | <pre> |
||
| 225 | cd $ARVADOS_HOME |
||
| 226 | RAILS_ENV=diagnostics bundle exec rake TEST=test/diagnostics/pipeline_test.rb |
||
| 227 | </pre> |
||
| 228 | 37 | Ward Vandewege | |
| 229 | h2. Running workbench2 tests |
||
| 230 | |||
| 231 | 54 | Ward Vandewege | React uses a lot of filesystem watchers (via inotify). The default number of watched files is relatively low at 8192. Increase that with: |
| 232 | 53 | Ward Vandewege | |
| 233 | echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p |
||
| 234 | |||
| 235 | 58 | Stephen Smith | h3. Docker |
| 236 | 1 | Tom Clegg | |
| 237 | 58 | Stephen Smith | The integration tests can be run on non-debian based systems using docker. The workbench2 repo includes a Dockerfile that preinstalls the necessary dependencies to run cypress. |
| 238 | |||
| 239 | 59 | Stephen Smith | Build the docker image using this command from within the @arvados@ repository |
| 240 | 58 | Stephen Smith | |
| 241 | 1 | Tom Clegg | <pre> |
| 242 | 59 | Stephen Smith | docker build . -f services/workbench2/docker/Dockerfile -t workbench2-build |
| 243 | 58 | Stephen Smith | </pre> |
| 244 | |||
| 245 | Then, start the container using the following arguments: |
||
| 246 | |||
| 247 | <pre> |
||
| 248 | 1 | Tom Clegg | xhost +local:root |
| 249 | 49 | Ward Vandewege | ARVADOS_DIR=/path/to/arvados |
| 250 | 61 | Stephen Smith | docker run -ti -v$ARVADOS_DIR:/usr/src/arvados -w /usr/src/arvados --env="DISPLAY" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" workbench2-build:latest bash |
| 251 | 46 | Ward Vandewege | </pre> |
| 252 | 1 | Tom Clegg | |
| 253 | 60 | Stephen Smith | h4. Docker Troubleshooting |
| 254 | |||
| 255 | h5. No version of Cypress is installed |
||
| 256 | |||
| 257 | Solution: Manually install the required cypress version by running @./node_modules/.bin/cypress install@ inside the container |
||
| 258 | |||
| 259 | 58 | Stephen Smith | h3. Debian Host System |
| 260 | 1 | Tom Clegg | |
| 261 | 58 | Stephen Smith | These instructions assume a Debian 10 (buster) host system. |
| 262 | |||
| 263 | 45 | Ward Vandewege | Install the Arvados test dependencies: |
| 264 | |||
| 265 | <pre> |
||
| 266 | echo "deb http://deb.debian.org/debian buster-backports main" > /etc/apt/sources.list.d/backports.list |
||
| 267 | apt-get update |
||
| 268 | apt-get install -y --no-install-recommends golang -t buster-backports |
||
| 269 | apt-get install -y --no-install-recommends build-essential ca-certificates git libpam0g-dev |
||
| 270 | </pre> |
||
| 271 | |||
| 272 | Install a few more dependencies for workbench2: |
||
| 273 | 37 | Ward Vandewege | |
| 274 | <pre> |
||
| 275 | 39 | Ward Vandewege | apt-get update |
| 276 | 40 | Ward Vandewege | apt-get install -y --no-install-recommends gnupg2 sudo curl |
| 277 | 37 | Ward Vandewege | curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - |
| 278 | echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list |
||
| 279 | 52 | Ward Vandewege | apt-get update |
| 280 | 51 | Ward Vandewege | apt-get install -y --no-install-recommends yarn libgbm-dev |
| 281 | # we need the correct version of node to install cypress |
||
| 282 | # use arvados-server install to get it (and all other dependencies) |
||
| 283 | # All this will then not need to be repeated by ./tools/run-integration-tests.sh |
||
| 284 | # so we are not doing double work. |
||
| 285 | 55 | Ward Vandewege | cd /usr/src/arvados |
| 286 | 51 | Ward Vandewege | go mod download |
| 287 | cd cmd/arvados-server |
||
| 288 | go install |
||
| 289 | 56 | Ward Vandewege | ~/go/bin/arvados-server install -type test |
| 290 | 1 | Tom Clegg | cd <your-wb2-directory> |
| 291 | 38 | Ward Vandewege | yarn run cypress install |
| 292 | 1 | Tom Clegg | </pre> |
| 293 | |||
| 294 | 58 | Stephen Smith | 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. |
| 295 | 37 | Ward Vandewege | |
| 296 | 58 | Stephen Smith | h3. Running Tests |
| 297 | |||
| 298 | Run the unit tests with: |
||
| 299 | 1 | Tom Clegg | <pre> |
| 300 | make unit-tests |
||
| 301 | 58 | Stephen Smith | # or |
| 302 | yarn test |
||
| 303 | </pre> |
||
| 304 | |||
| 305 | Run the cypress integration tests with: |
||
| 306 | |||
| 307 | <pre> |
||
| 308 | 48 | Ward Vandewege | ./tools/run-integration-tests.sh -i -a /usr/src/arvados |
| 309 | 37 | Ward Vandewege | </pre> |