Skip to content

Commit 08cc70d

Browse files
author
Toby McLaughlin
committed
Fix resource defaults for plugins on Puppet 5 #354
Additionally, reinstate the puppet-rspec unit test framework and use it to prove this fix is working.
1 parent 3c39af2 commit 08cc70d

File tree

10 files changed

+70
-23
lines changed

10 files changed

+70
-23
lines changed

.fixtures.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
fixtures:
2-
repositories:
3-
stdlib:
4-
repo: "https://github.com/puppetlabs/puppetlabs-stdlib"
5-
ref: "3.2.0"
6-
apt: https://github.com/puppetlabs/puppetlabs-apt.git
7-
zypprepo: https://github.com/deadpoint/puppet-zypprepo.git
8-
symlinks:
9-
logstash: "#{source_dir}"
2+
forge_modules:
3+
apt: puppetlabs/apt
4+
elastic_stack: elastic/elastic_stack
5+
stdlib: puppetlabs/stdlib
6+
zypprepo: darin/zypprepo
7+
8+
symlinks:
9+
logstash: #{source_dir}

.travis.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,36 @@ rvm:
1616

1717
script:
1818
- docker run --privileged -d polarbearlabs/haveged:1.9.1 # https://github.com/elastic/logstash/issues/5507
19-
- (if [[ -n $TRAVIS_LINT ]]; then make lint; else bundle exec rake beaker; fi)
19+
- |
20+
(
21+
if [[ -n $TRAVIS_LINT ]]; then
22+
make lint
23+
elif [[ -n $TRAVIS_UNIT ]]; then
24+
bundle exec rake spec
25+
else
26+
bundle exec rake beaker
27+
fi
28+
)
2029
2130
env:
2231
global:
2332
- LOGSTASH_VERSION=6.0.0
2433
- BEAKER_PE_DIR=spec/fixtures/artifacts
34+
- CI_SPEC_OPTIONS='--format documentation'
2535
matrix:
2636
# Do linting once.
2737
- TRAVIS_LINT=true
2838

39+
# Run the puppet-rspec synthetic/unit tests.
40+
- PUPPET_VERSION=4.6.1 TRAVIS_UNIT=true
41+
- PUPPET_VERSION=4.8.2 TRAVIS_UNIT=true
42+
- PUPPET_VERSION=4.9.4 TRAVIS_UNIT=true
43+
- PUPPET_VERSION=4.10.8 TRAVIS_UNIT=true
44+
- PUPPET_VERSION=5.0.1 TRAVIS_UNIT=true
45+
- PUPPET_VERSION=5.1.0 TRAVIS_UNIT=true
46+
- PUPPET_VERSION=5.2.0 TRAVIS_UNIT=true
47+
- PUPPET_VERSION=5.3.3 TRAVIS_UNIT=true
48+
2949
# Then run the acceptance tests across the matrix.
3050
- PUPPET_VERSION=4.6.1 BEAKER_set=centos-6
3151
- PUPPET_VERSION=4.8.2 BEAKER_set=centos-6

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ gem 'puppetlabs_spec_helper'
2929
gem 'puppet-syntax'
3030
gem 'rspec-puppet-facts'
3131
gem 'rubocop'
32+
gem 'semantic_puppet'
3233
gem 'serverspec', '2.38.0'
3334
gem 'specinfra', '2.67.3'
3435
gem 'syck'

manifests/plugin.pp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@
4646
require logstash::package
4747
$exe = "${logstash::home_dir}/bin/logstash-plugin"
4848

49+
Exec {
50+
path => '/bin:/usr/bin',
51+
user => $logstash::logstash_user,
52+
timeout => 1800,
53+
environment => $environment,
54+
}
55+
4956
case $source { # Where should we get the plugin from?
5057
undef: {
5158
# No explict source, so search Rubygems for the plugin, by name.
@@ -116,11 +123,4 @@
116123
fail "'ensure' should be 'present', 'absent', or a version like '1.3.4'."
117124
}
118125
}
119-
120-
Exec {
121-
path => '/bin:/usr/bin',
122-
user => $logstash::logstash_user,
123-
timeout => 1800,
124-
environment => $environment,
125-
}
126126
}

metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "elastic-logstash",
3-
"version": "6.0.1",
3+
"version": "6.0.2",
44
"source": "https://github.com/elastic/puppet-logstash",
55
"author": "elastic",
66
"license": "Apache-2.0",

spec/defines/define_plugin_spec.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
require 'spec_helper'
2+
3+
describe 'logstash::plugin' do
4+
on_supported_os.each do |os, facts|
5+
context "on #{os}" do
6+
let(:facts) do
7+
facts
8+
end
9+
10+
let(:pre_condition) { %q(
11+
include elastic_stack::repo
12+
include logstash
13+
)}
14+
15+
let(:title) { 'logstash-input-mysql' }
16+
17+
it { is_expected.to compile }
18+
19+
it {
20+
is_expected.to contain_exec("install-#{title}").with(user: 'logstash')
21+
}
22+
end
23+
end
24+
end

spec/fixtures/manifests/site.pp

Whitespace-only changes.

spec/fixtures/modules/logstash/manifests

Lines changed: 0 additions & 1 deletion
This file was deleted.

spec/fixtures/modules/logstash/templates

Lines changed: 0 additions & 1 deletion
This file was deleted.

spec/spec_helper.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
require 'rubygems'
21
require 'puppetlabs_spec_helper/module_spec_helper'
2+
require 'rspec-puppet-facts'
3+
include RspecPuppetFacts
4+
5+
default_facts = {
6+
puppetversion: Puppet.version,
7+
facterversion: Facter.version,
8+
}
39

410
RSpec.configure do |c|
5-
Puppet.settings[:strict_variables]=true if ENV['STRICT_VARIABLES'] == 'true'
6-
Puppet.settings[:ordering]='random' if ENV['ORDERING_RANDOM'] == 'true'
7-
c.parser = 'future' if ENV['FUTURE_PARSER'] == 'true'
11+
c.default_facts = default_facts
812
end

0 commit comments

Comments
 (0)