在 Travis-CI 中启动 Vagrant VM [英] Launching a Vagrant VM inside Travis-CI

查看:35
本文介绍了在 Travis-CI 中启动 Vagrant VM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Travis-CI 中使用 Vagrant 启动 Virtualbox VM?

How do you launch a Virtualbox VM using Vagrant inside Travis-CI?

我知道有时不支持在虚拟机内启动虚拟机,但已经有 使用此特定配置报告成功.

I know launching a VM inside a VM is sometimes not supported, but there have been reported successes with this specific configuration.

我正在尝试设置一个持续集成服务器来为我的系统管理工具运行单元测试, 以在不同的操作系统和 Python 版本中对其进行测试.它使用 Tox 来处理初始化各种 Python 虚拟环境和 Pytest 运行测试并包装 Vagrant 以设置和拆除 Virtualbox VM.它在我的 Ubuntu 14 本地主机上运行良好,但在 Travis 中,Vagrant 在尝试启动 Virtualbox VM 时超时:

I'm trying to setup a continuous integration server to run unittests for my sysadmin tool, to test it across different operating systems and Python versions. It uses Tox to handle initializing the various Python virtual environments and Pytest to run the tests and wrap Vagrant to setup and teardown the Virtualbox VM. It runs fine on my Ubuntu 14 localhost, but in Travis, Vagrant times out trying to boot a 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,但都没有帮助.

Since it's not giving me any details, I'm not sure how to diagnose the problem. I tried to enable more output with export VAGRANT_LOG=DEBUG; but that didn't show anything useful and exceeded Travis's maximum log size. I also tried increasing the timeout, and the memory allocation to 1GB, but neither helped.

我注意到的唯一奇怪的事情,我无法解释,是来自 sudo apt-get -y install -q virtualbox-ose-dkms virtualbox --fix-missing:

The only odd thing I've noticed, that I've not been able to explain, is this message from 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.

然而,就在这之前,安装内核源代码的命令成功了:

However, immediately before this, the command to install kernel source succeeds:

sudo apt-get -y --force-yes install linux-headers-`uname -r`

如何在 Travis-CI 中启动 Vagrant/Virtualbox VM?

How do you launch a Vagrant/Virtualbox VM inside Travis-CI?

推荐答案

遗憾的是 Travis-CI 不支持此功能,并且近期没有计划这样做.检查以下票证:https://github.com/travis-ci/travis-ci/issues/6060

Sadly this is not supported by Travis-CI and there's no plan to do it in the near future. Check the following ticket: https://github.com/travis-ci/travis-ci/issues/6060

由于 Travis 在虚拟化容器 (OpenVZ) 中运行您的构建,您可以尝试使用 32 位 VM.这可以工作,但我还没有测试过.

Since Travis is running your build in a virtualized container (OpenVZ) you could try with a 32-bit VM. That could work, but I haven't tested.

这篇关于在 Travis-CI 中启动 Vagrant VM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆