build/
.vagrant/
deploy/kata/logs/
+deploy/addons/logs/
--- /dev/null
+#!/usr/bin/env bash
+set -eux -o pipefail
+
+SCRIPTDIR="$(readlink -f $(dirname ${BASH_SOURCE[0]}))"
+LIBDIR="$(dirname $(dirname ${SCRIPTDIR}))/env/lib"
+
+source $LIBDIR/logging.sh
+source $LIBDIR/common.sh
+
+BUILDDIR=${SCRIPTDIR/deploy/build}
+mkdir -p ${BUILDDIR}
+
+function register_emco_controllers {
+ local -r cluster_name=${CLUSTER_NAME:-e2etest}
+ local -r host=$(kubectl -n metal3 get cluster/${cluster_name} -o jsonpath='{.spec.controlPlaneEndpoint.host}')
+ cat <<EOF >${BUILDDIR}/${cluster_name}-config.yaml
+orchestrator:
+ host: ${host}
+ port: 30415
+EOF
+ cat <<EOF >${BUILDDIR}/${cluster_name}-controllers.yaml
+---
+version: emco/v2
+resourceContext:
+ anchor: controllers
+metadata:
+ name: rsync
+spec:
+ host: ${host}
+ port: 30441
+---
+version: emco/v2
+resourceContext:
+ anchor: controllers
+metadata:
+ name: gac
+spec:
+ host: ${host}
+ port: 30493
+ type: "action"
+ priority: 1
+---
+version: emco/v2
+resourceContext:
+ anchor: controllers
+metadata:
+ name: ovnaction
+spec:
+ host: ${host}
+ port: 30473
+ type: "action"
+ priority: 1
+---
+version: emco/v2
+resourceContext:
+ anchor: controllers
+metadata:
+ name: dtc
+spec:
+ host: ${host}
+ port: 30483
+ type: "action"
+ priority: 1
+EOF
+ emcoctl --config ${BUILDDIR}/${cluster_name}-config.yaml apply -f ${BUILDDIR}/${cluster_name}-controllers.yaml
+}
+
+function unregister_emco_controllers {
+ local -r cluster_name=${CLUSTER_NAME:-e2etest}
+ emcoctl --config ${BUILDDIR}/${cluster_name}-config.yaml delete -f ${BUILDDIR}/${cluster_name}-controllers.yaml
+}
+
+function test_addons {
+ # Create a temporary kubeconfig file for the tests
+ local -r cluster_name=${CLUSTER_NAME:-e2etest}
+ local -r cluster_kubeconfig="${BUILDDIR}/${cluster_name}.conf"
+ clusterctl -n metal3 get kubeconfig ${cluster_name} >${cluster_kubeconfig}
+
+ clone_kud_repository
+ pushd ${KUDPATH}/kud/tests
+ failed_kud_tests=""
+ container_runtime=$(KUBECONFIG=${cluster_kubeconfig} kubectl get nodes -o jsonpath='{.items[].status.nodeInfo.containerRuntimeVersion}')
+ if [[ "${container_runtime}" == "containerd://1.2.13" ]]; then
+ # With containerd 1.2.13, the qat test container image fails to unpack.
+ kud_tests="topology-manager-sriov kubevirt multus ovn4nfv nfd sriov-network cmk"
+ else
+ kud_tests="topology-manager-sriov kubevirt multus ovn4nfv nfd sriov-network qat cmk"
+ fi
+ for test in ${kud_tests}; do
+ KUBECONFIG=${cluster_kubeconfig} bash ${test}.sh || failed_kud_tests="${failed_kud_tests} ${test}"
+ done
+ # The plugin_fw_v2 test needs the EMCO controllers in place
+ register_emco_controllers
+ DEMO_FOLDER=${KUDPATH}/kud/demo KUBECONFIG=${cluster_kubeconfig} bash plugin_fw_v2.sh --external || failed_kud_tests="${failed_kud_tests} plugin_fw_v2"
+ unregister_emco_controllers
+ popd
+ if [[ ! -z "$failed_kud_tests" ]]; then
+ echo "Test cases failed:${failed_kud_tests}"
+ exit 1
+ fi
+ echo "All test cases passed"
+
+ rm ${cluster_kubeconfig}
+}
+
+case $1 in
+ "test") test_addons ;;
+ *) cat <<EOF
+Usage: $(basename $0) COMMAND
+
+The "test" command looks for the CLUSTER_NAME variable in the
+environment (default: "e2etest"). This should be the name of the
+Cluster resource to execute the tests in.
+
+Commands:
+ test - Test the addons
+EOF
+ ;;
+esac
source $LIBDIR/logging.sh
source $LIBDIR/common.sh
+BUILDDIR=${SCRIPTDIR/deploy/build}
+mkdir -p ${BUILDDIR}
+
KATA_VERSION="2.1.0-rc0"
KATA_WEBHOOK_VERSION="2.1.0-rc0"
pushd ${SCRIPTDIR}/base && kustomize create --autodetect && popd
}
+function deploy_webhook {
+ local -r cluster_name=$1
+ local -r cluster_kubeconfig="${BUILDDIR}/${cluster_name}.conf"
+
+ # Note that the webhook-registration.yaml.tpl file is fetched here
+ # but webhook-registration.yaml is deployed: this is intentional,
+ # create-certs.sh takes care of converting the .yaml.tpl into the
+ # .yaml file
+ mkdir -p ${BUILDDIR}/webhook/base/deploy
+ curl -sL ${KATA_WEBHOOK_URL}/create-certs.sh -o ${BUILDDIR}/webhook/base/create-certs.sh
+ curl -sL ${KATA_WEBHOOK_URL}/deploy/webhook-registration.yaml.tpl -o ${BUILDDIR}/webhook/base/deploy/webhook-registration.yaml.tpl
+ curl -sL ${KATA_WEBHOOK_URL}/deploy/webhook.yaml -o ${BUILDDIR}/webhook/base/deploy/webhook.yaml
+
+ chmod +x ${BUILDDIR}/webhook/base/create-certs.sh
+ sed 's/value: kata/value: ${KATA_WEBHOOK_RUNTIMECLASS}/g' ${BUILDDIR}/webhook/base/deploy/webhook.yaml | tee ${BUILDDIR}/webhook/base/deploy/webhook-${KATA_WEBHOOK_RUNTIMECLASS}.yaml
+ pushd ${BUILDDIR}/webhook/base && ./create-certs.sh && popd
+
+ cat <<EOF >${BUILDDIR}/webhook/base/kustomization.yaml
+apiVersion: kustomize.config.k8s.io/v1beta1
+kind: Kustomization
+resources:
+- deploy/webhook-certs.yaml
+- deploy/webhook-registration.yaml
+- deploy/webhook-${KATA_WEBHOOK_RUNTIMECLASS}.yaml
+EOF
+
+ kustomize build ${BUILDDIR}/webhook/base | KUBECONFIG=${cluster_kubeconfig} kubectl apply -f -
+}
+
+function clean_webhook {
+ local -r cluster_name=$1
+ local -r cluster_kubeconfig="${BUILDDIR}/${cluster_name}.conf"
+
+ kustomize build ${BUILDDIR}/webhook/base | KUBECONFIG=${cluster_kubeconfig} kubectl delete -f -
+}
+
+function test_kata {
+ # Create a temporary kubeconfig file for the tests
+ local -r cluster_name=${CLUSTER_NAME:-e2etest}
+ local -r cluster_kubeconfig="${BUILDDIR}/${cluster_name}.conf"
+ clusterctl -n metal3 get kubeconfig ${cluster_name} >${cluster_kubeconfig}
+
+ deploy_webhook ${cluster_name}
+ clone_kud_repository
+ pushd ${KUDPATH}/kud/tests
+ failed_kud_tests=""
+ KUBECONFIG=${cluster_kubeconfig} bash kata.sh || failed_kud_tests="${failed_kud_tests} ${test}"
+ popd
+ clean_webhook ${cluster_name}
+ if [[ ! -z "$failed_kud_tests" ]]; then
+ echo "Test cases failed:${failed_kud_tests}"
+ exit 1
+ fi
+ echo "All test cases passed"
+
+ rm ${cluster_kubeconfig}
+}
+
case $1 in
"build-source") build_source ;;
+ "test") test_kata ;;
*) cat <<EOF
Usage: $(basename $0) COMMAND
+The "test" command looks for the CLUSTER_NAME variable in the
+environment (default: "e2etest"). This should be the name of the
+Cluster resource to execute the tests in.
+
Commands:
build-source - Rebuild the in-tree Kata YAML files
+ test - Test Kata
EOF
;;
esac
export KUBESPRAY_VERSION=2.16.0
function get_kud_repo {
- if [ -d $DOWNLOAD_PATH/multicloud-k8s ]; then
- rm -rf $DOWNLOAD_PATH/multicloud-k8s
- fi
-
- mkdir -p $DOWNLOAD_PATH
- pushd $DOWNLOAD_PATH
+ clone_kud_repository
if [ "$1" == "v1" ] ; then
export KUD_ADDONS=multus
- git clone https://github.com/onap/multicloud-k8s.git
- else
- git clone https://github.com/onap/multicloud-k8s.git
fi
- popd
}
function set_ssh_key {
}
function set_bm_kud {
- pushd $DOWNLOAD_PATH/multicloud-k8s/kud/hosting_providers/vagrant/inventory
+ pushd ${KUDPATH}/kud/hosting_providers/vagrant/inventory
HOST_IP=${HOST_IP:-$(hostname -I | cut -d ' ' -f 1)}
if [ "$1" == "minimal" ] ; then
cat <<EOL > hosts.ini
}
function kud_install {
- pushd $DOWNLOAD_PATH/multicloud-k8s/kud/hosting_providers/vagrant/
+ pushd ${KUDPATH}/kud/hosting_providers/vagrant/
if [ "$1" == "all" ]; then
sed -i -e 's/testing_enabled=${KUD_ENABLE_TESTS:-false}/testing_enabled=${KUD_ENABLE_TESTS:-true}/g' installer.sh
fi
if [ "$1" == "bm" ]; then
for addon in ${KUD_ADDONS:-multus ovn4nfv nfd sriov qat cmk optane}; do
- pushd $DOWNLOAD_PATH/multicloud-k8s/kud/tests/
+ pushd ${KUDPATH}/kud/tests/
bash ${addon}.sh
popd
done
}
function kud_reset {
- pushd $DOWNLOAD_PATH/multicloud-k8s/kud/hosting_providers/vagrant/
+ pushd ${KUDPATH}/kud/hosting_providers/vagrant/
ansible-playbook -i inventory/hosts.ini /opt/kubespray-${KUBESPRAY_VERSION}/reset.yml \
--become --become-user=root -e reset_confirmation=yes
popd
+++ /dev/null
-#!/usr/bin/env bash
-set -eu -o pipefail
-
-LIBDIR="$(dirname "$(dirname "$PWD")")"
-
-source $LIBDIR/env/lib/common.sh
-
-if [ ! -d $DOWNLOAD_PATH/multicloud-k8s ]; then
- pushd $DOWNLOAD_PATH
- git clone https://github.com/onap/multicloud-k8s.git
- popd
-fi
#!/usr/bin/env bash
set -eu -o pipefail
-DOWNLOAD_PATH=${DOWNLOAD_PATH:-/opt/icn}
-
IRONIC_DATA_DIR=${IRONIC_DATA_DIR:-"/opt/ironic"}
#IRONIC_PROVISIONING_INTERFACE is required to be provisioning, don't change it
IRONIC_INTERFACE=${IRONIC_INTERFACE:-}
BMOPATH="/opt/src/github.com/metal3-io/baremetal-operator"
#Bare Metal Operator version to use
BMO_VERSION="capm3-v0.5.1"
-#Discard existing baremetal operator repo directory
+
+#KuD repository URL
+KUDREPO="${KUDREPO:-https://github.com/onap/multicloud-k8s.git}"
+#Path to clone the KuD repo
+KUDPATH="/opt/src/github.com/onap/multicloud-k8s"
+#KuD version to use
+KUD_VERSION="ed96bca7fe415f1636d82c26af15d7474bdfe876"
+
+#EMCO repository URL
+EMCOREPO="${EMCOREPO:-https://github.com/open-ness/EMCO.git}"
+#Path to clone the EMCO repo
+EMCOPATH="/opt/src/github.com/open-ness/EMCO"
+#EMCO version to use
+EMCO_VERSION="openness-21.03.06"
+
+#Discard existing repo directory
FORCE_REPO_UPDATE="${FORCE_REPO_UPDATE:-true}"
# The kustomize version to use
done
}
-function clone_baremetal_operator_repository {
- mkdir -p $(dirname ${BMOPATH})
- if [[ -d ${BMOPATH} && "${FORCE_REPO_UPDATE}" == "true" ]]; then
- rm -rf "${BMOPATH}"
+function clone_repository {
+ local -r path=$1
+ local -r repo=$2
+ local -r version=$3
+ mkdir -p $(dirname ${path})
+ if [[ -d ${path} && "${FORCE_REPO_UPDATE}" == "true" ]]; then
+ rm -rf "${path}"
fi
- if [ ! -d "${BMOPATH}" ] ; then
- pushd $(dirname ${BMOPATH})
- git clone "${BMOREPO}"
+ if [ ! -d "${path}" ] ; then
+ pushd $(dirname ${path})
+ git clone "${repo}"
popd
else
- pushd "${BMOPATH}"
+ pushd "${path}"
git fetch
popd
fi
- pushd "${BMOPATH}"
- git reset --hard "${BMO_VERSION}"
+ pushd "${path}"
+ git reset --hard "${version}"
popd
}
+function clone_baremetal_operator_repository {
+ clone_repository ${BMOPATH} ${BMOREPO} ${BMO_VERSION}
+}
+
+function clone_kud_repository {
+ clone_repository ${KUDPATH} ${KUDREPO} ${KUD_VERSION}
+}
+
+function clone_emco_repository {
+ clone_repository ${EMCOPATH} ${EMCOREPO} ${EMCO_VERSION}
+}
+
function install_kustomize {
curl -sL "https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2F${KUSTOMIZE_VERSION}/kustomize_${KUSTOMIZE_VERSION}_linux_amd64.tar.gz" -o kustomize_${KUSTOMIZE_VERSION}_linux_amd64.tar.gz
tar xzf kustomize_${KUSTOMIZE_VERSION}_linux_amd64.tar.gz --no-same-owner
flux --version
}
+function install_emcoctl {
+ clone_emco_repository
+ make -C ${EMCOPATH}/src/tools/emcoctl
+ sudo install -o root -g root -m 0755 ${EMCOPATH}/bin/emcoctl/emcoctl /usr/local/bin/emcoctl
+}
+
function fetch_image {
if [[ "${BM_IMAGE_URL}" && "${BM_IMAGE}" ]]; then
mkdir -p "${IRONIC_DATA_DIR}/html/images"
install_kustomize
install_clusterctl
install_flux_cli
+ install_emcoctl
}
install