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 register_emco_controllers {
14 local -r cluster_name=${CLUSTER_NAME:-e2etest}
15 local -r host=$(kubectl -n metal3 get cluster/${cluster_name} -o jsonpath='{.spec.controlPlaneEndpoint.host}')
16 cat <<EOF >${BUILDDIR}/${cluster_name}-config.yaml
21 cat <<EOF >${BUILDDIR}/${cluster_name}-controllers.yaml
65 emcoctl --config ${BUILDDIR}/${cluster_name}-config.yaml apply -f ${BUILDDIR}/${cluster_name}-controllers.yaml
68 function unregister_emco_controllers {
69 local -r cluster_name=${CLUSTER_NAME:-e2etest}
70 emcoctl --config ${BUILDDIR}/${cluster_name}-config.yaml delete -f ${BUILDDIR}/${cluster_name}-controllers.yaml
73 function test_addons {
74 # Create a temporary kubeconfig file for the tests
75 local -r cluster_name=${CLUSTER_NAME:-e2etest}
76 local -r cluster_kubeconfig="${BUILDDIR}/${cluster_name}.conf"
77 clusterctl -n metal3 get kubeconfig ${cluster_name} >${cluster_kubeconfig}
80 pushd ${KUDPATH}/kud/tests
82 container_runtime=$(KUBECONFIG=${cluster_kubeconfig} kubectl get nodes -o jsonpath='{.items[].status.nodeInfo.containerRuntimeVersion}')
83 if [[ "${container_runtime}" == "containerd://1.2.13" ]]; then
84 # With containerd 1.2.13, the qat test container image fails to unpack.
85 kud_tests="topology-manager-sriov kubevirt multus ovn4nfv nfd sriov-network cmk"
87 kud_tests="topology-manager-sriov kubevirt multus ovn4nfv nfd sriov-network qat cmk"
89 for test in ${kud_tests}; do
90 KUBECONFIG=${cluster_kubeconfig} bash ${test}.sh || failed_kud_tests="${failed_kud_tests} ${test}"
92 # The plugin_fw_v2 test needs the EMCO controllers in place
93 register_emco_controllers
94 DEMO_FOLDER=${KUDPATH}/kud/demo KUBECONFIG=${cluster_kubeconfig} bash plugin_fw_v2.sh --external || failed_kud_tests="${failed_kud_tests} plugin_fw_v2"
95 unregister_emco_controllers
97 if [[ ! -z "$failed_kud_tests" ]]; then
98 echo "Test cases failed:${failed_kud_tests}"
101 echo "All test cases passed"
103 rm ${cluster_kubeconfig}
107 "test") test_addons ;;
109 Usage: $(basename $0) COMMAND
111 The "test" command looks for the CLUSTER_NAME variable in the
112 environment (default: "e2etest"). This should be the name of the
113 Cluster resource to execute the tests in.
116 test - Test the addons