[jboss-cvs] JBossAS SVN: r97962 - projects/reloaded/trunk/vdf-bootstrap-minimal/src/test/java.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Dec 17 11:01:56 EST 2009


Author: ALRubinger
Date: 2009-12-17 11:01:56 -0500 (Thu, 17 Dec 2009)
New Revision: 97962

Added:
   projects/reloaded/trunk/vdf-bootstrap-minimal/src/test/java/DeployersOrderingStressTestStandaloneHarness.java
   projects/reloaded/trunk/vdf-bootstrap-minimal/src/test/java/DeployersOrderingStressUnitTest.java
Removed:
   projects/reloaded/trunk/vdf-bootstrap-minimal/src/test/java/MainDeployerTestCaseStandaloneHarness.java
Modified:
   projects/reloaded/trunk/vdf-bootstrap-minimal/src/test/java/MainDeployerTestBase.java
Log:
[JBDEPLOY-230][RELOADED-10] Add a stress test for insertion of new deployers into MC

Copied: projects/reloaded/trunk/vdf-bootstrap-minimal/src/test/java/DeployersOrderingStressTestStandaloneHarness.java (from rev 97922, projects/reloaded/trunk/vdf-bootstrap-minimal/src/test/java/MainDeployerTestCaseStandaloneHarness.java)
===================================================================
--- projects/reloaded/trunk/vdf-bootstrap-minimal/src/test/java/DeployersOrderingStressTestStandaloneHarness.java	                        (rev 0)
+++ projects/reloaded/trunk/vdf-bootstrap-minimal/src/test/java/DeployersOrderingStressTestStandaloneHarness.java	2009-12-17 16:01:56 UTC (rev 97962)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * Standalone client which may act as an entry hook for Profilers.
+ * The Maven build will install all library dependencies under 
+ * target/dependency for easy addition to the profiling ClassPath.
+ * This test targets {@link DeployersOrderingStressUnitTest}
+ * 
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class DeployersOrderingStressTestStandaloneHarness
+{
+
+   //-------------------------------------------------------------------------------------||
+   // Class Members ----------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   //-------------------------------------------------------------------------------------||
+   // Main -------------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Entry
+    */
+   public static void main(final String... args)
+   {
+
+      try
+      {
+         new DeployersOrderingStressTestStandaloneHarness();
+      }
+      catch (final Throwable t)
+      {
+         throw new RuntimeException("Could not start test", t);
+      }
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Constructor ------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Creates a new instance and runs a test
+    */
+   public DeployersOrderingStressTestStandaloneHarness() throws Throwable
+   {
+      final DeployersOrderingStressUnitTest test = new DeployersOrderingStressUnitTest();
+      DeployersOrderingStressUnitTest.setupJBossXb();
+      DeployersOrderingStressUnitTest.createAndConfigureServer();
+      test.startServer();
+      test.addOneHundredDeployers();
+      test.stopServer();
+   }
+
+}

Added: projects/reloaded/trunk/vdf-bootstrap-minimal/src/test/java/DeployersOrderingStressUnitTest.java
===================================================================
--- projects/reloaded/trunk/vdf-bootstrap-minimal/src/test/java/DeployersOrderingStressUnitTest.java	                        (rev 0)
+++ projects/reloaded/trunk/vdf-bootstrap-minimal/src/test/java/DeployersOrderingStressUnitTest.java	2009-12-17 16:01:56 UTC (rev 97962)
@@ -0,0 +1,263 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+  *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import junit.framework.TestCase;
+
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.bootstrap.api.lifecycle.LifecycleState;
+import org.jboss.bootstrap.api.mc.server.MCServer;
+import org.jboss.bootstrap.api.mc.server.MCServerFactory;
+import org.jboss.deployers.client.spi.main.MainDeployer;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.Deployer;
+import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.kernel.Kernel;
+import org.jboss.logging.Logger;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Stress test to show geometric degradation when adding 
+ * increasingly incrementing {@link Deployer} instances into
+ * MC 
+ * 
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class DeployersOrderingStressUnitTest
+{
+   //-------------------------------------------------------------------------------------||
+   // Class Members ----------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Logger
+    */
+   private static final Logger log = Logger.getLogger(MainDeployerViaBootstrapUnitTest.class);
+
+   /**
+    * The Server
+    */
+   private static MCServer server;
+
+   /**
+    * Name of the system property signaling JBossXB to ignore order
+    */
+   private static final String NAME_SYSPROP_JBOSSXB_IGNORE_ORDER = "xb.builder.useUnorderedSequence";
+
+   /**
+    * Value to set for JBossXB ordering
+    */
+   private static final String VALUE_SYSPROP_JBOSSXB_IGNORE_ORDER = "true";
+
+   //-------------------------------------------------------------------------------------||
+   // Lifecycle --------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Setup JBossXB
+    * TODO @see comments below so that this step is not necessary
+    */
+   @BeforeClass
+   public static void setupJBossXb()
+   {
+      AccessController.doPrivileged(new PrivilegedAction<Void>()
+      {
+         public Void run()
+         {
+            // Must use unordered sequence else JBossXB will explode
+            //TODO Define a proper vfs.xml which is properly ordered
+            System.setProperty(NAME_SYSPROP_JBOSSXB_IGNORE_ORDER, VALUE_SYSPROP_JBOSSXB_IGNORE_ORDER);
+            return null;
+         }
+      });
+   }
+
+   /**
+    * Creates the server
+    */
+   @BeforeClass
+   public static void createAndConfigureServer()
+   {
+      // Create a server
+      final MCServer mcServer = MCServerFactory.createServer();
+      // Set the bootstrap home
+      final URL bootstrapHome = getBootstrapHome();
+      log.info("Using bootstrap home: " + bootstrapHome.toExternalForm());
+      mcServer.getConfiguration().bootstrapHome(bootstrapHome);
+      // Set
+      server = mcServer;
+   }
+
+   /**
+    * Starts the server before each test
+    * @throws Exception
+    */
+   @Before
+   public void startServer() throws Exception
+   {
+      long before = System.currentTimeMillis();
+      server.start();
+      long after = System.currentTimeMillis();
+      long total = after - before;
+      log.info("Boot took: " + total + "ms");
+   }
+
+   /**
+    * Stops the server after each test
+    * @throws Exception
+    */
+   @After
+   public void stopServer() throws Exception
+   {
+      if (server != null && server.getState().equals(LifecycleState.STARTED))
+      {
+         server.stop();
+      }
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Tests ------------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   @Test
+   public void addOneDeployer() throws Throwable
+   {
+      this.stressAddingDeployers(1);
+   }
+
+   @Test
+   public void addTenDeployers() throws Throwable
+   {
+      this.stressAddingDeployers(10);
+   }
+
+   @Test
+   public void addTwentyDeployers() throws Throwable
+   {
+      this.stressAddingDeployers(20);
+   }
+
+   @Test
+   public void addThirtyDeployers() throws Throwable
+   {
+      this.stressAddingDeployers(30);
+   }
+
+   @Test
+   public void addFortyDeployers() throws Throwable
+   {
+      this.stressAddingDeployers(40);
+   }
+
+   @Test
+   public void addFiftyDeployers() throws Throwable
+   {
+      this.stressAddingDeployers(50);
+   }
+
+   @Test
+   public void addSixtyDeployers() throws Throwable
+   {
+      this.stressAddingDeployers(60);
+   }
+
+   @Test
+   public void addSeventyDeployers() throws Throwable
+   {
+      this.stressAddingDeployers(70);
+   }
+
+   @Test
+   public void addEightyDeployers() throws Throwable
+   {
+      this.stressAddingDeployers(80);
+   }
+
+   @Test
+   public void addNinetyDeployers() throws Throwable
+   {
+      this.stressAddingDeployers(90);
+   }
+
+   @Test
+   public void addOneHundredDeployers() throws Throwable
+   {
+      this.stressAddingDeployers(100);
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Internal Helper Methods ------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Stress test to add the specified number of deployers to MC, and 
+    * note the amount of time taken
+    */
+   void stressAddingDeployers(final int numDeployers) throws Throwable
+   {
+      // Get the MainDeployer
+      final Kernel kernel = server.getKernel();
+      MainDeployer mainDeployer = (MainDeployer) kernel.getController().getInstalledContext("MainDeployer").getTarget();
+      TestCase.assertNotNull(MainDeployer.class.getName() + " instance was not installed into MC", mainDeployer);
+
+      // Add Deployers
+      final long start = System.currentTimeMillis();
+      for (int i = 0; i < numDeployers; i++)
+      {
+         // Install a deployer
+         final Deployer deployer = new AbstractDeployer()
+         {
+
+            @Override
+            public void deploy(final DeploymentUnit unit) throws DeploymentException
+            {
+               //NOOP            
+            }
+         };
+         final String deployerName = deployer.getClass().getSimpleName() + numDeployers + "-" + i;
+         final BeanMetaDataBuilder bmdb = BeanMetaDataBuilder
+               .createBuilder(deployerName, deployer.getClass().getName());
+         kernel.getController().install(bmdb.getBeanMetaData(), deployer);
+
+      }
+      final long total = System.currentTimeMillis() - start;
+      log.info("Adding " + numDeployers + " deployer(s) took " + total + "ms");
+
+   }
+
+   /**
+    * Obtains the location of the bootstrap home
+    */
+   private static URL getBootstrapHome()
+   {
+      return DeployersOrderingStressUnitTest.class.getProtectionDomain().getCodeSource().getLocation();
+   }
+
+}

Modified: projects/reloaded/trunk/vdf-bootstrap-minimal/src/test/java/MainDeployerTestBase.java
===================================================================
--- projects/reloaded/trunk/vdf-bootstrap-minimal/src/test/java/MainDeployerTestBase.java	2009-12-17 13:42:43 UTC (rev 97961)
+++ projects/reloaded/trunk/vdf-bootstrap-minimal/src/test/java/MainDeployerTestBase.java	2009-12-17 16:01:56 UTC (rev 97962)
@@ -33,6 +33,7 @@
 import org.jboss.deployers.vfs.spi.client.VFSDeployment;
 import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
 import org.jboss.kernel.Kernel;
+import org.jboss.logging.Logger;
 import org.jboss.shrinkwrap.api.Archives;
 import org.jboss.shrinkwrap.api.exporter.ZipExporter;
 import org.jboss.shrinkwrap.api.spec.JavaArchive;
@@ -59,6 +60,8 @@
    // Class Members ----------------------------------------------------------------------||
    //-------------------------------------------------------------------------------------||
 
+   private static final Logger log = Logger.getLogger(MainDeployerTestBase.class);
+
    /**
     * Name of the archive we'll deploy
     */

Deleted: projects/reloaded/trunk/vdf-bootstrap-minimal/src/test/java/MainDeployerTestCaseStandaloneHarness.java
===================================================================
--- projects/reloaded/trunk/vdf-bootstrap-minimal/src/test/java/MainDeployerTestCaseStandaloneHarness.java	2009-12-17 13:42:43 UTC (rev 97961)
+++ projects/reloaded/trunk/vdf-bootstrap-minimal/src/test/java/MainDeployerTestCaseStandaloneHarness.java	2009-12-17 16:01:56 UTC (rev 97962)
@@ -1,67 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.
- */
-
-/**
- * Standalone client which may act as an entry hook for Profilers.
- * The Maven build will install all library dependencies under 
- * target/dependency for easy addition to the profiling ClassPath.
- * 
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class MainDeployerTestCaseStandaloneHarness
-{
-
-   //-------------------------------------------------------------------------------------||
-   // Class Members ----------------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   //-------------------------------------------------------------------------------------||
-   // Main -------------------------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   /**
-    * Entry
-    */
-   public static void main(final String... args)
-   {
-
-      try
-      {
-         new MainDeployerTestCaseStandaloneHarness();
-      }
-      catch (final Throwable t)
-      {
-         throw new RuntimeException("Could not start test", t);
-      }
-   }
-
-   //-------------------------------------------------------------------------------------||
-   // Constructor ------------------------------------------------------------------------||
-   //-------------------------------------------------------------------------------------||
-
-   public MainDeployerTestCaseStandaloneHarness() throws Throwable
-   {
-      final MainDeployerViaBootstrapUnitTest test = new MainDeployerViaBootstrapUnitTest();
-      MainDeployerViaBootstrapUnitTest.setupJBossXb();
-      MainDeployerViaBootstrapUnitTest.createAndConfigureServer();
-      test.startServer();
-      //      test.testVdfBoot();
-      test.stopServer();
-   }
-
-}




More information about the jboss-cvs-commits mailing list