From da7f957a46fbfcbb5681e031225e77270728fba5 Mon Sep 17 00:00:00 2001 From: sophia Date: Mon, 14 Sep 2020 14:50:10 -0500 Subject: [PATCH] Add docker provider spec tests --- test/vagrant-spec/Vagrantfile.spec | 23 +++++++++++-------- .../configs/vagrant-spec.config.docker.rb | 11 +++++++++ .../vagrant-spec/scripts/ubuntu-run.docker.sh | 8 +++++++ .../scripts/ubuntu-setup.docker.sh | 14 +++++++++++ 4 files changed, 46 insertions(+), 10 deletions(-) create mode 100644 test/vagrant-spec/configs/vagrant-spec.config.docker.rb create mode 100644 test/vagrant-spec/scripts/ubuntu-run.docker.sh create mode 100644 test/vagrant-spec/scripts/ubuntu-setup.docker.sh diff --git a/test/vagrant-spec/Vagrantfile.spec b/test/vagrant-spec/Vagrantfile.spec index 37524ac41..b1b12be66 100644 --- a/test/vagrant-spec/Vagrantfile.spec +++ b/test/vagrant-spec/Vagrantfile.spec @@ -4,19 +4,19 @@ # Guest boxes to use for vagrant-spec GUEST_BOXES = { 'hashicorp/bionic64' => '1.0.282', - 'hashicorp-vagrant/ubuntu-16.04' => '1.0.1', - 'hashicorp-vagrant/centos-7.4' => '1.0.2', - 'hashicorp-vagrant/windows-10' => '1.0.0', - 'spox/osx-10.12' => '0.0.1' + # 'hashicorp-vagrant/ubuntu-16.04' => '1.0.1', + # 'hashicorp-vagrant/centos-7.4' => '1.0.2', + # 'hashicorp-vagrant/windows-10' => '1.0.0', + # 'spox/osx-10.12' => '0.0.1' } # Host boxes to run vagrant-spec HOST_BOXES = { 'hashicorp/bionic64' => '1.0.282', - 'hashicorp-vagrant/ubuntu-16.04' => '1.0.1', - 'hashicorp-vagrant/centos-7.4' => '1.0.2', - 'hashicorp-vagrant/windows-10' => '1.0.0', - 'spox/osx-10.12' => '0.0.1' + # 'hashicorp-vagrant/ubuntu-16.04' => '1.0.1', + # 'hashicorp-vagrant/centos-7.4' => '1.0.2', + # 'hashicorp-vagrant/windows-10' => '1.0.0', + # 'spox/osx-10.12' => '0.0.1' } # Not all boxes are named by their specific "platform" @@ -24,8 +24,8 @@ HOST_BOXES = { PLATFORM_SCRIPT_MAPPING = { "ubuntu" => "ubuntu", "bionic" => "ubuntu", - "centos" => "centos", - "windows" => "windows" + # "centos" => "centos", + # "windows" => "windows" } # Determine what providers to test @@ -42,6 +42,9 @@ vagrantcloud_token = ENV["VAGRANT_CLOUD_TOKEN"] # Download copies of the guest boxes for testing if missing enabled_providers.each do |provider_name| + + next if provider_name == "docker" + guest_boxes.each do |guest_box, box_version| box_owner, box_name = guest_box.split('/') box_path = File.join(File.dirname(__FILE__), "./boxes/#{guest_box.sub('/', '_')}.#{provider_name}.#{box_version}.box") diff --git a/test/vagrant-spec/configs/vagrant-spec.config.docker.rb b/test/vagrant-spec/configs/vagrant-spec.config.docker.rb new file mode 100644 index 000000000..5c7f532aa --- /dev/null +++ b/test/vagrant-spec/configs/vagrant-spec.config.docker.rb @@ -0,0 +1,11 @@ +require_relative "../../acceptance/base" + +Vagrant::Spec::Acceptance.configure do |c| + c.component_paths << File.expand_path("../test/acceptance", __FILE__) + c.skeleton_paths << File.expand_path("../test/acceptance/skeletons", __FILE__) + # Allow for slow setup to still pass + c.assert_retries = 15 + c.provider "docker", + box: ENV["VAGRANT_SPEC_DOCKER_IMAGE"], + contexts: ["provider-context/docker"] +end diff --git a/test/vagrant-spec/scripts/ubuntu-run.docker.sh b/test/vagrant-spec/scripts/ubuntu-run.docker.sh new file mode 100644 index 000000000..005fb70a0 --- /dev/null +++ b/test/vagrant-spec/scripts/ubuntu-run.docker.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -x + +export VAGRANT_SPEC_DOCKER_IMAGE="${VAGRANT_SPEC_DOCKER_IMAGE}" +vagrant vagrant-spec ${VAGRANT_SPEC_ARGS} /vagrant/test/vagrant-spec/configs/vagrant-spec.config.docker.rb +result=$? + +exit $result diff --git a/test/vagrant-spec/scripts/ubuntu-setup.docker.sh b/test/vagrant-spec/scripts/ubuntu-setup.docker.sh new file mode 100644 index 000000000..a5d4dfe80 --- /dev/null +++ b/test/vagrant-spec/scripts/ubuntu-setup.docker.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -xe + +apt-get update +apt-get install -qq -y --force-yes curl apt-transport-https +apt-get purge -qq -y lxc-docker* || true +curl -sSL https://get.docker.com/ | sh + +pushd /vagrant + +dpkg -i vagrant_*_x86_64.deb +vagrant plugin install ./vagrant-spec.gem + +popd