Initial commit
Some checks failed
Continuous Integration - Pull Request / code-tests (pull_request) Has been cancelled
Continuous Integration - Pull Request / deployment-tests (local-code) (pull_request) Has been cancelled
helm-chart-ci / helm-chart-ci (pull_request) Has been cancelled
kubevious-manifests-ci / kubevious-manifests-ci (pull_request) Has been cancelled
kustomize-build-ci / kustomize-build-ci (pull_request) Has been cancelled
terraform-validate-ci / terraform-validate-ci (pull_request) Has been cancelled
Clean up deployment / cleanup-namespace (pull_request) Has been cancelled
Continuous Integration - Main/Release / code-tests (push) Has been cancelled
Continuous Integration - Main/Release / deployment-tests (local-code) (push) Has been cancelled
helm-chart-ci / helm-chart-ci (push) Has been cancelled
kubevious-manifests-ci / kubevious-manifests-ci (push) Has been cancelled
kustomize-build-ci / kustomize-build-ci (push) Has been cancelled
terraform-validate-ci / terraform-validate-ci (push) Has been cancelled

This commit is contained in:
2026-02-04 20:47:56 +05:30
commit dafcd9777f
363 changed files with 52703 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
# Copyright 2020 Google LLC
#
# 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.
FROM --platform=$BUILDPLATFORM python:3.14.2-alpine@sha256:31da4cb527055e4e3d7e9e006dffe9329f84ebea79eaca0a1f1c27ce61e40ca5 AS base
FROM base AS builder
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
RUN apk update \
&& apk add --no-cache g++ linux-headers \
&& rm -rf /var/cache/apk/*
COPY requirements.txt .
RUN pip install --prefix="/install" -r requirements.txt
FROM base
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
RUN apk update \
&& apk add --no-cache libstdc++ \
&& rm -rf /var/cache/apk/*
WORKDIR /loadgen
COPY --from=builder /install /usr/local
# Add application code.
COPY locustfile.py .
# enable gevent support in debugger
ENV GEVENT_SUPPORT=True
ENTRYPOINT locust --host="http://${FRONTEND_ADDR}" --headless -u "${USERS:-10}" -r "${RATE:-1}" 2>&1

92
src/loadgenerator/locustfile.py Executable file
View File

@@ -0,0 +1,92 @@
#!/usr/bin/python
#
# Copyright 2018 Google LLC
#
# 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.
import random
from locust import FastHttpUser, TaskSet, between
from faker import Faker
import datetime
fake = Faker()
products = [
'0PUK6V6EV0',
'1YMWWN1N4O',
'2ZYFJ3GM2N',
'66VCHSJNUP',
'6E92ZMYYFZ',
'9SIQT8TOJO',
'L9ECAV7KIM',
'LS4PSXUNUM',
'OLJCESPC7Z']
def index(l):
l.client.get("/")
def setCurrency(l):
currencies = ['EUR', 'USD', 'JPY', 'CAD', 'GBP', 'TRY']
l.client.post("/setCurrency",
{'currency_code': random.choice(currencies)})
def browseProduct(l):
l.client.get("/product/" + random.choice(products))
def viewCart(l):
l.client.get("/cart")
def addToCart(l):
product = random.choice(products)
l.client.get("/product/" + product)
l.client.post("/cart", {
'product_id': product,
'quantity': random.randint(1,10)})
def empty_cart(l):
l.client.post('/cart/empty')
def checkout(l):
addToCart(l)
current_year = datetime.datetime.now().year+1
l.client.post("/cart/checkout", {
'email': fake.email(),
'street_address': fake.street_address(),
'zip_code': fake.zipcode(),
'city': fake.city(),
'state': fake.state_abbr(),
'country': fake.country(),
'credit_card_number': fake.credit_card_number(card_type="visa"),
'credit_card_expiration_month': random.randint(1, 12),
'credit_card_expiration_year': random.randint(current_year, current_year + 70),
'credit_card_cvv': f"{random.randint(100, 999)}",
})
def logout(l):
l.client.get('/logout')
class UserBehavior(TaskSet):
def on_start(self):
index(self)
tasks = {index: 1,
setCurrency: 2,
browseProduct: 10,
addToCart: 2,
viewCart: 3,
checkout: 1}
class WebsiteUser(FastHttpUser):
tasks = [UserBehavior]
wait_time = between(1, 10)

View File

@@ -0,0 +1,2 @@
locust==2.43.0
faker==40.1.0

View File

@@ -0,0 +1,100 @@
# This file was autogenerated by uv via the following command:
# uv pip compile requirements.in -o requirements.txt
bidict==0.23.1
# via python-socketio
blinker==1.9.0
# via flask
brotli==1.2.0
# via geventhttpclient
certifi==2025.8.3
# via
# geventhttpclient
# requests
charset-normalizer==3.4.3
# via requests
click==8.3.0
# via flask
configargparse==1.7.1
# via locust
faker==40.1.0
# via -r requirements.in
flask==3.1.2
# via
# flask-cors
# flask-login
# locust
flask-cors==6.0.1
# via locust
flask-login==0.6.3
# via locust
gevent==25.9.1
# via
# geventhttpclient
# locust
geventhttpclient==2.3.4
# via locust
greenlet==3.2.4
# via gevent
h11==0.16.0
# via wsproto
idna==3.10
# via requests
iniconfig==2.1.0
# via pytest
itsdangerous==2.2.0
# via flask
jinja2==3.1.6
# via flask
locust==2.43.0
# via -r requirements.in
markupsafe==3.0.2
# via
# flask
# jinja2
# werkzeug
msgpack==1.1.1
# via locust
packaging==25.0
# via pytest
pluggy==1.6.0
# via pytest
psutil==7.1.0
# via locust
pygments==2.19.2
# via pytest
pytest==8.4.2
# via locust
python-engineio==4.12.2
# via
# locust
# python-socketio
python-socketio[client]==5.13.0
# via locust
pyzmq==27.1.0
# via locust
requests==2.32.5
# via
# locust
# python-socketio
simple-websocket==1.1.0
# via python-engineio
tzdata==2025.2
# via faker
urllib3==2.6.3
# via
# geventhttpclient
# requests
websocket-client==1.8.0
# via python-socketio
werkzeug==3.1.5
# via
# flask
# flask-cors
# flask-login
# locust
wsproto==1.2.0
# via simple-websocket
zope-event==6.0
# via gevent
zope-interface==8.0
# via gevent