-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[YUNIKORN-2374] Add Performance testing tools #774
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
./output |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,194 @@ | ||
#!/bin/bash | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
RANDOM=0 | ||
OUTPUT_PATH="./output/affinity.yaml" | ||
NUM_PODS=0 | ||
NUM_NODES=0 | ||
OPERATORS=("In" "NotIn") | ||
OPERATORS_STATE=0 | ||
j=0 | ||
|
||
show_help() { | ||
cat << EOF | ||
Invalid option: -$OPTARG | ||
Usage: $0 <pod_count> <node_count> | ||
|
||
Options: | ||
-o, Specifies the location of the output yaml file (default is ./output/affinity.yaml) | ||
|
||
Arguments: | ||
<pod_count> Number of pod to create (required). | ||
<node_count> Number of kwok nodes (required). | ||
EOF | ||
} | ||
|
||
# Process command-line options | ||
while getopts ":o:" opt; do | ||
case $opt in | ||
o) | ||
OUTPUT_PATH=$OPTARG | ||
;; | ||
\?) | ||
show_help | ||
exit 1 | ||
;; | ||
:) | ||
show_help | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
# Shift the processed options out of the command-line arguments | ||
shift $((OPTIND-1)) | ||
|
||
# Check if pod count and node count are provided | ||
if [ $# -ne 2 ]; then | ||
show_help | ||
exit 1 | ||
fi | ||
|
||
NUM_PODS=$1 | ||
NUM_NODES=$2 | ||
|
||
if [ -f "$OUTPUT_PATH" ]; then | ||
# clear origin content in file | ||
echo "" > "$OUTPUT_PATH" | ||
echo "The original content of the file located at $OUTPUT_PATH has been cleared." | ||
else | ||
echo "The file $OUTPUT_PATH does not exist." | ||
mkdir -p "$(dirname "$OUTPUT_PATH")" | ||
touch "$OUTPUT_PATH" | ||
echo "The create $OUTPUT_PATH." | ||
fi | ||
|
||
# create pods assigned with random node affinity | ||
echo "Create $((NUM_PODS/2/2)) pods, each with random node affinity using the required rule." | ||
echo "Create $((NUM_PODS/2/2)) pods, each with random node affinity using the preferred rule." | ||
Comment on lines
+82
to
+83
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I'd just print a single line: |
||
for (( ;j<NUM_PODS/2; j+=2)) | ||
do | ||
operator=${OPERATORS[$OPERATORS_STATE]} | ||
OPERATORS_STATE=$(( (OPERATORS_STATE + 1) % 2 )) | ||
randHost1=$((RANDOM % NUM_NODES)) | ||
randHost2=$((RANDOM % NUM_NODES)) | ||
randHost3=$((RANDOM % NUM_NODES)) | ||
randHost4=$((RANDOM % NUM_NODES)) | ||
Comment on lines
+88
to
+91
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest reproducible testing. Determine a step from the number of nodes.
|
||
cat <<EOF >> "$OUTPUT_PATH" | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: nginx-$j | ||
labels: | ||
applicationId: nginx-$j | ||
spec: | ||
containers: | ||
- name: sleep300 | ||
image: "alpine:latest" | ||
command: ["sleep", "0"] | ||
ports: | ||
- containerPort: 80 | ||
affinity: | ||
nodeAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
nodeSelectorTerms: | ||
- matchExpressions: | ||
- key: kubernetes.io/hostname | ||
operator: $operator | ||
values: | ||
- kwok-node-$randHost1 | ||
- kwok-node-$randHost2 | ||
tolerations: | ||
- key: "kwok.x-k8s.io/node" | ||
operator: "Exists" | ||
effect: "NoSchedule" | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: nginx-$((j+1)) | ||
labels: | ||
applicationId: nginx-$((j+1)) | ||
spec: | ||
containers: | ||
- name: sleep300 | ||
image: "alpine:latest" | ||
command: ["sleep", "0"] | ||
ports: | ||
- containerPort: 80 | ||
affinity: | ||
nodeAffinity: | ||
preferredDuringSchedulingIgnoredDuringExecution: | ||
- weight: 1 | ||
preference: | ||
matchExpressions: | ||
- key: kubernetes.io/hostname | ||
operator: $operator | ||
values: | ||
- kwok-node-$randHost3 | ||
- kwok-node-$randHost4 | ||
tolerations: | ||
- key: "kwok.x-k8s.io/node" | ||
operator: "Exists" | ||
effect: "NoSchedule" | ||
--- | ||
EOF | ||
done | ||
|
||
# create pods assigned with random pod affinity | ||
echo "Create $((NUM_PODS-j)) pods, each with random node affinity using the preferred rule." | ||
for (( ;j<NUM_PODS; j+=1)) | ||
do | ||
operator=${OPERATORS[$OPERATORS_STATE]} | ||
OPERATORS_STATE=$(( (OPERATORS_STATE + 1) % 2 )) | ||
randAppID1=$((RANDOM % NUM_PODS)) | ||
randAppID2=$((RANDOM % NUM_PODS)) | ||
Comment on lines
+159
to
+160
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, try to come up with a deterministic code here. |
||
cat <<EOF >> "$OUTPUT_PATH" | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: nginx-$((j)) | ||
labels: | ||
applicationId: nginx-$((j)) | ||
spec: | ||
containers: | ||
- name: sleep300 | ||
image: "alpine:latest" | ||
command: ["sleep", "0"] | ||
ports: | ||
- containerPort: 80 | ||
affinity: | ||
podAffinity: | ||
preferredDuringSchedulingIgnoredDuringExecution: | ||
- weight: 100 | ||
podAffinityTerm: | ||
labelSelector: | ||
matchExpressions: | ||
- key: applicationId | ||
operator: $operator | ||
values: | ||
- nginx-$randAppID1 | ||
- nginx-$randAppID2 | ||
topologyKey: kubernetes.io/role | ||
tolerations: | ||
- key: "kwok.x-k8s.io/node" | ||
operator: "Exists" | ||
effect: "NoSchedule" | ||
--- | ||
EOF | ||
done |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
#!/bin/bash | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
RANDOM=0 | ||
OUTPUT_PATH="./output/priority.yaml" | ||
NUM_PODS=0 | ||
NUM_PRIORITY=0 | ||
|
||
show_help() { | ||
cat << EOF | ||
Invalid option: -$OPTARG | ||
Usage: $0 <pod_count> <priorityClass_count> | ||
|
||
Options: | ||
-o, Specifies the location of the output yaml file (default is ./output/priority.yaml) | ||
|
||
Arguments: | ||
<pod_count> Number of pod to create (required). | ||
<priorityClass_count> Number of priorityClass to create (required). | ||
EOF | ||
} | ||
|
||
# Process command-line options | ||
while getopts ":o:" opt; do | ||
case $opt in | ||
o) | ||
OUTPUT_PATH=$OPTARG | ||
;; | ||
\?) | ||
show_help | ||
exit 1 | ||
;; | ||
:) | ||
show_help | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
# Shift the processed options out of the command-line arguments | ||
shift $((OPTIND-1)) | ||
|
||
# Check if pod count and priorityClass count are provided | ||
if [ $# -ne 2 ]; then | ||
show_help | ||
exit 1 | ||
fi | ||
|
||
NUM_PODS=$1 | ||
NUM_PRIORITY=$2 | ||
Comment on lines
+64
to
+65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verify that the numbers make sense. |
||
|
||
if [ -f "$OUTPUT_PATH" ]; then | ||
# clear origin content in file | ||
echo "" > "$OUTPUT_PATH" | ||
echo "The original content of the file located at $OUTPUT_PATH has been cleared." | ||
else | ||
echo "The file $OUTPUT_PATH does not exist." | ||
mkdir -p "$(dirname "$OUTPUT_PATH")" | ||
touch "$OUTPUT_PATH" | ||
echo "The create $OUTPUT_PATH." | ||
fi | ||
|
||
# create PriorityClass | ||
echo "Create $((NUM_PRIORITY)) PriorityClass and save then to a YAML file." | ||
for (( i=0;i<NUM_PRIORITY; i++)) | ||
do | ||
cat <<EOF >> "$OUTPUT_PATH" | ||
apiVersion: scheduling.k8s.io/v1 | ||
kind: PriorityClass | ||
metadata: | ||
name: priority-$i | ||
value: $i | ||
preemptionPolicy: Never | ||
globalDefault: false | ||
--- | ||
EOF | ||
done | ||
|
||
# create pods assigned with random priorityClass name | ||
echo "Create $((NUM_PODS)) Pods and save them to a YAML file, with each Pod assigned a PriorityClass selected at random." | ||
for (( j=0;j<NUM_PODS; j++)) | ||
do | ||
randPriority=$((RANDOM % NUM_PRIORITY)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deterministic priority |
||
cat <<EOF >> "$OUTPUT_PATH" | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: nginx-$j | ||
spec: | ||
containers: | ||
- name: sleep300 | ||
image: "alpine:latest" | ||
command: ["sleep", "0"] | ||
ports: | ||
- containerPort: 80 | ||
tolerations: | ||
- key: "kwok.x-k8s.io/node" | ||
operator: "Exists" | ||
effect: "NoSchedule" | ||
priorityClassName: priority-$randPriority | ||
--- | ||
EOF | ||
done | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the minimum number of pods/nodes that make sense? Looking at the code below, we need at least 4 nodes. We need to validate them and show an error if it's necessary.