kitchen-docker:如何在厨房收敛之前运行shell命令

时间:2016-12-20 12:19:11

标签: docker chef test-kitchen

当使用带有测试厨房的流浪汉机器时,pre_create_command允许您指定在创建流浪汉机器之前在本地运行的命令。使用kitchen-docker似乎不存在此类配置选项,并且根据建议here弯曲chef_omnibus_url不是一个选项。

为测试流浪者指定为pre_create_command的脚本会生成一个本地厨师数据包。

我是否有一个我忽略的解决方案?

3 个答案:

答案 0 :(得分:0)

最佳做法包括Rakefile和Thor。

实质上,您可以从Rakefile控制测试。例如:

rake style

这将运行您的样式任务下的所有命令(可能是lint / syntax / unit和kitchen tests)。当然,您可以修改您的任务以执行您喜欢的任何操作。这是一些很好的资源:

https://blog.chef.io/2015/04/21/overview-of-test-driven-infrastructure-with-chef/

请参阅“支持工具和依赖关系”部分。

以下是Rakefile示例:

https://github.com/chef-cookbooks/chef-server/blob/master/Rakefile

答案 1 :(得分:0)

我勾画了一个厨房码头here的补丁。然而,正如关于这个拉动请求的讨论所显示的那样,反对厨房 - 码头工具中的适当功能存在争议,即这种功能(如果有的话)应该放在厨房核心中。

因此暂时我们不得不忍受码头工人和流浪者之间的这种不一致,这就是这个答案发挥作用的地方。

答案 2 :(得分:0)

可以使用

XPathExpression xPathExpression = xPath.compile("/catalog/book[(publish_date > '2005') and (number(price) > 10)]");
NodeList bookNodes = (NodeList)xPathExpression.evaluate(inputSource, XPathConstants.NODESET);
for (int i = 0; i < bookNodes.getLength(); i++) {
    Element bookElement = bookNodes.item(i);
    System.out.println("Author: " + bookElement.getElementsByTagName("author").item(0).getNodeValue());
}

driver_config: provision_command: <command>

检查更多here

K,

Rshad