Last active
July 7, 2021 17:38
-
-
Save rafaelliu/0cdc9a2cc06cf1ac006e6dd6a51bfd78 to your computer and use it in GitHub Desktop.
JMeter test plan for Lambda
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Variables | |
export AWS_ACCESS_KEY_ID=<my key> | |
export AWS_SECRET_ACCESS_KEY=<my secret> | |
export REGION=us-east-1 | |
export FUNCTION_NAME=python-test | |
# Build and start sigv4 proxy | |
git clone https://github.com/awslabs/aws-sigv4-proxy | |
cd aws-sigv4-proxy | |
docker build -t aws-sigv4-proxy . | |
docker run --rm -ti -e "AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID" -e "AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY" -p 80:8080 aws-sigv4-proxy -v | |
# Test it works | |
curl -XPOST -s -H "host: lambda.${REGION}.amazonaws.com" "http://localhost/2015-03-31/functions/${FUNCTION_NAME}/invocations" | |
# Run JMeter | |
./jmeter -Jfunction_name=$FUNCTION_NAME -Jregion=$REGION -n -t test-plan.jmx -l test.log -e | |
# Add custom metrics to JMeter if needed | |
echo " | |
sample_variables=MY_METRIC | |
jmeter.reportgenerator.graph.custom_graph.classname=org.apache.jmeter.report.processor.graph.impl.CustomGraphConsumer | |
jmeter.reportgenerator.graph.custom_graph.title=MY_METRIC | |
jmeter.reportgenerator.graph.custom_graph.property.set_Y_Axis=MY_METRIC | |
jmeter.reportgenerator.graph.custom_graph.set_X_Axis=Over Time | |
jmeter.reportgenerator.graph.custom_graph.property.set_granularity=10 | |
jmeter.reportgenerator.graph.custom_graph.property.set_Sample_Variable_Name=MY_METRIC | |
jmeter.reportgenerator.graph.custom_graph.property.set_Content_Message=MY_METRIC: | |
" >> jmeter.properties |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.4.1"> | |
<hashTree> | |
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true"> | |
<stringProp name="TestPlan.comments"></stringProp> | |
<boolProp name="TestPlan.functional_mode">false</boolProp> | |
<boolProp name="TestPlan.tearDown_on_shutdown">true</boolProp> | |
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp> | |
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true"> | |
<collectionProp name="Arguments.arguments"/> | |
</elementProp> | |
<stringProp name="TestPlan.user_define_classpath"></stringProp> | |
</TestPlan> | |
<hashTree> | |
<Arguments guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true"> | |
<collectionProp name="Arguments.arguments"> | |
<elementProp name="function_name" elementType="Argument"> | |
<stringProp name="Argument.name">function_name</stringProp> | |
<stringProp name="Argument.value">${__property(function_name)}</stringProp> | |
<stringProp name="Argument.metadata">=</stringProp> | |
</elementProp> | |
<elementProp name="region" elementType="Argument"> | |
<stringProp name="Argument.name">region</stringProp> | |
<stringProp name="Argument.value">${__property(region)}</stringProp> | |
<stringProp name="Argument.metadata">=</stringProp> | |
</elementProp> | |
</collectionProp> | |
</Arguments> | |
<hashTree/> | |
<ConfigTestElement guiclass="HttpDefaultsGui" testclass="ConfigTestElement" testname="HTTP Request Defaults (HTTP endpoint)" enabled="true"> | |
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true"> | |
<collectionProp name="Arguments.arguments"/> | |
</elementProp> | |
<stringProp name="HTTPSampler.domain">localhost</stringProp> | |
<stringProp name="HTTPSampler.port"></stringProp> | |
<stringProp name="HTTPSampler.protocol"></stringProp> | |
<stringProp name="HTTPSampler.contentEncoding"></stringProp> | |
<stringProp name="HTTPSampler.path"></stringProp> | |
<stringProp name="HTTPSampler.concurrentPool">6</stringProp> | |
<stringProp name="HTTPSampler.implementation">HttpClient4</stringProp> | |
<stringProp name="HTTPSampler.connect_timeout"></stringProp> | |
<stringProp name="HTTPSampler.response_timeout"></stringProp> | |
</ConfigTestElement> | |
<hashTree/> | |
<HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP Header Manager" enabled="true"> | |
<collectionProp name="HeaderManager.headers"> | |
<elementProp name="" elementType="Header"> | |
<stringProp name="Header.name">Accept</stringProp> | |
<stringProp name="Header.value">*/*</stringProp> | |
</elementProp> | |
<elementProp name="" elementType="Header"> | |
<stringProp name="Header.name">host</stringProp> | |
<stringProp name="Header.value">lambda.${region}.amazonaws.com</stringProp> | |
</elementProp> | |
</collectionProp> | |
</HeaderManager> | |
<hashTree/> | |
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true"> | |
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp> | |
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true"> | |
<boolProp name="LoopController.continue_forever">false</boolProp> | |
<stringProp name="LoopController.loops">1</stringProp> | |
</elementProp> | |
<stringProp name="ThreadGroup.num_threads">1</stringProp> | |
<stringProp name="ThreadGroup.ramp_time">1</stringProp> | |
<boolProp name="ThreadGroup.scheduler">false</boolProp> | |
<stringProp name="ThreadGroup.duration"></stringProp> | |
<stringProp name="ThreadGroup.delay"></stringProp> | |
<boolProp name="ThreadGroup.same_user_on_next_iteration">true</boolProp> | |
</ThreadGroup> | |
<hashTree> | |
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Invoke" enabled="true"> | |
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true"> | |
<collectionProp name="Arguments.arguments"/> | |
</elementProp> | |
<stringProp name="HTTPSampler.domain"></stringProp> | |
<stringProp name="HTTPSampler.port"></stringProp> | |
<stringProp name="HTTPSampler.protocol"></stringProp> | |
<stringProp name="HTTPSampler.contentEncoding"></stringProp> | |
<stringProp name="HTTPSampler.path">/2015-03-31/functions/${function_name}/invocations</stringProp> | |
<stringProp name="HTTPSampler.method">POST</stringProp> | |
<boolProp name="HTTPSampler.follow_redirects">true</boolProp> | |
<boolProp name="HTTPSampler.auto_redirects">false</boolProp> | |
<boolProp name="HTTPSampler.use_keepalive">true</boolProp> | |
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> | |
<stringProp name="HTTPSampler.embedded_url_re"></stringProp> | |
<stringProp name="HTTPSampler.implementation">HttpClient4</stringProp> | |
<stringProp name="HTTPSampler.connect_timeout"></stringProp> | |
<stringProp name="HTTPSampler.response_timeout"></stringProp> | |
</HTTPSamplerProxy> | |
<hashTree> | |
<JSONPostProcessor guiclass="JSONPostProcessorGui" testclass="JSONPostProcessor" testname="JSON Extractor" enabled="false"> | |
<stringProp name="JSONPostProcessor.referenceNames">MY_METRIC</stringProp> | |
<stringProp name="JSONPostProcessor.jsonPathExprs">$.my-metric</stringProp> | |
<stringProp name="JSONPostProcessor.match_numbers"></stringProp> | |
</JSONPostProcessor> | |
<hashTree/> | |
</hashTree> | |
</hashTree> | |
<ResultCollector guiclass="StatVisualizer" testclass="ResultCollector" testname="Aggregate Report" enabled="true"> | |
<boolProp name="ResultCollector.error_logging">false</boolProp> | |
<objProp> | |
<name>saveConfig</name> | |
<value class="SampleSaveConfiguration"> | |
<time>true</time> | |
<latency>true</latency> | |
<timestamp>true</timestamp> | |
<success>true</success> | |
<label>true</label> | |
<code>true</code> | |
<message>true</message> | |
<threadName>true</threadName> | |
<dataType>true</dataType> | |
<encoding>false</encoding> | |
<assertions>true</assertions> | |
<subresults>true</subresults> | |
<responseData>false</responseData> | |
<samplerData>false</samplerData> | |
<xml>false</xml> | |
<fieldNames>true</fieldNames> | |
<responseHeaders>false</responseHeaders> | |
<requestHeaders>false</requestHeaders> | |
<responseDataOnError>false</responseDataOnError> | |
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage> | |
<assertionsResultsToSave>0</assertionsResultsToSave> | |
<bytes>true</bytes> | |
<sentBytes>true</sentBytes> | |
<url>true</url> | |
<threadCounts>true</threadCounts> | |
<idleTime>true</idleTime> | |
<connectTime>true</connectTime> | |
</value> | |
</objProp> | |
<stringProp name="filename"></stringProp> | |
</ResultCollector> | |
<hashTree/> | |
<ResultCollector guiclass="SummaryReport" testclass="ResultCollector" testname="Summary Report" enabled="true"> | |
<boolProp name="ResultCollector.error_logging">false</boolProp> | |
<objProp> | |
<name>saveConfig</name> | |
<value class="SampleSaveConfiguration"> | |
<time>true</time> | |
<latency>true</latency> | |
<timestamp>true</timestamp> | |
<success>true</success> | |
<label>true</label> | |
<code>true</code> | |
<message>true</message> | |
<threadName>true</threadName> | |
<dataType>true</dataType> | |
<encoding>false</encoding> | |
<assertions>true</assertions> | |
<subresults>true</subresults> | |
<responseData>false</responseData> | |
<samplerData>false</samplerData> | |
<xml>false</xml> | |
<fieldNames>true</fieldNames> | |
<responseHeaders>false</responseHeaders> | |
<requestHeaders>false</requestHeaders> | |
<responseDataOnError>false</responseDataOnError> | |
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage> | |
<assertionsResultsToSave>0</assertionsResultsToSave> | |
<bytes>true</bytes> | |
<sentBytes>true</sentBytes> | |
<url>true</url> | |
<threadCounts>true</threadCounts> | |
<idleTime>true</idleTime> | |
<connectTime>true</connectTime> | |
</value> | |
</objProp> | |
<stringProp name="filename"></stringProp> | |
</ResultCollector> | |
<hashTree/> | |
<ResultCollector guiclass="TableVisualizer" testclass="ResultCollector" testname="View Results in Table" enabled="true"> | |
<boolProp name="ResultCollector.error_logging">false</boolProp> | |
<objProp> | |
<name>saveConfig</name> | |
<value class="SampleSaveConfiguration"> | |
<time>true</time> | |
<latency>true</latency> | |
<timestamp>true</timestamp> | |
<success>true</success> | |
<label>true</label> | |
<code>true</code> | |
<message>true</message> | |
<threadName>true</threadName> | |
<dataType>true</dataType> | |
<encoding>false</encoding> | |
<assertions>true</assertions> | |
<subresults>true</subresults> | |
<responseData>false</responseData> | |
<samplerData>false</samplerData> | |
<xml>false</xml> | |
<fieldNames>true</fieldNames> | |
<responseHeaders>false</responseHeaders> | |
<requestHeaders>false</requestHeaders> | |
<responseDataOnError>false</responseDataOnError> | |
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage> | |
<assertionsResultsToSave>0</assertionsResultsToSave> | |
<bytes>true</bytes> | |
<sentBytes>true</sentBytes> | |
<url>true</url> | |
<threadCounts>true</threadCounts> | |
<idleTime>true</idleTime> | |
<connectTime>true</connectTime> | |
</value> | |
</objProp> | |
<stringProp name="filename"></stringProp> | |
</ResultCollector> | |
<hashTree/> | |
<ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="true"> | |
<boolProp name="ResultCollector.error_logging">false</boolProp> | |
<objProp> | |
<name>saveConfig</name> | |
<value class="SampleSaveConfiguration"> | |
<time>true</time> | |
<latency>true</latency> | |
<timestamp>true</timestamp> | |
<success>true</success> | |
<label>true</label> | |
<code>true</code> | |
<message>true</message> | |
<threadName>true</threadName> | |
<dataType>true</dataType> | |
<encoding>false</encoding> | |
<assertions>true</assertions> | |
<subresults>true</subresults> | |
<responseData>false</responseData> | |
<samplerData>false</samplerData> | |
<xml>false</xml> | |
<fieldNames>true</fieldNames> | |
<responseHeaders>false</responseHeaders> | |
<requestHeaders>false</requestHeaders> | |
<responseDataOnError>false</responseDataOnError> | |
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage> | |
<assertionsResultsToSave>0</assertionsResultsToSave> | |
<bytes>true</bytes> | |
<sentBytes>true</sentBytes> | |
<url>true</url> | |
<threadCounts>true</threadCounts> | |
<idleTime>true</idleTime> | |
<connectTime>true</connectTime> | |
</value> | |
</objProp> | |
<stringProp name="filename"></stringProp> | |
</ResultCollector> | |
<hashTree/> | |
</hashTree> | |
</hashTree> | |
</jmeterTestPlan> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment