-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add functional tests for lightweight informer (#60)
* Functional tests * Update .travis.yml * Pass image tag * Update resourceBudgetTest.sh * Delete kind-hub.config.yaml * Update resourceBudgetTest.sh * Update resourceBudgetTest.sh * Test failure path * Fix test * Update .travis.yml * Fix in travis * Try different path * try to resolve permission denied * Update resourceBudgetTest.sh * Update resourceBudgetTest.sh * Update resourceBudgetTest.sh * Update resourceBudgetTest.sh * Update resourceBudgetTest.sh * Update resourceBudgetTest.sh * cleanup * Test fail path * Update resourceBudgetTest.sh * finalize * Update resourceBudgetTest.sh * Update resourceBudgetTest.sh Co-authored-by: Disaiah Bennett <lavontae.bennett@gmail.com>
- Loading branch information
Showing
5 changed files
with
121 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
#!/bin/bash | ||
|
||
echo " > Running run-e2e-test.sh" | ||
set -e | ||
sh tests/e2e/runTests.sh $1 | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
nodes: | ||
- role: control-plane | ||
extraPortMappings: | ||
- containerPort: 80 | ||
hostPort: 80 | ||
listenAddress: "0.0.0.0" | ||
- containerPort: 443 | ||
hostPort: 443 | ||
listenAddress: "0.0.0.0" | ||
- containerPort: 6443 | ||
hostPort: 32806 | ||
listenAddress: "0.0.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (c) 2020 Red Hat, Inc. | ||
|
||
echo "=== TEST: Memory and CPU budget ===\n" | ||
|
||
CPU_BUDGET=1.00 | ||
MEM_BUDGET=15.00 | ||
if [ $1 ]; then | ||
SEARCH_COLLECTOR_IMAGE=$1 | ||
else | ||
SEARCH_COLLECTOR_IMAGE="search-collector" | ||
fi | ||
KUBECONFIG_PATH=${PWD}/.kubeconfig-kind | ||
|
||
|
||
create_kind_cluster() { | ||
WORKDIR=`pwd` | ||
if [ ! -f /usr/local/bin/kind ]; then | ||
echo "Installing kind from (https://kind.sigs.k8s.io/)." | ||
|
||
# uname returns your operating system name | ||
# uname -- Print operating system name | ||
# -L location, lowercase -o specify output name, uppercase -O Write output to a local file named like the remote file we get | ||
curl -Lo ./kind "https://kind.sigs.k8s.io/dl/v0.7.0/kind-$(uname)-amd64" | ||
chmod +x ./kind | ||
sudo cp ./kind /usr/local/bin/kind | ||
fi | ||
# Delete kind cluster collector-test if it exists | ||
kind delete cluster --name collector-test --quiet || true | ||
|
||
echo "Starting kind cluster: collector-test" | ||
rm -rf $KUBECONFIG_PATH | ||
kind create cluster \ | ||
--kubeconfig $KUBECONFIG_PATH \ | ||
--name collector-test \ | ||
--config ${WORKDIR}/tests/e2e/kind/kind-collector-test.config.yaml \ | ||
--quiet | ||
chmod +r $KUBECONFIG_PATH | ||
} | ||
|
||
run_container() { | ||
docker run \ | ||
-e CLUSTER_NAME="local-cluster" \ | ||
-e DEPLOYED_IN_HUB="true" \ | ||
-e KUBECONFIG=".kubeconfig" \ | ||
-e KUBERNETES_SERVICE_HOST="https://127.0.0.1" \ | ||
-e KUBERNETES_SERVICE_PORT="63481" \ | ||
-v $PWD/sslcert:/sslcert \ | ||
-v $KUBECONFIG_PATH:/.kubeconfig \ | ||
--network="host" \ | ||
--name search-collector \ | ||
${SEARCH_COLLECTOR_IMAGE} & | ||
|
||
echo "Waiting 90s for search-collector container to start." | ||
sleep 90 | ||
OUTPUT=$(docker stats --no-stream --format "{{.MemUsage}} : {{.CPUPerc}}" search-collector) | ||
MEM=$(echo $OUTPUT | awk '{print $1}' | sed 's/[^0-9\.]*//g') | ||
CPU=$(echo $OUTPUT | awk '{print $5}' | sed 's/[^0-9\.]*//g') | ||
|
||
echo "Stopping and removing search-collector container." | ||
docker stop search-collector | ||
docker rm search-collector | ||
rm -rf $KUBECONFIG_PATH | ||
kind delete cluster --name collector-test --quiet | ||
} | ||
|
||
verify_mem_cpu() { | ||
MEM_TEST=$(awk 'BEGIN {print ('$MEM' >= '$MEM_BUDGET')}') | ||
CPU_TEST=$(awk 'BEGIN {print ('$CPU' >= '$CPU_BUDGET')}') | ||
|
||
if [ "$MEM_TEST" -eq 1 ]; then | ||
echo "MEMORY budget exceeded." | ||
echo "\tUsed: $MEM" | ||
echo "\tBudget: $MEM_BUDGET" | ||
fi | ||
if [ "$CPU_TEST" -eq 1 ]; then | ||
echo "CPU budget exceeded." | ||
echo "\tUsed: $CPU" | ||
echo "\tBudget: $CPU_BUDGET" | ||
fi | ||
if [ "$MEM_TEST" -eq 1 ] || [ "$CPU_TEST" -eq 1 ]; then | ||
echo "TEST FAILED." | ||
exit 1 | ||
fi | ||
} | ||
|
||
create_kind_cluster | ||
run_container | ||
verify_mem_cpu | ||
|
||
echo "\nTEST PASSED." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (c) 2020 Red Hat, Inc. | ||
|
||
sh tests/e2e/resourceBudgetTest.sh $1 |