diff options
author | Lianhao Lu <lianhao.lu@intel.com> | 2018-11-07 17:59:37 +0800 |
---|---|---|
committer | Lianhao Lu <lianhao.lu@intel.com> | 2018-11-09 08:52:35 +0800 |
commit | c1647ba56080a79d149b2e9fd647bda4da39997e (patch) | |
tree | b210de14bfc96f5d34a7c13e60841b1fa823245e /s3p/perf.jmx | |
parent | de0e18b974cb40cbbfac1accdc7d4b460ccd4186 (diff) |
Added JMeter scripts for perf test
Change-Id: I4286c6defdef331ee5c40399d17381d3c8b8a544
Issue-ID: POLICY-836
Signed-off-by: Lianhao Lu <lianhao.lu@intel.com>
Diffstat (limited to 's3p/perf.jmx')
-rw-r--r-- | s3p/perf.jmx | 407 |
1 files changed, 407 insertions, 0 deletions
diff --git a/s3p/perf.jmx b/s3p/perf.jmx new file mode 100644 index 00000000..ac934776 --- /dev/null +++ b/s3p/perf.jmx @@ -0,0 +1,407 @@ +<?xml version="1.0" encoding="UTF-8"?> +<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.0 r1840935"> + <hashTree> + <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="perf 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 name="PDP_HOST" elementType="Argument"> + <stringProp name="Argument.name">PDP_HOST</stringProp> + <stringProp name="Argument.value">${__P(host,pdp)}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> + <elementProp name="RETRY" elementType="Argument"> + <stringProp name="Argument.name">RETRY</stringProp> + <stringProp name="Argument.value">${__P(retry, 100)}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> + <elementProp name="PERF_DATA" elementType="Argument"> + <stringProp name="Argument.name">PERF_DATA</stringProp> + <stringProp name="Argument.value">${__P(perf_data, perf_data.csv)}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> + <elementProp name="BASE_DIR" elementType="Argument"> + <stringProp name="Argument.name">BASE_DIR</stringProp> + <stringProp name="Argument.value">${__BeanShell(import org.apache.jmeter.services.FileServer; FileServer.getFileServer().getBaseDir();)}${__BeanShell(File.separator,)}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> + <elementProp name="CSAR_DIR" elementType="Argument"> + <stringProp name="Argument.name">CSAR_DIR</stringProp> + <stringProp name="Argument.value">${__P(csardir, /tmp/policy_distribution/csar)}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> + <elementProp name="TOTAL" elementType="Argument"> + <stringProp name="Argument.name">TOTAL</stringProp> + <stringProp name="Argument.value">${__P(total, 5)}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> + </collectionProp> + </elementProp> + <stringProp name="TestPlan.user_define_classpath"></stringProp> + </TestPlan> + <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">${DURATION}</stringProp> + <stringProp name="ThreadGroup.delay">1</stringProp> + </ThreadGroup> + <hashTree> + <HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="GET_POLICY_HTTP_HEADER" enabled="true"> + <collectionProp name="HeaderManager.headers"> + <elementProp name="" elementType="Header"> + <stringProp name="Header.name">Content-Type</stringProp> + <stringProp name="Header.value">application/json</stringProp> + </elementProp> + <elementProp name="" elementType="Header"> + <stringProp name="Header.name">Accept</stringProp> + <stringProp name="Header.value">application/json</stringProp> + </elementProp> + <elementProp name="" elementType="Header"> + <stringProp name="Header.name">ClientAuth</stringProp> + <stringProp name="Header.value">cHl0aG9uOnRlc3Q=</stringProp> + </elementProp> + <elementProp name="" elementType="Header"> + <stringProp name="Header.name">Authorization</stringProp> + <stringProp name="Header.value">Basic dGVzdHBkcDphbHBoYTEyMw==</stringProp> + </elementProp> + <elementProp name="" elementType="Header"> + <stringProp name="Header.name">Environment</stringProp> + <stringProp name="Header.value">TEST</stringProp> + </elementProp> + </collectionProp> + </HeaderManager> + <hashTree/> + <GenericController guiclass="LogicControllerGui" testclass="GenericController" testname="check if existing policy" enabled="true"/> + <hashTree> + <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="list_policy" enabled="true"> + <boolProp name="HTTPSampler.postBodyRaw">true</boolProp> + <elementProp name="HTTPsampler.Arguments" elementType="Arguments"> + <collectionProp name="Arguments.arguments"> + <elementProp name="" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">false</boolProp> + <stringProp name="Argument.value">{"policyName": "oofCasablanca.*s3p.*"}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> + </collectionProp> + </elementProp> + <stringProp name="HTTPSampler.domain">${PDP_HOST}</stringProp> + <stringProp name="HTTPSampler.port">8081</stringProp> + <stringProp name="HTTPSampler.protocol">https</stringProp> + <stringProp name="HTTPSampler.contentEncoding"></stringProp> + <stringProp name="HTTPSampler.path">/pdp/api/listConfig</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.connect_timeout"></stringProp> + <stringProp name="HTTPSampler.response_timeout"></stringProp> + </HTTPSamplerProxy> + <hashTree> + <JSR223PostProcessor guiclass="TestBeanGUI" testclass="JSR223PostProcessor" testname="JSR223 PostProcessor" enabled="true"> + <stringProp name="scriptLanguage">groovy</stringProp> + <stringProp name="parameters"></stringProp> + <stringProp name="filename"></stringProp> + <stringProp name="cacheKey">true</stringProp> + <stringProp name="script">import groovy.json.JsonSlurper; + +def to_delete = []; +if (prev.getResponseCode() == '200') { + def jsonSlurper = new JsonSlurper(); + to_delete = jsonSlurper.parseText(prev.getResponseDataAsString()); +} +vars.putObject('to_delete', to_delete); +</stringProp> + </JSR223PostProcessor> + <hashTree/> + </hashTree> + <WhileController guiclass="WhileControllerGui" testclass="WhileController" testname="While Controller" enabled="true"> + <stringProp name="WhileController.condition">${__groovy(vars.getObject('to_delete').size() > 0)}</stringProp> + </WhileController> + <hashTree> + <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="delete_policy_pdp" enabled="true"> + <boolProp name="HTTPSampler.postBodyRaw">true</boolProp> + <elementProp name="HTTPsampler.Arguments" elementType="Arguments"> + <collectionProp name="Arguments.arguments"> + <elementProp name="" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">false</boolProp> + <stringProp name="Argument.value">{
 + "pdpGroup": "default",
 + "policyComponent": "PDP",
 + "policyType": "Optimization",
 + "policyName": "${policyname}"
 +}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> + </collectionProp> + </elementProp> + <stringProp name="HTTPSampler.domain">${PDP_HOST}</stringProp> + <stringProp name="HTTPSampler.port">8081</stringProp> + <stringProp name="HTTPSampler.protocol">https</stringProp> + <stringProp name="HTTPSampler.contentEncoding"></stringProp> + <stringProp name="HTTPSampler.path">/pdp/api/deletePolicy</stringProp> + <stringProp name="HTTPSampler.method">DELETE</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.connect_timeout"></stringProp> + <stringProp name="HTTPSampler.response_timeout"></stringProp> + </HTTPSamplerProxy> + <hashTree> + <JSR223PreProcessor guiclass="TestBeanGUI" testclass="JSR223PreProcessor" testname="JSR223 PreProcessor" enabled="true"> + <stringProp name="scriptLanguage">groovy</stringProp> + <stringProp name="parameters"></stringProp> + <stringProp name="filename"></stringProp> + <stringProp name="cacheKey">true</stringProp> + <stringProp name="script">def to_delete = vars.getObject('to_delete'); +def policyname = to_delete.pop() +vars.put('policyname', policyname.toString()); +vars.putObject('to_delete', to_delete); +</stringProp> + </JSR223PreProcessor> + <hashTree/> + </hashTree> + <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="delete_policy_pap" enabled="true"> + <boolProp name="HTTPSampler.postBodyRaw">true</boolProp> + <elementProp name="HTTPsampler.Arguments" elementType="Arguments"> + <collectionProp name="Arguments.arguments"> + <elementProp name="" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">false</boolProp> + <stringProp name="Argument.value">{
 + "deleteCondition":"ALL",
 + "policyComponent": "PAP",
 + "policyType": "Optimization",
 + "policyName": "${policyname}"
 +}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> + </collectionProp> + </elementProp> + <stringProp name="HTTPSampler.domain">${PDP_HOST}</stringProp> + <stringProp name="HTTPSampler.port">8081</stringProp> + <stringProp name="HTTPSampler.protocol">https</stringProp> + <stringProp name="HTTPSampler.contentEncoding"></stringProp> + <stringProp name="HTTPSampler.path">/pdp/api/deletePolicy</stringProp> + <stringProp name="HTTPSampler.method">DELETE</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.connect_timeout"></stringProp> + <stringProp name="HTTPSampler.response_timeout"></stringProp> + </HTTPSamplerProxy> + <hashTree/> + </hashTree> + </hashTree> + <GenericController guiclass="LogicControllerGui" testclass="GenericController" testname="prepare_perf_data" enabled="true"/> + <hashTree> + <SystemSampler guiclass="SystemSamplerGui" testclass="SystemSampler" testname="OS Process Sampler" enabled="true"> + <boolProp name="SystemSampler.checkReturnCode">false</boolProp> + <stringProp name="SystemSampler.expectedReturnCode">0</stringProp> + <stringProp name="SystemSampler.command">${BASE_DIR}generate_perf.sh</stringProp> + <elementProp name="SystemSampler.arguments" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true"> + <collectionProp name="Arguments.arguments"> + <elementProp name="" elementType="Argument"> + <stringProp name="Argument.name"></stringProp> + <stringProp name="Argument.value">${CSAR_DIR}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> + <elementProp name="" elementType="Argument"> + <stringProp name="Argument.name"></stringProp> + <stringProp name="Argument.value">${TOTAL}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> + </collectionProp> + </elementProp> + <elementProp name="SystemSampler.environment" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true"> + <collectionProp name="Arguments.arguments"/> + </elementProp> + <stringProp name="SystemSampler.directory"></stringProp> + </SystemSampler> + <hashTree/> + <JSR223Sampler guiclass="TestBeanGUI" testclass="JSR223Sampler" testname="Load_all_data" enabled="true"> + <stringProp name="cacheKey">true</stringProp> + <stringProp name="filename"></stringProp> + <stringProp name="parameters"></stringProp> + <stringProp name="script">def data_file=new File(vars.get('BASE_DIR') + vars.get('PERF_DATA')); +def data=data_file.readLines(); +def total=data.size(); + +vars.putObject('data', data); +vars.putObject('total', total); +vars.putObject('idx', 0); +vars.putObject('total_counter', vars.get('RETRY').toInteger() * total); + +SampleResult.setIgnore();</stringProp> + <stringProp name="scriptLanguage">groovy</stringProp> + </JSR223Sampler> + <hashTree/> + </hashTree> + <TransactionController guiclass="TransactionControllerGui" testclass="TransactionController" testname="verify policy created" enabled="true"> + <boolProp name="TransactionController.includeTimers">false</boolProp> + <boolProp name="TransactionController.parent">true</boolProp> + </TransactionController> + <hashTree> + <Arguments guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true"> + <collectionProp name="Arguments.arguments"> + <elementProp name="innter_counter" elementType="Argument"> + <stringProp name="Argument.name">innter_counter</stringProp> + <stringProp name="Argument.value">1</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> + <elementProp name="rescode" elementType="Argument"> + <stringProp name="Argument.name">rescode</stringProp> + <stringProp name="Argument.value"></stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> + <elementProp name="counter" elementType="Argument"> + <stringProp name="Argument.name">counter</stringProp> + <stringProp name="Argument.value">1</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> + </collectionProp> + </Arguments> + <hashTree/> + <WhileController guiclass="WhileControllerGui" testclass="WhileController" testname="OUTER" enabled="true"> + <stringProp name="WhileController.condition">${__javaScript(${counter} < ${total_counter} && ${idx} < ${total})}</stringProp> + </WhileController> + <hashTree> + <JSR223Sampler guiclass="TestBeanGUI" testclass="JSR223Sampler" testname="Reset_Inner_Loop" enabled="true"> + <stringProp name="scriptLanguage">groovy</stringProp> + <stringProp name="parameters"></stringProp> + <stringProp name="filename"></stringProp> + <stringProp name="cacheKey">true</stringProp> + <stringProp name="script">//log.info("idx: " + vars.getObject('idx')); +//log.info("counter: " + vars.get('counter')); +//log.info("total_counter: " + vars.get('total_counter')); + +vars.putObject('inner_counter', 0); +vars.put('rescode', ""); + +SampleResult.setIgnore();</stringProp> + </JSR223Sampler> + <hashTree/> + <WhileController guiclass="WhileControllerGui" testclass="WhileController" testname="INNER" enabled="true"> + <stringProp name="WhileController.condition">${__javaScript(${inner_counter} < ${RETRY} && "${rescode}" != '200')}</stringProp> + </WhileController> + <hashTree> + <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Get_Policy" enabled="true"> + <boolProp name="HTTPSampler.postBodyRaw">true</boolProp> + <elementProp name="HTTPsampler.Arguments" elementType="Arguments"> + <collectionProp name="Arguments.arguments"> + <elementProp name="" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">false</boolProp> + <stringProp name="Argument.value">{"policyName": "oofCasablanca.*${resid}.*"}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + </elementProp> + </collectionProp> + </elementProp> + <stringProp name="HTTPSampler.domain">${PDP_HOST}</stringProp> + <stringProp name="HTTPSampler.port">8081</stringProp> + <stringProp name="HTTPSampler.protocol">https</stringProp> + <stringProp name="HTTPSampler.contentEncoding"></stringProp> + <stringProp name="HTTPSampler.path">/pdp/api/getConfig</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.connect_timeout"></stringProp> + <stringProp name="HTTPSampler.response_timeout"></stringProp> + </HTTPSamplerProxy> + <hashTree> + <JSR223PreProcessor guiclass="TestBeanGUI" testclass="JSR223PreProcessor" testname="JSR223 PreProcessor" enabled="true"> + <stringProp name="scriptLanguage">groovy</stringProp> + <stringProp name="parameters"></stringProp> + <stringProp name="filename"></stringProp> + <stringProp name="cacheKey">true</stringProp> + <stringProp name="script">def idx=vars.getObject('idx'); +def data=vars.getObject('data'); + +vars.put('resid', data[idx]); +//log.error(data[idx]); +</stringProp> + </JSR223PreProcessor> + <hashTree/> + <JSR223PostProcessor guiclass="TestBeanGUI" testclass="JSR223PostProcessor" testname="JSR223 PostProcessor" enabled="true"> + <stringProp name="cacheKey">true</stringProp> + <stringProp name="filename"></stringProp> + <stringProp name="parameters"></stringProp> + <stringProp name="script">def rescode = prev.getResponseCode(); +def idx=vars.getObject('idx'); +def total=vars.getObject('total'); +def inner_counter=vars.getObject('inner_counter'); + +vars.put('rescode', rescode); +//log.info('inner_counter: ' + inner_counter); +//log.info('idx: '+ idx); + +inner_counter += 1; +vars.putObject('inner_counter', inner_counter); + +if (rescode == '200'){ + idx += 1; + vars.putObject('idx', idx); +}else { + +} +</stringProp> + <stringProp name="scriptLanguage">groovy</stringProp> + </JSR223PostProcessor> + <hashTree/> + </hashTree> + <CounterConfig guiclass="CounterConfigGui" testclass="CounterConfig" testname="Counter" enabled="true"> + <stringProp name="CounterConfig.start">1</stringProp> + <stringProp name="CounterConfig.end"></stringProp> + <stringProp name="CounterConfig.incr">1</stringProp> + <stringProp name="CounterConfig.name">counter</stringProp> + <stringProp name="CounterConfig.format"></stringProp> + <boolProp name="CounterConfig.per_user">true</boolProp> + <boolProp name="CounterConfig.reset_on_tg_iteration">true</boolProp> + </CounterConfig> + <hashTree/> + </hashTree> + </hashTree> + </hashTree> + <GenericController guiclass="LogicControllerGui" testclass="GenericController" testname="final_check" enabled="true"/> + <hashTree> + <JSR223Sampler guiclass="TestBeanGUI" testclass="JSR223Sampler" testname="final_check" enabled="true"> + <stringProp name="scriptLanguage">groovy</stringProp> + <stringProp name="parameters"></stringProp> + <stringProp name="filename"></stringProp> + <stringProp name="cacheKey">true</stringProp> + <stringProp name="script">def idx=vars.getObject('idx'); +def total=vars.getObject('total'); + +if (idx<total) { + SampleResult.setSuccessful(false); + SampleResult.setResponseCode("410"); + SampleResult.setResponseMessage("Fail at idx " + idx); +}else { + SampleResult.setSuccessful(true); + SampleResult.setResponseCode("200"); + SampleResult.setResponseMessage("Success"); +} +</stringProp> + </JSR223Sampler> + <hashTree/> + </hashTree> + </hashTree> + </hashTree> + </hashTree> +</jmeterTestPlan> |