qa_server 5.5.1 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -0
  3. data/README.md +53 -0
  4. data/app/controllers/{qa_server/authority_validation_controller.rb → concerns/qa_server/authority_validation_behavior.rb} +13 -11
  5. data/app/controllers/qa_server/authority_list_controller.rb +5 -1
  6. data/app/controllers/qa_server/check_status_controller.rb +5 -1
  7. data/app/controllers/qa_server/monitor_status_controller.rb +40 -28
  8. data/app/jobs/qa_server/monitor_tests_job.rb +50 -0
  9. data/app/models/qa_server/performance_cache.rb +11 -3
  10. data/app/models/qa_server/performance_history.rb +24 -106
  11. data/app/models/qa_server/scenario_run_history.rb +161 -176
  12. data/app/models/qa_server/scenario_run_registry.rb +4 -4
  13. data/app/prepends/prepended_linked_data/find_term.rb +4 -4
  14. data/app/prepends/prepended_linked_data/search_query.rb +4 -4
  15. data/app/prepends/prepended_rdf/rdf_graph.rb +4 -4
  16. data/app/presenters/concerns/qa_server/monitor_status/performance_datatable_behavior.rb +23 -1
  17. data/app/presenters/qa_server/check_status_presenter.rb +4 -4
  18. data/app/presenters/qa_server/monitor_status/current_status_presenter.rb +17 -5
  19. data/app/presenters/qa_server/monitor_status/history_presenter.rb +40 -19
  20. data/app/presenters/qa_server/monitor_status/performance_presenter.rb +3 -1
  21. data/app/presenters/qa_server/monitor_status_presenter.rb +9 -9
  22. data/app/services/qa_server/monitor_cache_service.rb +22 -0
  23. data/app/services/qa_server/performance_calculator_service.rb +18 -7
  24. data/app/services/qa_server/performance_datatable_service.rb +82 -0
  25. data/app/services/qa_server/performance_graph_data_service.rb +140 -82
  26. data/app/services/qa_server/performance_graphing_service.rb +15 -12
  27. data/app/services/qa_server/time_period_service.rb +93 -0
  28. data/app/services/qa_server/time_service.rb +29 -0
  29. data/app/validators/qa_server/scenario_validator.rb +3 -3
  30. data/app/validators/qa_server/search_scenario_validator.rb +3 -3
  31. data/app/views/qa_server/monitor_status/_performance.html.erb +2 -1
  32. data/app/views/qa_server/monitor_status/_test_history.html.erb +1 -2
  33. data/app/views/qa_server/monitor_status/_test_summary.html.erb +2 -2
  34. data/config/locales/qa_server.en.yml +3 -4
  35. data/lib/generators/qa_server/templates/config/initializers/qa_server.rb +4 -0
  36. data/lib/qa_server.rb +0 -23
  37. data/lib/qa_server/configuration.rb +20 -0
  38. data/lib/qa_server/version.rb +1 -1
  39. data/spec/lib/qa_server_spec.rb +0 -51
  40. data/spec/services/qa_server/monitor_cache_service_spec.rb +20 -0
  41. data/spec/services/qa_server/time_period_service_spec.rb +246 -0
  42. data/spec/services/qa_server/time_service_spec.rb +50 -0
  43. metadata +14 -3
@@ -0,0 +1,246 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+
4
+ RSpec.describe QaServer::TimePeriodService do
5
+ before { allow(QaServer::TimeService).to receive(:current_time).and_return(Time.find_zone('Eastern Time (US & Canada)').local(2020, 1, 1)) }
6
+
7
+ let(:end_range) { QaServer::TimeService.current_time }
8
+
9
+ let(:auth_name) { 'LOC_DIRECT' }
10
+ let(:auth_table) { :scenario_run_history }
11
+ let(:dt_table) { :scenario_run_registry }
12
+
13
+ describe '.where_clause_for_last_24_hours' do
14
+ let(:end_hour) { end_range }
15
+ let(:start_hour) { end_hour - 1.day }
16
+
17
+ context 'when auth_name is nil' do
18
+ context 'and auth_table is nil' do
19
+ context 'and dt_table is nil' do
20
+ let(:expected_result) do
21
+ { dt_stamp: start_hour..end_hour }
22
+ end
23
+ it 'returns where clause with dt_stamp range only' do
24
+ expect(described_class.where_clause_for_last_24_hours).to eq expected_result
25
+ end
26
+ end
27
+
28
+ context 'and dt_table is present' do
29
+ let(:expected_result) do
30
+ { scenario_run_registry: { dt_stamp: start_hour..end_hour } }
31
+ end
32
+ it 'returns where clause with dt_stamp range limited to a specified table' do
33
+ expect(described_class.where_clause_for_last_24_hours(dt_table: dt_table)).to eq expected_result
34
+ end
35
+ end
36
+ end
37
+
38
+ context 'and auth_table is present' do
39
+ it 'raise error' do
40
+ expect { described_class.where_clause_for_last_24_hours(auth_table: auth_table) }
41
+ .to raise_error ArgumentError, "Do not specify auth_table when auth_name is not specified"
42
+ end
43
+ end
44
+ end
45
+
46
+ context 'when auth_name is present' do
47
+ context 'and auth_table is nil' do
48
+ context 'and dt_table is nil' do
49
+ let(:expected_result) do
50
+ {
51
+ dt_stamp: start_hour..end_hour,
52
+ authority: auth_name
53
+ }
54
+ end
55
+ it 'returns where clause with dt_stamp range and authname' do
56
+ expect(described_class.where_clause_for_last_24_hours(auth_name: auth_name)).to eq expected_result
57
+ end
58
+ end
59
+
60
+ context 'and dt_table is present' do
61
+ it 'raises error' do
62
+ expect { described_class.where_clause_for_last_24_hours(auth_name: auth_name, dt_table: dt_table) }
63
+ .to raise_error ArgumentError, "Either both table names need to be specified or neither"
64
+ end
65
+ end
66
+ end
67
+
68
+ context 'and auth_table is present' do
69
+ context 'and dt_table is nil' do
70
+ it 'raises error' do
71
+ expect { described_class.where_clause_for_last_24_hours(auth_name: auth_name, auth_table: auth_table) }
72
+ .to raise_error ArgumentError, "Either both table names need to be specified or neither"
73
+ end
74
+ end
75
+
76
+ context 'and dt_table is present' do
77
+ let(:expected_result) do
78
+ {
79
+ scenario_run_registry: { dt_stamp: start_hour..end_hour },
80
+ scenario_run_history: { authority: auth_name }
81
+ }
82
+ end
83
+ it 'returns where clause with dt_stamp range and authname limited to the specified tables' do
84
+ expect(described_class.where_clause_for_last_24_hours(auth_name: auth_name, auth_table: auth_table, dt_table: dt_table)).to eq expected_result
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
90
+
91
+ describe '.where_clause_for_last_30_days' do
92
+ let(:end_day) { end_range }
93
+ let(:start_day) { end_day - 1.month }
94
+
95
+ context 'when auth_name is nil' do
96
+ context 'and auth_table is nil' do
97
+ context 'and dt_table is nil' do
98
+ let(:expected_result) do
99
+ { dt_stamp: start_day..end_day }
100
+ end
101
+ it 'returns where clause with dt_stamp range only' do
102
+ expect(described_class.where_clause_for_last_30_days).to eq expected_result
103
+ end
104
+ end
105
+
106
+ context 'and dt_table is present' do
107
+ let(:expected_result) do
108
+ { scenario_run_registry: { dt_stamp: start_day..end_day } }
109
+ end
110
+ it 'returns where clause with dt_stamp range limited to a specified table' do
111
+ expect(described_class.where_clause_for_last_30_days(dt_table: dt_table)).to eq expected_result
112
+ end
113
+ end
114
+ end
115
+
116
+ context 'and auth_table is present' do
117
+ it 'raise error' do
118
+ expect { described_class.where_clause_for_last_30_days(auth_table: auth_table) }
119
+ .to raise_error ArgumentError, "Do not specify auth_table when auth_name is not specified"
120
+ end
121
+ end
122
+ end
123
+
124
+ context 'when auth_name is present' do
125
+ context 'and auth_table is nil' do
126
+ context 'and dt_table is nil' do
127
+ let(:expected_result) do
128
+ {
129
+ dt_stamp: start_day..end_day,
130
+ authority: auth_name
131
+ }
132
+ end
133
+ it 'returns where clause with dt_stamp range and authname' do
134
+ expect(described_class.where_clause_for_last_30_days(auth_name: auth_name)).to eq expected_result
135
+ end
136
+ end
137
+
138
+ context 'and dt_table is present' do
139
+ it 'raises error' do
140
+ expect { described_class.where_clause_for_last_30_days(auth_name: auth_name, dt_table: dt_table) }
141
+ .to raise_error ArgumentError, "Either both table names need to be specified or neither"
142
+ end
143
+ end
144
+ end
145
+
146
+ context 'and auth_table is present' do
147
+ context 'and dt_table is nil' do
148
+ it 'raises error' do
149
+ expect { described_class.where_clause_for_last_30_days(auth_name: auth_name, auth_table: auth_table) }
150
+ .to raise_error ArgumentError, "Either both table names need to be specified or neither"
151
+ end
152
+ end
153
+
154
+ context 'and dt_table is present' do
155
+ let(:expected_result) do
156
+ {
157
+ scenario_run_registry: { dt_stamp: start_day..end_day },
158
+ scenario_run_history: { authority: auth_name }
159
+ }
160
+ end
161
+ it 'returns where clause with dt_stamp range and authname limited to the specified tables' do
162
+ expect(described_class.where_clause_for_last_30_days(auth_name: auth_name, auth_table: auth_table, dt_table: dt_table)).to eq expected_result
163
+ end
164
+ end
165
+ end
166
+ end
167
+ end
168
+
169
+ describe '.where_clause_for_last_12_months' do
170
+ let(:end_month) { end_range }
171
+ let(:start_month) { end_month - 1.year }
172
+
173
+ context 'when auth_name is nil' do
174
+ context 'and auth_table is nil' do
175
+ context 'and dt_table is nil' do
176
+ let(:expected_result) do
177
+ { dt_stamp: start_month..end_month }
178
+ end
179
+ it 'returns where clause with dt_stamp range only' do
180
+ expect(described_class.where_clause_for_last_12_months).to eq expected_result
181
+ end
182
+ end
183
+
184
+ context 'and dt_table is present' do
185
+ let(:expected_result) do
186
+ { scenario_run_registry: { dt_stamp: start_month..end_month } }
187
+ end
188
+ it 'returns where clause with dt_stamp range limited to a specified table' do
189
+ expect(described_class.where_clause_for_last_12_months(dt_table: dt_table)).to eq expected_result
190
+ end
191
+ end
192
+ end
193
+
194
+ context 'and auth_table is present' do
195
+ it 'raise error' do
196
+ expect { described_class.where_clause_for_last_12_months(auth_table: auth_table) }
197
+ .to raise_error ArgumentError, "Do not specify auth_table when auth_name is not specified"
198
+ end
199
+ end
200
+ end
201
+
202
+ context 'when auth_name is present' do
203
+ context 'and auth_table is nil' do
204
+ context 'and dt_table is nil' do
205
+ let(:expected_result) do
206
+ {
207
+ dt_stamp: start_month..end_month,
208
+ authority: auth_name
209
+ }
210
+ end
211
+ it 'returns where clause with dt_stamp range and authname' do
212
+ expect(described_class.where_clause_for_last_12_months(auth_name: auth_name)).to eq expected_result
213
+ end
214
+ end
215
+
216
+ context 'and dt_table is present' do
217
+ it 'raises error' do
218
+ expect { described_class.where_clause_for_last_12_months(auth_name: auth_name, dt_table: dt_table) }
219
+ .to raise_error ArgumentError, "Either both table names need to be specified or neither"
220
+ end
221
+ end
222
+ end
223
+
224
+ context 'and auth_table is present' do
225
+ context 'and dt_table is nil' do
226
+ it 'raises error' do
227
+ expect { described_class.where_clause_for_last_12_months(auth_name: auth_name, auth_table: auth_table) }
228
+ .to raise_error ArgumentError, "Either both table names need to be specified or neither"
229
+ end
230
+ end
231
+
232
+ context 'and dt_table is present' do
233
+ let(:expected_result) do
234
+ {
235
+ scenario_run_registry: { dt_stamp: start_month..end_month },
236
+ scenario_run_history: { authority: auth_name }
237
+ }
238
+ end
239
+ it 'returns where clause with dt_stamp range and authname limited to the specified tables' do
240
+ expect(described_class.where_clause_for_last_12_months(auth_name: auth_name, auth_table: auth_table, dt_table: dt_table)).to eq expected_result
241
+ end
242
+ end
243
+ end
244
+ end
245
+ end
246
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+
4
+ RSpec.describe QaServer::TimeService do
5
+ let(:timezone_name) { 'Eastern Time (US & Canada)' }
6
+ before do
7
+ allow(described_class).to receive_message_chain(:config, :preferred_time_zone_name).and_return(timezone_name) # rubocop:disable RSpec/MessageChain
8
+ allow(Time).to receive(:now).and_return(DateTime.parse('2019-12-11 05:00:00 -0500').in_time_zone(timezone_name))
9
+ end
10
+
11
+ describe '.current_time' do
12
+ it 'returns the time in the preferred time zone' do
13
+ expect(described_class.current_time.zone).to eq 'EST'
14
+ end
15
+
16
+ it 'returns the time current time' do
17
+ expect(described_class.current_time).to eq DateTime.parse('2019-12-11 05:00:00 -0500').in_time_zone(timezone_name)
18
+ end
19
+ end
20
+
21
+ describe '.current_time_s' do
22
+ before do
23
+ allow(Time).to receive(:now).and_return(DateTime.parse('1970-01-01 00:00:01 -0000').in_time_zone(timezone_name))
24
+ end
25
+
26
+ it 'number of seconds since epoch for current time' do
27
+ expect(described_class.current_time_s).to eq 1
28
+ end
29
+ end
30
+
31
+ describe '.pretty_time' do
32
+ before do
33
+ allow(Time).to receive(:now).and_return(DateTime.parse('2019-12-11 05:00:00 -0500').in_time_zone(timezone_name))
34
+ end
35
+
36
+ it 'converts dt_stamp to string formatted with date and time' do
37
+ expect(described_class.pretty_time(described_class.current_time)).to eq '12/11/2019 - 05:00 AM'
38
+ end
39
+ end
40
+
41
+ describe '.pretty_date' do
42
+ before do
43
+ allow(Time).to receive(:now).and_return(DateTime.parse('2019-12-11 05:00:00 -0500').in_time_zone(timezone_name))
44
+ end
45
+
46
+ it 'converts dt_stamp to string formatted with date' do
47
+ expect(described_class.pretty_date(described_class.current_time)).to eq '12/11/2019'
48
+ end
49
+ end
50
+ 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: 5.5.1
4
+ version: 6.0.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-01-29 00:00:00.000000000 Z
11
+ date: 2020-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -338,13 +338,14 @@ files:
338
338
  - app/assets/stylesheets/qa_server/_qa_server.scss
339
339
  - app/assets/stylesheets/qa_server/_styles.scss
340
340
  - app/assets/stylesheets/qa_server/_usage.scss
341
+ - app/controllers/concerns/qa_server/authority_validation_behavior.rb
341
342
  - app/controllers/qa_server/authority_list_controller.rb
342
- - app/controllers/qa_server/authority_validation_controller.rb
343
343
  - app/controllers/qa_server/check_status_controller.rb
344
344
  - app/controllers/qa_server/fetch_controller.rb
345
345
  - app/controllers/qa_server/homepage_controller.rb
346
346
  - app/controllers/qa_server/monitor_status_controller.rb
347
347
  - app/controllers/qa_server/usage_controller.rb
348
+ - app/jobs/qa_server/monitor_tests_job.rb
348
349
  - app/loggers/qa_server/scenario_logger.rb
349
350
  - app/models/concerns/qa_server/performance_history_data_keys.rb
350
351
  - app/models/qa_server/authority_scenario.rb
@@ -376,10 +377,14 @@ files:
376
377
  - app/services/qa_server/authority_loader_service.rb
377
378
  - app/services/qa_server/authority_validator_service.rb
378
379
  - app/services/qa_server/database_migrator.rb
380
+ - app/services/qa_server/monitor_cache_service.rb
379
381
  - app/services/qa_server/performance_calculator_service.rb
382
+ - app/services/qa_server/performance_datatable_service.rb
380
383
  - app/services/qa_server/performance_graph_data_service.rb
381
384
  - app/services/qa_server/performance_graphing_service.rb
382
385
  - app/services/qa_server/scenarios_loader_service.rb
386
+ - app/services/qa_server/time_period_service.rb
387
+ - app/services/qa_server/time_service.rb
383
388
  - app/validators/qa_server/scenario_validator.rb
384
389
  - app/validators/qa_server/search_scenario_validator.rb
385
390
  - app/validators/qa_server/term_scenario_validator.rb
@@ -475,6 +480,9 @@ files:
475
480
  - spec/lib/configuration_spec.rb
476
481
  - spec/lib/qa_server_spec.rb
477
482
  - spec/rails_helper.rb
483
+ - spec/services/qa_server/monitor_cache_service_spec.rb
484
+ - spec/services/qa_server/time_period_service_spec.rb
485
+ - spec/services/qa_server/time_service_spec.rb
478
486
  - spec/spec_helper.rb
479
487
  - spec/test_app_templates/Gemfile.extra
480
488
  - spec/test_app_templates/lib/generators/test_app_generator.rb
@@ -508,6 +516,9 @@ test_files:
508
516
  - spec/lib/configuration_spec.rb
509
517
  - spec/lib/qa_server_spec.rb
510
518
  - spec/rails_helper.rb
519
+ - spec/services/qa_server/monitor_cache_service_spec.rb
520
+ - spec/services/qa_server/time_period_service_spec.rb
521
+ - spec/services/qa_server/time_service_spec.rb
511
522
  - spec/spec_helper.rb
512
523
  - spec/test_app_templates/Gemfile.extra
513
524
  - spec/test_app_templates/lib/generators/test_app_generator.rb