dzbarsky / rules_itest

Bazel rules for integration testing services
MIT License
18 stars 6 forks source link

Add direct support for health check arguments #12

Closed darkrift closed 5 months ago

darkrift commented 5 months ago
00:23:14 rlavoie ~/rlavoie/darkrift/rules_itest/examples (health_check_args) $ bazel run //redis:redis
INFO: Analyzed target //redis:redis (0 packages loaded, 0 targets configured).
INFO: From GoLink external/rules_itest~/cmd/svcinit/svcinit_/svcinit:
ld: warning: ignoring duplicate libraries: '-lm'
INFO: Found 1 target...
Target //redis:redis up-to-date:
  bazel-bin/redis/redis
INFO: Elapsed time: 1.968s, Critical Path: 1.74s
INFO: 5 processes: 2 internal, 3 darwin-sandbox.
INFO: Build completed successfully, 5 total actions
INFO: Running command line: bazel-bin/redis/redis --port 0 --unixsocket '${TMPDIR}/redis.sock' --unixsocketperm 770 --dir '${TMPDIR}'
2024/05/25 00:23:37 Starting @@//redis:redis [--port 0 --unixsocket /var/folders/mp/95j4zyhx5yb8fm2lvvn0211r0000gn/T/3691759531/redis.sock --unixsocketperm 770 --dir /var/folders/mp/95j4zyhx5yb8fm2lvvn0211r0000gn/T/3691759531]
2024/05/25 00:23:37 CMD Healthchecking @@//redis:redis (pid 89470) : @@com_github_redis_redis//:redis_cli -s /var/folders/mp/95j4zyhx5yb8fm2lvvn0211r0000gn/T/3691759531/redis.sock PING
@@//redis:redis? Could not connect to Redis at /var/folders/mp/95j4zyhx5yb8fm2lvvn0211r0000gn/T/3691759531/redis.sock: No such file or directory
exit status 1
@@//redis:redis> 89470:C 25 May 2024 00:23:37.940 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
@@//redis:redis> 89470:C 25 May 2024 00:23:37.941 # Redis version=6.2.14, bits=64, commit=00000000, modified=0, pid=89470, just started
@@//redis:redis> 89470:C 25 May 2024 00:23:37.941 # Configuration loaded
@@//redis:redis> 89470:M 25 May 2024 00:23:37.941 * monotonic clock: POSIX clock_gettime
@@//redis:redis> 89470:M 25 May 2024 00:23:37.942 * Running mode=standalone, port=0.
@@//redis:redis> 89470:M 25 May 2024 00:23:37.942 # Server initialized
@@//redis:redis> 89470:M 25 May 2024 00:23:37.942 * The server is now ready to accept connections at /var/folders/mp/95j4zyhx5yb8fm2lvvn0211r0000gn/T/3691759531/redis.sock
2024/05/25 00:23:38 CMD Healthchecking @@//redis:redis (pid 89470) : @@com_github_redis_redis//:redis_cli -s /var/folders/mp/95j4zyhx5yb8fm2lvvn0211r0000gn/T/3691759531/redis.sock PING
@@//redis:redis? PONG
2024/05/25 00:23:38 @@//redis:redis healthy!

Target                 Critical Path Contribution
@@//redis:redis        214.90475ms

Target                 Startup Time
@@//redis:redis        214.90475ms

^C2024/05/25 00:23:51 Shutdown requested, exiting gracefully. Press Ctrl-C again to force exit
2024/05/25 00:23:51 Shutting down services.
2024/05/25 00:23:51 Stopping @@//redis:redis
2024/05/25 00:23:51 Cleaning up.

Bonus: Fix a seg fault if one of the dependencies finished early and the test timeout:

-- Test timed out at 2024-05-25 04:54:59 UTC --
@@//cproc/tests:redis> 7545:signal-handler (1716612899) Received SIGTERM scheduling shutdown...
2024/05/25 04:54:59 Shutdown requested, exiting gracefully. Press Ctrl-C again to force exit
2024/05/25 04:54:59 Stopping @@//cproc/services/domain-valet/tests:domain-valet
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x1049fff24]

goroutine 2302 [running]:
rules_itest/runner.stopInstance(0x1400022c480)
    external/rules_itest~/runner/runner.go:240 +0x24
rules_itest/runner.(*runner).StopAll.func1({0x1400007e720?, 0x14000114230?}, 0x1400022c480)
    external/rules_itest~/runner/runner.go:76 +0x160
rules_itest/runner.(*topoTask).Run(0x140003a6f48?, {0x104b0dbe0?, 0x14000224000?})
    external/rules_itest~/runner/topo.go:23 +0x3c
rules_itest/runner/topological.(*reversedTask).Run(0x14000234070?, {0x104b0dbe0?, 0x14000224000?})
    external/rules_itest~/runner/topological/runner.go:66 +0x30
rules_itest/runner/topological.(*runner).worker(0x14000234070, {0x104b0dbe0, 0x14000224000}, 0x140002c6120?)
    external/rules_itest~/runner/topological/runner.go:189 +0xa0
created by rules_itest/runner/topological.(*runner).Run in goroutine 1
    external/rules_itest~/runner/topological/runner.go:205 +0x48