qa_server 7.1.3 → 7.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop_fixme.yml +6 -0
  3. data/.travis.yml +4 -5
  4. data/CHANGELOG.md +36 -0
  5. data/Rakefile +1 -1
  6. data/app/assets/stylesheets/qa_server/_check-status.scss +36 -0
  7. data/app/cache_processors/concerns/qa_server/cache_keys.rb +0 -5
  8. data/app/cache_processors/qa_server/cache_expiry_service.rb +13 -8
  9. data/app/cache_processors/qa_server/job_id_cache.rb +29 -0
  10. data/app/cache_processors/qa_server/performance_cache.rb +34 -34
  11. data/app/cache_processors/qa_server/performance_day_graph_cache.rb +27 -0
  12. data/app/cache_processors/qa_server/performance_month_graph_cache.rb +27 -0
  13. data/app/cache_processors/qa_server/performance_year_graph_cache.rb +27 -0
  14. data/app/cache_processors/qa_server/scenario_history_cache.rb +7 -7
  15. data/app/cache_processors/qa_server/scenario_history_graph_cache.rb +12 -18
  16. data/app/cache_processors/qa_server/scenario_run_cache.rb +8 -8
  17. data/app/cache_processors/qa_server/scenario_run_failures_cache.rb +7 -7
  18. data/app/cache_processors/qa_server/scenario_run_summary_cache.rb +7 -7
  19. data/app/controllers/concerns/qa_server/authority_validation_behavior.rb +49 -44
  20. data/app/controllers/qa_server/check_status_controller.rb +92 -22
  21. data/app/controllers/qa_server/fetch_controller.rb +36 -36
  22. data/app/controllers/qa_server/monitor_status_controller.rb +105 -105
  23. data/app/jobs/qa_server/history_graph_job.rb +28 -0
  24. data/app/jobs/qa_server/monitor_tests_job.rb +19 -39
  25. data/app/jobs/qa_server/performance_day_graph_job.rb +45 -0
  26. data/app/jobs/qa_server/performance_month_graph_job.rb +45 -0
  27. data/app/jobs/qa_server/performance_per_byte_job.rb +85 -0
  28. data/app/jobs/qa_server/performance_year_graph_job.rb +45 -0
  29. data/app/loggers/qa_server/scenario_logger.rb +74 -4
  30. data/app/models/concerns/qa_server/performance_history_data_keys.rb +8 -0
  31. data/app/models/qa_server/authority_scenario.rb +4 -4
  32. data/app/models/qa_server/authority_status.rb +2 -2
  33. data/app/models/qa_server/authority_status_failure.rb +1 -1
  34. data/app/models/qa_server/performance_history.rb +2 -2
  35. data/app/models/qa_server/scenario_run_history.rb +52 -52
  36. data/app/models/qa_server/scenario_run_registry.rb +2 -2
  37. data/app/models/qa_server/scenarios.rb +26 -26
  38. data/app/models/qa_server/search_scenario.rb +18 -13
  39. data/app/models/qa_server/term_scenario.rb +29 -29
  40. data/app/prepends/prepended_linked_data/find_term.rb +40 -40
  41. data/app/prepends/prepended_linked_data/search_query.rb +36 -36
  42. data/app/prepends/prepended_rdf/rdf_graph.rb +7 -7
  43. data/app/presenters/concerns/qa_server/monitor_status/performance_datatable_behavior.rb +32 -32
  44. data/app/presenters/concerns/qa_server/monitor_status/performance_graph_behavior.rb +64 -65
  45. data/app/presenters/qa_server/check_status_presenter.rb +63 -7
  46. data/app/presenters/qa_server/monitor_status/history_presenter.rb +0 -2
  47. data/app/presenters/qa_server/monitor_status/performance_presenter.rb +0 -1
  48. data/app/services/concerns/qa_server/gruff_graph.rb +28 -0
  49. data/app/services/qa_server/authority_loader_service.rb +14 -14
  50. data/app/services/qa_server/authority_validator_service.rb +1 -0
  51. data/app/services/qa_server/database_migrator.rb +14 -14
  52. data/app/services/qa_server/history_graphing_service.rb +32 -36
  53. data/app/services/qa_server/performance_calculator_service.rb +80 -80
  54. data/app/services/qa_server/performance_datatable_service.rb +35 -35
  55. data/app/services/qa_server/performance_graph_data_service.rb +28 -28
  56. data/app/services/qa_server/performance_graphing_service.rb +60 -60
  57. data/app/services/qa_server/performance_per_byte_calculator_service.rb +88 -0
  58. data/app/services/qa_server/performance_per_byte_data_service.rb +41 -0
  59. data/app/services/qa_server/scenarios_loader_service.rb +1 -1
  60. data/app/services/qa_server/time_period_service.rb +21 -21
  61. data/app/validators/qa_server/scenario_validator.rb +99 -87
  62. data/app/validators/qa_server/search_scenario_validator.rb +67 -61
  63. data/app/validators/qa_server/term_scenario_validator.rb +20 -15
  64. data/app/views/qa_server/check_status/index.html.erb +120 -24
  65. data/config/locales/qa_server.en.yml +1 -0
  66. data/lib/generators/qa_server/assets_generator.rb +4 -4
  67. data/lib/generators/qa_server/templates/config/authorities/linked_data/cerl_ld4l_cache.json +2 -2
  68. data/lib/generators/qa_server/templates/config/authorities/linked_data/getty_aat_ld4l_cache.json +62 -1
  69. data/lib/generators/qa_server/templates/config/authorities/linked_data/getty_tgn_ld4l_cache.json +28 -4
  70. data/lib/generators/qa_server/templates/config/authorities/linked_data/isni_ld4l_cache.json +90 -0
  71. data/lib/generators/qa_server/templates/config/authorities/linked_data/ligatus_ld4l_cache.json +133 -0
  72. data/lib/generators/qa_server/templates/config/authorities/linked_data/locnames_rwo2_ld4l_cache.json +248 -0
  73. data/lib/generators/qa_server/templates/config/authorities/linked_data/locnames_rwo3_ld4l_cache.json +248 -0
  74. data/lib/generators/qa_server/templates/config/authorities/linked_data/locvocabs_ld4l_cache.json +117 -0
  75. data/lib/generators/qa_server/templates/config/authorities/linked_data/mesh_nlm_ld4l_cache.json +135 -3
  76. data/lib/generators/qa_server/templates/config/authorities/linked_data/oclcfast_direct.json +1 -0
  77. data/lib/generators/qa_server/templates/config/authorities/linked_data/oclcfast_ld4l_cache.json +1 -4
  78. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/agrovoc_direct_validation.yml +31 -0
  79. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/agrovoc_ld4l_cache_validation.yml +31 -0
  80. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/cerl_ld4l_cache_validation.yml +23 -11
  81. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/dbpedia_ld4l_cache_validation.yml +33 -0
  82. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/geonames_direct_validation.yml +35 -0
  83. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/geonames_ld4l_cache_validation.yml +58 -5
  84. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/getty_aat_ld4l_cache_validation.yml +256 -0
  85. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/getty_tgn_ld4l_cache_validation.yml +35 -1
  86. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/getty_ulan_ld4l_cache_validation.yml +37 -0
  87. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/isni_ld4l_cache_validation.yml +10 -0
  88. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/ligatus_ld4l_cache_validation.yml +36 -0
  89. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locdemographics_ld4l_cache_validation.yml +73 -44
  90. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locgenres_ld4l_cache_validation.yml +31 -0
  91. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locnames_ld4l_cache_validation.yml +71 -0
  92. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locnames_rwo_ld4l_cache_validation.yml +70 -2
  93. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locperformance_ld4l_cache_validation.yml +6 -0
  94. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locsubjects_ld4l_cache_validation.yml +32 -0
  95. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locvocabs_ld4l_cache_validation.yml +184 -0
  96. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/mesh_nlm_ld4l_cache_validation.yml +51 -1
  97. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/nalt_ld4l_cache_validation.yml +37 -0
  98. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/oclc_fast_validation.yml +71 -5
  99. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/oclcfast_direct_validation.yml +66 -1
  100. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/oclcfast_ld4l_cache_validation.yml +57 -0
  101. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/rda_registry_ld4l_cache_validation.yml +310 -0
  102. data/lib/qa_server/configuration.rb +28 -24
  103. data/lib/qa_server/version.rb +1 -1
  104. data/qa_server.gemspec +1 -1
  105. data/spec/feature/accuracy_spec.rb +32 -0
  106. data/spec/spec_helper.rb +4 -0
  107. metadata +30 -13
  108. data/app/cache_processors/qa_server/performance_daily_graph_cache.rb +0 -60
  109. data/app/cache_processors/qa_server/performance_hourly_graph_cache.rb +0 -65
  110. data/app/cache_processors/qa_server/performance_monthly_graph_cache.rb +0 -60
  111. data/app/presenters/concerns/qa_server/monitor_status/gruff_graph.rb +0 -20
@@ -7,22 +7,22 @@ module QaServer
7
7
 
8
8
  # Run connection tests
9
9
  def run_tests(force: false)
10
- Rails.cache.fetch(cache_key_for_running_tests, expires_in: next_expiry, race_condition_ttl: 30.seconds, force: force) do
10
+ Rails.cache.fetch(cache_key, expires_in: next_expiry, race_condition_ttl: 30.seconds, force: force) do
11
11
  QaServer.config.monitor_logger.debug("(QaServer::ScenarioRunCache) - KICKING OFF TEST RUN (force: #{force})")
12
12
  QaServer::MonitorTestsJob.perform_later
13
13
  "Test run initiated at #{QaServer::TimeService.current_time}"
14
14
  end
15
15
  end
16
16
 
17
- private
17
+ private
18
18
 
19
- def cache_key_for_running_tests
20
- SCENARIO_RUN_TEST_DATA_CACHE_KEY
21
- end
19
+ def cache_key
20
+ "QaServer::ScenarioRunCache.run_tests--latest_run_initiated"
21
+ end
22
22
 
23
- def next_expiry
24
- QaServer::CacheExpiryService.cache_expiry
25
- end
23
+ def next_expiry
24
+ QaServer::CacheExpiryService.cache_expiry
25
+ end
26
26
  end
27
27
  end
28
28
  end
@@ -37,15 +37,15 @@ module QaServer
37
37
  end
38
38
  end
39
39
 
40
- private
40
+ private
41
41
 
42
- def cache_key_for_run_failures(id)
43
- "#{SCENARIO_RUN_FAILURE_DATA_CACHE_KEY}--#{id}{"
44
- end
42
+ def cache_key_for_run_failures(id)
43
+ "#{SCENARIO_RUN_FAILURE_DATA_CACHE_KEY}--#{id}{"
44
+ end
45
45
 
46
- def next_expiry
47
- QaServer::CacheExpiryService.cache_expiry
48
- end
46
+ def next_expiry
47
+ QaServer::CacheExpiryService.cache_expiry
48
+ end
49
49
  end
50
50
  end
51
51
  end
@@ -26,15 +26,15 @@ module QaServer
26
26
  end
27
27
  end
28
28
 
29
- private
29
+ private
30
30
 
31
- def cache_key_for_run_summary(id)
32
- "#{SCENARIO_RUN_SUMMARY_DATA_CACHE_KEY}--#{id}"
33
- end
31
+ def cache_key_for_run_summary(id)
32
+ "#{SCENARIO_RUN_SUMMARY_DATA_CACHE_KEY}--#{id}"
33
+ end
34
34
 
35
- def next_expiry
36
- QaServer::CacheExpiryService.cache_expiry
37
- end
35
+ def next_expiry
36
+ QaServer::CacheExpiryService.cache_expiry
37
+ end
38
38
  end
39
39
  end
40
40
  end
@@ -6,6 +6,7 @@ module QaServer
6
6
  VALIDATION_TYPE_PARAM = :validation_type
7
7
  VALIDATE_CONNECTIONS = 'connections'
8
8
  VALIDATE_ACCURACY = 'accuracy'
9
+ VALIDATE_ACCURACY_COMPARISON = 'accuracy_comparison'
9
10
  ALL_VALIDATIONS = 'all_checks'
10
11
 
11
12
  included do
@@ -18,60 +19,64 @@ module QaServer
18
19
  self.logger_class = QaServer::ScenarioLogger
19
20
  end
20
21
 
21
- private
22
+ private
22
23
 
23
- def status_log
24
- @status_log ||= logger_class.new
25
- end
24
+ def status_log
25
+ @status_log ||= logger_class.new
26
+ end
26
27
 
27
- def status_data_from_log
28
- @status_data = status_log.to_a
29
- end
28
+ def status_data_from_log
29
+ @status_data = status_log.to_a
30
+ end
30
31
 
31
- def authorities_list
32
- @authorities_list ||= lister_class.authorities_list
33
- end
32
+ def authorities_list
33
+ @authorities_list ||= lister_class.authorities_list
34
+ end
34
35
 
35
- def validate(authorities_list, validation_type = validator_class::DEFAULT_VALIDATION_TYPE)
36
- return if authorities_list.blank?
37
- authorities_list.each { |auth_name| validate_authority(auth_name, validation_type) }
38
- end
36
+ def validate(authorities_list, validation_type = validator_class::DEFAULT_VALIDATION_TYPE)
37
+ return if authorities_list.blank?
38
+ result = []
39
+ authorities_list.each { |auth_name| result << validate_authority(auth_name, validation_type) }
40
+ result
41
+ end
39
42
 
40
- def validate_authority(auth_name, validation_type)
41
- validator_class.run(authority_name: auth_name, validation_type: validation_type, status_log: status_log)
42
- end
43
+ def validate_authority(auth_name, validation_type)
44
+ validator_class.run(authority_name: auth_name, validation_type: validation_type, status_log: status_log)
45
+ end
43
46
 
44
- def list(authorities_list)
45
- return if authorities_list.blank?
46
- authorities_list.each { |auth_name| list_scenarios(auth_name) }
47
- end
47
+ def list(authorities_list)
48
+ return if authorities_list.blank?
49
+ authorities_list.each { |auth_name| list_scenarios(auth_name) }
50
+ end
48
51
 
49
- def list_scenarios(auth_name)
50
- lister_class.scenarios_list(authority_name: auth_name, status_log: status_log)
51
- end
52
+ def list_scenarios(auth_name)
53
+ lister_class.scenarios_list(authority_name: auth_name, status_log: status_log)
54
+ end
52
55
 
53
- def validating_connections?
54
- return true if validation_type == VALIDATE_CONNECTIONS || validation_type == ALL_VALIDATIONS
55
- false
56
- end
56
+ def validating_accuracy?
57
+ return true if validation_type == validator_class::VALIDATE_ACCURACY
58
+ false
59
+ end
57
60
 
58
- def validating_accuracy?
59
- return true if validation_type == VALIDATE_ACCURACY || validation_type == ALL_VALIDATIONS
60
- false
61
- end
61
+ def comparing_accuracy?
62
+ return true if validation_type == validator_class::VALIDATE_ACCURACY_COMPARISON
63
+ false
64
+ end
62
65
 
63
- def validation_type
64
- return @validation_type if @validation_type.present?
65
- case params[VALIDATION_TYPE_PARAM]
66
- when ALL_VALIDATIONS
67
- validator_class::ALL_VALIDATIONS
68
- when VALIDATE_CONNECTIONS
69
- validator_class::VALIDATE_CONNECTIONS
70
- when VALIDATE_ACCURACY
71
- validator_class::VALIDATE_ACCURACY
72
- else
73
- validator_class::DEFAULT_VALIDATION_TYPE
74
- end
66
+ def validation_type
67
+ return @validation_type if @validation_type.present?
68
+ case params[VALIDATION_TYPE_PARAM]
69
+ when ALL_VALIDATIONS
70
+ validator_class::ALL_VALIDATIONS
71
+ when VALIDATE_CONNECTIONS
72
+ validator_class::VALIDATE_CONNECTIONS
73
+ when VALIDATE_ACCURACY
74
+ validator_class::VALIDATE_ACCURACY
75
+ when VALIDATE_ACCURACY_COMPARISON
76
+ validator_class::VALIDATE_ACCURACY_COMPARISON
77
+ else
78
+ validator_class::DEFAULT_VALIDATION_TYPE
75
79
  end
80
+ end
76
81
  end
77
82
  end
@@ -7,6 +7,7 @@ module QaServer
7
7
  include QaServer::AuthorityValidationBehavior
8
8
 
9
9
  ALL_AUTHORITIES = '__all__'
10
+ VALIDATE_ACCURACY_COMPARISON = :accuracy_comparison
10
11
 
11
12
  class_attribute :presenter_class
12
13
  self.presenter_class = QaServer::CheckStatusPresenter
@@ -17,36 +18,105 @@ module QaServer
17
18
  validate(authorities_to_validate, validation_type)
18
19
  @presenter = presenter_class.new(authorities_list: authorities_list,
19
20
  connection_status_data: connection_status_data_from_log,
20
- accuracy_status_data: accuracy_status_data_from_log)
21
+ accuracy_status_data: accuracy_status_data_from_log,
22
+ comparison_status_data: comparison_status_data_from_log)
21
23
  end
22
24
 
23
- private
25
+ private
24
26
 
25
- def connection_status_data_from_log
26
- status_log.filter(type: validator_class::VALIDATE_CONNECTIONS)
27
- end
27
+ def connection_status_data_from_log
28
+ status_log.filter(type: validator_class::VALIDATE_CONNECTIONS)
29
+ end
28
30
 
29
- def accuracy_status_data_from_log
30
- status_log.filter(type: validator_class::VALIDATE_ACCURACY)
31
- end
31
+ def accuracy_status_data_from_log
32
+ return [] unless validating_accuracy?
33
+ status_log.filter(type: validator_class::VALIDATE_ACCURACY)
34
+ end
32
35
 
33
- def authorities_to_validate
34
- return [] unless authority_name.present?
35
- authority_name == ALL_AUTHORITIES ? authorities_list : [authority_name]
36
- end
36
+ def comparison_status_data_from_log
37
+ return [] unless comparing_accuracy?
38
+ filtered_log = status_log.filter(type: validator_class::VALIDATE_ACCURACY, group: true)
39
+ return [] unless filtered_log.count == 2
40
+ overlay_log(filtered_log)
41
+ end
37
42
 
38
- def authority_name
39
- return @authority_name if @authority_name.present?
40
- @authority_name = params.key?(:authority) ? params[:authority].downcase : nil
41
- end
43
+ def overlay_log(log)
44
+ auths = log.keys
45
+ auth_a = log[auths[0]]
46
+ auth_b = log[auths[1]]
47
+ overlay = []
48
+ auth_a.each { |test| overlay << match_and_merge_test(test, auth_b) }
49
+ auth_b.each { |test| overlay << merge_test_results(empty_test(test), test) }
50
+ overlay
51
+ end
42
52
 
43
- def log_header
44
- QaServer.config.performance_cache_logger.debug("---------------------- check status (max_cache_size = #{max_cache_size}) ----------------------")
45
- QaServer.config.performance_cache_logger.debug("(#{self.class}##{__method__}) check status page request (authority_name # #{authority_name})")
53
+ def match_and_merge_test(a_test, auth_b)
54
+ auth_b.each_with_index do |b_test, idx|
55
+ next unless b_test[:action] == a_test[:action]
56
+ next unless b_test[:subauthority_name] == a_test[:subauthority_name]
57
+ next unless b_test[:request_data] == a_test[:request_data]
58
+ next unless b_test[:target] == a_test[:target]
59
+ return merge_test_results(a_test, auth_b.delete_at(idx))
46
60
  end
61
+ merge_test_results(a_test, empty_test(a_test))
62
+ end
47
63
 
48
- def max_cache_size
49
- ActiveSupport::NumberHelper.number_to_human_size(QaServer.config.max_performance_cache_size)
50
- end
64
+ def merge_test_results(a_test, b_test)
65
+ merged_tests = {}
66
+ merged_tests[:status] = [a_test[:status], b_test[:status]]
67
+ merged_tests[:service] = [a_test[:service], b_test[:service]]
68
+ merged_tests[:action] = a_test[:action]
69
+ merged_tests[:authority_name] = [a_test[:authority_name], b_test[:authority_name]]
70
+ merged_tests[:subauthority_name] = a_test[:subauthority_name]
71
+ merged_tests[:request_data] = a_test[:request_data]
72
+ merged_tests[:target] = a_test[:target]
73
+ merged_tests[:expected] = [a_test[:expected], b_test[:expected]]
74
+ merged_tests[:actual] = [a_test[:actual], b_test[:actual]]
75
+ merged_tests[:url] = [a_test[:url], b_test[:url]]
76
+ merged_tests[:err_message] = [a_test[:err_message], b_test[:err_message]]
77
+ merged_tests
78
+ end
79
+
80
+ def empty_test(base_test)
81
+ merged_tests = {}
82
+ merged_tests[:status] = ''
83
+ merged_tests[:service] = ''
84
+ merged_tests[:action] = base_test[:action]
85
+ merged_tests[:authority_name] = ''
86
+ merged_tests[:subauthority_name] = base_test[:subauthority_name]
87
+ merged_tests[:request_data] = base_test[:request_data]
88
+ merged_tests[:target] = base_test[:target]
89
+ merged_tests[:expected] = ''
90
+ merged_tests[:actual] = ''
91
+ merged_tests[:url] = ''
92
+ merged_tests[:err_message] = ''
93
+ merged_tests
94
+ end
95
+
96
+ def authorities_to_validate
97
+ return [] if authority_name.blank?
98
+ authority_names = authority_name == ALL_AUTHORITIES ? authorities_list : [authority_name]
99
+ authority_names << compare_with if comparing_accuracy? && compare_with.present?
100
+ authority_names
101
+ end
102
+
103
+ def authority_name
104
+ return @authority_name if @authority_name.present?
105
+ @authority_name = params.key?(:authority) ? params[:authority].downcase : nil
106
+ end
107
+
108
+ def compare_with
109
+ return @compare_with if @compare_with.present?
110
+ @compare_with = params.key?(:compare_with) ? params[:compare_with].downcase : nil
111
+ end
112
+
113
+ def log_header
114
+ QaServer.config.performance_cache_logger.debug("---------------------- check status (max_cache_size = #{max_cache_size}) ----------------------")
115
+ QaServer.config.performance_cache_logger.debug("(#{self.class}##{__method__}) check status page request (authority_name # #{authority_name})")
116
+ end
117
+
118
+ def max_cache_size
119
+ ActiveSupport::NumberHelper.number_to_human_size(QaServer.config.max_performance_cache_size)
120
+ end
51
121
  end
52
122
  end
@@ -20,41 +20,41 @@ module QaServer
20
20
  term_results: term_results)
21
21
  end
22
22
 
23
- private
24
-
25
- def authorities_list
26
- @authorities_list ||= lister_class.authorities_list
27
- end
28
-
29
- # @return [Qa::Authorities::LinkedData::GenericAuthority] the instance of the QA authority
30
- def authority
31
- return unless authority_name?
32
- @authority ||= QaServer::AuthorityLoaderService.load(authority_name: authority_name)
33
- end
34
-
35
- def uri?
36
- uri.present?
37
- end
38
-
39
- def uri
40
- @uri ||= params.key?(:uri) ? params[:uri] : nil
41
- end
42
-
43
- def authority_name?
44
- authority_name.present?
45
- end
46
-
47
- def authority_name
48
- @authority_name ||= params.key?(:authority) ? params[:authority].downcase : nil
49
- end
50
-
51
- def format
52
- @format ||= params.key?(:results_format) ? params[:results_format] : 'json'
53
- end
54
-
55
- def term_results
56
- return unless authority_name? && uri?
57
- @term_results = authority.find(uri, format: format)
58
- end
23
+ private
24
+
25
+ def authorities_list
26
+ @authorities_list ||= lister_class.authorities_list
27
+ end
28
+
29
+ # @return [Qa::Authorities::LinkedData::GenericAuthority] the instance of the QA authority
30
+ def authority
31
+ return unless authority_name?
32
+ @authority ||= QaServer::AuthorityLoaderService.load(authority_name: authority_name)
33
+ end
34
+
35
+ def uri?
36
+ uri.present?
37
+ end
38
+
39
+ def uri
40
+ @uri ||= params.key?(:uri) ? params[:uri] : nil
41
+ end
42
+
43
+ def authority_name?
44
+ authority_name.present?
45
+ end
46
+
47
+ def authority_name
48
+ @authority_name ||= params.key?(:authority) ? params[:authority].downcase : nil
49
+ end
50
+
51
+ def format
52
+ @format ||= params.key?(:results_format) ? params[:results_format] : 'json'
53
+ end
54
+
55
+ def term_results
56
+ return unless authority_name? && uri?
57
+ @term_results = authority.find(uri, format: format)
58
+ end
59
59
  end
60
60
  end
@@ -24,110 +24,110 @@ module QaServer
24
24
  render 'index', status: :internal_server_error if latest_summary.failing_authority_count.positive?
25
25
  end
26
26
 
27
- private
28
-
29
- def perform_updates
30
- update_tests
31
- update_historical_graph
32
- update_performance_graphs
33
- end
34
-
35
- def update_tests
36
- QaServer::ScenarioRunCache.run_tests(force: refresh_tests?)
37
- end
38
-
39
- # Sets @latest_test_run [QaServer::ScenarioRunRegistry]
40
- def latest_test_run
41
- @latest_test_run ||= scenario_run_registry_class.latest_run
42
- end
43
-
44
- # @returns [QaServer::ScenarioRunSummary] summary statistics on the latest run
45
- def latest_summary
46
- QaServer::ScenarioRunSummaryCache.summary_for_run(run: latest_test_run)
47
- end
48
-
49
- # @returns [Array<Hash>] scenario details for any failing scenarios in the latest run
50
- # @see QaServer::ScenarioRunHistory#run_failures for structure of output
51
- def latest_failures
52
- QaServer::ScenarioRunFailuresCache.failures_for_run(run: latest_test_run)
53
- end
54
-
55
- # Get a summary level of historical data
56
- # @returns [Array<Hash>] summary of passing/failing tests for each authority
57
- # @see QaServer::ScenarioRunHistory#historical_summary for structure of output
58
- def historical_data
59
- @historical_data ||= QaServer::ScenarioHistoryCache.historical_summary(force: refresh_history?)
60
- end
61
-
62
- def update_historical_graph
63
- return unless QaServer.config.display_historical_graph?
64
- QaServer::ScenarioHistoryGraphCache.generate_graph(data: historical_data, force: refresh_history?)
65
- end
66
-
67
- def performance_table_data
68
- return {} unless QaServer.config.display_performance_datatable?
69
- QaServer::PerformanceDatatableCache.data(force: refresh_performance_table?)
70
- end
71
-
72
- def update_performance_graphs
73
- return unless QaServer.config.display_performance_graph?
74
- QaServer::PerformanceHourlyGraphCache.generate_graphs(force: refresh_performance_graphs?)
75
- QaServer::PerformanceDailyGraphCache.generate_graphs(force: refresh_performance_graphs?)
76
- QaServer::PerformanceMonthlyGraphCache.generate_graphs(force: refresh_performance_graphs?)
77
- end
78
-
79
- def refresh?
80
- params.key?(:refresh) && validate_auth_reload_token("refresh status")
81
- end
82
-
83
- def refresh_all?
84
- return false unless refresh?
85
- params[:refresh].nil? || params[:refresh].casecmp?('all') # nil is for backward compatibility
86
- end
87
-
88
- def refresh_tests?
89
- refresh? ? (refresh_all? || params[:refresh].casecmp?('tests')) : false
90
- end
91
-
92
- def refresh_history?
93
- refresh? ? (refresh_all? || params[:refresh].casecmp?('history')) : false
94
- end
95
-
96
- def refresh_performance?
97
- refresh? ? (refresh_all? || params[:refresh].casecmp?('performance')) : false
98
- end
99
-
100
- def refresh_performance_table?
101
- refresh? ? (refresh_performance? || params[:refresh].casecmp?('performance_table')) : false
102
- end
103
-
104
- def refresh_performance_graphs?
105
- refresh? ? (refresh_performance? || params[:refresh].casecmp?('performance_graphs')) : false
106
- end
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
-
126
- def log_header
127
- QaServer.config.monitor_logger.debug("------------------------------------ monitor status -----------------------------------")
128
- QaServer.config.monitor_logger.debug("refresh_all? #{refresh_all?}, refresh_tests? #{refresh_tests?}, refresh_history? #{refresh_history?}")
129
- QaServer.config.monitor_logger.debug("refresh_performance? #{refresh_performance?}, refresh_performance_table? #{refresh_performance_table?}, " \
130
- "refresh_performance_graphs? #{refresh_performance_graphs?})")
131
- end
27
+ private
28
+
29
+ def perform_updates
30
+ update_tests
31
+ update_historical_graph
32
+ update_performance_graphs
33
+ end
34
+
35
+ def update_tests
36
+ QaServer::ScenarioRunCache.run_tests(force: refresh_tests?)
37
+ end
38
+
39
+ # Sets @latest_test_run [QaServer::ScenarioRunRegistry]
40
+ def latest_test_run
41
+ @latest_test_run ||= scenario_run_registry_class.latest_run
42
+ end
43
+
44
+ # @returns [QaServer::ScenarioRunSummary] summary statistics on the latest run
45
+ def latest_summary
46
+ QaServer::ScenarioRunSummaryCache.summary_for_run(run: latest_test_run)
47
+ end
48
+
49
+ # @returns [Array<Hash>] scenario details for any failing scenarios in the latest run
50
+ # @see QaServer::ScenarioRunHistory#run_failures for structure of output
51
+ def latest_failures
52
+ QaServer::ScenarioRunFailuresCache.failures_for_run(run: latest_test_run)
53
+ end
54
+
55
+ # Get a summary level of historical data
56
+ # @returns [Array<Hash>] summary of passing/failing tests for each authority
57
+ # @see QaServer::ScenarioRunHistory#historical_summary for structure of output
58
+ def historical_data
59
+ @historical_data ||= QaServer::ScenarioHistoryCache.historical_summary(force: refresh_history?)
60
+ end
61
+
62
+ def update_historical_graph
63
+ return unless QaServer.config.display_historical_graph?
64
+ QaServer::ScenarioHistoryGraphCache.generate_graph(data: historical_data, force: refresh_history?)
65
+ end
66
+
67
+ def performance_table_data
68
+ return {} unless QaServer.config.display_performance_datatable?
69
+ QaServer::PerformanceDatatableCache.data(force: refresh_performance_table?)
70
+ end
71
+
72
+ def update_performance_graphs
73
+ return unless QaServer.config.display_performance_graph?
74
+ QaServer::PerformanceDayGraphCache.generate_graphs(force: refresh_performance_graphs?)
75
+ QaServer::PerformanceMonthGraphCache.generate_graphs(force: refresh_performance_graphs?)
76
+ QaServer::PerformanceYearGraphCache.generate_graphs(force: refresh_performance_graphs?)
77
+ end
78
+
79
+ def refresh?
80
+ params.key?(:refresh) && validate_auth_reload_token("refresh status")
81
+ end
82
+
83
+ def refresh_all?
84
+ return false unless refresh?
85
+ params[:refresh].nil? || params[:refresh].casecmp?('all') # nil is for backward compatibility
86
+ end
87
+
88
+ def refresh_tests?
89
+ refresh? ? (refresh_all? || params[:refresh].casecmp?('tests')) : false
90
+ end
91
+
92
+ def refresh_history?
93
+ refresh? ? (refresh_all? || params[:refresh].casecmp?('history')) : false
94
+ end
95
+
96
+ def refresh_performance?
97
+ refresh? ? (refresh_all? || params[:refresh].casecmp?('performance')) : false
98
+ end
99
+
100
+ def refresh_performance_table?
101
+ refresh? ? (refresh_performance? || params[:refresh].casecmp?('performance_table')) : false
102
+ end
103
+
104
+ def refresh_performance_graphs?
105
+ refresh? ? (refresh_performance? || params[:refresh].casecmp?('performance_graphs')) : false
106
+ end
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
+
126
+ def log_header
127
+ QaServer.config.monitor_logger.debug("------------------------------------ monitor status -----------------------------------")
128
+ QaServer.config.monitor_logger.debug("refresh_all? #{refresh_all?}, refresh_tests? #{refresh_tests?}, refresh_history? #{refresh_history?}")
129
+ QaServer.config.monitor_logger.debug("refresh_performance? #{refresh_performance?}, refresh_performance_table? #{refresh_performance_table?}, " \
130
+ "refresh_performance_graphs? #{refresh_performance_graphs?})")
131
+ end
132
132
  end
133
133
  end