gitlab_quality-test_tooling 3.21.2 → 3.21.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ae21eb1d647c738006ae06faef24f5268d61fe30d0b72bd9aeebaa6b4b7d93e
4
- data.tar.gz: 934cd5bd6d0bdac314f7209d9fa212dafa4b14ec1daffb1f0dff77106bcbd0b0
3
+ metadata.gz: cc1eb2f60dd3f394c55bfbaff26309fbad61afd5eeceaa9c794092c1997f03eb
4
+ data.tar.gz: 5bfe5172b7ef0212b31b3eba7eb2483d1bebe57d2627d8b0863e0b5df61d7348
5
5
  SHA512:
6
- metadata.gz: 0b2c9ab4651163565cda4e146487bfa7ffec5b9e4d47a289431d4427926e35a8b92d81f759f6838169b2d2572a5fcac6c7c48fc9250cd572219f77a60f96e5aa
7
- data.tar.gz: 69479474c04e85f4ba6da8748af8d58fb7b85e7175ddae13c524fd2303f5e324af9c9d1dd9e07220509c52e107cb155545d0515ae4e49b9d75cb77df855a5a9b
6
+ metadata.gz: 9b892716ac4868efafa4dfebea723db41e0eb62d4bf036bbc2b36d0cd79f9e1fd3d58a6e8104f8a8ecf4999dae3315cd9f4103f3ef4e43556f28a0a0192062a7
7
+ data.tar.gz: 5c690dc16665ac12a38abb803af01399ded95c49c5b071127c7e0d67fc7e26dd1c9c87c9d122b8d3262f6e8ae7660a093238bbb8ba822d156caf9b6ed26f3abc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitlab_quality-test_tooling (3.21.2)
4
+ gitlab_quality-test_tooling (3.21.4)
5
5
  activesupport (>= 7.0)
6
6
  amatch (~> 0.4.1)
7
7
  fog-google (~> 1.25)
@@ -15,8 +15,10 @@ module GitlabQuality
15
15
 
16
16
  KNOWN_UNOWNED = %w[shared not_owned tooling].freeze
17
17
 
18
- # SQL query to get the latest ownership record for each unique category+ownership combination
19
- # Partitions by the full composite key to handle cases where a category has multiple ownerships
18
+ # Every owner a category has ever had, including ones it has moved off, one row per
19
+ # distinct owner and in no particular order. Only `push` reads this, to skip rows it
20
+ # has already stored. Deduping to one row per category here would make it re-insert
21
+ # old owners on every run.
20
22
  LATEST_RECORDS_QUERY = <<~SQL
21
23
  SELECT category, group, stage, section
22
24
  FROM (
@@ -27,6 +29,18 @@ module GitlabQuality
27
29
  WHERE rn = 1
28
30
  SQL
29
31
 
32
+ # The current owner of each category, one row per category, which is what `owners`
33
+ # and `owner_records` serve to callers. The table keeps every past owner as well, so
34
+ # the newest timestamp is what picks the current one. The owner columns after the
35
+ # timestamp in the ORDER BY break ties, so two rows sharing a category's newest
36
+ # timestamp always resolve the same way.
37
+ LATEST_OWNERS_QUERY = <<~SQL
38
+ SELECT category, group, stage, section
39
+ FROM %{table_name}
40
+ ORDER BY category, timestamp DESC, group, stage, section
41
+ LIMIT 1 BY category
42
+ SQL
43
+
30
44
  # Insert only new category ownership records that don't already exist
31
45
  # This avoids needing TRUNCATE permission
32
46
  def push(data)
@@ -71,7 +85,7 @@ module GitlabQuality
71
85
  private
72
86
 
73
87
  def records
74
- @records ||= fetch_latest_records.each_with_object({}) do |record, hsh|
88
+ @records ||= fetch_latest_owners.each_with_object({}) do |record, hsh|
75
89
  hsh[record["category"]] = record.slice("group", "stage", "section")
76
90
  end
77
91
  end
@@ -114,6 +128,11 @@ module GitlabQuality
114
128
  client.query(query)
115
129
  end
116
130
 
131
+ def fetch_latest_owners
132
+ query = format(LATEST_OWNERS_QUERY, table_name: table_name)
133
+ client.query(query)
134
+ end
135
+
117
136
  def sanitized_data_record(record)
118
137
  {
119
138
  timestamp: time,
@@ -134,26 +134,21 @@ module GitlabQuality
134
134
  def fetch_existing_mappings(ci_project_path, records) # rubocop:disable Metrics/AbcSize
135
135
  # Query for ALL latest mappings for this project
136
136
  # We filter in Ruby rather than building dynamic SQL to avoid injection risks
137
+ # Aggregate rather than matching rows against a set of the latest timestamps.
138
+ # The set form has to materialise one tuple per stored mapping before it can
139
+ # filter anything, which exceeds the server's memory limit at this table's
140
+ # size; argMax streams and peaks at roughly a quarter of it.
137
141
  sql = <<~SQL
138
142
  SELECT
139
143
  test_file,
140
144
  source_file,
141
- category,
142
- `group`,
143
- stage,
144
- section
145
+ argMax(category, timestamp) AS category,
146
+ argMax(`group`, timestamp) AS `group`,
147
+ argMax(stage, timestamp) AS stage,
148
+ argMax(section, timestamp) AS section
145
149
  FROM #{full_table_name}
146
150
  WHERE ci_project_path = {project_path:String}
147
- AND (ci_project_path, test_file, source_file, timestamp) IN (
148
- SELECT
149
- ci_project_path,
150
- test_file,
151
- source_file,
152
- MAX(timestamp) AS timestamp
153
- FROM #{full_table_name}
154
- WHERE ci_project_path = {project_path:String}
155
- GROUP BY ci_project_path, test_file, source_file
156
- )
151
+ GROUP BY test_file, source_file
157
152
  SQL
158
153
 
159
154
  # Substitute project_path value using manual escaping (client doesn't support parameterized queries)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GitlabQuality
4
4
  module TestTooling
5
- VERSION = "3.21.2"
5
+ VERSION = "3.21.4"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab_quality-test_tooling
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.21.2
4
+ version: 3.21.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitLab Quality
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-09-01 00:00:00.000000000 Z
11
+ date: 2026-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: climate_control