Skip creating replicated records in Geo registry shared examples
What does this MR do and why?
Cuts the CI time of the 42 Geo registry specs by 77%, from 4,177 s to 976 s per full run, saving about 53 minutes. These are the specs that include the a Geo framework registry shared example, such as ee/spec/models/geo/merge_request_diff_registry_spec.rb. The numbers compare the rspec-ee unit pg17 jobs of a scheduled master pipeline with this MR's pipeline; see the timings below.
The shared examples (a Geo framework registry and a Geo verifiable registry) created every registry with its factory. Registry factories also build the replicated record, for example a project with a merge request and an external diff for Geo::MergeRequestDiffRegistry. Building that record took most of the runtime. Registries only store the record's ID, and belongs_to_required_by_default is off, so most examples never need the record.
This MR adds a create_registry_without_model_record helper to EE::GeoHelpers, used by both registry shared examples. It builds the registry from attributes_for(registry_factory, *traits), which skips the replicated record association, and sets the record ID from a new unused_record_id sequence in spec/factories/sequences.rb. That sequence counts down from the same maximum as non_existing_record_id, so the ID never matches a real record. The real factory is still used for:
.oldest_unsynced_time, which updates the replicated records' timestamps#synced!, whoseafter_syncedhook loads the record throughready_to_verify?- registries that validate the record's presence, which are invalid with an unused ID. Only
Geo::ProjectWikiRepositoryRegistrydoes today.
Timings and checks
CI runtime of the 42 specs, from the [RSpecRunTime] lines in the rspec-ee unit pg17 job logs:
| Pipeline | Total | |
|---|---|---|
Before (master) |
https://gitlab.com/gitlab-org/gitlab/-/pipelines/3030518629 | 4,177 s |
| After (this MR) | https://gitlab.com/gitlab-org/gitlab/-/pipelines/3032584371 | 976 s |
That's 3,201 seconds (about 53 minutes, 77%) less per full run.
| Spec | Before | After |
|---|---|---|
design_management_action_upload_registry_spec.rb |
238.6 s | 41.6 s |
supply_chain_attestation_registry_spec.rb |
236.3 s | 35.5 s |
vulnerability_archive_export_upload_registry_spec.rb |
119.4 s | 37.6 s |
pipeline_artifact_registry_spec.rb |
116.0 s | 36.5 s |
project_wiki_repository_registry_spec.rb |
114.1 s | 106.1 s |
project_wiki_repository_registry_spec.rb barely changes, because Geo::ProjectWikiRepositoryRegistry validates the record's presence and keeps using the real factory.
Checks:
- With
.not_pendingchanged to also exclude failed registries and#failed!changed to add 2 toretry_count,merge_request_diff_registry_spec.rbandjob_artifact_registry_spec.rbgive 121 failures both before and after this change.
References
- Tracking issue: #638347 (closed)
Screenshots or screen recordings
Not applicable: test-only change.
How to set up and validate locally
Not applicable: test-only change with no manual steps.
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.