diff --git a/lib/facter/cassandrarelease.rb b/lib/facter/cassandrarelease.rb index 78ba9f9..13bf139 100644 --- a/lib/facter/cassandrarelease.rb +++ b/lib/facter/cassandrarelease.rb @@ -1,14 +1,14 @@ # Extract the release string from the running Cassandra instance. # # @resolution # Runs the command "nodetool version". # @caveats # The Cassandra service needs to be running, otherwise the fact will be # undefined. # @return [string] The version string (e.g. 3.0.1). Facter.add('cassandrarelease') do setcode do version = Facter::Util::Resolution.exec('nodetool version') - version.match(/\d+\.\d+\.\d+/).to_s if version && version != '' + version.match(%r{\d+\.\d+\.\d+}).to_s if version && version != '' end end diff --git a/spec/acceptance/cassandra_spec.rb b/spec/acceptance/cassandra_spec.rb index 14ec230..d7f4716 100644 --- a/spec/acceptance/cassandra_spec.rb +++ b/spec/acceptance/cassandra_spec.rb @@ -1,128 +1,128 @@ require 'spec_helper_acceptance' describe 'cassandra' do roles = hosts[0]['roles'] versions = [] versions.push(2.1) if roles.include? 'cassandra2' versions.push(2.2) if roles.include? 'cassandra2' versions.push(3.0) if roles.include? 'cassandra3' versions.each do |version| t = TestManifests.new(roles, version, fact('operatingsystemmajrelease')) describe "Cassandra #{version} installation." do # firewall_pp = t.firewall_pp() cassandra_install_pp = t.cassandra_install_pp - it 'should work with no errors' do + it 'works with no errors' do apply_manifest(cassandra_install_pp, catch_failures: true) end it 'check code is idempotent' do expect(apply_manifest(cassandra_install_pp, catch_failures: true).exit_code).to be_zero end end describe service('cassandra') do it "check Cassandra-#{version} is running and enabled" do is_expected.to be_running is_expected.to be_enabled end end if fact('osfamily') == 'RedHat' describe service('datastax-agent') do it 'check service status' do is_expected.to be_running is_expected.to be_enabled end end end describe "Create schema for #{version}." do - it 'should work with no errors' do + it 'works with no errors' do apply_manifest(t.schema_create_pp, catch_failures: true) end if version != 2.1 it 'check code is idempotent' do expect(apply_manifest(t.schema_create_pp, catch_failures: true).exit_code).to be_zero end end end describe "Schema drop type for #{version}." do - it 'should work with no errors' do + it 'works with no errors' do apply_manifest(t.schema_drop_type_pp, catch_failures: true) end it 'check code is idempotent' do expect(apply_manifest(t.schema_drop_type_pp, catch_failures: true).exit_code).to be_zero end end describe "Revoke permissions for #{version}." do - it 'should work with no errors' do + it 'works with no errors' do apply_manifest(t.permissions_revoke_pp, catch_failures: true) end it 'check code is idempotent' do expect(apply_manifest(t.permissions_revoke_pp, catch_failures: true).exit_code).to be_zero end end describe "Drop user for #{version}" do - it 'should work with no errors' do + it 'works with no errors' do apply_manifest(t.schema_drop_user_pp, catch_failures: true) end it 'check code is idempotent' do expect(apply_manifest(t.schema_drop_user_pp, catch_failures: true).exit_code).to be_zero end end describe "Drop index for #{version}" do - it 'should work with no errors' do + it 'works with no errors' do apply_manifest(t.schema_drop_index_pp, catch_failures: true) end it 'check code is idempotent' do expect(apply_manifest(t.schema_drop_index_pp, catch_failures: true).exit_code).to be_zero end end describe "Drop table for #{version}" do - it 'should work with no errors' do + it 'works with no errors' do apply_manifest(t.schema_drop_table_pp, catch_failures: true) end it 'check code is idempotent' do expect(apply_manifest(t.schema_drop_table_pp, catch_failures: true).exit_code).to be_zero end end describe "Drop keyspace for #{version}" do - it 'should work with no errors' do + it 'works with no errors' do apply_manifest(t.schema_drop_keyspace_pp, catch_failures: true) end it 'check code is idempotent' do expect(apply_manifest(t.schema_drop_keyspace_pp, catch_failures: true).exit_code).to be_zero end end describe "Facts Tests for #{version}" do - it 'should work with no errors' do + it 'works with no errors' do apply_manifest(t.facts_testing_pp, catch_failures: true) end end next unless version != 3.0 describe "Uninstall #{version}." do - it 'should work with no errors' do + it 'works with no errors' do apply_manifest(t.cassandra_uninstall_pp, catch_failures: true) end end end end diff --git a/spec/classes/apache_repo_spec.rb b/spec/classes/apache_repo_spec.rb index 7d46212..c6fd301 100644 --- a/spec/classes/apache_repo_spec.rb +++ b/spec/classes/apache_repo_spec.rb @@ -1,78 +1,78 @@ require 'spec_helper' describe 'cassandra::apache_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 let :params do { release: '311x' } end it do - should have_resource_count(1) + is_expected.to have_resource_count(1) - should contain_class('cassandra::apache_repo').only_with( + is_expected.to contain_class('cassandra::apache_repo').only_with( 'descr' => 'Repo for Apache Cassandra', 'key_id' => 'A26E528B271F19B9E5D8E19EA278B781FE4B2BDA', 'key_url' => 'https://www.apache.org/dist/cassandra/KEYS', 'release' => '311x' ) - should contain_yumrepo('cassandra_apache').with( + is_expected.to contain_yumrepo('cassandra_apache').with( ensure: 'present', descr: 'Repo for Apache Cassandra', baseurl: 'http://www.apache.org/dist/cassandra/redhat/311x', enabled: 1, gpgcheck: 1, gpgkey: 'https://www.apache.org/dist/cassandra/KEYS' ) 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') + is_expected.to have_resource_count(3) + is_expected.to contain_class('apt') + is_expected.to contain_class('apt::update') - should contain_apt__key('apache.cassandra').with( + is_expected.to contain_apt__key('apache.cassandra').with( id: 'A26E528B271F19B9E5D8E19EA278B781FE4B2BDA', source: 'https://www.apache.org/dist/cassandra/KEYS' ) - should contain_apt__source('cassandra.sources').with( + is_expected.to contain_apt__source('cassandra.sources').with( location: 'http://www.apache.org/dist/cassandra/debian', comment: 'Repo for Apache Cassandra', release: 'main', include: { 'src' => false } ).that_notifies('Exec[update-apache-cassandra-repo]') - should contain_exec('update-apache-cassandra-repo').with( + is_expected.to contain_exec('update-apache-cassandra-repo').with( refreshonly: true, command: '/bin/true' ) end end end diff --git a/spec/classes/datastax_agent_spec.rb b/spec/classes/datastax_agent_spec.rb index 199adff..7f71f19 100644 --- a/spec/classes/datastax_agent_spec.rb +++ b/spec/classes/datastax_agent_spec.rb @@ -1,140 +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) + is_expected.to have_resource_count(4) - should contain_class('cassandra::datastax_agent').only_with( + is_expected.to contain_class('cassandra::datastax_agent').only_with( 'defaults_file' => '/etc/default/datastax-agent', '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( + is_expected.to 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( + is_expected.to 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( + is_expected.to 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( + is_expected.to 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( + is_expected.to 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( + is_expected.to 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) + is_expected.to have_resource_count(4) end end end diff --git a/spec/classes/datastax_repo_spec.rb b/spec/classes/datastax_repo_spec.rb index d45e7b4..04b1886 100644 --- a/spec/classes/datastax_repo_spec.rb +++ b/spec/classes/datastax_repo_spec.rb @@ -1,71 +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) + is_expected.to have_resource_count(1) - should contain_class('cassandra::datastax_repo').only_with( + is_expected.to 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', 'release' => 'stable' ) - should contain_yumrepo('datastax').with( + is_expected.to 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') + is_expected.to have_resource_count(3) + is_expected.to contain_class('apt') + is_expected.to contain_class('apt::update') - should contain_apt__key('datastaxkey').with( + is_expected.to contain_apt__key('datastaxkey').with( id: '7E41C00F85BFC1706C4FFFB3350200F2B999A372', source: 'http://debian.datastax.com/debian/repo_key' ) - should contain_apt__source('datastax').with( + is_expected.to 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( + is_expected.to contain_exec('update-cassandra-repos').with( refreshonly: true, command: '/bin/true' ) end end end diff --git a/spec/classes/dse_spec.rb b/spec/classes/dse_spec.rb index ce93cab..7f18b1f 100644 --- a/spec/classes/dse_spec.rb +++ b/spec/classes/dse_spec.rb @@ -1,28 +1,28 @@ require 'spec_helper' describe 'cassandra::dse' do let(:pre_condition) do [ 'class stdlib () {}', 'define file_line($line, $path, $match) {}' ] end context 'with defaults for all parameters' do let :facts do { osfamily: 'RedHat', operatingsystemmajrelease: 7 } end it do - should have_resource_count(6) - should contain_class('cassandra') + is_expected.to have_resource_count(6) + is_expected.to contain_class('cassandra') - should contain_class('cassandra::dse').with( + is_expected.to contain_class('cassandra::dse').with( config_file_mode: '0644', config_file: '/etc/dse/dse.yaml' ) end end end diff --git a/spec/classes/firewall_ports_spec.rb b/spec/classes/firewall_ports_spec.rb index edc7f89..ff316f4 100644 --- a/spec/classes/firewall_ports_spec.rb +++ b/spec/classes/firewall_ports_spec.rb @@ -1,30 +1,30 @@ require 'spec_helper' describe 'cassandra::firewall_ports' do let(:pre_condition) do [ 'class cassandra () {}', 'define firewall ($action, $dport, $proto, $source) {}' ] end context 'Run with defaults.' do it do - should have_resource_count(2) - should contain_firewall('200 - Cassandra (Public) - 0.0.0.0/0') + is_expected.to have_resource_count(2) + is_expected.to contain_firewall('200 - Cassandra (Public) - 0.0.0.0/0') - should contain_class('cassandra::firewall_ports').with( + is_expected.to contain_class('cassandra::firewall_ports').with( client_ports: [9042, 9160], client_subnets: ['0.0.0.0/0'], inter_node_ports: [7000, 7001, 7199], inter_node_subnets: ['0.0.0.0/0'], public_ports: [8888], public_subnets: ['0.0.0.0/0'], ssh_port: 22, opscenter_ports: [9042, 9160, 61_620, 61_621], opscenter_subnets: ['0.0.0.0/0'] ) - should contain_cassandra__private__firewall_ports__rule('200_Public_0.0.0.0/0').with(ports: [8888, 22]) + is_expected.to contain_cassandra__private__firewall_ports__rule('200_Public_0.0.0.0/0').with(ports: [8888, 22]) end end end diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index ecd65fd..0c4e888 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -1,403 +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) } + it { is_expected.to 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( + is_expected.to contain_package('cassandra').with( ensure: 'present', name: 'cassandra22' ).that_notifies('Exec[cassandra_reload_systemctl]') - should contain_exec('cassandra_reload_systemctl').only_with( + is_expected.to 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( + is_expected.to 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( + is_expected.to contain_file('/etc/cassandra/default.conf/cassandra.yaml'). + with( ensure: 'present', owner: 'cassandra', group: 'cassandra', mode: '0644' - ) - .that_requires('Package[cassandra]') + ). + that_requires('Package[cassandra]') - should contain_class('cassandra').only_with( + is_expected.to 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', 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_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') + is_expected.to have_resource_count(10) + is_expected.to contain_file('/var/lib/cassandra/commitlog') + is_expected.to contain_file('/var/lib/cassandra/data') + is_expected.to contain_file('/var/lib/cassandra/hints') + is_expected.to 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( + is_expected.to have_resource_count(7) + is_expected.to contain_exec('/sbin/chkconfig --add cassandra').with( unless: '/sbin/chkconfig --list cassandra' - ) - .that_requires('Package[cassandra]') - .that_comes_before('Service[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') + is_expected.to contain_class('cassandra') + is_expected.to contain_group('cassandra').with_ensure('present') - should contain_package('cassandra').with( + is_expected.to contain_package('cassandra').with( ensure: 'present', name: 'cassandra' ).that_notifies('Exec[cassandra_reload_systemctl]') - should contain_exec('cassandra_reload_systemctl').only_with( + is_expected.to 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( + is_expected.to contain_service('cassandra').with( ensure: nil, name: 'cassandra', enable: 'true' ) - should contain_exec('CASSANDRA-2356 sleep') - .with( + is_expected.to contain_exec('CASSANDRA-2356 sleep'). + with( command: '/bin/sleep 5', refreshonly: true, user: 'root' - ) - .that_subscribes_to('Package[cassandra]') - .that_comes_before('Service[cassandra]') + ). + that_subscribes_to('Package[cassandra]'). + that_comes_before('Service[cassandra]') - should contain_user('cassandra') - .with( + is_expected.to contain_user('cassandra'). + with( ensure: 'present', comment: 'Cassandra database,,,', gid: 'cassandra', home: '/var/lib/cassandra', shell: '/bin/false', managehome: true - ) - .that_requires('Group[cassandra]') + ). + that_requires('Group[cassandra]') - should contain_file('/etc/cassandra').with( + is_expected.to contain_file('/etc/cassandra').with( ensure: 'directory', group: 'cassandra', owner: 'cassandra', mode: '0755' ) - should contain_file('/etc/cassandra/cassandra.yaml') - .with( + is_expected.to 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]']) + ). + that_comes_before('Package[cassandra]'). + that_requires(['User[cassandra]', 'File[/etc/cassandra]']) - should contain_file('/etc/cassandra/cassandra-rackdc.properties') - .with( + is_expected.to 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]') + ). + that_requires(['File[/etc/cassandra]', 'User[cassandra]']). + that_comes_before('Package[cassandra]') - should contain_service('cassandra') - .that_subscribes_to( + is_expected.to 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( + is_expected.to 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') + is_expected.to contain_file('/etc/dse/cassandra/cassandra.yaml').that_notifies('Service[cassandra]') + is_expected.to contain_file('/etc/dse/cassandra') - should contain_file('/etc/dse/cassandra/cassandra-rackdc.properties') - .with( + is_expected.to contain_file('/etc/dse/cassandra/cassandra-rackdc.properties'). + with( ensure: 'file', owner: 'cassandra', group: 'cassandra', mode: '0644' - ) - .that_notifies('Service[cassandra]') + ). + that_notifies('Service[cassandra]') - should contain_package('cassandra').with( + is_expected.to 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) + is_expected.to contain_file('/etc/cassandra/cassandra.yaml').with('mode' => '0755') + is_expected.to contain_service('cassandra').with(provider: 'base') + is_expected.to 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') + is_expected.to 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$/) + is_expected.to contain_file('/etc/cassandra/cassandra-rackdc.properties'). + with_content(%r{^dc=DC1}). + with_content(%r{^rack=RAC1$}). + with_content(%r{^#dc_suffix=$}). + with_content(%r{^# 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$/) + is_expected.to contain_file('/etc/cassandra/default.conf/cassandra-rackdc.properties'). + with_content(%r{^dc=DC1}). + with_content(%r{^rack=RAC1$}). + with_content(%r{^#dc_suffix=$}). + with_content(%r{^# 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$/) + is_expected.to contain_file('/etc/cassandra/default.conf/cassandra-topology.properties'). + with_content(%r{^dc=NYC$}). + with_content(%r{^rack=R101$}). + with_content(%r{^dc_suffix=_1_cassandra$}). + with_content(%r{^prefer_local=true$}) end end end diff --git a/spec/classes/java_spec.rb b/spec/classes/java_spec.rb index bcb8a42..8b288da 100644 --- a/spec/classes/java_spec.rb +++ b/spec/classes/java_spec.rb @@ -1,161 +1,161 @@ require 'spec_helper' describe 'cassandra::java' do let(:pre_condition) do [ 'class apt () {}', 'class apt::update () {}', 'define apt::key ($id, $server) {}', 'define apt::source ($location, $comment, $release, $repos) {}' ] end context 'On a RedHat OS with defaults for all parameters' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end it do - should contain_class('cassandra::java') - should contain_package('java-1.8.0-openjdk-headless') - should contain_package('jna') + is_expected.to contain_class('cassandra::java') + is_expected.to contain_package('java-1.8.0-openjdk-headless') + is_expected.to contain_package('jna') end end context 'On a Debian OS with defaults for all parameters' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'Debian' } end it do - should contain_class('cassandra::java') - should contain_package('openjdk-7-jre-headless') - should contain_package('libjna-java') - should have_resource_count(2) + is_expected.to contain_class('cassandra::java') + is_expected.to contain_package('openjdk-7-jre-headless') + is_expected.to contain_package('libjna-java') + is_expected.to have_resource_count(2) end end context 'On a Debian OS with package_ensure set' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'Debian' } end let :params do { package_ensure: '2.1.13' } end it do - should contain_package('openjdk-7-jre-headless').with_ensure('2.1.13') + is_expected.to contain_package('openjdk-7-jre-headless').with_ensure('2.1.13') end end context 'With package names set to foobar' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end let :params do { package_name: 'foobar-java', package_ensure: '42', jna_package_name: 'foobar-jna', jna_ensure: 'latest' } end it do - should contain_package('foobar-java').with(ensure: 42) - should contain_package('foobar-jna').with(ensure: 'latest') + is_expected.to contain_package('foobar-java').with(ensure: 42) + is_expected.to contain_package('foobar-jna').with(ensure: 'latest') end end context 'Ensure that a YUM repo can be specified.' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end let :params do { yumrepo: { 'ACME' => { 'baseurl' => 'http://yum.acme.org/repos', 'descr' => 'YUM Repository for ACME Products' } } } end it do - should contain_yumrepo('ACME').with( + is_expected.to contain_yumrepo('ACME').with( baseurl: 'http://yum.acme.org/repos', descr: 'YUM Repository for ACME Products' ).that_comes_before('Package[java-1.8.0-openjdk-headless]') end end context 'Ensure that Apt key and source can be specified.' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'Debian' } end let :params do { aptkey: { 'openjdk-r' => { 'id' => 'DA1A4A13543B466853BAF164EB9B1D8886F44E2A', 'server' => 'keyserver.ubuntu.com' } }, aptsource: { 'openjdk-r' => { 'comment' => 'OpenJDK builds (all archs)', 'location' => 'http://ppa.launchpad.net/openjdk-r/ppa/ubuntu', 'repos' => 'main', 'release' => 'trusty' } } } end it do - should contain_apt__key('openjdk-r') - .with( + is_expected.to contain_apt__key('openjdk-r'). + with( id: 'DA1A4A13543B466853BAF164EB9B1D8886F44E2A', server: 'keyserver.ubuntu.com' - ) - .that_comes_before('Package[openjdk-7-jre-headless]') - should contain_apt__source('openjdk-r') - .with( + ). + that_comes_before('Package[openjdk-7-jre-headless]') + is_expected.to contain_apt__source('openjdk-r'). + with( comment: 'OpenJDK builds (all archs)', location: 'http://ppa.launchpad.net/openjdk-r/ppa/ubuntu', repos: 'main', release: 'trusty' ) - should contain_exec('cassandra::java::apt_update') - .with( + is_expected.to contain_exec('cassandra::java::apt_update'). + with( refreshonly: true, command: '/bin/true' - ) - .that_comes_before('Package[openjdk-7-jre-headless]') + ). + that_comes_before('Package[openjdk-7-jre-headless]') end end end diff --git a/spec/classes/optutils_spec.rb b/spec/classes/optutils_spec.rb index c9efdc5..bc960bd 100644 --- a/spec/classes/optutils_spec.rb +++ b/spec/classes/optutils_spec.rb @@ -1,75 +1,75 @@ require 'spec_helper' describe 'cassandra::optutils' do context 'On a RedHat OS with defaults for all parameters' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end it do - should have_resource_count(1) - should contain_package('cassandra22-tools').with(ensure: 'present') + is_expected.to have_resource_count(1) + is_expected.to contain_package('cassandra22-tools').with(ensure: 'present') - should contain_class('cassandra::optutils').with( + is_expected.to contain_class('cassandra::optutils').with( package_ensure: 'present', package_name: 'cassandra22-tools' ) end end context 'On a Debian OS with defaults for all parameters' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'Debian' } end it do - should contain_package('cassandra-tools').with(ensure: 'present') + is_expected.to contain_package('cassandra-tools').with(ensure: 'present') - should contain_class('cassandra::optutils').with( + is_expected.to contain_class('cassandra::optutils').with( package_ensure: 'present', package_name: 'cassandra-tools' ) end end context 'With package_name set to foobar' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'Debian' } end let :params do { package_name: 'foobar-java', package_ensure: '42' } end it do - should contain_package('foobar-java').with(ensure: 42) + is_expected.to contain_package('foobar-java').with(ensure: 42) end end context 'On a Debian OS with package_ensure set' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'Debian' } end let :params do { package_ensure: '2.1.13' } end - it { should contain_package('cassandra-tools').with_ensure('2.1.13') } + it { is_expected.to contain_package('cassandra-tools').with_ensure('2.1.13') } end end diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb index 4a152d0..f6de206 100644 --- a/spec/classes/params_spec.rb +++ b/spec/classes/params_spec.rb @@ -1,16 +1,16 @@ require 'spec_helper' describe '::cassandra::params' do let :facts do { osfamily: 'RedHat', operatingsystemmajrelease: 7 } end it do - should compile - should contain_class('cassandra::params') - should have_resource_count(0) + is_expected.to compile + is_expected.to contain_class('cassandra::params') + is_expected.to have_resource_count(0) end end diff --git a/spec/classes/schema_spec.rb b/spec/classes/schema_spec.rb index 9d8bbd4..bd2f509 100644 --- a/spec/classes/schema_spec.rb +++ b/spec/classes/schema_spec.rb @@ -1,142 +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') + is_expected.to 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') 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) + is_expected.to 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( + is_expected.to contain_file('/root/.puppetcqlshrc').with( ensure: 'file', group: 'root', mode: '0600', owner: 'root', - content: /username = cassandra/ + content: %r{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) + is_expected.to 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( + is_expected.to contain_file('/root/.puppetcqlshrc').with( ensure: 'file', group: 'root', mode: '0600', owner: 'root', - content: /password = topsecret/ + content: %r{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) + is_expected.to 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) + is_expected.to 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/classes/system/swapoff_spec.rb b/spec/classes/system/swapoff_spec.rb index 5b95738..13dc298 100644 --- a/spec/classes/system/swapoff_spec.rb +++ b/spec/classes/system/swapoff_spec.rb @@ -1,30 +1,30 @@ require 'spec_helper' describe 'cassandra::system::swapoff' do context 'Test the default parameters' do it do - should have_resource_count(1) - should contain_class('cassandra::system::swapoff') - should contain_exec('Disable Swap') + is_expected.to have_resource_count(1) + is_expected.to contain_class('cassandra::system::swapoff') + is_expected.to contain_exec('Disable Swap') end end context 'Test we can remove a swap device from /etc/fstab' do let :params do { device: '/dev/mapper/centos-swap' } end it do - should have_resource_count(2) - should contain_class('cassandra::system::swapoff') - should contain_exec('Disable Swap') - should contain_mount('swap').with( + is_expected.to have_resource_count(2) + is_expected.to contain_class('cassandra::system::swapoff') + is_expected.to contain_exec('Disable Swap') + is_expected.to contain_mount('swap').with( ensure: 'absent', device: '/dev/mapper/centos-swap', fstype: 'swap' ) end end end diff --git a/spec/classes/system/sysctl_spec.rb b/spec/classes/system/sysctl_spec.rb index b5199a2..9d7b80c 100644 --- a/spec/classes/system/sysctl_spec.rb +++ b/spec/classes/system/sysctl_spec.rb @@ -1,39 +1,39 @@ require 'spec_helper' describe 'cassandra::system::sysctl' do let(:pre_condition) do [ 'define ini_setting($ensure = nil, $path, $section, $key_val_separator = nil, $setting, $value = nil) {}' ] end context 'Test the default parameters (RedHat)' do let :facts do { osfamily: 'RedHat', operatingsystemmajrelease: 7 } end it do - should have_resource_count(9) - should contain_class('Cassandra::System::Sysctl') - should contain_ini_setting('net.core.optmem_max = 40960') - should contain_ini_setting('net.core.rmem_default = 16777216') - should contain_ini_setting('net.core.rmem_max = 16777216') - should contain_ini_setting('net.core.wmem_default = 16777216') - should contain_ini_setting('net.core.wmem_max = 16777216') - should contain_ini_setting('net.ipv4.tcp_rmem = 4096, 87380, 16777216') - should contain_ini_setting('net.ipv4.tcp_wmem = 4096, 65536, 16777216') - should contain_ini_setting('vm.max_map_count = 1048575') - should contain_exec('Apply sysctl changes').with( + is_expected.to have_resource_count(9) + is_expected.to contain_class('Cassandra::System::Sysctl') + is_expected.to contain_ini_setting('net.core.optmem_max = 40960') + is_expected.to contain_ini_setting('net.core.rmem_default = 16777216') + is_expected.to contain_ini_setting('net.core.rmem_max = 16777216') + is_expected.to contain_ini_setting('net.core.wmem_default = 16777216') + is_expected.to contain_ini_setting('net.core.wmem_max = 16777216') + is_expected.to contain_ini_setting('net.ipv4.tcp_rmem = 4096, 87380, 16777216') + is_expected.to contain_ini_setting('net.ipv4.tcp_wmem = 4096, 65536, 16777216') + is_expected.to contain_ini_setting('vm.max_map_count = 1048575') + is_expected.to contain_exec('Apply sysctl changes').with( command: '/sbin/sysctl -p /etc/sysctl.d/10-cassandra.conf' ) end end end diff --git a/spec/classes/system/transparent_hugepage_spec.rb b/spec/classes/system/transparent_hugepage_spec.rb index b7df548..39ee3c1 100644 --- a/spec/classes/system/transparent_hugepage_spec.rb +++ b/spec/classes/system/transparent_hugepage_spec.rb @@ -1,33 +1,33 @@ require 'spec_helper' describe 'cassandra::system::transparent_hugepage' do context 'Test the default parameters (RedHat)' do let :facts do { osfamily: 'RedHat', operatingsystemmajrelease: 7 } end it do - should have_resource_count(1) - should contain_class('cassandra::system::transparent_hugepage') - should contain_exec('Disable Java Hugepages') + is_expected.to have_resource_count(1) + is_expected.to contain_class('cassandra::system::transparent_hugepage') + is_expected.to contain_exec('Disable Java Hugepages') end end context 'Test the default parameters (Debian)' do let :facts do { osfamily: 'Debian', operatingsystemmajrelease: 7 } end it do - should have_resource_count(1) - should contain_class('cassandra::system::transparent_hugepage') - should contain_exec('Disable Java Hugepages') + is_expected.to have_resource_count(1) + is_expected.to contain_class('cassandra::system::transparent_hugepage') + is_expected.to contain_exec('Disable Java Hugepages') end end end diff --git a/spec/defines/file_spec.rb b/spec/defines/file_spec.rb index c5d9342..2fbc8f4 100644 --- a/spec/defines/file_spec.rb +++ b/spec/defines/file_spec.rb @@ -1,52 +1,52 @@ require 'spec_helper' describe '::cassandra::file' do let(:pre_condition) do [ 'class stdlib () {}', 'define ini_setting($ensure = nil, $path, $section, $key_val_separator = nil, $setting, $value = nil) {}', 'define file_line($line, $path, $match) {}' ] end context 'On a Debian OS set the max and new heap size' do let :facts do { osfamily: 'Debian', operatingsystemmajrelease: 8 } end let(:title) { 'cassandra-env.sh' } let :params do { config_path: '/etc/cassandra', 'file_lines' => { 'MAX_HEAP_SIZE 4GB' => { 'line' => 'MAX_HEAP_SIZE="4G"', 'match' => '^#MAX_HEAP_SIZE="4G"$' } } } end it do - should contain_class('cassandra') - should contain_class('cassandra::params') - should contain_class('stdlib') - should contain_cassandra__file('cassandra-env.sh') + is_expected.to contain_class('cassandra') + is_expected.to contain_class('cassandra::params') + is_expected.to contain_class('stdlib') + is_expected.to contain_cassandra__file('cassandra-env.sh') - should contain_file_line('MAX_HEAP_SIZE 4GB').with( + is_expected.to contain_file_line('MAX_HEAP_SIZE 4GB').with( path: '/etc/cassandra/cassandra-env.sh', line: 'MAX_HEAP_SIZE="4G"', match: '^#MAX_HEAP_SIZE="4G"$' ) end end end diff --git a/spec/defines/private/firewall_ports/rule_spec.rb b/spec/defines/private/firewall_ports/rule_spec.rb index 8ebd1b0..1962c3b 100644 --- a/spec/defines/private/firewall_ports/rule_spec.rb +++ b/spec/defines/private/firewall_ports/rule_spec.rb @@ -1,25 +1,25 @@ require 'spec_helper' describe 'cassandra::private::firewall_ports::rule' do let(:pre_condition) do ['define firewall ($action, $dport, $proto, $source) {}'] end context 'Test that rules can be set.' do let(:title) { '200_Public_0.0.0.0/0' } let :params do { ports: [8888, 22] } end it do - should contain_firewall('200 - Cassandra (Public) - 0.0.0.0/0').with( + is_expected.to contain_firewall('200 - Cassandra (Public) - 0.0.0.0/0').with( action: 'accept', dport: [8888, 22], proto: 'tcp', source: '0.0.0.0/0' ) - should have_resource_count(2) + is_expected.to have_resource_count(2) end end end diff --git a/spec/defines/schema/cql_type_spec.rb b/spec/defines/schema/cql_type_spec.rb index 33f679b..bfe5132 100644 --- a/spec/defines/schema/cql_type_spec.rb +++ b/spec/defines/schema/cql_type_spec.rb @@ -1,84 +1,84 @@ require 'spec_helper' describe 'cassandra::schema::cql_type' do let(:pre_condition) do [ 'define ini_setting($ensure = nil, $path, $section, $key_val_separator = nil, $setting, $value = nil) {}' ] end context 'CQL TYPE (fullname)' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end let(:title) { 'fullname' } let(:params) do { 'keyspace' => 'Excelsior', fields: { 'firstname' => 'text', 'lastname' => 'text' } } end it do - should compile - should contain_class('cassandra::schema') - should contain_cassandra__schema__cql_type('fullname') - should contain_exec('/usr/bin/cqlsh -e "CREATE TYPE IF NOT EXISTS Excelsior.fullname (firstname text, lastname text)" localhost 9042') + is_expected.to compile + is_expected.to contain_class('cassandra::schema') + is_expected.to contain_cassandra__schema__cql_type('fullname') + is_expected.to contain_exec('/usr/bin/cqlsh -e "CREATE TYPE IF NOT EXISTS Excelsior.fullname (firstname text, lastname text)" localhost 9042') end end context 'Set ensure to absent' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end let(:title) { 'address' } let(:params) do { 'ensure' => 'absent', 'keyspace' => 'Excalibur' } end it do - should compile - should contain_cassandra__schema__cql_type('address') - should contain_exec('/usr/bin/cqlsh -e "DROP type Excalibur.address" localhost 9042') + is_expected.to compile + is_expected.to contain_cassandra__schema__cql_type('address') + is_expected.to contain_exec('/usr/bin/cqlsh -e "DROP type Excalibur.address" localhost 9042') end end context 'Set ensure to latest' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end let(:title) { 'foobar' } let(:params) do { ensure: 'latest' } end - it { should raise_error(Puppet::Error) } + it { is_expected.to raise_error(Puppet::Error) } end end diff --git a/spec/defines/schema/index_spec.rb b/spec/defines/schema/index_spec.rb index 6aecb11..7383aa8 100644 --- a/spec/defines/schema/index_spec.rb +++ b/spec/defines/schema/index_spec.rb @@ -1,132 +1,132 @@ require 'spec_helper' describe 'cassandra::schema::index' do let(:pre_condition) do [ 'define ini_setting($ensure = nil, $path, $section, $key_val_separator = nil, $setting, $value = nil) {}' ] end context 'Create a basic index' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end let(:title) { 'user_index' } let(:params) do { keys: 'lname', keyspace: 'mykeyspace', table: 'users' } end it do - should compile - should contain_cassandra__schema__index('user_index') - should contain_exec('/usr/bin/cqlsh -e "CREATE INDEX IF NOT EXISTS user_index ON mykeyspace.users (lname)" localhost 9042') + is_expected.to compile + is_expected.to contain_cassandra__schema__index('user_index') + is_expected.to contain_exec('/usr/bin/cqlsh -e "CREATE INDEX IF NOT EXISTS user_index ON mykeyspace.users (lname)" localhost 9042') end end context 'Create a custom index.' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end let(:title) { 'user_index' } let(:params) do { class_name: 'path.to.the.IndexClass', keys: 'email', keyspace: 'Excelsior', table: 'users' } end it do - should compile - should contain_exec('/usr/bin/cqlsh -e "CREATE CUSTOM INDEX IF NOT EXISTS user_index ON Excelsior.users (email) USING \'path.to.the.IndexClass\'" localhost 9042') + is_expected.to compile + is_expected.to contain_exec('/usr/bin/cqlsh -e "CREATE CUSTOM INDEX IF NOT EXISTS user_index ON Excelsior.users (email) USING \'path.to.the.IndexClass\'" localhost 9042') end end context 'Create a custom index with options.' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end let(:title) { 'user_index' } let(:params) do { class_name: 'path.to.the.IndexClass', keys: 'email', keyspace: 'Excelsior', options: "{'storage': '/mnt/ssd/indexes/'}", table: 'users' } end it do - should compile - should contain_exec('/usr/bin/cqlsh -e "CREATE CUSTOM INDEX IF NOT EXISTS user_index ON Excelsior.users (email) USING \'path.to.the.IndexClass\' WITH OPTIONS = {\'storage\': \'/mnt/ssd/indexes/\'}" localhost 9042') + is_expected.to compile + is_expected.to contain_exec('/usr/bin/cqlsh -e "CREATE CUSTOM INDEX IF NOT EXISTS user_index ON Excelsior.users (email) USING \'path.to.the.IndexClass\' WITH OPTIONS = {\'storage\': \'/mnt/ssd/indexes/\'}" localhost 9042') end end context 'Drop Index' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end let(:title) { 'user_index' } let(:params) do { ensure: 'absent', keys: 'lname', keyspace: 'Excelsior', table: 'users' } end it do - should compile - should contain_exec('/usr/bin/cqlsh -e "DROP INDEX Excelsior.user_index" localhost 9042') + is_expected.to compile + is_expected.to contain_exec('/usr/bin/cqlsh -e "DROP INDEX Excelsior.user_index" localhost 9042') end end context 'Set ensure to latest' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end let(:title) { 'foobar' } let(:params) do { ensure: 'latest' } end - it { should raise_error(Puppet::Error) } + it { is_expected.to raise_error(Puppet::Error) } end end diff --git a/spec/defines/schema/keyspace_spec.rb b/spec/defines/schema/keyspace_spec.rb index f1f6e09..fc62eb2 100644 --- a/spec/defines/schema/keyspace_spec.rb +++ b/spec/defines/schema/keyspace_spec.rb @@ -1,110 +1,110 @@ require 'spec_helper' describe 'cassandra::schema::keyspace' do let(:pre_condition) do [ 'define ini_setting($ensure = nil, $path, $section, $key_val_separator = nil, $setting, $value = nil) {}' ] end context 'Set ensure to present (SimpleStrategy)' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end let(:title) { 'foobar' } let(:params) do { ensure: 'present', replication_map: { 'keyspace_class' => 'SimpleStrategy', 'replication_factor' => 3 } } end it do - should compile - should contain_class('cassandra::schema') - should contain_exec('/usr/bin/cqlsh -e "CREATE KEYSPACE IF NOT EXISTS foobar WITH REPLICATION = { \'class\' : \'SimpleStrategy\', \'replication_factor\' : 3 } AND DURABLE_WRITES = true" localhost 9042') + is_expected.to compile + is_expected.to contain_class('cassandra::schema') + is_expected.to contain_exec('/usr/bin/cqlsh -e "CREATE KEYSPACE IF NOT EXISTS foobar WITH REPLICATION = { \'class\' : \'SimpleStrategy\', \'replication_factor\' : 3 } AND DURABLE_WRITES = true" localhost 9042') end end context 'Set ensure to present (NetworkTopologyStrategy)' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end let(:title) { 'foobar' } let(:params) do { ensure: 'present', replication_map: { 'keyspace_class' => 'NetworkTopologyStrategy', 'dc1' => '3', 'dc2' => '2' } } end it do - should contain_cassandra__schema__keyspace('foobar') - should contain_exec('/usr/bin/cqlsh -e "CREATE KEYSPACE IF NOT EXISTS foobar WITH REPLICATION = { \'class\' : \'NetworkTopologyStrategy\', \'dc1\': 3, \'dc2\': 2 } AND DURABLE_WRITES = true" localhost 9042') + is_expected.to contain_cassandra__schema__keyspace('foobar') + is_expected.to contain_exec('/usr/bin/cqlsh -e "CREATE KEYSPACE IF NOT EXISTS foobar WITH REPLICATION = { \'class\' : \'NetworkTopologyStrategy\', \'dc1\': 3, \'dc2\': 2 } AND DURABLE_WRITES = true" localhost 9042') end end context 'Set ensure to absent' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end let(:title) { 'foobar' } let(:params) do { ensure: 'absent' } end it do - should compile - should contain_exec('/usr/bin/cqlsh -e "DROP KEYSPACE foobar" localhost 9042') + is_expected.to compile + is_expected.to contain_exec('/usr/bin/cqlsh -e "DROP KEYSPACE foobar" localhost 9042') end end context 'Set ensure to latest' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end let(:title) { 'foobar' } let(:params) do { ensure: 'latest' } end - it { should raise_error(Puppet::Error) } + it { is_expected.to raise_error(Puppet::Error) } end end diff --git a/spec/defines/schema/permission_spec.rb b/spec/defines/schema/permission_spec.rb index 341d024..80424c9 100644 --- a/spec/defines/schema/permission_spec.rb +++ b/spec/defines/schema/permission_spec.rb @@ -1,185 +1,185 @@ require 'spec_helper' describe 'cassandra::schema::permission' do let(:pre_condition) do [ 'define ini_setting($ensure = nil, $path, $section, $key_val_separator = nil, $setting, $value = nil) {}' ] end context 'Set ensure to latest' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end let(:title) { 'foobar' } let(:params) do { user_name: 'foobar' } end - it { should raise_error(Puppet::Error) } + it { is_expected.to raise_error(Puppet::Error) } end context 'Set ensure to latest' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end let(:title) { 'foobar' } let(:params) do { ensure: 'latest' } end - it { should raise_error(Puppet::Error) } + it { is_expected.to raise_error(Puppet::Error) } end context 'spillman:SELECT:ALL' do let(:title) { 'spillman:SELECT:ALL' } let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end let(:params) do { user_name: 'spillman', permission_name: 'SELECT' } end it do - should have_resource_count(9) - should contain_cassandra__schema__permission('spillman:SELECT:ALL') - should contain_exec('GRANT SELECT ON ALL KEYSPACES TO spillman') + is_expected.to have_resource_count(9) + is_expected.to contain_cassandra__schema__permission('spillman:SELECT:ALL') + is_expected.to contain_exec('GRANT SELECT ON ALL KEYSPACES TO spillman') end end context 'akers:modify:field' do let(:title) { 'akers:modify:field' } let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end let(:params) do { user_name: 'akers', keyspace_name: 'field', permission_name: 'MODIFY' } end it do - should have_resource_count(9) - should contain_cassandra__schema__permission('akers:modify:field') - should contain_exec('GRANT MODIFY ON KEYSPACE field TO akers') + is_expected.to have_resource_count(9) + is_expected.to contain_cassandra__schema__permission('akers:modify:field') + is_expected.to contain_exec('GRANT MODIFY ON KEYSPACE field TO akers') end end context 'boone:alter:forty9ers' do let(:title) { 'boone:alter:forty9ers' } let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end let(:params) do { user_name: 'boone', keyspace_name: 'forty9ers', permission_name: 'ALTER' } end it do - should have_resource_count(9) - should contain_cassandra__schema__permission('boone:alter:forty9ers') - should contain_exec('GRANT ALTER ON KEYSPACE forty9ers TO boone') + is_expected.to have_resource_count(9) + is_expected.to contain_cassandra__schema__permission('boone:alter:forty9ers') + is_expected.to contain_exec('GRANT ALTER ON KEYSPACE forty9ers TO boone') end end context 'boone:ALL:ravens.plays' do let(:title) { 'boone:ALL:ravens.plays' } let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end let(:params) do { user_name: 'boone', keyspace_name: 'ravens', table_name: 'plays' } end it do - should have_resource_count(18) - should contain_cassandra__schema__permission('boone:ALL:ravens.plays') - should contain_cassandra__schema__permission('boone:ALL:ravens.plays - ALTER').with( + is_expected.to have_resource_count(18) + is_expected.to contain_cassandra__schema__permission('boone:ALL:ravens.plays') + is_expected.to contain_cassandra__schema__permission('boone:ALL:ravens.plays - ALTER').with( ensure: 'present', user_name: 'boone', keyspace_name: 'ravens', permission_name: 'ALTER', table_name: 'plays' ) - should contain_cassandra__schema__permission('boone:ALL:ravens.plays - AUTHORIZE') - should contain_cassandra__schema__permission('boone:ALL:ravens.plays - DROP') - should contain_cassandra__schema__permission('boone:ALL:ravens.plays - MODIFY') - should contain_cassandra__schema__permission('boone:ALL:ravens.plays - SELECT') - should contain_exec('GRANT ALTER ON TABLE ravens.plays TO boone') - should contain_exec('GRANT AUTHORIZE ON TABLE ravens.plays TO boone') - should contain_exec('GRANT DROP ON TABLE ravens.plays TO boone') - should contain_exec('GRANT MODIFY ON TABLE ravens.plays TO boone') - should contain_exec('GRANT SELECT ON TABLE ravens.plays TO boone') + is_expected.to contain_cassandra__schema__permission('boone:ALL:ravens.plays - AUTHORIZE') + is_expected.to contain_cassandra__schema__permission('boone:ALL:ravens.plays - DROP') + is_expected.to contain_cassandra__schema__permission('boone:ALL:ravens.plays - MODIFY') + is_expected.to contain_cassandra__schema__permission('boone:ALL:ravens.plays - SELECT') + is_expected.to contain_exec('GRANT ALTER ON TABLE ravens.plays TO boone') + is_expected.to contain_exec('GRANT AUTHORIZE ON TABLE ravens.plays TO boone') + is_expected.to contain_exec('GRANT DROP ON TABLE ravens.plays TO boone') + is_expected.to contain_exec('GRANT MODIFY ON TABLE ravens.plays TO boone') + is_expected.to contain_exec('GRANT SELECT ON TABLE ravens.plays TO boone') end end context 'REVOKE boone:SELECT:ravens.plays' do let(:title) { 'REVOKE boone:SELECT:ravens.plays' } let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end let(:params) do { ensure: 'absent', user_name: 'boone', keyspace_name: 'forty9ers', permission_name: 'SELECT' } end it do - should have_resource_count(9) - should contain_cassandra__schema__permission('REVOKE boone:SELECT:ravens.plays') - should contain_exec('REVOKE SELECT ON KEYSPACE forty9ers FROM boone') + is_expected.to have_resource_count(9) + is_expected.to contain_cassandra__schema__permission('REVOKE boone:SELECT:ravens.plays') + is_expected.to contain_exec('REVOKE SELECT ON KEYSPACE forty9ers FROM boone') end end end diff --git a/spec/defines/schema/table_spec.rb b/spec/defines/schema/table_spec.rb index c45403b..5bbc73f 100644 --- a/spec/defines/schema/table_spec.rb +++ b/spec/defines/schema/table_spec.rb @@ -1,93 +1,93 @@ require 'spec_helper' describe 'cassandra::schema::table' do let(:pre_condition) do [ 'define ini_setting($ensure = nil, $path, $section, $key_val_separator = nil, $setting, $value = nil) {}' ] end context 'Create Table' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end let(:title) { 'users' } let(:params) do { keyspace: 'Excelsior', columns: { 'userid' => 'text', 'username' => 'FROZEN', 'emails' => 'set', 'top_scores' => 'list', 'todo' => 'map', 'COLLECTION-TYPE' => 'tuple', 'PRIMARY KEY' => '(userid)' }, options: [ 'COMPACT STORAGE', 'ID=\'5a1c395e-b41f-11e5-9f22-ba0be0483c18\'' ] } end it do - should compile - should contain_cassandra__schema__table('users') - should contain_exec('/usr/bin/cqlsh -e "CREATE TABLE IF NOT EXISTS Excelsior.users (userid text, username FROZEN, emails set, top_scores list, todo map, tuple, PRIMARY KEY (userid)) WITH COMPACT STORAGE AND ID=\'5a1c395e-b41f-11e5-9f22-ba0be0483c18\'" localhost 9042') + is_expected.to compile + is_expected.to contain_cassandra__schema__table('users') + is_expected.to contain_exec('/usr/bin/cqlsh -e "CREATE TABLE IF NOT EXISTS Excelsior.users (userid text, username FROZEN, emails set, top_scores list, todo map, tuple, PRIMARY KEY (userid)) WITH COMPACT STORAGE AND ID=\'5a1c395e-b41f-11e5-9f22-ba0be0483c18\'" localhost 9042') end end context 'Drop Table' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end let(:title) { 'users' } let(:params) do { keyspace: 'Excelsior', ensure: 'absent' } end it do - should compile - should contain_exec('/usr/bin/cqlsh -e "DROP TABLE IF EXISTS Excelsior.users" localhost 9042') + is_expected.to compile + is_expected.to contain_exec('/usr/bin/cqlsh -e "DROP TABLE IF EXISTS Excelsior.users" localhost 9042') end end context 'Set ensure to latest' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end let(:title) { 'foobar' } let(:params) do { ensure: 'latest' } end - it { should raise_error(Puppet::Error) } + it { is_expected.to raise_error(Puppet::Error) } end end diff --git a/spec/defines/schema/user_spec.rb b/spec/defines/schema/user_spec.rb index e50fbe0..967f47f 100644 --- a/spec/defines/schema/user_spec.rb +++ b/spec/defines/schema/user_spec.rb @@ -1,211 +1,211 @@ require 'spec_helper' describe 'cassandra::schema::user' do let(:pre_condition) do [ 'define ini_setting($ensure = nil, $path, $section, $key_val_separator = nil, $setting, $value = nil) {}' ] end context 'Create a supper user on cassandrarelease undef' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat', cassandrarelease: nil } end let(:title) { 'akers' } let(:params) do { password: 'Niner2', superuser: true } end it do - should contain_cassandra__schema__user('akers').with_ensure('present') - should contain_exec('Create user (akers)').with( + is_expected.to contain_cassandra__schema__user('akers').with_ensure('present') + is_expected.to contain_exec('Create user (akers)').with( command: '/usr/bin/cqlsh -e "CREATE USER IF NOT EXISTS akers WITH PASSWORD \'Niner2\' SUPERUSER" localhost 9042' ) end end context 'Create a supper user in cassandrarelease < 2.2' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat', cassandrarelease: '2.0.1' } end let(:title) { 'akers' } let(:params) do { password: 'Niner2', superuser: true } end it do - should contain_cassandra__schema__user('akers').with_ensure('present') - should contain_exec('Create user (akers)').with( + is_expected.to contain_cassandra__schema__user('akers').with_ensure('present') + is_expected.to contain_exec('Create user (akers)').with( command: '/usr/bin/cqlsh -e "CREATE USER IF NOT EXISTS akers WITH PASSWORD \'Niner2\' SUPERUSER" localhost 9042' ) end end context 'Create a user in cassandrarelease < 2.2' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat', cassandrarelease: '2.0.1' } end let(:title) { 'akers' } let(:params) do { password: 'Niner2' } end it do - should contain_cassandra__schema__user('akers').with_ensure('present') - should contain_exec('Create user (akers)').with( + is_expected.to contain_cassandra__schema__user('akers').with_ensure('present') + is_expected.to contain_exec('Create user (akers)').with( command: '/usr/bin/cqlsh -e "CREATE USER IF NOT EXISTS akers WITH PASSWORD \'Niner2\' NOSUPERUSER" localhost 9042' ) end end context 'Create a supper user with login in cassandrarelease > 2.2' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat', cassandrarelease: '3.0.9' } end let(:title) { 'akers' } let(:params) do { password: 'Niner2', superuser: true } end it do - should contain_cassandra__schema__user('akers').with_ensure('present') - should contain_exec('Create user (akers)').with( + is_expected.to contain_cassandra__schema__user('akers').with_ensure('present') + is_expected.to contain_exec('Create user (akers)').with( command: '/usr/bin/cqlsh -e "CREATE ROLE IF NOT EXISTS akers WITH PASSWORD = \'Niner2\' AND SUPERUSER = true AND LOGIN = true" localhost 9042' ) end end context 'Create a user without login in cassandrarelease > 2.2' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat', cassandrarelease: '3.0.9' } end let(:title) { 'bob' } let(:params) do { password: 'kaZe89a', login: false } end it do - should contain_cassandra__schema__user('bob').with_ensure('present') - should contain_exec('Create user (bob)').with( + is_expected.to contain_cassandra__schema__user('bob').with_ensure('present') + is_expected.to contain_exec('Create user (bob)').with( command: '/usr/bin/cqlsh -e "CREATE ROLE IF NOT EXISTS bob WITH PASSWORD = \'kaZe89a\'" localhost 9042' ) end end context 'Drop a user in cassandrarelease > 2.2' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat', cassandrarelease: '3.0.9' } end let(:title) { 'akers' } let(:params) do { password: 'Niner2', ensure: 'absent' } end it do - should contain_exec('Delete user (akers)').with( + is_expected.to contain_exec('Delete user (akers)').with( command: '/usr/bin/cqlsh -e "DROP ROLE akers" localhost 9042' ) end end context 'Drop a user in cassandrarelease < 2.2' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat', cassandrarelease: '2.0.2' } end let(:title) { 'akers' } let(:params) do { password: 'Niner2', ensure: 'absent' } end it do - should contain_exec('Delete user (akers)').with( + is_expected.to contain_exec('Delete user (akers)').with( command: '/usr/bin/cqlsh -e "DROP USER akers" localhost 9042' ) end end context 'Set ensure to latest' do let :facts do { operatingsystemmajrelease: 7, osfamily: 'RedHat' } end let(:title) { 'foobar' } let(:params) do { ensure: 'latest' } end - it { should raise_error(Puppet::Error) } + it { is_expected.to raise_error(Puppet::Error) } end end diff --git a/spec/unit/facter/cassandracmsheapnewsize_spec.rb b/spec/unit/facter/cassandracmsheapnewsize_spec.rb index a77b58b..25e49c9 100644 --- a/spec/unit/facter/cassandracmsheapnewsize_spec.rb +++ b/spec/unit/facter/cassandracmsheapnewsize_spec.rb @@ -1,115 +1,115 @@ require 'spec_helper' describe 'Facter::Util::Fact' do before do Facter.clear end describe 'cassandrarelease DSE' do it do - allow(Facter::Util::Resolution) - .to receive(:exec).with('nodetool version') - .and_return('2.1.11.969') + allow(Facter::Util::Resolution). + to receive(:exec).with('nodetool version'). + and_return('2.1.11.969') expect(Facter.fact(:cassandrarelease).value).to eql('2.1.11') - expect(Facter.fact(:cassandramajorversion).value).to eql(2) - expect(Facter.fact(:cassandraminorversion).value).to eql(1) - expect(Facter.fact(:cassandrapatchversion).value).to eql(11) + expect(Facter.fact(:cassandramajorversion).value).to be(2) + expect(Facter.fact(:cassandraminorversion).value).to be(1) + expect(Facter.fact(:cassandrapatchversion).value).to be(11) end end describe 'cassandrarelease DDC' do it do - allow(Facter::Util::Resolution) - .to receive(:exec).with('nodetool version') - .and_return('3.0.1') + allow(Facter::Util::Resolution). + to receive(:exec).with('nodetool version'). + and_return('3.0.1') expect(Facter.fact(:cassandrarelease).value).to eql('3.0.1') - expect(Facter.fact(:cassandramajorversion).value).to eql(3) - expect(Facter.fact(:cassandraminorversion).value).to eql(0) - expect(Facter.fact(:cassandrapatchversion).value).to eql(1) + expect(Facter.fact(:cassandramajorversion).value).to be(3) + expect(Facter.fact(:cassandraminorversion).value).to be(0) + expect(Facter.fact(:cassandrapatchversion).value).to be(1) end end describe 'Cassandra not installed or not running' do it do - allow(Facter::Util::Resolution) - .to receive(:exec).with('nodetool version') - .and_return('') - expect(Facter.fact(:cassandrarelease).value).to eql(nil) - expect(Facter.fact(:cassandramajorversion).value).to eql(nil) - expect(Facter.fact(:cassandraminorversion).value).to eql(nil) - expect(Facter.fact(:cassandrapatchversion).value).to eql(nil) + allow(Facter::Util::Resolution). + to receive(:exec).with('nodetool version'). + and_return('') + expect(Facter.fact(:cassandrarelease).value).to be(nil) + expect(Facter.fact(:cassandramajorversion).value).to be(nil) + expect(Facter.fact(:cassandraminorversion).value).to be(nil) + expect(Facter.fact(:cassandrapatchversion).value).to be(nil) end end describe 'Heap settings' do context 'Rasberry Pi 3' do - before :each do + before do Facter.fact(:memorysize_mb).stubs(:value).returns('1024') Facter.fact(:processorcount).stubs(:value).returns('4') end it do expect(Facter.fact(:cassandramaxheapsize).value).to eq(512) - expect(Facter.fact(:cassandracmsmaxheapsize).value).to eql(512) - expect(Facter.fact(:cassandraheapnewsize).value).to eql(128) - expect(Facter.fact(:cassandracmsheapnewsize).value).to eql(128) + expect(Facter.fact(:cassandracmsmaxheapsize).value).to be(512) + expect(Facter.fact(:cassandraheapnewsize).value).to be(128) + expect(Facter.fact(:cassandracmsheapnewsize).value).to be(128) end end context 'm4.large' do - before :each do + before do Facter.fact(:memorysize_mb).stubs(:value).returns('8191.9') Facter.fact(:processorcount).stubs(:value).returns('2') end it do - expect(Facter.fact(:cassandramaxheapsize).value).to eql(2048) - expect(Facter.fact(:cassandracmsmaxheapsize).value).to eql(2048) - expect(Facter.fact(:cassandraheapnewsize).value).to eql(200) - expect(Facter.fact(:cassandracmsheapnewsize).value).to eql(200) + expect(Facter.fact(:cassandramaxheapsize).value).to be(2048) + expect(Facter.fact(:cassandracmsmaxheapsize).value).to be(2048) + expect(Facter.fact(:cassandraheapnewsize).value).to be(200) + expect(Facter.fact(:cassandracmsheapnewsize).value).to be(200) end end context 'm4.xlarge' do - before :each do + before do Facter.fact(:memorysize_mb).stubs(:value).returns('16384') Facter.fact(:processorcount).stubs(:value).returns('2') end it do - expect(Facter.fact(:cassandramaxheapsize).value).to eql(4096) - expect(Facter.fact(:cassandracmsmaxheapsize).value).to eql(4096) - expect(Facter.fact(:cassandraheapnewsize).value).to eql(200) - expect(Facter.fact(:cassandracmsheapnewsize).value).to eql(200) + expect(Facter.fact(:cassandramaxheapsize).value).to be(4096) + expect(Facter.fact(:cassandracmsmaxheapsize).value).to be(4096) + expect(Facter.fact(:cassandraheapnewsize).value).to be(200) + expect(Facter.fact(:cassandracmsheapnewsize).value).to be(200) end end context 'c4.2xlarge' do - before :each do + before do Facter.fact(:memorysize_mb).stubs(:value).returns('15360') Facter.fact(:processorcount).stubs(:value).returns('8') end it do - expect(Facter.fact(:cassandramaxheapsize).value).to eql(3840) - expect(Facter.fact(:cassandracmsmaxheapsize).value).to eql(3840) - expect(Facter.fact(:cassandraheapnewsize).value).to eql(800) - expect(Facter.fact(:cassandracmsheapnewsize).value).to eql(800) + expect(Facter.fact(:cassandramaxheapsize).value).to be(3840) + expect(Facter.fact(:cassandracmsmaxheapsize).value).to be(3840) + expect(Facter.fact(:cassandraheapnewsize).value).to be(800) + expect(Facter.fact(:cassandracmsheapnewsize).value).to be(800) end end context 'i2.2xlarge' do - before :each do + before do Facter.fact(:memorysize_mb).stubs(:value).returns('62464') Facter.fact(:processorcount).stubs(:value).returns('8') end it do - expect(Facter.fact(:cassandramaxheapsize).value).to eql(8192) - expect(Facter.fact(:cassandracmsmaxheapsize).value).to eql(14_336) - expect(Facter.fact(:cassandraheapnewsize).value).to eql(800) - expect(Facter.fact(:cassandracmsheapnewsize).value).to eql(800) + expect(Facter.fact(:cassandramaxheapsize).value).to be(8192) + expect(Facter.fact(:cassandracmsmaxheapsize).value).to be(14_336) + expect(Facter.fact(:cassandraheapnewsize).value).to be(800) + expect(Facter.fact(:cassandracmsheapnewsize).value).to be(800) end end end end diff --git a/spec/unit/facter/cassandracmsmaxheapsize_spec.rb b/spec/unit/facter/cassandracmsmaxheapsize_spec.rb index a77b58b..25e49c9 100644 --- a/spec/unit/facter/cassandracmsmaxheapsize_spec.rb +++ b/spec/unit/facter/cassandracmsmaxheapsize_spec.rb @@ -1,115 +1,115 @@ require 'spec_helper' describe 'Facter::Util::Fact' do before do Facter.clear end describe 'cassandrarelease DSE' do it do - allow(Facter::Util::Resolution) - .to receive(:exec).with('nodetool version') - .and_return('2.1.11.969') + allow(Facter::Util::Resolution). + to receive(:exec).with('nodetool version'). + and_return('2.1.11.969') expect(Facter.fact(:cassandrarelease).value).to eql('2.1.11') - expect(Facter.fact(:cassandramajorversion).value).to eql(2) - expect(Facter.fact(:cassandraminorversion).value).to eql(1) - expect(Facter.fact(:cassandrapatchversion).value).to eql(11) + expect(Facter.fact(:cassandramajorversion).value).to be(2) + expect(Facter.fact(:cassandraminorversion).value).to be(1) + expect(Facter.fact(:cassandrapatchversion).value).to be(11) end end describe 'cassandrarelease DDC' do it do - allow(Facter::Util::Resolution) - .to receive(:exec).with('nodetool version') - .and_return('3.0.1') + allow(Facter::Util::Resolution). + to receive(:exec).with('nodetool version'). + and_return('3.0.1') expect(Facter.fact(:cassandrarelease).value).to eql('3.0.1') - expect(Facter.fact(:cassandramajorversion).value).to eql(3) - expect(Facter.fact(:cassandraminorversion).value).to eql(0) - expect(Facter.fact(:cassandrapatchversion).value).to eql(1) + expect(Facter.fact(:cassandramajorversion).value).to be(3) + expect(Facter.fact(:cassandraminorversion).value).to be(0) + expect(Facter.fact(:cassandrapatchversion).value).to be(1) end end describe 'Cassandra not installed or not running' do it do - allow(Facter::Util::Resolution) - .to receive(:exec).with('nodetool version') - .and_return('') - expect(Facter.fact(:cassandrarelease).value).to eql(nil) - expect(Facter.fact(:cassandramajorversion).value).to eql(nil) - expect(Facter.fact(:cassandraminorversion).value).to eql(nil) - expect(Facter.fact(:cassandrapatchversion).value).to eql(nil) + allow(Facter::Util::Resolution). + to receive(:exec).with('nodetool version'). + and_return('') + expect(Facter.fact(:cassandrarelease).value).to be(nil) + expect(Facter.fact(:cassandramajorversion).value).to be(nil) + expect(Facter.fact(:cassandraminorversion).value).to be(nil) + expect(Facter.fact(:cassandrapatchversion).value).to be(nil) end end describe 'Heap settings' do context 'Rasberry Pi 3' do - before :each do + before do Facter.fact(:memorysize_mb).stubs(:value).returns('1024') Facter.fact(:processorcount).stubs(:value).returns('4') end it do expect(Facter.fact(:cassandramaxheapsize).value).to eq(512) - expect(Facter.fact(:cassandracmsmaxheapsize).value).to eql(512) - expect(Facter.fact(:cassandraheapnewsize).value).to eql(128) - expect(Facter.fact(:cassandracmsheapnewsize).value).to eql(128) + expect(Facter.fact(:cassandracmsmaxheapsize).value).to be(512) + expect(Facter.fact(:cassandraheapnewsize).value).to be(128) + expect(Facter.fact(:cassandracmsheapnewsize).value).to be(128) end end context 'm4.large' do - before :each do + before do Facter.fact(:memorysize_mb).stubs(:value).returns('8191.9') Facter.fact(:processorcount).stubs(:value).returns('2') end it do - expect(Facter.fact(:cassandramaxheapsize).value).to eql(2048) - expect(Facter.fact(:cassandracmsmaxheapsize).value).to eql(2048) - expect(Facter.fact(:cassandraheapnewsize).value).to eql(200) - expect(Facter.fact(:cassandracmsheapnewsize).value).to eql(200) + expect(Facter.fact(:cassandramaxheapsize).value).to be(2048) + expect(Facter.fact(:cassandracmsmaxheapsize).value).to be(2048) + expect(Facter.fact(:cassandraheapnewsize).value).to be(200) + expect(Facter.fact(:cassandracmsheapnewsize).value).to be(200) end end context 'm4.xlarge' do - before :each do + before do Facter.fact(:memorysize_mb).stubs(:value).returns('16384') Facter.fact(:processorcount).stubs(:value).returns('2') end it do - expect(Facter.fact(:cassandramaxheapsize).value).to eql(4096) - expect(Facter.fact(:cassandracmsmaxheapsize).value).to eql(4096) - expect(Facter.fact(:cassandraheapnewsize).value).to eql(200) - expect(Facter.fact(:cassandracmsheapnewsize).value).to eql(200) + expect(Facter.fact(:cassandramaxheapsize).value).to be(4096) + expect(Facter.fact(:cassandracmsmaxheapsize).value).to be(4096) + expect(Facter.fact(:cassandraheapnewsize).value).to be(200) + expect(Facter.fact(:cassandracmsheapnewsize).value).to be(200) end end context 'c4.2xlarge' do - before :each do + before do Facter.fact(:memorysize_mb).stubs(:value).returns('15360') Facter.fact(:processorcount).stubs(:value).returns('8') end it do - expect(Facter.fact(:cassandramaxheapsize).value).to eql(3840) - expect(Facter.fact(:cassandracmsmaxheapsize).value).to eql(3840) - expect(Facter.fact(:cassandraheapnewsize).value).to eql(800) - expect(Facter.fact(:cassandracmsheapnewsize).value).to eql(800) + expect(Facter.fact(:cassandramaxheapsize).value).to be(3840) + expect(Facter.fact(:cassandracmsmaxheapsize).value).to be(3840) + expect(Facter.fact(:cassandraheapnewsize).value).to be(800) + expect(Facter.fact(:cassandracmsheapnewsize).value).to be(800) end end context 'i2.2xlarge' do - before :each do + before do Facter.fact(:memorysize_mb).stubs(:value).returns('62464') Facter.fact(:processorcount).stubs(:value).returns('8') end it do - expect(Facter.fact(:cassandramaxheapsize).value).to eql(8192) - expect(Facter.fact(:cassandracmsmaxheapsize).value).to eql(14_336) - expect(Facter.fact(:cassandraheapnewsize).value).to eql(800) - expect(Facter.fact(:cassandracmsheapnewsize).value).to eql(800) + expect(Facter.fact(:cassandramaxheapsize).value).to be(8192) + expect(Facter.fact(:cassandracmsmaxheapsize).value).to be(14_336) + expect(Facter.fact(:cassandraheapnewsize).value).to be(800) + expect(Facter.fact(:cassandracmsheapnewsize).value).to be(800) end end end end diff --git a/spec/unit/facter/cassandraheapnewsize_spec.rb b/spec/unit/facter/cassandraheapnewsize_spec.rb index a77b58b..25e49c9 100644 --- a/spec/unit/facter/cassandraheapnewsize_spec.rb +++ b/spec/unit/facter/cassandraheapnewsize_spec.rb @@ -1,115 +1,115 @@ require 'spec_helper' describe 'Facter::Util::Fact' do before do Facter.clear end describe 'cassandrarelease DSE' do it do - allow(Facter::Util::Resolution) - .to receive(:exec).with('nodetool version') - .and_return('2.1.11.969') + allow(Facter::Util::Resolution). + to receive(:exec).with('nodetool version'). + and_return('2.1.11.969') expect(Facter.fact(:cassandrarelease).value).to eql('2.1.11') - expect(Facter.fact(:cassandramajorversion).value).to eql(2) - expect(Facter.fact(:cassandraminorversion).value).to eql(1) - expect(Facter.fact(:cassandrapatchversion).value).to eql(11) + expect(Facter.fact(:cassandramajorversion).value).to be(2) + expect(Facter.fact(:cassandraminorversion).value).to be(1) + expect(Facter.fact(:cassandrapatchversion).value).to be(11) end end describe 'cassandrarelease DDC' do it do - allow(Facter::Util::Resolution) - .to receive(:exec).with('nodetool version') - .and_return('3.0.1') + allow(Facter::Util::Resolution). + to receive(:exec).with('nodetool version'). + and_return('3.0.1') expect(Facter.fact(:cassandrarelease).value).to eql('3.0.1') - expect(Facter.fact(:cassandramajorversion).value).to eql(3) - expect(Facter.fact(:cassandraminorversion).value).to eql(0) - expect(Facter.fact(:cassandrapatchversion).value).to eql(1) + expect(Facter.fact(:cassandramajorversion).value).to be(3) + expect(Facter.fact(:cassandraminorversion).value).to be(0) + expect(Facter.fact(:cassandrapatchversion).value).to be(1) end end describe 'Cassandra not installed or not running' do it do - allow(Facter::Util::Resolution) - .to receive(:exec).with('nodetool version') - .and_return('') - expect(Facter.fact(:cassandrarelease).value).to eql(nil) - expect(Facter.fact(:cassandramajorversion).value).to eql(nil) - expect(Facter.fact(:cassandraminorversion).value).to eql(nil) - expect(Facter.fact(:cassandrapatchversion).value).to eql(nil) + allow(Facter::Util::Resolution). + to receive(:exec).with('nodetool version'). + and_return('') + expect(Facter.fact(:cassandrarelease).value).to be(nil) + expect(Facter.fact(:cassandramajorversion).value).to be(nil) + expect(Facter.fact(:cassandraminorversion).value).to be(nil) + expect(Facter.fact(:cassandrapatchversion).value).to be(nil) end end describe 'Heap settings' do context 'Rasberry Pi 3' do - before :each do + before do Facter.fact(:memorysize_mb).stubs(:value).returns('1024') Facter.fact(:processorcount).stubs(:value).returns('4') end it do expect(Facter.fact(:cassandramaxheapsize).value).to eq(512) - expect(Facter.fact(:cassandracmsmaxheapsize).value).to eql(512) - expect(Facter.fact(:cassandraheapnewsize).value).to eql(128) - expect(Facter.fact(:cassandracmsheapnewsize).value).to eql(128) + expect(Facter.fact(:cassandracmsmaxheapsize).value).to be(512) + expect(Facter.fact(:cassandraheapnewsize).value).to be(128) + expect(Facter.fact(:cassandracmsheapnewsize).value).to be(128) end end context 'm4.large' do - before :each do + before do Facter.fact(:memorysize_mb).stubs(:value).returns('8191.9') Facter.fact(:processorcount).stubs(:value).returns('2') end it do - expect(Facter.fact(:cassandramaxheapsize).value).to eql(2048) - expect(Facter.fact(:cassandracmsmaxheapsize).value).to eql(2048) - expect(Facter.fact(:cassandraheapnewsize).value).to eql(200) - expect(Facter.fact(:cassandracmsheapnewsize).value).to eql(200) + expect(Facter.fact(:cassandramaxheapsize).value).to be(2048) + expect(Facter.fact(:cassandracmsmaxheapsize).value).to be(2048) + expect(Facter.fact(:cassandraheapnewsize).value).to be(200) + expect(Facter.fact(:cassandracmsheapnewsize).value).to be(200) end end context 'm4.xlarge' do - before :each do + before do Facter.fact(:memorysize_mb).stubs(:value).returns('16384') Facter.fact(:processorcount).stubs(:value).returns('2') end it do - expect(Facter.fact(:cassandramaxheapsize).value).to eql(4096) - expect(Facter.fact(:cassandracmsmaxheapsize).value).to eql(4096) - expect(Facter.fact(:cassandraheapnewsize).value).to eql(200) - expect(Facter.fact(:cassandracmsheapnewsize).value).to eql(200) + expect(Facter.fact(:cassandramaxheapsize).value).to be(4096) + expect(Facter.fact(:cassandracmsmaxheapsize).value).to be(4096) + expect(Facter.fact(:cassandraheapnewsize).value).to be(200) + expect(Facter.fact(:cassandracmsheapnewsize).value).to be(200) end end context 'c4.2xlarge' do - before :each do + before do Facter.fact(:memorysize_mb).stubs(:value).returns('15360') Facter.fact(:processorcount).stubs(:value).returns('8') end it do - expect(Facter.fact(:cassandramaxheapsize).value).to eql(3840) - expect(Facter.fact(:cassandracmsmaxheapsize).value).to eql(3840) - expect(Facter.fact(:cassandraheapnewsize).value).to eql(800) - expect(Facter.fact(:cassandracmsheapnewsize).value).to eql(800) + expect(Facter.fact(:cassandramaxheapsize).value).to be(3840) + expect(Facter.fact(:cassandracmsmaxheapsize).value).to be(3840) + expect(Facter.fact(:cassandraheapnewsize).value).to be(800) + expect(Facter.fact(:cassandracmsheapnewsize).value).to be(800) end end context 'i2.2xlarge' do - before :each do + before do Facter.fact(:memorysize_mb).stubs(:value).returns('62464') Facter.fact(:processorcount).stubs(:value).returns('8') end it do - expect(Facter.fact(:cassandramaxheapsize).value).to eql(8192) - expect(Facter.fact(:cassandracmsmaxheapsize).value).to eql(14_336) - expect(Facter.fact(:cassandraheapnewsize).value).to eql(800) - expect(Facter.fact(:cassandracmsheapnewsize).value).to eql(800) + expect(Facter.fact(:cassandramaxheapsize).value).to be(8192) + expect(Facter.fact(:cassandracmsmaxheapsize).value).to be(14_336) + expect(Facter.fact(:cassandraheapnewsize).value).to be(800) + expect(Facter.fact(:cassandracmsheapnewsize).value).to be(800) end end end end diff --git a/spec/unit/facter/cassandramajorversion_spec.rb b/spec/unit/facter/cassandramajorversion_spec.rb index 8e07b9b..799d60d 100644 --- a/spec/unit/facter/cassandramajorversion_spec.rb +++ b/spec/unit/facter/cassandramajorversion_spec.rb @@ -1,43 +1,43 @@ require 'spec_helper' describe 'Facter::Util::Fact' do before do Facter.clear end describe 'cassandrarelease DSE' do it do - allow(Facter::Util::Resolution) - .to receive(:exec).with('nodetool version') - .and_return('2.1.11.969') + allow(Facter::Util::Resolution). + to receive(:exec).with('nodetool version'). + and_return('2.1.11.969') expect(Facter.fact(:cassandrarelease).value).to eql('2.1.11') - expect(Facter.fact(:cassandramajorversion).value).to eql(2) - expect(Facter.fact(:cassandraminorversion).value).to eql(1) - expect(Facter.fact(:cassandrapatchversion).value).to eql(11) + expect(Facter.fact(:cassandramajorversion).value).to be(2) + expect(Facter.fact(:cassandraminorversion).value).to be(1) + expect(Facter.fact(:cassandrapatchversion).value).to be(11) end end describe 'cassandrarelease DDC' do it do - allow(Facter::Util::Resolution) - .to receive(:exec).with('nodetool version') - .and_return('3.0.1') + allow(Facter::Util::Resolution). + to receive(:exec).with('nodetool version'). + and_return('3.0.1') expect(Facter.fact(:cassandrarelease).value).to eql('3.0.1') - expect(Facter.fact(:cassandramajorversion).value).to eql(3) - expect(Facter.fact(:cassandraminorversion).value).to eql(0) - expect(Facter.fact(:cassandrapatchversion).value).to eql(1) + expect(Facter.fact(:cassandramajorversion).value).to be(3) + expect(Facter.fact(:cassandraminorversion).value).to be(0) + expect(Facter.fact(:cassandrapatchversion).value).to be(1) end end describe 'Cassandra not installed or not running' do it do - allow(Facter::Util::Resolution) - .to receive(:exec).with('nodetool version') - .and_return('') - expect(Facter.fact(:cassandrarelease).value).to eql(nil) - expect(Facter.fact(:cassandramajorversion).value).to eql(nil) - expect(Facter.fact(:cassandraminorversion).value).to eql(nil) - expect(Facter.fact(:cassandrapatchversion).value).to eql(nil) + allow(Facter::Util::Resolution). + to receive(:exec).with('nodetool version'). + and_return('') + expect(Facter.fact(:cassandrarelease).value).to be(nil) + expect(Facter.fact(:cassandramajorversion).value).to be(nil) + expect(Facter.fact(:cassandraminorversion).value).to be(nil) + expect(Facter.fact(:cassandrapatchversion).value).to be(nil) end end end diff --git a/spec/unit/facter/cassandramaxheapsize_spec.rb b/spec/unit/facter/cassandramaxheapsize_spec.rb index a77b58b..25e49c9 100644 --- a/spec/unit/facter/cassandramaxheapsize_spec.rb +++ b/spec/unit/facter/cassandramaxheapsize_spec.rb @@ -1,115 +1,115 @@ require 'spec_helper' describe 'Facter::Util::Fact' do before do Facter.clear end describe 'cassandrarelease DSE' do it do - allow(Facter::Util::Resolution) - .to receive(:exec).with('nodetool version') - .and_return('2.1.11.969') + allow(Facter::Util::Resolution). + to receive(:exec).with('nodetool version'). + and_return('2.1.11.969') expect(Facter.fact(:cassandrarelease).value).to eql('2.1.11') - expect(Facter.fact(:cassandramajorversion).value).to eql(2) - expect(Facter.fact(:cassandraminorversion).value).to eql(1) - expect(Facter.fact(:cassandrapatchversion).value).to eql(11) + expect(Facter.fact(:cassandramajorversion).value).to be(2) + expect(Facter.fact(:cassandraminorversion).value).to be(1) + expect(Facter.fact(:cassandrapatchversion).value).to be(11) end end describe 'cassandrarelease DDC' do it do - allow(Facter::Util::Resolution) - .to receive(:exec).with('nodetool version') - .and_return('3.0.1') + allow(Facter::Util::Resolution). + to receive(:exec).with('nodetool version'). + and_return('3.0.1') expect(Facter.fact(:cassandrarelease).value).to eql('3.0.1') - expect(Facter.fact(:cassandramajorversion).value).to eql(3) - expect(Facter.fact(:cassandraminorversion).value).to eql(0) - expect(Facter.fact(:cassandrapatchversion).value).to eql(1) + expect(Facter.fact(:cassandramajorversion).value).to be(3) + expect(Facter.fact(:cassandraminorversion).value).to be(0) + expect(Facter.fact(:cassandrapatchversion).value).to be(1) end end describe 'Cassandra not installed or not running' do it do - allow(Facter::Util::Resolution) - .to receive(:exec).with('nodetool version') - .and_return('') - expect(Facter.fact(:cassandrarelease).value).to eql(nil) - expect(Facter.fact(:cassandramajorversion).value).to eql(nil) - expect(Facter.fact(:cassandraminorversion).value).to eql(nil) - expect(Facter.fact(:cassandrapatchversion).value).to eql(nil) + allow(Facter::Util::Resolution). + to receive(:exec).with('nodetool version'). + and_return('') + expect(Facter.fact(:cassandrarelease).value).to be(nil) + expect(Facter.fact(:cassandramajorversion).value).to be(nil) + expect(Facter.fact(:cassandraminorversion).value).to be(nil) + expect(Facter.fact(:cassandrapatchversion).value).to be(nil) end end describe 'Heap settings' do context 'Rasberry Pi 3' do - before :each do + before do Facter.fact(:memorysize_mb).stubs(:value).returns('1024') Facter.fact(:processorcount).stubs(:value).returns('4') end it do expect(Facter.fact(:cassandramaxheapsize).value).to eq(512) - expect(Facter.fact(:cassandracmsmaxheapsize).value).to eql(512) - expect(Facter.fact(:cassandraheapnewsize).value).to eql(128) - expect(Facter.fact(:cassandracmsheapnewsize).value).to eql(128) + expect(Facter.fact(:cassandracmsmaxheapsize).value).to be(512) + expect(Facter.fact(:cassandraheapnewsize).value).to be(128) + expect(Facter.fact(:cassandracmsheapnewsize).value).to be(128) end end context 'm4.large' do - before :each do + before do Facter.fact(:memorysize_mb).stubs(:value).returns('8191.9') Facter.fact(:processorcount).stubs(:value).returns('2') end it do - expect(Facter.fact(:cassandramaxheapsize).value).to eql(2048) - expect(Facter.fact(:cassandracmsmaxheapsize).value).to eql(2048) - expect(Facter.fact(:cassandraheapnewsize).value).to eql(200) - expect(Facter.fact(:cassandracmsheapnewsize).value).to eql(200) + expect(Facter.fact(:cassandramaxheapsize).value).to be(2048) + expect(Facter.fact(:cassandracmsmaxheapsize).value).to be(2048) + expect(Facter.fact(:cassandraheapnewsize).value).to be(200) + expect(Facter.fact(:cassandracmsheapnewsize).value).to be(200) end end context 'm4.xlarge' do - before :each do + before do Facter.fact(:memorysize_mb).stubs(:value).returns('16384') Facter.fact(:processorcount).stubs(:value).returns('2') end it do - expect(Facter.fact(:cassandramaxheapsize).value).to eql(4096) - expect(Facter.fact(:cassandracmsmaxheapsize).value).to eql(4096) - expect(Facter.fact(:cassandraheapnewsize).value).to eql(200) - expect(Facter.fact(:cassandracmsheapnewsize).value).to eql(200) + expect(Facter.fact(:cassandramaxheapsize).value).to be(4096) + expect(Facter.fact(:cassandracmsmaxheapsize).value).to be(4096) + expect(Facter.fact(:cassandraheapnewsize).value).to be(200) + expect(Facter.fact(:cassandracmsheapnewsize).value).to be(200) end end context 'c4.2xlarge' do - before :each do + before do Facter.fact(:memorysize_mb).stubs(:value).returns('15360') Facter.fact(:processorcount).stubs(:value).returns('8') end it do - expect(Facter.fact(:cassandramaxheapsize).value).to eql(3840) - expect(Facter.fact(:cassandracmsmaxheapsize).value).to eql(3840) - expect(Facter.fact(:cassandraheapnewsize).value).to eql(800) - expect(Facter.fact(:cassandracmsheapnewsize).value).to eql(800) + expect(Facter.fact(:cassandramaxheapsize).value).to be(3840) + expect(Facter.fact(:cassandracmsmaxheapsize).value).to be(3840) + expect(Facter.fact(:cassandraheapnewsize).value).to be(800) + expect(Facter.fact(:cassandracmsheapnewsize).value).to be(800) end end context 'i2.2xlarge' do - before :each do + before do Facter.fact(:memorysize_mb).stubs(:value).returns('62464') Facter.fact(:processorcount).stubs(:value).returns('8') end it do - expect(Facter.fact(:cassandramaxheapsize).value).to eql(8192) - expect(Facter.fact(:cassandracmsmaxheapsize).value).to eql(14_336) - expect(Facter.fact(:cassandraheapnewsize).value).to eql(800) - expect(Facter.fact(:cassandracmsheapnewsize).value).to eql(800) + expect(Facter.fact(:cassandramaxheapsize).value).to be(8192) + expect(Facter.fact(:cassandracmsmaxheapsize).value).to be(14_336) + expect(Facter.fact(:cassandraheapnewsize).value).to be(800) + expect(Facter.fact(:cassandracmsheapnewsize).value).to be(800) end end end end diff --git a/spec/unit/facter/cassandraminorversion_spec.rb b/spec/unit/facter/cassandraminorversion_spec.rb index 8e07b9b..799d60d 100644 --- a/spec/unit/facter/cassandraminorversion_spec.rb +++ b/spec/unit/facter/cassandraminorversion_spec.rb @@ -1,43 +1,43 @@ require 'spec_helper' describe 'Facter::Util::Fact' do before do Facter.clear end describe 'cassandrarelease DSE' do it do - allow(Facter::Util::Resolution) - .to receive(:exec).with('nodetool version') - .and_return('2.1.11.969') + allow(Facter::Util::Resolution). + to receive(:exec).with('nodetool version'). + and_return('2.1.11.969') expect(Facter.fact(:cassandrarelease).value).to eql('2.1.11') - expect(Facter.fact(:cassandramajorversion).value).to eql(2) - expect(Facter.fact(:cassandraminorversion).value).to eql(1) - expect(Facter.fact(:cassandrapatchversion).value).to eql(11) + expect(Facter.fact(:cassandramajorversion).value).to be(2) + expect(Facter.fact(:cassandraminorversion).value).to be(1) + expect(Facter.fact(:cassandrapatchversion).value).to be(11) end end describe 'cassandrarelease DDC' do it do - allow(Facter::Util::Resolution) - .to receive(:exec).with('nodetool version') - .and_return('3.0.1') + allow(Facter::Util::Resolution). + to receive(:exec).with('nodetool version'). + and_return('3.0.1') expect(Facter.fact(:cassandrarelease).value).to eql('3.0.1') - expect(Facter.fact(:cassandramajorversion).value).to eql(3) - expect(Facter.fact(:cassandraminorversion).value).to eql(0) - expect(Facter.fact(:cassandrapatchversion).value).to eql(1) + expect(Facter.fact(:cassandramajorversion).value).to be(3) + expect(Facter.fact(:cassandraminorversion).value).to be(0) + expect(Facter.fact(:cassandrapatchversion).value).to be(1) end end describe 'Cassandra not installed or not running' do it do - allow(Facter::Util::Resolution) - .to receive(:exec).with('nodetool version') - .and_return('') - expect(Facter.fact(:cassandrarelease).value).to eql(nil) - expect(Facter.fact(:cassandramajorversion).value).to eql(nil) - expect(Facter.fact(:cassandraminorversion).value).to eql(nil) - expect(Facter.fact(:cassandrapatchversion).value).to eql(nil) + allow(Facter::Util::Resolution). + to receive(:exec).with('nodetool version'). + and_return('') + expect(Facter.fact(:cassandrarelease).value).to be(nil) + expect(Facter.fact(:cassandramajorversion).value).to be(nil) + expect(Facter.fact(:cassandraminorversion).value).to be(nil) + expect(Facter.fact(:cassandrapatchversion).value).to be(nil) end end end diff --git a/spec/unit/facter/cassandrapatchversion_spec.rb b/spec/unit/facter/cassandrapatchversion_spec.rb index 8e07b9b..799d60d 100644 --- a/spec/unit/facter/cassandrapatchversion_spec.rb +++ b/spec/unit/facter/cassandrapatchversion_spec.rb @@ -1,43 +1,43 @@ require 'spec_helper' describe 'Facter::Util::Fact' do before do Facter.clear end describe 'cassandrarelease DSE' do it do - allow(Facter::Util::Resolution) - .to receive(:exec).with('nodetool version') - .and_return('2.1.11.969') + allow(Facter::Util::Resolution). + to receive(:exec).with('nodetool version'). + and_return('2.1.11.969') expect(Facter.fact(:cassandrarelease).value).to eql('2.1.11') - expect(Facter.fact(:cassandramajorversion).value).to eql(2) - expect(Facter.fact(:cassandraminorversion).value).to eql(1) - expect(Facter.fact(:cassandrapatchversion).value).to eql(11) + expect(Facter.fact(:cassandramajorversion).value).to be(2) + expect(Facter.fact(:cassandraminorversion).value).to be(1) + expect(Facter.fact(:cassandrapatchversion).value).to be(11) end end describe 'cassandrarelease DDC' do it do - allow(Facter::Util::Resolution) - .to receive(:exec).with('nodetool version') - .and_return('3.0.1') + allow(Facter::Util::Resolution). + to receive(:exec).with('nodetool version'). + and_return('3.0.1') expect(Facter.fact(:cassandrarelease).value).to eql('3.0.1') - expect(Facter.fact(:cassandramajorversion).value).to eql(3) - expect(Facter.fact(:cassandraminorversion).value).to eql(0) - expect(Facter.fact(:cassandrapatchversion).value).to eql(1) + expect(Facter.fact(:cassandramajorversion).value).to be(3) + expect(Facter.fact(:cassandraminorversion).value).to be(0) + expect(Facter.fact(:cassandrapatchversion).value).to be(1) end end describe 'Cassandra not installed or not running' do it do - allow(Facter::Util::Resolution) - .to receive(:exec).with('nodetool version') - .and_return('') - expect(Facter.fact(:cassandrarelease).value).to eql(nil) - expect(Facter.fact(:cassandramajorversion).value).to eql(nil) - expect(Facter.fact(:cassandraminorversion).value).to eql(nil) - expect(Facter.fact(:cassandrapatchversion).value).to eql(nil) + allow(Facter::Util::Resolution). + to receive(:exec).with('nodetool version'). + and_return('') + expect(Facter.fact(:cassandrarelease).value).to be(nil) + expect(Facter.fact(:cassandramajorversion).value).to be(nil) + expect(Facter.fact(:cassandraminorversion).value).to be(nil) + expect(Facter.fact(:cassandrapatchversion).value).to be(nil) end end end diff --git a/spec/unit/facter/cassandrarelease_spec.rb b/spec/unit/facter/cassandrarelease_spec.rb index 8e07b9b..799d60d 100644 --- a/spec/unit/facter/cassandrarelease_spec.rb +++ b/spec/unit/facter/cassandrarelease_spec.rb @@ -1,43 +1,43 @@ require 'spec_helper' describe 'Facter::Util::Fact' do before do Facter.clear end describe 'cassandrarelease DSE' do it do - allow(Facter::Util::Resolution) - .to receive(:exec).with('nodetool version') - .and_return('2.1.11.969') + allow(Facter::Util::Resolution). + to receive(:exec).with('nodetool version'). + and_return('2.1.11.969') expect(Facter.fact(:cassandrarelease).value).to eql('2.1.11') - expect(Facter.fact(:cassandramajorversion).value).to eql(2) - expect(Facter.fact(:cassandraminorversion).value).to eql(1) - expect(Facter.fact(:cassandrapatchversion).value).to eql(11) + expect(Facter.fact(:cassandramajorversion).value).to be(2) + expect(Facter.fact(:cassandraminorversion).value).to be(1) + expect(Facter.fact(:cassandrapatchversion).value).to be(11) end end describe 'cassandrarelease DDC' do it do - allow(Facter::Util::Resolution) - .to receive(:exec).with('nodetool version') - .and_return('3.0.1') + allow(Facter::Util::Resolution). + to receive(:exec).with('nodetool version'). + and_return('3.0.1') expect(Facter.fact(:cassandrarelease).value).to eql('3.0.1') - expect(Facter.fact(:cassandramajorversion).value).to eql(3) - expect(Facter.fact(:cassandraminorversion).value).to eql(0) - expect(Facter.fact(:cassandrapatchversion).value).to eql(1) + expect(Facter.fact(:cassandramajorversion).value).to be(3) + expect(Facter.fact(:cassandraminorversion).value).to be(0) + expect(Facter.fact(:cassandrapatchversion).value).to be(1) end end describe 'Cassandra not installed or not running' do it do - allow(Facter::Util::Resolution) - .to receive(:exec).with('nodetool version') - .and_return('') - expect(Facter.fact(:cassandrarelease).value).to eql(nil) - expect(Facter.fact(:cassandramajorversion).value).to eql(nil) - expect(Facter.fact(:cassandraminorversion).value).to eql(nil) - expect(Facter.fact(:cassandrapatchversion).value).to eql(nil) + allow(Facter::Util::Resolution). + to receive(:exec).with('nodetool version'). + and_return('') + expect(Facter.fact(:cassandrarelease).value).to be(nil) + expect(Facter.fact(:cassandramajorversion).value).to be(nil) + expect(Facter.fact(:cassandraminorversion).value).to be(nil) + expect(Facter.fact(:cassandrapatchversion).value).to be(nil) end end end