From 9dbf2c5129c89ce59356907b2cd9fa5210988c10 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Tue, 18 Feb 2020 13:16:46 -0800 Subject: [PATCH 01/29] Add initial files for running spec tests --- .ci/spec/build-vagrant-spec.sh | 0 .ci/spec/run-test.sh | 0 .github/workflows/spectesting.yml | 31 +++++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 .ci/spec/build-vagrant-spec.sh create mode 100644 .ci/spec/run-test.sh create mode 100644 .github/workflows/spectesting.yml diff --git a/.ci/spec/build-vagrant-spec.sh b/.ci/spec/build-vagrant-spec.sh new file mode 100644 index 000000000..e69de29bb diff --git a/.ci/spec/run-test.sh b/.ci/spec/run-test.sh new file mode 100644 index 000000000..e69de29bb diff --git a/.github/workflows/spectesting.yml b/.github/workflows/spectesting.yml new file mode 100644 index 000000000..b6cdcdab5 --- /dev/null +++ b/.github/workflows/spectesting.yml @@ -0,0 +1,31 @@ +on: + push: + branches: + - master + - 'spec-test-*' + paths-ignore: + - 'CHANGELOG.md' + - 'website/**' + +jobs: + spec-tests: + if: github.repository == 'hashicorp/vagrant' + runs-on: self-hosted + strategy: + matrix: + host_os: ["hashicorp/bionic64"] + guest_os: ["hashicorp/bionic64", "hashicorp-vagrant/ubuntu-16.04"] + name: Vagrant-Spec Tests + steps: + - name: Code Checkout + uses: actions/checkout@v1 + - name: vagrant-spec Code Checkout and Build + run: .ci/spec/build-vagrant-spec.sh + - name: Run Tests + run: .ci/spec/run-test.sh + env: + PKT_VAGRANT_HOST_BOXES: ${{ matrix.host_os }} + PKT_VAGRANT_GUEST_BOXES: ${{ matrix.guest_os }} + - name: Clean Workspace + if: always() + run: rm -rf ${{ github.workspace }} From 51c4f584127b6cebf4cc35a415b418b0e6bfcf8c Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Tue, 18 Feb 2020 13:18:23 -0800 Subject: [PATCH 02/29] Make scripts executable --- .ci/spec/build-vagrant-spec.sh | 1 + .ci/spec/run-test.sh | 1 + 2 files changed, 2 insertions(+) mode change 100644 => 100755 .ci/spec/build-vagrant-spec.sh mode change 100644 => 100755 .ci/spec/run-test.sh diff --git a/.ci/spec/build-vagrant-spec.sh b/.ci/spec/build-vagrant-spec.sh old mode 100644 new mode 100755 index e69de29bb..f1f641af1 --- a/.ci/spec/build-vagrant-spec.sh +++ b/.ci/spec/build-vagrant-spec.sh @@ -0,0 +1 @@ +#!/usr/bin/env bash diff --git a/.ci/spec/run-test.sh b/.ci/spec/run-test.sh old mode 100644 new mode 100755 index e69de29bb..f1f641af1 --- a/.ci/spec/run-test.sh +++ b/.ci/spec/run-test.sh @@ -0,0 +1 @@ +#!/usr/bin/env bash From e8a4380a00ca273fc947a85cca5a5fdfcbd4c0aa Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Tue, 18 Feb 2020 13:56:22 -0800 Subject: [PATCH 03/29] Add initial scripts for running spec tests on packet --- .ci/spec/build-vagrant-spec.sh | 7 ++++ .ci/spec/run-test.sh | 67 +++++++++++++++++++++++++++++++ .github/workflows/spectesting.yml | 7 ++-- 3 files changed, 78 insertions(+), 3 deletions(-) diff --git a/.ci/spec/build-vagrant-spec.sh b/.ci/spec/build-vagrant-spec.sh index f1f641af1..714aec949 100755 --- a/.ci/spec/build-vagrant-spec.sh +++ b/.ci/spec/build-vagrant-spec.sh @@ -1 +1,8 @@ #!/usr/bin/env bash + +git clone git@github.com:hashicorp/vagrant-spec.git +cd vagrant-spec +bundle install +gem build vagrant-spec.gemspec +# Assumes this is being run in the same workspace as the main vagrant repo +mv vagrant-spec-*.gem ../vagrant-spec.gem diff --git a/.ci/spec/run-test.sh b/.ci/spec/run-test.sh index f1f641af1..44c1aaf00 100755 --- a/.ci/spec/run-test.sh +++ b/.ci/spec/run-test.sh @@ -1 +1,68 @@ #!/usr/bin/env bash + +# packet and job configuration +export SLACK_USERNAME="Vagrant" +export SLACK_ICON="https://media.giphy.com/media/yIQ5glQeheYE0/200.gif" +export SLACK_TITLE="Vagrant-Spec Test Runner" +export PACKET_EXEC_DEVICE_NAME="${PACKET_EXEC_DEVICE_NAME:-spec-ci-boxes}" +export PACKET_EXEC_DEVICE_SIZE="${PACKET_EXEC_DEVICE_SIZE:-baremetal_0,baremetal_1,baremetal_1e}" +export PACKET_EXEC_PREFER_FACILITIES="${PACKET_EXEC_PREFER_FACILITIES:-iad1,iad2,ewr1,dfw1,dfw2,sea1,sjc1,lax1}" +export PACKET_EXEC_OPERATING_SYSTEM="${PACKET_EXEC_OPERATING_SYSTEM:-ubuntu_18_04}" +export PACKET_EXEC_PRE_BUILTINS="${PACKET_EXEC_PRE_BUILTINS:-InstallVagrant,InstallVirtualBox,InstallVmware,InstallHashiCorpTool,InstallVagrantVmware}" +export PACKET_EXEC_QUIET="1" +export PKT_VAGRANT_CLOUD_TOKEN="${VAGRANT_CLOUD_TOKEN}" +export VAGRANT_PKG_VERSION="2.2.7" # need to figure out how to make this latest instead +### + + +csource="${BASH_SOURCE[0]}" +while [ -h "$csource" ] ; do csource="$(readlink "$csource")"; done +root="$( cd -P "$( dirname "$csource" )/../" && pwd )" + +. "${root}/.ci/common.sh" + +pushd "${root}" > "${output}" + +# Define a custom cleanup function to destroy any orphan guests +# on the packet device +function cleanup() { + (>&2 echo "Cleaning up packet device") + unset PACKET_EXEC_PERSIST + pkt_wrap_stream "cd vagrant;VAGRANT_CWD=test/vagrant-spec/ VAGRANT_VAGRANTFILE=Vagrantfile.spec vagrant destroy -f" \ + "Vagrant command failed" +} + +# Ensure we have a packet device to connect +echo "Creating packet device if needed..." + +packet-exec info + +if [ $? -ne 0 ]; then + wrap_stream packet-exec create \ + "Failed to create packet device" +fi + +# job_id is provided by common.sh +export PACKET_EXEC_REMOTE_DIRECTORY="${job_id}" +export PACKET_EXEC_PERSIST="1" + +# spec test configuration, defined by action runners +export PKT_VAGRANT_HOST_BOXES="${VAGRANT_HOST_BOXES}" +export PKT_VAGRANT_GUEST_BOXES="${VAGRANT_GUEST_BOXES}" +### + +echo "Setting up remote packet device for current job... " +# NOTE: We only need to call packet-exec with the -upload option once +# since we are persisting the job directory. This command +# is used simply to seed the work directory. +wrap_stream packet-exec run -upload -- /bin/true \ + "Failed to setup project on remote packet instance" + +# Run the job + +echo "Running vagrant spec tests..." +pkt_wrap_stream "cd vagrant;VAGRANT_HOST_MEMORY=5000 VAGRANT_CWD=test/vagrant-spec/ VAGRANT_VAGRANTFILE=Vagrantfile.spec vagrant up --provider vmware_desktop" \ + "Vagrant command failed" + + +echo "Finished vagrant spec tests" diff --git a/.github/workflows/spectesting.yml b/.github/workflows/spectesting.yml index b6cdcdab5..65a162c9b 100644 --- a/.github/workflows/spectesting.yml +++ b/.github/workflows/spectesting.yml @@ -1,7 +1,6 @@ on: push: branches: - - master - 'spec-test-*' paths-ignore: - 'CHANGELOG.md' @@ -20,12 +19,14 @@ jobs: - name: Code Checkout uses: actions/checkout@v1 - name: vagrant-spec Code Checkout and Build + working-directory: ${{github.workspace}} run: .ci/spec/build-vagrant-spec.sh - name: Run Tests run: .ci/spec/run-test.sh + working-directory: ${{github.workspace}} env: - PKT_VAGRANT_HOST_BOXES: ${{ matrix.host_os }} - PKT_VAGRANT_GUEST_BOXES: ${{ matrix.guest_os }} + VAGRANT_HOST_BOXES: ${{ matrix.host_os }} + VAGRANT_GUEST_BOXES: ${{ matrix.guest_os }} - name: Clean Workspace if: always() run: rm -rf ${{ github.workspace }} From b326646fe5822cd2a3cfcb09ddd161e8401a9ace Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Tue, 18 Feb 2020 14:15:01 -0800 Subject: [PATCH 04/29] Add more descriptive title to job --- .github/workflows/spectesting.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/spectesting.yml b/.github/workflows/spectesting.yml index 65a162c9b..aa31c8b47 100644 --- a/.github/workflows/spectesting.yml +++ b/.github/workflows/spectesting.yml @@ -21,7 +21,7 @@ jobs: - name: vagrant-spec Code Checkout and Build working-directory: ${{github.workspace}} run: .ci/spec/build-vagrant-spec.sh - - name: Run Tests + - name: Run Tests on ${{ matrix.host_os }} with guest ${{ matrix.guest_os }} run: .ci/spec/run-test.sh working-directory: ${{github.workspace}} env: From dbec1a4182b2fe9dddbd8f5db6089fedf0bdc81c Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Tue, 18 Feb 2020 15:16:29 -0800 Subject: [PATCH 05/29] Ensure bundler exists --- .ci/spec/build-vagrant-spec.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.ci/spec/build-vagrant-spec.sh b/.ci/spec/build-vagrant-spec.sh index 714aec949..192db32bc 100755 --- a/.ci/spec/build-vagrant-spec.sh +++ b/.ci/spec/build-vagrant-spec.sh @@ -2,6 +2,7 @@ git clone git@github.com:hashicorp/vagrant-spec.git cd vagrant-spec +gem install bundle bundle install gem build vagrant-spec.gemspec # Assumes this is being run in the same workspace as the main vagrant repo From 38cb7380177dc6e1891e06bacd4ccbedd1997f21 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Tue, 18 Feb 2020 15:16:36 -0800 Subject: [PATCH 06/29] Setup ruby for building vagrant-spec gem --- .github/workflows/spectesting.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/spectesting.yml b/.github/workflows/spectesting.yml index aa31c8b47..233a6fa24 100644 --- a/.github/workflows/spectesting.yml +++ b/.github/workflows/spectesting.yml @@ -18,6 +18,11 @@ jobs: steps: - name: Code Checkout uses: actions/checkout@v1 + - name: Setup Ruby + uses: actions/setup-ruby@v1 + with: + ruby-version: '2.6.x' + architecture: 'x64' - name: vagrant-spec Code Checkout and Build working-directory: ${{github.workspace}} run: .ci/spec/build-vagrant-spec.sh From 1da68413ba143995186e05c13e7b342d5d076f55 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Tue, 18 Feb 2020 15:23:08 -0800 Subject: [PATCH 07/29] Add note about windows host memory --- .ci/spec/run-test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.ci/spec/run-test.sh b/.ci/spec/run-test.sh index 44c1aaf00..3e5f67697 100755 --- a/.ci/spec/run-test.sh +++ b/.ci/spec/run-test.sh @@ -61,6 +61,7 @@ wrap_stream packet-exec run -upload -- /bin/true \ # Run the job echo "Running vagrant spec tests..." +# Need to make memory customizable for windows hosts pkt_wrap_stream "cd vagrant;VAGRANT_HOST_MEMORY=5000 VAGRANT_CWD=test/vagrant-spec/ VAGRANT_VAGRANTFILE=Vagrantfile.spec vagrant up --provider vmware_desktop" \ "Vagrant command failed" From 6afcaa177677f85adb7822a971ee93104d33eaa1 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 19 Feb 2020 14:06:40 -0800 Subject: [PATCH 08/29] Add comments --- .ci/spec/run-test.sh | 2 +- .github/workflows/spectesting.yml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.ci/spec/run-test.sh b/.ci/spec/run-test.sh index 3e5f67697..a22601c94 100755 --- a/.ci/spec/run-test.sh +++ b/.ci/spec/run-test.sh @@ -46,7 +46,7 @@ fi export PACKET_EXEC_REMOTE_DIRECTORY="${job_id}" export PACKET_EXEC_PERSIST="1" -# spec test configuration, defined by action runners +# spec test configuration, defined by action runners, used by Vagrant on packet export PKT_VAGRANT_HOST_BOXES="${VAGRANT_HOST_BOXES}" export PKT_VAGRANT_GUEST_BOXES="${VAGRANT_GUEST_BOXES}" ### diff --git a/.github/workflows/spectesting.yml b/.github/workflows/spectesting.yml index 233a6fa24..9bb93370d 100644 --- a/.github/workflows/spectesting.yml +++ b/.github/workflows/spectesting.yml @@ -6,6 +6,7 @@ on: - 'CHANGELOG.md' - 'website/**' + # split packet setup and test runner into two jobs jobs: spec-tests: if: github.repository == 'hashicorp/vagrant' @@ -26,7 +27,7 @@ jobs: - name: vagrant-spec Code Checkout and Build working-directory: ${{github.workspace}} run: .ci/spec/build-vagrant-spec.sh - - name: Run Tests on ${{ matrix.host_os }} with guest ${{ matrix.guest_os }} + - name: Run Tests with host ${{ matrix.host_os }} using guest ${{ matrix.guest_os }} run: .ci/spec/run-test.sh working-directory: ${{github.workspace}} env: From 984d1d74c066ac1bf525e8ff49480bef8e8bfc21 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 19 Feb 2020 14:28:30 -0800 Subject: [PATCH 09/29] Split out packet creation from test runner --- .ci/spec/create-packet.sh | 49 +++++++++++++++++++++++++++++++ .ci/spec/run-test.sh | 14 ++------- .github/workflows/spectesting.yml | 10 ++++++- 3 files changed, 61 insertions(+), 12 deletions(-) create mode 100644 .ci/spec/create-packet.sh diff --git a/.ci/spec/create-packet.sh b/.ci/spec/create-packet.sh new file mode 100644 index 000000000..3af8ea8d3 --- /dev/null +++ b/.ci/spec/create-packet.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +# packet and job configuration +export SLACK_USERNAME="Vagrant" +export SLACK_ICON="https://media.giphy.com/media/yIQ5glQeheYE0/200.gif" +export SLACK_TITLE="Vagrant-Spec Test Runner" +export PACKET_EXEC_DEVICE_NAME="${PACKET_EXEC_DEVICE_NAME:-spec-ci-boxes}" +export PACKET_EXEC_DEVICE_SIZE="${PACKET_EXEC_DEVICE_SIZE:-baremetal_0,baremetal_1,baremetal_1e}" +export PACKET_EXEC_PREFER_FACILITIES="${PACKET_EXEC_PREFER_FACILITIES:-iad1,iad2,ewr1,dfw1,dfw2,sea1,sjc1,lax1}" +export PACKET_EXEC_OPERATING_SYSTEM="${PACKET_EXEC_OPERATING_SYSTEM:-ubuntu_18_04}" +export PACKET_EXEC_PRE_BUILTINS="${PACKET_EXEC_PRE_BUILTINS:-InstallVagrant,InstallVirtualBox,InstallVmware,InstallHashiCorpTool,InstallVagrantVmware}" +export PACKET_EXEC_QUIET="1" +export PKT_VAGRANT_CLOUD_TOKEN="${VAGRANT_CLOUD_TOKEN}" +export VAGRANT_PKG_VERSION="2.2.7" # need to figure out how to make this latest instead +### + + +csource="${BASH_SOURCE[0]}" +while [ -h "$csource" ] ; do csource="$(readlink "$csource")"; done +root="$( cd -P "$( dirname "$csource" )/../" && pwd )" + +. "${root}/.ci/common.sh" + +pushd "${root}" > "${output}" + +# Define a custom cleanup function to destroy any orphan guests +# on the packet device +function cleanup() { + (>&2 echo "Cleaning up packet device") + unset PACKET_EXEC_PERSIST + pkt_wrap_stream "cd vagrant;VAGRANT_CWD=test/vagrant-spec/ VAGRANT_VAGRANTFILE=Vagrantfile.spec vagrant destroy -f" \ + "Vagrant command failed" +} + +# Ensure we have a packet device to connect +echo "Creating packet device if needed..." + +packet-exec info + +if [ $? -ne 0 ]; then + wrap_stream packet-exec create \ + "Failed to create packet device" +fi + +# job_id is provided by common.sh +export PACKET_EXEC_REMOTE_DIRECTORY="${job_id}" +export PACKET_EXEC_PERSIST="1" + +echo "Finished creating spec test packet instance" diff --git a/.ci/spec/run-test.sh b/.ci/spec/run-test.sh index a22601c94..95d2f0a68 100755 --- a/.ci/spec/run-test.sh +++ b/.ci/spec/run-test.sh @@ -23,6 +23,8 @@ root="$( cd -P "$( dirname "$csource" )/../" && pwd )" pushd "${root}" > "${output}" +# Assumes packet is already set up + # Define a custom cleanup function to destroy any orphan guests # on the packet device function cleanup() { @@ -32,16 +34,6 @@ function cleanup() { "Vagrant command failed" } -# Ensure we have a packet device to connect -echo "Creating packet device if needed..." - -packet-exec info - -if [ $? -ne 0 ]; then - wrap_stream packet-exec create \ - "Failed to create packet device" -fi - # job_id is provided by common.sh export PACKET_EXEC_REMOTE_DIRECTORY="${job_id}" export PACKET_EXEC_PERSIST="1" @@ -51,7 +43,7 @@ export PKT_VAGRANT_HOST_BOXES="${VAGRANT_HOST_BOXES}" export PKT_VAGRANT_GUEST_BOXES="${VAGRANT_GUEST_BOXES}" ### -echo "Setting up remote packet device for current job... " +echo "Syncing up remote packet device for current job... " # NOTE: We only need to call packet-exec with the -upload option once # since we are persisting the job directory. This command # is used simply to seed the work directory. diff --git a/.github/workflows/spectesting.yml b/.github/workflows/spectesting.yml index 9bb93370d..fabd6ea57 100644 --- a/.github/workflows/spectesting.yml +++ b/.github/workflows/spectesting.yml @@ -6,8 +6,16 @@ on: - 'CHANGELOG.md' - 'website/**' - # split packet setup and test runner into two jobs jobs: + setup-packet: + if: github.repository == 'hashicorp/vagrant' + runs-on: self-hosted + name: Build Packet Instance + steps: + - name: Create packet instance + run: .ci/spec/create-packet.sh + working-directory: ${{github.workspace}} + spec-tests: if: github.repository == 'hashicorp/vagrant' runs-on: self-hosted From 9b770a0261f7ffe9c396aa7ed646a46f7a2e6c9e Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 19 Feb 2020 15:16:54 -0800 Subject: [PATCH 10/29] Add code sync for blackbox acceptance test repository --- .ci/sync.sh | 37 +++++++++++++++++++++++++++++ .github/workflows/code.yml | 48 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100755 .ci/sync.sh create mode 100644 .github/workflows/code.yml diff --git a/.ci/sync.sh b/.ci/sync.sh new file mode 100755 index 000000000..c5a4617be --- /dev/null +++ b/.ci/sync.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +csource="${BASH_SOURCE[0]}" +while [ -h "$csource" ] ; do csource="$(readlink "$csource")"; done +root="$( cd -P "$( dirname "$csource" )/../" && pwd )" + +. "${root}/.ci/common.sh" + +export PATH="${PATH}:${root}/.ci" + +pushd "${root}" > "${output}" + +if [ "${repo_name}" = "vagrant" ]; then + remote_repository="hashicorp/vagrant-blackbox" +else + remote_repository="hashicorp/vagrant" +fi + +echo "Adding remote mirror repository '${remote_repository}'..." +wrap git remote add mirror "https://${HASHIBOT_USERNAME}:${HASHIBOT_TOKEN}@github.com/${remote_repository}" \ + "Failed to add mirror '${remote_repository}' for sync" + +echo "Updating configured remotes..." +wrap_stream git remote update mirror \ + "Failed to update mirror repository (${remote_repository}) for sync" + +rb=$(git branch -r --list "mirror/${ident_ref}") + +if [ "${rb}" != "" ]; then + echo "Pulling ${ident_ref} from mirror..." + wrap_stream git pull mirror "${ident_ref}" \ + "Failed to pull ${ident_ref} from mirror repository (${remote_repository}) for sync" +fi + +echo "Pushing ${ident_ref} to mirror..." +wrap_stream git push mirror "${ident_ref}" \ + "Failed to sync mirror repository (${remote_repository})" diff --git a/.github/workflows/code.yml b/.github/workflows/code.yml new file mode 100644 index 000000000..05a4e81f7 --- /dev/null +++ b/.github/workflows/code.yml @@ -0,0 +1,48 @@ +on: + push: + branches: + - 'master' + - 'spec-test-*' + +jobs: + sync-vagrant: + if: github.repository == 'hashicorp/vagrant-blackbox' + runs-on: ubuntu-18.04 + steps: + - name: Code Checkout + uses: actions/checkout@v2 + with: + persist-credentials: false + fetch-depth: 0 + - name: Set Ruby + uses: actions/setup-ruby@v1 + with: + ruby-version: '2.6' + - name: Sync Installers Repository + run: ./.ci/sync.sh + working-directory: ${{github.workspace}} + env: + HASHIBOT_TOKEN: ${{ secrets.HASHIBOT_TOKEN }} + HASHIBOT_USERNAME: ${{ secrets.HASHIBOT_USERNAME }} + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + + sync-blackbox: + if: github.repository == 'hashicorp/vagrant' + runs-on: ubuntu-18.04 + steps: + - name: Code Checkout + uses: actions/checkout@v2 + with: + persist-credentials: false + fetch-depth: 0 + - name: Set Ruby + uses: actions/setup-ruby@v1 + with: + ruby-version: '2.6' + - name: Sync Builders Repository + run: ./.ci/sync.sh + working-directory: ${{github.workspace}} + env: + HASHIBOT_TOKEN: ${{ secrets.HASHIBOT_TOKEN }} + HASHIBOT_USERNAME: ${{ secrets.HASHIBOT_USERNAME }} + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} From a7228a0ce5f56240c65c631853dba833c3547219 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 19 Feb 2020 15:24:07 -0800 Subject: [PATCH 11/29] Fix name for code sync workflow --- .github/workflows/code.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code.yml b/.github/workflows/code.yml index 05a4e81f7..ba173a2df 100644 --- a/.github/workflows/code.yml +++ b/.github/workflows/code.yml @@ -18,7 +18,7 @@ jobs: uses: actions/setup-ruby@v1 with: ruby-version: '2.6' - - name: Sync Installers Repository + - name: Sync Vagrant Repository run: ./.ci/sync.sh working-directory: ${{github.workspace}} env: @@ -39,7 +39,7 @@ jobs: uses: actions/setup-ruby@v1 with: ruby-version: '2.6' - - name: Sync Builders Repository + - name: Sync Blackbox Testing Repository run: ./.ci/sync.sh working-directory: ${{github.workspace}} env: From ccc5c439344a495d4214e435e324ae3a57067fa9 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 19 Feb 2020 15:29:05 -0800 Subject: [PATCH 12/29] Only run tests on blackbox repo --- .github/workflows/spectesting.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/spectesting.yml b/.github/workflows/spectesting.yml index fabd6ea57..3e52ec2c2 100644 --- a/.github/workflows/spectesting.yml +++ b/.github/workflows/spectesting.yml @@ -8,7 +8,7 @@ on: jobs: setup-packet: - if: github.repository == 'hashicorp/vagrant' + if: github.repository == 'hashicorp/vagrant-blackbox' runs-on: self-hosted name: Build Packet Instance steps: @@ -17,7 +17,7 @@ jobs: working-directory: ${{github.workspace}} spec-tests: - if: github.repository == 'hashicorp/vagrant' + if: github.repository == 'hashicorp/vagrant-blackbox' runs-on: self-hosted strategy: matrix: From dc3b70aca44d9fa47d1252438139acb3680c66dd Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 19 Feb 2020 15:52:29 -0800 Subject: [PATCH 13/29] Make script executable --- .ci/spec/create-packet.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .ci/spec/create-packet.sh diff --git a/.ci/spec/create-packet.sh b/.ci/spec/create-packet.sh old mode 100644 new mode 100755 From f207754694c707f8cff6890c1a3080f1a88568b7 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 19 Feb 2020 15:52:35 -0800 Subject: [PATCH 14/29] Remove building vagrant-spec gem --- .ci/spec/build-vagrant-spec.sh | 9 --------- .github/workflows/spectesting.yml | 8 -------- 2 files changed, 17 deletions(-) delete mode 100755 .ci/spec/build-vagrant-spec.sh diff --git a/.ci/spec/build-vagrant-spec.sh b/.ci/spec/build-vagrant-spec.sh deleted file mode 100755 index 192db32bc..000000000 --- a/.ci/spec/build-vagrant-spec.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -git clone git@github.com:hashicorp/vagrant-spec.git -cd vagrant-spec -gem install bundle -bundle install -gem build vagrant-spec.gemspec -# Assumes this is being run in the same workspace as the main vagrant repo -mv vagrant-spec-*.gem ../vagrant-spec.gem diff --git a/.github/workflows/spectesting.yml b/.github/workflows/spectesting.yml index 3e52ec2c2..c4e3cda3e 100644 --- a/.github/workflows/spectesting.yml +++ b/.github/workflows/spectesting.yml @@ -27,14 +27,6 @@ jobs: steps: - name: Code Checkout uses: actions/checkout@v1 - - name: Setup Ruby - uses: actions/setup-ruby@v1 - with: - ruby-version: '2.6.x' - architecture: 'x64' - - name: vagrant-spec Code Checkout and Build - working-directory: ${{github.workspace}} - run: .ci/spec/build-vagrant-spec.sh - name: Run Tests with host ${{ matrix.host_os }} using guest ${{ matrix.guest_os }} run: .ci/spec/run-test.sh working-directory: ${{github.workspace}} From 0101a1798cb0f4e52b5fb6ff42e5a3329674ba8f Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 19 Feb 2020 16:27:18 -0800 Subject: [PATCH 15/29] Split up creating hosts and running tests --- .ci/spec/create-hosts.sh | 58 +++++++++++++++++++++++++++++++++++++++ .ci/spec/create-packet.sh | 4 --- .ci/spec/run-test.sh | 16 ++++------- 3 files changed, 64 insertions(+), 14 deletions(-) create mode 100755 .ci/spec/create-hosts.sh diff --git a/.ci/spec/create-hosts.sh b/.ci/spec/create-hosts.sh new file mode 100755 index 000000000..56ec7f911 --- /dev/null +++ b/.ci/spec/create-hosts.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# packet and job configuration +export SLACK_USERNAME="Vagrant" +export SLACK_ICON="https://media.giphy.com/media/yIQ5glQeheYE0/200.gif" +export SLACK_TITLE="Vagrant-Spec Test Runner" +export PACKET_EXEC_DEVICE_NAME="${PACKET_EXEC_DEVICE_NAME:-spec-ci-boxes}" +export PACKET_EXEC_DEVICE_SIZE="${PACKET_EXEC_DEVICE_SIZE:-baremetal_0,baremetal_1,baremetal_1e}" +export PACKET_EXEC_PREFER_FACILITIES="${PACKET_EXEC_PREFER_FACILITIES:-iad1,iad2,ewr1,dfw1,dfw2,sea1,sjc1,lax1}" +export PACKET_EXEC_OPERATING_SYSTEM="${PACKET_EXEC_OPERATING_SYSTEM:-ubuntu_18_04}" +export PACKET_EXEC_PRE_BUILTINS="${PACKET_EXEC_PRE_BUILTINS:-InstallVagrant,InstallVirtualBox,InstallVmware,InstallHashiCorpTool,InstallVagrantVmware}" +export PACKET_EXEC_QUIET="1" +export PKT_VAGRANT_CLOUD_TOKEN="${VAGRANT_CLOUD_TOKEN}" +export VAGRANT_PKG_VERSION="2.2.7" # need to figure out how to make this latest instead +### + + +csource="${BASH_SOURCE[0]}" +while [ -h "$csource" ] ; do csource="$(readlink "$csource")"; done +root="$( cd -P "$( dirname "$csource" )/../" && pwd )" + +. "${root}/.ci/common.sh" + +pushd "${root}" > "${output}" + +# Assumes packet is already set up + +# job_id is provided by common.sh +export PACKET_EXEC_REMOTE_DIRECTORY="${job_id}" + +# spec test configuration, defined by action runners, used by Vagrant on packet +export PKT_VAGRANT_HOST_BOXES="${VAGRANT_HOST_BOXES}" +export PKT_VAGRANT_GUEST_BOXES="${VAGRANT_GUEST_BOXES}" +# other vagrant-spec options +export PKT_VAGRANT_HOST_MEMORY=10000 +export PKT_VAGRANT_CWD="/test/vagrant-spec/" +export PKT_VAGRANT_VAGRANTFILE=Vagrantfile.spec +### + +# Grab vagrant-spec gem +### + +echo "Syncing up remote packet device for current job... " +# NOTE: We only need to call packet-exec with the -upload option once +# since we are persisting the job directory. This command +# is used simply to seed the work directory. +wrap_stream packet-exec run -upload -- /bin/true \ + "Failed to setup project on remote packet instance" + +# Run the job + +echo "Running vagrant spec tests..." +# Need to make memory customizable for windows hosts +wrap_stream packet-exec run -upload -- "cd vagrant;vagrant up --no-provision --provider vmware_desktop" \ + "Vagrant Blackbox host creation command failed" + + +echo "Finished vagrant spec tests" diff --git a/.ci/spec/create-packet.sh b/.ci/spec/create-packet.sh index 3af8ea8d3..3a36bd104 100755 --- a/.ci/spec/create-packet.sh +++ b/.ci/spec/create-packet.sh @@ -42,8 +42,4 @@ if [ $? -ne 0 ]; then "Failed to create packet device" fi -# job_id is provided by common.sh -export PACKET_EXEC_REMOTE_DIRECTORY="${job_id}" -export PACKET_EXEC_PERSIST="1" - echo "Finished creating spec test packet instance" diff --git a/.ci/spec/run-test.sh b/.ci/spec/run-test.sh index 95d2f0a68..ca9da5e69 100755 --- a/.ci/spec/run-test.sh +++ b/.ci/spec/run-test.sh @@ -36,26 +36,22 @@ function cleanup() { # job_id is provided by common.sh export PACKET_EXEC_REMOTE_DIRECTORY="${job_id}" -export PACKET_EXEC_PERSIST="1" # spec test configuration, defined by action runners, used by Vagrant on packet export PKT_VAGRANT_HOST_BOXES="${VAGRANT_HOST_BOXES}" export PKT_VAGRANT_GUEST_BOXES="${VAGRANT_GUEST_BOXES}" +# other vagrant-spec options +export PKT_VAGRANT_HOST_MEMORY=10000 +export PKT_VAGRANT_CWD="/test/vagrant-spec/" +export PKT_VAGRANT_VAGRANTFILE=Vagrantfile.spec ### -echo "Syncing up remote packet device for current job... " -# NOTE: We only need to call packet-exec with the -upload option once -# since we are persisting the job directory. This command -# is used simply to seed the work directory. -wrap_stream packet-exec run -upload -- /bin/true \ - "Failed to setup project on remote packet instance" - # Run the job echo "Running vagrant spec tests..." # Need to make memory customizable for windows hosts -pkt_wrap_stream "cd vagrant;VAGRANT_HOST_MEMORY=5000 VAGRANT_CWD=test/vagrant-spec/ VAGRANT_VAGRANTFILE=Vagrantfile.spec vagrant up --provider vmware_desktop" \ - "Vagrant command failed" +pkt_wrap_stream "cd vagrant;vagrant provision --provider vmware_desktop" \ + "Vagrant Blackbox testing command failed" echo "Finished vagrant spec tests" From 66c0a7510df1e345308fdf6014a182ebfa2561a7 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 19 Feb 2020 16:44:21 -0800 Subject: [PATCH 16/29] Add separate jobs for bringing up hosts and running tests on guests --- .ci/spec/clean-packet.sh | 37 +++++++++++++++++++++++++++++++ .github/workflows/spectesting.yml | 36 +++++++++++++++++++++++------- 2 files changed, 65 insertions(+), 8 deletions(-) create mode 100755 .ci/spec/clean-packet.sh diff --git a/.ci/spec/clean-packet.sh b/.ci/spec/clean-packet.sh new file mode 100755 index 000000000..cc3640dc1 --- /dev/null +++ b/.ci/spec/clean-packet.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# packet and job configuration +export SLACK_USERNAME="Vagrant" +export SLACK_ICON="https://media.giphy.com/media/yIQ5glQeheYE0/200.gif" +export SLACK_TITLE="Vagrant-Spec Test Runner" +export PACKET_EXEC_DEVICE_NAME="${PACKET_EXEC_DEVICE_NAME:-spec-ci-boxes}" +export PACKET_EXEC_DEVICE_SIZE="${PACKET_EXEC_DEVICE_SIZE:-baremetal_0,baremetal_1,baremetal_1e}" +export PACKET_EXEC_PREFER_FACILITIES="${PACKET_EXEC_PREFER_FACILITIES:-iad1,iad2,ewr1,dfw1,dfw2,sea1,sjc1,lax1}" +export PACKET_EXEC_OPERATING_SYSTEM="${PACKET_EXEC_OPERATING_SYSTEM:-ubuntu_18_04}" +export PACKET_EXEC_PRE_BUILTINS="${PACKET_EXEC_PRE_BUILTINS:-InstallVagrant,InstallVirtualBox,InstallVmware,InstallHashiCorpTool,InstallVagrantVmware}" +export PACKET_EXEC_QUIET="1" +export PKT_VAGRANT_CLOUD_TOKEN="${VAGRANT_CLOUD_TOKEN}" +export VAGRANT_PKG_VERSION="2.2.7" # need to figure out how to make this latest instead +### + + +csource="${BASH_SOURCE[0]}" +while [ -h "$csource" ] ; do csource="$(readlink "$csource")"; done +root="$( cd -P "$( dirname "$csource" )/../" && pwd )" + +. "${root}/.ci/common.sh" + +pushd "${root}" > "${output}" + +# Ensure we have a packet device to connect +echo "Cleaning up packet device..." + +export PKT_VAGRANT_HOST_BOXES="${VAGRANT_HOST_BOXES}" +export PKT_VAGRANT_GUEST_BOXES="${VAGRANT_GUEST_BOXES}" +export PKT_VAGRANT_CWD=test/vagrant-spec/ +export PKT_VAGRANT_VAGRANTFILE=Vagrantfile.spec +pkt_wrap_stream "cd vagrant;vagrant destroy -f" \ + "Vagrant command failed" + + +echo "Finished destroying spec test hosts" diff --git a/.github/workflows/spectesting.yml b/.github/workflows/spectesting.yml index c4e3cda3e..66aa140f9 100644 --- a/.github/workflows/spectesting.yml +++ b/.github/workflows/spectesting.yml @@ -16,23 +16,43 @@ jobs: run: .ci/spec/create-packet.sh working-directory: ${{github.workspace}} - spec-tests: + setup-hosts: if: github.repository == 'hashicorp/vagrant-blackbox' runs-on: self-hosted - strategy: - matrix: - host_os: ["hashicorp/bionic64"] - guest_os: ["hashicorp/bionic64", "hashicorp-vagrant/ubuntu-16.04"] - name: Vagrant-Spec Tests + name: Vagrant-Spec Start Hosts + needs: setup-packet steps: - name: Code Checkout uses: actions/checkout@v1 - name: Run Tests with host ${{ matrix.host_os }} using guest ${{ matrix.guest_os }} + run: .ci/spec/create-hosts.sh + working-directory: ${{github.workspace}} + env: + VAGRANT_HOST_BOXES: "hashicorp/bionic64" + VAGRANT_GUEST_BOXES: "hasicorp/bionic64","hashicorp-vagrant/ubuntu-16.04" + + spec-tests: + if: github.repository == 'hashicorp/vagrant-blackbox' + runs-on: self-hosted + name: Vagrant-Spec Tests + needs: setup-hosts + steps: + - name: Run Tests with all hosts and guests run: .ci/spec/run-test.sh working-directory: ${{github.workspace}} env: - VAGRANT_HOST_BOXES: ${{ matrix.host_os }} - VAGRANT_GUEST_BOXES: ${{ matrix.guest_os }} + VAGRANT_HOST_BOXES: "hashicorp/bionic64" + VAGRANT_GUEST_BOXES: "hasicorp/bionic64","hashicorp-vagrant/ubuntu-16.04" + + cleanup: + if: github.repository == 'hashicorp/vagrant-blackbox' + runs-on: self-hosted + name: Cleanup Post Vagrant-Spec Tests + needs: spec-tests + steps: + - name: Clean Packet + if: always() + run: .ci/spec/clean-packet.sh - name: Clean Workspace if: always() run: rm -rf ${{ github.workspace }} From b944138193c243a6342a903ecd053661944ffa44 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 19 Feb 2020 16:45:49 -0800 Subject: [PATCH 17/29] Try env vars unquoted --- .github/workflows/spectesting.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/spectesting.yml b/.github/workflows/spectesting.yml index 66aa140f9..bfe821f9b 100644 --- a/.github/workflows/spectesting.yml +++ b/.github/workflows/spectesting.yml @@ -28,8 +28,8 @@ jobs: run: .ci/spec/create-hosts.sh working-directory: ${{github.workspace}} env: - VAGRANT_HOST_BOXES: "hashicorp/bionic64" - VAGRANT_GUEST_BOXES: "hasicorp/bionic64","hashicorp-vagrant/ubuntu-16.04" + VAGRANT_HOST_BOXES: hashicorp/bionic64 + VAGRANT_GUEST_BOXES: hasicorp/bionic64,hashicorp-vagrant/ubuntu-16.04 spec-tests: if: github.repository == 'hashicorp/vagrant-blackbox' @@ -41,8 +41,8 @@ jobs: run: .ci/spec/run-test.sh working-directory: ${{github.workspace}} env: - VAGRANT_HOST_BOXES: "hashicorp/bionic64" - VAGRANT_GUEST_BOXES: "hasicorp/bionic64","hashicorp-vagrant/ubuntu-16.04" + VAGRANT_HOST_BOXES: hashicorp/bionic64 + VAGRANT_GUEST_BOXES: hasicorp/bionic64,hashicorp-vagrant/ubuntu-16.04 cleanup: if: github.repository == 'hashicorp/vagrant-blackbox' From 9c7b92a724f83182c4a0961e503bfced13f0fc99 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 19 Feb 2020 16:50:36 -0800 Subject: [PATCH 18/29] Remove extra packet-exec upload command --- .ci/spec/create-hosts.sh | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.ci/spec/create-hosts.sh b/.ci/spec/create-hosts.sh index 56ec7f911..86326a867 100755 --- a/.ci/spec/create-hosts.sh +++ b/.ci/spec/create-hosts.sh @@ -37,16 +37,9 @@ export PKT_VAGRANT_CWD="/test/vagrant-spec/" export PKT_VAGRANT_VAGRANTFILE=Vagrantfile.spec ### -# Grab vagrant-spec gem +# TODO: Grab vagrant-spec gem and place inside root dir of Vagrant repo ### -echo "Syncing up remote packet device for current job... " -# NOTE: We only need to call packet-exec with the -upload option once -# since we are persisting the job directory. This command -# is used simply to seed the work directory. -wrap_stream packet-exec run -upload -- /bin/true \ - "Failed to setup project on remote packet instance" - # Run the job echo "Running vagrant spec tests..." From f04137b05d813744c92c2bd4161e05c7fc1f8112 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Thu, 20 Feb 2020 08:58:48 -0800 Subject: [PATCH 19/29] Only use hashicorp-vagrant box for now The official bionic box does not have puppet installed, so the spec tests will fail --- .github/workflows/spectesting.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/spectesting.yml b/.github/workflows/spectesting.yml index bfe821f9b..520e0779f 100644 --- a/.github/workflows/spectesting.yml +++ b/.github/workflows/spectesting.yml @@ -29,7 +29,7 @@ jobs: working-directory: ${{github.workspace}} env: VAGRANT_HOST_BOXES: hashicorp/bionic64 - VAGRANT_GUEST_BOXES: hasicorp/bionic64,hashicorp-vagrant/ubuntu-16.04 + VAGRANT_GUEST_BOXES: hashicorp-vagrant/ubuntu-16.04 spec-tests: if: github.repository == 'hashicorp/vagrant-blackbox' @@ -42,7 +42,7 @@ jobs: working-directory: ${{github.workspace}} env: VAGRANT_HOST_BOXES: hashicorp/bionic64 - VAGRANT_GUEST_BOXES: hasicorp/bionic64,hashicorp-vagrant/ubuntu-16.04 + VAGRANT_GUEST_BOXES: hashicorp-vagrant/ubuntu-16.04 cleanup: if: github.repository == 'hashicorp/vagrant-blackbox' From 143a6901c2d3fc2c372ee5030986c9e8bb3f5a68 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Thu, 20 Feb 2020 14:31:44 -0800 Subject: [PATCH 20/29] Download vagrant-spec gem from S3 --- .ci/spec/create-hosts.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.ci/spec/create-hosts.sh b/.ci/spec/create-hosts.sh index 86326a867..a4eff3a03 100755 --- a/.ci/spec/create-hosts.sh +++ b/.ci/spec/create-hosts.sh @@ -37,7 +37,8 @@ export PKT_VAGRANT_CWD="/test/vagrant-spec/" export PKT_VAGRANT_VAGRANTFILE=Vagrantfile.spec ### -# TODO: Grab vagrant-spec gem and place inside root dir of Vagrant repo +# Grab vagrant-spec gem and place inside root dir of Vagrant repo +download_assets "${ASSETS_PRIVATE_BUCKET}/vagrant-spec/vagrant-spec.gem" "." ### # Run the job From 073b195d3c8ce2c48c665d5e5c041d79f98e1534 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 4 Mar 2020 16:14:44 -0800 Subject: [PATCH 21/29] Add env shell for CI spec tests --- .ci/spec/env.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 .ci/spec/env.sh diff --git a/.ci/spec/env.sh b/.ci/spec/env.sh new file mode 100755 index 000000000..74b531116 --- /dev/null +++ b/.ci/spec/env.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +# packet and job configuration +export SLACK_USERNAME="Vagrant" +export SLACK_ICON="https://media.giphy.com/media/yIQ5glQeheYE0/200.gif" +export SLACK_TITLE="Vagrant-Spec Test Runner" +export PACKET_EXEC_DEVICE_NAME="${PACKET_EXEC_DEVICE_NAME:-spec-ci-boxes}" +export PACKET_EXEC_DEVICE_SIZE="${PACKET_EXEC_DEVICE_SIZE:-baremetal_0,baremetal_1,baremetal_1e}" +export PACKET_EXEC_PREFER_FACILITIES="${PACKET_EXEC_PREFER_FACILITIES:-iad1,iad2,ewr1,dfw1,dfw2,sea1,sjc1,lax1}" +export PACKET_EXEC_OPERATING_SYSTEM="${PACKET_EXEC_OPERATING_SYSTEM:-ubuntu_18_04}" +export PACKET_EXEC_PRE_BUILTINS="${PACKET_EXEC_PRE_BUILTINS:-InstallVagrant,InstallVirtualBox,InstallVmware,InstallHashiCorpTool,InstallVagrantVmware}" +export PACKET_EXEC_QUIET="1" +export PKT_VAGRANT_CLOUD_TOKEN="${VAGRANT_CLOUD_TOKEN}" +export VAGRANT_PKG_VERSION="2.2.7" # need to figure out how to make this latest instead +### From 57e40fd6e12642dc7a67bc5e7c190a5711beb817 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 4 Mar 2020 16:15:05 -0800 Subject: [PATCH 22/29] Use env script to load env vars for testing --- .ci/spec/clean-packet.sh | 16 +--------------- .ci/spec/create-hosts.sh | 16 +--------------- .ci/spec/create-packet.sh | 16 +--------------- .ci/spec/run-test.sh | 16 +--------------- 4 files changed, 4 insertions(+), 60 deletions(-) diff --git a/.ci/spec/clean-packet.sh b/.ci/spec/clean-packet.sh index cc3640dc1..3a8189685 100755 --- a/.ci/spec/clean-packet.sh +++ b/.ci/spec/clean-packet.sh @@ -1,24 +1,10 @@ #!/usr/bin/env bash -# packet and job configuration -export SLACK_USERNAME="Vagrant" -export SLACK_ICON="https://media.giphy.com/media/yIQ5glQeheYE0/200.gif" -export SLACK_TITLE="Vagrant-Spec Test Runner" -export PACKET_EXEC_DEVICE_NAME="${PACKET_EXEC_DEVICE_NAME:-spec-ci-boxes}" -export PACKET_EXEC_DEVICE_SIZE="${PACKET_EXEC_DEVICE_SIZE:-baremetal_0,baremetal_1,baremetal_1e}" -export PACKET_EXEC_PREFER_FACILITIES="${PACKET_EXEC_PREFER_FACILITIES:-iad1,iad2,ewr1,dfw1,dfw2,sea1,sjc1,lax1}" -export PACKET_EXEC_OPERATING_SYSTEM="${PACKET_EXEC_OPERATING_SYSTEM:-ubuntu_18_04}" -export PACKET_EXEC_PRE_BUILTINS="${PACKET_EXEC_PRE_BUILTINS:-InstallVagrant,InstallVirtualBox,InstallVmware,InstallHashiCorpTool,InstallVagrantVmware}" -export PACKET_EXEC_QUIET="1" -export PKT_VAGRANT_CLOUD_TOKEN="${VAGRANT_CLOUD_TOKEN}" -export VAGRANT_PKG_VERSION="2.2.7" # need to figure out how to make this latest instead -### - - csource="${BASH_SOURCE[0]}" while [ -h "$csource" ] ; do csource="$(readlink "$csource")"; done root="$( cd -P "$( dirname "$csource" )/../" && pwd )" +. "${root}/.ci/spec/env.sh" . "${root}/.ci/common.sh" pushd "${root}" > "${output}" diff --git a/.ci/spec/create-hosts.sh b/.ci/spec/create-hosts.sh index a4eff3a03..66721cceb 100755 --- a/.ci/spec/create-hosts.sh +++ b/.ci/spec/create-hosts.sh @@ -1,24 +1,10 @@ #!/usr/bin/env bash -# packet and job configuration -export SLACK_USERNAME="Vagrant" -export SLACK_ICON="https://media.giphy.com/media/yIQ5glQeheYE0/200.gif" -export SLACK_TITLE="Vagrant-Spec Test Runner" -export PACKET_EXEC_DEVICE_NAME="${PACKET_EXEC_DEVICE_NAME:-spec-ci-boxes}" -export PACKET_EXEC_DEVICE_SIZE="${PACKET_EXEC_DEVICE_SIZE:-baremetal_0,baremetal_1,baremetal_1e}" -export PACKET_EXEC_PREFER_FACILITIES="${PACKET_EXEC_PREFER_FACILITIES:-iad1,iad2,ewr1,dfw1,dfw2,sea1,sjc1,lax1}" -export PACKET_EXEC_OPERATING_SYSTEM="${PACKET_EXEC_OPERATING_SYSTEM:-ubuntu_18_04}" -export PACKET_EXEC_PRE_BUILTINS="${PACKET_EXEC_PRE_BUILTINS:-InstallVagrant,InstallVirtualBox,InstallVmware,InstallHashiCorpTool,InstallVagrantVmware}" -export PACKET_EXEC_QUIET="1" -export PKT_VAGRANT_CLOUD_TOKEN="${VAGRANT_CLOUD_TOKEN}" -export VAGRANT_PKG_VERSION="2.2.7" # need to figure out how to make this latest instead -### - - csource="${BASH_SOURCE[0]}" while [ -h "$csource" ] ; do csource="$(readlink "$csource")"; done root="$( cd -P "$( dirname "$csource" )/../" && pwd )" +. "${root}/.ci/spec/env.sh" . "${root}/.ci/common.sh" pushd "${root}" > "${output}" diff --git a/.ci/spec/create-packet.sh b/.ci/spec/create-packet.sh index 3a36bd104..fee050381 100755 --- a/.ci/spec/create-packet.sh +++ b/.ci/spec/create-packet.sh @@ -1,24 +1,10 @@ #!/usr/bin/env bash -# packet and job configuration -export SLACK_USERNAME="Vagrant" -export SLACK_ICON="https://media.giphy.com/media/yIQ5glQeheYE0/200.gif" -export SLACK_TITLE="Vagrant-Spec Test Runner" -export PACKET_EXEC_DEVICE_NAME="${PACKET_EXEC_DEVICE_NAME:-spec-ci-boxes}" -export PACKET_EXEC_DEVICE_SIZE="${PACKET_EXEC_DEVICE_SIZE:-baremetal_0,baremetal_1,baremetal_1e}" -export PACKET_EXEC_PREFER_FACILITIES="${PACKET_EXEC_PREFER_FACILITIES:-iad1,iad2,ewr1,dfw1,dfw2,sea1,sjc1,lax1}" -export PACKET_EXEC_OPERATING_SYSTEM="${PACKET_EXEC_OPERATING_SYSTEM:-ubuntu_18_04}" -export PACKET_EXEC_PRE_BUILTINS="${PACKET_EXEC_PRE_BUILTINS:-InstallVagrant,InstallVirtualBox,InstallVmware,InstallHashiCorpTool,InstallVagrantVmware}" -export PACKET_EXEC_QUIET="1" -export PKT_VAGRANT_CLOUD_TOKEN="${VAGRANT_CLOUD_TOKEN}" -export VAGRANT_PKG_VERSION="2.2.7" # need to figure out how to make this latest instead -### - - csource="${BASH_SOURCE[0]}" while [ -h "$csource" ] ; do csource="$(readlink "$csource")"; done root="$( cd -P "$( dirname "$csource" )/../" && pwd )" +. "${root}/.ci/spec/env.sh" . "${root}/.ci/common.sh" pushd "${root}" > "${output}" diff --git a/.ci/spec/run-test.sh b/.ci/spec/run-test.sh index ca9da5e69..87dd2a1c6 100755 --- a/.ci/spec/run-test.sh +++ b/.ci/spec/run-test.sh @@ -1,24 +1,10 @@ #!/usr/bin/env bash -# packet and job configuration -export SLACK_USERNAME="Vagrant" -export SLACK_ICON="https://media.giphy.com/media/yIQ5glQeheYE0/200.gif" -export SLACK_TITLE="Vagrant-Spec Test Runner" -export PACKET_EXEC_DEVICE_NAME="${PACKET_EXEC_DEVICE_NAME:-spec-ci-boxes}" -export PACKET_EXEC_DEVICE_SIZE="${PACKET_EXEC_DEVICE_SIZE:-baremetal_0,baremetal_1,baremetal_1e}" -export PACKET_EXEC_PREFER_FACILITIES="${PACKET_EXEC_PREFER_FACILITIES:-iad1,iad2,ewr1,dfw1,dfw2,sea1,sjc1,lax1}" -export PACKET_EXEC_OPERATING_SYSTEM="${PACKET_EXEC_OPERATING_SYSTEM:-ubuntu_18_04}" -export PACKET_EXEC_PRE_BUILTINS="${PACKET_EXEC_PRE_BUILTINS:-InstallVagrant,InstallVirtualBox,InstallVmware,InstallHashiCorpTool,InstallVagrantVmware}" -export PACKET_EXEC_QUIET="1" -export PKT_VAGRANT_CLOUD_TOKEN="${VAGRANT_CLOUD_TOKEN}" -export VAGRANT_PKG_VERSION="2.2.7" # need to figure out how to make this latest instead -### - - csource="${BASH_SOURCE[0]}" while [ -h "$csource" ] ; do csource="$(readlink "$csource")"; done root="$( cd -P "$( dirname "$csource" )/../" && pwd )" +. "${root}/.ci/spec/env.sh" . "${root}/.ci/common.sh" pushd "${root}" > "${output}" From c7f8ac8101b58dc366699812f129f88b3f9c1efe Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 4 Mar 2020 16:18:56 -0800 Subject: [PATCH 23/29] Fix spec test path for vagrant-spec --- .ci/spec/clean-packet.sh | 2 +- .ci/spec/create-hosts.sh | 2 +- .ci/spec/run-test.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.ci/spec/clean-packet.sh b/.ci/spec/clean-packet.sh index 3a8189685..9aad1b3b7 100755 --- a/.ci/spec/clean-packet.sh +++ b/.ci/spec/clean-packet.sh @@ -14,7 +14,7 @@ echo "Cleaning up packet device..." export PKT_VAGRANT_HOST_BOXES="${VAGRANT_HOST_BOXES}" export PKT_VAGRANT_GUEST_BOXES="${VAGRANT_GUEST_BOXES}" -export PKT_VAGRANT_CWD=test/vagrant-spec/ +export PKT_VAGRANT_CWD="test/vagrant-spec/" export PKT_VAGRANT_VAGRANTFILE=Vagrantfile.spec pkt_wrap_stream "cd vagrant;vagrant destroy -f" \ "Vagrant command failed" diff --git a/.ci/spec/create-hosts.sh b/.ci/spec/create-hosts.sh index 66721cceb..b2dc2020e 100755 --- a/.ci/spec/create-hosts.sh +++ b/.ci/spec/create-hosts.sh @@ -19,7 +19,7 @@ export PKT_VAGRANT_HOST_BOXES="${VAGRANT_HOST_BOXES}" export PKT_VAGRANT_GUEST_BOXES="${VAGRANT_GUEST_BOXES}" # other vagrant-spec options export PKT_VAGRANT_HOST_MEMORY=10000 -export PKT_VAGRANT_CWD="/test/vagrant-spec/" +export PKT_VAGRANT_CWD="test/vagrant-spec/" export PKT_VAGRANT_VAGRANTFILE=Vagrantfile.spec ### diff --git a/.ci/spec/run-test.sh b/.ci/spec/run-test.sh index 87dd2a1c6..d7abfaaa6 100755 --- a/.ci/spec/run-test.sh +++ b/.ci/spec/run-test.sh @@ -28,7 +28,7 @@ export PKT_VAGRANT_HOST_BOXES="${VAGRANT_HOST_BOXES}" export PKT_VAGRANT_GUEST_BOXES="${VAGRANT_GUEST_BOXES}" # other vagrant-spec options export PKT_VAGRANT_HOST_MEMORY=10000 -export PKT_VAGRANT_CWD="/test/vagrant-spec/" +export PKT_VAGRANT_CWD="test/vagrant-spec/" export PKT_VAGRANT_VAGRANTFILE=Vagrantfile.spec ### From 6427576edd31d6f0bbb23eebae9ffbc65ad422bb Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 4 Mar 2020 16:19:38 -0800 Subject: [PATCH 24/29] Remove unused cleanup function --- .ci/spec/create-packet.sh | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.ci/spec/create-packet.sh b/.ci/spec/create-packet.sh index fee050381..c4ac144ad 100755 --- a/.ci/spec/create-packet.sh +++ b/.ci/spec/create-packet.sh @@ -9,15 +9,6 @@ root="$( cd -P "$( dirname "$csource" )/../" && pwd )" pushd "${root}" > "${output}" -# Define a custom cleanup function to destroy any orphan guests -# on the packet device -function cleanup() { - (>&2 echo "Cleaning up packet device") - unset PACKET_EXEC_PERSIST - pkt_wrap_stream "cd vagrant;VAGRANT_CWD=test/vagrant-spec/ VAGRANT_VAGRANTFILE=Vagrantfile.spec vagrant destroy -f" \ - "Vagrant command failed" -} - # Ensure we have a packet device to connect echo "Creating packet device if needed..." From b44a087dfc251f5d3986e357ed1d7236f8a0d5e9 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 4 Mar 2020 16:19:47 -0800 Subject: [PATCH 25/29] Remove env vars from command --- .ci/spec/run-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/spec/run-test.sh b/.ci/spec/run-test.sh index d7abfaaa6..d814b8de8 100755 --- a/.ci/spec/run-test.sh +++ b/.ci/spec/run-test.sh @@ -16,7 +16,7 @@ pushd "${root}" > "${output}" function cleanup() { (>&2 echo "Cleaning up packet device") unset PACKET_EXEC_PERSIST - pkt_wrap_stream "cd vagrant;VAGRANT_CWD=test/vagrant-spec/ VAGRANT_VAGRANTFILE=Vagrantfile.spec vagrant destroy -f" \ + pkt_wrap_stream "cd vagrant;vagrant destroy -f" \ "Vagrant command failed" } From 74ea419d115964d170d1116b6e93c91cfbe37132 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 4 Mar 2020 16:22:26 -0800 Subject: [PATCH 26/29] Remove vagrant package version --- .ci/spec/env.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/.ci/spec/env.sh b/.ci/spec/env.sh index 74b531116..48d58dfa5 100755 --- a/.ci/spec/env.sh +++ b/.ci/spec/env.sh @@ -11,5 +11,4 @@ export PACKET_EXEC_OPERATING_SYSTEM="${PACKET_EXEC_OPERATING_SYSTEM:-ubuntu_18_0 export PACKET_EXEC_PRE_BUILTINS="${PACKET_EXEC_PRE_BUILTINS:-InstallVagrant,InstallVirtualBox,InstallVmware,InstallHashiCorpTool,InstallVagrantVmware}" export PACKET_EXEC_QUIET="1" export PKT_VAGRANT_CLOUD_TOKEN="${VAGRANT_CLOUD_TOKEN}" -export VAGRANT_PKG_VERSION="2.2.7" # need to figure out how to make this latest instead ### From 79eef619eee3f07d7ec567344902a2ff5a642a74 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 4 Mar 2020 16:41:32 -0800 Subject: [PATCH 27/29] Add back job strategy for workflow jobs --- .github/workflows/spectesting.yml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/spectesting.yml b/.github/workflows/spectesting.yml index 520e0779f..93f433fad 100644 --- a/.github/workflows/spectesting.yml +++ b/.github/workflows/spectesting.yml @@ -21,28 +21,36 @@ jobs: runs-on: self-hosted name: Vagrant-Spec Start Hosts needs: setup-packet + strategy: + matrix: + host_os: ['hashicorp/bionic64'] + guest_os: ['hashicorp-vagrant/ubuntu-16.04'] steps: - name: Code Checkout uses: actions/checkout@v1 - - name: Run Tests with host ${{ matrix.host_os }} using guest ${{ matrix.guest_os }} + - name: Create packet host for tests run: .ci/spec/create-hosts.sh working-directory: ${{github.workspace}} env: - VAGRANT_HOST_BOXES: hashicorp/bionic64 - VAGRANT_GUEST_BOXES: hashicorp-vagrant/ubuntu-16.04 + VAGRANT_HOST_BOXES: ${{matrix.host_os}} + VAGRANT_GUEST_BOXES: ${{matrix.guest_os}} spec-tests: if: github.repository == 'hashicorp/vagrant-blackbox' runs-on: self-hosted name: Vagrant-Spec Tests needs: setup-hosts + strategy: + matrix: + host_os: ['hashicorp/bionic64'] + guest_os: ['hashicorp-vagrant/ubuntu-16.04'] steps: - - name: Run Tests with all hosts and guests + - name: Run Tests with host ${{ matrix.host_os }} using guest ${{ matrix.guest_os }} run: .ci/spec/run-test.sh working-directory: ${{github.workspace}} env: - VAGRANT_HOST_BOXES: hashicorp/bionic64 - VAGRANT_GUEST_BOXES: hashicorp-vagrant/ubuntu-16.04 + VAGRANT_HOST_BOXES: ${{matrix.host_os}} + VAGRANT_GUEST_BOXES: ${{matrix.guest_os}} cleanup: if: github.repository == 'hashicorp/vagrant-blackbox' From a50d5b3137bded4a30f997d622d25a56a6a942d9 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 13 May 2020 10:58:43 -0700 Subject: [PATCH 28/29] Update vagrant-spec tests based on feedback --- .ci/spec/clean-packet.sh | 7 +++---- .ci/spec/create-hosts.sh | 11 +++++------ .ci/spec/create-packet.sh | 2 +- .ci/spec/run-test.sh | 6 +++--- .ci/sync.sh | 4 ++-- .github/workflows/code.yml | 21 --------------------- 6 files changed, 14 insertions(+), 37 deletions(-) diff --git a/.ci/spec/clean-packet.sh b/.ci/spec/clean-packet.sh index 9aad1b3b7..66a40c69c 100755 --- a/.ci/spec/clean-packet.sh +++ b/.ci/spec/clean-packet.sh @@ -2,22 +2,21 @@ csource="${BASH_SOURCE[0]}" while [ -h "$csource" ] ; do csource="$(readlink "$csource")"; done -root="$( cd -P "$( dirname "$csource" )/../" && pwd )" +root="$( cd -P "$( dirname "$csource" )/../../" && pwd )" . "${root}/.ci/spec/env.sh" . "${root}/.ci/common.sh" pushd "${root}" > "${output}" -# Ensure we have a packet device to connect echo "Cleaning up packet device..." export PKT_VAGRANT_HOST_BOXES="${VAGRANT_HOST_BOXES}" export PKT_VAGRANT_GUEST_BOXES="${VAGRANT_GUEST_BOXES}" export PKT_VAGRANT_CWD="test/vagrant-spec/" export PKT_VAGRANT_VAGRANTFILE=Vagrantfile.spec -pkt_wrap_stream "cd vagrant;vagrant destroy -f" \ - "Vagrant command failed" +pkt_wrap_stream "vagrant destroy -f" \ + "Vagrant failed to destroy remaining vagrant-spec guests during clean up" echo "Finished destroying spec test hosts" diff --git a/.ci/spec/create-hosts.sh b/.ci/spec/create-hosts.sh index b2dc2020e..480cfab7c 100755 --- a/.ci/spec/create-hosts.sh +++ b/.ci/spec/create-hosts.sh @@ -2,7 +2,7 @@ csource="${BASH_SOURCE[0]}" while [ -h "$csource" ] ; do csource="$(readlink "$csource")"; done -root="$( cd -P "$( dirname "$csource" )/../" && pwd )" +root="$( cd -P "$( dirname "$csource" )/../../" && pwd )" . "${root}/.ci/spec/env.sh" . "${root}/.ci/common.sh" @@ -18,7 +18,7 @@ export PACKET_EXEC_REMOTE_DIRECTORY="${job_id}" export PKT_VAGRANT_HOST_BOXES="${VAGRANT_HOST_BOXES}" export PKT_VAGRANT_GUEST_BOXES="${VAGRANT_GUEST_BOXES}" # other vagrant-spec options -export PKT_VAGRANT_HOST_MEMORY=10000 +export PKT_VAGRANT_HOST_MEMORY="${VAGRANT_HOST_MEMORY:-10000}" export PKT_VAGRANT_CWD="test/vagrant-spec/" export PKT_VAGRANT_VAGRANTFILE=Vagrantfile.spec ### @@ -29,10 +29,9 @@ download_assets "${ASSETS_PRIVATE_BUCKET}/vagrant-spec/vagrant-spec.gem" "." # Run the job -echo "Running vagrant spec tests..." -# Need to make memory customizable for windows hosts -wrap_stream packet-exec run -upload -- "cd vagrant;vagrant up --no-provision --provider vmware_desktop" \ +echo "Creating vagrant spec guests..." +wrap_stream packet-exec run -upload -- "vagrant up --no-provision --provider vmware_desktop" \ "Vagrant Blackbox host creation command failed" -echo "Finished vagrant spec tests" +echo "Finished bringing up vagrant spec guests" diff --git a/.ci/spec/create-packet.sh b/.ci/spec/create-packet.sh index c4ac144ad..885b4a9b7 100755 --- a/.ci/spec/create-packet.sh +++ b/.ci/spec/create-packet.sh @@ -2,7 +2,7 @@ csource="${BASH_SOURCE[0]}" while [ -h "$csource" ] ; do csource="$(readlink "$csource")"; done -root="$( cd -P "$( dirname "$csource" )/../" && pwd )" +root="$( cd -P "$( dirname "$csource" )/../../" && pwd )" . "${root}/.ci/spec/env.sh" . "${root}/.ci/common.sh" diff --git a/.ci/spec/run-test.sh b/.ci/spec/run-test.sh index d814b8de8..f35189a01 100755 --- a/.ci/spec/run-test.sh +++ b/.ci/spec/run-test.sh @@ -2,7 +2,7 @@ csource="${BASH_SOURCE[0]}" while [ -h "$csource" ] ; do csource="$(readlink "$csource")"; done -root="$( cd -P "$( dirname "$csource" )/../" && pwd )" +root="$( cd -P "$( dirname "$csource" )/../../" && pwd )" . "${root}/.ci/spec/env.sh" . "${root}/.ci/common.sh" @@ -16,7 +16,7 @@ pushd "${root}" > "${output}" function cleanup() { (>&2 echo "Cleaning up packet device") unset PACKET_EXEC_PERSIST - pkt_wrap_stream "cd vagrant;vagrant destroy -f" \ + pkt_wrap_stream "vagrant destroy -f" \ "Vagrant command failed" } @@ -36,7 +36,7 @@ export PKT_VAGRANT_VAGRANTFILE=Vagrantfile.spec echo "Running vagrant spec tests..." # Need to make memory customizable for windows hosts -pkt_wrap_stream "cd vagrant;vagrant provision --provider vmware_desktop" \ +pkt_wrap_stream "vagrant provision --provider vmware_desktop" \ "Vagrant Blackbox testing command failed" diff --git a/.ci/sync.sh b/.ci/sync.sh index c5a4617be..3f39af7ed 100755 --- a/.ci/sync.sh +++ b/.ci/sync.sh @@ -2,7 +2,7 @@ csource="${BASH_SOURCE[0]}" while [ -h "$csource" ] ; do csource="$(readlink "$csource")"; done -root="$( cd -P "$( dirname "$csource" )/../" && pwd )" +root="$( cd -P "$( dirname "$csource" )/../../" && pwd )" . "${root}/.ci/common.sh" @@ -13,7 +13,7 @@ pushd "${root}" > "${output}" if [ "${repo_name}" = "vagrant" ]; then remote_repository="hashicorp/vagrant-blackbox" else - remote_repository="hashicorp/vagrant" + fail "This repository is not configured to sync vagrant to mirror repository" fi echo "Adding remote mirror repository '${remote_repository}'..." diff --git a/.github/workflows/code.yml b/.github/workflows/code.yml index ba173a2df..c9d332767 100644 --- a/.github/workflows/code.yml +++ b/.github/workflows/code.yml @@ -5,27 +5,6 @@ on: - 'spec-test-*' jobs: - sync-vagrant: - if: github.repository == 'hashicorp/vagrant-blackbox' - runs-on: ubuntu-18.04 - steps: - - name: Code Checkout - uses: actions/checkout@v2 - with: - persist-credentials: false - fetch-depth: 0 - - name: Set Ruby - uses: actions/setup-ruby@v1 - with: - ruby-version: '2.6' - - name: Sync Vagrant Repository - run: ./.ci/sync.sh - working-directory: ${{github.workspace}} - env: - HASHIBOT_TOKEN: ${{ secrets.HASHIBOT_TOKEN }} - HASHIBOT_USERNAME: ${{ secrets.HASHIBOT_USERNAME }} - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} - sync-blackbox: if: github.repository == 'hashicorp/vagrant' runs-on: ubuntu-18.04 From ed62d4b0123d58c85ad7f1c184f04123de969d00 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 13 May 2020 13:09:22 -0700 Subject: [PATCH 29/29] Remove cleanup function --- .ci/spec/run-test.sh | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.ci/spec/run-test.sh b/.ci/spec/run-test.sh index f35189a01..f41d3a4e0 100755 --- a/.ci/spec/run-test.sh +++ b/.ci/spec/run-test.sh @@ -11,15 +11,6 @@ pushd "${root}" > "${output}" # Assumes packet is already set up -# Define a custom cleanup function to destroy any orphan guests -# on the packet device -function cleanup() { - (>&2 echo "Cleaning up packet device") - unset PACKET_EXEC_PERSIST - pkt_wrap_stream "vagrant destroy -f" \ - "Vagrant command failed" -} - # job_id is provided by common.sh export PACKET_EXEC_REMOTE_DIRECTORY="${job_id}"