beaker 4.38.1 → 4.39.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +12 -0
  3. data/.rubocop.yml +62 -0
  4. data/.rubocop_todo.yml +215 -0
  5. data/CHANGELOG.md +72 -33
  6. data/Gemfile +8 -1
  7. data/HISTORY.md +103 -0
  8. data/Rakefile +10 -9
  9. data/acceptance/fixtures/module/Gemfile +1 -1
  10. data/acceptance/fixtures/module/Rakefile +2 -2
  11. data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -11
  12. data/acceptance/fixtures/module/spec/classes/init_spec.rb +1 -1
  13. data/acceptance/lib/helpers/test_helper.rb +3 -3
  14. data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +6 -6
  15. data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +6 -6
  16. data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +6 -12
  17. data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +4 -4
  18. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +1 -1
  19. data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +7 -7
  20. data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +4 -4
  21. data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +4 -4
  22. data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +8 -11
  23. data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +2 -2
  24. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +6 -11
  25. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +5 -9
  26. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +2 -2
  27. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +1 -1
  28. data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +4 -4
  29. data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +1 -1
  30. data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +1 -1
  31. data/acceptance/tests/base/dsl/structure_test.rb +4 -10
  32. data/acceptance/tests/base/host/file_test.rb +7 -7
  33. data/acceptance/tests/base/host/group_test.rb +2 -2
  34. data/acceptance/tests/base/host/host_test.rb +5 -5
  35. data/acceptance/tests/base/host/packages.rb +26 -28
  36. data/acceptance/tests/base/host/packages_unix.rb +4 -4
  37. data/acceptance/tests/base/host/user_test.rb +2 -2
  38. data/acceptance/tests/install/from_file.rb +2 -2
  39. data/beaker.gemspec +9 -9
  40. data/docs/concepts/style_guide.md +1 -1
  41. data/docs/how_to/debug_beaker_tests.md +1 -1
  42. data/docs/how_to/test_arbitrary_beaker_versions.md +2 -2
  43. data/lib/beaker/cli.rb +6 -8
  44. data/lib/beaker/command.rb +3 -3
  45. data/lib/beaker/command_factory.rb +2 -2
  46. data/lib/beaker/dsl/assertions.rb +1 -1
  47. data/lib/beaker/dsl/helpers/hocon_helpers.rb +2 -2
  48. data/lib/beaker/dsl/helpers/host_helpers.rb +11 -11
  49. data/lib/beaker/dsl/helpers/web_helpers.rb +3 -3
  50. data/lib/beaker/dsl/outcomes.rb +4 -4
  51. data/lib/beaker/dsl/roles.rb +2 -2
  52. data/lib/beaker/dsl/structure.rb +10 -10
  53. data/lib/beaker/host/aix/group.rb +3 -3
  54. data/lib/beaker/host/aix/user.rb +3 -3
  55. data/lib/beaker/host/cisco.rb +11 -11
  56. data/lib/beaker/host/eos.rb +2 -2
  57. data/lib/beaker/host/mac/exec.rb +1 -1
  58. data/lib/beaker/host/mac/group.rb +7 -7
  59. data/lib/beaker/host/mac/pkg.rb +6 -6
  60. data/lib/beaker/host/mac/user.rb +6 -6
  61. data/lib/beaker/host/pswindows/exec.rb +8 -8
  62. data/lib/beaker/host/pswindows/file.rb +1 -1
  63. data/lib/beaker/host/pswindows/group.rb +3 -3
  64. data/lib/beaker/host/pswindows/pkg.rb +6 -6
  65. data/lib/beaker/host/pswindows/user.rb +2 -2
  66. data/lib/beaker/host/unix/exec.rb +6 -6
  67. data/lib/beaker/host/unix/file.rb +3 -4
  68. data/lib/beaker/host/unix/group.rb +3 -3
  69. data/lib/beaker/host/unix/pkg.rb +17 -17
  70. data/lib/beaker/host/unix/user.rb +3 -3
  71. data/lib/beaker/host/unix.rb +10 -9
  72. data/lib/beaker/host/windows/exec.rb +3 -3
  73. data/lib/beaker/host/windows/file.rb +2 -2
  74. data/lib/beaker/host/windows/group.rb +3 -3
  75. data/lib/beaker/host/windows/pkg.rb +6 -6
  76. data/lib/beaker/host/windows/user.rb +2 -2
  77. data/lib/beaker/host/windows.rb +2 -2
  78. data/lib/beaker/host.rb +7 -7
  79. data/lib/beaker/host_prebuilt_steps.rb +38 -45
  80. data/lib/beaker/hypervisor.rb +4 -4
  81. data/lib/beaker/local_connection.rb +3 -3
  82. data/lib/beaker/logger.rb +5 -11
  83. data/lib/beaker/logger_junit.rb +2 -2
  84. data/lib/beaker/network_manager.rb +2 -2
  85. data/lib/beaker/options/command_line_parser.rb +1 -1
  86. data/lib/beaker/options/hosts_file_parser.rb +21 -4
  87. data/lib/beaker/options/options_file_parser.rb +1 -1
  88. data/lib/beaker/options/options_hash.rb +1 -3
  89. data/lib/beaker/options/parser.rb +6 -6
  90. data/lib/beaker/options/presets.rb +2 -2
  91. data/lib/beaker/options/validator.rb +2 -2
  92. data/lib/beaker/perf.rb +9 -9
  93. data/lib/beaker/platform.rb +1 -1
  94. data/lib/beaker/shared/host_manager.rb +4 -5
  95. data/lib/beaker/shared/repetition.rb +4 -4
  96. data/lib/beaker/shared/semvar.rb +2 -2
  97. data/lib/beaker/shared/timed.rb +2 -2
  98. data/lib/beaker/ssh_connection.rb +9 -9
  99. data/lib/beaker/subcommand.rb +6 -6
  100. data/lib/beaker/tasks/quick_start.rb +2 -2
  101. data/lib/beaker/tasks/rake_task.rb +3 -3
  102. data/lib/beaker/test_suite.rb +2 -2
  103. data/lib/beaker/test_suite_result.rb +8 -11
  104. data/lib/beaker/version.rb +1 -1
  105. data/spec/beaker/cli_spec.rb +46 -43
  106. data/spec/beaker/command_spec.rb +17 -7
  107. data/spec/beaker/dsl/assertions_spec.rb +2 -11
  108. data/spec/beaker/dsl/helpers/host_helpers_spec.rb +7 -7
  109. data/spec/beaker/dsl/helpers/web_helpers_spec.rb +2 -2
  110. data/spec/beaker/dsl/outcomes_spec.rb +1 -0
  111. data/spec/beaker/dsl/roles_spec.rb +48 -5
  112. data/spec/beaker/dsl/structure_spec.rb +22 -15
  113. data/spec/beaker/dsl/test_tagging_spec.rb +16 -16
  114. data/spec/beaker/dsl/wrappers_spec.rb +7 -7
  115. data/spec/beaker/host/cisco_spec.rb +8 -8
  116. data/spec/beaker/host/freebsd/exec_spec.rb +3 -3
  117. data/spec/beaker/host/freebsd/pkg_spec.rb +6 -3
  118. data/spec/beaker/host/mac/exec_spec.rb +3 -3
  119. data/spec/beaker/host/mac_spec.rb +6 -6
  120. data/spec/beaker/host/pswindows/exec_spec.rb +8 -5
  121. data/spec/beaker/host/pswindows/file_spec.rb +6 -3
  122. data/spec/beaker/host/pswindows_spec.rb +1 -1
  123. data/spec/beaker/host/unix/exec_spec.rb +24 -24
  124. data/spec/beaker/host/unix/file_spec.rb +18 -17
  125. data/spec/beaker/host/unix/pkg_spec.rb +26 -22
  126. data/spec/beaker/host/unix_spec.rb +8 -8
  127. data/spec/beaker/host/windows/exec_spec.rb +4 -4
  128. data/spec/beaker/host/windows/file_spec.rb +4 -4
  129. data/spec/beaker/host/windows/group_spec.rb +12 -12
  130. data/spec/beaker/host/windows/pkg_spec.rb +5 -5
  131. data/spec/beaker/host_prebuilt_steps_spec.rb +26 -20
  132. data/spec/beaker/host_spec.rb +72 -63
  133. data/spec/beaker/hypervisor/hypervisor_spec.rb +14 -14
  134. data/spec/beaker/localhost_connection_spec.rb +6 -4
  135. data/spec/beaker/logger_junit_spec.rb +16 -17
  136. data/spec/beaker/logger_spec.rb +54 -52
  137. data/spec/beaker/network_manager_spec.rb +5 -5
  138. data/spec/beaker/options/command_line_parser_spec.rb +2 -2
  139. data/spec/beaker/options/data/hosts_preserved.yml +395 -0
  140. data/spec/beaker/options/hosts_file_parser_spec.rb +9 -2
  141. data/spec/beaker/options/options_file_parser_spec.rb +1 -1
  142. data/spec/beaker/options/options_hash_spec.rb +4 -4
  143. data/spec/beaker/options/parser_spec.rb +23 -23
  144. data/spec/beaker/options/presets_spec.rb +2 -2
  145. data/spec/beaker/options/subcommand_options_parser_spec.rb +4 -3
  146. data/spec/beaker/options/validator_spec.rb +18 -18
  147. data/spec/beaker/perf_spec.rb +29 -28
  148. data/spec/beaker/platform_spec.rb +3 -2
  149. data/spec/beaker/shared/error_handler_spec.rb +1 -1
  150. data/spec/beaker/shared/fog_credentials_spec.rb +12 -12
  151. data/spec/beaker/shared/host_manager_spec.rb +7 -7
  152. data/spec/beaker/shared/repetition_spec.rb +9 -9
  153. data/spec/beaker/ssh_connection_spec.rb +14 -12
  154. data/spec/beaker/subcommand/subcommand_util_spec.rb +9 -4
  155. data/spec/beaker/subcommand_spec.rb +30 -28
  156. data/spec/beaker/test_case_spec.rb +11 -15
  157. data/spec/beaker/test_suite_spec.rb +24 -24
  158. data/spec/matchers.rb +1 -1
  159. data/spec/mocks.rb +5 -5
  160. data/spec/spec_helper.rb +0 -3
  161. metadata +59 -59
  162. data/spec/mock_fission.rb +0 -60
  163. data/spec/mock_vsphere.rb +0 -314
  164. data/spec/mock_vsphere_helper.rb +0 -183
metadata CHANGED
@@ -1,71 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.38.1
4
+ version: 4.39.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-21 00:00:00.000000000 Z
11
+ date: 2023-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rspec
14
+ name: fakefs
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.0'
19
+ version: '1.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.0'
26
+ version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rspec-its
28
+ name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: fakefs
42
+ name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.0'
47
+ version: '3.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.0'
54
+ version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rake
56
+ name: rspec-its
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '13.0'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '13.0'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: yard
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -81,33 +81,33 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.9.11
83
83
  - !ruby/object:Gem::Dependency
84
- name: minitest
84
+ name: minitar
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '5.4'
89
+ version: '0.6'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '5.4'
96
+ version: '0.6'
97
97
  - !ruby/object:Gem::Dependency
98
- name: minitar
98
+ name: minitest
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0.6'
103
+ version: '5.4'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0.6'
110
+ version: '5.4'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rexml
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -123,7 +123,7 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: hocon
126
+ name: ed25519
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
@@ -137,33 +137,33 @@ dependencies:
137
137
  - !ruby/object:Gem::Version
138
138
  version: '1.0'
139
139
  - !ruby/object:Gem::Dependency
140
- name: net-ssh
140
+ name: hocon
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ">="
143
+ - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '5.0'
145
+ version: '1.0'
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ">="
150
+ - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '5.0'
152
+ version: '1.0'
153
153
  - !ruby/object:Gem::Dependency
154
- name: ed25519
154
+ name: inifile
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: '1.0'
159
+ version: '3.0'
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: '1.0'
166
+ version: '3.0'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: net-scp
169
169
  requirement: !ruby/object:Gem::Requirement
@@ -173,7 +173,7 @@ dependencies:
173
173
  version: '1.2'
174
174
  - - "<"
175
175
  - !ruby/object:Gem::Version
176
- version: '4.0'
176
+ version: '5.0'
177
177
  type: :runtime
178
178
  prerelease: false
179
179
  version_requirements: !ruby/object:Gem::Requirement
@@ -183,35 +183,35 @@ dependencies:
183
183
  version: '1.2'
184
184
  - - "<"
185
185
  - !ruby/object:Gem::Version
186
- version: '4.0'
186
+ version: '5.0'
187
187
  - !ruby/object:Gem::Dependency
188
- name: inifile
188
+ name: net-ssh
189
189
  requirement: !ruby/object:Gem::Requirement
190
190
  requirements:
191
- - - "~>"
191
+ - - ">="
192
192
  - !ruby/object:Gem::Version
193
- version: '3.0'
193
+ version: '5.0'
194
194
  type: :runtime
195
195
  prerelease: false
196
196
  version_requirements: !ruby/object:Gem::Requirement
197
197
  requirements:
198
- - - "~>"
198
+ - - ">="
199
199
  - !ruby/object:Gem::Version
200
- version: '3.0'
200
+ version: '5.0'
201
201
  - !ruby/object:Gem::Dependency
202
- name: rsync
202
+ name: in-parallel
203
203
  requirement: !ruby/object:Gem::Requirement
204
204
  requirements:
205
205
  - - "~>"
206
206
  - !ruby/object:Gem::Version
207
- version: 1.0.9
207
+ version: '0.1'
208
208
  type: :runtime
209
209
  prerelease: false
210
210
  version_requirements: !ruby/object:Gem::Requirement
211
211
  requirements:
212
212
  - - "~>"
213
213
  - !ruby/object:Gem::Version
214
- version: 1.0.9
214
+ version: '0.1'
215
215
  - !ruby/object:Gem::Dependency
216
216
  name: open_uri_redirections
217
217
  requirement: !ruby/object:Gem::Requirement
@@ -227,19 +227,19 @@ dependencies:
227
227
  - !ruby/object:Gem::Version
228
228
  version: 0.2.1
229
229
  - !ruby/object:Gem::Dependency
230
- name: in-parallel
230
+ name: rsync
231
231
  requirement: !ruby/object:Gem::Requirement
232
232
  requirements:
233
233
  - - "~>"
234
234
  - !ruby/object:Gem::Version
235
- version: '0.1'
235
+ version: 1.0.9
236
236
  type: :runtime
237
237
  prerelease: false
238
238
  version_requirements: !ruby/object:Gem::Requirement
239
239
  requirements:
240
240
  - - "~>"
241
241
  - !ruby/object:Gem::Version
242
- version: '0.1'
242
+ version: 1.0.9
243
243
  - !ruby/object:Gem::Dependency
244
244
  name: thor
245
245
  requirement: !ruby/object:Gem::Requirement
@@ -261,33 +261,33 @@ dependencies:
261
261
  - !ruby/object:Gem::Version
262
262
  version: '2.0'
263
263
  - !ruby/object:Gem::Dependency
264
- name: stringify-hash
264
+ name: beaker-hostgenerator
265
265
  requirement: !ruby/object:Gem::Requirement
266
266
  requirements:
267
- - - "~>"
267
+ - - ">="
268
268
  - !ruby/object:Gem::Version
269
- version: '0.0'
269
+ version: '0'
270
270
  type: :runtime
271
271
  prerelease: false
272
272
  version_requirements: !ruby/object:Gem::Requirement
273
273
  requirements:
274
- - - "~>"
274
+ - - ">="
275
275
  - !ruby/object:Gem::Version
276
- version: '0.0'
276
+ version: '0'
277
277
  - !ruby/object:Gem::Dependency
278
- name: beaker-hostgenerator
278
+ name: stringify-hash
279
279
  requirement: !ruby/object:Gem::Requirement
280
280
  requirements:
281
- - - ">="
281
+ - - "~>"
282
282
  - !ruby/object:Gem::Version
283
- version: '0'
283
+ version: '0.0'
284
284
  type: :runtime
285
285
  prerelease: false
286
286
  version_requirements: !ruby/object:Gem::Requirement
287
287
  requirements:
288
- - - ">="
288
+ - - "~>"
289
289
  - !ruby/object:Gem::Version
290
- version: '0'
290
+ version: '0.0'
291
291
  description: Puppet's accceptance testing harness
292
292
  email:
293
293
  - voxpupuli@groups.io
@@ -301,6 +301,8 @@ files:
301
301
  - ".github/workflows/test.yml"
302
302
  - ".gitignore"
303
303
  - ".rspec"
304
+ - ".rubocop.yml"
305
+ - ".rubocop_todo.yml"
304
306
  - ".simplecov"
305
307
  - CHANGELOG.md
306
308
  - CODEOWNERS
@@ -601,6 +603,7 @@ files:
601
603
  - spec/beaker/options/command_line_parser_spec.rb
602
604
  - spec/beaker/options/data/badyaml.cfg
603
605
  - spec/beaker/options/data/hosts.cfg
606
+ - spec/beaker/options/data/hosts_preserved.yml
604
607
  - spec/beaker/options/data/opts.txt
605
608
  - spec/beaker/options/hosts_file_parser_spec.rb
606
609
  - spec/beaker/options/options_file_parser_spec.rb
@@ -624,9 +627,6 @@ files:
624
627
  - spec/beaker/test_suite_spec.rb
625
628
  - spec/helpers.rb
626
629
  - spec/matchers.rb
627
- - spec/mock_fission.rb
628
- - spec/mock_vsphere.rb
629
- - spec/mock_vsphere_helper.rb
630
630
  - spec/mocks.rb
631
631
  - spec/spec_helper.rb
632
632
  homepage: https://github.com/voxpupuli/beaker
data/spec/mock_fission.rb DELETED
@@ -1,60 +0,0 @@
1
- class Response
2
- attr_accessor :code, :message, :data
3
- def initialize(code = 0, message = '', data = nil)
4
- @code = code
5
- @message = message
6
- @data = data
7
- end
8
- end
9
-
10
- class MockFissionVM
11
- attr_accessor :name
12
- @@snaps = []
13
- def initialize name
14
- @name = name
15
- @running = true
16
- end
17
-
18
- def self.set_snapshots snaps
19
- @@snaps = snaps
20
- end
21
-
22
- def snapshots
23
- Response.new(0, '', @@snaps)
24
- end
25
-
26
- def revert_to_snapshot name
27
- @running = false
28
- end
29
-
30
- def running?
31
- Response.new(0, '', @running)
32
- end
33
-
34
- def start opt
35
- @running = true
36
- end
37
-
38
- def exists?
39
- true
40
- end
41
- end
42
-
43
- class MockFission
44
- @@vms = []
45
- def self.presets hosts
46
- snaps = []
47
- hosts.each do |host|
48
- @@vms << MockFissionVM.new( host.name )
49
- snaps << host[ :snapshot ]
50
- end
51
- MockFissionVM.set_snapshots(snaps)
52
- end
53
-
54
- def self.all
55
- Response.new(0, '', @@vms)
56
- end
57
- def self.new name
58
- MockFissionVM.new(name)
59
- end
60
- end
data/spec/mock_vsphere.rb DELETED
@@ -1,314 +0,0 @@
1
- class MockRbVmomiSnapshot
2
- attr_accessor :name
3
- attr_accessor :rootSnapshotList
4
- attr_accessor :childSnapshotList
5
-
6
- def initialize
7
- @name = nil
8
- @rootSnapshotList = []
9
- @childSnapshotList = []
10
- end
11
-
12
- def print_nested_array arg
13
- str = '[ '
14
- arg.each do |arry|
15
- if arry.is_a?(Array)
16
- str += print_nested_array( arry )
17
- elsif arry.is_a?(MockRbVmomiSnapshot)
18
- str += arry.to_s + ", "
19
- end
20
- end
21
- str + ' ]'
22
- end
23
-
24
- def to_s
25
- "Snapshot(name: #{@name}, rootSnapshotlist: #{print_nested_array(@rootSnapshotList)}, childSnapshotList: #{print_nested_array(@childSnapshotList)})"
26
- end
27
-
28
- def snapshot
29
- self
30
- end
31
-
32
- end
33
-
34
- class MockRbVmomiVM
35
- attr_accessor :snapshot, :name, :state
36
-
37
- def info
38
- self
39
- end
40
-
41
- def process_snaphash snaphash
42
- shotlist = []
43
- snaphash.each do | name, subsnaps |
44
- new_snap = MockRbVmomiSnapshot.new
45
- new_snap.name = name
46
- if subsnaps.is_a?(Hash)
47
- new_snap.childSnapshotList = process_snaphash( subsnaps )
48
- end
49
- shotlist << new_snap
50
- end
51
- shotlist
52
- end
53
-
54
- def get_snapshot name, snaplist = @snapshot.rootSnapshotList
55
- snapshot = nil
56
- snaplist.each do |snap|
57
- if snap.is_a?(Array)
58
- snapshot = get_snapshot(snap, name)
59
- elsif snap.name == name
60
- snapshot = snap.snapshot
61
- end
62
- end
63
- snapshot
64
- end
65
-
66
- def initialize name, snaphash
67
- @name = name
68
- @snapshot = MockRbVmomiSnapshot.new
69
- @snapshot.name = name
70
- @snapshot.rootSnapshotList = process_snaphash( snaphash )
71
- end
72
-
73
- end
74
-
75
- class MockRbVmomiConnection
76
-
77
- class CustomizationSpecManager
78
-
79
- class CustomizationSpec
80
- def spec
81
- true
82
- end
83
- end
84
-
85
- def initialize
86
- @customizationspec = CustomizationSpec.new
87
- end
88
-
89
- def GetCustomizationSpec arg
90
- @customizationspec
91
- end
92
-
93
- end
94
-
95
- class PropertyCollector
96
- class Result
97
- def initialize(name, object)
98
- @name = name
99
- @object = object
100
- end
101
-
102
- def val
103
- @name
104
- end
105
-
106
- def obj
107
- @object
108
- end
109
-
110
- def propSet
111
- [self]
112
- end
113
-
114
- end
115
-
116
- class ResultContainer
117
- attr_accessor :token
118
-
119
- def initialize
120
- @results = []
121
- end
122
-
123
- def objects
124
- @results
125
- end
126
-
127
- def add_object obj
128
- @results << obj
129
- end
130
-
131
- end
132
-
133
- def initialize
134
- @results = ResultContainer.new
135
- end
136
-
137
-
138
- def RetrievePropertiesEx hash
139
- @results.token = true
140
- @results
141
- end
142
-
143
- def ContinueRetrievePropertiesEx token
144
- @results.token = false
145
- @results
146
- end
147
-
148
- def add_result name, object
149
- @results.add_object( Result.new(name, object) )
150
- end
151
-
152
- def WaitForUpdates arg
153
- result = OpenStruct.new
154
- result.version = 'version'
155
- result
156
- end
157
-
158
- def CreateFilter arg
159
- filter = OpenStruct.new
160
- filter.DestroyPropertyFilter = true
161
- filter
162
- end
163
-
164
- end
165
-
166
- class ServiceInstance
167
- class Datacenter
168
- attr_accessor :vmFolder
169
- attr_accessor :hostFolder
170
-
171
- def initialize
172
- @vmFolder = MockRbVmomi::VIM::Folder.new
173
- @vmFolder.name = "/root"
174
- end
175
-
176
- def find_datastore arg
177
- true
178
- end
179
-
180
- end
181
-
182
- def initialize
183
- @datacenter = Datacenter.new
184
- end
185
-
186
- def find_datacenter dc
187
- @datacenter
188
- end
189
-
190
- end
191
-
192
- class ServiceManager
193
- class ViewManager
194
-
195
- def CreateContainerView hash
196
- @view = hash
197
- end
198
-
199
- end
200
-
201
- def initialize
202
- @customizationspecmanager = CustomizationSpecManager.new
203
- @viewmanager = ViewManager.new
204
- end
205
-
206
- def customizationSpecManager
207
- @customizationspecmanager
208
- end
209
-
210
- def viewManager
211
- @viewmanager
212
- end
213
-
214
- def rootFolder
215
- "/root"
216
- end
217
-
218
- end
219
-
220
- def initialize opts
221
- @host = opts[ :host ]
222
- @user = opts[ :user ]
223
- @password = opts[ :password ]
224
- @insecure = opts[ :insecure ]
225
- @serviceinstance = ServiceInstance.new
226
- @servicemanager = ServiceManager.new
227
- @propertycollector = PropertyCollector.new
228
-
229
- end
230
-
231
- def serviceInstance
232
- @serviceinstance
233
- end
234
-
235
- def serviceContent
236
- @servicemanager
237
- end
238
-
239
- def propertyCollector
240
- @propertycollector
241
- end
242
-
243
- def set_info vms
244
- vms.each do |vm|
245
- @propertycollector.add_result(vm.name, vm)
246
- end
247
- end
248
- end
249
-
250
-
251
- class MockRbVmomi
252
-
253
- class VIM
254
- class Folder
255
- attr_accessor :name
256
-
257
- def find
258
- self
259
- end
260
-
261
-
262
- def childEntity
263
- self
264
- end
265
-
266
- def resourcePool
267
- self
268
- end
269
-
270
- def traverse path, type=Object, create=false
271
- self
272
- end
273
- end
274
-
275
- class ResourcePool
276
- attr_accessor :name
277
-
278
- def find
279
- self
280
- end
281
-
282
- def resourcePool
283
- self
284
- end
285
-
286
- end
287
-
288
- class ClusterComputeResource
289
- attr_accessor :name
290
-
291
- def find
292
- self
293
- end
294
-
295
- def resourcePool
296
- self
297
- end
298
-
299
- end
300
-
301
- class TraversalSpec
302
- def initialize hash
303
-
304
- end
305
-
306
- end
307
-
308
- def self.connect opts
309
- MockRbVmomiConnection.new( opts )
310
- end
311
-
312
- end
313
-
314
- end