如何在测试厨房中编写特定于平台的测试?

How to write platform specific tests in test-kitchen?

编写根据所运行的平台做出不同反应的测试的最佳方式是什么?

我的用例如下:

我想确保我的系统免受 open ssl 中的 heartbleed 错误的影响。这意味着验证厨师安装的 openssl 包是最新的。对于 CentOS,最后一个易受攻击的版本是 1.0.1e-15,而对于 Ubuntu,它是 1.0.1-4ubuntu5.11

这取决于您使用的测试运行器,但对于 Serverspec:

describe command('openssl --version'), :if => os[:family] == 'ubuntu' do
  its(:stdout) { is_expected.to include '1.0.1-4ubuntu5.11' }
end

(未经测试,但请注意 os[:family] 助手的使用)