diff --git a/.travis.yml b/.travis.yml index a33cd3e..60c3e49 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,30 +1,30 @@ --- env: - "PUPPET_VERSION='~> 4.5' BEAKER_set=centos6_2" - "PUPPET_VERSION='~> 4.5' BEAKER_set=centos6_3" - "PUPPET_VERSION='~> 4.5' BEAKER_set=centos7" - - "PUPPET_VERSION='~> 4.5' BEAKER_set=debian7" +# - "PUPPET_VERSION='~> 4.5' BEAKER_set=debian7" - "PUPPET_VERSION='~> 4.5' BEAKER_set=debian8" - "PUPPET_VERSION='~> 4.5' BEAKER_set=ubuntu1204" - "PUPPET_VERSION='~> 4.5' BEAKER_set=ubuntu1404" - "PUPPET_VERSION='~> 4.5' BEAKER_set=ubuntu1604" language: ruby rvm: - 2.3.1 cache: bundler before_install: rm Gemfile.lock || true bundler_args: --without development dist: trusty sudo: required script: - "bundle exec puppet --version" - "bundle exec rake metadata_lint" - "bundle exec rubocop" - "bundle exec rake lint" - "bundle exec rake validate" - "bundle exec rake spec SPEC_OPTS='--format documentation'" - "bundle exec rake acceptance" notifications: email: false matrix: fast_finish: true diff --git a/Gemfile b/Gemfile index 0469e8d..ba4d4e1 100644 --- a/Gemfile +++ b/Gemfile @@ -1,48 +1,48 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org' -puppetversion = ENV.key?('PUPPET_VERSION') ? ENV['PUPPET_VERSION'] : ['>= 3.8'] +puppetversion = ENV.key?('PUPPET_VERSION') ? ENV['PUPPET_VERSION'] : ['~> 4.0'] # github_changelog_generator must be 1.13.0 for ruby < 2.2.2 github_changelog_generator_version = RUBY_VERSION < '2.2.2' ? '~> 1.13.0' : '>= 1.13.0' group :test do gem 'coveralls', require: false gem 'facter', '>= 1.7.0' gem 'git', '1.3.0' gem 'github_changelog_generator', github_changelog_generator_version gem 'hiera', require: false gem 'httparty', require: false gem 'metadata-json-lint', require: false gem 'puppet', puppetversion gem 'puppet-blacksmith', require: false gem 'puppet-lint', require: false gem 'puppet-strings', require: false gem 'puppetlabs_spec_helper', require: false gem 'rack', '~> 1.0', require: false if RUBY_VERSION < '2.2.2' gem 'rspec-puppet', '>= 2.3.2' gem 'rspec-puppet-utils', require: false gem 'rspec_junit_formatter', require: false gem 'rubocop-rspec', '1.4.1' if RUBY_VERSION < '2.2.0' gem 'travis', require: false gem 'travis-lint', require: false gem 'yard', require: false end group :acceptance do gem 'beaker' gem 'beaker-puppet_install_helper' gem 'beaker-rspec' gem 'pry' end group :development do gem 'notes', '~> 0.1.2' end # rspec must be v2 for ruby 1.8.7 if RUBY_VERSION >= '1.8.7' && RUBY_VERSION < '1.9' gem 'rake', '~> 10.0' gem 'rspec', '~> 2.0' else # rubocop requires ruby >= 1.9 gem 'rubocop' end diff --git a/spec/acceptance/nodesets/debian7.yml b/spec/acceptance/nodesets/debian7.yml deleted file mode 100644 index a832f44..0000000 --- a/spec/acceptance/nodesets/debian7.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -CONFIG: - log_level: notice - type: foss -HOSTS: - debian7: - docker_image_commands: - - "apt-get install -y wget" - hypervisor: docker - image: "debian:7" - platform: debian-7-amd64 - roles: - - cassandra2 - - cassandra3 - - firewall diff --git a/spec/classes/datastax_agent_spec.rb b/spec/classes/datastax_agent_spec.rb index 660181e..199adff 100644 --- a/spec/classes/datastax_agent_spec.rb +++ b/spec/classes/datastax_agent_spec.rb @@ -1,141 +1,140 @@ require 'spec_helper' describe 'cassandra::datastax_agent' do let(:pre_condition) do [ 'class cassandra() {}', 'define ini_setting($ensure = nil, $path, $section, $key_val_separator = nil, $setting, $value = nil) {}' ] end context 'Test for cassandra::datastax_agent with defaults (RedHat).' do let :facts do { osfamily: 'RedHat', operatingsystemmajrelease: 6 } end it do should have_resource_count(4) should contain_class('cassandra::datastax_agent').only_with( 'defaults_file' => '/etc/default/datastax-agent', - 'java_home' => nil, 'package_ensure' => 'present', 'package_name' => 'datastax-agent', 'service_ensure' => 'running', 'service_enable' => true, 'service_name' => 'datastax-agent', 'stomp_interface' => nil, 'local_interface' => nil ) should contain_package('datastax-agent').with( ensure: 'present', notify: 'Exec[datastax_agent_reload_systemctl]' ).that_notifies('Exec[datastax_agent_reload_systemctl]') should contain_exec('datastax_agent_reload_systemctl').only_with( command: '/usr/bin/systemctl daemon-reload', onlyif: 'test -x /usr/bin/systemctl', path: ['/usr/bin', '/bin'], refreshonly: true, notify: 'Service[datastax-agent]' ).that_notifies('Service[datastax-agent]') should contain_file('/var/lib/datastax-agent/conf/address.yaml') .with( owner: 'cassandra', group: 'cassandra', mode: '0644' ).that_requires('Package[datastax-agent]') should contain_service('datastax-agent').only_with( ensure: 'running', enable: true, name: 'datastax-agent' ) end end context 'Test for cassandra::datastax_agent with defaults (Debian).' do let :facts do { osfamily: 'Debian', operatingsystemmajrelease: 6 } end it do should contain_exec('datastax_agent_reload_systemctl').with( command: '/bin/systemctl daemon-reload', onlyif: 'test -x /bin/systemctl', path: ['/usr/bin', '/bin'], refreshonly: true ).that_notifies('Service[datastax-agent]') end end context 'Test that the JAVA_HOME can be set.' do let :facts do { osfamily: 'Debian', operatingsystemmajrelease: 6 } end let :params do { java_home: '/usr/lib/jvm/java-8-oracle' } end it do should contain_ini_setting('java_home').with( ensure: 'present', path: '/etc/default/datastax-agent', section: '', key_val_separator: '=', setting: 'JAVA_HOME', value: '/usr/lib/jvm/java-8-oracle' ).that_notifies('Service[datastax-agent]') end end context 'Test settings.' do let :facts do { osfamily: 'Debian', operatingsystemmajrelease: 6 } end let :params do { settings: { 'agent_alias' => { 'setting' => 'agent_alias', 'value' => 'foobar' }, 'stomp_interface' => { 'setting' => 'stomp_interface', 'value' => 'localhost' }, 'async_pool_size' => { 'ensure' => 'absent' } } } end it do should have_resource_count(4) end end end diff --git a/spec/classes/datastax_repo_spec.rb b/spec/classes/datastax_repo_spec.rb index 60adf73..d45e7b4 100644 --- a/spec/classes/datastax_repo_spec.rb +++ b/spec/classes/datastax_repo_spec.rb @@ -1,72 +1,71 @@ require 'spec_helper' describe 'cassandra::datastax_repo' do let(:pre_condition) do [ 'class apt () {}', 'class apt::update () {}', 'define apt::key ($id, $source) {}', 'define apt::source ($location, $comment, $release, $include) {}' ] end context 'On a RedHat OS with defaults for all parameters' do let :facts do { osfamily: 'RedHat' } end it do should have_resource_count(1) should contain_class('cassandra::datastax_repo').only_with( 'descr' => 'DataStax Repo for Apache Cassandra', 'key_id' => '7E41C00F85BFC1706C4FFFB3350200F2B999A372', 'key_url' => 'http://debian.datastax.com/debian/repo_key', - 'pkg_url' => nil, 'release' => 'stable' ) should contain_yumrepo('datastax').with( ensure: 'present', descr: 'DataStax Repo for Apache Cassandra', baseurl: 'http://rpm.datastax.com/community', enabled: 1, gpgcheck: 0 ) end end context 'On a Debian OS with defaults for all parameters' do let :facts do { osfamily: 'Debian', lsbdistid: 'Ubuntu', lsbdistrelease: '14.04' } end it do should have_resource_count(3) should contain_class('apt') should contain_class('apt::update') should contain_apt__key('datastaxkey').with( id: '7E41C00F85BFC1706C4FFFB3350200F2B999A372', source: 'http://debian.datastax.com/debian/repo_key' ) should contain_apt__source('datastax').with( location: 'http://debian.datastax.com/community', comment: 'DataStax Repo for Apache Cassandra', release: 'stable', include: { 'src' => false } ).that_notifies('Exec[update-cassandra-repos]') should contain_exec('update-cassandra-repos').with( refreshonly: true, command: '/bin/true' ) end end end diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index bc43e1c..ecd65fd 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -1,405 +1,403 @@ require 'spec_helper' describe 'cassandra' do let(:pre_condition) do [ 'class apt () {}', 'class apt::update () {}', 'define apt::key ($id, $source) {}', 'define apt::source ($location, $comment, $release, $include) {}', 'define ini_setting($ensure = nil, $path, $section, $key_val_separator = nil, $setting, $value = nil) {}' ] end context 'On an unknown OS with defaults for all parameters' do let :facts do { operatingsystemmajrelease: 10, osfamily: 'Darwin' } end it { should raise_error(Puppet::Error) } end context 'Test the default parameters (RedHat)' do let :facts do { osfamily: 'RedHat', operatingsystemmajrelease: 7 } end it do should contain_package('cassandra').with( ensure: 'present', name: 'cassandra22' ).that_notifies('Exec[cassandra_reload_systemctl]') should contain_exec('cassandra_reload_systemctl').only_with( command: '/usr/bin/systemctl daemon-reload', onlyif: 'test -x /usr/bin/systemctl', path: ['/usr/bin', '/bin'], refreshonly: true ) should contain_file('/etc/cassandra/default.conf').with( ensure: 'directory', group: 'cassandra', owner: 'cassandra', mode: '0755' ).that_requires('Package[cassandra]') should contain_file('/etc/cassandra/default.conf/cassandra.yaml') .with( ensure: 'present', owner: 'cassandra', group: 'cassandra', mode: '0644' ) .that_requires('Package[cassandra]') should contain_class('cassandra').only_with( baseline_settings: {}, cassandra_2356_sleep_seconds: 5, cassandra_9822: false, cassandra_yaml_tmpl: 'cassandra/cassandra.yaml.erb', commitlog_directory_mode: '0750', config_file_mode: '0644', config_path: '/etc/cassandra/default.conf', data_file_directories_mode: '0750', dc: 'DC1', - dc_suffix: nil, fail_on_non_supported_os: true, hints_directory_mode: '0750', package_ensure: 'present', package_name: 'cassandra22', rack: 'RAC1', rackdc_tmpl: 'cassandra/cassandra-rackdc.properties.erb', saved_caches_directory_mode: '0750', service_enable: true, - # service_ensure: nil, service_name: 'cassandra', service_provider: nil, service_refresh: true, settings: {}, systemctl: '/usr/bin/systemctl' ) end end context 'On RedHat 7 with data directories specified.' do let :facts do { osfamily: 'RedHat', operatingsystemmajrelease: 7 } end let :params do { commitlog_directory: '/var/lib/cassandra/commitlog', data_file_directories: ['/var/lib/cassandra/data'], hints_directory: '/var/lib/cassandra/hints', saved_caches_directory: '/var/lib/cassandra/saved_caches', settings: { 'cluster_name' => 'MyCassandraCluster' } } end it do should have_resource_count(10) should contain_file('/var/lib/cassandra/commitlog') should contain_file('/var/lib/cassandra/data') should contain_file('/var/lib/cassandra/hints') should contain_file('/var/lib/cassandra/saved_caches') end end context 'On RedHat 7 with service provider set to init.' do let :facts do { osfamily: 'RedHat', operatingsystemmajrelease: 7 } end let :params do { service_provider: 'init' } end it do should have_resource_count(7) should contain_exec('/sbin/chkconfig --add cassandra').with( unless: '/sbin/chkconfig --list cassandra' ) .that_requires('Package[cassandra]') .that_comes_before('Service[cassandra]') end end context 'On a Debian OS with defaults for all parameters' do let :facts do { operatingsystemmajrelease: 8, osfamily: 'Debian' } end it do should contain_class('cassandra') should contain_group('cassandra').with_ensure('present') should contain_package('cassandra').with( ensure: 'present', name: 'cassandra' ).that_notifies('Exec[cassandra_reload_systemctl]') should contain_exec('cassandra_reload_systemctl').only_with( command: '/bin/systemctl daemon-reload', onlyif: 'test -x /bin/systemctl', path: ['/usr/bin', '/bin'], refreshonly: true ) should contain_service('cassandra').with( ensure: nil, name: 'cassandra', enable: 'true' ) should contain_exec('CASSANDRA-2356 sleep') .with( command: '/bin/sleep 5', refreshonly: true, user: 'root' ) .that_subscribes_to('Package[cassandra]') .that_comes_before('Service[cassandra]') should contain_user('cassandra') .with( ensure: 'present', comment: 'Cassandra database,,,', gid: 'cassandra', home: '/var/lib/cassandra', shell: '/bin/false', managehome: true ) .that_requires('Group[cassandra]') should contain_file('/etc/cassandra').with( ensure: 'directory', group: 'cassandra', owner: 'cassandra', mode: '0755' ) should contain_file('/etc/cassandra/cassandra.yaml') .with( ensure: 'present', owner: 'cassandra', group: 'cassandra', mode: '0644' ) .that_comes_before('Package[cassandra]') .that_requires(['User[cassandra]', 'File[/etc/cassandra]']) should contain_file('/etc/cassandra/cassandra-rackdc.properties') .with( ensure: 'file', owner: 'cassandra', group: 'cassandra', mode: '0644' ) .that_requires(['File[/etc/cassandra]', 'User[cassandra]']) .that_comes_before('Package[cassandra]') should contain_service('cassandra') .that_subscribes_to( [ 'File[/etc/cassandra/cassandra.yaml]', 'File[/etc/cassandra/cassandra-rackdc.properties]', 'Package[cassandra]' ] ) end end context 'CASSANDRA-9822 activated on Debian' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'Debian', lsbdistid: 'Ubuntu', lsbdistrelease: '14.04' } end let :params do { cassandra_9822: true } end it do should contain_file('/etc/init.d/cassandra').with( source: 'puppet:///modules/cassandra/CASSANDRA-9822/cassandra', mode: '0555' ).that_comes_before('Package[cassandra]') end end context 'Install DSE on a Red Hat family OS.' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end let :params do { package_ensure: '4.7.0-1', package_name: 'dse-full', config_path: '/etc/dse/cassandra', service_name: 'dse' } end it do should contain_file('/etc/dse/cassandra/cassandra.yaml').that_notifies('Service[cassandra]') should contain_file('/etc/dse/cassandra') should contain_file('/etc/dse/cassandra/cassandra-rackdc.properties') .with( ensure: 'file', owner: 'cassandra', group: 'cassandra', mode: '0644' ) .that_notifies('Service[cassandra]') should contain_package('cassandra').with( ensure: '4.7.0-1', name: 'dse-full' ) is_expected.to contain_service('cassandra').with_name('dse') end end context 'On an unsupported OS pleading tolerance' do let :facts do { operatingsystemmajrelease: 10, osfamily: 'Darwin' } end let :params do { config_file_mode: '0755', config_path: '/etc/cassandra', fail_on_non_supported_os: false, package_name: 'cassandra', service_provider: 'base', systemctl: '/bin/true' } end it do should contain_file('/etc/cassandra/cassandra.yaml').with('mode' => '0755') should contain_service('cassandra').with(provider: 'base') should have_resource_count(6) end end context 'Ensure cassandra service can be stopped and disabled.' do let :facts do { operatingsystemmajrelease: 8, osfamily: 'Debian' } end let :params do { service_ensure: 'stopped', service_enable: 'false' } end it do should contain_service('cassandra') .with(ensure: 'stopped', name: 'cassandra', enable: 'false') end end context 'Test the dc and rack properties with defaults (Debian).' do let :facts do { operatingsystemmajrelease: 8, osfamily: 'Debian' } end it do should contain_file('/etc/cassandra/cassandra-rackdc.properties') .with_content(/^dc=DC1/) .with_content(/^rack=RAC1$/) .with_content(/^#dc_suffix=$/) .with_content(/^# prefer_local=true$/) end end context 'Test the dc and rack properties with defaults (RedHat).' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end it do should contain_file('/etc/cassandra/default.conf/cassandra-rackdc.properties') .with_content(/^dc=DC1/) .with_content(/^rack=RAC1$/) .with_content(/^#dc_suffix=$/) .with_content(/^# prefer_local=true$/) end end context 'Test the dc and rack properties.' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end let :params do { snitch_properties_file: 'cassandra-topology.properties', dc: 'NYC', rack: 'R101', dc_suffix: '_1_cassandra', prefer_local: 'true' } end it do should contain_file('/etc/cassandra/default.conf/cassandra-topology.properties') .with_content(/^dc=NYC$/) .with_content(/^rack=R101$/) .with_content(/^dc_suffix=_1_cassandra$/) .with_content(/^prefer_local=true$/) end end end diff --git a/spec/classes/schema_spec.rb b/spec/classes/schema_spec.rb index 5d9867f..9d8bbd4 100644 --- a/spec/classes/schema_spec.rb +++ b/spec/classes/schema_spec.rb @@ -1,143 +1,142 @@ require 'spec_helper' describe 'cassandra::schema' do let(:pre_condition) do [ 'define ini_setting($ensure = nil, $path, $section, $key_val_separator = nil, $setting, $value = nil) {}' ] end context 'Ensure that a connection test is made.' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end it do should contain_class('cassandra::schema') .with(connection_tries: 6, connection_try_sleep: 30, cqlsh_additional_options: '', cqlsh_command: '/usr/bin/cqlsh', cqlsh_host: 'localhost', cqlsh_password: nil, cqlsh_port: 9042, - cqlsh_user: 'cassandra', - keyspaces: []) + cqlsh_user: 'cassandra') read_command = '/usr/bin/cqlsh -e \'DESC KEYSPACES\' localhost 9042' should contain_exec('::cassandra::schema connection test') .only_with(command: read_command, returns: 0, tries: 6, try_sleep: 30, unless: read_command) end end context 'Test that users can specify a credentials file.' do let :facts do { id: 'root', gid: 'root', operatingsystemmajrelease: 7, osfamily: 'Debian' } end let :params do { cqlsh_client_config: '/root/.puppetcqlshrc' } end it do should contain_file('/root/.puppetcqlshrc').with( ensure: 'file', group: 'root', mode: '0600', owner: 'root', content: /username = cassandra/ ).that_comes_before('Exec[::cassandra::schema connection test]') read_command = "/usr/bin/cqlsh --cqlshrc=/root/.puppetcqlshrc -e 'DESC KEYSPACES' localhost 9042" should contain_exec('::cassandra::schema connection test') .only_with(command: read_command, returns: 0, tries: 6, try_sleep: 30, unless: read_command) end end context 'Test that users can specify a credentials file and password.' do let :facts do { id: 'root', gid: 'root', operatingsystemmajrelease: 7, osfamily: 'Debian' } end let :params do { cqlsh_client_config: '/root/.puppetcqlshrc', cqlsh_password: 'topsecret' } end it do should contain_file('/root/.puppetcqlshrc').with( ensure: 'file', group: 'root', mode: '0600', owner: 'root', content: /password = topsecret/ ) read_command = "/usr/bin/cqlsh --cqlshrc=/root/.puppetcqlshrc -e 'DESC KEYSPACES' localhost 9042" should contain_exec('::cassandra::schema connection test') .only_with(command: read_command, returns: 0, tries: 6, try_sleep: 30, unless: read_command) end end context 'Test that users can specify a password.' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'Redhat' } end let :params do { cqlsh_password: 'topsecret' } end it do read_command = "/usr/bin/cqlsh -u cassandra -p topsecret -e 'DESC KEYSPACES' localhost 9042" should contain_exec('::cassandra::schema connection test') .only_with(command: read_command, returns: 0, tries: 6, try_sleep: 30, unless: read_command) end end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 45563ff..6ccfb01 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,508 +1,508 @@ require 'beaker-rspec' require 'pry' class TestManifests def initialize(roles, version) # Instance variables @roles = roles @version = version if version == 2.1 init21 elsif version == 2.2 init22 elsif version == 3.0 init30 end end def init21 @debian_release = '21x' - @debian_package_ensure = '2.1.17' + @debian_package_ensure = '2.1.18' @redhat_package_ensure = '2.1.15-1' @cassandra_optutils_package = 'cassandra21-tools' @cassandra_package = 'cassandra21' end def init22 @debian_release = '22x' - @debian_package_ensure = '2.2.9' + @debian_package_ensure = '2.2.10' @redhat_package_ensure = '2.2.8-1' @cassandra_optutils_package = 'cassandra22-tools' @cassandra_package = 'cassandra22' end def init30 @debian_release = '30x' - @debian_package_ensure = '3.0.13' + @debian_package_ensure = '3.0.14' @redhat_package_ensure = '3.0.9-1' @cassandra_optutils_package = 'cassandra30-tools' @cassandra_package = 'cassandra30' end def bootstrap_pp <<-EOS Exec { path => [ '/usr/local/bin', '/opt/local/bin', '/usr/bin', '/usr/sbin', '/bin', '/sbin'], logoutput => true, } notify { "${::operatingsystem}-${::operatingsystemmajrelease}": } file { '/etc/dse': ensure => directory, } -> file { '/etc/dse/dse-env.sh': ensure => present, content => "#export DSE_HOME\n# export HADOOP_LOG_DIR=", } case downcase("${::operatingsystem}-${::operatingsystemmajrelease}") { 'centos-6': { package { ['gcc', 'tar', 'yum-utils', 'centos-release-scl']: } -> exec { 'yum-config-manager --enable rhel-server-rhscl-7-rpms': } -> package { 'ruby200': } -> package { 'python27-python': ensure => '2.7.8-18.el6', } -> exec { 'cp /opt/rh/python27/enable /etc/profile.d/python.sh': } -> exec { 'echo "\n" >> /etc/profile.d/python.sh': } -> exec { 'echo "export PYTHONPATH=/usr/lib/python2.7/site-packages" >> /etc/profile.d/python.sh': } -> exec { '/bin/cp /opt/rh/ruby200/enable /etc/profile.d/ruby.sh': } -> exec { '/bin/rm /usr/bin/ruby /usr/bin/gem': } -> exec { '/usr/sbin/alternatives --install /usr/bin/ruby ruby /opt/rh/ruby200/root/usr/bin/ruby 1000': } -> exec { '/usr/sbin/alternatives --install /usr/bin/gem gem /opt/rh/ruby200/root/usr/bin/gem 1000': } } 'centos-7': { package { ['gcc', 'tar', 'initscripts']: } } 'debian-7': { package { ['sudo', 'ufw', 'wget']: } } 'debian-8': { package { ['locales-all', 'net-tools', 'sudo', 'ufw']: } -> file { '/usr/sbin/policy-rc.d': ensure => absent, } } 'ubuntu-12.04': { package {['python-software-properties', 'iptables', 'sudo']:} -> exec {'/usr/bin/apt-add-repository ppa:brightbox/ruby-ng':} -> exec {'/usr/bin/apt-get update': } -> package {'ruby2.0': } -> exec { '/bin/rm /usr/bin/ruby': } -> exec { '/usr/sbin/update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby2.0 1000': } } 'ubuntu-16.04': { package { ['locales-all', 'net-tools', 'sudo', 'ufw']: } -> file { '/usr/sbin/policy-rc.d': ensure => absent, } } } EOS end def cassandra_install_pp <<-EOS if $::osfamily == 'Debian' { class { 'cassandra::apache_repo': release => '#{@debian_release}', before => Class['cassandra', 'cassandra::optutils'], } $package_ensure = '#{@debian_package_ensure}' $cassandra_package = 'cassandra' $cassandra_optutils_package = 'cassandra-tools' } else { class { 'cassandra::datastax_repo': before => Class['cassandra', 'cassandra::optutils'], } $package_ensure = '#{@redhat_package_ensure}' $cassandra_package = '#{@cassandra_package}' $cassandra_optutils_package = '#{@cassandra_optutils_package}' } require cassandra::system::swapoff require cassandra::system::transparent_hugepage include cassandra::java if versioncmp($::rubyversion, '1.9.0') < 0 { $service_refresh = false } else { $service_refresh = true } if #{@version} >= 3.0 { class { 'cassandra': hints_directory => '/var/lib/cassandra/hints', package_ensure => $package_ensure, package_name => $cassandra_package, service_refresh => $service_refresh, require => Class['cassandra::java'], } } else { class { 'cassandra': package_ensure => $package_ensure, package_name => $cassandra_package, service_refresh => $service_refresh, require => Class['cassandra::java'], } } class { 'cassandra::optutils': package_ensure => $package_ensure, package_name => $cassandra_optutils_package, require => Class['cassandra'] } if $::osfamily == 'RedHat' { class { 'cassandra::datastax_agent': require => Class['cassandra'] } } #{firewall_pp} include cassandra::dse EOS end def cassandra_uninstall_pp <<-EOS Exec { path => [ '/usr/bin', '/bin' ], logoutput => true, } if $::osfamily == 'RedHat' { $cassandra_optutils_package = '#{@cassandra_optutils_package}' $cassandra_package = '#{@cassandra_package}' } else { $cassandra_optutils_package = 'cassandra-tools' $cassandra_package = 'cassandra' } service { 'cassandra': ensure => stopped, } -> package { $cassandra_optutils_package: ensure => purged, } -> package { $cassandra_package: ensure => purged, } -> exec { 'rm -rf /var/lib/cassandra/*/* /var/log/cassandra/*': } EOS end def facts_testing_pp <<-EOS #{cassandra_install_pp} if $::osfamily == 'Debian' { $package_comparison = $cassandrarelease } else { $package_comparison = "${cassandrarelease}-1" } if $package_comparison != $package_ensure { fail("cassandrarelease: ${package_comparison} != ${package_ensure}") } if $::cassandramaxheapsize <= 0 { fail('cassandramaxheapsize is not set.') } if $::cassandracmsmaxheapsize <= 0 { fail('cassandracmsmaxheapsize is not set.') } if $::cassandraheapnewsize <= 0 { fail('cassandraheapnewsize is not set.') } if $::cassandracmsheapnewsize <= 0 { fail('cassandracmsheapnewsize is not set.') } EOS end def firewall_pp pp = if @roles.include? 'firewall' <<-EOS class { '::cassandra::firewall_ports': require => Class['::cassandra'], } EOS else <<-EOS # Firewall test skipped EOS end pp end def permissions_revoke_pp <<-EOS #{cassandra_install_pp} class { 'cassandra::schema': cqlsh_password => 'Niner2', cqlsh_user => 'akers', cqlsh_client_config => '/root/.puppetcqlshrc', permissions => { 'Revoke select permissions to spillman to all keyspaces' => { ensure => absent, permission_name => 'SELECT', user_name => 'spillman', }, 'Revoke modify to to keyspace mykeyspace to akers' => { ensure => absent, keyspace_name => 'mykeyspace', permission_name => 'MODIFY', user_name => 'akers', }, 'Revoke alter permissions to mykeyspace to boone' => { ensure => absent, keyspace_name => 'mykeyspace', permission_name => 'ALTER', user_name => 'boone', }, 'Revoke ALL permissions to mykeyspace.users to gbennet' => { ensure => absent, keyspace_name => 'mykeyspace', permission_name => 'ALTER', table_name => 'users', user_name => 'gbennet', }, }, } EOS end def schema_create_pp <<-EOS #{cassandra_install_pp} $cql_types = { 'fullname' => { 'keyspace' => 'mykeyspace', 'fields' => { 'fname' => 'text', 'lname' => 'text', }, }, } $keyspaces = { 'mykeyspace' => { ensure => present, replication_map => { keyspace_class => 'SimpleStrategy', replication_factor => 1, }, durable_writes => false, }, } class { 'cassandra::schema': cql_types => $cql_types, cqlsh_password => 'cassandra', cqlsh_user => 'cassandra', indexes => { 'users_lname_idx' => { keyspace => 'mykeyspace', table => 'users', keys => 'lname', }, }, keyspaces => $keyspaces, tables => { 'users' => { 'keyspace' => 'mykeyspace', 'columns' => { 'userid' => 'int', 'fname' => 'text', 'lname' => 'text', 'PRIMARY KEY' => '(userid)', }, }, }, permissions => { 'Grant select permissions to spillman to all keyspaces' => { permission_name => 'SELECT', user_name => 'spillman', }, 'Grant modify to to keyspace mykeyspace to akers' => { keyspace_name => 'mykeyspace', permission_name => 'MODIFY', user_name => 'akers', }, 'Grant alter permissions to mykeyspace to boone' => { keyspace_name => 'mykeyspace', permission_name => 'ALTER', user_name => 'boone', }, 'Grant ALL permissions to mykeyspace.users to gbennet' => { keyspace_name => 'mykeyspace', permission_name => 'ALTER', table_name => 'users', user_name => 'gbennet', }, }, users => { 'akers' => { password => 'Niner2', superuser => true, }, 'boone' => { password => 'Niner75', }, 'gbennet' => { password => 'Strewth', }, 'spillman' => { password => 'Niner27', }, 'bob' => { password => 'kaZe89a', login => false, }, 'john' => { superuser => true, password => 'kaZe89a', login => true, }, }, } EOS end def schema_drop_index_pp <<-EOS #{cassandra_install_pp} class { 'cassandra::schema': cqlsh_user => 'akers', cqlsh_password => 'Niner2', indexes => { 'users_lname_idx' => { ensure => absent, keyspace => 'mykeyspace', table => 'users', }, }, } EOS end def schema_drop_table_pp <<-EOS #{cassandra_install_pp} class { 'cassandra::schema': cqlsh_password => 'Niner2', cqlsh_user => 'akers', tables => { 'users' => { ensure => absent, keyspace => 'mykeyspace', }, }, } EOS end def schema_drop_keyspace_pp <<-EOS #{cassandra_install_pp} $keyspaces = { 'mykeyspace' => { ensure => absent, } } class { 'cassandra::schema': cqlsh_password => 'Niner2', cqlsh_user => 'akers', keyspaces => $keyspaces, } EOS end def schema_drop_type_pp pp = <<-EOS #{cassandra_install_pp} $cql_types = { 'fullname' => { 'keyspace' => 'mykeyspace', 'ensure' => 'absent' } } class { 'cassandra::schema': cql_types => $cql_types, cqlsh_user => 'akers', cqlsh_password => 'Niner2', } EOS pp end def schema_drop_user_pp pp = <<-EOS #{cassandra_install_pp} class { 'cassandra::schema': cqlsh_password => 'Niner2', cqlsh_user => 'akers', cqlsh_client_config => '/root/.puppetcqlshrc', users => { 'boone' => { ensure => absent, }, }, } EOS pp end end hosts.each do |host| case host.name when 'ubuntu1604' host.install_package('puppet') else install_puppet_on(host) end end RSpec.configure do |c| module_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) c.formatter = :documentation # Configure all nodes in nodeset c.before :suite do # Install modules puppet_module_install(source: module_root, module_name: 'cassandra') hosts.each do |host| on host, puppet('module', 'install', 'puppetlabs-apt'), acceptable_exit_codes: [0, 1] on host, puppet('module', 'install', 'puppetlabs-firewall'), acceptable_exit_codes: [0, 1] on host, puppet('module', 'install', 'puppetlabs-inifile'), acceptable_exit_codes: [0, 1] on host, puppet('module', 'install', 'puppetlabs-stdlib'), acceptable_exit_codes: [0, 1] # Install hiera write_hiera_config_on(host, [ 'environments/%{environment}/data/fqdn/%{fqdn}', 'environments/%{environment}/data/osfamily/%{osfamily}/%{lsbdistcodename}', 'environments/%{environment}/data/osfamily/%{osfamily}/%{lsbmajdistrelease}', 'environments/%{environment}/data/osfamily/%{osfamily}/%{architecture}', 'environments/%{environment}/data/osfamily/%{osfamily}/common', # 'environments/%{environment}/data/modules/%{cname}', 'environments/%{environment}/data/modules/%{caller_module_name}', 'environments/%{environment}/data/modules/%{module_name}', 'environments/%{environment}/data/common' ]) copy_hiera_data_to(host, './spec/acceptance/hieradata/') end end end