qa_server 7.1.1 → 7.1.2

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
  SHA1:
3
- metadata.gz: b76bc4d754d7b4fde7b44483af5e442f7ec57866
4
- data.tar.gz: 596c4ee549b8157470bbd184966cc5f136b19084
3
+ metadata.gz: c75de6851b1a52b9d4f482ef560bd0bae7107524
4
+ data.tar.gz: 25e2b0642efce7a0f73e260057248621d17f7e94
5
5
  SHA512:
6
- metadata.gz: f05e9708ede292b5ffe541e45d2061731fb2822284cdfd3f9e43993eaa7adf940904e230b9d2591fb70dc879e372f48ffa87d95122ea9d14064b1989169847af
7
- data.tar.gz: 41c0d98b7169ade0f5a18780d47a90bd6bdbfd888edca6c2f7606a332701903311704513210e0fb17f692876714a0fb6510eda4a8b48d9ceedabdf7144092786
6
+ metadata.gz: 145db9e102f9e88a48cb4e3fdd99687b70890d16751c8d9d43471eeeb126e478085ccce96f0e6d8a37170c91146c6e9704d2839ec899949acea0a88913ae16f6
7
+ data.tar.gz: 203aee3ca6a69164bf5f4b9ac6e6db49901d622e88a15521303c9815311e4f8182c74d7a8fd7485f57b848de3748081a42fcb5f4c0dedacfccb72bd6bf479405
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ### 7.1.2 (2020-02-21)
2
+
3
+ * make configs that return true/false end with ?
4
+ * add tests for configs that weren’t tested
5
+ * fix bugs in config#convert_size_to_bytes in response to testing
6
+
1
7
  ### 7.1.1 (2020-02-21)
2
8
 
3
9
  * empty performance cache after running monitor status tests
@@ -59,7 +59,7 @@ module QaServer
59
59
  end
60
60
 
61
61
  def log(id:)
62
- return if QaServer.config.suppress_logging_performance_datails
62
+ return if QaServer.config.suppress_logging_performance_datails?
63
63
  Rails.logger.debug("*** performance data for id: #{id} ***")
64
64
  Rails.logger.debug(@cache[id].to_yaml)
65
65
  end
@@ -3,7 +3,7 @@ module PrependedLinkedData::FindTerm
3
3
  # Override Qa::Authorities::LinkedData::FindTerm#find method
4
4
  # @return [Hash] single term results in requested format
5
5
  def find(id, request_header: {}, language: nil, replacements: {}, subauth: nil, format: nil, performance_data: false) # rubocop:disable Metrics/ParameterLists
6
- return super if QaServer.config.suppress_performance_gathering
6
+ return super if QaServer.config.suppress_performance_gathering?
7
7
  request_header = setup_find(request_header: request_header, language: language, replacements: replacements, subauth: subauth,
8
8
  format: format, performance_data: performance_data)
9
9
  @phid = QaServer.config.performance_cache.new_entry(authority: authority_name, action: 'fetch')
@@ -40,7 +40,7 @@ module PrependedLinkedData::FindTerm
40
40
 
41
41
  # Override to append performance history record id into the URL to allow access to the record in RDF::Graph
42
42
  def load_graph(url:)
43
- return super if QaServer.config.suppress_performance_gathering
43
+ return super if QaServer.config.suppress_performance_gathering?
44
44
 
45
45
  access_start_dt = QaServer::TimeService.current_time
46
46
 
@@ -55,7 +55,7 @@ module PrependedLinkedData::FindTerm
55
55
 
56
56
  # Temporary override to fix bug. Remove when QA Issue #271 is fixed and a new release is cut
57
57
  def performance_data?
58
- return super if QaServer.config.suppress_performance_gathering
58
+ return super if QaServer.config.suppress_performance_gathering?
59
59
  @performance_data == true
60
60
  end
61
61
 
@@ -3,7 +3,7 @@ module PrependedLinkedData::SearchQuery
3
3
  # Override Qa::Authorities::LinkedData::SearchQuery#search method
4
4
  # @return [String] json results for search query
5
5
  def search(query, request_header: {}, language: nil, replacements: {}, subauth: nil, context: false, performance_data: false) # rubocop:disable Metrics/ParameterLists
6
- return super if QaServer.config.suppress_performance_gathering
6
+ return super if QaServer.config.suppress_performance_gathering?
7
7
  request_header = setup_search(request_header: request_header, language: language, replacements: replacements, subauth: subauth,
8
8
  context: context, performance_data: performance_data)
9
9
  @phid = QaServer.config.performance_cache.new_entry(authority: authority_name, action: 'search')
@@ -40,7 +40,7 @@ module PrependedLinkedData::SearchQuery
40
40
 
41
41
  # Override to append performance history record id into the URL to allow access to the record in RDF::Graph
42
42
  def load_graph(url:)
43
- return super if QaServer.config.suppress_performance_gathering
43
+ return super if QaServer.config.suppress_performance_gathering?
44
44
 
45
45
  access_start_dt = QaServer::TimeService.current_time
46
46
 
@@ -12,7 +12,7 @@ module PrependedRdf::RdfGraph
12
12
  # Set set graph name of each loaded statement
13
13
  # @return [void]
14
14
  def load(url, graph_name: nil, **options) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
15
- return super if QaServer.config.suppress_performance_gathering
15
+ return super if QaServer.config.suppress_performance_gathering?
16
16
 
17
17
  raise TypeError, "#{self} is immutable" if immutable?
18
18
  phid, real_url = parse_phid(url)
@@ -63,7 +63,7 @@ module QaServer
63
63
  # @param time_period [Symbol] time period for calculating historical pass/fail (i.e., one of :month, :year, or :all)
64
64
  # @raise [ArgumentError] if time_period is not one of :month, :year, or :all
65
65
  def historical_datatable_default_time_period=(time_period)
66
- raise ArgumentError, 'time_period must be one of :day, :month, or :year' unless [:month, :year, :all].include? time_period
66
+ raise ArgumentError, 'time_period must be one of :month, :year, or :all' unless [:month, :year, :all].include? time_period
67
67
  @historical_datatable_default_time_period = time_period
68
68
  end
69
69
 
@@ -189,17 +189,23 @@ module QaServer
189
189
  # impact and may need to be suppressed. Performance stats will not be gathered when this config is true.
190
190
  # @param [Boolean] do not gather performance data when true (defaults to false for backward compatibitily)
191
191
  attr_writer :suppress_performance_gathering
192
- def suppress_performance_gathering
192
+ def suppress_performance_gathering?
193
+ return @suppress_performance_gathering unless @suppress_performance_gathering.nil?
193
194
  @suppress_performance_gathering ||= false
194
195
  end
196
+ alias suppress_performance_gathering suppress_performance_gathering?
197
+ deprecation_deprecate suppress_performance_gathering: "use #suppress_performance_gathering? instead"
195
198
 
196
199
  # Performance data is gathered on every incoming query. Basic stats are logged from QA. Full stats are logged
197
200
  # by QaServer and can eat up logging realestate. To suppress the logging of details, set this config to true.
198
201
  # @param [Boolean] do not log performance data details when true (defaults to false for backward compatibitily)
199
202
  attr_writer :suppress_logging_performance_datails
200
- def suppress_logging_performance_datails
203
+ def suppress_logging_performance_datails?
204
+ return @suppress_logging_performance_datails unless @suppress_logging_performance_datails.nil?
201
205
  @suppress_logging_performance_datails ||= false
202
206
  end
207
+ alias suppress_logging_performance_datails suppress_logging_performance_datails?
208
+ deprecation_deprecate suppress_logging_performance_datails: "use #suppress_logging_performance_datails? instead"
203
209
 
204
210
  # Maximum amount of memory the performance cache can occupy before it is written to the database.
205
211
  # @param [Integer] maximum size of performance cache before flushing
@@ -246,7 +252,9 @@ module QaServer
246
252
  private
247
253
 
248
254
  def convert_size_to_bytes(size)
255
+ return if size.nil?
249
256
  md = size.match(/^(?<num>\d+)\s?(?<unit>\w+)?$/)
257
+ return md[:num].to_i if md[:unit].nil?
250
258
  md[:num].to_i *
251
259
  case md[:unit].upcase
252
260
  when 'KB'
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module QaServer
3
- VERSION = '7.1.1'
3
+ VERSION = '7.1.2'
4
4
  end
@@ -62,6 +62,30 @@ RSpec.describe QaServer::Configuration do
62
62
  end
63
63
  end
64
64
 
65
+ describe '#historical_datatable_default_time_period=' do
66
+ it 'raises exception if time_period is invalid' do
67
+ expect { config.historical_datatable_default_time_period = :day }.to raise_error ArgumentError, 'time_period must be one of :month, :year, or :all'
68
+ expect { config.historical_datatable_default_time_period = :decade }.to raise_error ArgumentError, 'time_period must be one of :month, :year, or :all'
69
+ end
70
+
71
+ it 'sets time_period if valid' do
72
+ expect(config.historical_datatable_default_time_period = :month).to eq :month
73
+ expect(config.historical_datatable_default_time_period = :year).to eq :year
74
+ expect(config.historical_datatable_default_time_period = :all).to eq :all
75
+ end
76
+ end
77
+
78
+ describe '#historical_datatable_default_time_period' do
79
+ it 'return default as :year' do
80
+ expect(config.historical_datatable_default_time_period).to eq :year
81
+ end
82
+
83
+ it 'returns set value' do
84
+ config.historical_datatable_default_time_period = :month
85
+ expect(config.historical_datatable_default_time_period).to eq :month
86
+ end
87
+ end
88
+
65
89
  describe '#display_performance_graph?' do
66
90
  it 'return default as false' do
67
91
  expect(config.display_performance_graph?).to eq false
@@ -196,4 +220,99 @@ RSpec.describe QaServer::Configuration do
196
220
  expect(config.performance_datatable_warning_threshold).to eq 500
197
221
  end
198
222
  end
223
+
224
+ describe '#suppress_performance_gathering?' do
225
+ it 'return default as false' do
226
+ expect(config.suppress_performance_gathering?).to eq false
227
+ end
228
+
229
+ it 'returns set value' do
230
+ config.suppress_performance_gathering = true
231
+ expect(config.suppress_performance_gathering?).to eq true
232
+ end
233
+ end
234
+
235
+ describe '#suppress_logging_performance_datails?' do
236
+ it 'return default as false' do
237
+ expect(config.suppress_logging_performance_datails?).to eq false
238
+ end
239
+
240
+ it 'returns set value' do
241
+ config.suppress_logging_performance_datails = true
242
+ expect(config.suppress_logging_performance_datails?).to eq true
243
+ end
244
+ end
245
+
246
+ describe '#max_performance_cache_size' do
247
+ it 'return default as 32MB' do
248
+ expect(config.max_performance_cache_size).to eq 32.megabytes
249
+ end
250
+
251
+ it 'returns set value' do
252
+ config.max_performance_cache_size = 500
253
+ expect(config.max_performance_cache_size).to eq 500
254
+ end
255
+
256
+ context 'when value set through ENV' do
257
+ context 'when no unit specified' do
258
+ before { stub_const('ENV', 'MAX_PERFORMANCE_CACHE_SIZE' => '96') }
259
+ it 'sets value as is' do
260
+ expect(config.max_performance_cache_size).to eq 96
261
+ end
262
+ end
263
+
264
+ context 'when unit is KB' do
265
+ before { stub_const('ENV', 'MAX_PERFORMANCE_CACHE_SIZE' => '64KB') }
266
+ it 'sets value as is' do
267
+ expect(config.max_performance_cache_size).to eq 64.kilobytes
268
+ end
269
+ end
270
+
271
+ context 'when unit is MB' do
272
+ before { stub_const('ENV', 'MAX_PERFORMANCE_CACHE_SIZE' => '16mb') }
273
+ it 'sets value as is' do
274
+ expect(config.max_performance_cache_size).to eq 16.megabytes
275
+ end
276
+ end
277
+
278
+ context 'when unit is GB' do
279
+ before { stub_const('ENV', 'MAX_PERFORMANCE_CACHE_SIZE' => '8 gb') }
280
+ it 'sets value as is' do
281
+ expect(config.max_performance_cache_size).to eq 8.gigabytes
282
+ end
283
+ end
284
+ end
285
+ end
286
+
287
+ describe '#enable_performance_cache_logging' do
288
+ before { stub_const('ENV', 'PERFORMANCE_CACHE_LOG_PATH' => 'tmp/performance_cache.log') }
289
+ it 'sets logger level to DEBUG' do
290
+ config.enable_performance_cache_logging
291
+ expect(config.performance_cache_logger.level).to be Logger::DEBUG
292
+ end
293
+ end
294
+
295
+ describe '#disable_performance_cache_logging' do
296
+ before { stub_const('ENV', 'PERFORMANCE_CACHE_LOG_PATH' => 'tmp/performance_cache.log') }
297
+ it 'sets logger level to INFO' do
298
+ config.disable_performance_cache_logging
299
+ expect(config.performance_cache_logger.level).to be Logger::INFO
300
+ end
301
+ end
302
+
303
+ describe '#enable_monitor_status_logging' do
304
+ before { stub_const('ENV', 'MONITOR_LOG_PATH' => 'tmp/monitor.log') }
305
+ it 'sets logger level to DEBUG' do
306
+ config.enable_monitor_status_logging
307
+ expect(config.monitor_logger.level).to be Logger::DEBUG
308
+ end
309
+ end
310
+
311
+ describe '#disable_monitor_status_logging' do
312
+ before { stub_const('ENV', 'MONITOR_LOG_PATH' => 'tmp/monitor.log') }
313
+ it 'sets logger level to INFO' do
314
+ config.disable_monitor_status_logging
315
+ expect(config.monitor_logger.level).to be Logger::INFO
316
+ end
317
+ end
199
318
  end
data/tmp/.keep ADDED
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qa_server
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.1
4
+ version: 7.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - E. Lynette Rayle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-21 00:00:00.000000000 Z
11
+ date: 2020-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -500,6 +500,7 @@ files:
500
500
  - spec/test_app_templates/Gemfile.extra
501
501
  - spec/test_app_templates/lib/generators/test_app_generator.rb
502
502
  - tasks/qa_server_dev.rake
503
+ - tmp/.keep
503
504
  homepage: http://github.com/LD4P/qa_server
504
505
  licenses:
505
506
  - Apache-2.0