diff --git a/automation/components-functests.setup.sh b/automation/components-functests.setup.sh index ff781d76c..14a0a162e 100644 --- a/automation/components-functests.setup.sh +++ b/automation/components-functests.setup.sh @@ -21,20 +21,27 @@ source hack/components/git-utils.sh source hack/components/yaml-utils.sh source cluster/cluster.sh -# Spin up Kubernetes cluster -export KUBEVIRT_MEMORY_SIZE=9216M -make cluster-down cluster-up +USE_KUBEVIRTCI=${USE_KUBEVIRTCI:-"true"} # Export .kubeconfig full path, so it will be possible # to use 'kubectl' directly from the component directory path -export KUBECONFIG=$(cluster::kubeconfig) +export KUBECONFIG=${KUBECONFIG:-$(cluster::kubeconfig)} -# Deploy CNAO latest changes -make cluster-operator-push -make cluster-operator-install +function deploy_cluster { + # Spin up Kubernetes cluster + export KUBEVIRT_MEMORY_SIZE=9216M + make cluster-down cluster-up +} -# Test kubemacpool with restricted -if [ "$COMPONENT" == "kubemacpool" ]; then +function deploy_cnao { + # Deploy CNAO latest changes + make cluster-operator-push + make cluster-operator-install +} + +function patch_restricted_namespace { + # Test kubemacpool with restricted + if [ "$COMPONENT" == "kubemacpool" ]; then cluster/kubectl.sh apply -f - < cr.yaml apiVersion: networkaddonsoperator.network.kubevirt.io/v1 kind: NetworkAddonsConfig metadata: name: cluster spec: - multus: {} - multusDynamicNetworks: {} linuxBridge: {} kubeMacPool: rangeStart: "02:00:00:00:00:00" @@ -65,11 +73,19 @@ spec: imagePullPolicy: Always EOF -if [[ ! $(cluster/kubectl.sh wait networkaddonsconfig cluster --for condition=Available --timeout=13m) ]]; then - echo "Failed to wait for CNAO CR to be ready" - cluster/kubectl.sh get networkaddonsconfig -o custom-columns="":.status.conditions[*].message - exit 1 -fi + if [[ $USE_KUBEVIRTCI == true ]]; then + echo " multus: {}" >> cr.yaml + echo " multusDynamicNetworks: {}" >> cr.yaml + fi + + cluster/kubectl.sh apply -f cr.yaml + + if [[ ! $(cluster/kubectl.sh wait networkaddonsconfig cluster --for condition=Available --timeout=13m) ]]; then + echo "Failed to wait for CNAO CR to be ready" + cluster/kubectl.sh get networkaddonsconfig -o custom-columns="":.status.conditions[*].message + exit 1 + fi +} # Clone component repository component_url=$(yaml-utils::get_component_url ${COMPONENT}) @@ -82,3 +98,10 @@ component_path=${component_temp_dir}/${component_repo} git-utils::fetch_component ${component_path} ${component_url} ${component_commit} export TMP_COMPONENT_PATH=${component_path} + +if [[ $USE_KUBEVIRTCI == true ]]; then + deploy_cluster + deploy_cnao + patch_restricted_namespace + deploy_cnao_cr +fi