control 'iscsi_remount' do
  title 'Checks iscsi_remount recipe'

  if platform_family?('rhel')

    remount_script = '/root/iscsi_remount.sh'

    # Required packages
    packages = %w(
      iscsi-initiator-utils
    )

    packages.each do |package|
      describe package(package) do
        it { should be_installed }
      end
    end

    describe file(remount_script) do
      it { should exist }
      it { should be_owned_by 'root' }
      it { should be_grouped_into 'root' }
      its('mode') { should cmp '0755' }
    end

    describe service('iscsi') do
      it { should be_installed }
      it { should be_enabled }
      it { should be_running }
    end

    if node['platform_version'].start_with?('6')

      describe file('/etc/rc.d/rc.local') do
        it { should exist }
        it { should be_owned_by 'root' }
        it { should be_grouped_into 'root' }
        its('mode') { should cmp '0755' }
        its('content') { should match(%r{\/root\/iscsi_remount.sh}) }
      end

    elsif node['platform_version'].start_with?('7')

      describe service('iscsi-remount') do
        it { should be_installed }
        it { should be_enabled }
      end

    end
  end
end
