[9.18] Rewrite the hooks system test to pytest
Also, enable the test under TSAN.
(cherry picked from commit 5a84c7a0)
Backport of MR !7883 (merged)
Also, enable the test under TSAN.
(cherry picked from commit 5a84c7a0)
Backport of MR !7883 (merged)