qa_server 0.1.99 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/indexing_bug.md +11 -0
  3. data/.github/ISSUE_TEMPLATE/new_dataset_request.md +22 -0
  4. data/.gitignore +2 -0
  5. data/.rubocop.yml +18 -0
  6. data/.rubocop_fixme.yml +10 -0
  7. data/CHANGELOG.md +12 -0
  8. data/Gemfile +1 -0
  9. data/Gemfile.lock +21 -15
  10. data/README.md +4 -0
  11. data/Rakefile +2 -1
  12. data/app/assets/stylesheets/qa_server/_home-page.scss +2 -2
  13. data/app/assets/stylesheets/qa_server/_styles.scss +4 -0
  14. data/app/controllers/qa_server/authority_list_controller.rb +3 -3
  15. data/app/controllers/qa_server/authority_validation_controller.rb +11 -12
  16. data/app/controllers/qa_server/check_status_controller.rb +6 -6
  17. data/app/controllers/qa_server/homepage_controller.rb +2 -2
  18. data/app/controllers/qa_server/monitor_status_controller.rb +32 -48
  19. data/app/controllers/qa_server/usage_controller.rb +2 -2
  20. data/app/loggers/qa_server/scenario_logger.rb +38 -42
  21. data/app/models/qa_server/authority_scenario.rb +1 -1
  22. data/app/models/qa_server/authority_status.rb +1 -0
  23. data/app/models/qa_server/authority_status_failure.rb +1 -0
  24. data/app/models/qa_server/scenario_run_history.rb +189 -0
  25. data/app/models/qa_server/scenario_run_registry.rb +34 -0
  26. data/app/models/qa_server/scenario_run_summary.rb +44 -0
  27. data/app/models/qa_server/scenarios.rb +15 -17
  28. data/app/models/qa_server/search_scenario.rb +4 -4
  29. data/app/models/qa_server/term_scenario.rb +2 -1
  30. data/app/presenters/qa_server/authority_list_presenter.rb +7 -6
  31. data/app/presenters/qa_server/check_status_presenter.rb +26 -16
  32. data/app/presenters/qa_server/monitor_status_presenter.rb +94 -38
  33. data/app/services/qa_server/authority_lister_service.rb +9 -9
  34. data/app/services/qa_server/authority_loader_service.rb +16 -15
  35. data/app/services/qa_server/authority_validator_service.rb +13 -13
  36. data/app/services/qa_server/database_migrator.rb +1 -0
  37. data/app/services/qa_server/scenarios_loader_service.rb +29 -27
  38. data/app/validators/qa_server/scenario_validator.rb +25 -35
  39. data/app/validators/qa_server/search_scenario_validator.rb +25 -18
  40. data/app/validators/qa_server/term_scenario_validator.rb +2 -1
  41. data/app/views/qa_server/check_status/index.html.erb +1 -1
  42. data/app/views/qa_server/homepage/index.html.erb +3 -3
  43. data/app/views/qa_server/monitor_status/index.html.erb +15 -10
  44. data/app/views/qa_server/usage/index.html.erb +4 -4
  45. data/app/views/shared/_footer.html.erb +1 -1
  46. data/config/routes.rb +1 -0
  47. data/lib/generators/qa_server/assets_generator.rb +1 -0
  48. data/lib/generators/qa_server/config_generator.rb +6 -0
  49. data/lib/generators/qa_server/install_generator.rb +1 -0
  50. data/lib/generators/qa_server/models_generator.rb +1 -0
  51. data/lib/generators/qa_server/templates/config/initializers/qa_server.rb +4 -0
  52. data/lib/generators/qa_server/templates/config/locales/qa_server.en.yml +1 -1
  53. data/lib/generators/qa_server/templates/db/migrate/20180807045549_create_scenario_run_registry.rb.erb +7 -0
  54. data/lib/generators/qa_server/templates/db/migrate/20180807045552_create_scenario_run_history.rb.erb +16 -0
  55. data/lib/generators/qa_server/templates/db/migrate/20180807045554_drop_unused_tables.rb.erb +6 -0
  56. data/lib/generators/qa_server/templates/db/migrate/20180809045552_add_indices_to_scenario_run_history.rb.erb +8 -0
  57. data/lib/qa_server/configuration.rb +6 -0
  58. data/lib/qa_server/engine.rb +10 -1
  59. data/lib/qa_server/version.rb +2 -1
  60. data/lib/qa_server.rb +19 -1
  61. data/lib/tasks/install.rake +1 -0
  62. data/lib/tasks/qa_server_tasks.rake +1 -0
  63. data/qa_server.gemspec +8 -5
  64. data/spec/rails_helper.rb +1 -0
  65. data/spec/spec_helper.rb +98 -98
  66. data/spec/test_app_templates/Gemfile.extra +2 -1
  67. data/tasks/qa_server_dev.rake +1 -0
  68. metadata +49 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13fb44a70963e0c7b5b43a1068673df8a978fa98
4
- data.tar.gz: e5ad90e1aa1fc70b5c157da0f54541b2a2d5e044
3
+ metadata.gz: bb899be9f195123d4e4b12780679afac70ea5322
4
+ data.tar.gz: a12013b8d2434dae73f9d8ccf46ce0964fa95d9e
5
5
  SHA512:
6
- metadata.gz: 47f9271225161b5a90de64f589e1b699ced386b1c11272e213743f21cf970d39f46e249dd12a4b612390332ad9daca954c300b93633cd1bfa7131bbc3ed2cf05
7
- data.tar.gz: 4550a987b4ea1d3d36584c726ea19e5878a09e8d71532dbb2bbc35080840b7e76bb4ddef5ad195ff37e7912bdbad9c06619f2c0231ee0e6a54ecc28536c39543
6
+ metadata.gz: 52e2544fe44d77e9db9e93402caf3d922bd68bbaf1cfd02c62bd26aa5615aa68ad22836797a9fd1a8bd18891592c3c3c2be5ef5d16d452823873c1bce38e91de
7
+ data.tar.gz: 6eba1a6ffc47017d4ee5d8e5cc58e7c4bbadd84bb8bd2937483585fe520c49f0fd16a0699e6948b7e3c364620a4044a39fa30dd0823ea5bf727bcb614bb709b9
@@ -0,0 +1,11 @@
1
+ ---
2
+ name: 'Indexing bug:'
3
+ about: To make requests for indexing improvements for datasets currently available in QA
4
+
5
+ ---
6
+
7
+ For tracking purposes, please create a separate issue for each indexing improvement request.
8
+
9
+ - [ ] Please describe the expected performance and accuracy of a particular vocabulary.
10
+ - [ ] If applicable, please update and provide links related to existing tests, e.g. https://github.com/LD4P/qa_server/blob/master/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locgenres_ld4l_cache_validation.yml#L74-L78
11
+ - [ ] If applicable, please update the relevant tab in https://docs.google.com/spreadsheets/d/1rPvEoP9iYNkxJ0eWC8gXe3ci7e6mhW0da59xkGhadi0/edit?usp=sharing for the particular dataset in question
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: 'Request a New Dataset for QA:'
3
+ about: This issue template is for LD4P2 requests for a new data source to be added to QA.
4
+
5
+ ---
6
+
7
+ _Please only use this issue template for LD4P2 requests for a new data source to be added to QA. If your requesting changes to how a dataset currently available in QA is treated, please use the indexing bug issue template._
8
+
9
+ __For LD4P2 partners and cohorts:__
10
+
11
+ More information about making a request can be found at https://wiki.duraspace.org/display/LD4P2/Request+a+New+Dataset+For+QA
12
+
13
+ Please perform each task listed below. (Email sf433 @ cornell dot edu with questions):
14
+
15
+ - [ ] Identify the data source: (Include the Data Source Name and its homepage URL)
16
+ - [ ] Add a new tab and indexing information for the data source to the following spreadsheet: https://docs.google.com/spreadsheets/d/1rPvEoP9iYNkxJ0eWC8gXe3ci7e6mhW0da59xkGhadi0/edit?usp=sharing.
17
+ - [ ] Add a YAML test file to https://github.com/cul-it/qa_server/tree/master/config/authorities/linked_data/scenarios; please provide here a link to the YAML file related to this request.
18
+ - See the definition of YAML keys: (link coming soon).
19
+ - YAML Example: https://github.com/cul-it/qa_server/blob/master/config/authorities/linked_data/scenarios/locgenres_ld4l_cache_validation.yml
20
+
21
+
22
+ _Please note, all requests for new data sources in QA will be prioritized by the LD4P2 project. Due to time restrictions there is no guarantee that all requests will be added to QA during the lifetime of the LD4P2 grant; regardless of resources it is still useful to know which datasets the community would find useful in such a lookup service._
data/.gitignore CHANGED
@@ -69,3 +69,5 @@ test/dummy/storage/
69
69
  test/dummy/tmp/
70
70
 
71
71
  .internal_test_app
72
+
73
+ *.gem
data/.rubocop.yml ADDED
@@ -0,0 +1,18 @@
1
+ inherit_gem:
2
+ bixby: bixby_default.yml
3
+
4
+ inherit_from: .rubocop_fixme.yml
5
+
6
+ AllCops:
7
+ TargetRubyVersion: 2.4
8
+ DisplayCopNames: true
9
+ Exclude:
10
+ - 'db/**/*'
11
+ - 'script/**/*'
12
+ - 'spec/test_app_templates/**/*'
13
+ - 'vendor/**/*'
14
+ - 'lib/hyrax/specs/**/*'
15
+
16
+ Lint/ImplicitStringConcatenation:
17
+ Exclude:
18
+ - 'lib/generators/qa_server/**/*'
@@ -0,0 +1,10 @@
1
+ Lint/RescueException:
2
+ Exclude:
3
+ - 'app/services/qa_server/scenarios_loader_service.rb'
4
+ - 'app/services/qa_server/authority_loader_service.rb'
5
+ - 'app/validators/qa_server/scenario_validator.rb'
6
+ - 'app/validators/qa_server/search_scenario_validator.rb'
7
+
8
+ Lint/UnusedMethodArgument:
9
+ Exclude:
10
+ - 'app/models/qa_server/authority_scenario.rb'
data/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ ### 1.0.0 (2018-09-24)
2
+
3
+ * drive URL base host path from qa engine mount location
4
+ * show graph of historical data on monitor status page (prereq: ImageMagick)
5
+ * expand historical data to track all test results (passing and failing) (requires: db migrations)
6
+ * add bixby to control rubocop styles consistent with Hyrax
7
+ * add ability to use configurations to control app features
8
+ * fix security vulnerabilities
9
+
10
+ ### 0.1.99 (2018-08-27)
11
+
12
+ * convert existing app code into a ruby engine
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  source 'https://rubygems.org'
2
3
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
4
 
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  GIT
2
2
  remote: https://github.com/samvera/questioning_authority.git
3
- revision: 7fc60a1a205430774d32cff9dea9993fe68fcb76
3
+ revision: e870fc07b991188053d2cd9eeb6a843b896911d8
4
4
  branch: min_context
5
5
  specs:
6
- qa (2.0.1)
6
+ qa (2.1.1)
7
7
  activerecord-import
8
8
  deprecation
9
9
  faraday
@@ -12,12 +12,11 @@ GIT
12
12
  rdf
13
13
 
14
14
  PATH
15
- remote: /Users/elr37/Documents/__DEVELOPMENT__/LD4L/_LD4L3/qa_server/LD4P/sprint/qa_server
15
+ remote: /Users/elr37/Documents/__DEVELOPMENT__/LD4L/_LD4L3/sprint/LD4P/qa_server
16
16
  specs:
17
- qa_server (0.1.99)
18
- linkeddata
19
- qa
20
- rails (= 5.1.6)
17
+ qa_server (1.0.0)
18
+ gruff
19
+ rails (~> 5.0)
21
20
 
22
21
  GEM
23
22
  remote: https://rubygems.org/
@@ -67,11 +66,13 @@ GEM
67
66
  ast (2.4.0)
68
67
  bcp47 (0.3.3)
69
68
  i18n
70
- better_errors (2.4.0)
69
+ better_errors (2.5.0)
71
70
  coderay (>= 1.0.0)
72
71
  erubi (>= 1.0.0)
73
72
  rack (>= 0.9.0)
74
73
  bindex (0.5.0)
74
+ binding_of_caller (0.8.0)
75
+ debug_inspector (>= 0.0.1)
75
76
  bixby (1.0.0)
76
77
  rubocop (~> 0.50, <= 0.52.1)
77
78
  rubocop-rspec (~> 1.22, <= 1.22.2)
@@ -97,6 +98,7 @@ GEM
97
98
  concurrent-ruby (1.0.5)
98
99
  connection_pool (2.2.2)
99
100
  crass (1.0.4)
101
+ debug_inspector (0.0.3)
100
102
  deprecation (1.0.0)
101
103
  activesupport
102
104
  diff-lcs (1.3)
@@ -110,11 +112,13 @@ GEM
110
112
  nokogiri (>= 1.4.3)
111
113
  erubi (1.7.1)
112
114
  execjs (2.7.0)
113
- faraday (0.15.2)
115
+ faraday (0.15.3)
114
116
  multipart-post (>= 1.2, < 3)
115
117
  ffi (1.9.25)
116
118
  globalid (0.4.1)
117
119
  activesupport (>= 4.2.0)
120
+ gruff (0.7.0)
121
+ rmagick (~> 2.13, >= 2.13.4)
118
122
  haml (5.0.4)
119
123
  temple (>= 0.8.0)
120
124
  tilt
@@ -277,6 +281,7 @@ GEM
277
281
  rdf (~> 3.0)
278
282
  rdf-xsd (3.0.0)
279
283
  rdf (~> 3.0)
284
+ rmagick (2.16.0)
280
285
  rspec-activemodel-mocks (1.0.3)
281
286
  activemodel (>= 3.0)
282
287
  activesupport (>= 3.0)
@@ -312,8 +317,8 @@ GEM
312
317
  rubocop (>= 0.52.1)
313
318
  ruby-progressbar (1.10.0)
314
319
  ruby_dep (1.5.0)
315
- rubyzip (1.2.1)
316
- sass (3.5.7)
320
+ rubyzip (1.2.2)
321
+ sass (3.6.0)
317
322
  sass-listen (~> 4.0.0)
318
323
  sass-listen (4.0.0)
319
324
  rb-fsevent (~> 0.9, >= 0.9.4)
@@ -335,7 +340,7 @@ GEM
335
340
  rdf-xsd (>= 2.2, < 4.0)
336
341
  sparql (>= 2.2, < 4.0)
337
342
  sxp (~> 1.0)
338
- sparql (3.0.1)
343
+ sparql (3.0.2)
339
344
  builder (~> 3.2)
340
345
  ebnf (~> 1.1)
341
346
  rdf (~> 3.0)
@@ -365,10 +370,10 @@ GEM
365
370
  turbolinks-source (5.2.0)
366
371
  tzinfo (1.2.5)
367
372
  thread_safe (~> 0.1)
368
- uglifier (4.1.18)
373
+ uglifier (4.1.19)
369
374
  execjs (>= 0.3.0, < 3)
370
375
  unicode-display_width (1.4.0)
371
- web-console (3.6.2)
376
+ web-console (3.7.0)
372
377
  actionview (>= 5.0)
373
378
  activemodel (>= 5.0)
374
379
  bindex (>= 0.4.0)
@@ -384,6 +389,7 @@ PLATFORMS
384
389
 
385
390
  DEPENDENCIES
386
391
  better_errors
392
+ binding_of_caller
387
393
  bixby (~> 1.0.0)
388
394
  byebug
389
395
  capybara (~> 2.13)
@@ -408,4 +414,4 @@ DEPENDENCIES
408
414
  web-console (>= 3.3.0)
409
415
 
410
416
  BUNDLED WITH
411
- 1.16.4
417
+ 1.16.5
data/README.md CHANGED
@@ -18,6 +18,10 @@ Tested with...
18
18
  * Ruby 2.4.3
19
19
  * Rails 5.1.6
20
20
 
21
+ ### Prerequisites
22
+
23
+ 1. [ImageMagick](http://www.imagemagick.org/)
24
+
21
25
  ### Installation Instructions
22
26
 
23
27
  #### Adding the engine dependency
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
- #!/usr/bin/env rake
1
+ # frozen_string_literal: true
2
+ # !/usr/bin/env rake
2
3
  begin
3
4
  require 'bundler/setup'
4
5
  rescue LoadError
@@ -4,8 +4,8 @@ div.page-description {
4
4
 
5
5
  p.welcome, p.welcome2 {
6
6
  padding-top: 50px;
7
- padding-left: 225px;
8
- padding-right: 225px;
7
+ padding-left: 75px;
8
+ padding-right: 75px;
9
9
  font-size: 1.2em;
10
10
  text-align: justify;
11
11
  }
@@ -1,3 +1,7 @@
1
+ #skiptocontent {
2
+ visibility: hidden;
3
+ }
4
+
1
5
  .container {
2
6
  padding-left: 0px;
3
7
  padding-right: 0px;
@@ -1,9 +1,9 @@
1
+ # frozen_string_literal: true
1
2
  # Controller for Authorities header menu item
2
3
  module QaServer
3
- class AuthorityListController < AuthorityValidationController
4
-
4
+ class AuthorityListController < QaServer::AuthorityValidationController
5
5
  class_attribute :presenter_class
6
- self.presenter_class = AuthorityListPresenter
6
+ self.presenter_class = QaServer::AuthorityListPresenter
7
7
 
8
8
  # Sets up presenter with data to display in the UI
9
9
  def index
@@ -1,21 +1,20 @@
1
+ # frozen_string_literal: true
1
2
  module QaServer
2
3
  class AuthorityValidationController < ApplicationController
3
4
  layout 'qa_server'
4
5
 
5
- attr_reader :status_data
6
-
7
6
  class_attribute :validator_class,
8
7
  :lister_class,
9
8
  :logger_class
10
9
 
11
- self.validator_class = AuthorityValidatorService
12
- self.lister_class = AuthorityListerService
13
- self.logger_class = ScenarioLogger
10
+ self.validator_class = QaServer::AuthorityValidatorService
11
+ self.lister_class = QaServer::AuthorityListerService
12
+ self.logger_class = QaServer::ScenarioLogger
14
13
 
15
14
  VALIDATION_TYPE_PARAM = :validation_type
16
- VALIDATE_CONNECTIONS = 'connections'.freeze
17
- VALIDATE_ACCURACY = 'accuracy'.freeze
18
- ALL_VALIDATIONS = 'all_checks'.freeze
15
+ VALIDATE_CONNECTIONS = 'connections'
16
+ VALIDATE_ACCURACY = 'accuracy'
17
+ ALL_VALIDATIONS = 'all_checks'
19
18
  DEFAULT_VALIDATION_TYPE = validator_class::VALIDATE_CONNECTIONS
20
19
 
21
20
  private
@@ -62,12 +61,12 @@ module QaServer
62
61
 
63
62
  def validation_type
64
63
  return @validation_type if @validation_type.present?
65
- case
66
- when params[VALIDATION_TYPE_PARAM] == ALL_VALIDATIONS
64
+ case params[VALIDATION_TYPE_PARAM]
65
+ when ALL_VALIDATIONS
67
66
  validator_class::ALL_VALIDATIONS
68
- when params[VALIDATION_TYPE_PARAM] == VALIDATE_CONNECTIONS
67
+ when VALIDATE_CONNECTIONS
69
68
  validator_class::VALIDATE_CONNECTIONS
70
- when params[VALIDATION_TYPE_PARAM] == VALIDATE_ACCURACY
69
+ when VALIDATE_ACCURACY
71
70
  validator_class::VALIDATE_ACCURACY
72
71
  else
73
72
  DEFAULT_VALIDATION_TYPE
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
1
2
  # Controller for Check Status header menu item
2
3
  module QaServer
3
- class CheckStatusController < AuthorityValidationController
4
-
5
- ALL_AUTHORITIES = '__all__'.freeze
4
+ class CheckStatusController < QaServer::AuthorityValidationController
5
+ ALL_AUTHORITIES = '__all__'
6
6
 
7
7
  class_attribute :presenter_class
8
- self.presenter_class = CheckStatusPresenter
8
+ self.presenter_class = QaServer::CheckStatusPresenter
9
9
 
10
10
  # Sets up presenter with data to display in the UI
11
11
  def index
@@ -27,12 +27,12 @@ module QaServer
27
27
 
28
28
  def authorities_to_validate
29
29
  return [] unless authority_name.present?
30
- (authority_name == ALL_AUTHORITIES) ? authorities_list : [authority_name]
30
+ authority_name == ALL_AUTHORITIES ? authorities_list : [authority_name]
31
31
  end
32
32
 
33
33
  def authority_name
34
34
  return @authority_name if @authority_name.present?
35
- @authority_name = (params.key? :authority) ? params[:authority].downcase : nil
35
+ @authority_name = (params.key? :authority) ? params[:authority].downcase : nil # rubocop:disable Style/TernaryParentheses
36
36
  end
37
37
  end
38
38
  end
@@ -1,8 +1,8 @@
1
+ # frozen_string_literal: true
1
2
  module QaServer
2
3
  class HomepageController < ApplicationController
3
4
  layout 'qa_server'
4
5
 
5
- def index
6
- end
6
+ def index; end
7
7
  end
8
8
  end
@@ -1,75 +1,59 @@
1
+ # frozen_string_literal: true
1
2
  # Controller for Monitor Status header menu item
2
3
  module QaServer
3
- class MonitorStatusController < AuthorityValidationController
4
-
4
+ class MonitorStatusController < QaServer::AuthorityValidationController
5
5
  class_attribute :presenter_class,
6
- :authority_status_model_class,
7
- :authority_status_failure_model_class
6
+ :scenario_run_registry_class,
7
+ :scenario_history_class
8
8
 
9
- self.presenter_class = MonitorStatusPresenter
10
- self.authority_status_model_class = AuthorityStatus
11
- self.authority_status_failure_model_class = AuthorityStatusFailure
9
+ self.presenter_class = QaServer::MonitorStatusPresenter
10
+ self.scenario_run_registry_class = QaServer::ScenarioRunRegistry
11
+ self.scenario_history_class = QaServer::ScenarioRunHistory
12
12
 
13
13
  # Sets up presenter with data to display in the UI
14
14
  def index
15
- authority_status = latest_authority_status
16
- if refresh? || expired_status? || authority_status.blank?
15
+ if refresh? || expired?
17
16
  validate(authorities_list)
18
- status_log.delete_passing
19
- update_authority_status
20
- authority_status = latest_authority_status
21
- end
22
- @authority_count = authorities_list.size
23
- # TODO: Include historical data too
24
- @presenter = presenter_class.new(authority_count: @authority_count,
25
- authority_status: @latest_authority_status,
26
- current_data: @status_data,
27
- historical_data: [])
28
- render 'index', :status => :internal_server_error if authority_status.failure_count.positive?
17
+ update_summary_and_data
18
+ end
19
+ # TODO: Include historical data and performance data too
20
+ @presenter = presenter_class.new(current_summary: latest_summary,
21
+ current_failure_data: latest_failures,
22
+ historical_summary_data: historical_summary_data,
23
+ performance_data: [])
24
+ render 'index', status: :internal_server_error if latest_summary.failing_authority_count.positive?
29
25
  end
30
26
 
31
27
  private
32
28
 
33
- def latest_authority_status
34
- @status_data ||= authority_status_model_class.latest_failures.to_a
35
- @latest_authority_status ||= authority_status_model_class.latest
29
+ def latest_run
30
+ @latest_run ||= scenario_run_registry_class.latest_run
36
31
  end
37
32
 
38
- def update_authority_status
39
- save_authority_status(status_log)
40
- @status_data = status_data_from_log
33
+ def latest_summary
34
+ @latest_summary ||= scenario_history_class.run_summary(scenario_run: latest_run)
41
35
  end
42
36
 
43
- def save_authority_status(status_log)
44
- @latest_authority_status = authority_status_model_class.create(dt_stamp: dt_stamp_now_et,
45
- test_count: status_log.test_count,
46
- failure_count: status_log.failure_count)
47
- status_log.to_a.each { |failure| save_authority_status_failure(@latest_authority_status, failure) }
37
+ def latest_failures
38
+ @status_data ||= scenario_history_class.run_failures(run_id: latest_run.id)
48
39
  end
49
40
 
50
- def save_authority_status_failure(authority_status, failure)
51
- authority_status_failure_model_class.create(authority_status_id: authority_status.id,
52
- status: failure[:status],
53
- status_label: failure[:status_label],
54
- authority_name: failure[:authority_name].to_s,
55
- subauthority_name: failure[:subauthority_name],
56
- service: failure[:service],
57
- action: failure[:action],
58
- url: failure[:url],
59
- err_message: failure[:err_message])
41
+ def update_summary_and_data
42
+ scenario_run_registry_class.save_run(scenarios_results: status_log.to_a)
43
+ @latest_summary = nil # reset so next request recalculates
44
+ @latest_failures = nil # reset so next request recalculates
60
45
  end
61
46
 
62
- def expired_status?
63
- status = latest_authority_status
64
- status.blank? || status.dt_stamp < yesterday_midnight_et
47
+ def historical_summary_data
48
+ @historical_summary_data ||= scenario_history_class.historical_summary
65
49
  end
66
50
 
67
- def yesterday_midnight_et
68
- (DateTime.yesterday.midnight.to_time + 4.hours).to_datetime.in_time_zone("Eastern Time (US & Canada)")
51
+ def expired?
52
+ latest_summary.blank? || latest_summary.run_dt_stamp < yesterday_midnight_et
69
53
  end
70
54
 
71
- def dt_stamp_now_et
72
- Time.now.in_time_zone("Eastern Time (US & Canada)")
55
+ def yesterday_midnight_et
56
+ (DateTime.yesterday.midnight.to_time + 4.hours).to_datetime.in_time_zone("Eastern Time (US & Canada)")
73
57
  end
74
58
 
75
59
  def refresh?
@@ -1,8 +1,8 @@
1
+ # frozen_string_literal: true
1
2
  module QaServer
2
3
  class UsageController < ApplicationController
3
4
  layout 'qa_server'
4
5
 
5
- def index
6
- end
6
+ def index; end
7
7
  end
8
8
  end
@@ -1,11 +1,17 @@
1
+ # frozen_string_literal: true
1
2
  # Provide a log of scenario data and test results
2
3
  module QaServer
3
4
  class ScenarioLogger
5
+ include Enumerable
6
+
7
+ # @return the number of scenarios recorded in the log
8
+ delegate :size, :each, to: :@log
9
+
4
10
  attr_reader :test_count, :failure_count
5
11
 
6
- PASS = ScenarioValidator::PASS
7
- FAIL = ScenarioValidator::FAIL
8
- UNKNOWN = ScenarioValidator::UNKNOWN
12
+ PASS = QaServer::ScenarioValidator::PASS
13
+ FAIL = QaServer::ScenarioValidator::FAIL
14
+ UNKNOWN = QaServer::ScenarioValidator::UNKNOWN
9
15
 
10
16
  def initialize(test_count = 0, failure_count = 0)
11
17
  @log = []
@@ -14,41 +20,36 @@ module QaServer
14
20
  end
15
21
 
16
22
  # Add a scenario to the log
17
- # @param authority_name [String] name of the authority the scenario was run against
18
- # @param status [Symbol] indicating whether the scenario passed, failed, or has unknown status (see PASS, FAIL, UNKNOWN constants)
19
- # @param validation_type [Symbol] the type of validation this status data describes (e.g. :connection, :accuracy)
20
- # @param subauth [String] name of the subauthority the scenario was run against
21
- # @param service [String] identifies the primary service provider (e.g. 'ld4l_cache', 'direct', etc.)
22
- # @param action [String] type of scenario (i.e. 'term', 'search')
23
- # @param url [String] example url that was used to test a specific term fetch or search query
24
- # @param error_message [String] error message if scenario failed
25
- # @param expected [Integer] the expected result (e.g. min size of result OR max position of subject within results)
26
- # @param actual [Integer] the actual result (e.g. actual size of results OR actual position of subject within results)
27
- # @param target [String] the expected target that was validated (e.g. subject_uri for query, pref label for term fetch)
28
- def add(authority_name:, validation_type: '', status:, subauth: '', service: '', action: '', url: '', error_message: '', expected: nil, actual: nil, target: nil)
23
+ # @param [Hash] status_info holding information to be logged
24
+ # @option authority_name [String] name of the authority the scenario was run against
25
+ # @option status [Symbol] indicating whether the scenario passed, failed, or has unknown status (see PASS, FAIL, UNKNOWN constants)
26
+ # @option validation_type [Symbol] the type of validation this status data describes (e.g. :connection, :accuracy)
27
+ # @option subauth [String] name of the subauthority the scenario was run against
28
+ # @option service [String] identifies the primary service provider (e.g. 'ld4l_cache', 'direct', etc.)
29
+ # @option action [String] type of scenario (i.e. 'term', 'search')
30
+ # @option url [String] example url that was used to test a specific term fetch or search query
31
+ # @option error_message [String] error message if scenario failed
32
+ # @option expected [Integer] the expected result (e.g. min size of result OR max position of subject within results)
33
+ # @option actual [Integer] the actual result (e.g. actual size of results OR actual position of subject within results)
34
+ # @option target [String] the expected target that was validated (e.g. subject_uri for query, pref label for term fetch)
35
+ # @option request_run_time [BigDecimal] the amount of time to retrieve data from the authority
36
+ # @option normalization_run_time [BigDecimal] the amount of time to normalize the retrieved data into json
37
+ def add(status_info) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
29
38
  @test_count += 1
30
- case status
31
- when PASS
32
- status_label = ''
33
- when UNKNOWN
34
- status_label = '?'
35
- @failure_count += 1
36
- when FAIL
37
- status_label = 'X'
38
- @failure_count += 1
39
- end
40
- @log << { type: validation_type,
41
- status: status,
42
- status_label: status_label,
43
- authority_name: authority_name,
44
- subauthority_name: subauth,
45
- service: service,
46
- action: action,
47
- url: url,
48
- expected: expected,
49
- actual: actual,
50
- target: target,
51
- err_message: error_message }
39
+ @failure_count += 1 unless status_info[:status] == PASS
40
+ @log << { type: status_info[:validation_type] || '',
41
+ status: status_info[:status] || '',
42
+ authority_name: status_info[:authority_name] || '',
43
+ subauthority_name: status_info[:subauth] || '',
44
+ service: status_info[:service] || '',
45
+ action: status_info[:action] || '',
46
+ url: status_info[:url] || '',
47
+ expected: status_info[:expected] || nil,
48
+ actual: status_info[:actual] || nil,
49
+ target: status_info[:target] || nil,
50
+ err_message: status_info[:error_message] || '',
51
+ request_run_time: status_info[:request_run_time] || nil,
52
+ normalization_run_time: status_info[:normalization_run_time] || nil }
52
53
  end
53
54
 
54
55
  # Delete from the log any tests that passed.
@@ -75,10 +76,5 @@ module QaServer
75
76
  def to_a
76
77
  @log
77
78
  end
78
-
79
- # @return the number of scenarios recorded in the log
80
- def size
81
- to_a.size
82
- end
83
79
  end
84
80
  end
@@ -1,7 +1,7 @@
1
+ # frozen_string_literal: true
1
2
  # Abstract class that parses the authority configuration from the yml file into the parts needed by inheriting scenario types.
2
3
  module QaServer
3
4
  class AuthorityScenario
4
-
5
5
  # @return [Qa::Authorities::LinkedData::GenericAuthority] authority instance the scenarios run against
6
6
  attr_reader :authority
7
7
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Provide access to the authority_status database table which tracks a summary of status data over time.
2
3
  module QaServer
3
4
  class AuthorityStatus < ActiveRecord::Base
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Provide access to the authority_status_failure database table which tracks specific failures over time.
2
3
  module QaServer
3
4
  class AuthorityStatusFailure < ActiveRecord::Base