This document shows how you can use JMeter to perform more automated (non-interactive) testing.

Requirements

This article assumes that you:

Set up

Name:

Value:

HOST

${__P(host,localhost)}

jmeter -n -t load_test.jmx -l load_test_report.jtl -Gmytest.properties -j mytest.log -R remotehost1,remotehost2 ${GLOBAL_VARS}

Note that load injection to targets will be a increased as a ratio of number of threads per thread group multiplied by number of client machines.

A bash script similar to the following could be used to start up jmeter (called jmeter_test_wrapper.sh for example):

loadtest="myloadtest"
GLOBAL_VARS=""
REPORT_DIR=/tmp
JMETER_PROPERTIES=jmeter.properties
JMETER_CUSTOM_PROPERTIES=mytest.properties
# If set as an environment var, then use it, otherwise leave it unset.
HOST_LIST=${HOST_LIST:+"-R ${HOST_LIST}"}

# Had an issue with -Gglobal.properties file, so parsed this into individual properties.
for var in `grep -vE "^#|^$" ${JMETER_CUSTOM_PROPERTIES}`; do
        GLOBAL_VARS="-G${var} ${GLOBAL_VARS}"
done

# But after testing, it does work as expected.
GLOBAL_VARS="-G${JMETER_CUSTOM_PROPERTIES}"

if [ -f ${loadtest}.jmx ]; then
        echo "Running ${loadtest} with:"
        echo -e "               -----------------------
        $JMETER -n
                -t ${loadtest}.jmx
                -l ${REPORT_DIR}/${loadtest}.jtl
                -p ${JMETER_PROPERTIES}
                ${GLOBAL_VARS}
                ${HOST_LIST}
                -j ${REPORT_DIR}/_${loadtest}.log
        -----------------------"
        $JMETER -n \
                -t ${loadtest}.jmx \
                -l ${REPORT_DIR}/${loadtest}.jtl \
                -p ${JMETER_PROPERTIES} \
                ${GLOBAL_VARS} \
                ${HOST_LIST} \
                -j ${REPORT_DIR}/_${loadtest}.log
else
        echo "Could not find test plan for ${loadtest}"
fi

For a local test, you could run: ./jmeter_test_wrapper.sh For a remote test, it can be modified as HOST_LIST="192.168.1.10,192.168.1.12" ./jmeter_test_wrapper.sh Now all you need to do is make sure the servers are running and add the above command into scheduler.

JMeterAutomatedRemoteTesting (last edited 2011-11-27 00:26:07 by JMeterAdmin)