Skip to content
Permalink
Browse files
test case for replication conflict managment
  • Loading branch information
shawnmckinney committed May 5, 2021
1 parent 7caee62 commit 9891c753d996eb59080c049a1f6a67dc90e0294a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
@@ -34,7 +34,6 @@
*/
public class AddUser extends UserBase
{
private int ctr = 0;

/**
* Description of the Method
@@ -44,19 +43,27 @@ public class AddUser extends UserBase
*/
public SampleResult runTest( JavaSamplerContext samplerContext )
{
String userId = hostname + '-' + qualifier + '-' + getKey();
int count = getKey();
String userId = hostname + '-' + qualifier + '-' + count;
SampleResult sampleResult = new SampleResult();
try
{
sampleResult.sampleStart();
assertNotNull( adminMgr );
User user = new User();
user.setUserId( userId );
user.setDescription( "add one: " + user.getUserId() );
user.setPassword( "secret" );
user.setOu( ou );
write( "threadid: " + getThreadId() + ", userId: " + userId );
User outUser = adminMgr.addUser( user );
assertNotNull( outUser );
// This tests replication, ability to handle conflicts:
if ( duplicate > 0 && duplicate % count == 0 )
{
user.setDescription( "add two: " + user.getUserId() );
outUser = adminMgr.addUser( user );
}
if( update )
{
user.setDescription( "updated: " + user.getUserId() );
@@ -63,6 +63,7 @@ public abstract class UserBase extends AbstractJavaSamplerClient
protected String ou = null;
protected int sleep = 0;
protected int size = 0;
protected int duplicate = 0;
private PrintWriter printWriter;

protected enum Op
@@ -106,7 +107,7 @@ protected boolean verify( String userId, Op op )
public void setupTest( JavaSamplerContext samplerContext )
{
init( samplerContext );
String message = "FT SETUP User TID: " + getThreadId() + ", hostname: " + hostname + ", qualifier: " + qualifier + ", verify: " + verify + ", sleep: " + sleep;
String message = "FT SETUP User TID: " + getThreadId() + ", hostname: " + hostname + ", qualifier: " + qualifier + ", verify: " + verify + ", sleep: " + sleep + ", duplicate: " + duplicate;
info( message );
try
{
@@ -188,7 +189,7 @@ private void init( JavaSamplerContext samplerContext )
}
if (!StringUtils.isEmpty( szSleep ))
{
sleep = Integer.valueOf(szSleep);
sleep = Integer.valueOf( szSleep );
}
String szSize = System.getProperty( "size" );
if (StringUtils.isEmpty( szSize ))
@@ -199,6 +200,16 @@ private void init( JavaSamplerContext samplerContext )
{
size = Integer.valueOf(szSize);
}
String szDuplicate = System.getProperty( "duplicate" );
if (StringUtils.isEmpty( szDuplicate ))
{
szDuplicate = samplerContext.getParameter( "duplicate" );
}
if (!StringUtils.isEmpty( szDuplicate ))
{
duplicate = Integer.valueOf(szDuplicate);
}

filename = "operations" + '-' + "thread" + getThreadId() + '-' + hostname + '-' + qualifier + ".txt";
open();
}
@@ -94,6 +94,12 @@
<stringProp name="Argument.value">jmeterrole</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="duplicate" elementType="Argument">
<stringProp name="Argument.name">duplicate</stringProp>
<!-- Use one from JmeterTestPolicy.xml -->
<stringProp name="Argument.value">10000</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
</collectionProp>
</elementProp>
<stringProp name="classname">org.apache.directory.fortress.core.jmeter.AddUser</stringProp>

0 comments on commit 9891c75

Please sign in to comment.