modules/enterprise/server/plugins/rhnhosted/pom.xml
| 12
modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/TestPerfPackageMetadata.java
| 122 ++++++++++
2 files changed, 134 insertions(+)
New commits:
commit c25f0b1b097eb6a3b2a35f5ec98d9641f3464d9f
Author: John Matthews <jmatthew(a)redhat.com>
Date: Fri Jan 29 11:57:10 2010 -0500
Creating a test to isolate package metadata fetch from RHN Hosted
This test will not be run as part of normal unit tests, it's main purpose is to
isolate
the package metadata fetch into a standalone operation to aid us in
testing/profiling/etc.
diff --git a/modules/enterprise/server/plugins/rhnhosted/pom.xml
b/modules/enterprise/server/plugins/rhnhosted/pom.xml
index 3cac2a1..9c72345 100644
--- a/modules/enterprise/server/plugins/rhnhosted/pom.xml
+++ b/modules/enterprise/server/plugins/rhnhosted/pom.xml
@@ -142,6 +142,9 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
+ <!-- Memory Performance Testing
+ <argLine> -Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9000 -Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-agentlib:hprof=heap=dump,file=/tmp/hprof.bin,format=b,depth=10 </argLine>
+ -->
<!--
<argLine>-Xdebug -Xnoagent -Djava.compiler=NONE
-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</argLine>
-->
@@ -169,8 +172,17 @@
be deleted after use.
-->
<name>RhnXmlrpcSaveTempFiles</name>
+ <value>true</value>
+ </property>
+ <property>
+ <!--
+ set this to true if you want to run a package metadata
sync through RHNProvider.
+ -->
+ <name>RunTestPerfPackageMetadata</name>
<value>false</value>
</property>
+
+
<property>
<name>log4j.configuration</name>
<value>test-log4j.xml</value>
diff --git
a/modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/TestPerfPackageMetadata.java
b/modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/TestPerfPackageMetadata.java
new file mode 100644
index 0000000..7766a9b
--- /dev/null
+++
b/modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/TestPerfPackageMetadata.java
@@ -0,0 +1,122 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.server.plugins.rhnhosted.xmlrpc;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.enterprise.server.plugin.pc.content.ContentProviderPackageDetails;
+import org.rhq.enterprise.server.plugin.pc.content.PackageSyncReport;
+import org.rhq.enterprise.server.plugins.rhnhosted.RHNProvider;
+
+public class TestPerfPackageMetadata {
+ //
+ // By default this test will _NOT_ be run during normal unit test runs.
+ // It's goal is to give us a means to isolate a full run of the communication
& parsing of package metadata
+ // with RHN Hosted, outside of a JBoss/RHQ environment
+ //
+ private final Log log = LogFactory.getLog(TestPerfPackageMetadata.class);
+ String PROP_NAME_TO_TRIGGER_TEST = "RunTestPerfPackageMetadata";
+ boolean isTesting = false;
+ //String rhnURL = "http://satellite.rhn.stage.redhat.com";
+ String rhnURL = "http://satellite.rhn.redhat.com";
+ String certLoc = "./entitlement-cert.xml";
+
+ @BeforeTest
+ public void setUp() throws Exception {
+ String value = System.getProperty(PROP_NAME_TO_TRIGGER_TEST);
+ if (!StringUtils.isBlank(value)) {
+ isTesting = Boolean.parseBoolean(value);
+ }
+ }
+
+ @AfterTest
+ public void tearDown() {
+ }
+
+ public Configuration getConfiguration() {
+ String certData = "";
+ try {
+ certData = FileUtils.readFileToString(new File(certLoc));
+ } catch (Exception e) {
+ e.printStackTrace();
+ assert false;
+ }
+ return getConfiguration(rhnURL, certData);
+ }
+
+ public Configuration getConfiguration(String location, String certData) {
+ Configuration config = new Configuration();
+ PropertySimple locProp = new PropertySimple();
+ locProp.setName("location");
+ locProp.setStringValue(location);
+ config.put(locProp);
+ PropertySimple certProp = new PropertySimple();
+ certProp.setName("certificate");
+ certProp.setStringValue(certData);
+ config.put(certProp);
+ return config;
+ }
+
+ protected Map getRequestProperties() {
+ Map reqProps = new HashMap();
+ reqProps.put("X-RHN-Satellite-XML-Dump-Version", "3.3");
+ return reqProps;
+ }
+
+ @Test
+ public void testRHEL5FetchMetadata() {
+
+ if (!isTesting) {
+ log.info("Intentionally skipping test, since property is missing: "
+ PROP_NAME_TO_TRIGGER_TEST);
+ return;
+ }
+ log.info("Started test of fetching package metadata");
+ String channelName = "rhel-i386-server-5";
+
+ RHNProvider provider = new RHNProvider();
+ Configuration config = getConfiguration();
+ PackageSyncReport report = new PackageSyncReport();
+ try {
+ provider.initialize(config);
+ List<ContentProviderPackageDetails> existingPackages = new
ArrayList<ContentProviderPackageDetails>();
+ provider.synchronizePackages(channelName, report, existingPackages);
+ } catch (Exception e) {
+ e.printStackTrace();
+ assert false;
+ }
+ Set<ContentProviderPackageDetails> newPkgs = report.getNewPackages();
+ provider.shutdown();
+ }
+}
Show replies by date