From fa180c00084845287992bed2c5bf16453c57c79f Mon Sep 17 00:00:00 2001 From: Derek Nola Date: Mon, 23 Sep 2024 10:07:20 -0700 Subject: [PATCH 1/4] Move docker tests into tests folder Signed-off-by: Derek Nola --- Makefile | 12 ++++++------ scripts/test | 9 ++------- scripts/{unit-tests => test-unit} | 0 {scripts => tests/docker}/test-certs-openssl.cnf | 0 {scripts => tests/docker}/test-helpers | 8 ++++---- {scripts => tests/docker}/test-run-basics | 0 {scripts => tests/docker}/test-runner | 0 {scripts => tests/docker}/test-setup-sonobuoy | 0 8 files changed, 12 insertions(+), 17 deletions(-) rename scripts/{unit-tests => test-unit} (100%) rename {scripts => tests/docker}/test-certs-openssl.cnf (100%) rename {scripts => tests/docker}/test-helpers (98%) rename {scripts => tests/docker}/test-run-basics (100%) rename {scripts => tests/docker}/test-runner (100%) rename {scripts => tests/docker}/test-setup-sonobuoy (100%) diff --git a/Makefile b/Makefile index 96f525606c..13cb6387ca 100644 --- a/Makefile +++ b/Makefile @@ -149,14 +149,14 @@ package-windows-bundle: build-windows-binary ## Package the Windows tarball bund ./scripts/package-windows-bundle .PHONY: test -test: unit-tests integration-tests +test: test-unit test-docker -.PHONY: unit-tests -unit-tests: - ./scripts/unit-tests +.PHONY: test-unit +unit-test: + ./scripts/test-unit -.PHONY: integration-tests -integration-tests: +.PHONY: test-docker +test-docker: ./scripts/test .PHONY: checksum diff --git a/scripts/test b/scripts/test index d127783d55..5c6e09eb96 100755 --- a/scripts/test +++ b/scripts/test @@ -5,14 +5,14 @@ cd $(dirname $0)/.. docker ps -. ./scripts/test-helpers +. ./tests/docker/test-helpers artifacts=$(pwd)/dist/artifacts mkdir -p $artifacts # --- -. ./scripts/test-run-basics +. ./tests/docker/test-run-basics echo "Did test-run-basics $?" # --- @@ -25,11 +25,6 @@ E2E_OUTPUT=$artifacts test-run-sonobuoy echo "Did test-run-sonobuoy $?" # --- -if [ "$DRONE_BUILD_EVENT" = 'tag' ]; then - early-exit 'Skipping remaining tests on tag.' -fi -# --- - #test-run-sonobuoy mysql #test-run-sonobuoy postgres diff --git a/scripts/unit-tests b/scripts/test-unit similarity index 100% rename from scripts/unit-tests rename to scripts/test-unit diff --git a/scripts/test-certs-openssl.cnf b/tests/docker/test-certs-openssl.cnf similarity index 100% rename from scripts/test-certs-openssl.cnf rename to tests/docker/test-certs-openssl.cnf diff --git a/scripts/test-helpers b/tests/docker/test-helpers similarity index 98% rename from scripts/test-helpers rename to tests/docker/test-helpers index dc44358725..6b5b757e0d 100755 --- a/scripts/test-helpers +++ b/tests/docker/test-helpers @@ -324,7 +324,7 @@ test-setup() { return 1 fi - local setupFile=./scripts/test-setup-${TEST_TYPE} + local setupFile=./tests/docker/test-setup-${TEST_TYPE} [ -f $setupFile ] && source $setupFile echo ${RANDOM}${RANDOM}${RANDOM} >$TEST_DIR/metadata/secret @@ -337,7 +337,7 @@ gen-certs() {( set -e -x #umask 077 - local opensslConfig=$(pwd)/scripts/test-certs-openssl.cnf + local opensslConfig=$(pwd)/tests/docker/test-certs-openssl.cnf local subject="/C=US/ST=AZ/L=Tempe/O=Rancher/OU=DevOps/DC=com/DC=rancher" local caDir=$TEST_DIR/db-ca [ -d $caDir ] && rm -rf $caDir @@ -555,7 +555,7 @@ export -f early-exit run-test() { export PROVISION_LOCK=$(mktemp) - ./scripts/test-runner $@ & + ./tests/docker/test-runner $@ & pids+=($!) ( set +x @@ -605,7 +605,7 @@ test-run-sonobuoy() { export LABEL_SUFFIX=$1 fi - . ./scripts/test-setup-sonobuoy$suffix + . ./tests/docker/test-setup-sonobuoy$suffix run-e2e-tests } export -f test-run-sonobuoy diff --git a/scripts/test-run-basics b/tests/docker/test-run-basics similarity index 100% rename from scripts/test-run-basics rename to tests/docker/test-run-basics diff --git a/scripts/test-runner b/tests/docker/test-runner similarity index 100% rename from scripts/test-runner rename to tests/docker/test-runner diff --git a/scripts/test-setup-sonobuoy b/tests/docker/test-setup-sonobuoy similarity index 100% rename from scripts/test-setup-sonobuoy rename to tests/docker/test-setup-sonobuoy From 5a43aec5b88352c18301095a3537fc86682d5df8 Mon Sep 17 00:00:00 2001 From: Derek Nola Date: Mon, 23 Sep 2024 10:53:02 -0700 Subject: [PATCH 2/4] Consolidate install test READMEs Signed-off-by: Derek Nola --- tests/install/README.md | 59 ++++++++++++++++++++++++++++ tests/install/centos-9/README.md | 20 ---------- tests/install/rocky-8/README.md | 22 ----------- tests/install/ubuntu-2404/README.md | 21 ---------- tests/install/windows-2019/README.md | 19 --------- tests/install/windows-2022/README.md | 19 --------- 6 files changed, 59 insertions(+), 101 deletions(-) create mode 100644 tests/install/README.md delete mode 100644 tests/install/centos-9/README.md delete mode 100644 tests/install/rocky-8/README.md delete mode 100644 tests/install/ubuntu-2404/README.md delete mode 100644 tests/install/windows-2019/README.md delete mode 100644 tests/install/windows-2022/README.md diff --git a/tests/install/README.md b/tests/install/README.md new file mode 100644 index 0000000000..df2b3c9eea --- /dev/null +++ b/tests/install/README.md @@ -0,0 +1,59 @@ +## Install Tests + +These tests are used to validate the installation and operation of RKE2 on a variety of operating systems. The test themselves are Vagrantfiles describing single-node installations that are easily spun up with Vagrant for the `libvirt` and `virtualbox` providers: + +- [Install Script](install) :arrow_right: scheduled nightly and on an install script change + - [CentOS 9 Stream](install/centos-9) + - [Rocky Linux 8](install/rocky-8) (stand-in for RHEL 8) + - [Oracle 9](install/oracle-9) + - [Leap 15.6](install/opensuse-leap) (stand-in for SLES) + - [Ubuntu 24.04](install/ubuntu-2404) + - [Windows Server 2019](install/windows-2019) + - [Windows Server 2022](install/windows-2022) + +## Format +When adding new installer test(s) please copy the prevalent style for the `Vagrantfile`. +Ideally, the boxes used for additional assertions will support the default `libvirt` provider which +enables them to be used by our GitHub Actions [Nightly Install Test Workflow](../../.github/workflows/nightly-install.yaml). + +### Framework + +If you are new to Vagrant, Hashicorp has written some pretty decent introductory tutorials and docs, see: +- https://learn.hashicorp.com/collections/vagrant/getting-started +- https://www.vagrantup.com/docs/installation + +#### Plugins and Providers + +The `libvirt`provider cannot be used without first [installing the `vagrant-libvirt` plugin](https://github.com/vagrant-libvirt/vagrant-libvirt). Libvirtd service must be installed and running on the host machine as well. + +This can be installed with: +```shell +vagrant plugin install vagrant-libvirt +``` + +#### Environment Variables + +These can be set on the CLI or exported before invoking Vagrant: +- `TEST_VM_CPUS` (default :arrow_right: 2)
+ The number of vCPU for the guest to use. +- `TEST_VM_MEMORY` (default :arrow_right: 3072)
+ The number of megabytes of memory for the guest to use. +- `TEST_VM_BOOT_TIMEOUT` (default :arrow_right: 600)
+ The time in seconds that Vagrant will wait for the machine to boot and be accessible. + +### Running + +The **Install Script** tests can be run by changing to the fixture directory and invoking `vagrant up`, e.g.: +```shell +cd tests/install/rocky-8 +vagrant up +# The following provisioners are optional. In GitHub Actions CI they are invoked +# explicitly to avoid certain timeout issues on slow runners +vagrant provision --provision-with=rke2-wait-for-node +vagrant provision --provision-with=rke2-wait-for-coredns +vagrant provision --provision-with=rke2-wait-for-local-storage +vagrant provision --provision-with=rke2-wait-for-metrics-server +vagrant provision --provision-with=rke2-wait-for-traefik +vagrant provision --provision-with=rke2-status +vagrant provision --provision-with=rke2-procps +``` \ No newline at end of file diff --git a/tests/install/centos-9/README.md b/tests/install/centos-9/README.md deleted file mode 100644 index 65107f8c8b..0000000000 --- a/tests/install/centos-9/README.md +++ /dev/null @@ -1,20 +0,0 @@ -RKE2 Install on CentOS 8 ---- - -Asserting correctness of the RKE2 installer script using [CentOS 7](https://docs.centos.org/en-US/centos/install-guide/) -as a stand-in for [RHEL 7](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/). - -### Testing With Vagrant - -The [Vagrant box](https://app.vagrantup.com/dweomer/boxes/centos-7.9-amd64) used for this test supports these providers: -- `libvirt` -- `virtualbox` (the default for most installations, including `macos-12` github actions runners) -- `vmware_desktop` - -To spin up a VM to test a locally modified `install.sh`: -```shell -vagrant up -``` - -See also: -- [developer-docs/testing.md](../../../developer-docs/testing.md#environment-variables) diff --git a/tests/install/rocky-8/README.md b/tests/install/rocky-8/README.md deleted file mode 100644 index af74b5c631..0000000000 --- a/tests/install/rocky-8/README.md +++ /dev/null @@ -1,22 +0,0 @@ -RKE2 Install on CentOS 8 ---- - -Asserting correctness of the RKE2 installer script using [Rocky Linux](https://wiki.rockylinux.org/) -as a stand-in for [RHEL 8](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8). - -### Testing With Vagrant - -The [Vagrant box](https://app.vagrantup.com/generic/boxes/rocky8) used for this test supports these providers: -- `libvirt` -- `virtualbox` (the default for most installations, including `macos-12` github actions runners) -- `vmware_desktop` -- `hyperv` -- `parallels` - -To spin up a VM to test a locally modified `install.sh`: -```shell -vagrant up -``` - -See also: -- [developer-docs/testing.md](../../../developer-docs/testing.md#environment-variables) diff --git a/tests/install/ubuntu-2404/README.md b/tests/install/ubuntu-2404/README.md deleted file mode 100644 index 287db83609..0000000000 --- a/tests/install/ubuntu-2404/README.md +++ /dev/null @@ -1,21 +0,0 @@ -RKE2 Install on Ubuntu 20.04 Focal Fossa ---- - -Asserting correctness of the RKE2 installer script on [Ubuntu 24.04](https://releases.ubuntu.com/24.04/). - -### Testing With Vagrant - -The [Vagrant box](https://app.vagrantup.com/generic/boxes/ubuntu2004) used for this test supports these providers: -- `hyperv` -- `libvirt` -- `parallels` -- `virtualbox` (the default for most installations) -- `vmware_desktop` - -To spin up a VM to test a locally modified `install.sh`: -```shell -vagrant up -``` - -See also: -- [developer-docs/testing.md](../../../developer-docs/testing.md#environment-variables) diff --git a/tests/install/windows-2019/README.md b/tests/install/windows-2019/README.md deleted file mode 100644 index 4cf7c47541..0000000000 --- a/tests/install/windows-2019/README.md +++ /dev/null @@ -1,19 +0,0 @@ -RKE2 Install on Windows Server 2019 ---- - -Asserting correctness of the RKE2 installer script on [Windows Server 2019](https://docs.microsoft.com/en-us/windows-server/get-started/whats-new-in-windows-server-2019). - -### Testing With Vagrant - -The [Vagrant box](https://app.vagrantup.com/jborean93/boxes/WindowsServer2019) used for this test supports these providers: -- `hyperv` -- `libvirt` -- `virtualbox` (the default for most installations, including `macos-12` github actions runners) - -To spin up a VM to test a locally modified `install.ps1`: -```shell -vagrant up -``` - -See also: -- [developer-docs/testing.md](../../../developer-docs/testing.md#environment-variables) diff --git a/tests/install/windows-2022/README.md b/tests/install/windows-2022/README.md deleted file mode 100644 index 2c62e02cdc..0000000000 --- a/tests/install/windows-2022/README.md +++ /dev/null @@ -1,19 +0,0 @@ -RKE2 Install on Windows Server 2019 ---- - -Asserting correctness of the RKE2 installer script on [Windows Server 2022](https://docs.microsoft.com/en-us/windows-server/get-started/whats-new-in-windows-server-2022). - -### Testing With Vagrant - -The [Vagrant box](https://app.vagrantup.com/jborean93/boxes/WindowsServer2022) used for this test supports these providers: -- `hyperv` -- `libvirt` -- `virtualbox` (the default for most installations, including `macos-12` github actions runners) - -To spin up a VM to test a locally modified `install.ps1`: -```shell -vagrant up -``` - -See also: -- [developer-docs/testing.md](../../../developer-docs/testing.md#environment-variables) From 141a4e7db35072d5e0a50e36d2b9cade231d3a35 Mon Sep 17 00:00:00 2001 From: Derek Nola Date: Mon, 23 Sep 2024 10:55:01 -0700 Subject: [PATCH 3/4] Fix ubuntu and leap nightly install tests Signed-off-by: Derek Nola --- tests/install/install_util.rb | 2 +- tests/install/opensuse-leap/Vagrantfile | 4 ++-- tests/install/ubuntu-2404/Vagrantfile | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/install/install_util.rb b/tests/install/install_util.rb index 06a340d6cf..2f5b7d3ecd 100644 --- a/tests/install/install_util.rb +++ b/tests/install/install_util.rb @@ -117,7 +117,7 @@ def runKillAllScript(vm) #!/usr/bin/env bash set -eu -o pipefail echo 'Run kill all' - rke2-killall.sh + /usr/local/bin/rke2-killall.sh SHELL end end diff --git a/tests/install/opensuse-leap/Vagrantfile b/tests/install/opensuse-leap/Vagrantfile index c96c170963..1ec0d11d85 100644 --- a/tests/install/opensuse-leap/Vagrantfile +++ b/tests/install/opensuse-leap/Vagrantfile @@ -4,7 +4,7 @@ ENV['TEST_INSTALL_SH'] ||= '../../../install.sh' Vagrant.configure("2") do |config| - config.vm.box = 'opensuse/Leap-15.5.x86_64' + config.vm.box = 'opensuse/Leap-15.6.x86_64' config.vm.boot_timeout = ENV['TEST_VM_BOOT_TIMEOUT'] || 600 # seconds config.vm.synced_folder '.', '/vagrant', type: 'rsync', disabled: false %w[libvirt virtualbox vmware_desktop].each do |p| @@ -20,7 +20,7 @@ Vagrant.configure("2") do |config| external_env = "" ENV.select{|k,v| k.start_with?('RKE2_') || k.start_with?('INSTALL_RKE2_')}.each {|key,value| external_env << "#{key.to_s}=#{value.to_s}"} - config.vm.define "install-leap-15.4", primary: true do |test| + config.vm.define "install-leap-15.6", primary: true do |test| test.vm.hostname = 'smoke' test.vm.provision 'rke2-upload-installer', type: 'file', run: 'always', source: ENV['TEST_INSTALL_SH'], destination: 'install.sh' test.vm.provision"rke2-install", type: 'rke2', run: "once" do |rke2| diff --git a/tests/install/ubuntu-2404/Vagrantfile b/tests/install/ubuntu-2404/Vagrantfile index 74fb12fcee..a7a42f96f9 100644 --- a/tests/install/ubuntu-2404/Vagrantfile +++ b/tests/install/ubuntu-2404/Vagrantfile @@ -20,7 +20,7 @@ Vagrant.configure("2") do |config| external_env = "" ENV.select{|k,v| k.start_with?('RKE2_') || k.start_with?('INSTALL_RKE2_')}.each {|key,value| external_env << "#{key.to_s}=#{value.to_s}"} - config.vm.define "install-ubuntu-2004", primary: true do |test| + config.vm.define "install-ubuntu-2404", primary: true do |test| test.vm.hostname = 'smoke' test.vm.provision 'rke2-upload-installer', type: 'file', run: 'always', source: ENV['TEST_INSTALL_SH'], destination: 'install.sh' test.vm.provision"rke2-install", type: 'rke2', run: "once" do |rke2| @@ -66,7 +66,6 @@ Vagrant.configure("2") do |config| iptables \ less \ lsof \ - netcat \ socat \ ${INSTALL_PACKAGES} SHELL From 87cc277f7aa7409c522410b5514d0c45d8daf90d Mon Sep 17 00:00:00 2001 From: Derek Nola Date: Tue, 24 Sep 2024 11:18:40 -0700 Subject: [PATCH 4/4] Fix directory location calls Signed-off-by: Derek Nola --- {scripts => tests/docker}/log-upload | 0 tests/docker/test-helpers | 2 +- tests/docker/test-runner | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename {scripts => tests/docker}/log-upload (100%) diff --git a/scripts/log-upload b/tests/docker/log-upload similarity index 100% rename from scripts/log-upload rename to tests/docker/log-upload diff --git a/tests/docker/test-helpers b/tests/docker/test-helpers index 6b5b757e0d..82ac94acbc 100755 --- a/tests/docker/test-helpers +++ b/tests/docker/test-helpers @@ -171,7 +171,7 @@ dump-logs() { echo "#- Finish: logs for run ($testID)" echo "#---------------------------------" echo - ./scripts/log-upload $TEST_DIR + ./tests/docker/log-upload $TEST_DIR } export -f dump-logs diff --git a/tests/docker/test-runner b/tests/docker/test-runner index 79b4ce10da..a831e74ea1 100755 --- a/tests/docker/test-runner +++ b/tests/docker/test-runner @@ -1,6 +1,6 @@ #!/bin/bash set -x -e -cd $(dirname $0)/.. +cd $(dirname $0)/../.. # ---