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 is_emco_ready {
14 local -r cluster_name=${CLUSTER_NAME:-icn}
15 local -r cluster_kubeconfig="${BUILDDIR}/${cluster_name}.conf"
16 kubectl --kubeconfig=${cluster_kubeconfig} -n emco wait pod --all --for=condition=Ready --timeout=0s >/dev/null 2>&1
19 function register_emco_controllers {
20 wait_for is_emco_ready
21 local -r cluster_name=${CLUSTER_NAME:-icn}
22 local -r host=$(kubectl -n metal3 get cluster/${cluster_name} -o jsonpath='{.spec.controlPlaneEndpoint.host}')
23 cat <<EOF >${BUILDDIR}/${cluster_name}-config.yaml
28 cat <<EOF >${BUILDDIR}/${cluster_name}-controllers.yaml
72 emcoctl --config ${BUILDDIR}/${cluster_name}-config.yaml apply -f ${BUILDDIR}/${cluster_name}-controllers.yaml
75 function unregister_emco_controllers {
76 local -r cluster_name=${CLUSTER_NAME:-icn}
77 emcoctl --config ${BUILDDIR}/${cluster_name}-config.yaml delete -f ${BUILDDIR}/${cluster_name}-controllers.yaml
80 function is_addon_ready {
82 local -r cluster_name=${CLUSTER_NAME:-icn}
83 local -r cluster_kubeconfig="${BUILDDIR}/${cluster_name}.conf"
84 [[ $(kubectl --kubeconfig=${cluster_kubeconfig} -n kud get HelmRelease/${addon} -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}') == "True" ]]
87 function test_addons {
88 # Create a temporary kubeconfig file for the tests
89 local -r cluster_name=${CLUSTER_NAME:-icn}
90 local -r cluster_kubeconfig="${BUILDDIR}/${cluster_name}.conf"
91 clusterctl -n metal3 get kubeconfig ${cluster_name} >${cluster_kubeconfig}
94 pushd ${KUDPATH}/kud/tests
96 container_runtime=$(KUBECONFIG=${cluster_kubeconfig} kubectl get nodes -o jsonpath='{.items[].status.nodeInfo.containerRuntimeVersion}')
97 # TODO Temporarily remove kubevirt from kud_tests below. The
98 # kubevirt self-test needs AllowTcpForwarding yes in
99 # /etc/ssh/sshd_config which is currently disabled by the OS
100 # security hardening.
101 if [[ "${container_runtime}" == "containerd://1.2.13" ]]; then
102 # With containerd 1.2.13, the qat test container image fails to unpack.
103 kud_tests="topology-manager-sriov:sriov-network multus:multus-cni ovn4nfv:ovn4nfv-network nfd:node-feature-discovery sriov-network:sriov-network cmk:cpu-manager"
105 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"
107 for kud_test in ${kud_tests}; do
108 addon="${kud_test#*:}"
109 test="${kud_test%:*}"
110 if [[ ! -z ${addon} ]]; then
111 wait_for is_addon_ready ${addon}
113 KUBECONFIG=${cluster_kubeconfig} bash ${test}.sh || failed_kud_tests="${failed_kud_tests} ${test}"
115 # The plugin_fw_v2 test needs the EMCO controllers in place
116 register_emco_controllers
117 DEMO_FOLDER=${KUDPATH}/kud/demo KUBECONFIG=${cluster_kubeconfig} bash plugin_fw_v2.sh --external || failed_kud_tests="${failed_kud_tests} plugin_fw_v2"
118 unregister_emco_controllers
120 if [[ ! -z "$failed_kud_tests" ]]; then
121 echo "Test cases failed:${failed_kud_tests}"
124 echo "All test cases passed"
126 rm ${cluster_kubeconfig}
130 "test") test_addons ;;
132 Usage: $(basename $0) COMMAND
134 The "test" command looks for the CLUSTER_NAME variable in the
135 environment (default: "icn"). This should be the name of the
136 Cluster resource to execute the tests in.
139 test - Test the addons