如何使用 Vagrant 启动 Virtualbox VM Travis-CI ?
我知道有时不支持在虚拟机内启动虚拟机,但有 reported successes具有此特定配置。
我正在尝试设置一个持续集成服务器来为我的 sysadmin tool 运行单元测试,跨不同操作系统和 Python 版本进行测试。它使用 Tox处理初始化各种Python虚拟环境和Pytest运行测试并包装 Vagrant 以设置和拆卸 Virtualbox VM。它在我的 Ubuntu 14 本地主机上运行良好,但在 Travis 中,Vagrant 在尝试启动 Virtualbox VM 时超时:
==> default: Importing base box 'ubuntu/trusty64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/trusty64' is up to date...
==> default: Setting the name of the VM: functional_tests_default_1463515960654_71459
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 => 2222 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
...
The job exceeded the maximum time limit for jobs, and has been terminated.
由于它没有给我任何详细信息,我不确定如何诊断问题。我尝试使用 export VAGRANT_LOG=DEBUG;
启用更多输出但这没有显示任何有用的信息,并且超出了 Travis 的最大日志大小。我还尝试增加超时和内存分配到 1GB,但都没有帮助。
我注意到的唯一奇怪的事情是我无法解释的,这是来自 sudo apt-get -y install -q virtualbox-ose-dkms virtualbox --fix-missing
的消息。 :
Module build for the currently running kernel was skipped since the
kernel source for this kernel does not seem to be installed.
但是,在此之前,安装内核源代码的命令成功了:
sudo apt-get -y --force-yes install linux-headers-`uname -r`
如何在 Travis-CI 中启动 Vagrant/Virtualbox 虚拟机?
最佳答案
遗憾的是,Travis-CI 不支持这一点,并且在不久的将来也没有计划这样做。查看以下票证:https://github.com/travis-ci/travis-ci/issues/6060
由于 Travis 在虚拟化容器 (OpenVZ) 中运行您的构建,因此您可以尝试使用 32 位 VM。这可能有效,但我还没有测试过。
关于vagrant - 在 Travis-CI 中启动 Vagrant VM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37307114/