You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Manjula Priyantha <ma...@ebuilder.lk> on 2007/07/31 14:03:32 UTC

Using Regular Expression Extractor

Hi All,

 

My goal is to perform following goals;

 

1.	Query a database and fetch user names & passwords
2.	Using resulted user names & passwords, perform a load test

 

I was able to query a Oracle database and get the resulted query. Then used
Regular Expression Extractor to separate results into 2 variables.

Now I want to use those each and every [user name/password] set to perform
my load test, Pls. give me a way to proceed. (I have used "Match No."
parameter in Reg. Ex. Extractor to use one of them, but can't locate the way
of using them one by one)

 

BR,

Manjula   


Re: Using Regular Expression Extractor

Posted by Avishek Daga <av...@gmail.com>.

you could save the results of the select all into a text file
Give that text file to a "cvs data set config" and a thread looping through
all the records in the config file

Try this sample jmx script below:

<----- Start -->
<jmeterTestPlan version="1.2" properties="1.8">
  <hashTree>
    <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test
Plan" enabled="true">
      <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>
      <boolProp name="TestPlan.serialize_threadgroups">true</boolProp>
      <boolProp name="TestPlan.functional_mode">false</boolProp>
      <stringProp name="TestPlan.comments"></stringProp>
    </TestPlan>
    <hashTree>
      <Arguments guiclass="ArgumentsPanel" testclass="Arguments"
testname="globalVariables" enabled="true">
        <collectionProp name="Arguments.arguments">
          <elementProp name="countRows" elementType="Argument">
            <stringProp name="Argument.metadata">=</stringProp>
            <stringProp name="Argument.value">0</stringProp>
            <stringProp name="Argument.name">countRows</stringProp>
          </elementProp>
        </collectionProp>
      </Arguments>
      <hashTree/>
      <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup"
testname="Thread Group" enabled="true">
        <longProp name="ThreadGroup.start_time">1127346244000</longProp>
        <stringProp name="ThreadGroup.delay"></stringProp>
        <stringProp name="ThreadGroup.duration"></stringProp>
        <stringProp name="ThreadGroup.num_threads">1</stringProp>
        <boolProp name="ThreadGroup.scheduler">false</boolProp>
        <elementProp name="ThreadGroup.main_controller"
elementType="LoopController" guiclass="LoopControlPanel"
testclass="LoopController" testname="Loop Controller" enabled="true">
          <stringProp name="LoopController.loops">1</stringProp>
          <boolProp name="LoopController.continue_forever">false</boolProp>
        </elementProp>
        <longProp name="ThreadGroup.end_time">1127346244000</longProp>
        <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
        <stringProp name="ThreadGroup.ramp_time">1</stringProp>
      </ThreadGroup>
      <hashTree>
        <JDBCDataSource guiclass="TestBeanGUI" testclass="JDBCDataSource"
testname="JDBC Connection Configuration" enabled="true">
          <stringProp name="password"></stringProp>
          <stringProp name="timeout">10000</stringProp>
          <stringProp name="checkQuery">Select 1</stringProp>
          <stringProp name="trimInterval">60000</stringProp>
          <boolProp name="autocommit">true</boolProp>
          <stringProp name="poolMax">10</stringProp>
          <stringProp name="driver">com.mysql.jdbc.Driver</stringProp>
          <stringProp name="connectionAge">5000</stringProp>
          <stringProp name="dataSource">mysql</stringProp>
          <boolProp name="keepAlive">true</boolProp>
          <stringProp name="username">root</stringProp>
          <stringProp
name="dbUrl">jdbc:mysql://localhost:3306/todoApp_development</stringProp>
        </JDBCDataSource>
        <hashTree/>
        <JDBCSampler guiclass="TestBeanGUI" testclass="JDBCSampler"
testname="getAllRecords" enabled="true">
          <stringProp name="dataSource">mysql</stringProp>
          <stringProp name="queryType">Select Statement</stringProp>
          <stringProp name="query">select * from todos;</stringProp>
        </JDBCSampler>
        <hashTree>
          <BeanShellListener guiclass="TestBeanGUI"
testclass="BeanShellListener" testname="SaveRecordsTofile" enabled="true">
            <stringProp name="script">
   try {
      FileWriter responseFile = new FileWriter(
&quot;database_response.txt&quot;);

String response = sampleResult.getResponseDataAsString();
log.info(&quot;response = &quot; + sampleResult.getResponseDataAsString());
log.info(&quot;countRows = &quot; + vars.get(&quot;countRows&quot;));

      responseFile.write(response);
      responseFile.close();
   } catch (IOException io) {
      log.error(&quot;Problem writing to response file &quot; +responseFile,
io);
   }
</stringProp>
          </BeanShellListener>
          <hashTree/>
        </hashTree>
        <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup"
testname="RunForEachRecord" enabled="true">
          <longProp name="ThreadGroup.start_time">1127346244000</longProp>
          <stringProp name="ThreadGroup.delay"></stringProp>
          <stringProp name="ThreadGroup.duration"></stringProp>
          <stringProp name="ThreadGroup.num_threads">1</stringProp>
          <boolProp name="ThreadGroup.scheduler">false</boolProp>
          <elementProp name="ThreadGroup.main_controller"
elementType="LoopController" guiclass="LoopControlPanel"
testclass="LoopController" testname="Loop Controller" enabled="true">
            <stringProp name="LoopController.loops">1</stringProp>
            <boolProp
name="LoopController.continue_forever">false</boolProp>
          </elementProp>
          <longProp name="ThreadGroup.end_time">1127346244000</longProp>
          <stringProp
name="ThreadGroup.on_sample_error">continue</stringProp>
          <stringProp name="ThreadGroup.ramp_time">1</stringProp>
        </ThreadGroup>
        <hashTree>
          <CSVDataSet guiclass="TestBeanGUI" testclass="CSVDataSet"
testname="CSV Data Set Config" enabled="true">
            <stringProp name="delimiter">\t</stringProp>
            <stringProp name="variableNames">id1,name1,user_id1</stringProp>
            <boolProp name="recycle">false</boolProp>
            <stringProp name="filename">G:\Installers and
Softwares\jakarta-jmeter-2.2\bin\database_response.txt</stringProp>
          </CSVDataSet>
          <hashTree/>
          <LoopController guiclass="LoopControlPanel"
testclass="LoopController" testname="Loop Controller" enabled="true">
            <stringProp name="LoopController.loops">1</stringProp>
            <boolProp name="LoopController.continue_forever">true</boolProp>
          </LoopController>
          <hashTree>
            <HTTPSampler guiclass="HttpTestSampleGui"
testclass="HTTPSampler" testname="HTTP Request" enabled="true">
              <stringProp name="HTTPSampler.path">check</stringProp>
              <stringProp name="HTTPSampler.method">GET</stringProp>
              <boolProp name="HTTPSampler.use_keepalive">true</boolProp>
              <stringProp name="HTTPSampler.protocol"></stringProp>
              <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
              <stringProp name="HTTPSampler.port"></stringProp>
              <elementProp name="HTTPsampler.Arguments"
elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments"
testname="User Defined Variables" enabled="true">
                <collectionProp name="Arguments.arguments">
                  <elementProp name="" elementType="HTTPArgument">
                    <stringProp name="Argument.metadata">=</stringProp>
                    <stringProp name="Argument.value">${id1}</stringProp>
                    <boolProp name="HTTPArgument.use_equals">true</boolProp>
                    <stringProp name="Argument.name">id</stringProp>
                    <boolProp
name="HTTPArgument.always_encode">false</boolProp>
                  </elementProp>
                  <elementProp name="" elementType="HTTPArgument">
                    <stringProp name="Argument.metadata">=</stringProp>
                    <stringProp name="Argument.value">${name1}</stringProp>
                    <boolProp name="HTTPArgument.use_equals">true</boolProp>
                    <stringProp name="Argument.name">name</stringProp>
                    <boolProp
name="HTTPArgument.always_encode">false</boolProp>
                  </elementProp>
                  <elementProp name="" elementType="HTTPArgument">
                    <stringProp name="Argument.metadata">=</stringProp>
                    <stringProp
name="Argument.value">${user_id1}</stringProp>
                    <boolProp name="HTTPArgument.use_equals">true</boolProp>
                    <stringProp name="Argument.name">user_id</stringProp>
                    <boolProp
name="HTTPArgument.always_encode">false</boolProp>
                  </elementProp>
                </collectionProp>
              </elementProp>
              <stringProp name="HTTPSampler.mimetype"></stringProp>
              <stringProp name="HTTPSampler.FILE_FIELD"></stringProp>
              <stringProp name="HTTPSampler.monitor">false</stringProp>
              <stringProp name="HTTPSampler.domain">localhost</stringProp>
              <stringProp name="HTTPSampler.FILE_NAME"></stringProp>
              <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
            </HTTPSampler>
            <hashTree/>
          </hashTree>
        </hashTree>
      </hashTree>
      <ResultCollector guiclass="ViewResultsFullVisualizer"
testclass="ResultCollector" testname="View Results Tree" enabled="true">
        <objProp>
          <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>true</responseData>
            <samplerData>false</samplerData>
            <xml>false</xml>
            <fieldNames>false</fieldNames>
            <responseHeaders>false</responseHeaders>
            <requestHeaders>false</requestHeaders>
            <responseDataOnError>true</responseDataOnError>
           
<saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
            <assertionsResultsToSave>0</assertionsResultsToSave>
          </value>
          <name>saveConfig</name>
        </objProp>
        <stringProp name="filename"></stringProp>
        <boolProp name="ResultCollector.error_logging">false</boolProp>
      </ResultCollector>
      <hashTree/>
    </hashTree>
  </hashTree>
</jmeterTestPlan>

<----- End --->

Regards,
Avishek


Manjula Priyantha-2 wrote:
> 
> Hi All,
> 
>  
> 
> My goal is to perform following goals;
> 
>  
> 
> 1.	Query a database and fetch user names & passwords
> 2.	Using resulted user names & passwords, perform a load test
> 
>  
> 
> I was able to query a Oracle database and get the resulted query. Then
> used
> Regular Expression Extractor to separate results into 2 variables.
> 
> Now I want to use those each and every [user name/password] set to perform
> my load test, Pls. give me a way to proceed. (I have used "Match No."
> parameter in Reg. Ex. Extractor to use one of them, but can't locate the
> way
> of using them one by one)
> 
>  
> 
> BR,
> 
> Manjula   
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Using-Regular-Expression-Extractor-tf4192598.html#a11923527
Sent from the JMeter - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org