update throughput tester
This commit is contained in:
parent
4867096047
commit
e3e0c9c21a
3 changed files with 1035 additions and 57 deletions
1000
throughput/canvas_rects.txt
Normal file
1000
throughput/canvas_rects.txt
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -5,8 +5,9 @@ JMETER_CMD="jmeter"
|
|||
DEFAULT_THREADS=10
|
||||
DEFAULT_LOOPS=10
|
||||
|
||||
APP_NAME=""
|
||||
SAVE_OUTPUT=""
|
||||
TARGET_URL=""
|
||||
TARGET_PORT=5000
|
||||
THREADS=$DEFAULT_THREADS
|
||||
LOOPS=$DEFAULT_LOOPS
|
||||
|
||||
|
|
@ -16,10 +17,11 @@ show_help() {
|
|||
echo "Runs a JMeter benchmark test with specified parameters."
|
||||
echo ""
|
||||
echo "Required Flags:"
|
||||
echo " -o, --output The name of the app or user for organizing results."
|
||||
echo " -o, --output The output location for the benchmark results."
|
||||
echo " -H, --host The target URL or IP address for the test (e.g., 10.250.22.29)."
|
||||
echo ""
|
||||
echo "Optional Flags:"
|
||||
echo " -p, --port The target port for the test. Default: 5000."
|
||||
echo " -t, --threads Number of concurrent threads (users). Default: ${DEFAULT_THREADS}."
|
||||
echo " -l, --loops Number of loops each thread will execute. Default: ${DEFAULT_LOOPS}."
|
||||
echo " -h, --help Display this help message and exit."
|
||||
|
|
@ -29,7 +31,7 @@ while [[ $# -gt 0 ]]; do
|
|||
key="$1"
|
||||
case $key in
|
||||
-o|--output)
|
||||
APP_NAME="$2"
|
||||
SAVE_OUTPUT="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
|
|
@ -38,6 +40,11 @@ while [[ $# -gt 0 ]]; do
|
|||
shift
|
||||
shift
|
||||
;;
|
||||
-p|--port)
|
||||
TARGET_PORT="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
-t|--threads)
|
||||
THREADS="$2"
|
||||
shift
|
||||
|
|
@ -60,7 +67,7 @@ while [[ $# -gt 0 ]]; do
|
|||
esac
|
||||
done
|
||||
|
||||
if [ -z "$APP_NAME" ] || [ -z "$TARGET_URL" ]; then
|
||||
if [ -z "$SAVE_OUTPUT" ] || [ -z "$TARGET_URL" ]; then
|
||||
echo "ERROR: Missing required arguments."
|
||||
echo ""
|
||||
show_help
|
||||
|
|
@ -68,12 +75,14 @@ if [ -z "$APP_NAME" ] || [ -z "$TARGET_URL" ]; then
|
|||
fi
|
||||
|
||||
# --- Define Output Structure ---
|
||||
MAIN_OUTPUT_DIR="./${APP_NAME}"
|
||||
RESULT_CSV="${MAIN_OUTPUT_DIR}/${APP_NAME}_benchmark.csv"
|
||||
RESULT_DASHBOARD="${MAIN_OUTPUT_DIR}/${APP_NAME}_dashboard"
|
||||
JMETER_LOG_FILE="${MAIN_OUTPUT_DIR}/${APP_NAME}_jmeter.log"
|
||||
MAIN_OUTPUT_DIR="${SAVE_OUTPUT}"
|
||||
FOLDER_NAME=$(basename "$SAVE_OUTPUT")
|
||||
|
||||
echo "--- Preparing for test run: '$APP_NAME' ---"
|
||||
RESULT_CSV="${MAIN_OUTPUT_DIR}/${FOLDER_NAME}_benchmark.csv"
|
||||
RESULT_DASHBOARD="${MAIN_OUTPUT_DIR}/${FOLDER_NAME}_dashboard"
|
||||
JMETER_LOG_FILE="${MAIN_OUTPUT_DIR}/${FOLDER_NAME}_jmeter.log"
|
||||
|
||||
echo "--- Preparing for test run: '$FOLDER_NAME' ---"
|
||||
mkdir -p "$MAIN_OUTPUT_DIR"
|
||||
echo "Output will be saved in: $MAIN_OUTPUT_DIR"
|
||||
|
||||
|
|
@ -98,7 +107,8 @@ $JMETER_CMD -n \
|
|||
-j "$JMETER_LOG_FILE" \
|
||||
-Jthreads="$THREADS" \
|
||||
-Jloops="$LOOPS" \
|
||||
-Jurl="$TARGET_URL"
|
||||
-Jurl="$TARGET_URL" \
|
||||
-Jport="$TARGET_PORT"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo ""
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables">
|
||||
<collectionProp name="Arguments.arguments"/>
|
||||
</elementProp>
|
||||
<boolProp name="TestPlan.functional_mode">false</boolProp>
|
||||
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
|
||||
</TestPlan>
|
||||
<hashTree>
|
||||
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group">
|
||||
|
|
@ -18,9 +20,21 @@
|
|||
</elementProp>
|
||||
</ThreadGroup>
|
||||
<hashTree>
|
||||
<CSVDataSet guiclass="TestBeanGUI" testclass="CSVDataSet" testname="canvasRect">
|
||||
<stringProp name="delimiter">,</stringProp>
|
||||
<stringProp name="fileEncoding"></stringProp>
|
||||
<stringProp name="filename">canvas_rects.txt</stringProp>
|
||||
<boolProp name="ignoreFirstLine">false</boolProp>
|
||||
<boolProp name="quotedData">false</boolProp>
|
||||
<boolProp name="recycle">true</boolProp>
|
||||
<stringProp name="shareMode">shareMode.all</stringProp>
|
||||
<boolProp name="stopThread">false</boolProp>
|
||||
<stringProp name="variableNames">canvasRect</stringProp>
|
||||
</CSVDataSet>
|
||||
<hashTree/>
|
||||
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Request">
|
||||
<stringProp name="HTTPSampler.domain">${__P(url, stitchaton.local)}</stringProp>
|
||||
<stringProp name="HTTPSampler.port">5000</stringProp>
|
||||
<stringProp name="HTTPSampler.port">${__P(port, 5000)}</stringProp>
|
||||
<stringProp name="HTTPSampler.protocol">http</stringProp>
|
||||
<stringProp name="HTTPSampler.path">/api/image/generate</stringProp>
|
||||
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
|
||||
|
|
@ -43,52 +57,6 @@
|
|||
</elementProp>
|
||||
</HTTPSamplerProxy>
|
||||
<hashTree>
|
||||
<JSR223PreProcessor guiclass="TestBeanGUI" testclass="JSR223PreProcessor" testname="JSR223 PreProcessor">
|
||||
<stringProp name="cacheKey">true</stringProp>
|
||||
<stringProp name="filename"></stringProp>
|
||||
<stringProp name="parameters"></stringProp>
|
||||
<stringProp name="script">// Function to convert a numeric index (1-31) to the SBS Plate Row format (A-AE)
|
||||
String indexToRow(int num) {
|
||||
if (num <= 0) return "";
|
||||
if (num <= 26) {
|
||||
// A-Z is ASCII 65-90. 'A' is char 65. So (num - 1) + 65.
|
||||
return (char)(num + 64) as String;
|
||||
} else {
|
||||
// For AA-AE, the first char is 'A'.
|
||||
// 27 -> AA, 28 -> AB, etc.
|
||||
// The second char is (num - 27) + 65 -> 'A', 'B', etc.
|
||||
return "A" + (char)(num - 26 + 64) as String;
|
||||
}
|
||||
}
|
||||
|
||||
// Define the maximum starting indices for a 2x2 grid
|
||||
// Max row is AE (31), so max starting row is AD (30)
|
||||
// Max col is 55, so max starting col is 54
|
||||
int maxStartRowIndex = 30;
|
||||
int maxStartCol = 54;
|
||||
|
||||
// Generate random starting coordinates
|
||||
// nextInt(bound) generates 0 to bound-1, so add 1
|
||||
int randomRowStartIndex = new Random().nextInt(maxStartRowIndex) + 1;
|
||||
int randomColStart = new Random().nextInt(maxStartCol) + 1;
|
||||
|
||||
// Calculate the end coordinates for the 2x2 grid
|
||||
String rowStart = indexToRow(randomRowStartIndex);
|
||||
String rowEnd = indexToRow(randomRowStartIndex + 1);
|
||||
int colEnd = randomColStart + 1;
|
||||
|
||||
// Construct the final canvas_rect string
|
||||
String canvasRectValue = "${rowStart}${randomColStart}:${rowEnd}${colEnd}";
|
||||
|
||||
// Store the generated string in a JMeter variable named "canvasRect"
|
||||
// This makes it available to the HTTP Request sampler
|
||||
vars.put("canvasRect", canvasRectValue);
|
||||
|
||||
// Optional: Log the generated value to see it in the JMeter log (for debugging)
|
||||
log.info("Generated canvas_rect: " + canvasRectValue);</stringProp>
|
||||
<stringProp name="scriptLanguage">groovy</stringProp>
|
||||
</JSR223PreProcessor>
|
||||
<hashTree/>
|
||||
<HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP Header Manager">
|
||||
<collectionProp name="HeaderManager.headers">
|
||||
<elementProp name="" elementType="Header">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue