nucleus 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/CHANGELOG.md +18 -4
  4. data/README.md +28 -40
  5. data/Rakefile +137 -137
  6. data/config/nucleus_config.rb +0 -4
  7. data/lib/nucleus/adapter_resolver.rb +115 -115
  8. data/lib/nucleus/adapters/buildpack_translator.rb +79 -79
  9. data/lib/nucleus/adapters/v1/cloud_control/application.rb +108 -108
  10. data/lib/nucleus/adapters/v1/cloud_control/authentication.rb +27 -27
  11. data/lib/nucleus/adapters/v1/cloud_control/cloud_control.rb +153 -153
  12. data/lib/nucleus/adapters/v1/cloud_control/domains.rb +68 -68
  13. data/lib/nucleus/adapters/v1/cloud_control/logs.rb +103 -103
  14. data/lib/nucleus/adapters/v1/cloud_control/vars.rb +88 -88
  15. data/lib/nucleus/adapters/v1/cloud_foundry_v2/domains.rb +149 -149
  16. data/lib/nucleus/adapters/v1/cloud_foundry_v2/logs.rb +303 -303
  17. data/lib/nucleus/adapters/v1/cloud_foundry_v2/services.rb +286 -286
  18. data/lib/nucleus/adapters/v1/heroku/heroku.rb +2 -2
  19. data/lib/nucleus/adapters/v1/heroku/logs.rb +108 -108
  20. data/lib/nucleus/core/adapter_authentication_inductor.rb +0 -2
  21. data/lib/nucleus/core/adapter_extensions/auth/http_basic_auth_client.rb +37 -37
  22. data/lib/nucleus/core/adapter_extensions/http_client.rb +177 -177
  23. data/lib/nucleus/core/common/files/archive_extractor.rb +112 -112
  24. data/lib/nucleus/core/common/files/archiver.rb +91 -91
  25. data/lib/nucleus/core/common/logging/request_log_formatter.rb +48 -48
  26. data/lib/nucleus/core/error_messages.rb +127 -127
  27. data/lib/nucleus/core/models/abstract_model.rb +29 -29
  28. data/lib/nucleus/scripts/load_dependencies.rb +0 -1
  29. data/lib/nucleus/scripts/setup_config.rb +28 -28
  30. data/lib/nucleus/version.rb +3 -3
  31. data/nucleus.gemspec +10 -12
  32. data/spec/factories/models.rb +63 -61
  33. data/spec/integration/api/auth_spec.rb +58 -58
  34. data/spec/test_suites.rake +31 -31
  35. data/spec/unit/common/helpers/auth_helper_spec.rb +73 -73
  36. data/spec/unit/common/oauth2_auth_client_spec.rb +1 -1
  37. data/tasks/compatibility.rake +113 -113
  38. data/tasks/evaluation.rake +162 -162
  39. metadata +16 -30
@@ -1,162 +1,162 @@
1
- require 'rspec/core/rake_task'
2
- require 'oj'
3
-
4
- namespace :evaluation do
5
- namespace :requests do
6
- namespace :count do
7
- desc 'Load the data that will be used in the request evaluation tasks'
8
- task load: :environment do
9
- # TODO: choose API version
10
- api_version = 'v1'
11
-
12
- adapter_dao = Nucleus::API::DB::AdapterDao.instance(api_version)
13
- endpoint_dao = Nucleus::API::DB::EndpointDao.instance(api_version)
14
- provider_dao = Nucleus::API::DB::ProviderDao.instance(api_version)
15
- vendor_dao = Nucleus::API::DB::VendorDao.instance(api_version)
16
- @vendor_results = {}
17
-
18
- adapter_dao.all.each do |adapter_index_entry|
19
- vendor_name = vendor_dao.get(provider_dao.get(endpoint_dao.get(adapter_index_entry.id).provider).vendor).name
20
- # from camel to sneak case
21
- adapter_file_name = vendor_name.gsub(/\s/, '_').gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
22
- .gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase
23
- next if @vendor_results.key?(vendor_name)
24
- adaper_results = {}
25
-
26
- method_recordings_dir = File.join('spec', 'adapter', 'recordings', api_version, adapter_file_name,
27
- 'vcr_cassettes', 'with_valid_credentials', 'is_compliant_and')
28
- Find.find(method_recordings_dir) do |file|
29
- next if File.directory?(file) || File.basename(file) == '.DS_Store'
30
- test = Pathname.new(file).relative_path_from(Pathname.new(method_recordings_dir)).to_s
31
- # Load contents with the serializer, oj
32
- cassette = ::Oj.load(File.read(file))
33
- adaper_results[test] = cassette['http_interactions'].length
34
- end
35
- @vendor_results[vendor_name] = adaper_results
36
- end
37
-
38
- @all_tests = @vendor_results.flat_map { |_name, tests| tests.keys }.uniq
39
- end
40
-
41
- task markdown: :load do
42
- # table header
43
- puts "Test / Vendor|#{@vendor_results.keys.join('|')}"
44
-
45
- # column styles
46
- alignment = ':--'
47
- @vendor_results.length.times { |_time| alignment << '|:-:' }
48
- puts alignment
49
-
50
- lines = []
51
- @all_tests.sort.each_with_index do |test_name, line|
52
- @vendor_results.each do |_vendor, results|
53
- lines[line] = "#{test_name}" unless lines[line]
54
- lines[line] << "|#{results[test_name]}"
55
- end
56
- end
57
-
58
- lines.each do |line|
59
- puts line
60
- end
61
-
62
- # table header
63
- puts '|' * @vendor_results.length
64
- puts "Test / Vendor|#{@vendor_results.keys.join('|')}"
65
- puts '|' * @vendor_results.length
66
- puts "Tested methods|#{@vendor_results.collect { |_name, tests| tests.length }.join('|')}"
67
- puts "Total vendor API requests|#{@vendor_results.collect do |_name, tests|
68
- tests.map { |_key, value| value }.sum
69
- end.join('|')}"
70
- puts "Avg. vendor API requests per tested method|#{@vendor_results.collect do |_name, tests|
71
- ((tests.map { |_key, value| value }.sum) / tests.length.to_f).round(2)
72
- end.join('|')}"
73
- end
74
-
75
- task :latex, [:save_to] => :load do |_t, args|
76
- tests_with_wait = %w(app-actions/lifecycle/restart/succeeds
77
- app-actions/lifecycle/start/succeeds_for_app_all_if_currently_stopped
78
- app-actions/lifecycle/start/succeeds_for_app_min_if_currently_stopped
79
- app-actions/lifecycle/stop/succeeds_for_app_all_if_currently_running
80
- app-actions/lifecycle/stop/succeeds_for_app_min_if_currently_running
81
- app-data/deploy/succeeds/and_app_with
82
- app-data/rebuild/changes_the_release_version_property
83
- app/web access/for_app_with_min_properties)
84
- ignore_tests_with_wait = 0
85
- ignore_req_with_wait = {}
86
- @vendor_results.each { |vendor, _| ignore_req_with_wait[vendor] = 0 }
87
-
88
- table = []
89
- table << '\\scriptsize'
90
- table << "\\begin{longtable}{|L{12cm}|#{'c|' * @vendor_results.length}}"
91
- next_line = ' \\multicolumn{1}{l}{\\Large{\\textbf{recorded test cassette}}}'
92
- @vendor_results.keys.each do |vendor|
93
- next_line += " & \\multicolumn{1}{l}{\\turn{60}{#{vendor}}}"
94
- end
95
- next_line += ' \\\\\\hline'
96
- table << next_line
97
- table << ' \\endhead'
98
- table << ' \\rowcolor{white}'
99
- table << ' \\caption{Requests per method test case for all vendors}'\
100
- '\\label{table:evaluation_request_count}%'
101
- table << ' \\endlastfoot'
102
-
103
- lines = []
104
- @all_tests.sort.each_with_index do |t_name, line|
105
- @vendor_results.each do |v, results|
106
- unless lines[line]
107
- lines[line] = "#{t_name}"
108
- if tests_with_wait.any? { |name| t_name.start_with?(name) }
109
- ignore_tests_with_wait += 1
110
- lines[line] = "\\rowcolor{failedtablebg}#{lines[line]}"
111
- end
112
- end
113
- ignore_req_with_wait[v] += results[t_name].to_i if tests_with_wait.any? { |name| t_name.start_with?(name) }
114
- lines[line] << " & #{results[t_name]}"
115
- end
116
- end
117
-
118
- # format and print all lines
119
- lines.each_with_index do |line, index|
120
- if index != lines.length - 1
121
- table << " #{line.gsub(/_/, '\_')} \\\\\\hline"
122
- else
123
- # special treatment for the last line
124
- table << " #{line.gsub(/_/, '\_')} \\\\\\hhline{|=|#{'=|' * @vendor_results.length}}"
125
- end
126
- end
127
-
128
- # print general statistics
129
- table << " Tested methods & #{@vendor_results.collect { |_n, tests| tests.length }.join(' & ')} \\\\\\hline"
130
- table << " Total vendor API requests & #{@vendor_results.collect do |_name, tests|
131
- tests.map { |_key, value| value }.sum
132
- end.join(' & ')} \\\\\\hline"
133
- table << " Avg. vendor API requests per tested method & #{@vendor_results.collect do |_name, tests|
134
- ((tests.map { |_key, value| value }.sum) / tests.length.to_f).round(2)
135
- end.join(' & ')} \\\\\\hhline{|=|#{'=|' * @vendor_results.length}}"
136
-
137
- # sanitize stats, exclude methods with rspec wait repetitions
138
- table << " Tested methods without repeated requests & #{@vendor_results.collect do |_n, tests|
139
- tests.length - ignore_tests_with_wait
140
- end.join(' & ')} \\\\\\hline"
141
-
142
- table << " Total vendor API requests without repeated requests & #{@vendor_results.collect do |name, tests|
143
- tests.map { |_key, value| value }.sum - ignore_req_with_wait[name]
144
- end.join(' & ')} \\\\\\hline"
145
- table << ' Avg. vendor API requests per tested method without repeated requests & '\
146
- "#{@vendor_results.collect do |name, tests|
147
- ((tests.map { |_key, value| value }.sum - ignore_req_with_wait[name]) /
148
- (tests.length - ignore_tests_with_wait).to_f).round(2)
149
- end.join(' & ')} \\\\\\hline"
150
-
151
- table << '\\end{longtable}'
152
- table << '\\normalsize'
153
-
154
- # print lines
155
- table.each { |line| puts line }
156
-
157
- # and save to file if requested
158
- File.open(args.save_to, 'w') { |file| file.write table.join("\n") } if args.save_to
159
- end
160
- end
161
- end
162
- end
1
+ require 'rspec/core/rake_task'
2
+ require 'oj'
3
+
4
+ namespace :evaluation do
5
+ namespace :requests do
6
+ namespace :count do
7
+ desc 'Load the data that will be used in the request evaluation tasks'
8
+ task load: :environment do
9
+ # TODO: choose API version
10
+ api_version = 'v1'
11
+
12
+ adapter_dao = Nucleus::API::DB::AdapterDao.instance(api_version)
13
+ endpoint_dao = Nucleus::API::DB::EndpointDao.instance(api_version)
14
+ provider_dao = Nucleus::API::DB::ProviderDao.instance(api_version)
15
+ vendor_dao = Nucleus::API::DB::VendorDao.instance(api_version)
16
+ @vendor_results = {}
17
+
18
+ adapter_dao.all.each do |adapter_index_entry|
19
+ vendor_name = vendor_dao.get(provider_dao.get(endpoint_dao.get(adapter_index_entry.id).provider).vendor).name
20
+ # from camel to sneak case
21
+ adapter_file_name = vendor_name.gsub(/\s/, '_').gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
22
+ .gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase
23
+ next if @vendor_results.key?(vendor_name)
24
+ adaper_results = {}
25
+
26
+ method_recordings_dir = File.join('spec', 'adapter', 'recordings', api_version, adapter_file_name,
27
+ 'vcr_cassettes', 'with_valid_credentials', 'is_compliant_and')
28
+ Find.find(method_recordings_dir) do |file|
29
+ next if File.directory?(file) || File.basename(file) == '.DS_Store'
30
+ test = Pathname.new(file).relative_path_from(Pathname.new(method_recordings_dir)).to_s
31
+ # Load contents with the serializer, oj
32
+ cassette = ::Oj.load(File.read(file))
33
+ adaper_results[test] = cassette['http_interactions'].length
34
+ end
35
+ @vendor_results[vendor_name] = adaper_results
36
+ end
37
+
38
+ @all_tests = @vendor_results.flat_map { |_name, tests| tests.keys }.uniq
39
+ end
40
+
41
+ task markdown: :load do
42
+ # table header
43
+ puts "Test / Vendor|#{@vendor_results.keys.join('|')}"
44
+
45
+ # column styles
46
+ alignment = ':--'
47
+ @vendor_results.length.times { |_time| alignment << '|:-:' }
48
+ puts alignment
49
+
50
+ lines = []
51
+ @all_tests.sort.each_with_index do |test_name, line|
52
+ @vendor_results.each do |_vendor, results|
53
+ lines[line] = test_name.to_s unless lines[line]
54
+ lines[line] << "|#{results[test_name]}"
55
+ end
56
+ end
57
+
58
+ lines.each do |line|
59
+ puts line
60
+ end
61
+
62
+ # table header
63
+ puts '|' * @vendor_results.length
64
+ puts "Test / Vendor|#{@vendor_results.keys.join('|')}"
65
+ puts '|' * @vendor_results.length
66
+ puts "Tested methods|#{@vendor_results.collect { |_name, tests| tests.length }.join('|')}"
67
+ puts "Total vendor API requests|#{@vendor_results.collect do |_name, tests|
68
+ tests.map { |_key, value| value }.sum
69
+ end.join('|')}"
70
+ puts "Avg. vendor API requests per tested method|#{@vendor_results.collect do |_name, tests|
71
+ (tests.map { |_key, value| value }.sum / tests.length.to_f).round(2)
72
+ end.join('|')}"
73
+ end
74
+
75
+ task :latex, [:save_to] => :load do |_t, args|
76
+ tests_with_wait = %w(app-actions/lifecycle/restart/succeeds
77
+ app-actions/lifecycle/start/succeeds_for_app_all_if_currently_stopped
78
+ app-actions/lifecycle/start/succeeds_for_app_min_if_currently_stopped
79
+ app-actions/lifecycle/stop/succeeds_for_app_all_if_currently_running
80
+ app-actions/lifecycle/stop/succeeds_for_app_min_if_currently_running
81
+ app-data/deploy/succeeds/and_app_with
82
+ app-data/rebuild/changes_the_release_version_property
83
+ app/web access/for_app_with_min_properties)
84
+ ignore_tests_with_wait = 0
85
+ ignore_req_with_wait = {}
86
+ @vendor_results.each { |vendor, _| ignore_req_with_wait[vendor] = 0 }
87
+
88
+ table = []
89
+ table << '\\scriptsize'
90
+ table << "\\begin{longtable}{|L{12cm}|#{'c|' * @vendor_results.length}}"
91
+ next_line = ' \\multicolumn{1}{l}{\\Large{\\textbf{recorded test cassette}}}'
92
+ @vendor_results.keys.each do |vendor|
93
+ next_line += " & \\multicolumn{1}{l}{\\turn{60}{#{vendor}}}"
94
+ end
95
+ next_line += ' \\\\\\hline'
96
+ table << next_line
97
+ table << ' \\endhead'
98
+ table << ' \\rowcolor{white}'
99
+ table << ' \\caption{Requests per method test case for all vendors}'\
100
+ '\\label{table:evaluation_request_count}%'
101
+ table << ' \\endlastfoot'
102
+
103
+ lines = []
104
+ @all_tests.sort.each_with_index do |t_name, line|
105
+ @vendor_results.each do |v, results|
106
+ unless lines[line]
107
+ lines[line] = t_name.to_s
108
+ if tests_with_wait.any? { |name| t_name.start_with?(name) }
109
+ ignore_tests_with_wait += 1
110
+ lines[line] = "\\rowcolor{failedtablebg}#{lines[line]}"
111
+ end
112
+ end
113
+ ignore_req_with_wait[v] += results[t_name].to_i if tests_with_wait.any? { |name| t_name.start_with?(name) }
114
+ lines[line] << " & #{results[t_name]}"
115
+ end
116
+ end
117
+
118
+ # format and print all lines
119
+ lines.each_with_index do |line, index|
120
+ table << if index != lines.length - 1
121
+ " #{line.gsub(/_/, '\_')} \\\\\\hline"
122
+ else
123
+ # special treatment for the last line
124
+ " #{line.gsub(/_/, '\_')} \\\\\\hhline{|=|#{'=|' * @vendor_results.length}}"
125
+ end
126
+ end
127
+
128
+ # print general statistics
129
+ table << " Tested methods & #{@vendor_results.collect { |_n, tests| tests.length }.join(' & ')} \\\\\\hline"
130
+ table << " Total vendor API requests & #{@vendor_results.collect do |_name, tests|
131
+ tests.map { |_key, value| value }.sum
132
+ end.join(' & ')} \\\\\\hline"
133
+ table << " Avg. vendor API requests per tested method & #{@vendor_results.collect do |_name, tests|
134
+ (tests.map { |_key, value| value }.sum / tests.length.to_f).round(2)
135
+ end.join(' & ')} \\\\\\hhline{|=|#{'=|' * @vendor_results.length}}"
136
+
137
+ # sanitize stats, exclude methods with rspec wait repetitions
138
+ table << " Tested methods without repeated requests & #{@vendor_results.collect do |_n, tests|
139
+ tests.length - ignore_tests_with_wait
140
+ end.join(' & ')} \\\\\\hline"
141
+
142
+ table << " Total vendor API requests without repeated requests & #{@vendor_results.collect do |name, tests|
143
+ tests.map { |_key, value| value }.sum - ignore_req_with_wait[name]
144
+ end.join(' & ')} \\\\\\hline"
145
+ table << ' Avg. vendor API requests per tested method without repeated requests & '\
146
+ "#{@vendor_results.collect do |name, tests|
147
+ ((tests.map { |_key, value| value }.sum - ignore_req_with_wait[name]) /
148
+ (tests.length - ignore_tests_with_wait).to_f).round(2)
149
+ end.join(' & ')} \\\\\\hline"
150
+
151
+ table << '\\end{longtable}'
152
+ table << '\\normalsize'
153
+
154
+ # print lines
155
+ table.each { |line| puts line }
156
+
157
+ # and save to file if requested
158
+ File.open(args.save_to, 'w') { |file| file.write table.join("\n") } if args.save_to
159
+ end
160
+ end
161
+ end
162
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nucleus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Kolb
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-10-28 00:00:00.000000000 Z
12
+ date: 2016-01-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: configatron
@@ -25,20 +25,6 @@ dependencies:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '4.5'
28
- - !ruby/object:Gem::Dependency
29
- name: daybreak
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - "~>"
33
- - !ruby/object:Gem::Version
34
- version: '0.3'
35
- type: :runtime
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - "~>"
40
- - !ruby/object:Gem::Version
41
- version: '0.3'
42
28
  - !ruby/object:Gem::Dependency
43
29
  name: em-http-request
44
30
  requirement: !ruby/object:Gem::Requirement
@@ -101,21 +87,21 @@ dependencies:
101
87
  requirements:
102
88
  - - "~>"
103
89
  - !ruby/object:Gem::Version
104
- version: '0.12'
90
+ version: 0.13.0
105
91
  type: :runtime
106
92
  prerelease: false
107
93
  version_requirements: !ruby/object:Gem::Requirement
108
94
  requirements:
109
95
  - - "~>"
110
96
  - !ruby/object:Gem::Version
111
- version: '0.12'
97
+ version: 0.13.0
112
98
  - !ruby/object:Gem::Dependency
113
99
  name: grape-entity
114
100
  requirement: !ruby/object:Gem::Requirement
115
101
  requirements:
116
102
  - - "~>"
117
103
  - !ruby/object:Gem::Version
118
- version: '0.4'
104
+ version: 0.4.8
119
105
  - - ">="
120
106
  - !ruby/object:Gem::Version
121
107
  version: 0.4.5
@@ -125,7 +111,7 @@ dependencies:
125
111
  requirements:
126
112
  - - "~>"
127
113
  - !ruby/object:Gem::Version
128
- version: '0.4'
114
+ version: 0.4.8
129
115
  - - ">="
130
116
  - !ruby/object:Gem::Version
131
117
  version: 0.4.5
@@ -135,7 +121,7 @@ dependencies:
135
121
  requirements:
136
122
  - - "~>"
137
123
  - !ruby/object:Gem::Version
138
- version: '0.10'
124
+ version: 0.10.2
139
125
  - - ">="
140
126
  - !ruby/object:Gem::Version
141
127
  version: 0.10.1
@@ -145,7 +131,7 @@ dependencies:
145
131
  requirements:
146
132
  - - "~>"
147
133
  - !ruby/object:Gem::Version
148
- version: '0.10'
134
+ version: 0.10.2
149
135
  - - ">="
150
136
  - !ruby/object:Gem::Version
151
137
  version: 0.10.1
@@ -197,14 +183,14 @@ dependencies:
197
183
  requirements:
198
184
  - - "~>"
199
185
  - !ruby/object:Gem::Version
200
- version: '2.4'
186
+ version: '2.6'
201
187
  type: :runtime
202
188
  prerelease: false
203
189
  version_requirements: !ruby/object:Gem::Requirement
204
190
  requirements:
205
191
  - - "~>"
206
192
  - !ruby/object:Gem::Version
207
- version: '2.4'
193
+ version: '2.6'
208
194
  - !ruby/object:Gem::Dependency
209
195
  name: moneta
210
196
  requirement: !ruby/object:Gem::Requirement
@@ -239,14 +225,14 @@ dependencies:
239
225
  requirements:
240
226
  - - "~>"
241
227
  - !ruby/object:Gem::Version
242
- version: '2.12'
228
+ version: '2.14'
243
229
  type: :runtime
244
230
  prerelease: false
245
231
  version_requirements: !ruby/object:Gem::Requirement
246
232
  requirements:
247
233
  - - "~>"
248
234
  - !ruby/object:Gem::Version
249
- version: '2.12'
235
+ version: '2.14'
250
236
  - !ruby/object:Gem::Dependency
251
237
  name: protobuf
252
238
  requirement: !ruby/object:Gem::Requirement
@@ -497,28 +483,28 @@ dependencies:
497
483
  requirements:
498
484
  - - "~>"
499
485
  - !ruby/object:Gem::Version
500
- version: '0.34'
486
+ version: 0.36.0
501
487
  type: :development
502
488
  prerelease: false
503
489
  version_requirements: !ruby/object:Gem::Requirement
504
490
  requirements:
505
491
  - - "~>"
506
492
  - !ruby/object:Gem::Version
507
- version: '0.34'
493
+ version: 0.36.0
508
494
  - !ruby/object:Gem::Dependency
509
495
  name: vcr
510
496
  requirement: !ruby/object:Gem::Requirement
511
497
  requirements:
512
498
  - - "~>"
513
499
  - !ruby/object:Gem::Version
514
- version: '2.9'
500
+ version: '3.0'
515
501
  type: :development
516
502
  prerelease: false
517
503
  version_requirements: !ruby/object:Gem::Requirement
518
504
  requirements:
519
505
  - - "~>"
520
506
  - !ruby/object:Gem::Version
521
- version: '2.9'
507
+ version: '3.0'
522
508
  - !ruby/object:Gem::Dependency
523
509
  name: webmock
524
510
  requirement: !ruby/object:Gem::Requirement