1

我有一本设置 Splunk Forwarder 的食谱。我为配置文件创建了许多集成 - serverspec 测试。特别是一个,/opt/splunkforwarder/etc/apps/search/local/inputs.conf不断失败其他文件正在通过的所有测试。我的代码如下所示:

require 'spec_helper'

describe file('/opt/splunkforwarder/etc/apps/search/local/') do
  it { should be_directory }
  it { should be_owned_by 'nobody' }
  it { should be_mode 755 }
end

describe file('/opt/splunkforwarder/etc/system/local/') do
  it { should be_directory }
  it { should be_owned_by 'nobody' }
  it { should be_mode 755 }
end

describe file('/opt/splunkforwarder/etc/system/local/outputs.conf') do
  it { should exist }
  it { should be_owned_by 'nobody' }
  it { should be_mode 600 }
end

describe file('/opt/splunkforwarder/etc/system/local/inputs.conf') do
  it { should exist }
  it { should be_owned_by 'nobody' }
  it { should be_mode 600 }
end

describe file('/opt/splunkforwarder/etc/apps/search/local/inputs.conf}') do
  it { should exist }
  it { should be_owned_by 'nobody' }
  it { should be_mode 600 }
end

describe file('/opt/splunkforwarder/etc/apps/SplunkUniversalForwarder/default/limits.conf') do
  it { should exist }
  it { should be_owned_by 'nobody' }
  it { should be_mode 444 }
end

describe file('/opt/splunkforwarder/etc/system/local/web.conf') do
  it { should exist }
  it { should be_owned_by 'nobody' }
  it { should be_mode 600 }
end

此规范文件中的每个文件和目录都通过,除了/opt/splunkforwarder/etc/apps/search/local/inputs.conf. 我正在使用 Docker 实例和测试厨房,所以当我登录时,我发现:

  1. 文件存在
  2. 该文件归“nobody”所有
  3. 该文件有600个权限

与其他几个文件完全一样。此外,我可以从我的 Chef 融合的标准中看到,创建的文件具有正确的权限和所有权以及内容。

我已经检查过其中一个父目录是否没有正确拥有或具有与传递的其他文件不同的权限,但事实并非如此。

我不知道为什么这没有通过。

4

1 回答 1

2

我怀疑测试中的错字是你的敌人。

describe file('/opt/splunkforwarder/etc/apps/search/local/inputs.conf}') do

尝试删除该支架并再次运行测试。

于 2017-10-09T12:38:42.197 回答