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 test_addons {
81 # Create a temporary kubeconfig file for the tests
82 local -r cluster_name=${CLUSTER_NAME:-icn}
83 local -r cluster_kubeconfig="${BUILDDIR}/${cluster_name}.conf"
84 clusterctl -n metal3 get kubeconfig ${cluster_name} >${cluster_kubeconfig}
87 pushd ${KUDPATH}/kud/tests
89 container_runtime=$(KUBECONFIG=${cluster_kubeconfig} kubectl get nodes -o jsonpath='{.items[].status.nodeInfo.containerRuntimeVersion}')
90 # TODO Temporarily remove kubevirt from kud_tests below. The
91 # kubevirt self-test needs AllowTcpForwarding yes in
92 # /etc/ssh/sshd_config which is currently disabled by the OS
94 if [[ "${container_runtime}" == "containerd://1.2.13" ]]; then
95 # With containerd 1.2.13, the qat test container image fails to unpack.
96 kud_tests="topology-manager-sriov multus ovn4nfv nfd sriov-network cmk"
98 kud_tests="topology-manager-sriov multus ovn4nfv nfd sriov-network qat cmk"
100 for test in ${kud_tests}; do
101 KUBECONFIG=${cluster_kubeconfig} bash ${test}.sh || failed_kud_tests="${failed_kud_tests} ${test}"
103 # The plugin_fw_v2 test needs the EMCO controllers in place
104 register_emco_controllers
105 DEMO_FOLDER=${KUDPATH}/kud/demo KUBECONFIG=${cluster_kubeconfig} bash plugin_fw_v2.sh --external || failed_kud_tests="${failed_kud_tests} plugin_fw_v2"
106 unregister_emco_controllers
108 if [[ ! -z "$failed_kud_tests" ]]; then
109 echo "Test cases failed:${failed_kud_tests}"
112 echo "All test cases passed"
114 rm ${cluster_kubeconfig}
118 "test") test_addons ;;
120 Usage: $(basename $0) COMMAND
122 The "test" command looks for the CLUSTER_NAME variable in the
123 environment (default: "icn"). This should be the name of the
124 Cluster resource to execute the tests in.
127 test - Test the addons