diff --git a/scripts/test b/scripts/test index d90d843386cc..b6b042fd32c8 100755 --- a/scripts/test +++ b/scripts/test @@ -3,7 +3,7 @@ set -e -x cd $(dirname $0)/.. . ./scripts/version.sh -. ./scripts/test-helpers +. ./tests/docker/test-helpers # sysctl commands sysctl -w fs.inotify.max_queued_events=16384 @@ -21,28 +21,28 @@ docker ps # --- -. ./scripts/test-run-basics +. ./tests/docker/test-run-basics echo "Did test-run-basics $?" -. ./scripts/test-run-compat +. ./tests/docker/test-run-compat echo "Did test-run-compat $?" -. ./scripts/test-run-hardened +. ./tests/docker/test-run-hardened echo "Did test-run-hardened $?" -. ./scripts/test-run-cacerts +. ./tests/docker/test-run-cacerts echo "Did test-run-cacerts $?" -. ./scripts/test-run-bootstraptoken +. ./tests/docker/test-run-bootstraptoken echo "Did test-run-bootstraptoken $?" -. ./scripts/test-run-upgrade +. ./tests/docker/test-run-upgrade echo "Did test-run-upgrade $?" -. ./scripts/test-run-etcd +. ./tests/docker/test-run-etcd echo "Did test-run-etcd $?" -. ./scripts/test-run-lazypull +. ./tests/docker/test-run-lazypull echo "Did test-run-lazypull $?" # --- diff --git a/scripts/test-certs-openssl.cnf b/scripts/test-certs-openssl.cnf deleted file mode 100644 index 222288ec6da8..000000000000 --- a/scripts/test-certs-openssl.cnf +++ /dev/null @@ -1,72 +0,0 @@ -# db OpenSSL configuration file. -SAN = "IP:127.0.0.1, IP:172.17.0.1, DNS:host.docker.internal" -dir = . - -[ ca ] -default_ca = db_ca - -[ db_ca ] -certs = $dir/certs -certificate = $dir/certs/ca.crt -crl = $dir/crl.pem -crl_dir = $dir/crl -crlnumber = $dir/crlnumber -database = $dir/index.txt -email_in_dn = no -new_certs_dir = $dir/newcerts -private_key = $dir/private/ca.key -serial = $dir/serial -RANDFILE = $dir/private/.rand -name_opt = ca_default -cert_opt = ca_default -default_days = 3650 -default_crl_days = 30 -default_md = sha512 -preserve = no -policy = policy_db - -[ policy_db ] -organizationName = optional -commonName = supplied - -[ req ] -default_bits = 1024 -default_keyfile = privkey.pem -distinguished_name = req_distinguished_name -attributes = req_attributes -x509_extensions = v3_ca -string_mask = utf8only -req_extensions = db_client - -[ req_distinguished_name ] -countryName = Country Name (2 letter code) -countryName_default = US -countryName_min = 2 -countryName_max = 2 -commonName = Common Name (FQDN) -0.organizationName = Organization Name (eg, company) -0.organizationName_default = db-ca - -[ req_attributes ] - -[ v3_ca ] -basicConstraints = CA:true -keyUsage = keyCertSign,cRLSign -subjectKeyIdentifier = hash - -[ db_client ] -basicConstraints = CA:FALSE -extendedKeyUsage = clientAuth -keyUsage = digitalSignature, keyEncipherment - -[ db_peer ] -basicConstraints = CA:FALSE -extendedKeyUsage = clientAuth, serverAuth -keyUsage = digitalSignature, keyEncipherment -subjectAltName = ${ENV::SAN} - -[ db_server ] -basicConstraints = CA:FALSE -extendedKeyUsage = clientAuth, serverAuth -keyUsage = digitalSignature, keyEncipherment -subjectAltName = ${ENV::SAN} \ No newline at end of file diff --git a/scripts/test-unit b/scripts/test-unit deleted file mode 100755 index 429755243686..000000000000 --- a/scripts/test-unit +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -go test -v ./pkg/... -run Unit diff --git a/tests/TESTING.md b/tests/TESTING.md index 4a1029e93d41..29af08a9ead3 100644 --- a/tests/TESTING.md +++ b/tests/TESTING.md @@ -3,6 +3,7 @@ Testing in K3s comes in 5 forms: - [Unit](#unit-tests) - [Integration](#integration-tests) +- [Docker](#docker-tests) - [Smoke](#smoke-tests) - [Performance](#performance) - [End-to-End (E2E)](#end-to-end-e2e-tests) @@ -59,6 +60,12 @@ See [integration/README.md](./integration/README.md) for more info. ___ +## Docker Tests + +Docker tests run clusters of K3s nodes as containers and test basic functionality. These tests are run in the Drone CI pipeline `test` stage. + +___ + ## Smoke Tests Smoke tests are a collection of tests defined under the [tests](./tests) and fall into two categories: install and snapshotter. These tests are used to validate the installation and operation of K3s on a variety of operating systems. The sub-directories therein contain fixtures for running simple clusters to assert correct behavior for "happy path" scenarios. The test themses are Vagrantfiles describing single-node installations that are easily spun up with Vagrant for the `libvirt` and `virtualbox` providers: diff --git a/scripts/flaky-tests b/tests/docker/flaky-tests similarity index 100% rename from scripts/flaky-tests rename to tests/docker/flaky-tests diff --git a/scripts/test-helpers b/tests/docker/test-helpers similarity index 99% rename from scripts/test-helpers rename to tests/docker/test-helpers index c34cc3bda93f..6a5335689557 100755 --- a/scripts/test-helpers +++ b/tests/docker/test-helpers @@ -511,7 +511,7 @@ run-test() { ) export PROVISION_LOCK=$(mktemp) - ./scripts/test-runner "$@" & + ./tests/docker/test-runner "$@" & pids+=($!) ( @@ -585,7 +585,7 @@ test-run-sonobuoy() { fi cleanup-test-env - . ./scripts/test-setup-sonobuoy$suffix + . ./tests/docker/test-setup-sonobuoy$suffix if [ "$1" = "parallel" ] || [ "$2" = "parallel" ]; then label=PARALLEL \ 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-run-bootstraptoken b/tests/docker/test-run-bootstraptoken similarity index 100% rename from scripts/test-run-bootstraptoken rename to tests/docker/test-run-bootstraptoken diff --git a/scripts/test-run-cacerts b/tests/docker/test-run-cacerts similarity index 100% rename from scripts/test-run-cacerts rename to tests/docker/test-run-cacerts diff --git a/scripts/test-run-compat b/tests/docker/test-run-compat similarity index 100% rename from scripts/test-run-compat rename to tests/docker/test-run-compat diff --git a/scripts/test-run-etcd b/tests/docker/test-run-etcd similarity index 100% rename from scripts/test-run-etcd rename to tests/docker/test-run-etcd diff --git a/scripts/test-run-hardened b/tests/docker/test-run-hardened similarity index 100% rename from scripts/test-run-hardened rename to tests/docker/test-run-hardened diff --git a/scripts/test-run-lazypull b/tests/docker/test-run-lazypull similarity index 100% rename from scripts/test-run-lazypull rename to tests/docker/test-run-lazypull diff --git a/scripts/test-run-upgrade b/tests/docker/test-run-upgrade similarity index 100% rename from scripts/test-run-upgrade rename to tests/docker/test-run-upgrade diff --git a/scripts/test-runner b/tests/docker/test-runner similarity index 84% rename from scripts/test-runner rename to tests/docker/test-runner index 79b4ce10dae0..a831e74ea14d 100755 --- a/scripts/test-runner +++ b/tests/docker/test-runner @@ -1,6 +1,6 @@ #!/bin/bash set -x -e -cd $(dirname $0)/.. +cd $(dirname $0)/../.. # --- diff --git a/scripts/test-setup-sonobuoy b/tests/docker/test-setup-sonobuoy similarity index 91% rename from scripts/test-setup-sonobuoy rename to tests/docker/test-setup-sonobuoy index d86cc49a1b31..028ef1345de1 100755 --- a/scripts/test-setup-sonobuoy +++ b/tests/docker/test-setup-sonobuoy @@ -19,7 +19,7 @@ test-post-hook() { fi local failures=$(awk '/^Summarizing .* Failures?:$/,0' "$TEST_DIR/sonobuoy/plugins/e2e/results/global/e2e.log") # Ignore sonobuoy failures if only these flaky tests have failed - flakyFails=$( grep -scF -f ./scripts/flaky-tests <<< "$failures" ) + flakyFails=$( grep -scF -f ./tests/docker/flaky-tests <<< "$failures" ) totalFails=$( grep -scF -e "[Fail]" <<< "$failures" ) [ "$totalFails" -le "$flakyFails" ] } diff --git a/scripts/test-setup-sonobuoy-etcd b/tests/docker/test-setup-sonobuoy-etcd similarity index 86% rename from scripts/test-setup-sonobuoy-etcd rename to tests/docker/test-setup-sonobuoy-etcd index b90dec30da8c..1d3dae59d91f 100644 --- a/scripts/test-setup-sonobuoy-etcd +++ b/tests/docker/test-setup-sonobuoy-etcd @@ -1,6 +1,6 @@ #!/bin/bash -. ./scripts/test-setup-sonobuoy +. ./tests/docker/test-setup-sonobuoy export NUM_SERVERS=1 export NUM_AGENTS=1 @@ -20,7 +20,7 @@ test-post-hook() { fi local failures=$(awk '/^Summarizing .* Failures?:$/,0' "$TEST_DIR/sonobuoy/plugins/e2e/results/global/e2e.log") # Ignore sonobuoy failures if only these flaky tests have failed - flakyFails=$( grep -scF -f ./scripts/flaky-tests <<< "$failures" ) + flakyFails=$( grep -scF -f ./tests/docker/flaky-tests <<< "$failures" ) totalFails=$( grep -scF -e "[Fail]" <<< "$failures" ) [ "$totalFails" -le "$flakyFails" ] } diff --git a/scripts/test-setup-sonobuoy-mysql b/tests/docker/test-setup-sonobuoy-mysql similarity index 93% rename from scripts/test-setup-sonobuoy-mysql rename to tests/docker/test-setup-sonobuoy-mysql index c8ae42c0dbeb..fd5e98e3284b 100644 --- a/scripts/test-setup-sonobuoy-mysql +++ b/tests/docker/test-setup-sonobuoy-mysql @@ -1,6 +1,6 @@ #!/bin/bash -. ./scripts/test-setup-sonobuoy +. ./tests/docker/test-setup-sonobuoy # --- @@ -47,7 +47,7 @@ test-post-hook() { fi local failures=$(awk '/^Summarizing .* Failures?:$/,0' "$TEST_DIR/sonobuoy/plugins/e2e/results/global/e2e.log") # Ignore sonobuoy failures if only these flaky tests have failed - flakyFails=$( grep -scF -f ./scripts/flaky-tests <<< "$failures" ) + flakyFails=$( grep -scF -f ./tests/docker/flaky-tests <<< "$failures" ) totalFails=$( grep -scF -e "[Fail]" <<< "$failures" ) [ "$totalFails" -le "$flakyFails" ] } diff --git a/scripts/test-setup-sonobuoy-postgres b/tests/docker/test-setup-sonobuoy-postgres similarity index 93% rename from scripts/test-setup-sonobuoy-postgres rename to tests/docker/test-setup-sonobuoy-postgres index 4b7f794ed920..4290cb5ac7d5 100644 --- a/scripts/test-setup-sonobuoy-postgres +++ b/tests/docker/test-setup-sonobuoy-postgres @@ -1,6 +1,6 @@ #!/bin/bash -. ./scripts/test-setup-sonobuoy +. ./tests/docker/test-setup-sonobuoy # --- @@ -47,7 +47,7 @@ test-post-hook() { fi local failures=$(awk '/^Summarizing .* Failures?:$/,0' "$TEST_DIR/sonobuoy/plugins/e2e/results/global/e2e.log") # Ignore sonobuoy failures if only these flaky tests have failed - flakyFails=$( grep -scF -f ./scripts/flaky-tests <<< "$failures" ) + flakyFails=$( grep -scF -f ./tests/docker/flaky-tests <<< "$failures" ) totalFails=$( grep -scF -e "[Fail]" <<< "$failures" ) [ "$totalFails" -le "$flakyFails" ] }