You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by an...@apache.org on 2016/05/13 13:36:12 UTC
svn commit: r1743674 - in /jackrabbit/oak/trunk/oak-run: ./
src/main/java/org/apache/jackrabbit/oak/benchmark/
src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/
src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/external/
Author: angela
Date: Fri May 13 13:36:12 2016
New Revision: 1743674
URL: http://svn.apache.org/viewvc?rev=1743674&view=rev
Log:
OAK-4364 : Initial Benchmarks for oak-auth-external
Added:
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/external/
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/external/AbstractExternalTest.java
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/external/ExternalLoginTest.java
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/external/SyncAllExternalUsersTest.java
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/external/SyncExternalUsersTest.java
Modified:
jackrabbit/oak/trunk/oak-run/pom.xml
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
Modified: jackrabbit/oak/trunk/oak-run/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/pom.xml?rev=1743674&r1=1743673&r2=1743674&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-run/pom.xml Fri May 13 13:36:12 2016
@@ -282,6 +282,11 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>oak-auth-external</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
<version>7.0.64</version>
Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java?rev=1743674&r1=1743673&r2=1743674&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java (original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java Fri May 13 13:36:12 2016
@@ -42,7 +42,7 @@ import org.slf4j.LoggerFactory;
/**
* Abstract base class for individual performance benchmarks.
*/
-abstract class AbstractTest<T> extends Benchmark implements CSVResultGenerator {
+public abstract class AbstractTest<T> extends Benchmark implements CSVResultGenerator {
/**
* A random string to guarantee concurrently running tests don't overwrite
Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java?rev=1743674&r1=1743673&r2=1743674&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java (original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java Fri May 13 13:36:12 2016
@@ -32,6 +32,9 @@ import joptsimple.OptionParser;
import joptsimple.OptionSet;
import joptsimple.OptionSpec;
import org.apache.commons.io.FileUtils;
+import org.apache.jackrabbit.oak.benchmark.authentication.external.ExternalLoginTest;
+import org.apache.jackrabbit.oak.benchmark.authentication.external.SyncAllExternalUsersTest;
+import org.apache.jackrabbit.oak.benchmark.authentication.external.SyncExternalUsersTest;
import org.apache.jackrabbit.oak.benchmark.wikipedia.WikipediaImport;
import org.apache.jackrabbit.oak.fixture.JackrabbitRepositoryFixture;
import org.apache.jackrabbit.oak.fixture.OakFixture;
@@ -381,7 +384,12 @@ public class BenchmarkRunner {
wikipedia.value(options),
flatStructure.value(options),
report.value(options), withStorage.value(options)),
- new ReplicaCrashResilienceTest()
+ new ReplicaCrashResilienceTest(),
+
+ // benchmarks for oak-auth-external
+ new ExternalLoginTest(numberOfUsers.value(options), numberOfGroups.value(options), expiration.value(options), false),
+ new SyncAllExternalUsersTest(numberOfUsers.value(options), numberOfGroups.value(options), expiration.value(options), false),
+ new SyncExternalUsersTest(numberOfUsers.value(options), numberOfGroups.value(options), expiration.value(options), false, batchSize.value(options))
};
Set<String> argset = Sets.newHashSet(nonOption.values(options));
Added: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/external/AbstractExternalTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/external/AbstractExternalTest.java?rev=1743674&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/external/AbstractExternalTest.java (added)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/external/AbstractExternalTest.java Fri May 13 13:36:12 2016
@@ -0,0 +1,321 @@
+/*
+ * 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.jackrabbit.oak.benchmark.authentication.external;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
+import javax.jcr.Credentials;
+import javax.jcr.Repository;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+import javax.security.auth.login.Configuration;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import org.apache.jackrabbit.oak.Oak;
+import org.apache.jackrabbit.oak.benchmark.AbstractTest;
+import org.apache.jackrabbit.oak.fixture.JcrCreator;
+import org.apache.jackrabbit.oak.fixture.OakRepositoryFixture;
+import org.apache.jackrabbit.oak.fixture.RepositoryFixture;
+import org.apache.jackrabbit.oak.jcr.Jcr;
+import org.apache.jackrabbit.oak.security.SecurityProviderImpl;
+import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters;
+import org.apache.jackrabbit.oak.spi.security.SecurityProvider;
+import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup;
+import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity;
+import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityException;
+import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityProvider;
+import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityProviderManager;
+import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef;
+import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser;
+import org.apache.jackrabbit.oak.spi.security.authentication.external.SyncHandler;
+import org.apache.jackrabbit.oak.spi.security.authentication.external.SyncManager;
+import org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncConfig;
+import org.apache.jackrabbit.oak.spi.security.authentication.external.impl.DefaultSyncHandler;
+import org.apache.jackrabbit.oak.spi.security.authentication.external.impl.ExternalIDPManagerImpl;
+import org.apache.jackrabbit.oak.spi.security.authentication.external.impl.SyncManagerImpl;
+import org.apache.jackrabbit.oak.spi.security.user.UserConstants;
+import org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard;
+
+/**
+ * Base benchmark test for external authentication.
+ *
+ * The setup currently defines the following configuration options:
+ *
+ * - {@code numberofUsers} : number of user accounts that are 'known' to the IDP
+ * - {@code numberofGroups}: number of groups 'known' to the IDP and equally used to define the membershipSize of each user.
+ * - {@code expirationTime}: expiration time as set with
+ * {@link DefaultSyncConfig.Authorizable#setExpirationTime(long)}, used for both users and groups
+ * - {@code dynamicMembership}: boolean flag to enable dynamic membership (see OAK-4101)
+ *
+ * Note: by default the {@link DefaultSyncConfig.User#setMembershipNestingDepth(long)}
+ * is set to 1 and each user will become member of each of the groups as defined
+ * by {@code numberofGroups}.
+ */
+abstract class AbstractExternalTest extends AbstractTest {
+
+ private static final String PATH_PREFIX = "pathPrefix";
+ final DefaultSyncConfig syncConfig = new DefaultSyncConfig();
+ final SyncHandler syncHandler = new DefaultSyncHandler(syncConfig);
+
+ final ExternalIdentityProvider idp;
+
+ SyncManagerImpl syncManager;
+ ExternalIdentityProviderManager idpManager;
+
+ private final Random random = new Random();
+
+ protected AbstractExternalTest(int numberofUsers, int numberofGroups, long expTime, boolean dynamicMembership) {
+ idp = new TestIdentityProvider(numberofUsers, numberofGroups);
+ syncConfig.user().setMembershipNestingDepth(1).setExpirationTime(expTime).setPathPrefix(PATH_PREFIX);
+ syncConfig.group().setExpirationTime(expTime).setPathPrefix(PATH_PREFIX);
+ // TODO OAK-4101 : syncConfig.user().setDynamicMembership(dynamicMembership);
+ }
+
+ protected abstract Configuration createConfiguration();
+
+ protected String getRandomUserId() {
+ int index = random.nextInt(((TestIdentityProvider) idp).numberofUsers);
+ return "u" + index;
+ }
+
+ protected String getRandomGroupId() {
+ int index = random.nextInt(((TestIdentityProvider) idp).membershipSize);
+ return "g" + index;
+ }
+
+ @Override
+ public void run(Iterable iterable, List concurrencyLevels) {
+ // make sure the desired JAAS config is set
+ Configuration.setConfiguration(createConfiguration());
+ super.run(iterable, concurrencyLevels);
+ }
+
+ /**
+ * Remove any user/group accounts that have been synchronized into the repo.
+ *
+ * @throws Exception
+ */
+ @Override
+ protected void afterSuite() throws Exception {
+ Session s = loginAdministrative();
+ for (String creationRoot : new String[] {UserConstants.DEFAULT_USER_PATH, UserConstants.DEFAULT_GROUP_PATH}) {
+ String path = creationRoot + "/" + PATH_PREFIX;
+ if (s.nodeExists(path)) {
+ s.getNode(path).remove();
+ }
+ }
+ s.save();
+ }
+
+ @Override
+ protected Repository[] createRepository(RepositoryFixture fixture) throws Exception {
+ if (fixture instanceof OakRepositoryFixture) {
+ return ((OakRepositoryFixture) fixture).setUpCluster(1, new JcrCreator() {
+ @Override
+ public Jcr customize(Oak oak) {
+ Whiteboard whiteboard = oak.getWhiteboard();
+
+ syncManager = new SyncManagerImpl(whiteboard);
+ whiteboard.register(SyncManager.class, syncManager, Collections.emptyMap());
+
+ idpManager = new ExternalIDPManagerImpl(whiteboard);
+ whiteboard.register(ExternalIdentityProviderManager.class, idpManager, Collections.emptyMap());
+
+ whiteboard.register(ExternalIdentityProvider.class, idp, Collections.emptyMap());
+ whiteboard.register(SyncHandler.class, syncHandler, Collections.emptyMap());
+
+ SecurityProvider sp = new TestSecurityProvider(ConfigurationParameters.EMPTY);
+ return new Jcr(oak).with(sp);
+ }
+ });
+ } else {
+ throw new UnsupportedOperationException("unsupported fixture" + fixture);
+ }
+ }
+
+ private final class TestSecurityProvider extends SecurityProviderImpl {
+ public TestSecurityProvider(@Nonnull ConfigurationParameters configuration) {
+ super(configuration);
+ // TODO: enable once OAK-4104 is commited
+ // PrincipalConfiguration principalConfiguration = getConfiguration(PrincipalConfiguration.class);
+ // if (!(principalConfiguration instanceof CompositePrincipalConfiguration)) {
+ // throw new IllegalStateException();
+ // } else {
+ // PrincipalConfiguration defConfig = checkNotNull(((CompositePrincipalConfiguration) principalConfiguration).getDefaultConfig());
+ // bindPrincipalConfiguration((new ExternalPrincipalConfiguration(this)));
+ // bindPrincipalConfiguration(defConfig);
+ // }
+ }
+ }
+
+ private final class TestIdentityProvider implements ExternalIdentityProvider {
+
+ private final int numberofUsers;
+ private final int membershipSize;
+
+ private TestIdentityProvider(int numberofUsers, int membershipSize) {
+ this.numberofUsers = numberofUsers;
+ this.membershipSize = membershipSize;
+ }
+
+ @Nonnull
+ @Override
+ public String getName() {
+ return "test";
+ }
+
+ @CheckForNull
+ @Override
+ public ExternalIdentity getIdentity(@Nonnull ExternalIdentityRef ref) {
+ String id = ref.getId();
+ long index = Long.valueOf(id.substring(1));
+ if (id.charAt(0) == 'u') {
+ return new TestUser(index);
+ } else {
+ return new TestGroup(index);
+ }
+ }
+
+ @CheckForNull
+ @Override
+ public ExternalUser getUser(@Nonnull String userId) {
+ return new TestUser(Long.valueOf(userId.substring(1)));
+ }
+
+ @CheckForNull
+ @Override
+ public ExternalUser authenticate(@Nonnull Credentials credentials) {
+ return getUser(((SimpleCredentials) credentials).getUserID());
+ }
+
+ @CheckForNull
+ @Override
+ public ExternalGroup getGroup(@Nonnull String name) {
+ return new TestGroup(Long.valueOf(name.substring(1)));
+ }
+
+ @Nonnull
+ @Override
+ public Iterator<ExternalUser> listUsers() {
+ Set<ExternalUser> all = new HashSet<>();
+ for (long i = 0; i < numberofUsers; i++) {
+ all.add(new TestUser(i));
+ }
+ return all.iterator();
+ }
+
+ @Nonnull
+ @Override
+ public Iterator<ExternalGroup> listGroups() {
+ Set<ExternalGroup> all = new HashSet<>();
+ for (long i = 0; i < membershipSize; i++) {
+ all.add(new TestGroup(i));
+ }
+ return all.iterator();
+ }
+
+ Iterable<ExternalIdentityRef> getDeclaredGroupRefs(String userId) {
+ if (userId.charAt(0) == 'u') {
+ Set<ExternalIdentityRef> groupRefs = new HashSet<>();
+ for (long i = 0; i < membershipSize; i++) {
+ groupRefs.add(new ExternalIdentityRef("g"+ i, idp.getName()));
+ }
+ return groupRefs;
+ } else {
+ return ImmutableSet.of();
+ }
+ }
+ }
+
+ private class TestIdentity implements ExternalIdentity {
+
+ private final String userId;
+ private final String principalName;
+ private final ExternalIdentityRef id;
+
+ public TestIdentity(@Nonnull String userId) {
+ this.userId = userId;
+ this.principalName = "p_"+userId;
+ id = new ExternalIdentityRef(userId, idp.getName());
+ }
+
+ @Nonnull
+ @Override
+ public String getId() {
+ return userId;
+ }
+
+ @Nonnull
+ @Override
+ public String getPrincipalName() {
+ return principalName;
+ }
+
+ @Nonnull
+ @Override
+ public ExternalIdentityRef getExternalId() {
+ return id;
+ }
+
+ @Override
+ public String getIntermediatePath() {
+ return null;
+ }
+
+ @Nonnull
+ @Override
+ public Iterable<ExternalIdentityRef> getDeclaredGroups() {
+ return ((TestIdentityProvider) idp).getDeclaredGroupRefs(userId);
+ }
+
+ @Nonnull
+ @Override
+ public Map<String, ?> getProperties() {
+ return ImmutableMap.of();
+ }
+
+
+ }
+
+ private class TestUser extends TestIdentity implements ExternalUser {
+
+ public TestUser(long index) {
+ super("u" + index);
+ }
+ }
+
+ private class TestGroup extends TestIdentity implements ExternalGroup {
+
+ public TestGroup(long index) {
+ super("g" + index);
+ }
+
+ @Nonnull
+ @Override
+ public Iterable<ExternalIdentityRef> getDeclaredMembers() throws ExternalIdentityException {
+ return ImmutableSet.of();
+ }
+ }
+}
\ No newline at end of file
Added: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/external/ExternalLoginTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/external/ExternalLoginTest.java?rev=1743674&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/external/ExternalLoginTest.java (added)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/external/ExternalLoginTest.java Fri May 13 13:36:12 2016
@@ -0,0 +1,65 @@
+/*
+ * 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.jackrabbit.oak.benchmark.authentication.external;
+
+import javax.jcr.SimpleCredentials;
+import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.Configuration;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.jackrabbit.oak.security.authentication.user.LoginModuleImpl;
+import org.apache.jackrabbit.oak.spi.security.authentication.external.impl.ExternalLoginModule;
+
+/**
+ * Login against the {@link ExternalLoginModule} with a randomly selected user.
+ * The first login of a given user will trigger the user-synchronization mechanism.
+ * Subsequent login calls will only result in an extra sync-call if the configured
+ * expiration time is reached.
+ *
+ * Configuration options as defined in {@link AbstractExternalTest}.
+ */
+public class ExternalLoginTest extends AbstractExternalTest {
+
+ public ExternalLoginTest(int numberofUsers, int numberofGroups, long expTime, boolean dynamicMembership) {
+ super(numberofUsers, numberofGroups, expTime, dynamicMembership);
+ }
+
+ @Override
+ protected void runTest() throws Exception {
+ getRepository().login(new SimpleCredentials(getRandomUserId(), new char[0])).logout();
+ }
+
+ protected Configuration createConfiguration() {
+ return new Configuration() {
+ @Override
+ public AppConfigurationEntry[] getAppConfigurationEntry(String s) {
+ return new AppConfigurationEntry[]{
+ new AppConfigurationEntry(
+ LoginModuleImpl.class.getName(),
+ AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT,
+ ImmutableMap.<String, Object>of()),
+ new AppConfigurationEntry(
+ ExternalLoginModule.class.getName(),
+ AppConfigurationEntry.LoginModuleControlFlag.REQUIRED,
+ ImmutableMap.of(
+ ExternalLoginModule.PARAM_SYNC_HANDLER_NAME, syncConfig.getName(),
+ ExternalLoginModule.PARAM_IDP_NAME, idp.getName()))
+ };
+ }
+ };
+ }
+}
\ No newline at end of file
Added: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/external/SyncAllExternalUsersTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/external/SyncAllExternalUsersTest.java?rev=1743674&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/external/SyncAllExternalUsersTest.java (added)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/external/SyncAllExternalUsersTest.java Fri May 13 13:36:12 2016
@@ -0,0 +1,51 @@
+/*
+ * 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.jackrabbit.oak.benchmark.authentication.external;
+
+import javax.security.auth.login.Configuration;
+
+import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters;
+import org.apache.jackrabbit.oak.spi.security.authentication.ConfigurationUtil;
+import org.apache.jackrabbit.oak.spi.security.authentication.external.impl.jmx.SyncMBeanImpl;
+import org.apache.jackrabbit.oak.spi.security.authentication.external.impl.jmx.SynchronizationMBean;
+
+/**
+ * Benchmark for {@link SynchronizationMBean#syncAllExternalUsers()}
+ */
+public class SyncAllExternalUsersTest extends AbstractExternalTest {
+
+ private SynchronizationMBean bean;
+
+ public SyncAllExternalUsersTest(int numberofUsers, int membershipSize, long expTime, boolean dynamicMembership) {
+ super(numberofUsers, membershipSize, expTime, dynamicMembership);
+ }
+
+ @Override
+ protected Configuration createConfiguration() {
+ return ConfigurationUtil.getDefaultConfiguration(ConfigurationParameters.EMPTY);
+ }
+
+ @Override
+ protected void beforeSuite() throws Exception {
+ bean = new SyncMBeanImpl(getRepository(), syncManager, "default", idpManager, idp.getName());
+ }
+
+ @Override
+ protected void runTest() throws Exception {
+ bean.syncAllExternalUsers();
+ }
+}
\ No newline at end of file
Added: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/external/SyncExternalUsersTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/external/SyncExternalUsersTest.java?rev=1743674&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/external/SyncExternalUsersTest.java (added)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/authentication/external/SyncExternalUsersTest.java Fri May 13 13:36:12 2016
@@ -0,0 +1,60 @@
+/*
+ * 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.jackrabbit.oak.benchmark.authentication.external;
+
+import javax.security.auth.login.Configuration;
+
+import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters;
+import org.apache.jackrabbit.oak.spi.security.authentication.ConfigurationUtil;
+import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef;
+import org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncConfig;
+import org.apache.jackrabbit.oak.spi.security.authentication.external.impl.jmx.SyncMBeanImpl;
+import org.apache.jackrabbit.oak.spi.security.authentication.external.impl.jmx.SynchronizationMBean;
+
+/**
+ * Benchmark for {@link SynchronizationMBean#syncExternalUsers(String[])}
+ */
+public class SyncExternalUsersTest extends AbstractExternalTest {
+
+ private final int batchSize;
+ private SynchronizationMBean bean;
+
+ public SyncExternalUsersTest(int numberofUsers, int membershipSize, long expTime,
+ boolean dynamicMembership, int batchSize) {
+ super(numberofUsers, membershipSize, expTime, dynamicMembership);
+ this.batchSize = batchSize;
+ }
+
+ @Override
+ protected Configuration createConfiguration() {
+ return ConfigurationUtil.getDefaultConfiguration(ConfigurationParameters.EMPTY);
+ }
+
+ @Override
+ protected void beforeSuite() throws Exception {
+ bean = new SyncMBeanImpl(getRepository(), syncManager, syncConfig.getName(), idpManager, idp.getName());
+ }
+
+ @Override
+ protected void runTest() throws Exception {
+ String[] externalIds = new String[batchSize];
+ for (int i = 0; i < batchSize; i++) {
+ externalIds[i] = new ExternalIdentityRef(getRandomUserId(), idp.getName()).getString();
+ }
+ bean.syncExternalUsers(externalIds);
+ }
+}
\ No newline at end of file