Skip to content

Commit

Permalink
E2E: metrics-agent tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cheina97 authored and adamjensenbot committed Nov 13, 2023
1 parent 4fc964f commit cf311ad
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Makefile
Expand Up @@ -215,6 +215,7 @@ E2E_TARGETS = e2e-dir \
installer/liqoctl/peer \
e2e/postinstall \
e2e/cruise \
metrics \
installer/liqoctl/unpeer \
installer/liqoctl/uninstall \
e2e/postuninstall
Expand Down Expand Up @@ -254,5 +255,9 @@ installer/%:
telemetry:
${PWD}/test/e2e/pipeline/telemetry/telemetry.sh

metrics:
chmod +x ${PWD}/test/e2e/pipeline/metrics/metrics.sh
${PWD}/test/e2e/pipeline/metrics/metrics.sh

e2e/%:
go test ${PWD}/test/$@/... -count=1 -timeout=20m
4 changes: 4 additions & 0 deletions test/e2e/pipeline/infra/cluster-api/setup.sh
Expand Up @@ -93,6 +93,10 @@ do
# install local-path storage class
"${KUBECTL}" apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/v0.0.24/deploy/local-path-storage.yaml --kubeconfig "${TMPDIR}/kubeconfigs/liqo_kubeconf_${i}"
"${KUBECTL}" annotate storageclass local-path storageclass.kubernetes.io/is-default-class=true --kubeconfig "${TMPDIR}/kubeconfigs/liqo_kubeconf_${i}"

# Install metrics-server
"${KUBECTL}" apply -f https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.6.4/components.yaml --kubeconfig "${TMPDIR}/kubeconfigs/liqo_kubeconf_${i}"
"${KUBECTL}" -n kube-system patch deployment metrics-server --type json --patch '[{"op":"add","path":"/spec/template/spec/containers/0/args/-","value":"--kubelet-insecure-tls"}]' --kubeconfig "${TMPDIR}/kubeconfigs/liqo_kubeconf_${i}"
done

for i in $(seq 1 "${CLUSTER_NUMBER}");
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/pipeline/installer/liqoctl/peer.sh
Expand Up @@ -44,7 +44,7 @@ do
retries=$((retries + 1))
done
set -e
"${LIQOCTL}" status peer "liqo-${i}" --verbose
"${LIQOCTL}" status peer "cluster-${i}" --verbose
fi
done

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/pipeline/installer/liqoctl/setup.sh
Expand Up @@ -67,7 +67,7 @@ do
# this should avoid the ipam to reserve a pod CIDR of another cluster as local external CIDR causing remapping
export POD_CIDR="10.$((i * 10)).0.0/16"
fi
COMMON_ARGS=(--cluster-name "liqo-${i}" --local-chart-path ./deployments/liqo
COMMON_ARGS=(--cluster-name "cluster-${i}" --local-chart-path ./deployments/liqo
--version "${LIQO_VERSION}" --set controllerManager.config.enableResourceEnforcement=true --set "networking.securityMode=${SECURITY_MODE}")
if [[ "${CLUSTER_LABELS}" != "" ]]; then
COMMON_ARGS=("${COMMON_ARGS[@]}" --cluster-labels "${CLUSTER_LABELS}")
Expand Down
42 changes: 42 additions & 0 deletions test/e2e/pipeline/metrics/metrics.sh
@@ -0,0 +1,42 @@
#!/bin/bash
#shellcheck disable=SC1091

# This scripts expects the following variables to be set:
# CLUSTER_NUMBER -> the number of liqo clusters
# NAMESPACE -> the namespace where liqo is running
# LIQO_VERSION -> the liqo version to test
# K8S_VERSION -> the Kubernetes version
# TMPDIR -> the directory where kubeconfigs are stored

set -e # Fail in case of error
set -o nounset # Fail if undefined variables are used
set -o pipefail # Fail if one of the piped commands fails

error() {
local sourcefile=$1
local lineno=$2
echo "An error occurred at $sourcefile:$lineno."
}
trap 'error "${BASH_SOURCE}" "${LINENO}"' ERR

FILEPATH=$(realpath "$0")
WORKDIR=$(dirname "$FILEPATH")

# shellcheck source=../utils.sh
source "$WORKDIR/../utils.sh"

for i in $(seq 1 "${CLUSTER_NUMBER}")
do
for j in $(seq 1 "${CLUSTER_NUMBER}")
do
if [ "$i" -ne "$j" ]
then
export KUBECONFIG="${TMPDIR}/kubeconfigs/liqo_kubeconf_${i}"
if ! waitandretry 5s 12 "$KUBECTL top node liqo-cluster-${j}";
then
echo "Failed to get metrics from liqo-cluster-${j} in cluster liqo-cluster-${i}"
exit 1
fi
fi
done
done

0 comments on commit cf311ad

Please sign in to comment.