Return-Path: X-Original-To: apmail-sling-commits-archive@www.apache.org Delivered-To: apmail-sling-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B8462108A1 for ; Thu, 23 Jan 2014 13:26:00 +0000 (UTC) Received: (qmail 73100 invoked by uid 500); 23 Jan 2014 13:25:59 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 73016 invoked by uid 500); 23 Jan 2014 13:25:56 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 72989 invoked by uid 99); 23 Jan 2014 13:25:54 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Jan 2014 13:25:54 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Jan 2014 13:25:51 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 08667238889B; Thu, 23 Jan 2014 13:25:30 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1560681 - /sling/trunk/performance/tests/src/main/java/org/apache/sling/performance/tests/StartupWithManyAliasTest.java Date: Thu, 23 Jan 2014 13:25:29 -0000 To: commits@sling.apache.org From: asanso@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140123132530.08667238889B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: asanso Date: Thu Jan 23 13:25:29 2014 New Revision: 1560681 URL: http://svn.apache.org/r1560681 Log: SLING-3332 - Long startup time with many sling:alias - added performance test for Startup with many aliases Added: sling/trunk/performance/tests/src/main/java/org/apache/sling/performance/tests/StartupWithManyAliasTest.java Added: sling/trunk/performance/tests/src/main/java/org/apache/sling/performance/tests/StartupWithManyAliasTest.java URL: http://svn.apache.org/viewvc/sling/trunk/performance/tests/src/main/java/org/apache/sling/performance/tests/StartupWithManyAliasTest.java?rev=1560681&view=auto ============================================================================== --- sling/trunk/performance/tests/src/main/java/org/apache/sling/performance/tests/StartupWithManyAliasTest.java (added) +++ sling/trunk/performance/tests/src/main/java/org/apache/sling/performance/tests/StartupWithManyAliasTest.java Thu Jan 23 13:25:29 2014 @@ -0,0 +1,118 @@ +package org.apache.sling.performance.tests; +/* + * 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. + */ + + +import java.math.BigInteger; +import java.security.SecureRandom; +import javax.jcr.Node; +import org.apache.jackrabbit.JcrConstants; +import org.apache.sling.commons.testing.jcr.RepositoryUtil; +import org.apache.sling.performance.AbstractRepositoryTest; +import org.apache.sling.performance.TestHelper; +import org.apache.sling.performance.annotation.AfterMethodInvocation; +import org.apache.sling.performance.annotation.PerformanceTest; +import org.junit.After; +import org.junit.Before; + +public class StartupWithManyAliasTest extends AbstractRepositoryTest { + private static final String PN_SLING_ALIAS = "sling:alias"; + + public static final String PROP_REDIRECT_INTERNAL = "sling:internalRedirect"; + + private final TestHelper helper; + + private Node mapRoot; + + private Node rootNode; + + private String rootPath; + + private final int nodeCount; + + public StartupWithManyAliasTest(String testInstanceName, + TestHelper helper, int nodeCount) { + super(testInstanceName); + this.helper = helper; + this.nodeCount = nodeCount; + + } + + @After + protected void afterSuite() throws Exception { + if (helper != null) { + helper.dispose(); + } + + if (rootNode != null) { + rootNode.remove(); + } + if (mapRoot != null) { + mapRoot.remove(); + } + session.save(); + } + + @AfterMethodInvocation + protected void afterMethod() throws Exception { + helper.dispose(); + } + + @Before + protected void beforeSuite() throws Exception { + RepositoryUtil.registerNodeType(getSession(), + this.getClass().getResourceAsStream("/SLING-INF/nodetypes/folder.cnd")); + RepositoryUtil.registerNodeType(getSession(), + this.getClass().getResourceAsStream("/SLING-INF/nodetypes/resource.cnd")); + RepositoryUtil.registerNodeType(getSession(), + this.getClass().getResourceAsStream("/SLING-INF/nodetypes/vanitypath.cnd")); + RepositoryUtil.registerNodeType(getSession(), + this.getClass().getResourceAsStream("/SLING-INF/nodetypes/mapping.cnd")); + + // test data + rootPath = "/test" + System.currentTimeMillis(); + rootNode = getSession().getRootNode().addNode(rootPath.substring(1), "nt:unstructured"); + + // test mappings + mapRoot = getSession().getRootNode().addNode("etc", JcrConstants.NT_FOLDER); + Node map = mapRoot.addNode("map", "sling:Mapping"); + Node http = map.addNode("http", "sling:Mapping"); + Node aliasNode = map.addNode("alias", "nt:unstructured"); + Node localhost80 =http.addNode("localhost.80", "sling:Mapping"); + Node https = map.addNode("https", "sling:Mapping"); + https.addNode("localhost.443", "sling:Mapping"); + + SecureRandom random = new SecureRandom(); + + for (int j = 0; j < nodeCount; j++) { + Node content = rootNode.addNode("a" + j, JcrConstants.NT_UNSTRUCTURED); + String alias = new BigInteger(130, random).toString(32); + content.setProperty(PN_SLING_ALIAS, alias); + + if (j % 10 == 0) { + session.save(); + } + } + session.save(); + } + + @PerformanceTest + public void runTest() throws Exception { + helper.init(rootPath, session, getRepository()); + } + +}