Commit 8c30471b authored by Shawn McKinney's avatar Shawn McKinney
Browse files

+ mod user test

parent 4074a371
/* Copyright (c) 2021 by Symas Corporation. */
package com.symas;
import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.directory.fortress.core.model.User;
import java.sql.Timestamp;
import static org.junit.Assert.*;
/**
* Modifies LDAP users
* @author smckinney
* @created Nov 22, 2021
*/
public class ModUser extends LoadBase
{
/**
* Description of the Method
*
* @param samplerContext Description of the Parameter
* @return Description of the Return Value
*/
public SampleResult runTest( JavaSamplerContext samplerContext )
{
int count = getKey();
String userId = hostname + '-' + qualifier + '-' + count;
SampleResult sampleResult = new SampleResult();
try
{
sampleResult.sampleStart();
User user = new User();
user.setUserId( userId );
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
user.setDescription( "mod once: " + user.getUserId() + ": " + timestamp);
write( "threadid: " + getThreadId() + ", userId: " + userId );
User outUser = userImpl.update( user );
assertNotNull( outUser );
// This tests replication, ability to handle conflicts:
if ( duplicate > 0 && count > duplicate && ( count % duplicate ) == 0 )
{
warn( "DUPLICATE Mod[" + count + "]: " + user.getUserId() );
user.setDescription( "mod twice: " + user.getUserId() + ": " + timestamp);
outUser = userImpl.update( user );
assertNotNull( outUser );
}
if( sleep > 0 )
{
try
{
Thread.sleep( sleep );
}
catch (InterruptedException ie)
{
Thread.currentThread().interrupt();
}
}
sampleResult.setSampleCount( 1 );
sampleResult.sampleEnd();
sampleResult.setBytes(1);
sampleResult.setResponseMessage("test completed TID: " + getThreadId() + " UID: " + userId);
sampleResult.setSuccessful(true);
}
catch ( org.apache.directory.fortress.core.SecurityException se )
{
warn( "ThreadId: " + getThreadId() + ", error running test: " + se );
se.printStackTrace();
sampleResult.setSuccessful( false );
}
return sampleResult;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (c) 2021 by Symas Corporation. -->
<jmeterTestPlan version="1.2" properties="2.6" jmeter="2.11 r1554548">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="LdapLoadGen" enabled="true">
<stringProp name="TestPlan.comments"></stringProp>
<boolProp name="TestPlan.functional_mode">false</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">../../../config</stringProp>
</TestPlan>
<hashTree>
<CSVDataSet guiclass="TestBeanGUI" testclass="CSVDataSet" testname="CSV Data Set Config" enabled="false">
<stringProp name="delimiter">,</stringProp>
<stringProp name="fileEncoding"></stringProp>
<stringProp name="filename">ModUser.csv</stringProp>
<boolProp name="quotedData">false</boolProp>
<boolProp name="recycle">true</boolProp>
<stringProp name="shareMode">shareMode.all</stringProp>
<boolProp name="stopThread">false</boolProp>
<stringProp name="variableNames"></stringProp>
</CSVDataSet>
<hashTree/>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Mod User" 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">1000</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">10</stringProp>
<stringProp name="ThreadGroup.ramp_time">10</stringProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
</ThreadGroup>
<hashTree>
<JavaSampler guiclass="JavaTestSamplerGui" testclass="JavaSampler" testname="Mod User" enabled="true">
<elementProp name="arguments" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" enabled="true">
<collectionProp name="Arguments.arguments">
<elementProp name="qualifier" elementType="Argument">
<stringProp name="Argument.name">qualifier</stringProp>
<stringProp name="Argument.value">Z</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="output" elementType="Argument">
<stringProp name="Argument.name">output</stringProp>
<stringProp name="Argument.value">false</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="sleep" elementType="Argument">
<stringProp name="Argument.name">sleep</stringProp>
<stringProp name="Argument.value">0</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="password" elementType="Argument">
<stringProp name="Argument.name">password</stringProp>
<stringProp name="Argument.value">secret</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
</collectionProp>
</elementProp>
<stringProp name="classname">com.symas.ModUser</stringProp>
</JavaSampler>
<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>true</xml>
<fieldNames>false</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
</value>
</objProp>
<stringProp name="filename"></stringProp>
</ResultCollector>
<hashTree/>
</hashTree>
</hashTree>
</hashTree>
</jmeterTestPlan>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment