qa_server 7.8.0 → 7.9.0

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: 794b6a1df8268f9b316ba8626f45ace1241f5208538c2dab2965c36077ce8ad3
4
- data.tar.gz: ad7b9425e8f9d4fcdca98dfa0f6ae31ac0fa6a0fe5d4b6b8207d648db023edfd
3
+ metadata.gz: 98c71b17c28452d0503ee1afd8ee920dbaa12332e578890d02527a402ce1a793
4
+ data.tar.gz: b569538f771243239ff2fe85428fbe11b9dd948947aa90e598a12c513aa2e4e2
5
5
  SHA512:
6
- metadata.gz: 2efb90f8b0d3409fc7058557497820476791b642db776ef406855c3e4c5d3bd581e0661662b8eeb74dec146f59ae7e9a5a5a1aad36c297524ab6a88ee07e6505
7
- data.tar.gz: 5f32bb54311cbd6cc58c4f6cf4017c7dff1d64047672af9b303cb57a3dae7010e8d64353a49666d1e5378ab2ddb3f1f8108e48a7114926b49badda60a6f425bf
6
+ metadata.gz: 96ae15dfd8d90bab80600eea28865a6749347bd084df9771b0864e5d58c803bfb7dc23bff8025f4939ca78c5dfbbfa452a0a8f7fe028acb3c85ee7c3374d78ee
7
+ data.tar.gz: 04f668c250e1f95188ad2a0553b2ab8a09f33415e4a9028024e4ce97407aa1af041be643dbb6f7b603e61887df8f3b0d7b3b80d7a41c0c194aaa579cb07cd03d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 7.9.0 (2021-04-16)
2
+
3
+ * Add chart showing simulated graph (in table) of the last 30 days of up-down connection data
4
+
1
5
  ### 7.8.0 (2021-04-14)
2
6
 
3
7
  * add geographic subauth for Mesh-NLM
@@ -53,3 +53,48 @@ div#performance-by-the-day {
53
53
  div#performance-by-the-month {
54
54
  display: none;
55
55
  }
56
+
57
+ table.up-down-history {
58
+ border: none;
59
+ }
60
+
61
+ td.up-down-history {
62
+ font-size: .8em;
63
+ font-style: italic;
64
+ border: none;
65
+ }
66
+ th.up-down-history {
67
+ width: 20px;
68
+ border: none;
69
+ }
70
+
71
+ td.connection-up-down {
72
+ border-right: 8px white solid;
73
+ border-left: 8px white solid;
74
+ border-top: none;
75
+ border-bottom: 3px white solid;
76
+ }
77
+
78
+ td.connection-no-data {
79
+ background-color: white;
80
+ }
81
+
82
+ td.connection-fully-up {
83
+ background-color: #19AE19;
84
+ }
85
+
86
+ td.connection-mostly-up {
87
+ background-color: #19AEA7;
88
+ }
89
+
90
+ td.connection-timeouts {
91
+ background-color: #EDF908;
92
+ }
93
+
94
+ td.connection-barely-up {
95
+ background-color: #AE7619;
96
+ }
97
+
98
+ td.connection-down {
99
+ background-color: #CE0303;
100
+ }
@@ -5,6 +5,7 @@ module QaServer
5
5
  SCENARIO_RUN_SUMMARY_DATA_CACHE_KEY = "QaServer--CacheKeys--scenario_run_summary_data"
6
6
  SCENARIO_RUN_FAILURE_DATA_CACHE_KEY = "QaServer--CacheKeys--scenario_run_failure_data"
7
7
  SCENARIO_RUN_HISTORY_DATA_CACHE_KEY = "QaServer--CacheKeys--scenario_run_history_data"
8
+ SCENARIO_RUN_HISTORY_UP_DOWN_DATA_CACHE_KEY = "QaServer--CacheKeys--history_up_down_data"
8
9
 
9
10
  PERFORMANCE_DATATABLE_DATA_CACHE_KEY = "QaServer--Cache--performance_datatable_data"
10
11
  end
@@ -2,8 +2,9 @@
2
2
  # Maintain a cache of data for Authority Connection History table displayed on Monitor Status page
3
3
  module QaServer
4
4
  class ScenarioHistoryCache
5
- class_attribute :scenario_history_class
5
+ class_attribute :scenario_history_class, :scenario_up_down_class
6
6
  self.scenario_history_class = QaServer::ScenarioRunHistory
7
+ self.scenario_up_down_class = QaServer::HistoryUpDownService
7
8
 
8
9
  class << self
9
10
  include QaServer::CacheKeys
@@ -21,12 +22,29 @@ module QaServer
21
22
  end
22
23
  end
23
24
 
25
+ # Get a status for each of the last 30 days for queries that succeeded or failed.
26
+ # @param force [Boolean] if true, run the tests even if the cache hasn't expired; otherwise, use cache if not expired
27
+ # @returns [Hash<Array>] status for the last 30 days for each authority
28
+ # @example { auth_name => [:fully_up, :fully_up, :down, :mostly_up, ... ], ... }
29
+ # { 'agrovoc' => [ :fully_up, :fully_up, :down, :mostly_up, ...],
30
+ # 'geonames_ld4l_cache' => [ :fully_up, :mostly_up, :down, :fully_up, :timeouts, ...] }
31
+ def historical_up_down_data(force: false)
32
+ Rails.cache.fetch(cache_key_for_historical_up_down_data, expires_in: next_expiry, race_condition_ttl: 30.seconds, force: force) do
33
+ QaServer.config.monitor_logger.debug("(QaServer::ScenarioHistoryCache) - CALCULATING UP-DOWN STATUS HISTORY of scenario runs (force: #{force})")
34
+ scenario_up_down_class.new.last_30_days
35
+ end
36
+ end
37
+
24
38
  private
25
39
 
26
40
  def cache_key_for_historical_data
27
41
  SCENARIO_RUN_HISTORY_DATA_CACHE_KEY
28
42
  end
29
43
 
44
+ def cache_key_for_historical_up_down_data
45
+ SCENARIO_RUN_HISTORY_UP_DOWN_DATA_CACHE_KEY
46
+ end
47
+
30
48
  def next_expiry
31
49
  QaServer::CacheExpiryService.cache_expiry
32
50
  end
@@ -19,6 +19,7 @@ module QaServer
19
19
  @presenter = presenter_class.new(current_summary: latest_summary,
20
20
  current_failure_data: latest_failures,
21
21
  historical_summary_data: historical_data,
22
+ historical_up_down_data: historical_up_down_data,
22
23
  performance_data: performance_table_data)
23
24
  QaServer.config.monitor_logger.debug("~~~~~~~~ DONE rendering monitor status")
24
25
  render 'index', status: :internal_server_error if latest_summary&.failing_authority_count&.positive?
@@ -59,6 +60,13 @@ module QaServer
59
60
  @historical_data ||= QaServer::ScenarioHistoryCache.historical_summary(force: refresh_history?)
60
61
  end
61
62
 
63
+ # Get a summary level of historical data
64
+ # @returns [Array<Hash>] summary of passing/failing tests for each authority
65
+ # @see QaServer::ScenarioRunHistory#historical_summary for structure of output
66
+ def historical_up_down_data
67
+ @historical_up_down_data ||= QaServer::ScenarioHistoryCache.historical_up_down_data(force: refresh_history?)
68
+ end
69
+
62
70
  def update_historical_graph
63
71
  return unless QaServer.config.display_historical_graph?
64
72
  QaServer::ScenarioHistoryGraphCache.generate_graph(data: historical_data, force: refresh_history?)
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+ # This presenter class provides historical testing data needed by the view that monitors status of authorities.
3
+ module QaServer::MonitorStatus
4
+ class HistoryUpDownPresenter
5
+ attr_reader :historical_up_down_data
6
+
7
+ # @param parent [QaServer::MonitorStatusPresenter] parent presenter
8
+ # @param historical_up_down_data [Hash<Array>] recent connection status of queries (typically last 30 days)
9
+ # @example historical_up_down_data
10
+ # { 'AGROVOC' = [
11
+ # :FULLY_UP, # 0 - today
12
+ # :MOSTLY_UP, # 1 - yesterday
13
+ # :MOSTLY_UP, # 2 - two days ago
14
+ # :FULLY_UP, # 3 - three days ago
15
+ # :DOWN, # 4 - four days ago
16
+ # ... # etc.
17
+ # ],
18
+ # 'CERL' = [ ... ]
19
+ # }
20
+ def initialize(parent:, historical_up_down_data:)
21
+ @parent = parent
22
+ @historical_up_down_data = historical_up_down_data
23
+ end
24
+
25
+ # Return the last date of data represented in the history graph and data table
26
+ # @return [ActiveSupport::TimeWithZone] date time stamp
27
+ def up_down_start
28
+ QaServer::TimeService.pretty_date(up_down_end_dt - 29.days)
29
+ end
30
+
31
+ def up_down_end
32
+ QaServer::TimeService.pretty_date(up_down_end_dt)
33
+ end
34
+
35
+ def up_down_end_dt
36
+ @parent.last_updated_dt
37
+ end
38
+
39
+ # @param status [Symbol] :fully_up, :mostly_up, :timeouts, :barely_up, :down
40
+ # @param day [Integer] retrieve the status for this day
41
+ # @return [String] name of the css class for the status
42
+ def historical_up_down_status_class(status, day) # rubocop:disable Metrics/CyclomaticComplexity
43
+ case status[day]
44
+ when :no_date then 'connection-no-date'
45
+ when :fully_up then 'connection-fully-up'
46
+ when :mostly_up then 'connection-mostly-up'
47
+ when :timeouts then 'connection-timeouts'
48
+ when :barely_up then 'connection-barely-up'
49
+ when :down then 'connection-down'
50
+ end
51
+ end
52
+
53
+ # @return [Boolean] true if historical datatable should be visible; otherwise false
54
+ def display_historical_up_down?
55
+ QaServer.config.display_historical_datatable? && @historical_up_down_data.present?
56
+ end
57
+ end
58
+ end
@@ -5,12 +5,14 @@ module QaServer
5
5
  extend Forwardable
6
6
 
7
7
  # @param current_summary [ScenarioRunSummary] summary status of the latest run of test scenarios
8
- # @param current_data [Array<Hash>] current set of failures for the latest test run, if any
8
+ # @param current_failure_data [Array<Hash>] current set of failures for the latest test run, if any
9
9
  # @param historical_summary_data [Array<Hash>] summary of past failuring runs per authority to drive chart
10
+ # @param historical_up_down_data [Hash<Array>] status of queries for the last 30 days
10
11
  # @param performance_data [Hash<Hash>] performance datatable data
11
- def initialize(current_summary:, current_failure_data:, historical_summary_data:, performance_data:)
12
+ def initialize(current_summary:, current_failure_data:, historical_summary_data:, historical_up_down_data:, performance_data:)
12
13
  @current_status_presenter = QaServer::MonitorStatus::CurrentStatusPresenter.new(parent: self, current_summary: current_summary, current_failure_data: current_failure_data)
13
14
  @history_presenter = QaServer::MonitorStatus::HistoryPresenter.new(parent: self, historical_summary_data: historical_summary_data)
15
+ @history_up_down_presenter = QaServer::MonitorStatus::HistoryUpDownPresenter.new(parent: self, historical_up_down_data: historical_up_down_data)
14
16
  @performance_presenter = QaServer::MonitorStatus::PerformancePresenter.new(parent: self, performance_data: performance_data)
15
17
  end
16
18
 
@@ -23,6 +25,9 @@ module QaServer
23
25
  :percent_authority_failing, :percent_authority_failing_str, :failure_style_class, :passing_style_class,
24
26
  :display_history_details?, :display_historical_graph?, :display_historical_datatable?, :history_start, :history_end
25
27
 
28
+ def_delegators :@history_up_down_presenter, :historical_up_down_data, :display_historical_up_down?, :historical_up_down_status_class,
29
+ :up_down_start, :up_down_end
30
+
26
31
  def_delegators :@performance_presenter, :performance_data, :performance_data?, :display_performance?, :display_performance_graph?,
27
32
  :display_performance_datatable?, :performance_data_authority_name, :performance_for_day_graph, :performance_for_month_graph,
28
33
  :performance_for_year_graph, :datatable_search_stats, :datatable_fetch_stats, :datatable_all_actions_stats,
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+ # This class determines the state (e.g. fully_up, mostly_up, barely_up, down)of an authority during the last 30 days.
3
+ module QaServer
4
+ class HistoryUpDownService
5
+ NO_DATA = :no_data
6
+ FULLY_UP = :fully_up
7
+ MOSTLY_UP = :mostly_up
8
+ EXCESSIVE_TIMEOUTS = :timeouts
9
+ BARELY_UP = :barely_up
10
+ DOWN = :down
11
+
12
+ MOSTLY_UP_THRESHOLD = QaServer.config.up_down_data_mostly_up_threshold
13
+ TIMEOUT_THRESHOLD = QaServer.config.up_down_data_timeouts_max_threshold
14
+
15
+ class_attribute :authority_lister, :scenario_history_class, :time_service
16
+ self.authority_lister = QaServer::AuthorityListerService
17
+ self.scenario_history_class = QaServer::ScenarioRunHistory
18
+ self.time_service = QaServer::TimeService
19
+
20
+ def last_30_days
21
+ data = {}
22
+ authorities_list.each { |authority| data[authority] = last_30_days_for(authority.to_s) }
23
+ data
24
+ end
25
+
26
+ private
27
+
28
+ # @returns [Hash <Array<Hash>>] data for an authority for each of the last 30 days
29
+ # @example
30
+ # { 'AGROVOC' = [
31
+ # :FULLY_UP, # 0 - today
32
+ # :MOSTLY_UP, # 1 - yesterday
33
+ # :MOSTLY_UP, # 2 - two days ago
34
+ # :FULLY_UP, # 3 - three days ago
35
+ # :DOWN, # 4 - four days ago
36
+ # ... # etc.
37
+ # ]
38
+ # }
39
+ def last_30_days_for(authority)
40
+ auth_data = []
41
+ 0.upto(29) { |offset| auth_data[offset] = day_status(authority, offset) }
42
+ auth_data
43
+ end
44
+
45
+ # @returns [Symbol] status for a given day for an authority
46
+ def day_status(authority, offset)
47
+ day = offset_day(offset)
48
+ good_count = count_good(authority, day)
49
+ unknown_count = count_unknown(authority, day)
50
+ bad_count = count_bad(authority, day)
51
+ timeout_count = count_timeouts(authority, day)
52
+ status_determination(good_count, unknown_count, bad_count, timeout_count)
53
+ end
54
+
55
+ def status_determination(good_count, unknown_count, bad_count, timeout_count) # rubocop:disable Metrics/CyclomaticComplexity
56
+ total_count = good_count + unknown_count + bad_count
57
+ return NO_DATA if total_count.zero?
58
+ return FULLY_UP if good_count == total_count
59
+ return DOWN if bad_count == total_count
60
+ return BARELY_UP if unknown_count == total_count
61
+ return EXCESSIVE_TIMEOUTS if (timeout_count.to_f / total_count) > TIMEOUT_THRESHOLD
62
+ return MOSTLY_UP if (bad_count.to_f / total_count) < (1 - MOSTLY_UP_THRESHOLD)
63
+ BARELY_UP
64
+ end
65
+
66
+ def authorities_list
67
+ @authorities_list ||= authority_lister.authorities_list
68
+ end
69
+
70
+ def offset_day(offset)
71
+ @today ||= time_service.current_time
72
+ time_service.pretty_query_date(@today - offset.days)
73
+ end
74
+
75
+ def count_good(authority, day)
76
+ scenario_history_class.where(authority_name: authority)
77
+ .where(date: day)
78
+ .where(status: :good)
79
+ .count(:id)
80
+ end
81
+
82
+ def count_unknown(authority, day)
83
+ scenario_history_class.where(authority_name: authority)
84
+ .where(date: day)
85
+ .where(status: :unknown)
86
+ .count(:id)
87
+ end
88
+
89
+ def count_bad(authority, day)
90
+ scenario_history_class.where(authority_name: authority)
91
+ .where(date: day)
92
+ .where(status: :bad)
93
+ .count(:id)
94
+ end
95
+
96
+ def count_timeouts(authority, day)
97
+ scenario_history_class.where(authority_name: authority)
98
+ .where(date: day)
99
+ .where('err_message LIKE ?', "%timeout%")
100
+ .count(:id)
101
+ end
102
+ end
103
+ end
@@ -24,6 +24,12 @@ module QaServer
24
24
  def pretty_date(dt)
25
25
  dt.in_time_zone(QaServer.config.preferred_time_zone_name).strftime("%m/%d/%Y")
26
26
  end
27
+
28
+ # @param dt [ActiveSupport::TimeWithZone] date time stamp
29
+ # @return [String] string version of date formatted with just date (e.g. "2020-02-01")
30
+ def pretty_query_date(dt)
31
+ dt.in_time_zone(QaServer.config.preferred_time_zone_name).strftime("%Y-%m-%d")
32
+ end
27
33
  end
28
34
  end
29
35
  end
@@ -0,0 +1,30 @@
1
+ <% if @presenter.history? && @presenter.display_history_details?%>
2
+ <div id="availability-history" class="status-section">
3
+ <h3><%= t('qa_server.monitor_status.history.title') %></h3>
4
+ <% if @presenter.display_historical_graph? %>
5
+ <p class="status-update-dtstamp"><%= t('qa_server.monitor_status.history.range', from: @presenter.history_start, to: @presenter.history_end) %></p>
6
+ <%= image_tag(@presenter.historical_graph, alt: 'History Graph Unavailable') %>
7
+ <% end %>
8
+
9
+ <% if @presenter.display_historical_up_down? %>
10
+ <p class="status-update-dtstamp"><%= t('qa_server.monitor_status.history.range', from: @presenter.up_down_start, to: @presenter.up_down_end) %></p>
11
+ <table class="up-down-history">
12
+ <tr>
13
+ <th class="up-down-history"><%= t('qa_server.monitor_status.history.authority') %></th>
14
+ <% 0.upto(29) do %>
15
+ <th class='up-down-history'></th>
16
+ <% end %>
17
+ <td class='up-down-history'>Most Recent</td>
18
+ </tr>
19
+ <% @presenter.historical_up_down_data.each do |authority_name, status| %>
20
+ <tr>
21
+ <td class="connection-up-down"><%= authority_name %></td>
22
+ <% 29.downto(0) do |day| %>
23
+ <td class="connection-up-down <%= @presenter.historical_up_down_status_class(status, day) %>"></td>
24
+ <% end %>
25
+ </tr>
26
+ <% end %>
27
+ </table>
28
+ <% end %>
29
+ </div>
30
+ <% end %>
@@ -5,7 +5,8 @@
5
5
  <h2><%= t('qa_server.monitor_status.title') %></h2>
6
6
 
7
7
  <%= render 'test_summary' %>
8
- <%= render 'test_history' %>
8
+ <%= render 'test_up_down_connection_history' %>
9
+ <% # = render 'test_history' %>
9
10
  <%= render 'performance' %>
10
11
 
11
12
  </div>
@@ -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.8.0'
3
+ VERSION = '7.9.0'
4
4
  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,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
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.8.0
4
+ version: 7.9.0
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: 2021-04-14 00:00:00.000000000 Z
11
+ date: 2021-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -418,6 +418,7 @@ files:
418
418
  - app/presenters/qa_server/fetch_presenter.rb
419
419
  - app/presenters/qa_server/monitor_status/current_status_presenter.rb
420
420
  - app/presenters/qa_server/monitor_status/history_presenter.rb
421
+ - app/presenters/qa_server/monitor_status/history_up_down_presenter.rb
421
422
  - app/presenters/qa_server/monitor_status/performance_presenter.rb
422
423
  - app/presenters/qa_server/monitor_status_presenter.rb
423
424
  - app/presenters/qa_server/navmenu_presenter.rb
@@ -427,6 +428,7 @@ files:
427
428
  - app/services/qa_server/authority_validator_service.rb
428
429
  - app/services/qa_server/database_migrator.rb
429
430
  - app/services/qa_server/history_graphing_service.rb
431
+ - app/services/qa_server/history_up_down_service.rb
430
432
  - app/services/qa_server/performance_calculator_service.rb
431
433
  - app/services/qa_server/performance_datatable_service.rb
432
434
  - app/services/qa_server/performance_graph_data_service.rb
@@ -447,6 +449,7 @@ files:
447
449
  - app/views/qa_server/monitor_status/_performance.html.erb
448
450
  - app/views/qa_server/monitor_status/_test_history.html.erb
449
451
  - app/views/qa_server/monitor_status/_test_summary.html.erb
452
+ - app/views/qa_server/monitor_status/_test_up_down_connection_history.html.erb
450
453
  - app/views/qa_server/monitor_status/index.html.erb
451
454
  - app/views/qa_server/usage/index.html.erb
452
455
  - app/views/shared/_footer.html.erb
@@ -548,6 +551,7 @@ files:
548
551
  - spec/lib/qa_server_spec.rb
549
552
  - spec/presenters/qa_server/monitor_status/history_presenter_spec.rb
550
553
  - spec/rails_helper.rb
554
+ - spec/services/qa_server/history_up_down_service_spec.rb
551
555
  - spec/services/qa_server/time_period_service_spec.rb
552
556
  - spec/services/qa_server/time_service_spec.rb
553
557
  - spec/spec_helper.rb
@@ -587,6 +591,7 @@ test_files:
587
591
  - spec/lib/qa_server_spec.rb
588
592
  - spec/presenters/qa_server/monitor_status/history_presenter_spec.rb
589
593
  - spec/rails_helper.rb
594
+ - spec/services/qa_server/history_up_down_service_spec.rb
590
595
  - spec/services/qa_server/time_period_service_spec.rb
591
596
  - spec/services/qa_server/time_service_spec.rb
592
597
  - spec/spec_helper.rb