diff --git a/Gemfile b/Gemfile index 9a361308..1432103d 100644 --- a/Gemfile +++ b/Gemfile @@ -1,11 +1,11 @@ source 'https://rubygems.org' -group :development, :test do - gem 'puppetlabs_spec_helper', :require => false - gem 'puppet-lint', '~> 0.3.2' -end - +gem 'puppetlabs_spec_helper' +gem 'puppet-lint' gem 'json' +gem 'rspec-puppet', :git => 'https://github.com/rodjek/rspec-puppet.git' +gem 'rake' +gem 'puppet-syntax' if puppetversion = ENV['PUPPET_GEM_VERSION'] gem 'puppet', puppetversion, :require => false diff --git a/Rakefile b/Rakefile index 6f883b30..6230cc29 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,6 @@ require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-lint/tasks/puppet-lint' +require 'puppet-syntax/tasks/puppet-syntax' PuppetLint.configuration.fail_on_warnings = true PuppetLint.configuration.send('disable_80chars') @@ -8,7 +9,15 @@ PuppetLint.configuration.send('disable_class_parameter_defaults') # For stonith-enabled (it's a string not a bool) PuppetLint.configuration.send('disable_quoted_booleans') # Ignore all upstream modules -PuppetLint.configuration.ignore_paths = ['spec/fixtures/modules/**/*.pp','examples/*.pp'] +exclude_paths = ['spec/**/*','pkg/**/*','vendor/**/*'] +exclude_lint_paths = exclude_paths + ['examples/*.pp'] + +PuppetLint.configuration.ignore_paths = exclude_lint_paths +PuppetSyntax.exclude_paths = exclude_paths + task(:default).clear task :default => [:spec_prep, :spec_standalone, :lint] + +desc 'Run syntax, lint and spec tests' +task :test => [:syntax,:lint,:spec] diff --git a/examples/params.pp b/examples/params.pp index 92d68b6f..93659787 100644 --- a/examples/params.pp +++ b/examples/params.pp @@ -71,9 +71,9 @@ class os_params { $lb_internal_netif = $internal_netif $swift_zone = { - 'swiftstore1' => 1, + 'swiftstore1' => 1, 'swiftstore2' => 2, - 'swiftstore3' => 3, + 'swiftstore3' => 3 } $galera_master_name = $mgmt_names[0] @@ -83,12 +83,12 @@ class os_params { $galera_nextserver = { "${galera_master_name}" => $mgmt_internal_ips[0], "${mgmt_names[1]}" => $mgmt_internal_ips[1], - "${mgmt_names[2]}" => $mgmt_internal_ips[2], + "${mgmt_names[2]}" => $mgmt_internal_ips[2] } $ceph_version = 'cuttlefish' - $ceph_names = ['cephstore1', 'cephstore2', 'cephstore3'] + $ceph_names = ['cephstore1','cephstore2','cephstore3'] $ceph_osd_devices = ['sdb','sdc','sdd'] @@ -99,9 +99,11 @@ class os_params { $args = get_scope_args() $schema = { - 'ntp_servers' => { - 'type' => 'any', - 'required' => true, + 'type' => 'map', + 'mapping' => { + 'ntp_servers' => { + 'type' => 'any', + 'required' => true, }, 'compute' => { 'type' => 'bool', @@ -324,10 +326,10 @@ class os_params { # Red Hat Network registration $rhn_registration = { - username => 'rhn', - password => 'pass', - server_url => 'https://rhn.redhat.com/rpc/api', - force => true, + username => 'rhn', + password => 'pass', + server_url => 'https://rhn.redhat.com/rpc/api', + force => true } # OpenStack Identity @@ -389,17 +391,17 @@ class os_params { $keepalived_email = ["dev@${site_domain}"] $keepalived_smtp = "${smtp_name}.${site_domain}" $keepalived_localhost_ip = $lb_internal_netif_ip - $haproxy_auth = 'root:secrete' + $haproxy_auth = 'root:secrete' # Horizon $horizon_port = '80' - $secret_key = 'secrete' + $secret_key = 'secrete' # RabbitMQ #FIXME: https://github.com/enovance/puppet-cloud/issues/14 $rabbit_names = $mgmt_names $rabbit_host = $mgmt_internal_ips[0] - $rabbit_hosts = suffix($mgmt_internal_ips, ':5672') + $rabbit_hosts = suffix($mgmt_internal_ips,':5672') $rabbit_password = 'secrete' # Useful when we need a single Rabbit host (like Sensu needs) $rabbit_main_host = $mgmt_internal_ips[0] @@ -447,8 +449,8 @@ class os_params { $spice_port = '6082' $nova_rbd_user = 'nova' $nova_rbd_pool = 'vm' - $nova_ssh_public_key='ssh-rsa XXX nova@openstack' - $nova_ssh_private_key=' + $nova_ssh_public_key = 'ssh-rsa XXX nova@openstack' + $nova_ssh_private_key = ' -----BEGIN RSA PRIVATE KEY----- XXX -----END RSA PRIVATE KEY----- @@ -486,7 +488,7 @@ XXX $ks_ceilometer_public_port = '8777' $ks_ceilometer_public_proto = 'http' $replset_members = $mgmt_internal_ips - $mongo_nodes = $mgmt_internal_ips + $mongo_nodes = $mgmt_internal_ips # Cinder $cinder_db_allowed_hosts = $db_allowed_hosts diff --git a/spec/classes/cloud_init_spec.rb b/spec/classes/cloud_init_spec.rb index 58e35832..cc2d9924 100644 --- a/spec/classes/cloud_init_spec.rb +++ b/spec/classes/cloud_init_spec.rb @@ -95,9 +95,7 @@ describe 'cloud' do { :osfamily => 'Solaris' } end - it 'should fail' do - expect { subject }.to raise_error(/module puppet-cloud only support/) - end - end + it { should compile.and_raise_error(/module puppet-cloud only support/) } + end end diff --git a/spec/classes/cloud_network_dhcp_spec.rb b/spec/classes/cloud_network_dhcp_spec.rb index fae78774..e04dc2bd 100644 --- a/spec/classes/cloud_network_dhcp_spec.rb +++ b/spec/classes/cloud_network_dhcp_spec.rb @@ -88,7 +88,7 @@ describe 'cloud::network::dhcp' do :owner => 'root', :group => 'root' ) - verify_contents(subject, '/etc/neutron/dnsmasq-neutron.conf', ["dhcp-option-force=26,1400"]) + should contain_file('/etc/neutron/dnsmasq-neutron.conf').with_content(/^dhcp-option-force=26,1400$/) end end diff --git a/spec/classes/coverage_spec.rb b/spec/classes/coverage_spec.rb new file mode 100644 index 00000000..12513b83 --- /dev/null +++ b/spec/classes/coverage_spec.rb @@ -0,0 +1 @@ +at_exit { RSpec::Puppet::Coverage.report! }