qa_server 7.5.1 → 7.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_fixme.yml +3 -2
  3. data/.travis.yml +1 -1
  4. data/CHANGELOG.md +28 -0
  5. data/app/assets/stylesheets/qa_server/_check-status.scss +4 -0
  6. data/app/assets/stylesheets/qa_server/_monitor-status.scss +45 -0
  7. data/app/cache_processors/concerns/qa_server/cache_keys.rb +1 -0
  8. data/app/cache_processors/qa_server/scenario_history_cache.rb +19 -1
  9. data/app/controllers/qa_server/monitor_status_controller.rb +39 -9
  10. data/app/models/qa_server/scenario_run_history.rb +12 -3
  11. data/app/models/qa_server/search_scenario.rb +6 -0
  12. data/app/presenters/qa_server/check_status_presenter.rb +1 -1
  13. data/app/presenters/qa_server/monitor_status/current_status_presenter.rb +9 -8
  14. data/app/presenters/qa_server/monitor_status/history_presenter.rb +55 -4
  15. data/app/presenters/qa_server/monitor_status/history_up_down_presenter.rb +58 -0
  16. data/app/presenters/qa_server/monitor_status_presenter.rb +7 -2
  17. data/app/services/qa_server/history_up_down_service.rb +103 -0
  18. data/app/services/qa_server/time_service.rb +6 -0
  19. data/app/views/qa_server/check_status/index.html.erb +7 -6
  20. data/app/views/qa_server/monitor_status/_test_summary.html.erb +1 -1
  21. data/app/views/qa_server/monitor_status/_test_up_down_connection_history.html.erb +30 -0
  22. data/app/views/qa_server/monitor_status/index.html.erb +2 -1
  23. data/config/locales/qa_server.en.yml +8 -7
  24. data/lib/generators/qa_server/templates/config/authorities/linked_data/getty_tgn_ld4l_cache.json +24 -14
  25. data/lib/generators/qa_server/templates/config/authorities/linked_data/getty_ulan_ld4l_cache.json +104 -8
  26. data/lib/generators/qa_server/templates/config/authorities/linked_data/locnames_rwo2_ld4l_cache.json +4 -4
  27. data/lib/generators/qa_server/templates/config/authorities/linked_data/locnames_rwo3_ld4l_cache.json +4 -4
  28. data/lib/generators/qa_server/templates/config/authorities/linked_data/locnames_rwo_ld4l_cache.json +4 -4
  29. data/lib/generators/qa_server/templates/config/authorities/linked_data/locvocabs_ld4l_cache.json +1 -1
  30. data/lib/generators/qa_server/templates/config/authorities/linked_data/mesh_nlm_ld4l_cache.json +1 -0
  31. data/lib/generators/qa_server/templates/config/authorities/linked_data/oclcfast_direct.json +4 -0
  32. data/lib/generators/qa_server/templates/config/authorities/linked_data/oclcfast_ld4l_cache.json +1 -0
  33. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/cerl_ld4l_cache_validation.yml +3 -3
  34. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/geonames_ld4l_cache_validation.yml +2 -5
  35. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/getty_aat_ld4l_cache_validation.yml +0 -3
  36. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/getty_tgn_ld4l_cache_validation.yml +3 -7
  37. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/getty_ulan_ld4l_cache_validation.yml +5 -5
  38. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locdemographics_ld4l_cache_validation.yml +0 -4
  39. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locgenres_ld4l_cache_validation.yml +0 -9
  40. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locnames_ld4l_cache_validation.yml +1 -7
  41. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locnames_rwo2_ld4l_cache_validation.yml +78 -0
  42. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locnames_rwo3_ld4l_cache_validation.yml +73 -0
  43. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locnames_rwo_ld4l_cache_validation.yml +11 -11
  44. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locsubjects_ld4l_cache_validation.yml +1 -3
  45. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locvocabs_ld4l_cache_validation.yml +246 -0
  46. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/mesh_nlm_ld4l_cache_validation.yml +8 -5
  47. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/oclcfast_direct_validation.yml +13 -7
  48. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/oclcfast_ld4l_cache_validation.yml +19 -3
  49. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/rda_registry_ld4l_cache_validation.yml +0 -3
  50. data/lib/generators/qa_server/templates/config/initializers/qa_server.rb +8 -0
  51. data/lib/qa_server/configuration.rb +14 -0
  52. data/lib/qa_server/version.rb +1 -1
  53. data/qa_server.gemspec +5 -5
  54. data/spec/feature/accuracy_spec.rb +1 -1
  55. data/spec/i18n_spec.rb +0 -1
  56. data/spec/lib/configuration_spec.rb +22 -0
  57. data/spec/presenters/qa_server/monitor_status/history_presenter_spec.rb +81 -0
  58. data/spec/services/qa_server/history_up_down_service_spec.rb +86 -0
  59. metadata +39 -12
@@ -14,10 +14,6 @@ search:
14
14
  -
15
15
  query: Malignant Hyperthermia
16
16
  subauth: subject
17
- -
18
- query: Spain
19
- subauth: subject
20
- result_size: 75
21
17
  -
22
18
  query: Address
23
19
  subauth: publication_type
@@ -26,7 +22,6 @@ search:
26
22
  # Accuracy tests
27
23
  #------------------
28
24
  -
29
- pending: true
30
25
  query: Malignant Hyperthermia
31
26
  subject_uri: "http://id.nlm.nih.gov/mesh/D008305"
32
27
  position: 3
@@ -47,6 +42,14 @@ search:
47
42
  position: 3
48
43
  replacements:
49
44
  maxRecords: '8'
45
+ -
46
+ pending: true
47
+ query: Spain
48
+ subauth: geographic
49
+ subject_uri: "http://id.nlm.nih.gov/mesh/D013030"
50
+ position: 3
51
+ replacements:
52
+ maxRecords: '8'
50
53
  -
51
54
  pending: true
52
55
  query: Email
@@ -26,12 +26,13 @@ search:
26
26
  replacements:
27
27
  maxRecords: '4'
28
28
  # -
29
- # query: War
29
+ # # This is an event at OCLCFAST web-search, but a meeting through OCLCFAST API.
30
+ # query: Bronze Night
30
31
  # subauth: event_name
31
32
  # replacements:
32
33
  # maxRecords: '4'
33
34
  -
34
- query: Festival
35
+ query: convention
35
36
  subauth: meeting
36
37
  replacements:
37
38
  maxRecords: '4'
@@ -71,7 +72,6 @@ search:
71
72
  replacements:
72
73
  maxRecords: '5'
73
74
  -
74
- pending: true
75
75
  query: Sleep-overs
76
76
  subauth: concept
77
77
  subject_uri: "http://id.worldcat.org/fast/1120873"
@@ -79,6 +79,7 @@ search:
79
79
  replacements:
80
80
  maxRecords: '10'
81
81
  -
82
+ # This is a meeting in OCLCFAST_DIRECT, but event in OCLCFAST_LD4L_CACHE.
82
83
  pending: true
83
84
  query: People's International Tribunal on the Rights of Indigenous Hawaiians
84
85
  subauth: event
@@ -86,6 +87,13 @@ search:
86
87
  position: 3
87
88
  replacements:
88
89
  maxRecords: '8'
90
+ -
91
+ query: Science Fiction
92
+ subauth: meeting
93
+ subject_uri: "http://id.worldcat.org/fast/1406163"
94
+ position: 5
95
+ replacements:
96
+ maxRecords: '10'
89
97
  -
90
98
  pending: true
91
99
  query: University of Chicago Library
@@ -102,7 +110,6 @@ search:
102
110
  replacements:
103
111
  maxRecords: '20'
104
112
  -
105
- pending: true
106
113
  query: Sjælland
107
114
  subauth: place
108
115
  result_size: 190
@@ -111,13 +118,12 @@ search:
111
118
  replacements:
112
119
  maxRecords: '10'
113
120
  -
114
- pending: true
115
121
  query: Scream
116
122
  subauth: work
117
123
  subject_uri: "http://id.worldcat.org/fast/1358031"
118
- position: 5
124
+ position: 10
119
125
  replacements:
120
- maxRecords: '10'
126
+ maxRecords: '20'
121
127
  term:
122
128
  -
123
129
  identifier: '1914919'
@@ -13,6 +13,9 @@ search:
13
13
  -
14
14
  query: tribunal
15
15
  subauth: event
16
+ -
17
+ query: convention
18
+ subauth: meeting
16
19
  -
17
20
  query: 'mark twain'
18
21
  subauth: person
@@ -32,7 +35,6 @@ search:
32
35
  # Accuracy tests
33
36
  #------------------
34
37
  -
35
- pending: true
36
38
  query: Tralee & Dingle Railway
37
39
  subject_uri: "http://id.worldcat.org/fast/1733583"
38
40
  position: 3
@@ -53,6 +55,14 @@ search:
53
55
  replacements:
54
56
  maxRecords: '8'
55
57
  -
58
+ query: Science Fiction
59
+ subauth: meeting
60
+ subject_uri: "http://id.worldcat.org/fast/1406163"
61
+ position: 5
62
+ replacements:
63
+ maxRecords: '10'
64
+ -
65
+ pending: true
56
66
  query: University of Chicago Library
57
67
  subauth: organization
58
68
  subject_uri: "http://id.worldcat.org/fast/539173"
@@ -78,10 +88,16 @@ search:
78
88
  query: Scream
79
89
  subauth: work
80
90
  subject_uri: "http://id.worldcat.org/fast/1358031"
81
- position: 5
91
+ position: 10
92
+ replacements:
93
+ maxRecords: '20'
94
+ -
95
+ query: 'mark twain'
96
+ subauth: intangible
97
+ subject_uri: "http://id.worldcat.org/fast/1200561"
98
+ position: 3
82
99
  replacements:
83
100
  maxRecords: '10'
84
-
85
101
  term:
86
102
  -
87
103
  identifier: 'http://id.worldcat.org/fast/1914919'
@@ -316,7 +316,6 @@ search:
316
316
  replacements:
317
317
  maxRecords: '20'
318
318
  -
319
- pending: true
320
319
  query: polychrome
321
320
  subauth: colour_content
322
321
  position: 3
@@ -457,7 +456,6 @@ search:
457
456
  replacements:
458
457
  maxRecords: '20'
459
458
  -
460
- pending: true
461
459
  query: unknown
462
460
  subauth: gender
463
461
  position: 3
@@ -556,7 +554,6 @@ search:
556
554
  replacements:
557
555
  maxRecords: '10'
558
556
  -
559
- pending: true
560
557
  query: Hi 8
561
558
  subauth: video_format
562
559
  position: 3
@@ -24,6 +24,14 @@ QaServer.config do |config|
24
24
  # @param [Symbol] time period for calculating historical pass/fail (i.e., one of :month, :year, or :all)
25
25
  # config.historical_datatable_default_time_period = :year
26
26
 
27
+ # Threshold for percentage of queries that timed out after which it gets marked in the Authority Connection up-down History
28
+ # @param [Float] percentage of queries that are ok to timeout
29
+ # config.up_down_data_timeouts_max_threshold = 0.3
30
+
31
+ # Threshold for percentage of queries that are passing, below which are marked in the Authority Connection up-down History as barely_up
32
+ # @param [Float] required percentage of queries passing to be considered mostly-up when there are some failures
33
+ # config.up_down_data_mostly_up_threshold = 0.95
34
+
27
35
  # Displays a graph of performance test data when true
28
36
  # @param [Boolean] display performance graph when true
29
37
  # config.display_performance_graph = false
@@ -73,6 +73,20 @@ module QaServer
73
73
  @historical_datatable_default_time_period ||= :year
74
74
  end
75
75
 
76
+ # Threshold for percentage of queries that timed out after which it gets marked in the Authority Connection up-down History
77
+ # @param [Float] percentage of queries that are ok to timeout
78
+ attr_writer :up_down_data_timeouts_max_threshold
79
+ def up_down_data_timeouts_max_threshold
80
+ @up_down_data_timeouts_max_threshold ||= 0.3
81
+ end
82
+
83
+ # Threshold for percentage of queries that are passing, below which are marked in the Authority Connection up-down History as barely_up
84
+ # @param [Float] required percentage of queries passing to be considered mostly-up when there are some failures
85
+ attr_writer :up_down_data_mostly_up_threshold
86
+ def up_down_data_mostly_up_threshold
87
+ @up_down_data_mostly_up_threshold ||= 0.95
88
+ end
89
+
76
90
  # Displays a graph of performance test data when true
77
91
  # @param [Boolean] display performance graph when true
78
92
  attr_writer :display_performance_graph
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module QaServer
3
- VERSION = '7.5.1'
3
+ VERSION = '7.9.0'
4
4
  end
data/qa_server.gemspec CHANGED
@@ -22,11 +22,11 @@ Gem::Specification.new do |spec|
22
22
  # Note: rails does not follow sem-ver conventions, it's
23
23
  # minor version releases can include breaking changes; see
24
24
  # http://guides.rubyonrails.org/maintenance_policy.html
25
- spec.add_dependency 'rails', '~> 5.0' # Keep in sync with version supported by Hyrax
25
+ spec.add_dependency 'rails', '~> 5.2', '>= 5.2.5' # v5.2.5 required to address mimemagic gem yank
26
26
  spec.add_dependency 'useragent'
27
27
 
28
28
  # Required gems for QA and linked data access
29
- spec.add_development_dependency 'qa', '~> 5.3'
29
+ spec.add_development_dependency 'qa', '~> 5.5', '>= 5.5.1' # questioning_authority
30
30
  spec.add_development_dependency 'linkeddata'
31
31
 
32
32
  # Produces dashboard charts on monitor status page
@@ -34,12 +34,12 @@ Gem::Specification.new do |spec|
34
34
 
35
35
  spec.add_development_dependency 'better_errors' # provide debugging command line in
36
36
  spec.add_development_dependency 'binding_of_caller' # provides deep stack info used by better_errors
37
- spec.add_development_dependency 'bixby', '~> 3.0.0' # rubocop styleguide
37
+ spec.add_development_dependency 'bixby', '~> 3.0', ">= 3.0.2" # rubocop styleguide
38
38
  # spec.add_development_dependency "capybara", '~> 3.29'
39
39
  # spec.add_development_dependency 'capybara-maleficent', '~> 0.3.0'
40
40
  # spec.add_development_dependency 'chromedriver-helper', '~> 2.1'
41
41
  spec.add_development_dependency 'deprecation'
42
- spec.add_development_dependency 'engine_cart', '~> 2.0'
42
+ spec.add_development_dependency 'engine_cart', '~> 2.2'
43
43
  spec.add_development_dependency "factory_bot", '~> 4.4'
44
44
  spec.add_development_dependency 'i18n-tasks'
45
45
  spec.add_development_dependency 'simplecov'
@@ -49,7 +49,7 @@ Gem::Specification.new do |spec|
49
49
  spec.add_development_dependency 'rspec-its', '~> 1.1'
50
50
  spec.add_development_dependency 'rspec-rails', '~> 3.1'
51
51
  spec.add_development_dependency 'selenium-webdriver'
52
- spec.add_development_dependency 'webdrivers', '~> 3.0'
52
+ spec.add_development_dependency 'webdrivers', '~> 4.4'
53
53
  spec.add_development_dependency 'webmock'
54
54
 
55
55
  ########################################################
@@ -21,7 +21,7 @@ RSpec.describe 'Accuracy test' do # rubocop:disable RSpec/DescribeClass
21
21
  it "finds actual <= expected" do
22
22
  pending 'test is known to fail' if test_result[:pending]
23
23
  expect(test_result[:err_message]).to be_empty
24
- expect(test_result[:request_data]).not_to be_empty
24
+ expect(test_result[:request_data]).to be_present
25
25
  expect(test_result[:actual]).not_to be_nil
26
26
  expect(test_result[:actual]).to be <= test_result[:expected]
27
27
  end
data/spec/i18n_spec.rb CHANGED
@@ -14,7 +14,6 @@ RSpec.describe I18n do
14
14
  end
15
15
 
16
16
  it 'does not have unused keys' do
17
- pending 'need to explore unused keys further'
18
17
  expect(unused_keys).to be_empty,
19
18
  "#{unused_keys.leaves.count} unused i18n keys, run `i18n-tasks unused' to show them"
20
19
  end
@@ -86,6 +86,28 @@ RSpec.describe QaServer::Configuration do
86
86
  end
87
87
  end
88
88
 
89
+ describe '#up_down_data_timeouts_max_threshold' do
90
+ it 'return default as 0.3 (e.g. 30%)' do
91
+ expect(config.up_down_data_timeouts_max_threshold).to eq 0.3
92
+ end
93
+
94
+ it 'returns set value' do
95
+ config.up_down_data_timeouts_max_threshold = 0.25
96
+ expect(config.up_down_data_timeouts_max_threshold).to eq 0.25
97
+ end
98
+ end
99
+
100
+ describe '#up_down_data_mostly_up_threshold' do
101
+ it 'return default as 0.95 (e.g. 95%)' do
102
+ expect(config.up_down_data_mostly_up_threshold).to eq 0.95
103
+ end
104
+
105
+ it 'returns set value' do
106
+ config.up_down_data_mostly_up_threshold = 0.98
107
+ expect(config.up_down_data_mostly_up_threshold).to eq 0.98
108
+ end
109
+ end
110
+
89
111
  describe '#display_performance_graph?' do
90
112
  it 'return default as false' do
91
113
  expect(config.display_performance_graph?).to eq false
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+
4
+ RSpec.describe QaServer::MonitorStatus::HistoryPresenter do
5
+ let(:presenter) { described_class.new(parent: nil, historical_summary_data: historical_summary_data) }
6
+ # rubocop:disable Layout/ExtraSpacing
7
+ let(:historical_summary_data) do
8
+ # { 'auth_name' => { good: count_of_passing_tests, bad: count_of_failing_tests } }
9
+ {
10
+ 'GOOD_AUTH' => { good: 0, bad: 1000 },
11
+ 'BARELY_GOOD' => { good: 49, bad: 951 },
12
+ 'OK_AUTH' => { good: 50, bad: 950 },
13
+ 'STILL_OK' => { good: 51, bad: 949 },
14
+ 'BARELY_OK' => { good: 99, bad: 901 },
15
+ 'BAD_AUTH' => { good: 100, bad: 900 },
16
+ 'STILL_BAD' => { good: 101, bad: 899 },
17
+ 'REALLY_BAD' => { good: 500, bad: 500 },
18
+ 'HORRIBLE' => { good: 1000, bad: 0 }
19
+ }
20
+ # rubocop:enable Layout/ExtraSpacing
21
+ end
22
+
23
+ describe '.failure_style_class' do
24
+ context 'returns NEUTRAL style' do
25
+ let(:expected_css_style) { "status-neutral" }
26
+ let(:zero_failure_entry) { ['GOOD_AUTH', { good: 1000, bad: 0 }] } # rubocop:disable Layout/ExtraSpacing
27
+ let(:just_below_caution) { ['BARELY_GOOD', { good: 951, bad: 49 }] } # rubocop:disable Layout/ExtraSpacing
28
+
29
+ it 'when no failures' do
30
+ expect(presenter.failure_style_class(zero_failure_entry)).to eq expected_css_style
31
+ end
32
+
33
+ it 'when percent of failures is just below the CAUTION_THRESHOLD' do
34
+ expect(presenter.failure_style_class(just_below_caution)).to eq expected_css_style
35
+ end
36
+ end
37
+
38
+ context 'returns CAUTION style' do
39
+ let(:expected_css_style) { "status-unknown" }
40
+ let(:equal_caution) { ['OK_AUTH', { good: 950, bad: 50 }] }
41
+ let(:just_above_caution) { ['STILL_OK', { good: 949, bad: 51 }] }
42
+ let(:just_below_warning) { ['BARELY_OK', { good: 901, bad: 99 }] }
43
+
44
+ it 'when percent of failures is equal to CAUTION_THRESHOLD' do
45
+ expect(presenter.failure_style_class(equal_caution)).to eq expected_css_style
46
+ end
47
+
48
+ it 'when percent of failures is just above CAUTION_THRESHOLD' do
49
+ expect(presenter.failure_style_class(just_above_caution)).to eq expected_css_style
50
+ end
51
+
52
+ it 'when percent of failures is just below WARNING_THRESHOLD' do
53
+ expect(presenter.failure_style_class(just_below_warning)).to eq expected_css_style
54
+ end
55
+ end
56
+
57
+ context 'returns WARNING style' do
58
+ let(:expected_css_style) { "status-bad" }
59
+ let(:equal_warning) { ['BAD_AUTH', { good: 900, bad: 100 }] }
60
+ let(:just_above_warning) { ['STILL_BAD', { good: 899, bad: 101 }] }
61
+ let(:well_above_warning) { ['REALLY_BAD', { good: 500, bad: 500 }] }
62
+ let(:all_failures) { ['HORRIBLE', { good: 0, bad: 1000 }] }
63
+
64
+ it 'when percent of failures is equal to WARNING_THRESHOLD' do
65
+ expect(presenter.failure_style_class(equal_warning)).to eq expected_css_style
66
+ end
67
+
68
+ it 'when percent of failures is just above WARNING_THRESHOLD' do
69
+ expect(presenter.failure_style_class(just_above_warning)).to eq expected_css_style
70
+ end
71
+
72
+ it 'when percent of failures is well above WARNING_THRESHOLD' do
73
+ expect(presenter.failure_style_class(well_above_warning)).to eq expected_css_style
74
+ end
75
+
76
+ it 'when percent of failures is 100%' do
77
+ expect(presenter.failure_style_class(all_failures)).to eq expected_css_style
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+
4
+ RSpec.describe QaServer::HistoryUpDownService do
5
+ let(:service) { described_class.new }
6
+
7
+ context 'when total_count is 0' do
8
+ let(:good_count) { 0 }
9
+ let(:unknown_count) { 0 }
10
+ let(:bad_count) { 0 }
11
+ let(:timeout_count) { 0 }
12
+ it 'returns :no_data' do
13
+ status = service.send(:status_determination, good_count, unknown_count, bad_count, timeout_count)
14
+ expect(status).to eq :no_data
15
+ end
16
+ end
17
+
18
+ context 'when all queries failed' do
19
+ let(:good_count) { 0 }
20
+ let(:unknown_count) { 0 }
21
+ let(:bad_count) { 5 }
22
+ let(:timeout_count) { 0 }
23
+ it 'returns :down' do
24
+ status = service.send(:status_determination, good_count, unknown_count, bad_count, timeout_count)
25
+ expect(status).to eq :down
26
+ end
27
+ end
28
+
29
+ context 'when all queries passed' do
30
+ let(:good_count) { 5 }
31
+ let(:unknown_count) { 0 }
32
+ let(:bad_count) { 0 }
33
+ let(:timeout_count) { 0 }
34
+ it 'returns :fully_up' do
35
+ status = service.send(:status_determination, good_count, unknown_count, bad_count, timeout_count)
36
+ expect(status).to eq :fully_up
37
+ end
38
+ end
39
+
40
+ context 'when all queries are unknown' do
41
+ let(:good_count) { 0 }
42
+ let(:unknown_count) { 5 }
43
+ let(:bad_count) { 0 }
44
+ let(:timeout_count) { 0 }
45
+ it 'returns :barely_up' do
46
+ status = service.send(:status_determination, good_count, unknown_count, bad_count, timeout_count)
47
+ expect(status).to eq :barely_up
48
+ end
49
+ end
50
+
51
+ context 'when too many queries timed out' do
52
+ let(:threshold) { 0.5 }
53
+ let(:good_count) { 100 - bad_count }
54
+ let(:unknown_count) { 0 }
55
+ let(:bad_count) { timeout_count + 2 }
56
+ let(:timeout_count) { threshold * 100 + 1 }
57
+ it 'returns :good' do
58
+ status = service.send(:status_determination, good_count, unknown_count, bad_count, timeout_count)
59
+ expect(status).to eq :timeouts
60
+ end
61
+ end
62
+
63
+ context 'when almost all queries pass' do
64
+ let(:threshold) { 0.95 }
65
+ let(:good_count) { threshold * 100 + 1 }
66
+ let(:unknown_count) { 0 }
67
+ let(:bad_count) { 100 - good_count }
68
+ let(:timeout_count) { 0 }
69
+ it 'returns :good' do
70
+ status = service.send(:status_determination, good_count, unknown_count, bad_count, timeout_count)
71
+ expect(status).to eq :mostly_up
72
+ end
73
+ end
74
+
75
+ context 'when too many queries fail' do
76
+ let(:threshold) { 0.95 }
77
+ let(:good_count) { threshold * 100 - 1 }
78
+ let(:unknown_count) { 0 }
79
+ let(:bad_count) { 100 - good_count }
80
+ let(:timeout_count) { 0 }
81
+ it 'returns :good' do
82
+ status = service.send(:status_determination, good_count, unknown_count, bad_count, timeout_count)
83
+ expect(status).to eq :barely_up
84
+ end
85
+ end
86
+ end