-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Distributed Load Test with Jmeter on GKE Example (#1197)
* Added gke distributed load test with jmeter * Fix shellcheck test for bash conditional * Reorg for better organization --------- Co-authored-by: Andrew Gold <[email protected]>
- Loading branch information
Showing
10 changed files
with
451 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Distributed Load-Testing with Jmeter | ||
|
||
## Build and Push jmeter-master docker File | ||
|
||
```Dockerfile | ||
FROM justb4/jmeter:latest | ||
|
||
EXPOSE 60000 | ||
``` | ||
|
||
```bash | ||
docker build --tag="<artifact_registry_address>/jmeter-master:latest" -f Dockerfile-master . | ||
docker push <artifact_registry_address>/jmeter-master:latest | ||
``` | ||
|
||
## Build and Push jmeter-slave docker File | ||
|
||
```Dockerfile | ||
FROM justb4/jmeter:latest | ||
|
||
EXPOSE 1099 50000 | ||
|
||
ENTRYPOINT $JMETER_HOME/bin/jmeter-server \ | ||
-Dserver.rmi.ssl.disable=true \ | ||
-Dserver.rmi.localport=50000 \ | ||
-Dserver_port=1099 | ||
``` | ||
|
||
```bash | ||
docker build --tag="<artifact_registry_address>/jmeter-master:latest" -f Dockerfile-master . | ||
docker push <artifact_registry_address>/jmeter-master:latest | ||
``` | ||
|
||
## Create Deployments | ||
|
||
```bash | ||
./jmeter_cluster_create.sh | ||
``` | ||
|
||
## Copy Test plan to Jmeter Master | ||
|
||
```bash | ||
kubectl cp neo4j-bolt-request.jmx <servive_name>/<pod_nam>:/bin/ | ||
``` | ||
|
||
## Run the load-test | ||
|
||
```bash | ||
kubectl exec -it <master_pod_name> -- /bin/bash | ||
cd bin | ||
./jmeter -n -t neo4j-bolt-request.jmx -l neo4j-load-test-logs.jtl -R <jmeter-slave-pod-ip-1>,<jmeter-slave-pod-ip-2> | ||
``` |
110 changes: 110 additions & 0 deletions
110
examples/gke-distributed-load-test-jmeter/deployments/jmeter_cluster_create.sh
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,110 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright 2023 Google Inc. All Rights Reserved. | ||
# | ||
# Licensed 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. | ||
|
||
####################################### | ||
# Deploy Jmeter on GKE | ||
# Globals: | ||
# None | ||
# Arguments: | ||
# None | ||
####################################### | ||
|
||
echo "checking if kubectl is present" | ||
|
||
if ! hash kubectl 2>/dev/null | ||
then | ||
echo "'kubectl' was not found in PATH" | ||
|
||
echo "Kindly ensure that you can acces an existing kubernetes cluster via kubectl" | ||
|
||
exit | ||
fi | ||
|
||
kubectl version --short | ||
|
||
echo "Current list of namespaces on the kubernetes cluster:" | ||
|
||
echo | ||
|
||
kubectl get namespaces | grep -v NAME | awk '{print $1}' || true | ||
|
||
echo | ||
|
||
tenant="$1" | ||
if [[ -z "${tenant}" ]] | ||
then | ||
|
||
echo "Enter the name of the new tenant unique name, this will be used to create the namespace" | ||
|
||
read -r tenant | ||
fi | ||
|
||
echo | ||
|
||
#Check If namespace exists | ||
|
||
|
||
if ! hash kubectl get namespace "${tenant}" > /dev/null 2>&1 | ||
then | ||
|
||
echo "Namespace ${tenant} already exists, please select a unique name" | ||
|
||
echo "Current list of namespaces on the kubernetes cluster" | ||
|
||
sleep 2 | ||
|
||
kubectl get namespaces | grep -v NAME | awk '{print $1}' || true | ||
|
||
exit 1 | ||
fi | ||
|
||
echo | ||
echo "Creating Namespace: ${tenant}" | ||
|
||
kubectl create namespace "${tenant}" | ||
|
||
echo "Namspace ${tenant} has been created" | ||
|
||
echo | ||
|
||
echo "Creating Jmeter worker nodes" | ||
|
||
nodes=$(kubectl get no | grep -c -v "controller| NAME" ) || true | ||
|
||
echo | ||
|
||
echo "Number of worker nodes on this cluster is " "${nodes}" | ||
|
||
echo | ||
|
||
#echo "Creating $nodes Jmeter slave replicas and service" | ||
|
||
echo | ||
|
||
kubectl create -n "${tenant}" -f jmeter_workers_deploy.yaml | ||
kubectl create -n "${tenant}" -f jmeter_workers_svc.yaml | ||
|
||
echo "Creating Jmeter Controller" | ||
|
||
kubectl create -n "${tenant}" -f jmeter_controller_deploy.yaml | ||
|
||
echo "Printout Of the ${tenant} Objects" | ||
|
||
echo | ||
|
||
kubectl get -n "${tenant}" all | ||
|
||
echo namespace = "${tenant}" > tenant_export |
38 changes: 38 additions & 0 deletions
38
examples/gke-distributed-load-test-jmeter/deployments/jmeter_controller_deploy.yaml
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,38 @@ | ||
# Copyright 2023 Google Inc. All Rights Reserved. | ||
# | ||
# Licensed 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. | ||
|
||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: jmeter-controller | ||
labels: | ||
jmeter_mode: controller | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
jmeter_mode: controller | ||
template: | ||
metadata: | ||
labels: | ||
jmeter_mode: controller | ||
spec: | ||
containers: | ||
- name: jmcontroller | ||
image: <artifact_registry_address>/jmeter-controller:latest | ||
imagePullPolicy: IfNotPresent | ||
command: [ "/bin/bash", "-c", "--" ] | ||
args: [ "while true; do sleep 30; done;" ] | ||
ports: | ||
- containerPort: 60000 |
31 changes: 31 additions & 0 deletions
31
examples/gke-distributed-load-test-jmeter/deployments/jmeter_slaves_svc.yaml
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,31 @@ | ||
# Copyright 2023 Google Inc. All Rights Reserved. | ||
# | ||
# Licensed 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. | ||
|
||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: jmeter-workers-svc | ||
labels: | ||
jmeter_mode: worker | ||
spec: | ||
clusterIP: None | ||
ports: | ||
- port: 1099 | ||
name: first | ||
targetPort: 1099 | ||
- port: 50000 | ||
name: second | ||
targetPort: 50000 | ||
selector: | ||
jmeter_mode: worker |
37 changes: 37 additions & 0 deletions
37
examples/gke-distributed-load-test-jmeter/deployments/jmeter_workers_deploy.yaml
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,37 @@ | ||
# Copyright 2023 Google Inc. All Rights Reserved. | ||
# | ||
# Licensed 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. | ||
|
||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: jmeter-workers | ||
labels: | ||
jmeter_mode: worker | ||
spec: | ||
replicas: 2 | ||
selector: | ||
matchLabels: | ||
jmeter_mode: worker | ||
template: | ||
metadata: | ||
labels: | ||
jmeter_mode: worker | ||
spec: | ||
containers: | ||
- name: jmworker | ||
image: <artifact_registry_address>/jmeter-worker:latest | ||
imagePullPolicy: IfNotPresent | ||
ports: | ||
- containerPort: 1099 | ||
- containerPort: 50000 |
25 changes: 25 additions & 0 deletions
25
examples/gke-distributed-load-test-jmeter/docker/Dockerfile-controller
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,25 @@ | ||
# Copyright 2023 Google Inc. All Rights Reserved. | ||
# | ||
# Licensed 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. | ||
|
||
####################################### | ||
# Docker env to run Jmeter Controller | ||
# Globals: | ||
# None | ||
# Arguments: | ||
# None | ||
####################################### | ||
|
||
FROM justb4/jmeter:latest | ||
|
||
EXPOSE 60000 |
30 changes: 30 additions & 0 deletions
30
examples/gke-distributed-load-test-jmeter/docker/Dockerfile-worker
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,30 @@ | ||
# Copyright 2023 Google Inc. All Rights Reserved. | ||
# | ||
# Licensed 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. | ||
|
||
####################################### | ||
# Docker env to run Jmeter Worker | ||
# Globals: | ||
# None | ||
# Arguments: | ||
# None | ||
####################################### | ||
|
||
FROM justb4/jmeter:latest | ||
|
||
EXPOSE 1099 50000 | ||
|
||
ENTRYPOINT $JMETER_HOME/bin/jmeter-server \ | ||
-Dserver.rmi.localport=50000 \ | ||
-Dserver_port=1099 \ | ||
-Jserver.rmi.ssl.disable=true |
32 changes: 32 additions & 0 deletions
32
examples/gke-distributed-load-test-jmeter/docker/dockerimages.sh
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,32 @@ | ||
#!/bin/bash -e | ||
|
||
# Copyright 2023 Google Inc. All Rights Reserved. | ||
# | ||
# Licensed 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. | ||
|
||
####################################### | ||
# Build and Push Docker Images for | ||
# Jmeter Controller and Worker | ||
# Globals: | ||
# None | ||
# Arguments: | ||
# None | ||
####################################### | ||
|
||
docker build --tag="<artifact_registry_address>/jmeter-controller:latest" -f Dockerfile-controller . | ||
docker build --tag="<artifact_registry_address>/jmeter-worker:latest" -f Dockerfile-worker . | ||
|
||
gcloud auth configure-docker <GCP_REGION>-docker.pkg.dev | ||
|
||
docker push <artifact_registry_address>/jmeter-controller:latest | ||
docker push <artifact_registry_address>/jmeter-worker:latest |
Oops, something went wrong.