qa_server 6.1.0 → 6.2.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 +4 -4
- data/CHANGELOG.md +6 -0
- data/app/controllers/qa_server/check_status_controller.rb +6 -0
- data/app/controllers/qa_server/monitor_status_controller.rb +24 -4
- data/app/jobs/qa_server/monitor_tests_job.rb +3 -4
- data/app/models/qa_server/performance_cache.rb +30 -14
- data/app/models/qa_server/scenario_run_history.rb +3 -3
- data/app/prepends/prepended_linked_data/find_term.rb +1 -1
- data/app/prepends/prepended_linked_data/search_query.rb +1 -1
- data/app/services/qa_server/performance_datatable_service.rb +1 -1
- data/app/services/qa_server/performance_graph_data_service.rb +1 -1
- data/app/services/qa_server/performance_graphing_service.rb +1 -1
- data/lib/generators/qa_server/templates/config/initializers/qa_server.rb +16 -0
- data/lib/qa_server/configuration.rb +32 -1
- data/lib/qa_server/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b602ac44639871d5021eb47493edf93fb8abdc25
|
4
|
+
data.tar.gz: bf9e6a5ece3786edab98ed79d1fc3edb8e54f8b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec1fec69f78b763fc7012c92118fddeb6e0f6ad98d53d9ae80d959f80f0c1373c435626452644294ecbcf1b1843ac37517af58a71e04ece333a9d14afa99486f
|
7
|
+
data.tar.gz: d4e87a9c8157f8d03b3fdbc26ded7698f294cee41f9c7a2222355db878c26ab7e7d121d32dda69fbf1660f5b7942de7ec05688431a364b1e06f22b9b73967598
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
### 6.2.0 (2020-02-17)
|
2
|
+
|
3
|
+
* use authentication for refreshing monitor tests
|
4
|
+
* add performance cache logger
|
5
|
+
* exceeding max performance cache size flushing the cache
|
6
|
+
|
1
7
|
### 6.1.0 (2020-02-17)
|
2
8
|
|
3
9
|
* change historical summary to show number of days instead of number of tests (original intent)
|
@@ -13,6 +13,7 @@ module QaServer
|
|
13
13
|
|
14
14
|
# Sets up presenter with data to display in the UI
|
15
15
|
def index
|
16
|
+
log_header
|
16
17
|
validate(authorities_to_validate, validation_type)
|
17
18
|
@presenter = presenter_class.new(authorities_list: authorities_list,
|
18
19
|
connection_status_data: connection_status_data_from_log,
|
@@ -38,5 +39,10 @@ module QaServer
|
|
38
39
|
return @authority_name if @authority_name.present?
|
39
40
|
@authority_name = params.key?(:authority) ? params[:authority].downcase : nil
|
40
41
|
end
|
42
|
+
|
43
|
+
def log_header
|
44
|
+
QaServer.config.performance_cache_logger.debug("------------------------------------- check status ---------------------------------")
|
45
|
+
QaServer.config.performance_cache_logger.debug("(#{self.class}##{__method__}) check status page request (authority_name # #{authority_name})")
|
46
|
+
end
|
41
47
|
end
|
42
48
|
end
|
@@ -21,11 +21,13 @@ module QaServer
|
|
21
21
|
def index
|
22
22
|
log_header
|
23
23
|
latest_test_run
|
24
|
+
commit_cache if commit_cache?
|
24
25
|
@presenter = presenter_class.new(current_summary: latest_summary,
|
25
26
|
current_failure_data: latest_failures,
|
26
27
|
historical_summary_data: historical_data,
|
27
28
|
performance_data: performance_table_data)
|
28
29
|
update_performance_graphs
|
30
|
+
QaServer.config.monitor_logger.debug("(#{self.class}##{__method__}) DONE rendering")
|
29
31
|
render 'index', status: :internal_server_error if latest_summary.failing_authority_count.positive?
|
30
32
|
end
|
31
33
|
|
@@ -40,7 +42,7 @@ module QaServer
|
|
40
42
|
# @see #latest_test_run_from_temp_cache
|
41
43
|
def latest_test_run_from_cache
|
42
44
|
Rails.cache.fetch("#{self.class}/#{__method__}", expires_in: QaServer::MonitorCacheService.cache_expiry, race_condition_ttl: 5.minutes, force: refresh_tests?) do
|
43
|
-
QaServer.config.monitor_logger.
|
45
|
+
QaServer.config.monitor_logger.debug("(#{self.class}##{__method__}) get latest run of monitoring tests - cache expired or refresh requested (force: #{refresh_tests?})")
|
44
46
|
QaServer::MonitorTestsJob.perform_later
|
45
47
|
scenario_run_registry_class.latest_run
|
46
48
|
end
|
@@ -80,7 +82,7 @@ module QaServer
|
|
80
82
|
end
|
81
83
|
|
82
84
|
def refresh?
|
83
|
-
params.key?
|
85
|
+
params.key?(:refresh) && validate_auth_reload_token("refresh status")
|
84
86
|
end
|
85
87
|
|
86
88
|
def refresh_all?
|
@@ -103,10 +105,28 @@ module QaServer
|
|
103
105
|
refresh_all? || params[:refresh].casecmp?('performance')
|
104
106
|
end
|
105
107
|
|
108
|
+
def commit_cache?
|
109
|
+
params.key?(:commit) && validate_auth_reload_token("commit cache")
|
110
|
+
end
|
111
|
+
|
112
|
+
def commit_cache
|
113
|
+
QaServer.config.performance_cache.write_all
|
114
|
+
end
|
115
|
+
|
116
|
+
def validate_auth_reload_token(action)
|
117
|
+
token = params.key?(:auth_token) ? params[:auth_token] : nil
|
118
|
+
valid = Qa.config.valid_authority_reload_token?(token)
|
119
|
+
return true if valid
|
120
|
+
msg = "Permission denied. Unable to #{action}."
|
121
|
+
logger.warn msg
|
122
|
+
flash.now[:error] = msg
|
123
|
+
false
|
124
|
+
end
|
125
|
+
|
106
126
|
def log_header
|
107
127
|
QaServer.config.monitor_logger.debug("------------------------------------- monitor status ---------------------------------")
|
108
|
-
QaServer.config.monitor_logger.
|
109
|
-
|
128
|
+
QaServer.config.monitor_logger.debug("(#{self.class}##{__method__}) monitor status page request (refresh_tests? # #{refresh_tests?}, " \
|
129
|
+
"refresh_history? # #{refresh_history?}, refresh_performance? # #{refresh_performance?})")
|
110
130
|
end
|
111
131
|
end
|
112
132
|
end
|
@@ -9,9 +9,8 @@ module QaServer
|
|
9
9
|
class_attribute :scenario_run_registry_class
|
10
10
|
self.scenario_run_registry_class = QaServer::ScenarioRunRegistry
|
11
11
|
|
12
|
-
# def perform(job_id:)
|
13
12
|
def perform
|
14
|
-
Rails.cache.fetch("QaServer::
|
13
|
+
Rails.cache.fetch("QaServer::MonitorStatusController/latest_test_run_from_cache", expires_in: QaServer::MonitorCacheService.cache_expiry, race_condition_ttl: 5.minutes, force: true) do
|
15
14
|
job_id = SecureRandom.uuid
|
16
15
|
monitor_tests_job_id = job_id unless monitor_tests_job_id
|
17
16
|
run_tests if monitor_tests_job_id == job_id # avoid race conditions
|
@@ -22,11 +21,11 @@ module QaServer
|
|
22
21
|
private
|
23
22
|
|
24
23
|
def run_tests
|
25
|
-
QaServer.config.monitor_logger.
|
24
|
+
QaServer.config.monitor_logger.debug("(#{self.class}##{__method__}-#{job_id}) RUNNING monitoring tests")
|
26
25
|
validate(authorities_list)
|
27
26
|
log_results(authorities_list, status_log.to_a)
|
28
27
|
scenario_run_registry_class.save_run(scenarios_results: status_log.to_a)
|
29
|
-
QaServer.config.monitor_logger.
|
28
|
+
QaServer.config.monitor_logger.debug("(#{self.class}##{__method__}-#{job_id}) COMPLETED monitoring tests")
|
30
29
|
reset_monitor_tests_job_id
|
31
30
|
end
|
32
31
|
|
@@ -21,32 +21,47 @@ module QaServer
|
|
21
21
|
@cache[id] = entry.merge(updates)
|
22
22
|
end
|
23
23
|
|
24
|
+
def complete_entry(id:)
|
25
|
+
log(id: id)
|
26
|
+
QaServer.config.performance_cache_logger.debug("#{self.class}##{__method__} - id: #{id} cache memory: #{ObjectSpace.memsize_of @cache}")
|
27
|
+
write_all if ObjectSpace.memsize_of(@cache) > QaServer.config.max_performance_cache_size
|
28
|
+
end
|
29
|
+
|
24
30
|
def destroy(id)
|
25
|
-
@cache.delete(id)
|
31
|
+
@cache.delete(id) # WARNING: doesn't change the size of the cache
|
26
32
|
end
|
27
33
|
|
28
34
|
def write_all
|
29
|
-
|
30
|
-
|
35
|
+
cache_to_write = swap_cache_hash
|
36
|
+
size_before = cache_to_write.size
|
37
|
+
cache_to_write.each do |id, entry|
|
31
38
|
next if incomplete? entry
|
32
39
|
QaServer::PerformanceHistory.create(dt_stamp: entry[:dt_stamp], authority: entry[:authority],
|
33
40
|
action: entry[:action], action_time_ms: entry[:action_time_ms],
|
34
41
|
size_bytes: entry[:size_bytes], retrieve_time_ms: entry[:retrieve_time_ms],
|
35
42
|
graph_load_time_ms: entry[:graph_load_time_ms],
|
36
43
|
normalization_time_ms: entry[:normalization_time_ms])
|
37
|
-
|
44
|
+
cache_to_write.delete(id)
|
38
45
|
end
|
39
|
-
log_write_all("(#{self.class}##{__method__})", size_before,
|
40
|
-
|
41
|
-
|
42
|
-
def log(id:)
|
43
|
-
return if QaServer.config.suppress_logging_performance_datails
|
44
|
-
Rails.logger.debug("*** performance data for id: #{id} ***")
|
45
|
-
Rails.logger.debug(@cache[id].to_yaml)
|
46
|
+
log_write_all("(#{self.class}##{__method__})", size_before, cache_to_write.size)
|
47
|
+
cache_to_write = nil # free cache for garbage collection
|
46
48
|
end
|
47
49
|
|
48
50
|
private
|
49
51
|
|
52
|
+
def swap_cache_hash
|
53
|
+
cache_to_write = @cache
|
54
|
+
@cache = {} # reset main cache so new items after write begins are cached in the main cache
|
55
|
+
QaServer.config.performance_cache_logger.debug("#{self.class}##{__method__} - cache memory BEFORE write: #{ObjectSpace.memsize_of(cache_to_write)}")
|
56
|
+
cache_to_write
|
57
|
+
end
|
58
|
+
|
59
|
+
def log(id:)
|
60
|
+
return if QaServer.config.suppress_logging_performance_datails
|
61
|
+
Rails.logger.debug("*** performance data for id: #{id} ***")
|
62
|
+
Rails.logger.debug(@cache[id].to_yaml)
|
63
|
+
end
|
64
|
+
|
50
65
|
def incomplete?(entry)
|
51
66
|
required_keys.each { |k| return true unless entry.key? k }
|
52
67
|
false
|
@@ -65,11 +80,12 @@ module QaServer
|
|
65
80
|
|
66
81
|
def log_write_all(prefix, size_before, cache_size)
|
67
82
|
if size_before.positive?
|
68
|
-
QaServer.config.
|
69
|
-
QaServer.config.
|
83
|
+
QaServer.config.performance_cache_logger.debug("#{prefix} 0 of #{size_before} performance data records were saved") if size_before == cache_size
|
84
|
+
QaServer.config.performance_cache_logger.debug("#{prefix} #{size_before - cache_size} of #{size_before} performance data records were saved") if size_before > cache_size
|
70
85
|
else
|
71
|
-
QaServer.config.
|
86
|
+
QaServer.config.performance_cache_logger.debug("#{prefix} 0 of 0 performance data records were saved")
|
72
87
|
end
|
88
|
+
QaServer.config.performance_cache_logger.debug("#{prefix} - cache memory AFTER write: #{ObjectSpace.memsize_of @cache}")
|
73
89
|
end
|
74
90
|
end
|
75
91
|
end
|
@@ -47,7 +47,7 @@ module QaServer
|
|
47
47
|
# * total_scenario_count: 159,
|
48
48
|
def run_summary(scenario_run:, force: false)
|
49
49
|
Rails.cache.fetch("QaServer::ScenarioRunHistory/#{__method__}", expires_in: QaServer::MonitorCacheService.cache_expiry, race_condition_ttl: 1.minute, force: force) do
|
50
|
-
QaServer.config.monitor_logger.
|
50
|
+
QaServer.config.monitor_logger.debug("(QaServer::ScenarioRunHistory##{__method__}) - CALCULATING summary of latest run - cache expired or refresh requested (force: #{force})")
|
51
51
|
status = status_counts_in_run(run_id: scenario_run.id)
|
52
52
|
summary_class.new(run_id: scenario_run.id,
|
53
53
|
run_dt_stamp: scenario_run.dt_stamp,
|
@@ -130,7 +130,7 @@ module QaServer
|
|
130
130
|
def run_failures(run_id:, force: false)
|
131
131
|
return [] unless run_id
|
132
132
|
Rails.cache.fetch("QaServer::ScenarioRunHistory/#{__method__}", expires_in: QaServer::MonitorCacheService.cache_expiry, race_condition_ttl: 1.minute, force: force) do
|
133
|
-
QaServer.config.monitor_logger.
|
133
|
+
QaServer.config.monitor_logger.debug("(QaServer::ScenarioRunHistory##{__method__}) - finding failures in latest run - cache expired or refresh requested (force: #{force})")
|
134
134
|
QaServer::ScenarioRunHistory.where(scenario_run_registry_id: run_id).where.not(status: :good).to_a
|
135
135
|
end
|
136
136
|
end
|
@@ -142,7 +142,7 @@ module QaServer
|
|
142
142
|
# 'geonames_ld4l_cache' => { good: 32, bad: 1 } }
|
143
143
|
def historical_summary(force: false)
|
144
144
|
Rails.cache.fetch("QaServer::ScenarioRunHistory/#{__method__}", expires_in: QaServer::MonitorCacheService.cache_expiry, race_condition_ttl: 1.minute, force: force) do
|
145
|
-
QaServer.config.monitor_logger.
|
145
|
+
QaServer.config.monitor_logger.debug("(QaServer::ScenarioRunHistory##{__method__}) - CALCULATING authority connection history - cache expired or refresh requested (force: #{force})")
|
146
146
|
days_good = count_days(:good)
|
147
147
|
days_bad = count_days(:bad)
|
148
148
|
days_unknown = count_days(:unknown)
|
@@ -35,7 +35,7 @@ module PrependedLinkedData::FindTerm
|
|
35
35
|
retrieve_plus_graph_load_time_ms: full_results[:performance][:fetch_time_s] * 1000,
|
36
36
|
normalization_time_ms: full_results[:performance][:normalization_time_s] * 1000 }
|
37
37
|
QaServer.config.performance_cache.update(id: @phid, updates: updates)
|
38
|
-
QaServer.config.performance_cache.
|
38
|
+
QaServer.config.performance_cache.complete_entry(id: @phid)
|
39
39
|
end
|
40
40
|
|
41
41
|
# Override to append performance history record id into the URL to allow access to the record in RDF::Graph
|
@@ -35,7 +35,7 @@ module PrependedLinkedData::SearchQuery
|
|
35
35
|
retrieve_plus_graph_load_time_ms: full_results[:performance][:fetch_time_s] * 1000,
|
36
36
|
normalization_time_ms: full_results[:performance][:normalization_time_s] * 1000 }
|
37
37
|
QaServer.config.performance_cache.update(id: @phid, updates: updates)
|
38
|
-
QaServer.config.performance_cache.
|
38
|
+
QaServer.config.performance_cache.complete_entry(id: @phid)
|
39
39
|
end
|
40
40
|
|
41
41
|
# Override to append performance history record id into the URL to allow access to the record in RDF::Graph
|
@@ -26,7 +26,7 @@ module QaServer
|
|
26
26
|
# }
|
27
27
|
def calculate_datatable_data(force:)
|
28
28
|
Rails.cache.fetch("QaServer::PerformanceDatatableService/#{__method__}", expires_in: QaServer::MonitorCacheService.cache_expiry, race_condition_ttl: 5.minutes, force: force) do
|
29
|
-
QaServer.config.monitor_logger.
|
29
|
+
QaServer.config.monitor_logger.debug("(QaServer::PerformanceDatatableService##{__method__}) - CALCULATING performance datatable stats - cache expired or refresh requested (force: #{force})")
|
30
30
|
data = {}
|
31
31
|
auths = authority_list_class.authorities_list
|
32
32
|
data[ALL_AUTH] = datatable_data_for_authority
|
@@ -49,7 +49,7 @@ module QaServer
|
|
49
49
|
data = {}
|
50
50
|
auths = authority_list_class.authorities_list
|
51
51
|
calculate_all = force || cache_expired?
|
52
|
-
QaServer.config.monitor_logger.
|
52
|
+
QaServer.config.monitor_logger.debug("(QaServer::PerformanceGraphDataService##{__method__}) - CALCULATING performance graph data (calculate_all: #{calculate_all})")
|
53
53
|
data[ALL_AUTH] = graph_data_for_authority(force: force, calculate_all: calculate_all)
|
54
54
|
auths.each { |auth_name| data[auth_name] = graph_data_for_authority(authority_name: auth_name, force: force, calculate_all: calculate_all) }
|
55
55
|
data
|
@@ -12,7 +12,7 @@ module QaServer
|
|
12
12
|
# @param performance_data [Hash] hash of all performance data for all authorities
|
13
13
|
# @see QaServer:PerformanceHistory
|
14
14
|
def create_performance_graphs(performance_data:)
|
15
|
-
QaServer.config.monitor_logger.
|
15
|
+
QaServer.config.monitor_logger.debug("(QaServer::PerformanceGraphingService##{__method__}) - generating graphs")
|
16
16
|
performance_data.each_key do |auth_name|
|
17
17
|
create_graphs_for_authority(performance_data, auth_name.to_sym, :search)
|
18
18
|
create_graphs_for_authority(performance_data, auth_name.to_sym, :fetch)
|
@@ -82,4 +82,20 @@ QaServer.config do |config|
|
|
82
82
|
# by QaServer and can eat up logging realestate. To suppress the logging of details, set this config to true.
|
83
83
|
# @param [Boolean] do not log performance data details when true (defaults to false for backward compatibitily)
|
84
84
|
# config.suppress_logging_performance_datails = false
|
85
|
+
|
86
|
+
# Maximum amount of memory the performance cache can occupy before it is written to the database.
|
87
|
+
# @param [Integer] maximum size of performance cache before flushing
|
88
|
+
# config.max_performance_cache_size = 32.megabytes
|
89
|
+
|
90
|
+
# Enable/Disable logging of performance cache
|
91
|
+
# Uncomment one of the lines below to enable or disable performance cache logging. NOTE: By default, loggers follow the
|
92
|
+
# default levels for Rails loggers (i.e. enabled for development, disabled for production.)
|
93
|
+
# config.enable_performance_cache_logging
|
94
|
+
# config.disable_performance_cache_logging
|
95
|
+
|
96
|
+
# Enable/Disable logging of monitoring process
|
97
|
+
# Uncomment one of the lines below to enable or disable monitoring process logging. NOTE: By default, loggers follow the
|
98
|
+
# default levels for Rails loggers (i.e. enabled for development, disabled for production.)
|
99
|
+
# config.enable_monitor_status_logging
|
100
|
+
# config.disable_monitor_status_logging
|
85
101
|
end
|
@@ -201,12 +201,43 @@ module QaServer
|
|
201
201
|
@suppress_logging_performance_datails ||= false
|
202
202
|
end
|
203
203
|
|
204
|
+
# Maximum amount of memory the performance cache can occupy before it is written to the database.
|
205
|
+
# @param [Integer] maximum size of performance cache before flushing
|
206
|
+
attr_writer :max_performance_cache_size
|
207
|
+
def max_performance_cache_size
|
208
|
+
@max_performance_cache_size ||= 32.megabytes
|
209
|
+
end
|
210
|
+
|
204
211
|
# For internal use only
|
205
|
-
# TODO: consider refactor performance caching to use Rails cache
|
206
212
|
def performance_cache
|
207
213
|
@performance_cache ||= QaServer::PerformanceCache.new
|
208
214
|
end
|
209
215
|
|
216
|
+
# Enable logging of performance cache
|
217
|
+
def enable_performance_cache_logging
|
218
|
+
performance_cache_logger.level = Logger::DEBUG
|
219
|
+
end
|
220
|
+
|
221
|
+
# Disable logging of performance cache
|
222
|
+
def disable_performance_cache_logging
|
223
|
+
performance_cache_logger.level = Logger::INFO
|
224
|
+
end
|
225
|
+
|
226
|
+
# For internal use only
|
227
|
+
def performance_cache_logger
|
228
|
+
@performance_cache_logger ||= Logger.new(ENV['PERFORMANCE_CACHE_LOG_PATH'] || File.join("log", "performance_cache.log"))
|
229
|
+
end
|
230
|
+
|
231
|
+
# Enable logging of monitoring process
|
232
|
+
def enable_monitor_status_logging
|
233
|
+
monitor_logger.level = Logger::DEBUG
|
234
|
+
end
|
235
|
+
|
236
|
+
# Disable logging of performance cache
|
237
|
+
def disable_monitor_status_logging
|
238
|
+
monitor_logger.level = Logger::INFO
|
239
|
+
end
|
240
|
+
|
210
241
|
# For internal use only
|
211
242
|
def monitor_logger
|
212
243
|
@monitor_logger ||= Logger.new(ENV['MONITOR_LOG_PATH'] || File.join("log", "monitor.log"))
|
data/lib/qa_server/version.rb
CHANGED
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: 6.
|
4
|
+
version: 6.2.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: 2020-02-
|
11
|
+
date: 2020-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|