Skip to content

Commit

Permalink
E2E: metrics-agent tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cheina97 committed Nov 9, 2023
1 parent 6bae562 commit b1878d9
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
"${KUBECTL}" -n kube-system patch deployment metrics-server --type json --patch '[{"op":"add","path":"/spec/template/spec/containers/0/args/-","value":"--kubelet-insecure-tls"}]'
done

for i in $(seq 1 "${CLUSTER_NUMBER}");
Expand Down
36 changes: 36 additions & 0 deletions test/e2e/pipeline/metrics/metrics.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/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
export KUBECONFIG="${TMPDIR}/kubeconfigs/liqo_kubeconf_${i}"
if ! waitandretry 5s 12 "$KUBECTL top node liqo-${i}";
then
echo "Failed to get metrics from cluster ${i}"
exit 1
fi
done

0 comments on commit b1878d9

Please sign in to comment.