Skip to content

Commit

Permalink
Set testing infra for ffi
Browse files Browse the repository at this point in the history
resolves #233
The following setup script, set identical deploy topology for:
AutoSD.qcow2 image
autosd container
c9s

FFI tests run against unified test topology

Signed-off-by: Yariv Rachmani <[email protected]>
  • Loading branch information
Yarboa committed Oct 12, 2023
1 parent 0e2899c commit f363914
Show file tree
Hide file tree
Showing 4 changed files with 217 additions and 1 deletion.
11 changes: 10 additions & 1 deletion .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,17 @@ jobs:
- job: tests
trigger: pull_request
identifier: e2e
tmt_plan: /plans/e2e
skip_build: true
tf_extra_params:
environments:
- artifacts:
tmt:
context:
"distro=centos-stream-9,scenario=ffi"
test:
tmt:
test_filter: "tier:0,tier:1,tag:ffi"

targets:
- centos-stream-9-x86_64

Expand Down
23 changes: 23 additions & 0 deletions plans/e2e/ffi.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
summary: FFI - QM FreedomFromInterference

discover:
how: fmf
filter: tag:ffi

provision:
how: local

adjust:
prepare+:
- name: Set QM env
how: shell
script: |
cd tests/e2e
./set-ffi-env-e2e --qm-setup-from-gh-url=https://raw.githubusercontent.com/containers
when: scenario == ffi

execute:
how: tmt

report:
how: junit
183 changes: 183 additions & 0 deletions tests/e2e/set-ffi-env-e2e
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
#!/bin/bash
# shellcheck disable=SC1091
#
# Copyright 2023 The qm Authors
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; If not, see <http://www.gnu.org/licenses/>.
#
# Capture the start time
START_TIME=$(date +%s)
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

source "${SCRIPT_DIR}"/lib/utils
source "${SCRIPT_DIR}"/lib/container
source "${SCRIPT_DIR}"/lib/systemd
source "${SCRIPT_DIR}"/lib/tests

# GLOBALS
export CONFIG_NODE_AGENT_PATH="/etc/bluechi/agent.conf.d/agent.conf"
export REGISTRY_UBI8_MINIMAL="registry.access.redhat.com/ubi8/ubi-minimal"
export WAIT_BLUECHI_SERVER_BE_READY_IN_SEC=5
export CONTROL_CONTAINER_NAME="control"
export NODES_FOR_TESTING=("control" "node1")
export IP_CONTROL_MACHINE=""
export CONTAINER_CAP_ADD=""
export ARCH=""

export BUILD_BLUECHI_FROM_GH_URL=""
export QM_GH_URL=""
export BRANCH_QM=""

if [ -t 1 ]; then
RED='\033[91m'
GRN='\033[92m'
CLR='\033[0m'
fi

# ====================== Start - int main {} ;-)
ARGUMENT_LIST=(
"qm-setup-from-gh-url"
"branch-qm"
)

usage() {
cat <<EOF
Usage: ./set-ffi-env-e2e [OPTIONS]
--help
This message
--qm-setup-from-gh-url
Override QM setup QM from a specific GitHub URL, useful for testing new features
--branch-qm
Specify which branch the GitHub repo will be set. Requires --qm-setup-from-gh-url
Examples:
No args, it will install latest qm and bluechi from copr rpm repository
./set-ffi-env-e2e
Build qm and bluechi from a specific github url and select the branches
./set-ffi-env-e2e \\
--branch-qm=superfeature \\
--qm-setup-from-gh-url=https://raw.githubusercontent.com/MYUSER/ \\
EOF
exit 0
}

# read arguments
opts=$(getopt \
--longoptions "$(printf "help,%s:," "${ARGUMENT_LIST[@]}")" \
--name "$(basename "$0")" \
--options "" \
-- "$@"
)

eval set --"${opts}"

while [ $# -gt 0 ]; do
case "$1" in
--branch-qm)
BRANCH_QM="${2}"
shift 2
;;

--qm-setup-from-gh-url)
if [ -z "${BRANCH_QM}" ]; then
BRANCH_QM="main"
fi
#QM_GH_URL="${2}/qm/${BRANCH_QM}/setup"
shift 2
;;

--help)
usage
;;

*)
break
;;
esac
done

install_qm_rpms() {

info_message "Installing qm setup rpm"
ARCH=$(arch)
dnf update -y
dnf install -y 'dnf-command(config-manager)'
dnf config-manager --set-enabled crb
dnf copr enable -y mperina/hirte-snapshot centos-stream-9-"${ARCH}"
dnf copr enable -y rhcontainerbot/qm centos-stream-9-"${ARCH}"
dnf install -y qm bluechi-ctl bluechi podman hostname
}

setup_qm_services() {

info_message "Setup qm services"
#Update setup script from QM repos, in case rpm not updates yet
if [ -n "${QM_GH_URL}" ]; then
curl "${QM_GH_URL}" > /usr/share/qm/setup
chmod +x /usr/share/qm/setup
fi
/usr/share/qm/setup --hostname localrootfs
systemctl enable bluechi-controller
systemctl enable bluechi-agent
systemctl setup bluechi-agent

}

info_message "Starting setup"
info_message "=============================="
if [ "$EUID" -ne 0 ]
then
echo -e "[${RED} ERROR ${CLR}] Please run as root this script. It requires to set limits inside a container which is not allowed by root."
exit
fi

info_message "Cleaning any previous e2e files"
cleanup

echo
info_message "Preparing QM environment"
info_message "=============================="

# Creates the QM env on VM
install_qm_rpms
setup_qm_services

info_message "${GRN}QM environment${CLR}"
echo

# Capture the end time
END_TIME=$(date +%s)

# Calculate the duration in seconds
DURATION=$((END_TIME - START_TIME))

# Calculate minutes and seconds
DAYS=$((DURATION / 86400))
HOURS=$(( (DURATION % 86400) / 3600 ))
MINUTES=$(( (DURATION % 3600) / 60 ))
SECONDS=$((DURATION % 60))

echo
info_message "${GRN}Running time for this script${CLR}"
info_message "\t- ${DAYS} days, ${HOURS} hours, ${MINUTES} minutes and ${SECONDS} seconds"
echo
info_message "All set!"
echo
1 change: 1 addition & 0 deletions tests/qm-connectivity/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ test:
test:
./test.sh
tier: 1
tag: ffi
environment:
CONTROL_CONTAINER_NAME: "autosd"
NODES_FOR_TESTING_ARR: "localrootfs qm.localrootfs"
Expand Down

0 comments on commit f363914

Please sign in to comment.