195 Commits

Author SHA1 Message Date
Jaroslav Prokop
5208032594 Docker provider: catch container name when using podman.
When user is using podman's docker CLI emulation the containers would
fail to enter running state because the docker driver could not catch
the container name. This commit fixes that by adding a check if podman
docker emulation is used and pick the container hash correctly from the
output.
2020-03-25 19:34:31 +01:00
Sophia Castellarin
2dadeb3ee5
Merge pull request #11461 from soapy1/get-docker-image-id
Get correct docker image from build output
2020-03-24 09:27:20 -05:00
Sophia Castellarin
e07d3c80e2
Merge pull request #11355 from terryburton/master
docker provider: Don't explode when removing an image if it is in use
2020-03-24 09:22:36 -05:00
Terry Burton
b566b0ee13
rmi docker provider tests: May also be in use by a stopped container 2020-03-23 23:28:18 +00:00
sophia
114742f3f8 Test rmi functionality for docker provider 2020-03-23 15:39:30 -05:00
sophia
ea7cc687f2 Add test for multiple Successsfully built messages 2020-03-23 09:55:30 -05:00
Jeff Bonhag
a10b2c3108
Fix #11403: Parse list dhcpservers output on VirtualBox 6.1 (#11404)
This commit creates a custom `read_dhcp_servers` method in the
VirtualBox 6.1 driver to handle changes made in the ouput of
`VBoxManage list dhcpservers`.

Tests for VirtualBox 6.1+ can no longer use the shared examples for the
VirtualBox 4.x driver, because the `read_dhcp_servers` change is not
backwards compatible.

This commit also creates the boilerplate for a VirtualBox 6.x shared
example in case we want to put tests there in the future.
2020-02-18 15:14:31 -05:00
Brian Cain
625bbf9cc8
Add more specific rescue exceptions for when errors occur for resizing
disks
2020-02-12 16:26:18 -08:00
Brian Cain
efde9595c4
Add error case handling for resizing vmdk disks 2020-02-12 09:32:38 -08:00
Brian Cain
1826d210a0
Recover from cloning and resizin disk failures
This commit adds some recovery if Vagrant fails to reattach or clone a
vmdk disk that needs to be resized. It first moves the original disk
(after cloning) to a backup file. If something fails, it will reattach
the original disk to the guest and continue to raise the exception.
2020-02-11 16:02:24 -08:00
Brian Cain
3662344d2e
Update rspec tests for driver methods 2020-02-10 15:31:10 -08:00
Brian Cain
b594715ded
Add tests for resizing disks 2020-02-10 12:58:11 -08:00
Brian Cain
0ea26b9506
Add test for comparing disk size 2020-02-10 12:58:11 -08:00
Brian Cain
d1d27a3b56
Add tests for handle_configure_disk 2020-02-10 12:58:11 -08:00
Brian Cain
6872625609
Add more tests for configure_disks virtualbox cap 2020-02-10 12:58:11 -08:00
Brian Cain
337f7dd616
Add cleanup_disks tests 2020-02-10 12:58:11 -08:00
Brian Cain
55cb8d1f0a
Add configure_disk blank unit test file and some method docs 2020-02-10 12:58:11 -08:00
Jeff Bonhag
d7a5f74897
Fixes #11128: Error if machine folder inaccessible (#11239)
This commit catches the Errno::EPERM raised by the operating system if
the machine folder is inaccessible and displays it as a more friendly
error message.

This can be an issue on macOS Catalina if virtual machine files are kept
in a special directory (Documents/Downloads/Desktop) that Vagrant's
embedded Ruby is not allowed to access.
2019-12-17 12:41:12 -05:00
Brian Cain
4d70856b8a
Enhance docker build matching for determining built container ID
Prior to this commit, docker would look for a container ID based on
"Successfully built" string. This output does not exist if a user has
enabled the experimental feature buildkit. This commit updates the build
behavior to match against both kinds of outputs, and instead of using
`scan`, it uses MatchData and groups the container id with match group
name `:id` instead of making hard assumptions with the matches being
contained inside arrays from scan.
2019-11-19 10:59:28 -08:00
Dan Čermák
fe4743a22b
Mock call to PrepareNetworks.list_interfaces in docker prepare_networks_test
The test "generates a network name and configuration" calls at the end
`process_public_network()`, which can return an empty list if the currently
executing machine has no usable network interfaces (this is typically the case
for workers that build rpm packages in OBS or Koji). This results in an
exception of type Errors::NetworkNoInterfaces to be thrown and causing this test
to fail.

This commit adds a mock of the PrepareNetworks.list_interfaces call that returns
a single entry with just the required defaults.
2019-11-01 17:36:31 +01:00
Brian Cain
7c93151f67
Add test for listing interfaces with docker networks 2019-10-10 11:38:57 -07:00
Brian Cain
8458a21657
Determine prefix with netmask 2019-10-09 15:40:36 -07:00
Brian Cain
62b7e35169
Fixes #11094: Determine prefix for docker public networks
Prior to this commit, the docker action was using the method `prefix` on
an IPv4 and IPv6 address. This works fine for ruby versions 2.5 and
newer, however the ruby shipped with Vagrant is before 2.5, and
therefore the IPv4 and IPv6 classes do not have the prefix method,
resulting in an error. This commit fixes that by using a different
method of determining the prefix.
2019-10-09 09:56:59 -07:00
Brian Cain
f1ea4eaac0
Ensure build_args are passed into docker compose config file
Prior to this commit, the docker compose build method would not properly
set build_args if given in a Vagrantfile. This commit fixes that by
using the passed in key `extra_args` from the docker build action.
2019-10-07 12:48:59 -07:00
Brian Cain
96e275451c
Merge pull request #10938 from andersk/virtualbox-usable
virtualbox: Fix usability test to reject bad installs without crashing
2019-10-07 09:04:24 -07:00
Anders Kaseorg
4afd370d6a virtualbox: Fix usability test to reject bad installs without crashing
If VirtualBox is installed but the kernel module is missing or the
service is stopped, the usability test should fail without crashing so
we can fall back to other providers.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2019-10-04 15:56:10 -07:00
Brian Cain
c7b1f8821d
Try to mock up docker version subprocess result in test 2019-09-11 09:36:11 -07:00
Brian Cain
d4002aa74d
Add vagrantfile mock to iso_env machine 2019-09-11 09:17:14 -07:00
Brian Cain
e820b5df8e
Add vagrantfile double for environment class 2019-09-11 09:01:35 -07:00
Brian Cain
f14cf09af6
Add allow for docker driver execute method 2019-09-11 08:37:07 -07:00
Brian Cain
21db2db9ac
Add machine config to machine double for rspec tests
This commit mocks up the docker machines test config so that it doesn't
actually invoke the docker driver in circle-ci
2019-09-11 08:09:26 -07:00
Brian Cain
ebe1f3f1c9
Remove virtualbox context from docker tests 2019-09-11 07:46:40 -07:00
Anders Kaseorg
5b4dcf9443
providers/docker: Fix usability check
In commit 7980178d194bb21bde2e21858fbc969e4cc7eb3f (#10879) I added a
`usable?` class method to `VagrantPlugins::DockerProvider::Provider`.
However, commit 34e53a5a4b208edcc3e25c1f0e3aa0ef56e8d8d9 (#10890)
incorrectly changed it to an instance method.  This rendered it
ineffective because it’s called on the class, not an instance.  Change
it back to a class method.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2019-09-10 15:10:43 -07:00
Brian Cain
09af983caa
Fixes #11051: Only use host vm if specified
Prior to this commit, the docker login action assumed that if there was
a password to authenticate with, Vagrant was using a host vm to run
docker. This is likely due to some legacy decisions with how Vagrant
used to manage running docker. This commit fixes that by only grabbing a
host_vm lock if the host_vm is actually in use, otherwise login
normally.
2019-09-05 14:54:40 -07:00
Chris Roberts
2f2d1f9cb2 Fix docker test to not call docker executable 2019-06-19 11:59:09 -07:00
Brian Cain
fb80e8da9f
Merge pull request #10890 from briancain/add-usability-check-for-docker-plus-tests
Add usability check for docker plus tests
2019-06-05 07:58:23 -07:00
Brian Cain
bb6913e6e8
Fixup virtualbox provider tests for Travis 2019-06-04 14:43:13 -07:00
Brian Cain
74c89e5ec1
Add virtualbox provider rspec tests 2019-06-04 14:14:06 -07:00
Brian Cain
34e53a5a4b
Add docker provider class test
This commit introduces aa provider_test class for the Docker provider
2019-06-04 13:24:07 -07:00
Brian Cain
ca0fd64ded
Fixes #10798: Enhance how docker compose driver path expands
Prior to this commit, the docker compose driver would _always_ path
expand a host volume no matter what. This is not always the correct
option, for example if that host volume is actually a reference to a key
inside a `volumes` hash instead of a path on disk. This commit changes
that by looking to see if the requested host volume is actually a
defined key inside the compose config, and if not, it will path expand
it like before. Otherwise it will leave the key "as is".
2019-04-29 16:14:37 -07:00
Brian Cain
75d4aa42a1
Ensure non-existent machines do not attempt to list snapshots
Prior to this commit, if a snapshot restore was run on an entire
environment with some non-existent guests, Vagrant would attempt to list
their snapshots with a nil id. This commit fixes that by returning an
empty list of snapshots if the machine has not been created yet.
2019-04-09 13:11:19 -07:00
Brian Cain
f8744b66f0
Add connect cli argument tests 2019-03-22 09:24:26 -07:00
Brian Cain
4f80a9e6d5
Add test for requesting public ip range for docker network provider 2019-03-22 09:02:40 -07:00
Brian Cain
36f2aaf55e
Add test for public network gateway request 2019-03-22 08:45:14 -07:00
Brian Cain
b56f89775d
Add more mocks for public network
Ensure test values are used rather than real values from machine
2019-03-22 08:24:22 -07:00
Brian Cain
6bffdca972
Add beginning of connect network tests for docker provider 2019-03-21 16:06:24 -07:00
Brian Cain
88a18fe2c5
Add public network tests for docker provider 2019-03-21 16:06:11 -07:00
Brian Cain
82700d95b3
Ensure subnet is used if specified from user config options 2019-03-21 15:29:04 -07:00
Brian Cain
2bc6fa854a
Add tests for validating network configurations 2019-03-21 13:51:24 -07:00
Brian Cain
36a41957c9
Fix travis ci tests for public gateway and ip range issues 2019-03-21 13:51:07 -07:00