测试厨房:厨师重启后不重启

时间:2017-03-27 11:24:09

标签: vagrant chef test-kitchen convergence

我在使用Kitchen测试厨师食谱时遇到了问题。 我使用Vagrant作为驱动程序,使用Virtual Box作为虚拟化系统。它们在Linux平台上运行。

我已经创建了一个测试配方来重启我的机器。 这是代码:

#
# Author:: Alessandro Zucchelli
# Recipe:: test_recipe_required_reboot
#

reboot 'test if kitchen runs when a recipe leaves it to the post-install phase' do
  action :request_reboot
  reason 'Need to reboot when the run completes successfully.'
  delay_mins 1
end

我在这种模式下配置我的.kitchen.yml:

driver:
  name: vagrant
  gui: true
  boot_timeout: 1200
#  log_level: debug
provisioner:
  name: chef_zero
  require_chef_omnibus: 12.11 # need the RFC 062 exit codes
  retry_on_exit_code: 
    - 35 # 35 is the exit code signaling that the node is rebooting
  max_retries: 3
  multiple_converge: 3
  client_rb:
    exit_status: :enabled # Opt-in to the standardized exit codes
    client_fork: false # Forked instances don't return the real exit code
  #log_level: debug
platforms:
  - name: mybox/win-7-professional-amd64-nocm
    transport:
        name: winrm
        elevated: true
        connection_timeout: 3600
        max_wait_until_ready: 600
        connection_retry_sleep: 300

我希望通过启动配方循环重启vm不止一次。 相反,在第一次重启后,我得到了:

      Starting Chef Client, version 12.11.18
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Failed to complete #converge action: [execution expired] on ktest-mybox-win-7-professional-amd64-nocm
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

1 个答案:

答案 0 :(得分:1)

我解决了我的问题! 我在kitchen.yml中添加了这些参数(查看代码块),现在工作正常!

  max_retries: 3
  multiple_converge: 3
  wait_for_retry: 600

我的食谱现在重启我的虚拟机4次!