test: move greenprint and redprint functions to shared_lib.sh

Since we're sharing functions between test scripts, move greenprint(),
the most rewritten function in the history of the project, to
shared_lib.sh and source it everywhere.
This commit is contained in:
Achilleas Koutsou 2022-08-30 16:08:04 +02:00 committed by Tom Gundersen
parent 3b14828669
commit bf83bbea38
28 changed files with 19 additions and 105 deletions

View file

@ -79,14 +79,11 @@ case ${IMAGE_TYPE} in
exit 1
esac
# Colorful timestamped output.
function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
}
ARTIFACTS="${ARTIFACTS:-/tmp/artifacts}"
source /usr/libexec/osbuild-composer-test/set-env-variables.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
# Container image used for cloud provider CLI tools
export CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest"

View file

@ -1,4 +1,5 @@
#!/usr/bin/bash
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
function installClient() {
if ! hash aws; then

View file

@ -1,5 +1,7 @@
#!/usr/bin/bash
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
function createReqFileEdge() {
cat > "$REQUEST_FILE" << EOF
{

View file

@ -2,6 +2,7 @@
source /usr/libexec/tests/osbuild-composer/api/common/common.sh
source /usr/libexec/tests/osbuild-composer/api/common/s3.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
function checkEnv() {
printenv AWS_REGION > /dev/null

View file

@ -12,10 +12,6 @@ set -euo pipefail
source /usr/libexec/osbuild-composer-test/set-env-variables.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
# Colorful output.
function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
}
# Container image used for cloud provider CLI tools
CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest"

View file

@ -17,11 +17,6 @@ BRANCH_NAME="${CI_COMMIT_BRANCH:-local}"
BUILD_ID="${CI_BUILD_ID:-$(uuidgen)}"
HYPER_V_GEN="${HYPER_V_GEN:-V1}"
# Colorful output.
function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
}
# Container image used for cloud provider CLI tools
CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest"

View file

@ -1,10 +1,6 @@
#!/usr/bin/bash
set -euxo pipefail
# Colorful timestamped output.
function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
}
source /usr/libexec/osbuild-composer-test/set-env-variables.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh

View file

@ -1,10 +1,6 @@
#!/usr/bin/bash
set -euxo pipefail
# Colorful timestamped output.
function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
}
source /usr/libexec/osbuild-composer-test/set-env-variables.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh

View file

@ -2,13 +2,11 @@
set -euo pipefail
# Colorful output.
# Colorful timestamped output.
function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
}
function redprint {
echo -e "\033[1;31m[$(date -Isecond)] ${1}\033[0m"
}
function revert_to_head {
git checkout "$head"
}

View file

@ -12,11 +12,6 @@ source /etc/os-release
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
# Colorful output.
function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
}
TEST_UUID=$(uuidgen)
IMAGE_KEY="osbuild-composer-test-${TEST_UUID}"

View file

@ -12,10 +12,6 @@ source /usr/libexec/tests/osbuild-composer/shared_lib.sh
set -euo pipefail
# Colorful output.
function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
}
# Container image used for cloud provider CLI tools
CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest"

View file

@ -15,11 +15,6 @@ set -euo pipefail
source /usr/libexec/osbuild-composer-test/set-env-variables.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
# Colorful output.
function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
}
# modify existing kickstart by prepending and appending commands
function modksiso {
sudo dnf install -y lorax # for mkksiso

View file

@ -5,11 +5,8 @@ OSBUILD_COMPOSER_TEST_DATA=/usr/share/tests/osbuild-composer/
# Get OS data.
source /usr/libexec/osbuild-composer-test/set-env-variables.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
# Colorful output.
function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
}
if [ "${NIGHTLY:=false}" == "true" ]; then
greenprint "INFO: Test not supported during nightly CI pipelines. Exiting ..."

View file

@ -15,16 +15,12 @@ OSBUILD_COMPOSER_TEST_DATA=/usr/share/tests/osbuild-composer/
# Get OS data.
source /usr/libexec/osbuild-composer-test/set-env-variables.sh
# Colorful output.
function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
}
# Provision the software under test.
/usr/libexec/osbuild-composer-test/provision.sh jwt
# Source common functions
source /usr/libexec/tests/osbuild-composer/api/common/common.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
greenprint "Registering clean ups"
KILL_PIDS=()

View file

@ -11,11 +11,6 @@ source /etc/os-release
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
# Colorful output.
function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
}
# Start libvirtd and test it.
greenprint "🚀 Starting libvirt daemon"
sudo systemctl start libvirtd

View file

@ -8,11 +8,6 @@ set -euo pipefail
source /usr/libexec/osbuild-composer-test/set-env-variables.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
# Colorful output.
function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
}
# Install openshift client
greenprint "🔧 Installing oenshift client(oc)"

View file

@ -10,10 +10,6 @@ source /usr/libexec/tests/osbuild-composer/shared_lib.sh
source /etc/os-release
ARCH=$(uname -m)
# Colorful output.
function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
}
# Start libvirtd and test it.
greenprint "🚀 Starting libvirt daemon"

View file

@ -14,11 +14,6 @@ fi
# Provision the software under test.
/usr/libexec/osbuild-composer-test/provision.sh none
# Colorful output.
function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
}
# Start libvirtd and test it.
greenprint "🚀 Starting libvirt daemon"
sudo systemctl start libvirtd

View file

@ -13,11 +13,6 @@ fi
# Provision the software under test.
/usr/libexec/osbuild-composer-test/provision.sh none
# Colorful output.
function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
}
# Start libvirtd and test it.
greenprint "🚀 Starting libvirt daemon"
sudo systemctl start libvirtd

View file

@ -8,11 +8,6 @@ set -euo pipefail
source /etc/os-release
ARCH=$(uname -m)
# Colorful output.
function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
}
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
# Start firewalld

View file

@ -111,11 +111,6 @@ case "${ID}-${VERSION_ID}" in
esac
# Colorful output.
function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
}
# Start libvirtd and test it.
greenprint "🚀 Starting libvirt daemon"
sudo systemctl start libvirtd

View file

@ -7,10 +7,6 @@
set -exuo pipefail
function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
}
function generate_certificates {
# Generate CA root key
sudo openssl genrsa -out ca.key

View file

@ -8,9 +8,7 @@
set -exuo pipefail
function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
}
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
function generate_certificates {
# Generate CA root key

View file

@ -6,10 +6,6 @@
set -xeuo pipefail
function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
}
source /usr/libexec/osbuild-composer-test/set-env-variables.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh

View file

@ -7,10 +7,6 @@
set -exuo pipefail
# Colorful timestamped output.
function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
}
ARTIFACTS="${ARTIFACTS:-/tmp/artifacts}"

View file

@ -33,3 +33,11 @@ function get_build_info() {
jq -r "${key}" "${fname}"
}
# Colorful timestamped output.
function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
}
function redprint {
echo -e "\033[1;31m[$(date -Isecond)] ${1}\033[0m"
}

View file

@ -3,13 +3,10 @@ set -uxo pipefail
# Get OS data.
source /usr/libexec/osbuild-composer-test/set-env-variables.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
ARTIFACTS="${ARTIFACTS:-/tmp/artifacts}"
# Colorful output.
function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
}
# Wait for VM to start
function wait_for_vm {

View file

@ -12,10 +12,6 @@ set -euo pipefail
source /usr/libexec/osbuild-composer-test/set-env-variables.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
# Colorful output.
function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
}
# Provision the software under test.
/usr/libexec/osbuild-composer-test/provision.sh none