Skip to content

Only disable calls into Rails with GITALY_TESTING_NO_GIT_HOOKS

Sami Hiltunen requested to merge smh-fix-hooks-in-tests into master

GITALY_TESTING_NO_GIT_HOOKS is an environment variable that disables hooks in Gitaly entirely. This is only used by Rails' specs to disable the calls into internal API as it is not set up during tests. Gitaly however disables the entire hook functionality. This leads to us testing less but causes problems with transactions.

Transactions rely on the reference transaction hook to capture the reference updates made in the transaction. As the reference transaction hook is not ran, the changes are not captured and are not committed. Fix this issue by only stubbing out the Rails calls when the environment variable is set. This leads us to running the full hook logic but just stubbing out requests into Rails and assuming they were succcessful. This tests Gitaly closer to how it runs in production and also fixes the issue with transactions as reference transaction hook is running again.

Since the hooks were disabled, Rails' specs also haven't been exercising Praefect's voting logic which should now be exercised. Praefect has so far functioned mostly by accident as there is only a single voter, and the transaction has concluded when the primary returns without voting.

Closes Gitaly doesn't run reference transaction hook i... (#5979 - closed)

Merge request reports