beaker-puppet 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/.gitignore +25 -0
- data/.simplecov +9 -0
- data/Gemfile +25 -0
- data/HISTORY.md +8 -0
- data/LICENSE +202 -0
- data/README.md +55 -0
- data/Rakefile +299 -0
- data/acceptance/config/acceptance-options.rb +6 -0
- data/acceptance/config/gem/acceptance-options.rb +9 -0
- data/acceptance/config/git/acceptance-options.rb +9 -0
- data/acceptance/config/nodes/vagrant-ubuntu-1404.yml +8 -0
- data/acceptance/config/pkg/acceptance-options.rb +8 -0
- data/acceptance/lib/beaker/acceptance/install_utils.rb +58 -0
- data/acceptance/pre_suite/gem/install.rb +8 -0
- data/acceptance/pre_suite/git/install.rb +97 -0
- data/acceptance/pre_suite/pkg/install.rb +9 -0
- data/acceptance/tests/README.md +3 -0
- data/acceptance/tests/backwards_compatible.rb +19 -0
- data/acceptance/tests/install_smoke_test.rb +21 -0
- data/acceptance/tests/stub_host.rb +47 -0
- data/acceptance/tests/web_helpers_test.rb +54 -0
- data/acceptance/tests/with_puppet_running_on.rb +26 -0
- data/beaker-puppet.gemspec +38 -0
- data/bin/beaker-puppet +32 -0
- data/lib/beaker-puppet.rb +46 -0
- data/lib/beaker-puppet/helpers/facter_helpers.rb +57 -0
- data/lib/beaker-puppet/helpers/puppet_helpers.rb +865 -0
- data/lib/beaker-puppet/helpers/tk_helpers.rb +89 -0
- data/lib/beaker-puppet/install_utils/aio_defaults.rb +93 -0
- data/lib/beaker-puppet/install_utils/ezbake_utils.rb +256 -0
- data/lib/beaker-puppet/install_utils/foss_defaults.rb +211 -0
- data/lib/beaker-puppet/install_utils/foss_utils.rb +1309 -0
- data/lib/beaker-puppet/install_utils/module_utils.rb +244 -0
- data/lib/beaker-puppet/install_utils/puppet_utils.rb +157 -0
- data/lib/beaker-puppet/version.rb +3 -0
- data/lib/beaker-puppet/wrappers.rb +93 -0
- data/lib/beaker/dsl/helpers/facter_helpers.rb +1 -0
- data/lib/beaker/dsl/helpers/puppet_helpers.rb +1 -0
- data/lib/beaker/dsl/helpers/tk_helpers.rb +1 -0
- data/lib/beaker/dsl/install_utils/aio_defaults.rb +1 -0
- data/lib/beaker/dsl/install_utils/ezbake_utils.rb +1 -0
- data/lib/beaker/dsl/install_utils/foss_defaults.rb +1 -0
- data/lib/beaker/dsl/install_utils/foss_utils.rb +1 -0
- data/lib/beaker/dsl/install_utils/module_utils.rb +1 -0
- data/lib/beaker/dsl/install_utils/puppet_utils.rb +1 -0
- data/spec/beaker-puppet/helpers/facter_helpers_spec.rb +64 -0
- data/spec/beaker-puppet/helpers/puppet_helpers_spec.rb +1287 -0
- data/spec/beaker-puppet/helpers/tk_helpers_spec.rb +86 -0
- data/spec/helpers.rb +109 -0
- data/spec/spec_helper.rb +23 -0
- metadata +249 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MzZhZjg0NGIxMjBhNDkyMjQ5NGEyYmNjYzljMTYyZDVmZWFhMmM4YQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OTQ0YjQ4MTkzOTAzMWU5ZGYwZjZlNTE1ZTg5MGMxNzk0Y2VmNjBlYw==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NmY3YTljNDMxOGViNTFlYWM3MDJlNmQ3MmU4OTk0MjdkMjE2Y2RmOGU3OWU0
|
10
|
+
Yjc0ZjRjN2I2YWYyZTU0NjJhNjYwZGMwMTBmNDJiYzg3OTBiMjA5ZGI5NDE0
|
11
|
+
YmQ3NzNkY2NmNDhiNGJjNGY0NjRjMTg4Njg1MDU4YTI0Y2YxZGE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZjA3NmY0YTcyMDI3NmMxNjc2MWY2YzllODFjMjc0YTZiODE1MzUzZjc5YzFi
|
14
|
+
YjcyZTcyMTljNmM1YTYyN2IwODI5Y2NkZGU5M2M3ZjgxMDc5OWJjYWY4YTRk
|
15
|
+
ZWUwOTc2M2MwZTAwNjA0MmFmMWMxYjNiNDZkYzk4OTZlOTYyOWY=
|
data/.gitignore
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
*.swp
|
2
|
+
log/*
|
3
|
+
!.gitignore
|
4
|
+
junit
|
5
|
+
acceptance-tests
|
6
|
+
Gemfile.lock
|
7
|
+
options.rb
|
8
|
+
test.cfg
|
9
|
+
.yardoc
|
10
|
+
yard_docs
|
11
|
+
coverage
|
12
|
+
.bundle
|
13
|
+
.vendor
|
14
|
+
_vendor
|
15
|
+
tmp/
|
16
|
+
doc
|
17
|
+
# JetBrains IDEA
|
18
|
+
*.iml
|
19
|
+
.idea/
|
20
|
+
# rbenv file
|
21
|
+
.ruby-version
|
22
|
+
.ruby-gemset
|
23
|
+
# Vagrant folder
|
24
|
+
.vagrant/
|
25
|
+
.vagrant_files/
|
data/.simplecov
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
source ENV['GEM_SOURCE'] || "https://rubygems.org"
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
def location_for(place, fake_version = nil)
|
8
|
+
if place =~ /^(git:[^#]*)#(.*)/
|
9
|
+
[fake_version, { :git => $1, :branch => $2, :require => false }].compact
|
10
|
+
elsif place =~ /^file:\/\/(.*)/
|
11
|
+
['>= 0', { :path => File.expand_path($1), :require => false }]
|
12
|
+
else
|
13
|
+
[place, { :require => false }]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
group :test do
|
19
|
+
gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 3.0')
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
if File.exists? "#{__FILE__}.local"
|
24
|
+
eval(File.read("#{__FILE__}.local"), binding)
|
25
|
+
end
|
data/HISTORY.md
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright {yyyy} {name of copyright owner}
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
202
|
+
|
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# beaker-puppet: The Puppet-Specific Beaker Library
|
2
|
+
|
3
|
+
The purpose of this library is to hold all puppet-specific info & DSL methods.
|
4
|
+
This includes all helper & installer methods.
|
5
|
+
|
6
|
+
It might not be up to that state yet, but that's the goal for this library. If
|
7
|
+
you see anything puppet-specific that you'd like to pull into this library out
|
8
|
+
of beaker, please do, we would love any help that you'd like to provide.
|
9
|
+
|
10
|
+
# How Do I Use This?
|
11
|
+
|
12
|
+
### Right Now? (beaker 3.x)
|
13
|
+
|
14
|
+
At this point, beaker-puppet is included in beaker, so you don't have to _do_
|
15
|
+
anything to get the methods in this library.
|
16
|
+
|
17
|
+
You can use these methods in a test by referencing them by name without
|
18
|
+
qualifications, as they're included in the beaker DSL by default.
|
19
|
+
|
20
|
+
### In beaker's Next Major Version? (beaker 4.x)
|
21
|
+
|
22
|
+
In beaker's next major version, the requirement for beaker-puppet will be pulled
|
23
|
+
from that repo. When that happens, then the usage pattern will change. In order
|
24
|
+
to use this then, you'll need to include beaker-puppet as a dependency right
|
25
|
+
next to beaker itself.
|
26
|
+
|
27
|
+
Once you've done that & installed the gems, in your test, you'll have to
|
28
|
+
```ruby
|
29
|
+
require 'beaker-puppet'
|
30
|
+
```
|
31
|
+
|
32
|
+
Doing this will include (automatically) the beaker-puppet DSL methods in the
|
33
|
+
beaker DSL. Then you can call beaker-puppet methods, exactly as you did before.
|
34
|
+
|
35
|
+
# How Do I Test This?
|
36
|
+
|
37
|
+
### Unit / Spec Testing
|
38
|
+
|
39
|
+
You can run the spec testing using our rake task `test:spec:run`. You can also run
|
40
|
+
`rspec` directly. If you'd like to see a coverage report, then you can run the
|
41
|
+
`test:spec:coverage` rake task.
|
42
|
+
|
43
|
+
### Acceptance Testing
|
44
|
+
|
45
|
+
Acceptance testing can be run using the `acceptance` rake test namespace. For
|
46
|
+
instance, to test using our package installation, you can run the
|
47
|
+
`acceptance:pkg` task.
|
48
|
+
|
49
|
+
Note in the above rake tasks that there are some environment variables that you
|
50
|
+
can use to customize your run. For specifying your System Under Test (SUT)
|
51
|
+
environment, you can use `BEAKER_HOSTS`, passing a file path to a beaker hosts
|
52
|
+
file, or you can provide a beaker-hostgenerator value to the `TEST_TARGET`
|
53
|
+
environment variable. You can also specify the tests that get executed with the
|
54
|
+
`TESTS` environment variable.
|
55
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,299 @@
|
|
1
|
+
require 'rspec/core/rake_task'
|
2
|
+
require 'securerandom'
|
3
|
+
require 'beaker-hostgenerator'
|
4
|
+
|
5
|
+
|
6
|
+
namespace :test do
|
7
|
+
|
8
|
+
namespace :spec do
|
9
|
+
|
10
|
+
desc "Run spec tests"
|
11
|
+
RSpec::Core::RakeTask.new(:run) do |t|
|
12
|
+
t.rspec_opts = ['--color']
|
13
|
+
t.pattern = 'spec/'
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "Run spec tests with coverage"
|
17
|
+
RSpec::Core::RakeTask.new(:coverage) do |t|
|
18
|
+
ENV['BEAKER_PUPPET_COVERAGE'] = 'y'
|
19
|
+
t.rspec_opts = ['--color']
|
20
|
+
t.pattern = 'spec/'
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
namespace :acceptance do
|
26
|
+
USAGE = <<-EOS
|
27
|
+
You may set BEAKER_HOSTS=config/nodes/foo.yaml or include it in an acceptance-options.rb for Beaker,
|
28
|
+
or specify TEST_TARGET in a form beaker-hostgenerator accepts, e.g. ubuntu1504-64a.
|
29
|
+
You may override the default master test target by specifying MASTER_TEST_TARGET.
|
30
|
+
You may set TESTS=path/to/test,and/more/tests.
|
31
|
+
You may set additional Beaker OPTIONS='--more --options'
|
32
|
+
If there is a Beaker options hash in a ./acceptance/local_options.rb, it will be included.
|
33
|
+
Commandline options set through the above environment variables will override settings in this file.
|
34
|
+
EOS
|
35
|
+
|
36
|
+
desc <<-EOS
|
37
|
+
Run the puppet beaker acceptance tests on a puppet gem install.
|
38
|
+
#{USAGE}
|
39
|
+
EOS
|
40
|
+
task :gem => 'gen_hosts' do
|
41
|
+
beaker_test(:gem)
|
42
|
+
end
|
43
|
+
|
44
|
+
desc <<-EOS
|
45
|
+
Run the puppet beaker acceptance tests on a puppet git install.
|
46
|
+
#{USAGE}
|
47
|
+
EOS
|
48
|
+
task :git => 'gen_hosts' do
|
49
|
+
beaker_test(:git)
|
50
|
+
end
|
51
|
+
|
52
|
+
desc <<-EOS
|
53
|
+
Run the puppet beaker acceptance tests on a puppet package install.
|
54
|
+
#{USAGE}
|
55
|
+
EOS
|
56
|
+
task :pkg => 'gen_hosts' do
|
57
|
+
beaker_test(:pkg)
|
58
|
+
end
|
59
|
+
|
60
|
+
desc <<-EOS
|
61
|
+
Run the puppet beaker acceptance tests on a base system (no install).
|
62
|
+
#{USAGE}
|
63
|
+
EOS
|
64
|
+
task :base => 'gen_hosts' do
|
65
|
+
beaker_test()
|
66
|
+
end
|
67
|
+
|
68
|
+
desc 'Generate Beaker Host Config File'
|
69
|
+
task :gen_hosts do
|
70
|
+
if hosts_file_env
|
71
|
+
next
|
72
|
+
end
|
73
|
+
cli = BeakerHostGenerator::CLI.new([test_targets])
|
74
|
+
FileUtils.mkdir_p('tmp') # -p ignores when dir already exists
|
75
|
+
File.open("tmp/#{HOSTS_FILE}", 'w') do |fh|
|
76
|
+
fh.print(cli.execute)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def hosts_opt(use_preserved_hosts=false)
|
81
|
+
if use_preserved_hosts
|
82
|
+
"--hosts=#{HOSTS_PRESERVED}"
|
83
|
+
else
|
84
|
+
if hosts_file_env
|
85
|
+
"--hosts=#{hosts_file_env}"
|
86
|
+
else
|
87
|
+
"--hosts=tmp/#{HOSTS_FILE}"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def hosts_file_env
|
93
|
+
ENV['BEAKER_HOSTS']
|
94
|
+
end
|
95
|
+
|
96
|
+
def agent_target
|
97
|
+
ENV['TEST_TARGET'] || 'redhat7-64af'
|
98
|
+
end
|
99
|
+
|
100
|
+
def master_target
|
101
|
+
ENV['MASTER_TEST_TARGET'] || 'redhat7-64default.mdcal'
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_targets
|
105
|
+
ENV['LAYOUT'] || "#{master_target}-#{agent_target}"
|
106
|
+
end
|
107
|
+
|
108
|
+
HOSTS_FILE = "#{test_targets}-#{SecureRandom.uuid}.yaml"
|
109
|
+
HOSTS_PRESERVED = 'log/latest/hosts_preserved.yml'
|
110
|
+
|
111
|
+
def beaker_test(mode = :base, options = {})
|
112
|
+
|
113
|
+
preserved_hosts_mode = options[:hosts] == HOSTS_PRESERVED
|
114
|
+
final_options = HarnessOptions.final_options(mode, options)
|
115
|
+
|
116
|
+
options_opt = ""
|
117
|
+
# preserved hosts can not be used with an options file (BKR-670)
|
118
|
+
# one can still use OPTIONS
|
119
|
+
|
120
|
+
if !preserved_hosts_mode
|
121
|
+
options_file = 'merged_options.rb'
|
122
|
+
options_opt = "--options-file=#{options_file}"
|
123
|
+
File.open(options_file, 'w') do |merged|
|
124
|
+
merged.puts <<-EOS
|
125
|
+
# Copy this file to local_options.rb and adjust as needed if you wish to run
|
126
|
+
# with some local overrides.
|
127
|
+
EOS
|
128
|
+
merged.puts(final_options)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
tests = ENV['TESTS'] || ENV['TEST']
|
133
|
+
tests_opt = ""
|
134
|
+
tests_opt = "--tests=#{tests}" if tests
|
135
|
+
|
136
|
+
overriding_options = ENV['OPTIONS'].to_s
|
137
|
+
|
138
|
+
args = [options_opt, hosts_opt(preserved_hosts_mode), tests_opt,
|
139
|
+
*overriding_options.split(' ')].compact
|
140
|
+
|
141
|
+
sh("beaker", *args)
|
142
|
+
end
|
143
|
+
|
144
|
+
module HarnessOptions
|
145
|
+
defaults = {
|
146
|
+
:tests => ['tests'],
|
147
|
+
:log_level => 'debug',
|
148
|
+
:preserve_hosts => 'onfail',
|
149
|
+
}
|
150
|
+
|
151
|
+
DEFAULTS = defaults
|
152
|
+
|
153
|
+
def self.get_options(file_path)
|
154
|
+
puts "Attempting to merge config file: #{file_path}"
|
155
|
+
if File.exists? file_path
|
156
|
+
options = eval(File.read(file_path), binding)
|
157
|
+
else
|
158
|
+
puts "No options file found at #{File.expand_path(file_path)}... skipping"
|
159
|
+
end
|
160
|
+
options || {}
|
161
|
+
end
|
162
|
+
|
163
|
+
def self.get_mode_options(mode)
|
164
|
+
get_options("./acceptance/config/#{mode}/acceptance-options.rb")
|
165
|
+
end
|
166
|
+
|
167
|
+
def self.get_local_options
|
168
|
+
get_options('./acceptance/local_options.rb')
|
169
|
+
end
|
170
|
+
|
171
|
+
def self.final_options(mode, intermediary_options = {})
|
172
|
+
mode_options = get_mode_options(mode)
|
173
|
+
local_overrides = get_local_options
|
174
|
+
final_options = DEFAULTS.merge(mode_options)
|
175
|
+
final_options.merge!(intermediary_options)
|
176
|
+
final_options.merge!(local_overrides)
|
177
|
+
end
|
178
|
+
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|
182
|
+
|
183
|
+
end
|
184
|
+
|
185
|
+
# namespace-named default tasks.
|
186
|
+
# these are the default tasks invoked when only the namespace is referenced.
|
187
|
+
# they're needed because `task :default` in those blocks doesn't work as expected.
|
188
|
+
task 'test:spec' => 'test:spec:run'
|
189
|
+
task 'test:acceptance' => 'test:acceptance:quick'
|
190
|
+
|
191
|
+
# global defaults
|
192
|
+
task :test => 'test:spec'
|
193
|
+
task :default => :test
|
194
|
+
|
195
|
+
###########################################################
|
196
|
+
#
|
197
|
+
# Documentation Tasks
|
198
|
+
#
|
199
|
+
###########################################################
|
200
|
+
DOCS_DAEMON = "yard server --reload --daemon --server thin"
|
201
|
+
FOREGROUND_SERVER = 'bundle exec yard server --reload --verbose --server thin lib/beaker'
|
202
|
+
|
203
|
+
def running?( cmdline )
|
204
|
+
ps = `ps -ef`
|
205
|
+
found = ps.lines.grep( /#{Regexp.quote( cmdline )}/ )
|
206
|
+
if found.length > 1
|
207
|
+
raise StandardError, "Found multiple YARD Servers. Don't know what to do."
|
208
|
+
end
|
209
|
+
|
210
|
+
yes = found.empty? ? false : true
|
211
|
+
return yes, found.first
|
212
|
+
end
|
213
|
+
|
214
|
+
def pid_from( output )
|
215
|
+
output.squeeze(' ').strip.split(' ')[1]
|
216
|
+
end
|
217
|
+
|
218
|
+
desc 'Start the documentation server in the foreground'
|
219
|
+
task :docs => 'docs:clear' do
|
220
|
+
original_dir = Dir.pwd
|
221
|
+
Dir.chdir( File.expand_path(File.dirname(__FILE__)) )
|
222
|
+
sh FOREGROUND_SERVER
|
223
|
+
Dir.chdir( original_dir )
|
224
|
+
end
|
225
|
+
|
226
|
+
namespace :docs do
|
227
|
+
|
228
|
+
desc 'Clear the generated documentation cache'
|
229
|
+
task :clear do
|
230
|
+
original_dir = Dir.pwd
|
231
|
+
Dir.chdir( File.expand_path(File.dirname(__FILE__)) )
|
232
|
+
sh 'rm -rf docs'
|
233
|
+
Dir.chdir( original_dir )
|
234
|
+
end
|
235
|
+
|
236
|
+
desc 'Generate static documentation'
|
237
|
+
task :gen => 'docs:clear' do
|
238
|
+
original_dir = Dir.pwd
|
239
|
+
Dir.chdir( File.expand_path(File.dirname(__FILE__)) )
|
240
|
+
output = `bundle exec yard doc`
|
241
|
+
puts output
|
242
|
+
if output =~ /\[warn\]|\[error\]/
|
243
|
+
fail "Errors/Warnings during yard documentation generation"
|
244
|
+
end
|
245
|
+
Dir.chdir( original_dir )
|
246
|
+
end
|
247
|
+
|
248
|
+
desc 'Run the documentation server in the background, alias `bg`'
|
249
|
+
task :background => 'docs:clear' do
|
250
|
+
yes, output = running?( DOCS_DAEMON )
|
251
|
+
if yes
|
252
|
+
puts "Not starting a new YARD Server..."
|
253
|
+
puts "Found one running with pid #{pid_from( output )}."
|
254
|
+
else
|
255
|
+
original_dir = Dir.pwd
|
256
|
+
Dir.chdir( File.expand_path(File.dirname(__FILE__)) )
|
257
|
+
sh "bundle exec #{DOCS_DAEMON}"
|
258
|
+
Dir.chdir( original_dir )
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
task(:bg) { Rake::Task['docs:background'].invoke }
|
263
|
+
|
264
|
+
desc 'Check the status of the documentation server'
|
265
|
+
task :status do
|
266
|
+
yes, output = running?( DOCS_DAEMON )
|
267
|
+
if yes
|
268
|
+
pid = pid_from( output )
|
269
|
+
puts "Found a YARD Server running with pid #{pid}"
|
270
|
+
else
|
271
|
+
puts "Could not find a running YARD Server."
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
desc "Stop a running YARD Server"
|
276
|
+
task :stop do
|
277
|
+
yes, output = running?( DOCS_DAEMON )
|
278
|
+
if yes
|
279
|
+
pid = pid_from( output )
|
280
|
+
puts "Found a YARD Server running with pid #{pid}"
|
281
|
+
`kill #{pid}`
|
282
|
+
puts "Stopping..."
|
283
|
+
yes, output = running?( DOCS_DAEMON )
|
284
|
+
if yes
|
285
|
+
`kill -9 #{pid}`
|
286
|
+
yes, output = running?( DOCS_DAEMON )
|
287
|
+
if yes
|
288
|
+
puts "Could not Stop Server!"
|
289
|
+
else
|
290
|
+
puts "Server stopped."
|
291
|
+
end
|
292
|
+
else
|
293
|
+
puts "Server stopped."
|
294
|
+
end
|
295
|
+
else
|
296
|
+
puts "Could not find a running YARD Server"
|
297
|
+
end
|
298
|
+
end
|
299
|
+
end
|