You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by sm...@apache.org on 2020/09/16 15:54:14 UTC
[directory-fortress-core] branch jmeter-add-case created (now
5401fda)
This is an automated email from the ASF dual-hosted git repository.
smckinney pushed a change to branch jmeter-add-case
in repository https://gitbox.apache.org/repos/asf/directory-fortress-core.git.
at 5401fda jmeter add user test case
This branch includes the following new commits:
new 5401fda jmeter add user test case
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[directory-fortress-core] 01/01: jmeter add user test case
Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
smckinney pushed a commit to branch jmeter-add-case
in repository https://gitbox.apache.org/repos/asf/directory-fortress-core.git
commit 5401fdaa61bebf48b4d36212b26a2b8e9635d268
Author: Shawn McKinney <sm...@symas.com>
AuthorDate: Wed Sep 16 10:54:07 2020 -0500
jmeter add user test case
---
README.md | 7 +-
pom.xml | 72 ++++++++++-
.../directory/fortress/core/jmeter/AddUser.java | 144 +++++++++++++++++++++
src/test/jmeter/ftAddUser.jmx | 105 +++++++++++++++
4 files changed, 321 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index 1948f6e..9ed3e4d 100644
--- a/README.md
+++ b/README.md
@@ -830,6 +830,11 @@ ________________________________________________________________________________
mvn -Ploadtest-accel-createsess jmeter:jmeter
```
+ F. Add Users:
+ ```
+ mvn -Ploadtest-fortress-adduser jmeter:jmeter
+ ```
+
The tests will run and produce measurements for throughput and latency.
___________________________________________________________________________________
@@ -857,4 +862,4 @@ use the 'encrypt' ant target.
```
___________________________________________________________________________________
- #### END OF README
\ No newline at end of file
+ #### END OF README
diff --git a/pom.xml b/pom.xml
index ad3802c..9f9f7af 100644
--- a/pom.xml
+++ b/pom.xml
@@ -862,7 +862,7 @@
</profile>
<!-- This profile starts Openldap accelerator checkAccess loadTest -->
- <!-- To execute: ./m.sh -Ploadtest-accel jmeter:jmeter -->
+ <!-- To execute: mvn -Ploadtest-accel jmeter:jmeter -->
<profile>
<id>loadtest-accel</id>
<build>
@@ -915,7 +915,7 @@
</profile>
<!-- This profile starts Fortress core checkAccess loadTest -->
- <!-- To execute: ./m.sh -Ploadtest-fortress jmeter:jmeter -->
+ <!-- To execute: mvn -Ploadtest-fortress jmeter:jmeter -->
<profile>
<id>loadtest-fortress</id>
<build>
@@ -975,7 +975,7 @@
</profile>
<!-- This profile starts Openldap accelerator createSession loadTest -->
- <!-- To execute: ./m.sh -Ploadtest-accel-createsess jmeter:jmeter -->
+ <!-- To execute: mvn -Ploadtest-accel-createsess jmeter:jmeter -->
<profile>
<id>loadtest-accel-createsess</id>
<build>
@@ -1031,7 +1031,7 @@
</profile>
<!-- This profile starts Fortress core checkAccess loadTest -->
- <!-- To execute: ./m.sh -Ploadtest-fortress-createsess jmeter:jmeter -->
+ <!-- To execute: mvn -Ploadtest-fortress-createsess jmeter:jmeter -->
<profile>
<id>loadtest-fortress-createsess</id>
<build>
@@ -1092,7 +1092,7 @@
</profile>
<!-- This profile starts Fortress core sessionPermissions loadTest -->
- <!-- To execute: ./m.sh -Ploadtest-fortress-sessperms jmeter:jmeter -->
+ <!-- To execute: mvn -Ploadtest-fortress-sessperms jmeter:jmeter -->
<profile>
<id>loadtest-fortress-sessperms</id>
<build>
@@ -1152,7 +1152,7 @@
</profile>
<!-- This profile starts Fortress accelerator sessionPermissions loadTest but function not implemented yet! -->
- <!-- To execute: ./m.sh -Ploadtest-accel-sessperms jmeter:jmeter -->
+ <!-- To execute: mvn -Ploadtest-accel-sessperms jmeter:jmeter -->
<profile>
<id>loadtest-accel-sessperms</id>
<build>
@@ -1210,6 +1210,66 @@
</build>
</profile>
+ <!-- This profile starts Fortress core checkAccess loadTest -->
+ <!-- To execute: mvn -Ploadtest-fortress-adduser jmeter:jmeter -->
+ <profile>
+ <id>loadtest-fortress-adduser</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.lazerycode.jmeter</groupId>
+ <artifactId>jmeter-maven-plugin</artifactId>
+ <version>1.10.0</version>
+ <configuration>
+ <overrideRootLogLevel>DEBUG</overrideRootLogLevel>
+ <suppressJMeterOutput>false</suppressJMeterOutput>
+ <testFilesIncluded>
+ <jMeterTestFile>ftAddUser.jmx</jMeterTestFile>
+ </testFilesIncluded>
+ <propertiesSystem>
+ <version>${project.version}</version>
+ </propertiesSystem>
+ <propertiesSystem>
+ <tenant>${tenant}</tenant>
+ </propertiesSystem>
+ </configuration>
+ <executions>
+ <execution>
+ <id>jmeter-tests</id>
+ <goals>
+ <goal>jmeter</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ <version>${version.log4j}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <version>${version.log4j}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.directory.fortress</groupId>
+ <artifactId>fortress-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.directory.fortress</groupId>
+ <artifactId>fortress-core</artifactId>
+ <type>test-jar</type>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
+
<!-- This profile calls ant target init-slapd in build-config.xml script. -->
<!-- To execute: mvn -Pinit-slapd test -->
<profile>
diff --git a/src/test/java/org/apache/directory/fortress/core/jmeter/AddUser.java b/src/test/java/org/apache/directory/fortress/core/jmeter/AddUser.java
new file mode 100644
index 0000000..9bed581
--- /dev/null
+++ b/src/test/java/org/apache/directory/fortress/core/jmeter/AddUser.java
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.fortress.core.jmeter;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.directory.fortress.core.*;
+import org.apache.directory.fortress.core.SecurityException;
+import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
+import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
+import org.apache.jmeter.samplers.SampleResult;
+import org.slf4j.LoggerFactory;
+import org.apache.directory.fortress.core.AdminMgr;
+import org.apache.directory.fortress.core.model.Session;
+import org.apache.directory.fortress.core.impl.TestUtils;
+import org.apache.directory.fortress.core.model.User;
+
+import static org.junit.Assert.*;
+
+/**
+ * Description of the Class
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class AddUser extends AbstractJavaSamplerClient
+{
+ private AdminMgr adminMgr;
+ private static final org.slf4j.Logger LOG = LoggerFactory.getLogger( AddUser.class );
+ private static int count = 0;
+ private int key = 0;
+ private int ctr = 0;
+ //private String userId = "";
+
+ /**
+ * Description of the Method
+ *
+ * @param samplerContext Description of the Parameter
+ * @return Description of the Return Value
+ */
+ public SampleResult runTest( JavaSamplerContext samplerContext )
+ {
+ String userId = "";
+ SampleResult sampleResult = new SampleResult();
+ try
+ {
+ sampleResult.sampleStart();
+ String message = "FT AddUser TID: " + getThreadId() + " UID:" + userId + " CTR:" + ctr++;
+ LOG.info( message );
+ //System.out.println( message );
+ assertNotNull( adminMgr );
+
+ key = getKey();
+ userId = "loadtestuser" + key;
+
+ Session session;
+ User user = new User();
+ // positive test case:
+ user.setUserId( userId );
+ user.setPassword( "secret" );
+ user.setOu( "dev0");
+ User outUser = adminMgr.addUser( user );
+ assertNotNull( outUser );
+ sampleResult.sampleEnd();
+ sampleResult.setBytes(1);
+ sampleResult.setResponseMessage("test completed TID: " + getThreadId() + " UID: " + userId);
+ sampleResult.setSuccessful(true);
+ }
+ catch ( org.apache.directory.fortress.core.SecurityException se )
+ {
+ System.out.println( "ThreadId:" + getThreadId() + "Error running test: " + se );
+ se.printStackTrace();
+ sampleResult.setSuccessful( false );
+ }
+
+ return sampleResult;
+ }
+
+ /**
+ * Description of the Method
+ *
+ * @param samplerContext Description of the Parameter
+ */
+ public void setupTest( JavaSamplerContext samplerContext )
+ {
+ ctr = 0;
+ String message = "FT SETUP AdminMgr TID: " + getThreadId();
+ LOG.info( message );
+ System.out.println( message );
+ try
+ {
+ adminMgr = AdminMgrFactory.createInstance( TestUtils.getContext() );
+ }
+ catch ( SecurityException se )
+ {
+ System.out.println( "ThreadId:" + getThreadId() + "FT SETUP Error: " + se );
+ se.printStackTrace();
+ }
+ }
+
+ /**
+ *
+ * @return
+ */
+ synchronized private int getKey( )
+ {
+ return ++count;
+ }
+ synchronized private String getKey( long threadId )
+ {
+ return threadId + "-" + count++;
+ }
+ private String getThreadId()
+ {
+ return "" + Thread.currentThread().getId();
+ }
+
+ /**
+ * Description of the Method
+ *
+ * @param samplerContext Description of the Parameter
+ */
+ public void teardownTest( JavaSamplerContext samplerContext )
+ {
+ String message = "FT SETUP CreateSession TID: " + getThreadId();
+ LOG.info( message );
+ System.out.println( message );
+ }
+}
diff --git a/src/test/jmeter/ftAddUser.jmx b/src/test/jmeter/ftAddUser.jmx
new file mode 100644
index 0000000..ef41bdb
--- /dev/null
+++ b/src/test/jmeter/ftAddUser.jmx
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<jmeterTestPlan version="1.2" properties="2.6" jmeter="2.11 r1554548">
+ <hashTree>
+ <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="RbacLoadTester" 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">AddUser.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="Fortress CreateSession" 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">10</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="Fortress CheckAccess" enabled="true">
+ <elementProp name="arguments" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" enabled="true">
+ <collectionProp name="Arguments.arguments">
+ <elementProp name="type" elementType="Argument">
+ <stringProp name="Argument.name">type</stringProp>
+ <stringProp name="Argument.value">2</stringProp>
+ <stringProp name="Argument.metadata">=</stringProp>
+ </elementProp>
+ </collectionProp>
+ </elementProp>
+ <stringProp name="classname">org.apache.directory.fortress.core.jmeter.AddUser</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>