require 'spec_helper'

describe file('/etc/ceilometer/ceilometer.conf') do
  it { should contain('^admin_password[ ]*=[ ]*.\{8,\}') }
end

dirs = ['/etc/ceilometer/', '/var/log/ceilometer/']
dirs.each do |dir|
  describe file(dir) do
    it { should be_directory }
    it { should be_mode '755'}
  end
end

files = ['api_paste.ini', 'event_pipeline.yaml', 'policy.json',
  'ceilometer.conf', 'event_definitions.yaml', 'pipeline.yaml']
files.each do |file|
  describe file("/etc/ceilometer/#{file}") do
    it { should be_mode '644'}
  end
end

processes = ['ceilometer-api',
  'ceilometer-collector',
  'ceilometer-agent-notification',
  'ceilometer-agent-central',
  'ceilometer-alarm-evaluator',
  'ceilometer-alarm-notifier']
processes.each do |process|
  describe process(process) do
    its(:user) { should eq 'ceilometer' }
  end
end

files = Dir['/var/log/ceilometer/*']
files.each do |file|
  describe file(file) do
    it { should be_mode 644 }
  end
end

describe file("/etc/ceilometer/ceilometer.conf") do
  it { should contain '^debug = {{ ceilometer.logging.debug }}' }
end

require 'spec_helper'

describe file('/etc/ceilometer/ceilometer.conf') do
  it { should contain('^admin_password[ ]*=[ ]*.\{8,\}') }
end

dirs = ['/etc/ceilometer/', '/var/log/ceilometer/']
dirs.each do |dir|
  describe file(dir) do
    it { should be_directory }
    it { should be_mode '755'}
  end
end

files = ['api_paste.ini', 'event_pipeline.yaml', 'policy.json',
  'ceilometer.conf', 'event_definitions.yaml', 'pipeline.yaml']
files.each do |file|
  describe file("/etc/ceilometer/#{file}") do
    it { should be_mode '644'}
  end
end

{% if inventory_hostname in groups['controller'] %}
processes = ['ceilometer-api',
  'ceilometer-collector',
  'ceilometer-agent-notification',
  'ceilometer-agent-central',
  'ceilometer-alarm-evaluator',
  'ceilometer-alarm-notifier']
processes.each do |process|
  describe process(process) do
    its(:user) { should eq 'ceilometer' }
  end
end
{% endif %}

files = Dir['/var/log/ceilometer/*']
files.each do |file|
  describe file(file) do
    it { should be_mode 644 }
  end
end

describe file("/etc/ceilometer/ceilometer.conf") do
  it { should contain '^debug = {{ ceilometer.logging.debug }}' }
end

Check ceilometer process on controller nodes only
Check ceilometer process on controller nodes only

The process checked for by the ceilometer serverspec only exist
on controller nodes. We should only drop those checks on the node
ceilometer role is being run on if it is in the controller group.
