Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move docker tests into tests folder, fix nightly #6855

Merged
merged 4 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 2 additions & 7 deletions scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -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 $?"

# ---
Expand All @@ -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

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions scripts/test-helpers → tests/docker/test-helpers
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -555,7 +555,7 @@ export -f early-exit

run-test() {
export PROVISION_LOCK=$(mktemp)
./scripts/test-runner $@ &
./tests/docker/test-runner $@ &
pids+=($!)
(
set +x
Expand Down Expand Up @@ -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
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion scripts/test-runner → tests/docker/test-runner
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
set -x -e
cd $(dirname $0)/..
cd $(dirname $0)/../..

# ---

Expand Down
File renamed without changes.
59 changes: 59 additions & 0 deletions tests/install/README.md
Original file line number Diff line number Diff line change
@@ -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)<br/>
The number of vCPU for the guest to use.
- `TEST_VM_MEMORY` (default :arrow_right: 3072)<br/>
The number of megabytes of memory for the guest to use.
- `TEST_VM_BOOT_TIMEOUT` (default :arrow_right: 600)<br/>
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
```
20 changes: 0 additions & 20 deletions tests/install/centos-9/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion tests/install/install_util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions tests/install/opensuse-leap/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand All @@ -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|
Expand Down
22 changes: 0 additions & 22 deletions tests/install/rocky-8/README.md

This file was deleted.

21 changes: 0 additions & 21 deletions tests/install/ubuntu-2404/README.md

This file was deleted.

3 changes: 1 addition & 2 deletions tests/install/ubuntu-2404/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down Expand Up @@ -66,7 +66,6 @@ Vagrant.configure("2") do |config|
iptables \
less \
lsof \
netcat \
socat \
${INSTALL_PACKAGES}
SHELL
Expand Down
19 changes: 0 additions & 19 deletions tests/install/windows-2019/README.md

This file was deleted.

19 changes: 0 additions & 19 deletions tests/install/windows-2022/README.md

This file was deleted.

Loading