In a specific edge case in the PerfCheck CI test suite we built an app that has a blank database when we run PerfCheck.
The following happens:
Fetch and hard reset to experiment branch
Bundle install
Trigger before start callbacks
Run migrations
(Re)start Rails server etc…
When the before start callbacks attempt to access something introduced by the migrations it will not be able to do so.
One solution would be to trigger the start callbacks after the migrations, but that might introduce other issues.
Potential solutions:
Move the callbacks and hope for the best.
More fine-grained callbacks (eg. before_all, before_setup, before_each_test_case, etc).
Insane callbacks by using event handlers instead of callbacks*
Callbacks
We can have a system where every step in a run can have its own before, around, and after callbacks.
# Configure an around callback so you can decide not to yield for
# a certain step in the process to keep it from happening.
perf_check.steps.around(:start) do |step|
if perf_check.options.experiment_branch == 'master'
perf_check.logger.info(
"Sorry, running benchmarks against master is " \
"not allowed."
)
else
step.call
end
end
# Run something afterwards.
perf_check.steps.after(:migrations) do
puts "Migrations done!"
end
perf_check.steps.around(:request) do |step|
puts step.call.body
end
class Git
def checkout(branch)
perf_check.steps.call(:checkout) do
git.checkout(branch)
end
end
end
In a specific edge case in the PerfCheck CI test suite we built an app that has a blank database when we run PerfCheck.
The following happens:
When the before start callbacks attempt to access something introduced by the migrations it will not be able to do so.
One solution would be to trigger the start callbacks after the migrations, but that might introduce other issues.
Potential solutions:
before_all
,before_setup
,before_each_test_case
, etc).Callbacks
We can have a system where every step in a run can have its own before, around, and after callbacks.