Fix flaky test in elasticsearch_indexed_namespace_spec.rb
What does this MR do and why?
The flaky test was found in this job, https://gitlab.com/gitlab-org/gitlab/-/jobs/7241430817. It seems the order caused the failure,
Failures:
1) ElasticsearchIndexedNamespace scope .namespace_in returns records of the ids
Failure/Error: expect(described_class.namespace_in(records.last(2).map(&:id))).to eq(records.last(2))
expected: [#<ElasticsearchIndexedNamespace created_at: "2024-07-02 02:24:34.945830541 +0000", updated_at: "2024...2 02:24:35.087612790 +0000", updated_at: "2024-07-02 02:24:35.087612790 +0000", namespace_id: 2690>]
got: #<ActiveRecord::Relation [#<ElasticsearchIndexedNamespace created_at: "2024-07-02 02:24:35.087612000 ... 02:24:34.945830000 +0000", updated_at: "2024-07-02 02:24:34.945830000 +0000", namespace_id: 2689>]>
(compared using ==)
Diff:
@@ -1,3 +1,9 @@
-[#<ElasticsearchIndexedNamespace created_at: "2024-07-02 02:24:34.945830541 +0000", updated_at: "2024-07-02 02:24:34.945830541 +0000", namespace_id: 2689>,
- #<ElasticsearchIndexedNamespace created_at: "2024-07-02 02:24:35.087612790 +0000", updated_at: "2024-07-02 02:24:35.087612790 +0000", namespace_id: 2690>]
+[#<ElasticsearchIndexedNamespace:0x00007ea71c183868
+ created_at: Tue, 02 Jul 2024 02:24:35.087612000 UTC +00:00,
+ updated_at: Tue, 02 Jul 2024 02:24:35.087612000 UTC +00:00,
+ namespace_id: 2690>,
+ #<ElasticsearchIndexedNamespace:0x00007ea71c183750
+ created_at: Tue, 02 Jul 2024 02:24:34.945830000 UTC +00:00,
+ updated_at: Tue, 02 Jul 2024 02:24:34.945830000 UTC +00:00,
+ namespace_id: 2689>]
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
Related to #470122 (closed)