pdqtest 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/puppet_module_dependencies.md +2 -1
- data/docker_images/centos/Dockerfile +2 -2
- data/docker_images/ubuntu/Dockerfile +1 -1
- data/lib/pdqtest/docker.rb +2 -2
- data/lib/pdqtest/puppet.rb +32 -0
- data/lib/pdqtest/rspec.rb +4 -6
- data/lib/pdqtest/skeleton.rb +9 -7
- data/lib/pdqtest/version.rb +1 -1
- data/pdqtest.gemspec +3 -3
- data/res/skeleton/dot_gitignore +1 -0
- data/res/templates/r10k.yaml.erb +3 -0
- data/res/templates/rspec.rb.erb +2 -2
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37530405f473c1f36eda386d84ab94debf584179e52bb55bff2fd1f30e27eaf0
|
4
|
+
data.tar.gz: b216fd428e5dc17a4f9d1d395090ae2d0359591693d4bfa9eaef490f9c38e412
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1f5cfe1259ef9c487c7c0d05b0d62495e57ad37366b9e6e5de226e30534ec24012aeed6806be02a28816822ffca2d9affc624d9f70108b2b68ff8ffeebda863
|
7
|
+
data.tar.gz: ed98f8ca46b59f583b7b8df038ffce1052b21515c3c66fe3224a14f3db938eae908314ca15761367d48b20234e6a5935bf0c63aa2696cdee890656f55526cef6
|
@@ -18,9 +18,10 @@ repositories:
|
|
18
18
|
|
19
19
|
|
20
20
|
## .fixtures.yml
|
21
|
-
There is no need to maintain a `.fixtures.yml` file and the presence of this file when using `pdqtest` is an error
|
21
|
+
There is no need to maintain a `.fixtures.yml` file and the presence of this file when using `pdqtest` is an error (note the leading period)
|
22
22
|
|
23
23
|
## Notes:
|
24
24
|
* The filename is for private modules is `fixtures.yml` NOT `.fixtures.yml`. The leading dot had to be removed to avoid `puppetlabs_spec_helper` also detecting the file and trying to use it.
|
25
25
|
* The file format of `.fixtures.yml` and `fixtures.yml` for specifing git repositories is identical
|
26
26
|
* Only the repositories section of the file will be processed as we do not use `puppetlabs_spec_helper` to do this for us.
|
27
|
+
* We convert the dependencies from `metadata.json` to a temporary puppetfile store at `.Puppetfile.pdqtes` which is then installed using r10k
|
@@ -51,8 +51,8 @@ RUN yum -y install https://pm.puppet.com/puppet-agent/2017.3.5/5.3.5/repos/el/7/
|
|
51
51
|
# bats
|
52
52
|
RUN git clone https://github.com/bats-core/bats-core /usr/local/bats
|
53
53
|
|
54
|
-
#
|
55
|
-
RUN /opt/puppetlabs/puppet/bin/gem install
|
54
|
+
# r10k
|
55
|
+
RUN /opt/puppetlabs/puppet/bin/gem install r10k
|
56
56
|
|
57
57
|
# git refresh (for processing .fixtures.yml git modules)
|
58
58
|
RUN /opt/puppetlabs/puppet/bin/gem install git_refresh
|
@@ -51,7 +51,7 @@ RUN curl -Lo /tmp/puppet-agent.deb https://pm.puppet.com/puppet-agent/2017.3.5/5
|
|
51
51
|
RUN git clone https://github.com/bats-core/bats-core /usr/local/bats
|
52
52
|
|
53
53
|
# librarian
|
54
|
-
RUN /opt/puppetlabs/puppet/bin/gem install
|
54
|
+
RUN /opt/puppetlabs/puppet/bin/gem install r10k
|
55
55
|
|
56
56
|
# git refresh (for processing .fixtures.yml git modules)
|
57
57
|
RUN /opt/puppetlabs/puppet/bin/gem install git_refresh
|
data/lib/pdqtest/docker.rb
CHANGED
@@ -8,8 +8,8 @@ module PDQTest
|
|
8
8
|
STATUS = 2
|
9
9
|
ENV='export TERM=xterm LC_ALL=C PATH=/usr/local/bats/bin:/opt/puppetlabs/puppet/bin:$PATH;'
|
10
10
|
IMAGES = {
|
11
|
-
:DEFAULT => 'declarativesystems/pdqtest-centos:2018-
|
12
|
-
:UBUNTU => 'declarativesystems/pdqtest-ubuntu:2018-
|
11
|
+
:DEFAULT => 'declarativesystems/pdqtest-centos:2018-05-31-0',
|
12
|
+
:UBUNTU => 'declarativesystems/pdqtest-ubuntu:2018-05-31-0',
|
13
13
|
}
|
14
14
|
HIERA_YAML_CONTAINER = '/etc/puppetlabs/puppet/hiera.yaml'
|
15
15
|
HIERA_YAML_HOST = '/spec/fixtures/hiera.yaml'
|
data/lib/pdqtest/puppet.rb
CHANGED
@@ -22,6 +22,8 @@ module PDQTest
|
|
22
22
|
@@setup_executed = []
|
23
23
|
@@skip_second_run = false
|
24
24
|
FIXTURES = 'fixtures.yml'
|
25
|
+
TMP_PUPPETFILE = '.Puppetfile.pdqtest'
|
26
|
+
|
25
27
|
|
26
28
|
def self.skip_second_run(skip_second_run)
|
27
29
|
@@skip_second_run = skip_second_run
|
@@ -315,5 +317,35 @@ module PDQTest
|
|
315
317
|
Escort::Logger.output.puts "Parsed module name: #{module_name}"
|
316
318
|
Escort::Logger.output.puts "Link module command: #{link_module}"
|
317
319
|
end
|
320
|
+
|
321
|
+
# extract a Puppetfile from metadata.json and install modules using r10k
|
322
|
+
def self.install_modules()
|
323
|
+
json = JSON.parse(File.read(METADATA))
|
324
|
+
puppetfile = []
|
325
|
+
if json.has_key?("dependencies")
|
326
|
+
json["dependencies"].each { |dependency|
|
327
|
+
line = "mod '#{dependency['name']}'"
|
328
|
+
if dependency.has_key?("version_requirement")
|
329
|
+
# R10K supports specifc named version or 'latest', not the rich versions defined in metadata. To make this
|
330
|
+
# work we will drop any version that specifies a range and just install the latest
|
331
|
+
if dependency['version_requirement'].start_with?(/\d/)
|
332
|
+
line += ", '#{dependency['version_requirement']}'"
|
333
|
+
end
|
334
|
+
end
|
335
|
+
puppetfile << line
|
336
|
+
}
|
337
|
+
end
|
338
|
+
|
339
|
+
File.open(TMP_PUPPETFILE, "w") do |f|
|
340
|
+
f.puts(puppetfile)
|
341
|
+
end
|
342
|
+
|
343
|
+
PDQTest::Emoji.emoji_message("🐌", "I'm downloading The Internet, please hold...")
|
344
|
+
|
345
|
+
cmd = "bundle exec r10k puppetfile install --verbose --moduledir ./spec/fixtures/modules --config .r10k.yaml --puppetfile #{TMP_PUPPETFILE}"
|
346
|
+
status = system(cmd)
|
347
|
+
|
348
|
+
status
|
349
|
+
end
|
318
350
|
end
|
319
351
|
end
|
data/lib/pdqtest/rspec.rb
CHANGED
@@ -5,6 +5,7 @@ require 'pdqtest/emoji'
|
|
5
5
|
require 'erb'
|
6
6
|
require 'fileutils'
|
7
7
|
require 'pdqtest/util'
|
8
|
+
require 'json'
|
8
9
|
|
9
10
|
|
10
11
|
module PDQTest
|
@@ -19,9 +20,8 @@ module PDQTest
|
|
19
20
|
FileUtils.mkdir_p(MODULE_CACHE_DIR)
|
20
21
|
end
|
21
22
|
|
22
|
-
PDQTest::
|
23
|
-
|
24
|
-
status = system(cmd)
|
23
|
+
status = PDQTest::Puppet.install_modules()
|
24
|
+
|
25
25
|
if status
|
26
26
|
PDQTest::Puppet.git_fixtures.each { |extra_mod_install_cmd|
|
27
27
|
if status
|
@@ -62,9 +62,7 @@ module PDQTest
|
|
62
62
|
end
|
63
63
|
|
64
64
|
# process the rspec template into a new file
|
65
|
-
|
66
|
-
testcase = ERB.new(template, nil, '-').result(binding)
|
67
|
-
File.write(spec_file, testcase)
|
65
|
+
PDQTest::Skeleton.install_template(spec_file, 'rspec.rb.erb', {:classname=>classname})
|
68
66
|
end
|
69
67
|
}
|
70
68
|
end
|
data/lib/pdqtest/skeleton.rb
CHANGED
@@ -41,12 +41,13 @@ module PDQTest
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
44
|
+
# vars is a hash of variables that can be accessed in template
|
45
|
+
def self.install_template(target, template_file, vars)
|
46
|
+
example_file = File.join(EXAMPLES_DIR, template_file)
|
47
|
+
if ! File.exists?(target)
|
48
|
+
template = File.read(Util::resource_path(File.join('templates', template_file)))
|
49
|
+
content = ERB.new(template, nil, '-').result(binding)
|
50
|
+
File.write(target, content)
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
@@ -90,11 +91,12 @@ module PDQTest
|
|
90
91
|
install_skeleton('Makefile', 'Makefile')
|
91
92
|
install_skeleton('bitbucket-pipelines.yml', 'bitbucket-pipelines.yml')
|
92
93
|
install_skeleton('.travis.yml', 'dot_travis.yml')
|
94
|
+
install_template('.r10k.yaml', 'r10k.yaml.erb', {})
|
93
95
|
end
|
94
96
|
|
95
97
|
def self.install_acceptance(example_file ="init.pp")
|
96
|
-
install_example(File.basename(example_file))
|
97
98
|
example_name = File.basename(example_file).gsub(/\.pp$/, '')
|
99
|
+
install_template("#{EXAMPLES_DIR}/#{File.basename(example_file)}",'examples_init.pp.erb', {})
|
98
100
|
|
99
101
|
install_skeleton(File.join('spec', 'acceptance', "#{example_name}.bats"), 'init.bats', false)
|
100
102
|
install_skeleton(File.join('spec', 'acceptance', "#{example_name}__before.bats"), 'init__before.bats', false)
|
data/lib/pdqtest/version.rb
CHANGED
data/pdqtest.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.16"
|
25
25
|
spec.add_development_dependency "coveralls", "0.8.21"
|
26
|
-
spec.add_development_dependency "fakefs", "0.
|
26
|
+
spec.add_development_dependency "fakefs", "0.14.2"
|
27
27
|
spec.add_development_dependency "puppet", "5.3.5"
|
28
28
|
|
29
29
|
spec.add_runtime_dependency "rake", "12.3.1"
|
@@ -35,8 +35,8 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.add_runtime_dependency "docker-api", "1.34.2"
|
36
36
|
spec.add_runtime_dependency "puppet-lint", "2.3.5"
|
37
37
|
spec.add_runtime_dependency "puppet-syntax", "2.4.1"
|
38
|
-
spec.add_runtime_dependency "puppetlabs_spec_helper", "2.
|
39
|
-
spec.add_runtime_dependency "
|
38
|
+
spec.add_runtime_dependency "puppetlabs_spec_helper", "2.7.0"
|
39
|
+
spec.add_runtime_dependency "r10k", "2.6.2"
|
40
40
|
spec.add_runtime_dependency "git_refresh", "0.1.1"
|
41
41
|
spec.add_runtime_dependency "puppet_factset", "0.5.0"
|
42
42
|
end
|
data/res/skeleton/dot_gitignore
CHANGED
data/res/templates/rspec.rb.erb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'puppet_factset'
|
3
|
-
describe '<%= classname %>' do
|
3
|
+
describe '<%= vars[:classname] %>' do
|
4
4
|
# Uncomment only the factset you would like to use for these tests
|
5
5
|
<%
|
6
6
|
require 'puppet_factset'
|
@@ -18,6 +18,6 @@ PuppetFactset.factsets.each { |factset|
|
|
18
18
|
end
|
19
19
|
|
20
20
|
context 'with default values for all parameters' do
|
21
|
-
it { should contain_class('<%= classname %>') }
|
21
|
+
it { should contain_class('<%= vars[:classname] %>') }
|
22
22
|
end
|
23
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pdqtest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geoff Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04
|
11
|
+
date: 2018-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.14.2
|
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: 0.
|
54
|
+
version: 0.14.2
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: puppet
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -198,28 +198,28 @@ dependencies:
|
|
198
198
|
requirements:
|
199
199
|
- - '='
|
200
200
|
- !ruby/object:Gem::Version
|
201
|
-
version: 2.
|
201
|
+
version: 2.7.0
|
202
202
|
type: :runtime
|
203
203
|
prerelease: false
|
204
204
|
version_requirements: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
206
206
|
- - '='
|
207
207
|
- !ruby/object:Gem::Version
|
208
|
-
version: 2.
|
208
|
+
version: 2.7.0
|
209
209
|
- !ruby/object:Gem::Dependency
|
210
|
-
name:
|
210
|
+
name: r10k
|
211
211
|
requirement: !ruby/object:Gem::Requirement
|
212
212
|
requirements:
|
213
213
|
- - '='
|
214
214
|
- !ruby/object:Gem::Version
|
215
|
-
version:
|
215
|
+
version: 2.6.2
|
216
216
|
type: :runtime
|
217
217
|
prerelease: false
|
218
218
|
version_requirements: !ruby/object:Gem::Requirement
|
219
219
|
requirements:
|
220
220
|
- - '='
|
221
221
|
- !ruby/object:Gem::Version
|
222
|
-
version:
|
222
|
+
version: 2.6.2
|
223
223
|
- !ruby/object:Gem::Dependency
|
224
224
|
name: git_refresh
|
225
225
|
requirement: !ruby/object:Gem::Requirement
|
@@ -314,6 +314,7 @@ files:
|
|
314
314
|
- res/skeleton/spec_helper.rb
|
315
315
|
- res/skeleton/test.yaml
|
316
316
|
- res/templates/examples_init.pp.erb
|
317
|
+
- res/templates/r10k.yaml.erb
|
317
318
|
- res/templates/rspec.rb.erb
|
318
319
|
homepage: https://github.com/GeoffWilliams/pdqtest
|
319
320
|
licenses:
|