gitlab_quality-test_tooling 1.36.0 → 1.38.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: 25fe4fd0cb49b8e51816f2da8c88e0722e81c4bd1b71e6ba3f980a8a1ca0e255
4
- data.tar.gz: 679100eddc3bcce725465a9e4c71808fde8917c9014d149639081c22daf95e03
3
+ metadata.gz: 3637a075d6d648d02c32ba655c94a1fcbe7eb4d6aa1c4cabf3387ea5b00b8af3
4
+ data.tar.gz: ba6326ac31d8e7a558069ac6e195841e572ad9f8de772fa3281fd3c7f5c2bc3e
5
5
  SHA512:
6
- metadata.gz: db8f81ef6632edf827cce50997a2318f5d82c17a1714b3bf4cf6e0407aca5ad47bc34de92a49b3d45c3ad764a585085ff93baa1ce3da5da286dc5015ad61e113
7
- data.tar.gz: 157ac822424ad6cf581ac9cd1993071474e5238d61b44f093080358f1829f95505488d9382819173c632e27f3cc9fff5bd8c3aee3efae51b84bc87ef0373b70d
6
+ metadata.gz: 1bed8063e6e2e5504edcf23c88b05390c5ee2ed81651bc108ef28df1d1e70f4ab214fbdb84c0f8e645aaee36f36cfe181ae101a8a5bd9d8063e75bd9ae01e38e
7
+ data.tar.gz: ebfadcceffe6327444fd2f614a29fc31c5116902c0113416ba3d40e3f750381cc5263c6b8a399b5eaaa1c3b96b12853e6467989d48c05116fabdd454db590d11
data/Gemfile.lock CHANGED
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitlab_quality-test_tooling (1.36.0)
4
+ gitlab_quality-test_tooling (1.38.0)
5
5
  activesupport (>= 7.0, < 7.2)
6
6
  amatch (~> 0.4.1)
7
+ fog-google (~> 1.24, >= 1.24.1)
7
8
  gitlab (~> 4.19)
8
9
  http (~> 5.0)
9
10
  influxdb-client (~> 3.1)
@@ -39,6 +40,7 @@ GEM
39
40
  bigdecimal (3.1.8)
40
41
  binding_of_caller (1.0.0)
41
42
  debug_inspector (>= 0.0.1)
43
+ builder (3.3.0)
42
44
  byebug (11.1.3)
43
45
  claide (1.1.0)
44
46
  claide-plugins (0.9.2)
@@ -71,11 +73,13 @@ GEM
71
73
  danger
72
74
  gitlab (~> 4.2, >= 4.2.0)
73
75
  debug_inspector (1.2.0)
76
+ declarative (0.0.20)
74
77
  diff-lcs (1.5.0)
75
78
  docile (1.4.0)
76
79
  domain_name (0.6.20240107)
77
80
  drb (2.2.1)
78
81
  e2mmap (0.1.0)
82
+ excon (0.111.0)
79
83
  faraday (2.9.0)
80
84
  faraday-net_http (>= 2.0, < 3.2)
81
85
  faraday-http-cache (2.5.1)
@@ -86,6 +90,30 @@ GEM
86
90
  ffi-compiler (1.0.1)
87
91
  ffi (>= 1.0.0)
88
92
  rake
93
+ fog-core (2.4.0)
94
+ builder
95
+ excon (~> 0.71)
96
+ formatador (>= 0.2, < 2.0)
97
+ mime-types
98
+ fog-google (1.24.1)
99
+ addressable (>= 2.7.0)
100
+ fog-core (< 2.5)
101
+ fog-json (~> 1.2)
102
+ fog-xml (~> 0.1.0)
103
+ google-apis-compute_v1 (~> 0.53)
104
+ google-apis-dns_v1 (~> 0.28)
105
+ google-apis-iamcredentials_v1 (~> 0.15)
106
+ google-apis-monitoring_v3 (~> 0.37)
107
+ google-apis-pubsub_v1 (~> 0.30)
108
+ google-apis-sqladmin_v1beta4 (~> 0.38)
109
+ google-apis-storage_v1 (>= 0.19, < 1)
110
+ google-cloud-env (>= 1.2, < 3.0)
111
+ fog-json (1.2.0)
112
+ fog-core
113
+ multi_json (~> 1.10)
114
+ fog-xml (0.1.4)
115
+ fog-core
116
+ nokogiri (>= 1.5.11, < 2.0.0)
89
117
  formatador (1.1.0)
90
118
  git (1.19.1)
91
119
  addressable (~> 2.8)
@@ -103,6 +131,37 @@ GEM
103
131
  rubocop-performance (~> 1.15)
104
132
  rubocop-rails (~> 2.17)
105
133
  rubocop-rspec (~> 2.22)
134
+ google-apis-compute_v1 (0.102.0)
135
+ google-apis-core (>= 0.15.0, < 2.a)
136
+ google-apis-core (0.15.0)
137
+ addressable (~> 2.5, >= 2.5.1)
138
+ googleauth (~> 1.9)
139
+ httpclient (>= 2.8.1, < 3.a)
140
+ mini_mime (~> 1.0)
141
+ representable (~> 3.0)
142
+ retriable (>= 2.0, < 4.a)
143
+ rexml
144
+ google-apis-dns_v1 (0.44.0)
145
+ google-apis-core (>= 0.15.0, < 2.a)
146
+ google-apis-iamcredentials_v1 (0.21.0)
147
+ google-apis-core (>= 0.15.0, < 2.a)
148
+ google-apis-monitoring_v3 (0.65.0)
149
+ google-apis-core (>= 0.15.0, < 2.a)
150
+ google-apis-pubsub_v1 (0.54.0)
151
+ google-apis-core (>= 0.15.0, < 2.a)
152
+ google-apis-sqladmin_v1beta4 (0.74.0)
153
+ google-apis-core (>= 0.15.0, < 2.a)
154
+ google-apis-storage_v1 (0.41.0)
155
+ google-apis-core (>= 0.15.0, < 2.a)
156
+ google-cloud-env (2.1.1)
157
+ faraday (>= 1.0, < 3.a)
158
+ googleauth (1.11.0)
159
+ faraday (>= 1.0, < 3.a)
160
+ google-cloud-env (~> 2.1)
161
+ jwt (>= 1.4, < 3.0)
162
+ multi_json (~> 1.11)
163
+ os (>= 0.9, < 2.0)
164
+ signet (>= 0.16, < 2.a)
106
165
  guard (2.18.1)
107
166
  formatador (>= 0.2.4)
108
167
  listen (>= 2.7, < 4.0)
@@ -129,11 +188,14 @@ GEM
129
188
  httparty (0.21.0)
130
189
  mini_mime (>= 1.0.0)
131
190
  multi_xml (>= 0.5.2)
191
+ httpclient (2.8.3)
132
192
  i18n (1.14.5)
133
193
  concurrent-ruby (~> 1.0)
134
194
  influxdb-client (3.1.0)
135
195
  jaro_winkler (1.5.6)
136
196
  json (2.7.1)
197
+ jwt (2.8.2)
198
+ base64
137
199
  kramdown (2.4.0)
138
200
  rexml
139
201
  kramdown-parser-gfm (1.1.0)
@@ -147,11 +209,15 @@ GEM
147
209
  rake (~> 13.0)
148
210
  lumberjack (1.2.10)
149
211
  method_source (1.0.0)
212
+ mime-types (3.5.2)
213
+ mime-types-data (~> 3.2015)
214
+ mime-types-data (3.2024.0702)
150
215
  mini_mime (1.1.5)
151
216
  mini_portile2 (2.8.5)
152
217
  minitest (5.23.0)
153
218
  mize (0.4.1)
154
219
  protocol (~> 2.0)
220
+ multi_json (1.15.0)
155
221
  multi_xml (0.6.0)
156
222
  mutex_m (0.2.0)
157
223
  nap (1.1.0)
@@ -169,6 +235,7 @@ GEM
169
235
  faraday (>= 1, < 3)
170
236
  sawyer (~> 0.9)
171
237
  open4 (1.3.4)
238
+ os (1.1.4)
172
239
  parallel (1.24.0)
173
240
  parser (3.3.0.5)
174
241
  ast (~> 2.4.1)
@@ -196,6 +263,11 @@ GEM
196
263
  rbs (2.8.4)
197
264
  rchardet (1.8.0)
198
265
  regexp_parser (2.9.0)
266
+ representable (3.2.0)
267
+ declarative (< 0.1.0)
268
+ trailblazer-option (>= 0.1.1, < 0.2.0)
269
+ uber (< 0.2.0)
270
+ retriable (3.1.2)
199
271
  reverse_markdown (2.1.1)
200
272
  nokogiri
201
273
  rexml (3.2.6)
@@ -262,6 +334,11 @@ GEM
262
334
  faraday (>= 0.17.3, < 3)
263
335
  sexp_processor (4.17.1)
264
336
  shellany (0.0.1)
337
+ signet (0.19.0)
338
+ addressable (~> 2.8)
339
+ faraday (>= 0.17.5, < 3.a)
340
+ jwt (>= 1.5, < 3.0)
341
+ multi_json (~> 1.10)
265
342
  simplecov (0.22.0)
266
343
  docile (~> 1.1)
267
344
  simplecov-html (~> 0.11)
@@ -296,8 +373,10 @@ GEM
296
373
  timecop (0.9.8)
297
374
  tins (1.32.1)
298
375
  sync
376
+ trailblazer-option (0.1.2)
299
377
  tzinfo (2.0.6)
300
378
  concurrent-ruby (~> 1.0)
379
+ uber (0.1.0)
301
380
  unicode-display_width (2.5.0)
302
381
  unparser (0.6.12)
303
382
  diff-lcs (~> 1.3)
@@ -330,4 +409,4 @@ DEPENDENCIES
330
409
  webmock (= 3.7.0)
331
410
 
332
411
  BUNDLED WITH
333
- 2.5.13
412
+ 2.5.15
@@ -58,7 +58,7 @@ module GitlabQuality
58
58
  end
59
59
 
60
60
  def health_problem_status_label_quick_action(reports_list)
61
- '/label ~"severity::1"' if reports_list.spiked_in_short_period?
61
+ '/label ~"priority::1" ~"severity::1"' if reports_list.spiked_in_short_period?
62
62
  end
63
63
 
64
64
  def up_to_date_labels(test:, issue: nil, new_labels: Set.new)
@@ -100,13 +100,15 @@ module GitlabQuality
100
100
  puts "Reporting tests in `#{files.join(',')}` as issues in project `#{project}` via the API at `#{Runtime::Env.gitlab_api_base}`."
101
101
 
102
102
  TestResults::Builder.new(file_glob: files, token: token, project: project).test_results_per_file do |test_results|
103
- puts "=> Reporting #{test_results.count} tests in #{test_results.path}"
103
+ puts "=> Processing #{test_results.count} tests in #{test_results.path}"
104
104
 
105
105
  process_test_results(test_results)
106
106
  end
107
107
  end
108
108
 
109
109
  def process_test_results(test_results)
110
+ reported_test_count = 0
111
+
110
112
  test_results.each do |test|
111
113
  next unless test_is_applicable?(test)
112
114
 
@@ -123,7 +125,10 @@ module GitlabQuality
123
125
 
124
126
  update_reports(issues, test)
125
127
  collect_issues(test, issues)
128
+ reported_test_count += 1
126
129
  end
130
+
131
+ puts " => Reported #{reported_test_count} #{problem_type} tests."
127
132
  end
128
133
 
129
134
  def update_reports(issues, test)
@@ -28,7 +28,7 @@ module GitlabQuality
28
28
 
29
29
  contents['specs'].each do |spec|
30
30
  processor.create_commit(spec, self)
31
- break if processed_commits.keys.count >= ENV.fetch('BATCH_LIMIT', 10)
31
+ break if processed_commits.keys.count >= batch_limit
32
32
  end
33
33
 
34
34
  processor.create_merge_requests(self)
@@ -37,6 +37,13 @@ module GitlabQuality
37
37
  end
38
38
  end
39
39
 
40
+ # Returns the number of records to process
41
+ #
42
+ # @return [Integer]
43
+ def batch_limit
44
+ ENV.fetch('BATCH_LIMIT', 10).to_i
45
+ end
46
+
40
47
  # Add processed commits.
41
48
  #
42
49
  # processed_commits has the following form. Note that each key in the :commits hash
@@ -21,11 +21,15 @@ module GitlabQuality
21
21
  attr_accessor :influxdb_url,
22
22
  :influxdb_token,
23
23
  :influxdb_bucket,
24
+ :gcs_bucket,
25
+ :gcs_project_id,
26
+ :gcs_credentials,
27
+ :gcs_metrics_file_name,
28
+ :test_metric_file_name,
24
29
  :run_type
25
30
 
26
31
  attr_writer :custom_keys_tags,
27
- :custom_keys_fields,
28
- :test_metric_file_name
32
+ :custom_keys_fields
29
33
 
30
34
  def custom_keys_tags
31
35
  @custom_keys_tags || []
@@ -34,10 +38,6 @@ module GitlabQuality
34
38
  def custom_keys_fields
35
39
  @custom_keys_fields || []
36
40
  end
37
-
38
- def test_metric_file_name
39
- @test_metric_file_name || "test_metrics.json"
40
- end
41
41
  end
42
42
  end
43
43
  end
@@ -29,15 +29,27 @@ module GitlabQuality
29
29
  Config.configuration
30
30
  end
31
31
 
32
+ # rubocop:disable Metrics/AbcSize
32
33
  def setup_test_metrics_exporter(examples)
33
34
  @log_test_metrics = LogTestMetrics.new(
34
35
  examples: examples,
36
+ run_type: config.run_type
37
+ )
38
+
39
+ @log_test_metrics.configure_influxdb_client(
35
40
  influxdb_url: config.influxdb_url,
36
41
  influxdb_token: config.influxdb_token,
37
- influxdb_bucket: config.influxdb_bucket,
38
- run_type: config.run_type
42
+ influxdb_bucket: config.influxdb_bucket
43
+ )
44
+
45
+ @log_test_metrics.configure_gcs_client(
46
+ gcs_bucket: config.gcs_bucket,
47
+ gcs_project_id: config.gcs_project_id,
48
+ gcs_credentials: config.gcs_credentials,
49
+ gcs_metrics_file_name: config.gcs_metrics_file_name
39
50
  )
40
51
  end
52
+ # rubocop:enable Metrics/AbcSize
41
53
  end
42
54
  end
43
55
  end
@@ -5,19 +5,33 @@ module GitlabQuality
5
5
  module TestMetricsExporter
6
6
  class LogTestMetrics
7
7
  include TestMetrics
8
- include InfluxdbTools
8
+ include Support::InfluxdbTools
9
+ include Support::GcsTools
9
10
 
10
11
  CUSTOM_METRICS_KEY = :custom_test_metrics
11
12
 
12
- def initialize(examples:, influxdb_url: nil, influxdb_token: nil, influxdb_bucket: nil, run_type: nil)
13
+ def initialize(
14
+ examples:,
15
+ run_type: nil
16
+ )
13
17
  @examples = examples
18
+ @run_type = run_type
19
+ end
20
+
21
+ def configure_influxdb_client(influxdb_url: nil, influxdb_token: nil, influxdb_bucket: nil)
14
22
  @influxdb_url = influxdb_url
15
23
  @influxdb_token = influxdb_token
16
24
  @influxdb_bucket = influxdb_bucket
17
- @run_type = run_type
18
25
  end
19
26
 
20
- # Push test execution metrics to influxdb
27
+ def configure_gcs_client(gcs_bucket: nil, gcs_project_id: nil, gcs_credentials: nil, gcs_metrics_file_name: nil)
28
+ @gcs_bucket = gcs_bucket
29
+ @gcs_project_id = gcs_project_id
30
+ @gcs_credentials = gcs_credentials
31
+ @gcs_metrics_file_name = gcs_metrics_file_name
32
+ end
33
+
34
+ # Push test execution metrics
21
35
  #
22
36
  # @param [Array<String>] custom_keys_tags
23
37
  # @param [Array<String>] custom_keys_fields
@@ -25,10 +39,8 @@ module GitlabQuality
25
39
  def push_test_metrics(custom_keys_tags: nil, custom_keys_fields: nil)
26
40
  @test_metrics ||= examples.filter_map { |example| parse_test_results(example, custom_keys_tags, custom_keys_fields) }
27
41
 
28
- write_api(url: influxdb_url, token: influxdb_token, bucket: influxdb_bucket).write(data: test_metrics)
29
- Runtime::Logger.debug("Pushed #{test_metrics.length} test execution entries to influxdb")
30
- rescue StandardError => e
31
- Runtime::Logger.error("Failed to push test execution metrics to influxdb, error: #{e}")
42
+ push_test_metrics_to_influxdb
43
+ push_test_metrics_to_gcs
32
44
  end
33
45
 
34
46
  # Save metrics in json file
@@ -43,14 +55,43 @@ module GitlabQuality
43
55
  @test_metrics ||= examples.filter_map { |example| parse_test_results(example, custom_keys_tags, custom_keys_fields) }
44
56
  file = "tmp/#{file_name}"
45
57
 
46
- File.write(file, test_metrics.to_json) && Runtime::Logger.debug("Saved test metrics to #{file}")
58
+ File.write(file, test_metrics.to_json) && Runtime::Logger.info("Saved test metrics to #{file}")
47
59
  rescue StandardError => e
48
60
  Runtime::Logger.error("Failed to save test execution metrics, error: #{e}")
49
61
  end
50
62
 
51
63
  private
52
64
 
53
- attr_reader :examples, :test_metrics, :influxdb_url, :influxdb_token, :influxdb_bucket, :run_type
65
+ attr_reader :examples, :test_metrics, :influxdb_url, :influxdb_token, :influxdb_bucket, :run_type, :gcs_bucket,
66
+ :gcs_project_id, :gcs_credentials, :gcs_metrics_file_name
67
+
68
+ # Push test execution metrics to Influxdb
69
+ #
70
+ # @return [nil]
71
+ def push_test_metrics_to_influxdb
72
+ write_api(url: influxdb_url, token: influxdb_token, bucket: influxdb_bucket).write(data: test_metrics)
73
+ Runtime::Logger.info("Pushed #{test_metrics.length} test execution entries to Influxdb")
74
+ rescue StandardError => e
75
+ Runtime::Logger.error("Failed to push test execution metrics to Influxdb, error: #{e}")
76
+ end
77
+
78
+ # Push test execution metrics to GCS
79
+ #
80
+ # @return [nil]
81
+ def push_test_metrics_to_gcs
82
+ gcs_client(project_id: gcs_project_id, credentials: gcs_credentials)
83
+ .put_object(
84
+ gcs_bucket || raise("Missing GCS bucket name"),
85
+ gcs_metrics_file_name,
86
+ test_metrics.to_json,
87
+ force: true,
88
+ content_type: 'application/json'
89
+ )
90
+
91
+ Runtime::Logger.info("Pushed #{test_metrics.length} test execution entries to GCS")
92
+ rescue StandardError => e
93
+ Runtime::Logger.error("Failed to push test execution metrics to GCS, error: #{e}")
94
+ end
54
95
 
55
96
  # Transform example to influxdb compatible metrics data
56
97
  # https://github.com/influxdata/influxdb-client-ruby#data-format
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fog/google'
4
+
5
+ module GitlabQuality
6
+ module TestTooling
7
+ module TestMetricsExporter
8
+ module Support
9
+ module GcsTools
10
+ # GCS Client
11
+ #
12
+ # @param project_id [String]
13
+ # @param credentials [String]
14
+ # @return [Fog::Storage::Google]
15
+ def gcs_client(project_id:, credentials:)
16
+ Fog::Storage::Google.new(
17
+ google_project: project_id || raise("Missing Google project_id"),
18
+ **gcs_creds(credentials)
19
+ )
20
+ end
21
+
22
+ # GCS Credentials
23
+ #
24
+ # @param credentials [String]
25
+ # @return [Hash]
26
+ def gcs_creds(credentials)
27
+ json_key = credentials || raise('Missing Google credentials')
28
+ return { google_json_key_location: json_key } if File.exist?(json_key)
29
+
30
+ { google_json_key_string: json_key }
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'influxdb-client'
4
+
5
+ module GitlabQuality
6
+ module TestTooling
7
+ module TestMetricsExporter
8
+ module Support
9
+ module InfluxdbTools
10
+ # InfluxDb client
11
+ #
12
+ # @return [InfluxDB2::Client]
13
+ def influx_client(url:, token:, bucket:)
14
+ @influx_client ||= InfluxDB2::Client.new(
15
+ url || raise('Missing influxdb_url'),
16
+ token || raise('Missing influxdb_token'),
17
+ bucket: bucket || raise('Missing influxdb_bucket'),
18
+ org: "gitlab-qa",
19
+ precision: InfluxDB2::WritePrecision::NANOSECOND
20
+ )
21
+ end
22
+
23
+ # Write client
24
+ #
25
+ # @return [WriteApi]
26
+ def write_api(url:, token:, bucket:)
27
+ @write_api ||= influx_client(url: url, token: token, bucket: bucket).create_write_api
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GitlabQuality
4
4
  module TestTooling
5
- VERSION = "1.36.0"
5
+ VERSION = "1.38.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.36.0
4
+ version: 1.38.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-08-28 00:00:00.000000000 Z
11
+ date: 2024-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: climate_control
@@ -268,6 +268,26 @@ dependencies:
268
268
  - - "~>"
269
269
  - !ruby/object:Gem::Version
270
270
  version: '3.1'
271
+ - !ruby/object:Gem::Dependency
272
+ name: fog-google
273
+ requirement: !ruby/object:Gem::Requirement
274
+ requirements:
275
+ - - "~>"
276
+ - !ruby/object:Gem::Version
277
+ version: '1.24'
278
+ - - ">="
279
+ - !ruby/object:Gem::Version
280
+ version: 1.24.1
281
+ type: :runtime
282
+ prerelease: false
283
+ version_requirements: !ruby/object:Gem::Requirement
284
+ requirements:
285
+ - - "~>"
286
+ - !ruby/object:Gem::Version
287
+ version: '1.24'
288
+ - - ">="
289
+ - !ruby/object:Gem::Version
290
+ version: 1.24.1
271
291
  - !ruby/object:Gem::Dependency
272
292
  name: nokogiri
273
293
  requirement: !ruby/object:Gem::Requirement
@@ -479,8 +499,9 @@ files:
479
499
  - lib/gitlab_quality/test_tooling/test_metrics/json_test_metric_collection.rb
480
500
  - lib/gitlab_quality/test_tooling/test_metrics_exporter/config.rb
481
501
  - lib/gitlab_quality/test_tooling/test_metrics_exporter/formatter.rb
482
- - lib/gitlab_quality/test_tooling/test_metrics_exporter/influxdb_tools.rb
483
502
  - lib/gitlab_quality/test_tooling/test_metrics_exporter/log_test_metrics.rb
503
+ - lib/gitlab_quality/test_tooling/test_metrics_exporter/support/gcs_tools.rb
504
+ - lib/gitlab_quality/test_tooling/test_metrics_exporter/support/influxdb_tools.rb
484
505
  - lib/gitlab_quality/test_tooling/test_metrics_exporter/test_metrics.rb
485
506
  - lib/gitlab_quality/test_tooling/test_result/base_test_result.rb
486
507
  - lib/gitlab_quality/test_tooling/test_result/j_unit_test_result.rb
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'influxdb-client'
4
-
5
- module GitlabQuality
6
- module TestTooling
7
- module TestMetricsExporter
8
- module InfluxdbTools
9
- # InfluxDb client
10
- #
11
- # @return [InfluxDB2::Client]
12
- def influx_client(url:, token:, bucket:)
13
- @influx_client ||= InfluxDB2::Client.new(
14
- url || raise('Missing influxdb_url'),
15
- token || raise('Missing influxdb_token'),
16
- bucket: bucket || raise('Missing influxdb_bucket'),
17
- org: "gitlab-qa",
18
- precision: InfluxDB2::WritePrecision::NANOSECOND
19
- )
20
- end
21
-
22
- # Write client
23
- #
24
- # @return [WriteApi]
25
- def write_api(url:, token:, bucket:)
26
- @write_api ||= influx_client(url: url, token: token, bucket: bucket).create_write_api
27
- end
28
- end
29
- end
30
- end
31
- end