Skip to content
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

Cluster script #11

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
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
48 changes: 48 additions & 0 deletions locust/kubernetes-config/locust-master-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: locust-master
labels:
name: locust-master
spec:
replicas: 1
selector:
matchLabels:
app: locust-master
template:
metadata:
labels:
app: locust-master
spec:
containers:
- name: locust-master
image: rahulbhati/fission-locust:4
ports:
- name: loc-master-web
containerPort: 8089
protocol: TCP
- name: loc-master-p1
containerPort: 5557
protocol: TCP
- name: loc-master-p2
containerPort: 5558
protocol: TCP
env:
- name: LOCUST_MODE
value: master
- name: TARGET_HOST
value: http://router.fission/
- name: NET_TIMEOUT
value: "3600"
- name: CON_TIMEOUT
value: "3600"
- name: TASK_1
value: hello-1-15
- name: TASK_2
value: hello-2-45
- name: TASK_3
value: hello-3-75
- name: TASK_4
value: hello-4-90
- name: TASK_5
value: hello-5-120
23 changes: 23 additions & 0 deletions locust/kubernetes-config/locust-master-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
kind: Service
apiVersion: v1
metadata:
name: locust-master
labels:
app: locust-master
spec:
ports:
- port: 8089
targetPort: loc-master-web
protocol: TCP
name: loc-master-web
- port: 5557
targetPort: loc-master-p1
protocol: TCP
name: loc-master-p1
- port: 5558
targetPort: loc-master-p2
protocol: TCP
name: loc-master-p2
selector:
app: locust-master
type: LoadBalancer
40 changes: 40 additions & 0 deletions locust/kubernetes-config/locust-worker-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apiVersion: apps/v1
kind: "Deployment"
metadata:
name: locust-worker
labels:
name: locust-worker
spec:
replicas: 10
selector:
matchLabels:
app: locust-worker
template:
metadata:
labels:
app: locust-worker
spec:
containers:
- name: locust-worker
image: rahulbhati/fission-locust:4
env:
- name: LOCUST_MODE
value: worker
- name: LOCUST_MASTER
value: locust-master
- name: TARGET_HOST
value: http://router.fission/
- name: NET_TIMEOUT
value: "3600"
- name: CON_TIMEOUT
value: "3600"
- name: TASK_1
value: hello-1-15
- name: TASK_2
value: hello-2-45
- name: TASK_3
value: hello-3-75
- name: TASK_4
value: hello-4-90
- name: TASK_5
value: hello-5-120
16 changes: 16 additions & 0 deletions locust/tasks/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Start with a base Python 3.7.2 image
FROM python:3.7.2

# Add the external tasks directory into /tasks
ADD code /code

RUN pip install -r /code/requirements.txt

# Expose the required Locust ports
EXPOSE 5557 5558 8089

# Set script to be executable
RUN chmod 755 /code/run.sh

# Start Locust using LOCUS_OPTS environment variable
ENTRYPOINT ["/code/run.sh"]
23 changes: 23 additions & 0 deletions locust/tasks/code/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
certifi==2020.6.20
chardet==3.0.4
click==7.1.2
ConfigArgParse==1.2.3
Flask==1.1.2
Flask-BasicAuth==0.2.0
gevent==20.9.0
geventhttpclient==1.4.4
greenlet==0.4.17
idna==2.10
itsdangerous==1.1.0
Jinja2==2.11.2
locust==1.2.3
MarkupSafe==1.1.1
msgpack==1.0.0
psutil==5.7.2
pyzmq==19.0.2
requests==2.24.0
six==1.15.0
urllib3==1.25.10
Werkzeug==1.0.1
zope.event==4.5.0
zope.interface==5.1.2
12 changes: 12 additions & 0 deletions locust/tasks/code/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
LOCUST="/usr/local/bin/locust"
LOCUS_OPTS="-f /code/tasks.py --host=$TARGET_HOST"
LOCUST_MODE=${LOCUST_MODE:-standalone}

if [[ "$LOCUST_MODE" = "master" ]]; then
LOCUS_OPTS="$LOCUS_OPTS --master"
elif [[ "$LOCUST_MODE" = "worker" ]]; then
LOCUS_OPTS="$LOCUS_OPTS --worker --master-host=$LOCUST_MASTER"
fi

$LOCUST $LOCUS_OPTS
35 changes: 35 additions & 0 deletions locust/tasks/code/tasks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from datetime import datetime
import os
from locust import HttpUser, TaskSet, task, between
from locust.contrib.fasthttp import FastHttpUser


class FissionUser(FastHttpUser):
network_timeout = float(os.environ['NET_TIMEOUT'])
connection_timeout = float(os.environ['CON_TIMEOUT'])
wait_time = between(1, 2)

@task(33)
def task1(self):
self.client.get(
'/fission-function/' + os.environ['TASK_1'])

@task(19)
def task2(self):
self.client.get(
'/fission-function/' + os.environ['TASK_2'])

@task(19)
def task3(self):
self.client.get(
'/fission-function/' + os.environ['TASK_3'])

@task(13)
def task4(self):
self.client.get(
'/fission-function/' + os.environ['TASK_4'])

@task(13)
def task5(self):
self.client.get(
'/fission-function/' + os.environ['TASK_5'])
18 changes: 0 additions & 18 deletions samples/gobuster-example/binary-env/Dockerfile

This file was deleted.

45 changes: 0 additions & 45 deletions samples/gobuster-example/binary-env/env.go

This file was deleted.

Loading