Skip to content

Commit

Permalink
Update to latest modulesync
Browse files Browse the repository at this point in the history
  • Loading branch information
ekohl committed Apr 30, 2020
1 parent f8f94dc commit 4395709
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ junit/
pkg/
coverage/
.yardoc/
REFERENCE.md

## InteliJ / RubyMine
.idea
Expand Down
30 changes: 26 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,34 @@ With all dependencies in place and up-to-date we can now run the tests:
rake spec
```

This will execute all the [rspec tests](http://rspec-puppet.com/) tests
under [spec/defines](./spec/defines), [spec/classes](./spec/classes),
and so on. rspec tests may have the same kind of dependencies as the
module they are testing. While the module defines in its [Modulefile](./Modulefile),
This will execute all the [rspec tests](http://rspec-puppet.com/) tests under
[spec/defines](./spec/defines), [spec/classes](./spec/classes), and so on.
rspec tests may have the same kind of dependencies as the module they are
testing. While the module defines in its [metadata.json](./metadata.json),
rspec tests define them in [.fixtures.yml](./fixtures.yml).

To run specific tests, use the spec test file name and a filter like:

```shell
bundle exec rspec spec/classes/foreman_spec.rb -e 'should restart passenger'
```
More filter info available [here](https://relishapp.com/rspec/rspec-core/v/3-9/docs/command-line/example-option)

To run OS specific tests:

```shell
SPEC_FACTS_OS=redhat-7-x86_64 bundle exec rspec spec/classes/foreman_spec.rb
```

If you have more than one version of `redhat` OS specified in metadata.json,
you can run them all like:

```shell
SPEC_FACTS_OS=redhat bundle exec rspec spec/classes/foreman_spec.rb
```
For more information on running the tests, see [rspec-puppet-facts](https://github.com/mcanevet/rspec-puppet-facts)
and specifically the [section for running tests](https://github.com/mcanevet/rspec-puppet-facts#running-your-tests).

Writing Tests
-------------

Expand Down
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ gem 'puppet-lint-param-docs', '>= 1.3.0'
gem 'puppet-lint-spaceship_operator_without_tag-check'
gem 'puppet-lint-strict_indent-check'
gem 'puppet-lint-undef_in_function-check'
gem 'voxpupuli-test', '~> 1.0'
gem 'voxpupuli-test', '~> 1.3'
gem 'github_changelog_generator', '>= 1.15.0', {"groups"=>["development"]}
gem 'puppet-blacksmith', '>= 4.1.0', {"groups"=>["development"]}
gem 'voxpupuli-acceptance', '~> 0.1', {"groups"=>["system_tests"]}
gem 'puppet-blacksmith', '>= 6.0.0', {"groups"=>["development"]}
gem 'voxpupuli-acceptance', '~> 0.2', {"groups"=>["system_tests"]}

# vim:ft=ruby
3 changes: 3 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

require 'voxpupuli/test/rake'

# We use fixtures in our modules, which is not the default
task :beaker => 'spec_prep'

# blacksmith isn't always present, e.g. on Travis with --without development
begin
require 'puppet_blacksmith/rake_tasks'
Expand Down
5 changes: 5 additions & 0 deletions spec/setup_acceptance_node.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if $facts['os']['name'] == 'Ubuntu' {
package { 'cron':
ensure => installed,
}
}
13 changes: 6 additions & 7 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

ENV['BEAKER_setfile'] ||= 'centos7-64{hostname=centos7-64.example.com}'

configure_beaker do |host|
configure_beaker(modules: :fixtures) do |host|
if fact_on(host, 'os.family') == 'RedHat'
unless fact_on(host, 'os.name') == 'Fedora'
# don't delete downloaded rpm for use with BEAKER_provision=no +
Expand All @@ -11,13 +11,12 @@
end
# refresh check if cache needs refresh on next yum command
on host, 'yum clean expire-cache'
end

# this is absent in the el8 container images used for testing
if fact_on(host, 'os.release.major') == '8'
on host, puppet('resource', 'package', 'glibc-langpack-en', 'ensure=installed')
end
elsif fact_on(host, 'os.name') == 'Ubuntu'
on host, 'apt-get -qq -y install cron'
local_setup = File.join(__dir__, 'setup_acceptance_node.pp')
if File.exist?(local_setup)
puts "Configuring #{host} by applying #{local_setup}"
apply_manifest_on(host, File.read(local_setup), catch_failures: true)
end
end

Expand Down

0 comments on commit 4395709

Please sign in to comment.