Skip to content

Commit cfdc43e

Browse files
authored
Merge pull request #579 from voxpupuli/modulesync
modulesync 2.12.0
2 parents 1f7aafb + 3470fc2 commit cfdc43e

File tree

10 files changed

+54
-131
lines changed

10 files changed

+54
-131
lines changed

.github/CONTRIBUTING.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,18 +256,20 @@ Beaker also supports docker containers. We also use that in our automated CI
256256
pipeline at [travis-ci](http://travis-ci.org). To use that instead of Vagrant:
257257

258258
```sh
259-
PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=debian9-64{hypervisor=docker} BEAKER_destroy=yes bundle exec rake beaker
259+
PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=debian10-64{hypervisor=docker} BEAKER_destroy=yes bundle exec rake beaker
260260
```
261261

262-
You can replace the string `debian9` with any common operating system.
262+
You can replace the string `debian10` with any common operating system.
263263
The following strings are known to work:
264264

265265
* ubuntu1604
266266
* ubuntu1804
267267
* debian8
268268
* debian9
269+
* debian10
269270
* centos6
270271
* centos7
272+
* centos8
271273

272274
The easiest way to debug in a docker container is to open a shell:
273275

.msync.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
modulesync_config_version: '2.10.1'
1+
modulesync_config_version: '2.12.0'

.rubocop.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require: rubocop-rspec
22
AllCops:
3-
TargetRubyVersion: 2.1
3+
# Puppet Server 5 defaults to jruby 1.7 so TargetRubyVersion must stay at 1.9 until we drop support for puppet 5
4+
TargetRubyVersion: 1.9
45
Include:
56
- ./**/*.rb
67
Exclude:
@@ -543,6 +544,3 @@ Style/FormatStringToken:
543544
# are located.
544545
RSpec/FilePath:
545546
Enabled: false
546-
547-
RSpec/MessageSpies:
548-
EnforcedStyle: receive

Gemfile

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,9 @@ def location_for(place, fake_version = nil)
1111
end
1212

1313
group :test do
14-
gem 'puppetlabs_spec_helper', '>= 2.14.0', :require => false
15-
gem 'rspec-puppet-facts', '>= 1.9.5', :require => false
16-
gem 'rspec-puppet-utils', :require => false
17-
gem 'puppet-lint-leading_zero-check', :require => false
18-
gem 'puppet-lint-trailing_comma-check', :require => false
19-
gem 'puppet-lint-version_comparison-check', :require => false
20-
gem 'puppet-lint-classes_and_types_beginning_with_digits-check', :require => false
21-
gem 'puppet-lint-unquoted_string-check', :require => false
22-
gem 'puppet-lint-variable_contains_upcase', :require => false
23-
gem 'puppet-lint-absolute_classname-check', '>= 2.0.0', :require => false
24-
gem 'puppet-lint-topscope-variable-check', :require => false
25-
gem 'puppet-lint-legacy_facts-check', :require => false
26-
gem 'puppet-lint-anchor-check', :require => false
27-
gem 'metadata-json-lint', :require => false
28-
gem 'redcarpet', :require => false
29-
gem 'rubocop', '~> 0.49.1', :require => false
30-
gem 'rubocop-rspec', '~> 1.15.0', :require => false
31-
gem 'mocha', '~> 1.4.0', :require => false
32-
gem 'coveralls', :require => false
33-
gem 'simplecov-console', :require => false
34-
gem 'parallel_tests', :require => false
14+
gem 'voxpupuli-test', '>= 1.0.0', :require => false
15+
gem 'coveralls', :require => false
16+
gem 'simplecov-console', :require => false
3517
end
3618

3719
group :development do
@@ -62,6 +44,7 @@ group :system_tests do
6244
gem 'rbnacl', '>= 4', :require => false
6345
gem 'rbnacl-libsodium', :require => false
6446
gem 'bcrypt_pbkdf', :require => false
47+
gem 'ed25519', :require => false
6548
end
6649

6750
group :release do

Rakefile

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'puppetlabs_spec_helper/rake_tasks'
1+
require 'voxpupuli/test/rake'
22

33
# load optional tasks for releases
44
# only available if gem group releases is installed
@@ -7,37 +7,6 @@ begin
77
rescue LoadError
88
end
99

10-
PuppetLint.configuration.log_format = '%{path}:%{line}:%{check}:%{KIND}:%{message}'
11-
12-
desc 'Auto-correct puppet-lint offenses'
13-
task 'lint:auto_correct' do
14-
Rake::Task[:lint_fix].invoke
15-
end
16-
17-
desc 'Run acceptance tests'
18-
RSpec::Core::RakeTask.new(:acceptance) do |t|
19-
t.pattern = 'spec/acceptance'
20-
end
21-
22-
desc 'Run tests'
23-
task test: [:release_checks]
24-
25-
namespace :check do
26-
desc 'Check for trailing whitespace'
27-
task :trailing_whitespace do
28-
Dir.glob('**/*.md', File::FNM_DOTMATCH).sort.each do |filename|
29-
next if filename =~ %r{^((modules|acceptance|\.?vendor|spec/fixtures|pkg)/|REFERENCE.md)}
30-
File.foreach(filename).each_with_index do |line, index|
31-
if line =~ %r{\s\n$}
32-
puts "#{filename} has trailing whitespace on line #{index + 1}"
33-
exit 1
34-
end
35-
end
36-
end
37-
end
38-
end
39-
Rake::Task[:release_checks].enhance ['check:trailing_whitespace']
40-
4110
desc "Run main 'test' task and report merged results to coveralls"
4211
task test_with_coveralls: [:test] do
4312
if Dir.exist?(File.expand_path('../lib', __FILE__))

spec/spec_helper.rb

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
# This file is managed via modulesync
22
# https://github.com/voxpupuli/modulesync
33
# https://github.com/voxpupuli/modulesync_config
4-
RSpec.configure do |c|
5-
c.mock_with :rspec
6-
end
74

8-
require 'puppetlabs_spec_helper/module_spec_helper'
9-
require 'rspec-puppet-facts'
10-
require 'bundler'
11-
include RspecPuppetFacts
5+
# puppetlabs_spec_helper will set up coverage if the env variable is set.
6+
# We want to do this if lib exists and it hasn't been explicitly set.
7+
ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../../lib', __FILE__))
128

13-
if ENV['DEBUG']
14-
Puppet::Util::Log.level = :debug
15-
Puppet::Util::Log.newdestination(:console)
16-
end
9+
require 'voxpupuli/test/spec_helper'
1710

1811
if File.exist?(File.join(__dir__, 'default_module_facts.yml'))
1912
facts = YAML.load(File.read(File.join(__dir__, 'default_module_facts.yml')))
@@ -23,43 +16,3 @@
2316
end
2417
end
2518
end
26-
27-
if Dir.exist?(File.expand_path('../../lib', __FILE__))
28-
require 'coveralls'
29-
require 'simplecov'
30-
require 'simplecov-console'
31-
SimpleCov.formatters = [
32-
SimpleCov::Formatter::HTMLFormatter,
33-
SimpleCov::Formatter::Console
34-
]
35-
SimpleCov.start do
36-
track_files 'lib/**/*.rb'
37-
add_filter '/spec'
38-
add_filter '/vendor'
39-
add_filter '/.vendor'
40-
add_filter Bundler.configured_bundle_path.path
41-
end
42-
end
43-
44-
RSpec.configure do |c|
45-
# getting the correct facter version is tricky. We use facterdb as a source to mock facts
46-
# see https://github.com/camptocamp/facterdb
47-
# people might provide a specific facter version. In that case we use it.
48-
# Otherwise we need to match the correct facter version to the used puppet version.
49-
# as of 2019-10-31, puppet 5 ships facter 3.11 and puppet 6 ships facter 3.14
50-
# https://puppet.com/docs/puppet/5.5/about_agent.html
51-
#
52-
# The environment variable `PUPPET_VERSION` is available in our travis environment, but we cannot rely on it
53-
# if somebody runs the tests locally. For that case we should fallback the the puppet gem version.
54-
c.default_facter_version = if ENV['FACTERDB_FACTS_VERSION']
55-
ENV['FACTERDB_FACTS_VERSION']
56-
else
57-
puppet_version = ENV['PUPPET_VERSION'] ? ENV['PUPPET_VERSION'] : Gem.loaded_specs['puppet'].version.to_s
58-
Gem::Dependency.new('', puppet_version).match?('', '5') ? '3.11.0' : '3.14.0'
59-
end
60-
61-
# Coverage generation
62-
c.after(:suite) do
63-
RSpec::Puppet::Coverage.report!
64-
end
65-
end

spec/unit/puppet/provider/mongodb_database/mongodb_spec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,17 @@
4848

4949
describe 'create' do
5050
it 'makes a database' do
51-
expect(provider).to receive(:mongo_eval)
51+
allow(provider).to receive(:mongo_eval)
5252
provider.create
53+
expect(provider).to have_received(:mongo_eval)
5354
end
5455
end
5556

5657
describe 'destroy' do
5758
it 'removes a database' do
58-
expect(provider).to receive(:mongo_eval)
59+
allow(provider).to receive(:mongo_eval)
5960
provider.destroy
61+
expect(provider).to have_received(:mongo_eval)
6062
end
6163
end
6264

spec/unit/puppet/provider/mongodb_replset/mongodb_spec.rb

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,19 @@
3939

4040
# rubocop:disable RSpec/MultipleExpectations
4141
it 'creates a replicaset' do
42-
expect(provider.class).to receive(:replset_properties)
43-
expect(provider).to receive(:get_hosts_status).and_return([valid_members, []])
44-
expect(provider).to receive(:master_host).and_return(false)
45-
expect(provider).to receive(:rs_initiate).with('{"_id":"rs_test","members":[{"host":"mongo1:27017","_id":0},{"host":"mongo2:27017","_id":1},{"host":"mongo3:27017","_id":2}],"settings":{}}', 'mongo1:27017').and_return('info' => 'Config now saved locally. Should come online in about a minute.', 'ok' => 1)
46-
expect(provider).to receive(:db_ismaster).and_return('{"ismaster" : true}')
42+
allow(provider.class).to receive(:replset_properties)
43+
allow(provider).to receive(:get_hosts_status).and_return([valid_members, []])
44+
allow(provider).to receive(:master_host).and_return(false)
45+
allow(provider).to receive(:rs_initiate).with('{"_id":"rs_test","members":[{"host":"mongo1:27017","_id":0},{"host":"mongo2:27017","_id":1},{"host":"mongo3:27017","_id":2}],"settings":{}}', 'mongo1:27017').and_return('info' => 'Config now saved locally. Should come online in about a minute.', 'ok' => 1)
46+
allow(provider).to receive(:db_ismaster).and_return('{"ismaster" : true}')
4747
provider.create
4848
provider.flush
49+
50+
expect(provider.class).to have_received(:replset_properties)
51+
expect(provider).to have_received(:get_hosts_status)
52+
expect(provider).to have_received(:master_host)
53+
expect(provider).to have_received(:rs_initiate)
54+
expect(provider).to have_received(:db_ismaster)
4955
end
5056
# rubocop:enable RSpec/MultipleExpectations
5157
end
@@ -145,9 +151,10 @@
145151
it 'adds missing members to an existing replicaset' do
146152
allow(provider.class).to receive(:replset_properties)
147153
allow(provider).to receive(:rs_status).and_return('set' => 'rs_test')
148-
expect(provider).to receive('rs_add').thrice.and_return('ok' => 1)
154+
allow(provider).to receive('rs_add').thrice.and_return('ok' => 1)
149155
provider.members = valid_members
150156
provider.flush
157+
expect(provider).to have_received('rs_add').thrice
151158
end
152159

153160
it 'raises an error when the master host is not available' do

spec/unit/puppet/provider/mongodb_shard/mongodb_spec.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,18 @@
5050
describe '#create' do
5151
# rubocop:disable RSpec/MultipleExpectations
5252
it 'makes a shard' do
53-
expect(provider).to receive(:sh_addshard).with('rs_test/mongo1:27018').and_return(
53+
allow(provider).to receive(:sh_addshard).with('rs_test/mongo1:27018').and_return(
5454
'shardAdded' => 'rs_test',
5555
'ok' => 1
5656
)
57-
expect(provider).to receive(:sh_enablesharding).with('rs_test').and_return(
57+
allow(provider).to receive(:sh_enablesharding).with('rs_test').and_return(
5858
'ok' => 1
5959
)
6060
provider.create
6161
provider.flush
62+
63+
expect(provider).to have_received(:sh_addshard)
64+
expect(provider).to have_received(:sh_enablesharding)
6265
end
6366
# rubocop:enable RSpec/MultipleExpectations
6467
end

spec/unit/puppet/provider/mongodb_user/mongodb_spec.rb

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,17 @@
6161
}
6262
EOS
6363

64-
expect(provider).to receive(:mongo_eval).with("db.runCommand(#{cmd_json})", 'new_database')
64+
allow(provider).to receive(:mongo_eval).with("db.runCommand(#{cmd_json})", 'new_database')
6565
provider.create
66+
expect(provider).to have_received(:mongo_eval)
6667
end
6768
end
6869

6970
describe 'destroy' do
7071
it 'removes a user' do
71-
expect(provider).to receive(:mongo_eval).with('db.dropUser("new_user")')
72+
allow(provider).to receive(:mongo_eval).with('db.dropUser("new_user")')
7273
provider.destroy
74+
expect(provider).to have_received(:mongo_eval)
7375
end
7476
end
7577

@@ -94,9 +96,10 @@
9496
"digestPassword":false
9597
}
9698
EOS
97-
expect(provider).to receive(:mongo_eval).
99+
allow(provider).to receive(:mongo_eval).
98100
with("db.runCommand(#{cmd_json})", 'new_database')
99101
provider.password_hash = 'newpass'
102+
expect(provider).to have_received(:mongo_eval)
100103
end
101104
end
102105

@@ -121,34 +124,37 @@
121124
describe 'roles=' do
122125
it 'changes nothing' do
123126
resource.provider.set(name: 'new_user', ensure: :present, roles: %w[role1 role2@other_database])
124-
expect(provider).not_to receive(:mongo_eval)
127+
allow(provider).to receive(:mongo_eval)
125128
provider.roles = %w[role1 role2@other_database]
129+
expect(provider).not_to have_received(:mongo_eval)
126130
end
127131

128132
it 'grant a role' do
129133
resource.provider.set(name: 'new_user', ensure: :present, roles: %w[role1 role2@other_database])
130-
expect(provider).to receive(:mongo_eval).
134+
allow(provider).to receive(:mongo_eval).
131135
with('db.getSiblingDB("new_database").grantRolesToUser("new_user", [{"role":"role3","db":"new_database"}])')
132136
provider.roles = %w[role1 role2@other_database role3]
137+
expect(provider).to have_received(:mongo_eval)
133138
end
134139

135140
it 'revokes a role' do
136141
resource.provider.set(name: 'new_user', ensure: :present, roles: %w[role1 role2@other_database])
137-
expect(provider).to receive(:mongo_eval).
142+
allow(provider).to receive(:mongo_eval).
138143
with('db.getSiblingDB("new_database").revokeRolesFromUser("new_user", [{"role":"role1","db":"new_database"}])')
139144
provider.roles = ['role2@other_database']
145+
expect(provider).to have_received(:mongo_eval)
140146
end
141147

142-
# rubocop:disable RSpec/MultipleExpectations
143148
it 'exchanges a role' do
144149
resource.provider.set(name: 'new_user', ensure: :present, roles: %w[role1 role2@other_database])
145-
expect(provider).to receive(:mongo_eval).
150+
allow(provider).to receive(:mongo_eval).
146151
with('db.getSiblingDB("new_database").revokeRolesFromUser("new_user", [{"role":"role1","db":"new_database"}])')
147-
expect(provider).to receive(:mongo_eval).
152+
allow(provider).to receive(:mongo_eval).
148153
with('db.getSiblingDB("new_database").grantRolesToUser("new_user", [{"role":"role3","db":"new_database"}])')
149154

150155
provider.roles = %w[role2@other_database role3]
156+
157+
expect(provider).to have_received(:mongo_eval).twice
151158
end
152-
# rubocop:enable RSpec/MultipleExpectations
153159
end
154160
end

0 commit comments

Comments
 (0)