Clear detached partitions before tests run
What does this MR do and why?
Prevent flaky migration specs where detached tables were preventing some tables from being dropped
More details in https://gitlab.com/gitlab-org/gitlab/-/issues/570251#note_2777046318
References
Related to #570251
How to set up and validate locally
-
Simulate an extra detached
p_duo_workflows_checkpointspartitionI did this by changing
CHECKPOINT_RETENTION_DAYStemporarily to31and then runningRAILS_ENV=test bundle exec rails db:reset.You should change it back to
30before running the spec so that it gets detached.Sample diff
diff --git a/ee/app/models/ai/duo_workflows/checkpoint.rb b/ee/app/models/ai/duo_workflows/checkpoint.rb index 034ac6045afa1..f966bcd722c23 100644 --- a/ee/app/models/ai/duo_workflows/checkpoint.rb +++ b/ee/app/models/ai/duo_workflows/checkpoint.rb @@ -2,7 +2,7 @@ module Ai module DuoWorkflows - CHECKPOINT_RETENTION_DAYS = 30 + CHECKPOINT_RETENTION_DAYS = 31 class Checkpoint < ::ApplicationRecord include ::Ai::DuoWorkflows::SyncWorkflowAttributes -
Run the spec:
CI=1 bundle exec rspec ./ee/spec/lib/ee/gitlab/background_migration/delete_invalid_epic_issues_spec.rbAs Rails boots, it should see the 31 partitions and detach the oldest one. Then the spec should fail.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.