diff --git a/test/scale/label-nodes.sh b/test/scale/label-nodes.sh new file mode 100755 index 0000000000..ec500f677b --- /dev/null +++ b/test/scale/label-nodes.sh @@ -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 diff --git a/test/scale/templates/real-deployment.yaml b/test/scale/templates/real-agnhost-deployment.yaml similarity index 100% rename from test/scale/templates/real-deployment.yaml rename to test/scale/templates/real-agnhost-deployment.yaml diff --git a/test/scale/templates/real-nginx-deployment.yaml b/test/scale/templates/real-nginx-deployment.yaml new file mode 100644 index 0000000000..0bdd413f92 --- /dev/null +++ b/test/scale/templates/real-nginx-deployment.yaml @@ -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 diff --git a/test/scale/test-scale.sh b/test/scale/test-scale.sh index 433264cffb..1a24f7fe7c 100755 --- a/test/scale/test-scale.sh +++ b/test/scale/test-scale.sh @@ -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 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= seconds to sleep after creating everything. Default is 0 @@ -79,6 +80,9 @@ while [[ $# -gt 0 ]]; do --num-real-deployments=*) numRealDeployments="${1#*=}" ;; + --real-pod-type=*) + realPodType="${1#*=}" + ;; --num-real-replicas=*) numRealReplicas="${1#*=}" ;; @@ -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 @@ -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] @@ -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/ @@ -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" @@ -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 @@ -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/