gitlab_quality-test_tooling 1.25.0 → 1.26.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d9ffa0b968a30865f566b0e0605f0f1f3e86ada066e5d9f556cf5fc841158a2
4
- data.tar.gz: 86ff9419e5023c229f7e0dfbb98d9afae4370f62e98e0742a0050d314839d9a3
3
+ metadata.gz: 6895c7a00b6414c417fdadfe15fc030d316c1a6ecac135d5a3b281748d321926
4
+ data.tar.gz: d9c8dcf80524df5f22c3cc32439f2abaf5f148d061c46a1b8f74a6c40aaa2a21
5
5
  SHA512:
6
- metadata.gz: c1a1d48ad6f07f3861d2c20cac6c24623b709664b80f796b42972238e0c378c22a97f9374bb29546c5f9a3012d22b523d84b3e178d413040fe4d8e40a14e3827
7
- data.tar.gz: 6ec38fbbba05b00c978a3f0a48994217257aca572ec8081b1764d950c47175e91bd0cdc3dbd944c730c184ea76e856bd0e46691c7323f16c5acc0b7fe1d5cab1
6
+ metadata.gz: c6305ab3fcdf665926a8a1180ffd1308611e39ef53442d584e1797e8caf0115527bac36376b668ee89473d94f86ee160eeeeeaf2a72dca8348a96b44c375f233
7
+ data.tar.gz: bf77f8ce83ebebb939925479593cb7c21b9f2f4a8ac564da009605d509ec4e56c4eb68b73fbc156b05567c9c0d5603b7ac2552f77c615b1b19fa2e5e19ad568a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitlab_quality-test_tooling (1.25.0)
4
+ gitlab_quality-test_tooling (1.26.0)
5
5
  activesupport (>= 6.1, < 7.2)
6
6
  amatch (~> 0.4.1)
7
7
  gitlab (~> 4.19)
@@ -33,10 +33,11 @@ module GitlabQuality
33
33
  input_files:,
34
34
  base_issue_labels: nil,
35
35
  dry_run: false,
36
+ related_issues_file: nil,
36
37
  project: nil,
37
38
  max_diff_ratio: DEFAULT_MAX_DIFF_RATIO_FOR_DETECTION,
38
39
  **_kwargs)
39
- super(token: token, input_files: input_files, project: project, dry_run: dry_run)
40
+ super(token: token, input_files: input_files, related_issues_file: related_issues_file, project: project, dry_run: dry_run)
40
41
 
41
42
  @base_issue_labels = Set.new(base_issue_labels)
42
43
  @max_diff_ratio = max_diff_ratio.to_f
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "singleton"
4
+
5
+ module GitlabQuality
6
+ module TestTooling
7
+ module TestMetricsExporter
8
+ class << self
9
+ def configuration
10
+ Config.instance
11
+ end
12
+
13
+ def configure
14
+ yield(configuration)
15
+ end
16
+ end
17
+
18
+ class Config
19
+ include Singleton
20
+
21
+ attr_accessor :influxdb_url,
22
+ :influxdb_token,
23
+ :influxdb_bucket,
24
+ :run_type
25
+
26
+ attr_writer :custom_keys_tags,
27
+ :custom_keys_fields,
28
+ :test_metric_file_name
29
+
30
+ def custom_keys_tags
31
+ @custom_keys_tags || []
32
+ end
33
+
34
+ def custom_keys_fields
35
+ @custom_keys_fields || []
36
+ end
37
+
38
+ def test_metric_file_name
39
+ @test_metric_file_name || "test_metrics.json"
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GitlabQuality
4
+ module TestTooling
5
+ module TestMetricsExporter
6
+ class Formatter < RSpec::Core::Formatters::BaseFormatter
7
+ RSpec::Core::Formatters.register(self, :stop)
8
+
9
+ def stop(_notification)
10
+ setup_test_metrics_exporter
11
+
12
+ log_test_metrics.push_test_metrics(
13
+ custom_keys_tags: config.custom_keys_tags,
14
+ custom_keys_fields: config.custom_keys_fields
15
+ )
16
+
17
+ log_test_metrics.save_test_metrics(
18
+ file_name: config.test_metric_file_name,
19
+ custom_keys_tags: config.custom_keys_tags,
20
+ custom_keys_fields: config.custom_keys_fields
21
+ )
22
+ end
23
+
24
+ private
25
+
26
+ attr_reader :log_test_metrics
27
+
28
+ def config
29
+ Config.configuration
30
+ end
31
+
32
+ def setup_test_metrics_exporter
33
+ @log_test_metrics = LogTestMetrics.new(
34
+ examples: notification.examples,
35
+ influxdb_url: config.influxdb_url,
36
+ influxdb_token: config.influxdb_token,
37
+ influxdb_bucket: config.influxdb_bucket,
38
+ run_type: config.run_type
39
+ )
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module GitlabQuality
4
4
  module TestTooling
5
- module Concerns
5
+ module TestMetricsExporter
6
6
  module InfluxdbTools
7
7
  # InfluxDb client
8
8
  #
@@ -1,13 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'json'
4
-
5
3
  module GitlabQuality
6
4
  module TestTooling
7
- module TestMetric
5
+ module TestMetricsExporter
8
6
  class LogTestMetrics
9
- include Concerns::TestMetrics
10
- include Concerns::InfluxdbTools
7
+ include TestMetrics
8
+ include InfluxdbTools
11
9
 
12
10
  CUSTOM_METRICS_KEY = :custom_test_metrics
13
11
 
@@ -39,7 +37,9 @@ module GitlabQuality
39
37
  # @param [Array<String>] custom_keys_tags
40
38
  # @param [Array<String>] custom_keys_fields
41
39
  # @return [nil]
42
- def save_test_metrics(file_name, custom_keys_tags: nil, custom_keys_fields: nil)
40
+ def save_test_metrics(file_name:, custom_keys_tags: nil, custom_keys_fields: nil)
41
+ return Runtime::Logger.warn("No file_name provided, not saving test metrics") if file_name.nil?
42
+
43
43
  @test_metrics ||= examples.filter_map { |example| parse_test_results(example, custom_keys_tags, custom_keys_fields) }
44
44
  file = "tmp/#{file_name}"
45
45
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module GitlabQuality
4
4
  module TestTooling
5
- module Concerns
5
+ module TestMetricsExporter
6
6
  module TestMetrics
7
7
  # Single common timestamp for all exported example metrics to keep data points consistently grouped
8
8
  #
@@ -30,7 +30,7 @@ module GitlabQuality
30
30
  job_name: job_name,
31
31
  merge_request: merge_request,
32
32
  run_type: run_type,
33
- stage: example.metadata[:product_stage] || example.metadata[:product_category],
33
+ feature_category: example.metadata[:feature_category],
34
34
  product_group: example.metadata[:product_group],
35
35
  exception_class: example.execution_result.exception&.class&.to_s,
36
36
  **custom_metrics(example.metadata, custom_keys)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GitlabQuality
4
4
  module TestTooling
5
- VERSION = "1.25.0"
5
+ VERSION = "1.26.0"
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: 1.25.0
4
+ version: 1.26.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitLab Quality
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-14 00:00:00.000000000 Z
11
+ date: 2024-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -438,8 +438,6 @@ files:
438
438
  - lefthook.yml
439
439
  - lib/gitlab_quality/test_tooling.rb
440
440
  - lib/gitlab_quality/test_tooling/concerns/find_set_dri.rb
441
- - lib/gitlab_quality/test_tooling/concerns/influxdb_tools.rb
442
- - lib/gitlab_quality/test_tooling/concerns/test_metrics.rb
443
441
  - lib/gitlab_quality/test_tooling/failed_jobs_table.rb
444
442
  - lib/gitlab_quality/test_tooling/gitlab_client/branches_client.rb
445
443
  - lib/gitlab_quality/test_tooling/gitlab_client/branches_dry_client.rb
@@ -497,8 +495,12 @@ files:
497
495
  - lib/gitlab_quality/test_tooling/test_meta/processor/meta_processor.rb
498
496
  - lib/gitlab_quality/test_tooling/test_meta/test_meta_updater.rb
499
497
  - lib/gitlab_quality/test_tooling/test_metric/json_test_metric.rb
500
- - lib/gitlab_quality/test_tooling/test_metric/log_test_metrics.rb
501
498
  - lib/gitlab_quality/test_tooling/test_metrics/json_test_metric_collection.rb
499
+ - lib/gitlab_quality/test_tooling/test_metrics_exporter/config.rb
500
+ - lib/gitlab_quality/test_tooling/test_metrics_exporter/formatter.rb
501
+ - lib/gitlab_quality/test_tooling/test_metrics_exporter/influxdb_tools.rb
502
+ - lib/gitlab_quality/test_tooling/test_metrics_exporter/log_test_metrics.rb
503
+ - lib/gitlab_quality/test_tooling/test_metrics_exporter/test_metrics.rb
502
504
  - lib/gitlab_quality/test_tooling/test_result/base_test_result.rb
503
505
  - lib/gitlab_quality/test_tooling/test_result/j_unit_test_result.rb
504
506
  - lib/gitlab_quality/test_tooling/test_result/json_test_result.rb