Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions test/scale/label-nodes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh
cmd=$1
retries=0
while [ $retries -lt 5 ]; do
$cmd
if [ $? -eq 0 ]; then
break
fi
retries=$((retries+1))
sleep 5s
done

if [ $retries -eq 5 ]; then
echo "Error in executing $cmd"
exit 1
fi

for node in $(kubectl get nodes -o name);
do
echo "Current : $node"
node_name="${node##*/}"
echo "Apply label to the node"
kubectl label node $node_name connectivity-test=true
kubectl label node $node_name scale-test=true
if [ $? -eq 0 ]; then
echo "Label applied to the node"
else
echo "Error in applying label to the node $node_name"
fi
sleep 2s
done
30 changes: 30 additions & 0 deletions test/scale/templates/real-nginx-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: TEMP_NAME
namespace: scale-test
labels:
app: scale-test
is-real: "true"
name: TEMP_NAME
spec:
replicas: TEMP_REPLICAS
selector:
matchLabels:
app: scale-test
is-real: "true"OTHER_LABELS_6_SPACES
template:
metadata:
labels:
app: scale-test
name: TEMP_NAME
is-real: "true"OTHER_LABELS_8_SPACES
spec:
nodeSelector:
scale-test: "true"
containers:
- name: nginx
image: nginx:1
ports:
- name: http
containerPort: 80
21 changes: 15 additions & 6 deletions test/scale/test-scale.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ OPTIONAL PARAMETERS:
--debug-exit-after-print-counts skip scale test. Just print out counts of things to be created and counts of IPSets/ACLs that NPM would create
--num-real-services cluster ip service for the real deployments scheduled. Each svc will point to the respective deployment(having <num-real-replicas> pods) Default is 0
--debug-exit-after-generation skip scale test. Exit after generating templates
--real-pod-type select deployment type. Options are agnhost or nginx. Default is agnhost

OPTIONAL PARAMETERS TO TEST DELETION:
--sleep-after-creation=<int> seconds to sleep after creating everything. Default is 0
Expand Down Expand Up @@ -79,6 +80,9 @@ while [[ $# -gt 0 ]]; do
--num-real-deployments=*)
numRealDeployments="${1#*=}"
;;
--real-pod-type=*)
realPodType="${1#*=}"
;;
--num-real-replicas=*)
numRealReplicas="${1#*=}"
;;
Expand Down Expand Up @@ -180,6 +184,9 @@ fi
if [[ -z $KUBECTL ]]; then
KUBECTL="kubectl"
fi
if [[ -z $realPodType ]]; then
realPodType="agnhost"
fi
if [[ -z $numRealServices ]]; then numRealServices=0; fi
if [[ -z $deletePodsInterval ]]; then deletePodsInterval=60; fi
if [[ -z $deletePodsTimes ]]; then deletePodsTimes=1; fi
Expand Down Expand Up @@ -213,7 +220,7 @@ if [[ $numRealPods -gt 0 ]]; then
extraIPSets=$(( $extraIPSets + 2 ))
fi
if [[ $numRealServices -gt 0 ]]; then
extraIPSets=$(( $extraIPSets + $numRealDeployments ))
extraIPSets=$(( $extraIPSets + $numRealDeployments))
fi
numIPSetsAddedByNPM=$(( 4 + 2*$numTotalPods*$numUniqueLabelsPerPod + 2*$numSharedLabelsPerPod + 2*($numKwokDeployments+$numRealDeployments)*$numUniqueLabelsPerDeployment + $extraIPSets ))
# 3 basic members are [all-ns,kubernetes.io/metadata.name,kubernetes.io/metadata.name:scale-test]
Expand Down Expand Up @@ -292,7 +299,7 @@ test -d generated && rm -rf generated/
mkdir -p generated/networkpolicies/applied
mkdir -p generated/networkpolicies/unapplied
mkdir -p generated/kwok-nodes
mkdir -p generated/deployments/real/
mkdir -p generated/deployments/real-$realPodType/
mkdir -p generated/deployments/kwok/
mkdir -p generated/services/real/

Expand All @@ -301,6 +308,7 @@ generateDeployments() {
local numReplicas=$2
local depKind=$3


for i in $(seq -f "%05g" 1 $numDeployments); do
name="$depKind-dep-$i"
labelPrefix="$depKind-dep-lab-$i"
Expand Down Expand Up @@ -332,21 +340,22 @@ generateServices() {
local numServices=$1
local numDeployments=$2
local serviceKind=$3
local depKind=$4

for i in $(seq -f "%05g" 1 $numServices); do
name="$serviceKind-svc-$i"
outFile=generated/services/$serviceKind/$name.yaml

sed "s/TEMP_NAME/$name/g" templates/$serviceKind-service.yaml > $outFile
sed -i "s/TEMP_DEPLOYMENT_NAME/$serviceKind-dep-$i/g" $outFile
sed -i "s/TEMP_DEPLOYMENT_NAME/$serviceKind-$depKind-dep-$i/g" $outFile
done
}

echo "Generating yamls..."

generateDeployments $numKwokDeployments $numKwokReplicas kwok
generateDeployments $numRealDeployments $numRealReplicas real
generateServices $numRealServices $numRealDeployments real
generateDeployments $numRealDeployments $numRealReplicas real-$realPodType
generateServices $numRealServices $numRealDeployments real $realPodType

for j in $(seq 1 $numNetworkPolicies); do
valNum=$j
Expand Down Expand Up @@ -439,7 +448,7 @@ if [[ $numKwokNodes -gt 0 ]]; then
$KUBECTL $KUBECONFIG_ARG apply -f generated/kwok-nodes/
fi
if [[ $numRealPods -gt 0 ]]; then
$KUBECTL $KUBECONFIG_ARG apply -f generated/deployments/real/
$KUBECTL $KUBECONFIG_ARG apply -f generated/deployments/real-$realPodType/
fi
if [[ $numKwokPods -gt 0 ]]; then
$KUBECTL $KUBECONFIG_ARG apply -f generated/deployments/kwok/
Expand Down