Skip to content

Commit 8f1596d

Browse files
committed
Add bats tests covering database connection loss handling
1 parent a165cea commit 8f1596d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/bats/sidekiq-orchestrator.bats

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,34 @@ teardown() {
8585
kill -15 "$(cat "$TEST_PIDDIR/o1.pid")"
8686
wait_for 120 1 grep 'dynflow: Acquired orchestrator lock, entering active mode.' "$(bg_output_file o2)"
8787
}
88+
89+
@test "active orchestrator exits when pg goes away for good" {
90+
cd "$(get_project_root)"
91+
92+
run_background 'o1' bundle exec sidekiq -r ./examples/remote_executor.rb -q dynflow_orchestrator -c 1
93+
wait_for 30 1 grep 'dynflow: Acquired orchestrator lock, entering active mode.' "$(bg_output_file o1)"
94+
95+
run_background 'w1' bundle exec sidekiq -r ./examples/remote_executor.rb -q default
96+
wait_for 5 1 grep 'dynflow: Finished performing validity checks' "$(bg_output_file o1)"
97+
98+
podman stop "$POSTGRES_CONTAINER_NAME"
99+
wait_for 60 1 grep 'dynflow: World terminated, exiting.' "$(bg_output_file o1)"
100+
}
101+
102+
@test "active orchestrator can withstand temporary pg connection drop" {
103+
cd "$(get_project_root)"
104+
105+
run_background 'o1' bundle exec sidekiq -r ./examples/remote_executor.rb -q dynflow_orchestrator -c 1
106+
wait_for 30 1 grep 'dynflow: Acquired orchestrator lock, entering active mode.' "$(bg_output_file o1)"
107+
108+
run_background 'w1' bundle exec sidekiq -r ./examples/remote_executor.rb -q default
109+
wait_for 5 1 grep 'dynflow: Finished performing validity checks' "$(bg_output_file o1)"
110+
111+
podman stop "$POSTGRES_CONTAINER_NAME"
112+
wait_for 30 1 grep 'dynflow: Persistence retry no. 1' "$(bg_output_file o1)"
113+
podman start "$POSTGRES_CONTAINER_NAME"
114+
wait_for 30 1 grep 'dynflow: Executor heartbeat' "$(bg_output_file o1)"
115+
116+
timeout 30 bundle exec ruby examples/remote_executor.rb client 1
117+
wait_for 1 1 grep -P 'dynflow: ExecutionPlan.*running >>.*stopped' "$(bg_output_file o1)"
118+
}

0 commit comments

Comments
 (0)