4 SCRIPTDIR="$(readlink -f $(dirname ${BASH_SOURCE[0]}))"
5 LIBDIR="$(dirname $(dirname ${SCRIPTDIR}))/env/lib"
7 source $LIBDIR/logging.sh
8 source $LIBDIR/common.sh
10 BUILDDIR=${SCRIPTDIR/deploy/build}
13 function install_deps {
17 function is_emco_ready {
18 local -r cluster_name=${CLUSTER_NAME:-icn}
19 local -r cluster_kubeconfig="${BUILDDIR}/${cluster_name}.conf"
20 kubectl --kubeconfig=${cluster_kubeconfig} -n emco wait pod --all --for=condition=Ready --timeout=0s >/dev/null 2>&1
23 function register_emco_controllers {
24 wait_for is_emco_ready
25 local -r cluster_name=${CLUSTER_NAME:-icn}
26 local -r host=$(kubectl -n metal3 get cluster/${cluster_name} -o jsonpath='{.spec.controlPlaneEndpoint.host}')
27 cat <<EOF >${BUILDDIR}/${cluster_name}-config.yaml
32 cat <<EOF >${BUILDDIR}/${cluster_name}-controllers.yaml
76 emcoctl --config ${BUILDDIR}/${cluster_name}-config.yaml apply -f ${BUILDDIR}/${cluster_name}-controllers.yaml
79 function unregister_emco_controllers {
80 local -r cluster_name=${CLUSTER_NAME:-icn}
81 emcoctl --config ${BUILDDIR}/${cluster_name}-config.yaml delete -f ${BUILDDIR}/${cluster_name}-controllers.yaml
84 function is_addon_ready {
86 local -r cluster_name=${CLUSTER_NAME:-icn}
87 local -r cluster_kubeconfig="${BUILDDIR}/${cluster_name}.conf"
88 [[ $(kubectl --kubeconfig=${cluster_kubeconfig} -n kud get HelmRelease/${addon} -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}') == "True" ]]
91 function test_addons {
94 # Create a temporary kubeconfig file for the tests
95 local -r cluster_name=${CLUSTER_NAME:-icn}
96 local -r cluster_kubeconfig="${BUILDDIR}/${cluster_name}.conf"
97 clusterctl -n metal3 get kubeconfig ${cluster_name} >${cluster_kubeconfig}
100 pushd ${KUDPATH}/kud/tests
102 container_runtime=$(KUBECONFIG=${cluster_kubeconfig} kubectl get nodes -o jsonpath='{.items[].status.nodeInfo.containerRuntimeVersion}')
103 # TODO Temporarily remove kubevirt from kud_tests below. The
104 # kubevirt self-test needs AllowTcpForwarding yes in
105 # /etc/ssh/sshd_config which is currently disabled by the OS
106 # security hardening.
107 if [[ "${container_runtime}" == "containerd://1.2.13" ]]; then
108 # With containerd 1.2.13, the qat test container image fails to unpack.
109 kud_tests="topology-manager-sriov:sriov-network multus:multus-cni ovn4nfv:ovn4nfv-network nfd:node-feature-discovery sriov-network:sriov-network cmk:cpu-manager"
111 kud_tests="topology-manager-sriov:sriov-network multus:multus-cni ovn4nfv:ovn4nfv-network nfd:node-feature-discovery sriov-network:sriov-network qat:qat-device-plugin cmk:cpu-manager"
113 for kud_test in ${kud_tests}; do
114 addon="${kud_test#*:}"
115 test="${kud_test%:*}"
116 if [[ ! -z ${addon} ]]; then
117 wait_for is_addon_ready ${addon}
119 KUBECONFIG=${cluster_kubeconfig} bash ${test}.sh || failed_kud_tests="${failed_kud_tests} ${test}"
121 # The plugin_fw_v2 test needs the EMCO controllers in place
122 register_emco_controllers
123 DEMO_FOLDER=${KUDPATH}/kud/demo KUBECONFIG=${cluster_kubeconfig} bash plugin_fw_v2.sh --external || failed_kud_tests="${failed_kud_tests} plugin_fw_v2"
124 unregister_emco_controllers
126 if [[ ! -z "$failed_kud_tests" ]]; then
127 echo "Test cases failed:${failed_kud_tests}"
130 echo "All test cases passed"
132 rm ${cluster_kubeconfig}
136 "test") test_addons ;;
138 Usage: $(basename $0) COMMAND
140 The "test" command looks for the CLUSTER_NAME variable in the
141 environment (default: "icn"). This should be the name of the
142 Cluster resource to execute the tests in.
145 test - Test the addons