Skip to content

Drop some hard-coded IDs in migration tests

Stan Hu requested to merge sh-drop-hard-coded-ids into master

What does this MR do and why?

Some tests created namespaces and their traversal IDs with hard-coded primary IDs. However, these hard-coded primary key values do not increase the database sequence number. If another namespace is created without an ID, it's possible to hit a duplicate key error (such as in https://gitlab.com/gitlab-org/gitlab/-/jobs/3204595559).

To avoid this, don't hard-code the IDs and update the traversal IDs after creation.

How to set up and validate locally

Previously this would fail:

RAILS_ENV=test bin/rake db:reset
CACHE_CLASSES=true bundle exec rspec --format d --fail-fast ee/spec/lib/ee/gitlab/background_migration/backfill_epic_cache_counts_spec.rb ./ee/spec/lib/ee/gitlab/background_migration/backfill_project_statistics_container_repository_size_spec.rb

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Stan Hu

Merge request reports

Loading