tests/e2e: add memory limit test
This commit is contained in:
parent
3aefb6d428
commit
ad9a128703
@ -10,6 +10,7 @@ k3d
|
||||
cluster [CLUSTERNAME] # default cluster name is 'k3s-default'
|
||||
create
|
||||
-a, --agents # specify how many agent nodes you want to create (integer, default: 0)
|
||||
--agents-memory # specify memory limit for agent containers/nodes (unit, e.g. 1g)
|
||||
--api-port # specify the port on which the cluster will be accessible (format '[HOST:]HOSTPORT', default: random)
|
||||
-c, --config # use a config file (format 'PATH')
|
||||
-e, --env # add environment variables to the nodes (quoted string, format: 'KEY[=VALUE][@NODEFILTER[;NODEFILTER...]]', use flag multiple times)
|
||||
@ -29,6 +30,7 @@ k3d
|
||||
--registry-create # create a new (docker) registry dedicated for this cluster (default: false)
|
||||
--registry-use # use an existing local (docker) registry with this cluster (string, use multiple times)
|
||||
-s, --servers # specify how many server nodes you want to create (integer, default: 1)
|
||||
--servers-memory # specify memory limit for server containers/nodes (unit, e.g. 1g)
|
||||
--token # specify a cluster token (string, default: auto-generated)
|
||||
--timeout # specify a timeout, after which the cluster creation will be interrupted and changes rolled back (duration, e.g. '10s')
|
||||
-v, --volume # specify additional bind-mounts (format: '[SOURCE:]DEST[@NODEFILTER[;NODEFILTER...]]', use flag multiple times)
|
||||
|
||||
42
tests/test_memory_limits.sh
Executable file
42
tests/test_memory_limits.sh
Executable file
@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
|
||||
CURR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
[ -d "$CURR_DIR" ] || { echo "FATAL: no current dir (maybe running in zsh?)"; exit 1; }
|
||||
|
||||
# shellcheck source=./common.sh
|
||||
source "$CURR_DIR/common.sh"
|
||||
|
||||
export CURRENT_STAGE="Test | MemoryLimits"
|
||||
|
||||
highlight "[START] MemoryLimitTest $EXTRA_TITLE"
|
||||
|
||||
clustername="memlimittest"
|
||||
|
||||
info "Creating cluster $clustername..."
|
||||
$EXE cluster create $clustername --servers-memory 1g --agents 1 --agents-memory 1.5g || failed "could not create cluster $clustername"
|
||||
|
||||
info "Checking we have access to the cluster..."
|
||||
check_clusters "$clustername" || failed "error checking cluster"
|
||||
|
||||
info "Checking Memory Limits (docker)..."
|
||||
if [[ $(docker inspect k3d-$clustername-server-0 | jq '.[0].HostConfig.Memory') != "1073741824" ]]; then
|
||||
fail "Server Memory not set to 1g as expected (docker)"
|
||||
fi
|
||||
if [[ $(docker inspect k3d-$clustername-agent-0 | jq '.[0].HostConfig.Memory') != "1610612736" ]]; then
|
||||
fail "Agent Memory not set to 1.5g as expected (docker)"
|
||||
fi
|
||||
|
||||
info "Checking Memory Limits (Kubernetes)..."
|
||||
if [[ $(kubectl get node k3d-$clustername-server-0 -o go-template='{{ .status.capacity.memory }}') != "1073741Ki" ]]; then
|
||||
fail "Server Memory not set to 1g as expected (k8s)"
|
||||
fi
|
||||
if [[ $(kubectl get node k3d-$clustername-agent-0 -o go-template='{{ .status.capacity.memory }}') != "1610612Ki" ]]; then
|
||||
fail "Agent Memory not set to 1.5g as expected (k8s)"
|
||||
fi
|
||||
|
||||
info "Deleting clusters..."
|
||||
$EXE cluster delete $clustername || failed "could not delete the cluster $clustername"
|
||||
|
||||
exit 0
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user