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

locust fingerprints with all dependencies added #311

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,7 @@ eclipsebin
\#*\#

# VSCode history
.history
.history

# Python Module Compile Bytecode
__pycache__/
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
master:
image: "locustio/locust:${LC_VERSION}"
ports:
- "8089:8089"
volumes:
- ./locustfile.py:/mnt/locust/locustfile.py
command: -f /mnt/locust/locustfile.py --master -H http://master:8089
healthcheck:
test: [ "CMD", "python3", "-c", "import socket; socket.create_connection(('localhost', 8089), timeout=1)" ]
interval: 3s
retries: 10
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
try:
from locust import HttpUser, TaskSet, task
except ImportError:
# For older versions of Locust
from locust import HttpLocust as HttpUser, TaskSet, task


class UserTasks(TaskSet):
@task
def hello_world(self):
self.client.get("/hello")
self.client.get("/world")


class HelloWorldUser(HttpUser):
host = "http://127.0.0.1:8089"
task_set = UserTasks
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import requests


def get_locust_tags():
url = "https://hub.docker.com/v2/repositories/locustio/locust/tags"
tags = []
while url:
response = requests.get(url)
data = response.json()
tags.extend([tag['name'] for tag in data['results']])
url = data['next']
return tags


if __name__ == "__main__":
tags = get_locust_tags()
for tag in tags:
print(tag)
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/usr/bin/env bash

# Copyright 2025 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
#
# https://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.

set -e

source ../../common.sh

SCRIPT_PATH="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)"
# Root path to the web fingerprinter plugin.
PROJECT_ROOT="$(cd -- "${SCRIPT_PATH}/../../../.." >/dev/null 2>&1 ; pwd -P)"
# Path to the configurations for starting a live instance of Locust.
APP_PATH="${SCRIPT_PATH}/app"
# Path to the temporary data holder.
TMP_DATA="/tmp/lc_fingerprints"
# Path to the local git repository for Locsut codebase.
GIT_REPO="${TMP_DATA}/repo"
# Path to the directory of all the updated fingerprints data.
FINGERPRINTS_PATH="${TMP_DATA}/fingerprints"
# Json data of the final result.
JSON_DATA="${FINGERPRINTS_PATH}/fingerprint.json"
# Binary proto data of the final result.
BIN_DATA="${FINGERPRINTS_PATH}/fingerprint.binproto"
# Read all the versions to be fingerprinted.
readarray -t ALL_VERSIONS < "${SCRIPT_PATH}/versions.txt"

mkdir -p "${FINGERPRINTS_PATH}"

BINPROTO="${PROJECT_ROOT}/src/main/resources/fingerprinters/web/data/community/locust.binproto"

startLocust() {
local version="$1"
pushd "${APP_PATH}" >/dev/null
LC_VERSION="${version}" docker compose up -d --wait
popd >/dev/null
}

stopLocust() {
local version="$1"
pushd "${APP_PATH}" >/dev/null
LC_VERSION="${version}" docker compose down --volumes --remove-orphans
popd >/dev/null
}

# Convert the existing data file to a human-readable json file.
convertFingerprint \
$BINPROTO \
"${JSON_DATA}"

# Fetch Locust codebase.
if [[ ! -d "${GIT_REPO}" ]] ; then
git clone https://github.com/locustio/locust.git "${GIT_REPO}"
fi

# Update for all the versions listed in "versions.txt" file.
for LC_VERSION in "${ALL_VERSIONS[@]}"; do
echo "Fingerprinting Locust version ${LC_VERSION} ..."
# Start a live instance of Locust.
startLocust "${LC_VERSION}"

# Checkout the repository to the correct tag.
checkOutRepo "${GIT_REPO}" "${LC_VERSION}"

updateFingerprint \
"locust" \
"${LC_VERSION}" \
"${FINGERPRINTS_PATH}" \
"${GIT_REPO}" \
"http://localhost:8089"

# Stop the live instance of Locust.
stopLocust "${LC_VERSION}"
done

convertFingerprint "${JSON_DATA}" "${BIN_DATA}"

echo "Fingerprint updated for MLflow. Please commit the following file:"
echo " ${BIN_DATA}"
echo "to"
echo " ${BINPROTO}"

Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
2.33.0
2.32.10
2.32.9
2.32.8
2.32.7
2.32.6
2.32.5
2.32.4
2.32.3
2.32.2
2.32.1
2.32.0
2.31.8
2.31.7
2.31.6
2.31.5
2.31.4
2.31.3
2.31.2
2.31.1
2.31.0
2.30.1
2.29.1
2.29.0
2.28.0
2.27.0
2.26.0
2.25.0
2.24.1
2.24.0
2.23.1
2.23.0
2.22.0
2.21.0
2.20.2
2.20.1
2.20.0
2.19.1
2.19.0
2.18.4
2.18.3
2.18.2
2.18.1
2.17.0
2.16.1
2.16.0
2.15.1
2.15.0
2.14.2
2.14.1
2.14.0
2.13.2
2.13.1
2.13.0
2.12.2
2.12.1
2.12.0
2.11.1
2.11.0
2.10.2
2.10.1
2.10.0
2.9.0
2.8.6
2.8.5
2.8.4
2.8.3
2.8.2
2.8.1
2.8.0
2.7.3
2.7.2
2.7.1
2.7.0
2.6.1
2.6.0
2.5.1
2.5.0
2.4.3
2.4.2
2.4.1
2.4.0
2.2.3
2.2.2
2.2.1
2.2.0b0
2.2.0
2.1.0
2.0.0b3
2.0.0b2
2.0.0b1
2.0.0b0
1.6.0
1.5.3
1.5.2
1.5.1
1.5.0
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.3.2
1.3.1
1.3.0
1.2.3
1.2.2
1.2.1
1.2
1.1.1
1.1
1.0.3
1.0.2
0.14.5
1.0.1
1.0
1.0b2
0.14.6
1.0b1
0.14.4
0.14.3
0.14.2
0.14.1
0.14.0
0.13.5
0.13.4
0.13.3
0.13.2
0.13.1
0.13.0
0.12.2
0.12.1
Loading