modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java | 88 + modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java | 9 modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java | 63 modules/core/plugin-container/src/test/java/org/rhq/test/pc/PluginContainerSetup.java | 3 modules/core/plugin-container/src/test/java/org/rhq/test/pc/PluginContainerTest.java | 4 modules/core/util/src/main/java/org/rhq/core/util/stream/StreamUtil.java | 72 modules/enterprise/server/safe-invoker/src/main/java/org/rhq/enterprise/server/util/HibernateDetachUtility.java | 14 modules/helpers/inventory-serializer/inventory-serializer.sh | 4 modules/helpers/inventory-serializer/pom.xml | 127 + modules/helpers/inventory-serializer/src/main/java/org/rhq/helpers/inventoryserializer/Main.java | 221 ++ modules/helpers/inventory-serializer/src/main/java/org/rhq/helpers/inventoryserializer/util/ChildFirstClassLoader.java | 125 + modules/helpers/inventory-serializer/src/main/resources/log4j.properties | 8 modules/helpers/pom.xml | 2 modules/plugins/apache/pom.xml | 123 + modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java | 14 modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java | 37 modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java | 40 modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/VHostSpec.java | 4 modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/VirtualHostLegacyResourceKeyUtil.java | 90 - modules/plugins/apache/src/test/java/org/rhq/plugins/apache/ApachePluginTest.java | 12 modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java | 776 ++++++++++ modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeConfigurationWithIncludesFromRHQ1_3Test.java | 36 modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeMessyConfigurationFromRHQ1_3Test.java | 35 modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeNestedConfigurationFromRHQ1_3Test.java | 171 ++ modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeSimpleConfigurationFromRHQ1_3Test.java | 153 + modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeConfigurationWithIncludesFromRHQ3_0_0Test.java | 36 modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeMessyConfigurationFromRHQ3_0_0Test.java | 34 modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeNestedConfigurationFromRHQ3_0_0Test.java | 378 ++++ modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java | 332 ++++ modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeConfigurationWithIncludesFromRHQ3_0_1Test.java | 38 modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeMessyConfigurationFromRHQ3_0_1Test.java | 38 modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeNestedConfigurationFromRHQ3_0_1Test.java | 479 ++++++ modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java | 467 ++++++ modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeConfigurationWithIncludesFromRHQ3_0_2Test.java | 34 modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeMessyConfigurationFromRHQ3_0_2Test.java | 36 modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeNestedConfigurationFromRHQ3_0_2Test.java | 206 ++ modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeSimpleConfigurationFromRHQ3_0_2Test.java | 180 ++ modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java | 453 +++++ modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheExecutionUtil.java | 147 + modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/StandAloneContainer.java | 75 modules/plugins/apache/src/test/resources/full-configurations/1.3.x/includes/1.vhost.conf | 9 modules/plugins/apache/src/test/resources/full-configurations/1.3.x/includes/2.vhost.conf | 9 modules/plugins/apache/src/test/resources/full-configurations/1.3.x/includes/httpd.conf | 40 modules/plugins/apache/src/test/resources/full-configurations/1.3.x/mess/1.vhost.conf | 17 modules/plugins/apache/src/test/resources/full-configurations/1.3.x/mess/2.vhost.conf | 13 modules/plugins/apache/src/test/resources/full-configurations/1.3.x/mess/httpd.conf | 40 modules/plugins/apache/src/test/resources/full-configurations/1.3.x/nested/httpd.conf | 68 modules/plugins/apache/src/test/resources/full-configurations/1.3.x/simple/httpd.conf | 47 modules/plugins/apache/src/test/resources/full-configurations/2.2.x/includes/1.vhost.conf | 9 modules/plugins/apache/src/test/resources/full-configurations/2.2.x/includes/2.vhost.conf | 9 modules/plugins/apache/src/test/resources/full-configurations/2.2.x/includes/httpd.conf | 29 modules/plugins/apache/src/test/resources/full-configurations/2.2.x/mess/1.vhost.conf | 17 modules/plugins/apache/src/test/resources/full-configurations/2.2.x/mess/2.vhost.conf | 13 modules/plugins/apache/src/test/resources/full-configurations/2.2.x/mess/httpd.conf | 29 modules/plugins/apache/src/test/resources/full-configurations/2.2.x/nested/httpd.conf | 57 modules/plugins/apache/src/test/resources/full-configurations/2.2.x/simple/httpd.conf | 47 modules/plugins/apache/src/test/resources/log4j.xml | 2 modules/plugins/apache/src/test/resources/mocked-inventories/generating.query | 1 modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/includes/inventory-single-vhost.xml | 215 ++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/includes/inventory.xml | 539 ++++++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/mess/inventory-single-vhost.xml | 215 ++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/mess/inventory.xml | 543 ++++++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/nested/inventory-single-vhost.xml | 215 ++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/nested/inventory.xml | 543 ++++++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/simple/inventory-single-vhost.xml | 215 ++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/simple/inventory.xml | 539 ++++++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/includes/inventory-with-snmp-anyaddr.xml | 538 ++++++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/includes/inventory-with-snmp.xml | 462 +++++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/includes/inventory-without-snmp.xml | 538 ++++++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/mess/inventory-with-snmp.xml | 313 ++++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/mess/inventory-without-snmp.xml | 310 +++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/nested/inventory-with-snmp.xml | 313 ++++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/nested/inventory-without-snmp.xml | 310 +++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp-anyaddr.xml | 538 ++++++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml | 462 +++++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml | 538 ++++++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/includes/inventory-with-duplicate-main.xml | 538 ++++++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/includes/inventory-with-snmp-anyaddr.xml | 538 ++++++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/includes/inventory-with-snmp.xml | 462 +++++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/includes/inventory-without-snmp.xml | 538 ++++++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/mess/inventory-with-duplicate-main.xml | 386 ++++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/mess/inventory-with-snmp-anyaddr.xml | 310 +++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/mess/inventory-with-snmp.xml | 310 +++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/mess/inventory-without-snmp.xml | 310 +++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/nested/inventory-with-duplicate-main.xml | 386 ++++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/nested/inventory-with-snmp-anyaddr.xml | 310 +++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/nested/inventory-with-snmp.xml | 310 +++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/nested/inventory-without-snmp.xml | 310 +++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-with-duplicate-main.xml | 538 ++++++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp-anyaddr.xml | 538 ++++++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml | 462 +++++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-without-snmp.xml | 538 ++++++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/includes/inventory-single-vhost.xml | 215 ++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/includes/inventory.xml | 539 ++++++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/mess/inventory-single-vhost.xml | 215 ++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/mess/inventory.xml | 377 ++++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/nested/inventory-single-vhost.xml | 215 ++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/nested/inventory.xml | 377 ++++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/simple/inventory-single-vhost.xml | 215 ++ modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/simple/inventory.xml | 539 ++++++ modules/plugins/apache/src/test/resources/snmpd.conf | 141 + modules/test-utils/src/main/java/org/rhq/test/ObjectCollectionSerializer.java | 239 +++ modules/test-utils/src/main/java/org/rhq/test/TokenReplacingProperties.java | 300 +++ modules/test-utils/src/main/java/org/rhq/test/TokenReplacingReader.java | 201 ++ modules/test-utils/src/test/java/org/rhq/test/test/ObjectCollectionSerializerTest.java | 181 ++ pom.xml | 6 106 files changed, 23359 insertions(+), 151 deletions(-)
New commits: commit 04e6a23b75298ee26a6b21da54bbe56d1a74e4db Merge: 8aede51 c2e13e2 Author: Lukas Krejci lkrejci@redhat.com Date: Mon Jul 11 19:39:58 2011 +0200
Merge branch 'apache-integration-tests'
commit c2e13e2556bf584d352314be028333328569502b Author: Lukas Krejci lkrejci@redhat.com Date: Mon Jul 11 19:34:24 2011 +0200
Apache integration tests now only explicitly executed by passing -Dapache.integration.tests, the httpd binary now downloaded as a maven dependency so that we don't require some complicated setup outside of the build process.
diff --git a/modules/plugins/apache/pom.xml b/modules/plugins/apache/pom.xml index 65d1bb2..41625fb 100644 --- a/modules/plugins/apache/pom.xml +++ b/modules/plugins/apache/pom.xml @@ -119,11 +119,57 @@
<activation> <property> - <name>maven.test.skip</name> - <value>!true</value> + <name>apache.integration.tests</name> </property> </activation>
+ <properties> + <httpd.version>2.2.17</httpd.version> + <httpd.install.dir>${basedir}/target/itest/httpd</httpd.install.dir> + </properties> + + <repositories> + <repository> + <id>Httpd binary repo</id> + <name>Repository containing a binaries of httpd to be used with the tests</name> + <url>http://jon01.mw.lab.eng.bos.redhat.com:8042/m2-repo</url> + </repository> + </repositories> + + <dependencies> + <!-- The expected layout of the httpd zip is: + + httpd-${httpd.version}.zip + |-httpd-${httpd.version} + |- x86 + | |- ( ... the x86 build of apache configured as suggested below ... ) + |- x86_64 + |- ( ... the x86_64 build of apache configured as suggested below ... ) + + the httpd is expected to be built with most of the modules not built in: + + (the '- -' below is in reality a double hypen which is not allowed in XML + comments) + cd $HTTPD_CHECKOUT + ./configure - -enable-modules=all - -enable-mods-shared=most - -prefix='somewhere' + + after the build successfully finishes, it is necessary to update the apachectl + script and envvars and envvars-std files in the bin directory of the build target + (configured using the "prefix" option to the configure script) + Those files contain the hardcoded path to the build target directory which needs + to be replaced by the literal ${server.root} so that the tests can update the files + with the actual server root before the tests get executed. + + --> + <dependency> + <groupId>org.apache</groupId> + <artifactId>httpd</artifactId> + <version>${httpd.version}</version> + <scope>test</scope> + <type>zip</type> + </dependency> + </dependencies> + <build> <plugins> <!-- Integration testing voodoo to load and test this plugin with its plugin dependencies --> @@ -144,6 +190,7 @@ <mkdir dir="target/itest" /> <mkdir dir="target/itest/plugins" /> <mkdir dir="target/itest/lib" /> + <mkdir dir="target/itest/httpd" /> <copy toDir="target/itest/plugins" flatten="true"> <fileset dir="${settings.localRepository}/"> <include name="org/rhq/rhq-platform-plugin/${project.version}/rhq-platform-plugin-${project.version}.jar" /> @@ -206,7 +253,30 @@ </move> </then> </if> - <delete dir="target/itest/lib/augeas-native-${augeas.zip.version}" /> + <delete dir="target/itest/lib/augeas-native-${augeas.zip.version}" /> + + <!-- Now deploy the httpd binaries --> + <unzip dest="target/itest/httpd"> + <fileset dir="${settings.localRepository}/org/apache/httpd/${httpd.version}" includes="*.zip" /> + </unzip> + <move todir="target/itest/httpd"> + <fileset dir="target/itest/httpd/httpd-${httpd.version}/x86" /> + </move> + <if> + <or> + <os family="unix" arch="x86_64" /> + <os family="unix" arch="amd64" /> + </or> + <then> + <move todir="target/itest/httpd"> + <fileset dir="target/itest/httpd/httpd-${httpd.version}/x86_64" /> + </move> + </then> + </if> + <delete dir="target/itest/httpd/httpd-${httpd.version}" /> + <chmod perm="ugo+rx"> + <fileset dir="target/itest/httpd/bin" /> + </chmod> </tasks> </configuration> <goals> @@ -241,10 +311,8 @@ <project.artifactId>${project.artifactId}</project.artifactId> <project.version>${project.version}</project.version>
- <apache2.install.dir>PASS THIS IN FROM THE COMMAND LINE</apache2.install.dir> - <apache2.exe.path>bin/httpd</apache2.exe.path> - <apache1.install.dir>PASS THIS IN FROM THE COMMAND LINE</apache1.install.dir> - <apache1.exe.path>bin/httpd</apache1.exe.path> + <apache2.install.dir>${httpd.install.dir}</apache2.install.dir> + <apache2.exe.path>${httpd.install.dir}/bin/httpd</apache2.exe.path>
<!-- generic configurations --> <!--
commit 27fd5b6192b77ea9631f11cbc98689805519124f Author: Lukas Krejci lkrejci@redhat.com Date: Mon Jul 11 19:32:56 2011 +0200
improve error reporting in case of rare interruption of the test case.
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/test/pc/PluginContainerTest.java b/modules/core/plugin-container/src/test/java/org/rhq/test/pc/PluginContainerTest.java index 07a8ea3..06b5ba9 100644 --- a/modules/core/plugin-container/src/test/java/org/rhq/test/pc/PluginContainerTest.java +++ b/modules/core/plugin-container/src/test/java/org/rhq/test/pc/PluginContainerTest.java @@ -175,7 +175,7 @@ public class PluginContainerTest extends JMockTest { Thread.sleep(100); } } catch (InterruptedException e) { - throw new IllegalStateException("Thread interrupted while waiting for plugin container to start."); + throw new IllegalStateException("Thread interrupted while waiting for plugin container to start.", e); }
InventoryManager im = PluginContainer.getInstance().getInventoryManager();
commit 4d02b78649ac3541eef7a3bcc04df2d1ffa2c551 Author: Lukas Krejci lkrejci@redhat.com Date: Mon Jul 11 19:32:11 2011 +0200
Don't spam the console with the debug messages.
diff --git a/modules/plugins/apache/src/test/resources/log4j.xml b/modules/plugins/apache/src/test/resources/log4j.xml index e003864..56284ce 100644 --- a/modules/plugins/apache/src/test/resources/log4j.xml +++ b/modules/plugins/apache/src/test/resources/log4j.xml @@ -6,7 +6,7 @@
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> <param name="Target" value="System.out"/> - <param name="Threshold" value="DEBUG"/> + <param name="Threshold" value="INFO"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/> </layout>
commit 89b7d02ffa3b927969c232fd207019ee33a1c6de Author: Lukas Krejci lkrejci@redhat.com Date: Mon Jul 11 19:30:42 2011 +0200
Adding the nested and "messy" configurations and tests for them. A couple of refactorings to enable more code reuse.
diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java index 9d7e632..1574015 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java @@ -20,12 +20,14 @@ package org.rhq.plugins.apache.upgrade;
import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue;
import java.io.File; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; +import java.io.StringReader; import java.net.InetAddress; import java.net.URI; import java.net.UnknownHostException; @@ -34,6 +36,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -52,6 +55,7 @@ import org.rhq.core.domain.discovery.AvailabilityReport; import org.rhq.core.domain.resource.InventoryStatus; import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.ResourceError; +import org.rhq.core.domain.resource.ResourceErrorType; import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.pc.ServerServices; import org.rhq.core.pc.upgrade.FakeServerInventory; @@ -59,7 +63,10 @@ import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; import org.rhq.core.pluginapi.inventory.PluginContainerDeployment; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; +import org.rhq.core.system.ProcessInfo; import org.rhq.core.system.SystemInfoFactory; +import org.rhq.core.util.stream.StreamUtil; +import org.rhq.plugins.apache.ApacheServerComponent; import org.rhq.plugins.apache.ApacheServerDiscoveryComponent; import org.rhq.plugins.apache.ApacheVirtualHostServiceComponent; import org.rhq.plugins.apache.ApacheVirtualHostServiceDiscoveryComponent; @@ -67,11 +74,14 @@ import org.rhq.plugins.apache.parser.ApacheConfigReader; import org.rhq.plugins.apache.parser.ApacheDirectiveTree; import org.rhq.plugins.apache.parser.ApacheParser; import org.rhq.plugins.apache.parser.ApacheParserImpl; +import org.rhq.plugins.apache.upgrade.UpgradeTestBase.ResourceKeyFormat; import org.rhq.plugins.apache.util.ApacheDeploymentUtil; import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig; import org.rhq.plugins.apache.util.ApacheExecutionUtil; import org.rhq.plugins.apache.util.HttpdAddressUtility; +import org.rhq.plugins.apache.util.RuntimeApacheConfiguration; import org.rhq.plugins.apache.util.VHostSpec; +import org.rhq.plugins.apache.util.VirtualHostLegacyResourceKeyUtil; import org.rhq.test.ObjectCollectionSerializer; import org.rhq.test.TokenReplacingReader; import org.rhq.test.pc.PluginContainerTest; @@ -86,6 +96,10 @@ public class UpgradeTestBase extends PluginContainerTest {
private static final Log LOG = LogFactory.getLog(UpgradeTestBase.class);
+ public enum ResourceKeyFormat { + SNMP, RHQ3, RHQ4 + }; + public class TestSetup { private String configurationName; private FakeServerInventory fakeInventory = new FakeServerInventory(); @@ -162,7 +176,12 @@ public class UpgradeTestBase extends PluginContainerTest {
if (configurationName != null) { if (deploy) { - ApacheDeploymentUtil.deployConfiguration(confDir, configurationFiles, deploymentConfig); + File binDir = new File(serverRootDir, "bin"); + List<File> additionalFilesToProcess = Arrays.asList( + new File(binDir, "apachectl"), + new File(binDir, "envvars"), + new File(binDir, "envvars-std")); + ApacheDeploymentUtil.deployConfiguration(confDir, configurationFiles, additionalFilesToProcess, deploymentConfig); }
//ok, now try to find the ping URL. The best thing is to actually invoke @@ -187,7 +206,31 @@ public class UpgradeTestBase extends PluginContainerTest {
private void doSetup() throws Exception { init(); - execution.invokeOperation("start"); + + int i = 0; + while (i < 10) { + execution.invokeOperation("start"); + + //wait for max 30s for the httpd to start up + int w = 0; + ProcessInfo pi; + while (w < 30) { + pi = execution.getResourceContext().getNativeProcess(); + if (pi != null && pi.isRunning()) { + //all is well, we have an apache process to test with + return; + } + + Thread.sleep(1000); + ++w; + } + + ++i; + + LOG.warn("Could not detect the httpd process after invoking the start operation but the operation didn't throw any exception. I will retry at most ten times and then fail loudly. This has been attempt no. " + i); + } + + throw new IllegalStateException("Failed to start the httpd process even after 10 retries without the apache component complaining. This is super strange."); }
public TestSetup setup() throws Exception { @@ -394,7 +437,6 @@ public class UpgradeTestBase extends PluginContainerTest { public String serverRoot; public String binPath; public Map<String, String> defaultOverrides = new HashMap<String, String>(); - public boolean upgradeShouldSucceed = true;
public void beforeTestSetup(TestSetup testSetup) throws Throwable {
@@ -407,6 +449,34 @@ public class UpgradeTestBase extends PluginContainerTest { public void beforeTests(TestSetup setup) throws Throwable {
} + + public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { + return getFullSuccessfulUpgradeResourceKeys(setup); + } + + public String[] getExpectedResourceKeysWithFailures(TestSetup setup) { + return null; + } + + protected String[] getFullSuccessfulUpgradeResourceKeys(TestSetup setup) { + DeploymentConfig dc = setup.getDeploymentConfig(); + Map<String, String> replacements = dc.getTokenReplacements(); + + VHostSpec vh1 = dc.vhost1.getVHostSpec(replacements); + VHostSpec vh2 = dc.vhost2.getVHostSpec(replacements); + VHostSpec vh3 = dc.vhost3.getVHostSpec(replacements); + VHostSpec vh4 = dc.vhost4.getVHostSpec(replacements); + + String[] ret = new String[5]; + + ret[0] = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY; + ret[1] = ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(vh1.serverName, vh1.hosts); + ret[2] = ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(vh2.serverName, vh2.hosts); + ret[3] = ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(vh3.serverName, vh3.hosts); + ret[4] = ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(vh4.serverName, vh4.hosts); + + return ret; + } }
protected static final String PLATFORM_PLUGIN = "file:target/itest/plugins/rhq-platform-plugin-for-apache-test.jar"; @@ -441,9 +511,8 @@ public class UpgradeTestBase extends PluginContainerTest { boolean testFailed = false; try {
- String[] configFiles = Arrays.copyOf(testConfiguration.apacheConfigurationFiles, testConfiguration.apacheConfigurationFiles.length + 2); + String[] configFiles = Arrays.copyOf(testConfiguration.apacheConfigurationFiles, testConfiguration.apacheConfigurationFiles.length + 1); configFiles[testConfiguration.apacheConfigurationFiles.length] = "/snmpd.conf"; - configFiles[testConfiguration.apacheConfigurationFiles.length + 1] = "/mime.types";
setup.withInventoryFrom(testConfiguration.inventoryFile) .withPlatformResource(platform).withDefaultExpectations().withDefaultOverrides(testConfiguration.defaultOverrides) @@ -460,10 +529,6 @@ public class UpgradeTestBase extends PluginContainerTest {
testConfiguration.beforeTests(setup);
- if (!testConfiguration.upgradeShouldSucceed) { - return; - } - //ok, now we should see the resources upgraded in the fake server inventory. ResourceType serverResourceType = findApachePluginResourceTypeByName("Apache HTTP Server"); ResourceType vhostResourceType = findApachePluginResourceTypeByName("Apache Virtual Host"); @@ -482,32 +547,53 @@ public class UpgradeTestBase extends PluginContainerTest {
Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(vhostResourceType);
- assertEquals(vhosts.size(), 5, "Unexpected number of vhosts discovered found"); - - List<String> expectedResourceKeys = new ArrayList<String>(5); - - DeploymentConfig dc = setup.getDeploymentConfig(); - Map<String, String> replacements = dc.getTokenReplacements(); + String[] expectedRKs = testConfiguration.getExpectedResourceKeysAfterUpgrade(setup);
- VHostSpec vh1 = dc.vhost1.getVHostSpec(replacements); - VHostSpec vh2 = dc.vhost2.getVHostSpec(replacements); - VHostSpec vh3 = dc.vhost3.getVHostSpec(replacements); - VHostSpec vh4 = dc.vhost4.getVHostSpec(replacements); - - expectedResourceKeys.add(ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY); - expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - vh1.serverName, vh1.hosts)); - expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - vh2.serverName, vh2.hosts)); - expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - vh3.serverName, vh3.hosts)); - expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - vh4.serverName, vh4.hosts)); + assertEquals(vhosts.size(), expectedRKs.length, "Unexpected number of vhosts discovered found"); + + List<String> expectedResourceKeys = Arrays.asList(expectedRKs);
for (Resource vhost : vhosts) { assertTrue(expectedResourceKeys.contains(vhost.getResourceKey()), "Unexpected virtual host resource key: '" + vhost.getResourceKey() + "'. Only expecting " + expectedResourceKeys); } + + String[] expectedFailureRKs = testConfiguration.getExpectedResourceKeysWithFailures(setup); + if (expectedFailureRKs != null && expectedFailureRKs.length > 0) { + Set<Resource> failingResources = new HashSet<Resource>(); + + for(String rk : expectedFailureRKs) { + for(Resource r : vhosts) { + if (rk.equals(r.getResourceKey())) { + failingResources.add(r); + break; + } + } + } + + assertEquals(failingResources.size(), expectedFailureRKs.length, "Couldn't find all the resources that should have failed."); + + for(Resource failingResource : failingResources) { + List<ResourceError> errors = failingResource.getResourceErrors(ResourceErrorType.UPGRADE); + assertNotNull(errors, "The main vhost doesn't have any upgrade errors."); + assertEquals(errors.size(), 1, "There should be exactly one upgrade error on the main vhost."); + } + + //check that all other vhosts were not upgraded but have no errors + for(Resource r : vhosts) { + if (failingResources.contains(r)) { + continue; + } + + assertEquals(r.getResourceErrors(ResourceErrorType.UPGRADE).size(), 0, "Unexpected number of resource upgrade errors on vhost " + r); + } + } else { + for(Resource r : vhosts) { + assertEquals(r.getResourceErrors(ResourceErrorType.UPGRADE).size(), 0, "Unexpected number of resource upgrade errors on vhost " + r); + } + } + } catch (AssertionError e) { + throw e; } catch (Throwable t) { testFailed = true; LOG.error("Error during test upgrade execution.", t); @@ -525,6 +611,97 @@ public class UpgradeTestBase extends PluginContainerTest { } }
+ protected void defineRHQ3ResourceKeys(TestConfiguration testConfig, TestSetup setup) throws Exception { + setup.withApacheSetup().init(); + ApacheServerComponent component = setup.withApacheSetup().getExecutionUtil().getServerComponent(); + ApacheDirectiveTree config = component.loadParser(); + config = RuntimeApacheConfiguration.extract(config, component.getCurrentProcessInfo(), component.getCurrentBinaryInfo(), component.getModuleNames(), false); + + DeploymentConfig deployConfig = setup.getDeploymentConfig(); + + VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config); + + Map<String, String> replacements = deployConfig.getTokenReplacements(); + + testConfig.defaultOverrides.put("main.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyMainServerResourceKey()); + + if (deployConfig.vhost1 != null) { + testConfig.defaultOverrides.put("vhost1.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost1.getVHostSpec(replacements))); + } + + if (deployConfig.vhost2 != null) { + testConfig.defaultOverrides.put("vhost2.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost2.getVHostSpec(replacements))); + } + + if (deployConfig.vhost3 != null) { + testConfig.defaultOverrides.put("vhost3.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost3.getVHostSpec(replacements))); + } + + if (deployConfig.vhost4 != null) { + testConfig.defaultOverrides.put("vhost4.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost4.getVHostSpec(replacements))); + } + + setup.withDefaultOverrides(testConfig.defaultOverrides); + } + + protected String interpret(String string, Map<String, String> variables) { + return StreamUtil.slurp(new TokenReplacingReader(new StringReader(string), variables)); + } + + protected static String[] getVHostRKs(TestSetup setup, int[] successfulUpgrades, int[] failedUpgrades, ResourceKeyFormat rkFormat) { + int sucLen = successfulUpgrades == null ? 0 : successfulUpgrades.length; + int failLen = failedUpgrades == null ? 0 : failedUpgrades.length; + + String[] ret = new String[sucLen + failLen]; + + int retIdx = 0; + + Map<String, String> replacements = setup.getInventoryFileReplacements(); + + for(int i = 0; i < sucLen; ++i, ++retIdx) { + int vhostNum = successfulUpgrades[i]; + if (vhostNum == 0) { + ret[retIdx] = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY; + } else { + VHostSpec vhost = setup.getDeploymentConfig().getVHost(vhostNum).getVHostSpec(replacements); + ret[retIdx] = ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(vhost.serverName, vhost.hosts); + } + } + + for(int i = 0; i < failLen; ++i, ++retIdx) { + String variableName = null; + if (failedUpgrades[i] == 0) { + if (rkFormat == ResourceKeyFormat.SNMP) { + variableName = ""; + } else { + variableName = "main.rhq"; + } + } else { + if (rkFormat == ResourceKeyFormat.SNMP) { + variableName += "vhost" + failedUpgrades[i] + "."; + } else { + variableName = "vhost" + failedUpgrades[i] + ".rhq"; + } + } + + switch (rkFormat) { + case RHQ3: + variableName += "3.resource.key"; + break; + case RHQ4: + variableName += "4.resource.key"; + break; + case SNMP: + variableName += "snmp.identifier"; + break; + } + + ret[retIdx] = replacements.get(variableName); + } + + return ret; + } + private static List<ResourceType> getResourceTypesInPlugin(String pluginUri) throws Exception { PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(new URI(pluginUri).toURL()); PluginMetadataParser parser = new PluginMetadataParser(descriptor, diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeConfigurationWithIncludesFromRHQ1_3Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeConfigurationWithIncludesFromRHQ1_3Test.java index 95ea298..8b64bf4 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeConfigurationWithIncludesFromRHQ1_3Test.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeConfigurationWithIncludesFromRHQ1_3Test.java @@ -27,7 +27,10 @@ package org.rhq.plugins.apache.upgrade.rhq1_3_x; public class UpgradeConfigurationWithIncludesFromRHQ1_3Test extends UpgradeSimpleConfigurationFromRHQ1_3Test {
public UpgradeConfigurationWithIncludesFromRHQ1_3Test() { - super("/mocked-inventories/rhq-1.3.x/includes/inventory.xml", "/full-configurations/2.2.x/includes/httpd.conf", "/full-configurations/2.2.x/includes/1.vhost.conf", "/full-configurations/2.2.x/includes/2.vhost.conf"); + super("/mocked-inventories/rhq-1.3.x/includes/inventory.xml", + "/mocked-inventories/rhq-1.3.x/includes/inventory-single-vhost.xml", + "/full-configurations/2.2.x/includes/httpd.conf", "/full-configurations/2.2.x/includes/1.vhost.conf", + "/full-configurations/2.2.x/includes/2.vhost.conf"); }
} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeMessyConfigurationFromRHQ1_3Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeMessyConfigurationFromRHQ1_3Test.java new file mode 100644 index 0000000..59e00d9 --- /dev/null +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeMessyConfigurationFromRHQ1_3Test.java @@ -0,0 +1,35 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.plugins.apache.upgrade.rhq1_3_x; + + +/** + * + * + * @author Lukas Krejci + */ +public class UpgradeMessyConfigurationFromRHQ1_3Test extends UpgradeNestedConfigurationFromRHQ1_3Test { + + public UpgradeMessyConfigurationFromRHQ1_3Test() { + super("/mocked-inventories/rhq-1.3.x/mess/inventory.xml", "/mocked-inventories/rhq-1.3.x/mess/inventory-single-vhost.xml", + "/full-configurations/2.2.x/mess/httpd.conf", "/full-configurations/2.2.x/mess/1.vhost.conf", + "/full-configurations/2.2.x/mess/2.vhost.conf"); + } +} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeNestedConfigurationFromRHQ1_3Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeNestedConfigurationFromRHQ1_3Test.java new file mode 100644 index 0000000..69d7e78 --- /dev/null +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeNestedConfigurationFromRHQ1_3Test.java @@ -0,0 +1,171 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.plugins.apache.upgrade.rhq1_3_x; + +import java.util.HashMap; + +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +import org.rhq.plugins.apache.upgrade.UpgradeTestBase; +import org.rhq.test.pc.PluginContainerSetup; + +/** + * + * + * @author Lukas Krejci + */ +public class UpgradeNestedConfigurationFromRHQ1_3Test extends UpgradeTestBase { + String[] configuredApacheConfigurationFiles; + String configuredInventoryFile; + String configuredInventoryFileWithSingleVHost; + + public UpgradeNestedConfigurationFromRHQ1_3Test() { + configuredApacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/nested/httpd.conf" }; + configuredInventoryFile = "/mocked-inventories/rhq-1.3.x/nested/inventory.xml"; + configuredInventoryFileWithSingleVHost = "/mocked-inventories/rhq-1.3.x/nested/inventory-single-vhost.xml"; + } + + protected UpgradeNestedConfigurationFromRHQ1_3Test(String defaultInventoryFile, String defaultInventoryFileWithSingleVHost, String... defaultApacheConfigurationFiles) { + this.configuredApacheConfigurationFiles = defaultApacheConfigurationFiles; + this.configuredInventoryFile = defaultInventoryFile; + this.configuredInventoryFileWithSingleVHost = defaultInventoryFileWithSingleVHost; + } + + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testWithResolvableServerNames(final String installPath, final String exePath) + throws Throwable { + + testUpgrade(new TestConfiguration() { + { + serverRoot = installPath; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFile; + } + + @Override + public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { + return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.SNMP); + } + }); + } + +// @Test(enabled = false) +// //ApacheServerOperationsDelegate doesn't work with apache 1.3 +// @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) +// @Parameters({ "apache1.install.dir", "apache1.exe.path" }) +// public void testWithResolvableServerNames_Apache1(final String installPath, final String exePath) +// throws Throwable { +// +// testUpgrade(new TestConfiguration() {{ +// serverRoot = installPath; +// binPath = exePath; +// configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; +// apacheConfigurationFiles = configuredApacheConfigurationFiles; +// inventoryFile = configuredInventoryFile; +// }}); +// } + + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }, numberOfInitialDiscoveries = 2) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testWithNonUniqueServerNames(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithSingleVHost; + serverRoot = installPath; + binPath = exePath; + + defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}"); + } + + @Override + public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { + return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.SNMP); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}, numberOfInitialDiscoveries = 2) + @Parameters({"apache2.install.dir", "apache2.exe.path" }) + public void testWithAnyAddress(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFile; + serverRoot = installPath; + binPath = exePath; + + defaultOverrides = new HashMap<String, String>(); + defaultOverrides.put(variableName(configurationName, "listen1"), "0.0.0.0:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "0.0.0.0:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "0.0.0.0:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "0.0.0.0:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "0.0.0.0:${port1}"); + } + + @Override + public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { + return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.SNMP); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path" }) + public void testWithWildcardAddress(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFile; + serverRoot = installPath; + binPath = exePath; + + defaultOverrides = new HashMap<String, String>(); + defaultOverrides.put(variableName(configurationName, "listen1"), "*:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "*:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "*:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "*:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "*:${port1}"); + } + + @Override + public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { + return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.SNMP); + } + }); + } +} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeSimpleConfigurationFromRHQ1_3Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeSimpleConfigurationFromRHQ1_3Test.java index 752c845..167ba8d 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeSimpleConfigurationFromRHQ1_3Test.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeSimpleConfigurationFromRHQ1_3Test.java @@ -19,15 +19,11 @@
package org.rhq.plugins.apache.upgrade.rhq1_3_x;
-import java.util.Comparator; import java.util.HashMap; -import java.util.Set; -import java.util.TreeSet;
import org.testng.annotations.Parameters; import org.testng.annotations.Test;
-import org.rhq.core.domain.resource.Resource; import org.rhq.plugins.apache.upgrade.UpgradeTestBase; import org.rhq.test.pc.PluginContainerSetup;
@@ -41,15 +37,18 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase {
String[] configuredApacheConfigurationFiles; String configuredInventoryFile; + String configuredInventoryFileWithSingleVHost;
public UpgradeSimpleConfigurationFromRHQ1_3Test() { configuredApacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; configuredInventoryFile = "/mocked-inventories/rhq-1.3.x/simple/inventory.xml"; + configuredInventoryFileWithSingleVHost = "/mocked-inventories/rhq-1.3.x/simple/inventory-single-vhost.xml"; }
- protected UpgradeSimpleConfigurationFromRHQ1_3Test(String defaultInventoryFile, String... defaultApacheConfigurationFiles) { + protected UpgradeSimpleConfigurationFromRHQ1_3Test(String defaultInventoryFile, String defaultInventoryFileWithSingleVHost, String... defaultApacheConfigurationFiles) { this.configuredApacheConfigurationFiles = defaultApacheConfigurationFiles; this.configuredInventoryFile = defaultInventoryFile; + this.configuredInventoryFileWithSingleVHost = defaultInventoryFileWithSingleVHost; }
@Test @@ -93,7 +92,7 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase { { configurationName = DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES; apacheConfigurationFiles = configuredApacheConfigurationFiles; - inventoryFile = configuredInventoryFile; + inventoryFile = configuredInventoryFileWithSingleVHost; serverRoot = installPath; binPath = exePath;
@@ -104,30 +103,7 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase { defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}"); defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}"); defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}"); - } - - @Override - public void beforePluginContainerStart(TestSetup setup) { - //in this scenario, the RHQ 1.3 would only discover 1 vhost (and the main vhost), because they would have the same resource key - //due to the same ServerName. I need to process the default inventory to reflect that otherwise I would get upgrade - //failures. - - Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(findApachePluginResourceTypeByName("Apache Virtual Host")); - Set<Resource> uniques = new TreeSet<Resource>(new Comparator<Resource>() { - public int compare(Resource a, Resource b) { - return a.getResourceKey().compareTo(b.getResourceKey()); - } - }); - - for(Resource vhost : vhosts) { - if (uniques.contains(vhost)) { - //remove the vhost from the server's inventory - setup.getFakeInventory().removeResource(vhost); - } else { - uniques.add(vhost); - } - } - } + } }); }
@@ -144,7 +120,6 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase { serverRoot = installPath; binPath = exePath;
- defaultOverrides = new HashMap<String, String>(); defaultOverrides.put(variableName(configurationName, "listen1"), "0.0.0.0:${port1}"); defaultOverrides.put(variableName(configurationName, "listen2"), "0.0.0.0:${port2}"); defaultOverrides.put(variableName(configurationName, "listen3"), "0.0.0.0:${port3}"); @@ -167,7 +142,6 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase { serverRoot = installPath; binPath = exePath;
- defaultOverrides = new HashMap<String, String>(); defaultOverrides.put(variableName(configurationName, "listen1"), "*:${port1}"); defaultOverrides.put(variableName(configurationName, "listen2"), "*:${port2}"); defaultOverrides.put(variableName(configurationName, "listen3"), "*:${port3}"); diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeMessyConfigurationFromRHQ3_0_0Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeMessyConfigurationFromRHQ3_0_0Test.java new file mode 100644 index 0000000..03dd443 --- /dev/null +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeMessyConfigurationFromRHQ3_0_0Test.java @@ -0,0 +1,34 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.plugins.apache.upgrade.rhq3_0_0; + +/** + * + * + * @author Lukas Krejci + */ +public class UpgradeMessyConfigurationFromRHQ3_0_0Test extends UpgradeNestedConfigurationFromRHQ3_0_0Test { + + public UpgradeMessyConfigurationFromRHQ3_0_0Test() { + super("/mocked-inventories/rhq-3.0.0/mess/inventory-without-snmp.xml", + "/mocked-inventories/rhq-3.0.0/mess/inventory-with-snmp.xml", "/full-configurations/2.2.x/mess/httpd.conf", + "/full-configurations/2.2.x/mess/1.vhost.conf", "/full-configurations/2.2.x/mess/2.vhost.conf"); + } +} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeNestedConfigurationFromRHQ3_0_0Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeNestedConfigurationFromRHQ3_0_0Test.java new file mode 100644 index 0000000..4e16208 --- /dev/null +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeNestedConfigurationFromRHQ3_0_0Test.java @@ -0,0 +1,378 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.plugins.apache.upgrade.rhq3_0_0; + +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +import org.rhq.plugins.apache.upgrade.UpgradeTestBase; +import org.rhq.test.pc.PluginContainerSetup; + +/** + * + * + * @author Lukas Krejci + */ +public class UpgradeNestedConfigurationFromRHQ3_0_0Test extends UpgradeTestBase { + String[] configuredApacheConfigurationFiles; + private String configuredInventoryFileWithoutSNMP; + private String configuredInventoryFileWithSNMP; + + public UpgradeNestedConfigurationFromRHQ3_0_0Test() { + configuredApacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/nested/httpd.conf" }; + configuredInventoryFileWithoutSNMP = "/mocked-inventories/rhq-3.0.0/nested/inventory-without-snmp.xml"; + configuredInventoryFileWithSNMP = "/mocked-inventories/rhq-3.0.0/nested/inventory-with-snmp.xml"; + } + + /** + * @param configuredApacheConfigurationFiles + * @param configuredInventoryFileWithoutSNMP + * @param configuredInventoryFileWithSNMP + * @param configuredInventoryFileWithSNMPWithAnyAddress + */ + public UpgradeNestedConfigurationFromRHQ3_0_0Test(String configuredInventoryFileWithoutSNMP, + String configuredInventoryFileWithSNMP, String... configuredApacheConfigurationFiles) { + this.configuredApacheConfigurationFiles = configuredApacheConfigurationFiles; + this.configuredInventoryFileWithoutSNMP = configuredInventoryFileWithoutSNMP; + this.configuredInventoryFileWithSNMP = configuredInventoryFileWithSNMP; + } + + /** + * This tests the upgrade from RHQ 3.0.0 where the apache server was discovered without SNMP support. + * The Main Server URL must have been set in this case, otherwise the component would fail to start + * and therefore the vhost discovery wouldn't even take place. + */ + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }, numberOfInitialDiscoveries = 2) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testWithResolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithoutSNMP; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + + //just define the servername value without actually setting the ${servername.directive} so that + //we don't define a servername directive itself but do have a value for the actual server name. + //this is deduced by apache and the plugin but tests aren't that clever. + defaultOverrides.put("servername", "${localhost}"); + } + + @Override + public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { + return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3); + } + }); + } + + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }, numberOfInitialDiscoveries = 2) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testWithUnresolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithoutSNMP; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES; + + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), + "ServerName ${unresolvable.host}:${listen1}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), + "ServerName ${unresolvable.host}:${listen2}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), + "ServerName ${unresolvable.host}:${listen3}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), + "ServerName ${unresolvable.host}:${listen4}"); + } + + @Override + public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { + return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3); + } + }); + } + + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }, numberOfInitialDiscoveries = 2) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testWithNonUniqueNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithoutSNMP; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES; + + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), + "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), + "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), + "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), + "ServerName ${unresolvable.host}"); + } + + @Override + public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { + return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3); + } + }); + } + + /** + * This tests the upgrade from RHQ 3.0.0 where the Apache server was discovered with the following: + * <p> + * <ol> + * <li> SNMP enabled + * <li> Main URL set or unset (it doesn't make a difference here) + * </ol> + * @param installDir + * @param exePath + * @throws Throwable + */ + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testWithResolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithSNMP; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + defineRHQ3ResourceKeys(this, testSetup); + } + + @Override + public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { + return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3); + } + }); + } + + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testWithUnresolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithSNMP; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + + defaultOverrides.put(variableName(configurationName, "servername.directive"), + "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), + "ServerName ${unresolvable.host}:${listen1}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), + "ServerName ${unresolvable.host}:${listen2}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), + "ServerName ${unresolvable.host}:${listen3}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), + "ServerName ${unresolvable.host}:${listen4}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + defineRHQ3ResourceKeys(this, testSetup); + } + + @Override + public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { + return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3); + } + }); + } + + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testWithNonUniqueNamesWithSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithSNMP; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + + defaultOverrides.put(variableName(configurationName, "servername.directive"), + "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), + "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), + "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), + "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), + "ServerName ${unresolvable.host}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + defineRHQ3ResourceKeys(this, testSetup); + } + + @Override + public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { + return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3); + } + }); + } + + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testWithAnyAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithoutSNMP; + serverRoot = installPath; + binPath = exePath; + + //just define the servername value without actually setting the ${servername.directive} so that + //we don't define a servername directive itself but do have a value for the actual server name. + //this is deduced by apache and the plugin but tests aren't that clever. + defaultOverrides.put("servername", "${localhost}"); + defaultOverrides.put(variableName(configurationName, "listen1"), "0.0.0.0:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "0.0.0.0:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "0.0.0.0:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "0.0.0.0:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "0.0.0.0:${port1}"); + } + + @Override + public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { + return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3); + } + }); + } + + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testWithAnyAddressWithSNMP(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithSNMP; + serverRoot = installPath; + binPath = exePath; + + defaultOverrides.put(variableName(configurationName, "listen1"), "0.0.0.0:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "0.0.0.0:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "0.0.0.0:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "0.0.0.0:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "0.0.0.0:${port1}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + defineRHQ3ResourceKeys(this, testSetup); + } + + @Override + public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { + return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3); + } + }); + } + + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testWithWildcardAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithoutSNMP; + serverRoot = installPath; + binPath = exePath; + + //just define the servername value without actually setting the ${servername.directive} so that + //we don't define a servername directive itself but do have a value for the actual server name. + //this is deduced by apache and the plugin but tests aren't that clever. + defaultOverrides.put("servername", "${localhost}"); + defaultOverrides.put(variableName(configurationName, "listen1"), "*:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "*:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "*:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "*:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "*:${port1}"); + } + + @Override + public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { + return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3); + } + }); + } + + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testWithWildcardAddressWithSNMP(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithSNMP; + serverRoot = installPath; + binPath = exePath; + + defaultOverrides.put(variableName(configurationName, "listen1"), "*:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "*:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "*:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "*:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "*:${port1}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + defineRHQ3ResourceKeys(this, testSetup); + } + + @Override + public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { + return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, ResourceKeyFormat.RHQ3); + } + }); + } +} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java index c4399d9..ececb12 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java @@ -20,27 +20,10 @@ package org.rhq.plugins.apache.upgrade.rhq3_0_0;
-import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import java.util.List; -import java.util.Map; -import java.util.Set; - import org.testng.annotations.Parameters; import org.testng.annotations.Test;
-import org.rhq.core.domain.resource.Resource; -import org.rhq.core.domain.resource.ResourceError; -import org.rhq.core.domain.resource.ResourceErrorType; -import org.rhq.core.domain.resource.ResourceType; -import org.rhq.plugins.apache.ApacheServerComponent; -import org.rhq.plugins.apache.ApacheServerDiscoveryComponent; -import org.rhq.plugins.apache.parser.ApacheDirectiveTree; import org.rhq.plugins.apache.upgrade.UpgradeTestBase; -import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig; -import org.rhq.plugins.apache.util.RuntimeApacheConfiguration; -import org.rhq.plugins.apache.util.VirtualHostLegacyResourceKeyUtil; import org.rhq.test.pc.PluginContainerSetup;
/** @@ -167,21 +150,11 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - upgradeShouldSucceed = false; }
@Override public void beforeTestSetup(TestSetup testSetup) throws Throwable { - beforeTestSetupWithSNMP(this, testSetup); - } - - /** - * Do our own tests here, because the generic test method won't do much, since - * we told it that the upgrade won't succeed. - */ - @Override - public void beforeTests(TestSetup setup) throws Throwable { - testWithSNMP(this, setup); + defineRHQ3ResourceKeys(this, testSetup); } }); } @@ -197,7 +170,6 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - upgradeShouldSucceed = false;
defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}:${listen1}"); @@ -208,16 +180,7 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
@Override public void beforeTestSetup(TestSetup testSetup) throws Throwable { - beforeTestSetupWithSNMP(this, testSetup); - } - - /** - * Do our own tests here, because the generic test method won't do much, since - * we told it that the upgrade won't succeed. - */ - @Override - public void beforeTests(TestSetup setup) throws Throwable { - testWithSNMP(this, setup); + defineRHQ3ResourceKeys(this, testSetup); } }); } @@ -233,7 +196,6 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - upgradeShouldSucceed = false;
defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}"); @@ -244,16 +206,7 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
@Override public void beforeTestSetup(TestSetup testSetup) throws Throwable { - beforeTestSetupWithSNMP(this, testSetup); - } - - /** - * Do our own tests here, because the generic test method won't do much, since - * we told it that the upgrade won't succeed. - */ - @Override - public void beforeTests(TestSetup setup) throws Throwable { - testWithSNMP(this, setup); + defineRHQ3ResourceKeys(this, testSetup); } }); } @@ -319,7 +272,7 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
@Override public void beforeTestSetup(TestSetup testSetup) throws Throwable { - beforeTestSetupWithSNMP(this, testSetup); + defineRHQ3ResourceKeys(this, testSetup); } }); } @@ -362,7 +315,6 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase inventoryFile = configuredInventoryFileWithSNMP; serverRoot = installPath; binPath = exePath; - upgradeShouldSucceed = false;
defaultOverrides.put(variableName(configurationName, "listen1"), "*:${port1}"); defaultOverrides.put(variableName(configurationName, "listen2"), "*:${port2}"); @@ -373,103 +325,8 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
@Override public void beforeTestSetup(TestSetup testSetup) throws Throwable { - beforeTestSetupWithSNMP(this, testSetup); - } - - /** - * Do our own tests here, because the generic test method won't do much, since - * we told it that the upgrade won't succeed. - */ - @Override - public void beforeTests(TestSetup setup) throws Throwable { - testWithSNMP(this, setup); + defineRHQ3ResourceKeys(this, testSetup); } }); } - - private void beforeTestSetupWithSNMP(TestConfiguration testConfig, TestSetup setup) throws Exception { - setup.withApacheSetup().init(); - ApacheServerComponent component = setup.withApacheSetup().getExecutionUtil().getServerComponent(); - ApacheDirectiveTree config = component.loadParser(); - config = RuntimeApacheConfiguration.extract(config, component.getCurrentProcessInfo(), component.getCurrentBinaryInfo(), component.getModuleNames(), false); - - DeploymentConfig deployConfig = setup.getDeploymentConfig(); - - VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config); - - Map<String, String> replacements = deployConfig.getTokenReplacements(); - - testConfig.defaultOverrides.put("main.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyMainServerResourceKey()); - - if (deployConfig.vhost1 != null) { - testConfig.defaultOverrides.put("vhost1.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost1.getVHostSpec(replacements))); - } - - if (deployConfig.vhost2 != null) { - testConfig.defaultOverrides.put("vhost2.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost2.getVHostSpec(replacements))); - } - - if (deployConfig.vhost3 != null) { - testConfig.defaultOverrides.put("vhost3.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost3.getVHostSpec(replacements))); - } - - if (deployConfig.vhost4 != null) { - testConfig.defaultOverrides.put("vhost4.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost4.getVHostSpec(replacements))); - } - - setup.withDefaultOverrides(testConfig.defaultOverrides); - } - - private void testWithSNMP(TestConfiguration testConfig, TestSetup setup) { - //ok, now we should see the resources upgraded in the fake server inventory. - ResourceType serverResourceType = findApachePluginResourceTypeByName("Apache HTTP Server"); - ResourceType vhostResourceType = findApachePluginResourceTypeByName("Apache Virtual Host"); - - Set<Resource> servers = setup.getFakeInventory().findResourcesByType(serverResourceType); - - assertEquals(servers.size(), 1, "There should be exactly one apache server discovered."); - - Resource server = servers.iterator().next(); - - String expectedResourceKey = ApacheServerDiscoveryComponent.formatResourceKey(testConfig.serverRoot, testConfig.serverRoot - + "/conf/httpd.conf"); - - assertEquals(server.getResourceKey(), expectedResourceKey, - "The server resource key doesn't seem to be upgraded."); - - Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(vhostResourceType); - - assertEquals(vhosts.size(), 4, "Unexpected number of vhosts discovered found"); - - //let's check that the main vhost has a an upgrade error attached to it - ApacheServerComponent component = setup.withApacheSetup().getExecutionUtil().getServerComponent(); - ApacheDirectiveTree config = component.loadParser(); - config = RuntimeApacheConfiguration.extract(config, component.getCurrentProcessInfo(), component.getCurrentBinaryInfo(), component.getModuleNames(), false); - VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config); - - String mainVhostRK = keyUtil.getRHQ3NonSNMPLegacyMainServerResourceKey(); - - Resource mainVhost = null; - for(Resource r : vhosts) { - if (mainVhostRK.equals(r.getResourceKey())) { - mainVhost = r; - break; - } - } - - assertNotNull(mainVhost, "Couldn't find the main vhost with the expected resource key '" + mainVhostRK + "'."); - - List<ResourceError> errors = mainVhost.getResourceErrors(ResourceErrorType.UPGRADE); - assertNotNull(errors, "The main vhost doesn't have any upgrade errors."); - assertEquals(errors.size(), 1, "There should be exactly one upgrade error on the main vhost."); - - //check that all other vhosts were not upgraded but have no errors - for(Resource r : vhosts) { - if (r.equals(mainVhost)) { - continue; - } - - assertEquals(r.getResourceErrors(ResourceErrorType.UPGRADE).size(), 0, "Unexpected number of resource upgrade errors on non-main vhost " + r); - } - } } diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeMessyConfigurationFromRHQ3_0_1Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeMessyConfigurationFromRHQ3_0_1Test.java new file mode 100644 index 0000000..590728b --- /dev/null +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeMessyConfigurationFromRHQ3_0_1Test.java @@ -0,0 +1,38 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.plugins.apache.upgrade.rhq3_0_1; + +/** + * + * + * @author Lukas Krejci + */ +public class UpgradeMessyConfigurationFromRHQ3_0_1Test extends UpgradeNestedConfigurationFromRHQ3_0_1Test { + + public UpgradeMessyConfigurationFromRHQ3_0_1Test() { + super("/mocked-inventories/rhq-3.0.1/mess/inventory-with-snmp.xml", + "/mocked-inventories/rhq-3.0.1/mess/inventory-without-snmp.xml", + "/mocked-inventories/rhq-3.0.1/mess/inventory-with-snmp-anyaddr.xml", + "/mocked-inventories/rhq-3.0.1/mess/inventory-with-duplicate-main.xml", + "/full-configurations/2.2.x/mess/httpd.conf", "/full-configurations/2.2.x/mess/1.vhost.conf", + "/full-configurations/2.2.x/mess/2.vhost.conf"); + } + +} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeNestedConfigurationFromRHQ3_0_1Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeNestedConfigurationFromRHQ3_0_1Test.java new file mode 100644 index 0000000..278b72c --- /dev/null +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeNestedConfigurationFromRHQ3_0_1Test.java @@ -0,0 +1,479 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.plugins.apache.upgrade.rhq3_0_1; + +import java.util.Arrays; + +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +import org.rhq.plugins.apache.upgrade.UpgradeTestBase; +import org.rhq.test.pc.PluginContainerSetup; + +/** + * + * + * @author Lukas Krejci + */ +public class UpgradeNestedConfigurationFromRHQ3_0_1Test extends UpgradeTestBase { + + private String[] configuredApacheConfigurationFiles; + private String configuredInventoryFileWithSNMP; + private String configuredInventoryFileWithoutSNMP; + private String configuredInventoryFileWithSNMPWithAnyAddress; + private String configuredInventoryFileWithDuplicateMain; + + + public UpgradeNestedConfigurationFromRHQ3_0_1Test() { + configuredApacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/nested/httpd.conf"}; + configuredInventoryFileWithSNMP = "/mocked-inventories/rhq-3.0.1/nested/inventory-with-snmp.xml"; + configuredInventoryFileWithoutSNMP = "/mocked-inventories/rhq-3.0.1/nested/inventory-without-snmp.xml"; + configuredInventoryFileWithSNMPWithAnyAddress = "/mocked-inventories/rhq-3.0.1/nested/inventory-with-snmp-anyaddr.xml"; + configuredInventoryFileWithDuplicateMain = "/mocked-inventories/rhq-3.0.1/nested/inventory-with-duplicate-main.xml"; + } + + /** + * @param configuredApacheConfigurationFiles + * @param configuredInventoryFileWithSNMP + * @param configuredInventoryFileWithoutSNMP + * @param configuredInventoryFileWithSNMPWithAnyAddress + * @param configuredInventoryFileWithDuplicateMain + */ + protected UpgradeNestedConfigurationFromRHQ3_0_1Test(String configuredInventoryFileWithSNMP, + String configuredInventoryFileWithoutSNMP, String configuredInventoryFileWithSNMPWithAnyAddress, + String configuredInventoryFileWithDuplicateMain, String... configuredApacheConfigurationFiles) { + + this.configuredApacheConfigurationFiles = configuredApacheConfigurationFiles; + this.configuredInventoryFileWithSNMP = configuredInventoryFileWithSNMP; + this.configuredInventoryFileWithoutSNMP = configuredInventoryFileWithoutSNMP; + this.configuredInventoryFileWithSNMPWithAnyAddress = configuredInventoryFileWithSNMPWithAnyAddress; + this.configuredInventoryFileWithDuplicateMain = configuredInventoryFileWithDuplicateMain; + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path"}) + public void testWithResolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithSNMP; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + defineRHQ3ResourceKeys(this, testSetup); + } + + @Override + public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { + return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null); + } + }); + } + +// @Test +// @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) +// @Parameters({ "apache2.install.dir", "apache2.exe.path" }) +// public void testWithResolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { +// testUpgrade(new TestConfiguration() { +// { +// apacheConfigurationFiles = configuredApacheConfigurationFiles; +// inventoryFile = configuredInventoryFileWithoutSNMP; +// serverRoot = installDir; +// binPath = exePath; +// configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; +// +// //just define the servername value without actually setting the ${servername.directive} so that +// //we don't define a servername directive itself but do have a value for the actual server name. +// //this is deduced by apache and the plugin but tests aren't that clever. +// defaultOverrides.put("servername", "${localhost.ip}"); +// } +// +// @Override +// public void beforeTestSetup(TestSetup testSetup) throws Throwable { +// defineRHQ3ResourceKeys(this, testSetup); +// } +// +// @Override +// public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { +// return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null); +// } +// }); +// } +// +// @Test +// @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) +// @Parameters({"apache2.install.dir", "apache2.exe.path"}) +// public void testWithUnresolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable { +// testUpgrade(new TestConfiguration() { +// { +// apacheConfigurationFiles = configuredApacheConfigurationFiles; +// inventoryFile = configuredInventoryFileWithSNMP; +// serverRoot = installDir; +// binPath = exePath; +// configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; +// +// defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); +// defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}:${listen1}"); +// defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}:${listen2}"); +// defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}:${listen3}"); +// defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}:${listen4}"); +// } +// +// @Override +// public void beforeTestSetup(TestSetup testSetup) throws Throwable { +// defineRHQ3ResourceKeys(this, testSetup); +// } +// +// @Override +// public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { +// return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null); +// } +// }); +// } +// +// @Test +// @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) +// @Parameters({ "apache2.install.dir", "apache2.exe.path" }) +// public void testWithUnresolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { +// testUpgrade(new TestConfiguration() { +// { +// apacheConfigurationFiles = configuredApacheConfigurationFiles; +// inventoryFile = configuredInventoryFileWithoutSNMP; +// serverRoot = installDir; +// binPath = exePath; +// configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; +// +// defaultOverrides.put(variableName(configurationName, "servername.directive"), +// "ServerName ${unresolvable.host}"); +// //we use this in the serialized inventory to init the URL of the main server. The localhost.ip is actually what +// //the RHQ 301 discovers even though unresolvable.host is specified in the ServerName directive. +// defaultOverrides.put("servername", "${localhost.ip}"); +// defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), +// "ServerName ${unresolvable.host}:${port1}"); +// defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), +// "ServerName ${unresolvable.host}:${port2}"); +// defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), +// "ServerName ${unresolvable.host}:${port3}"); +// defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), +// "ServerName ${unresolvable.host}:${port4}"); +// } +// +// @Override +// public void beforeTestSetup(TestSetup testSetup) throws Throwable { +// defineRHQ3ResourceKeys(this, testSetup); +// } +// +// @Override +// public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { +// return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null); +// } +// }); +// } +// +// @Test +// @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) +// @Parameters({"apache2.install.dir", "apache2.exe.path"}) +// public void testWithNonUniqueNamesWithSNMP(final String installDir, final String exePath) throws Throwable { +// testUpgrade(new TestConfiguration() { +// { +// apacheConfigurationFiles = configuredApacheConfigurationFiles; +// inventoryFile = configuredInventoryFileWithSNMP; +// serverRoot = installDir; +// binPath = exePath; +// configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; +// +// defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); +// defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}"); +// defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}"); +// defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}"); +// defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}"); +// } +// +// @Override +// public void beforeTestSetup(TestSetup testSetup) throws Throwable { +// defineRHQ3ResourceKeys(this, testSetup); +// } +// +// @Override +// public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { +// return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null); +// } +// }); +// } +// +// @Test +// @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) +// @Parameters({"apache2.install.dir", "apache2.exe.path"}) +// public void testWithNonUniqueNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { +// testUpgrade(new TestConfiguration() { +// { +// apacheConfigurationFiles = configuredApacheConfigurationFiles; +// inventoryFile = configuredInventoryFileWithoutSNMP; +// serverRoot = installDir; +// binPath = exePath; +// configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; +// +// //we use this in the serialized inventory to init the URL of the main server. The localhost.ip is actually what +// //the RHQ 301 discovers even though unresolvable.host is specified in the ServerName directive. +// defaultOverrides.put("servername", "${localhost.ip}"); +// defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); +// defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), +// "ServerName ${unresolvable.host}"); +// defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), +// "ServerName ${unresolvable.host}"); +// defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), +// "ServerName ${unresolvable.host}"); +// defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), +// "ServerName ${unresolvable.host}"); +// } +// +// @Override +// public void beforeTestSetup(TestSetup testSetup) throws Throwable { +// defineRHQ3ResourceKeys(this, testSetup); +// } +// +// @Override +// public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { +// return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null); +// } +// }); +// } +// +// /** +// * The duplicate Main vhosts "condition" was triggered by: +// * <ol> +// * <li>Disabling SNMP by putting in an invalid hostname +// * <li>Changing the URL of the apache server to some "other" value +// * <li>Running discovery +// * </ol> +// * From that point on, 2 Main vhosts live in the inventory and the inventory has the "rest" +// * of the resource keys coming from the SNMP based discovery. +// * <p> +// * It is not possible to recover from such condition automatically during +// * the resource upgrade, so the only thing we need to check here is that +// * the two main vhosts are marked as failed upgrade and that the rest of the vhosts +// * are not upgraded and have no upgrade errors attached. +// * +// * @param installDir +// * @param exePath +// * @throws Throwable +// */ +// @Test +// @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) +// @Parameters({"apache2.install.dir", "apache2.exe.path"}) +// public void testDuplicateMainVhostsMarkedAsFailedUpgrade(final String installDir, final String exePath) throws Throwable { +// testUpgrade(new TestConfiguration() { +// { +// apacheConfigurationFiles = configuredApacheConfigurationFiles; +// inventoryFile = configuredInventoryFileWithDuplicateMain; +// serverRoot = installDir; +// binPath = exePath; +// configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; +// } +// +// @Override +// public void beforeTestSetup(TestSetup testSetup) throws Throwable { +// defineRHQ3ResourceKeys(this, testSetup); +// } +// +// @Override +// public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { +// //the inventory has main1, main2 and vhost4 +// //main2 and main1 would be upgraded to the same resource key (MainServer) +// //the upgrade therefore fails and no discoveries are being made +// //therefore we expect the two mains to have the old resource key and +// //4 to have the new resource key. the vhost2 never gets a chance to +// //be discovered. +// +// String[] ret = getVHostRKs(setup, new int[] { 4 }, new int[] { 0 }, ResourceKeyFormat.RHQ3); +// String mainVhost2RK = setup.getInventoryFileReplacements().get("snmp.identifier"); +// +// ret = Arrays.copyOf(ret, ret.length + 1); +// ret[ret.length - 1] = mainVhost2RK; +// +// return ret; +// } +// +// @Override +// public String[] getExpectedResourceKeysWithFailures(TestSetup setup) { +// String mainVhost1RK = setup.getInventoryFileReplacements().get("main.rhq3.resource.key"); +// String mainVhost2RK = setup.getInventoryFileReplacements().get("snmp.identifier"); +// return new String[] { mainVhost1RK, mainVhost2RK }; +// } +// }); +// } +// +// @Test +// @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) +// @Parameters({"apache2.install.dir", "apache2.exe.path" }) +// public void testWithAnyAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable { +// testUpgrade(new TestConfiguration() { +// { +// configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; +// +// apacheConfigurationFiles = configuredApacheConfigurationFiles; +// //yes, the inventory file can be the same for both the with and without snmp tests because +// //they both yield the same inventory in this case. +// inventoryFile = configuredInventoryFileWithSNMPWithAnyAddress; +// serverRoot = installPath; +// binPath = exePath; +// +// //just define the servername value without actually setting the ${servername.directive} so that +// //we don't define a servername directive itself but do have a value for the actual server name. +// //this is deduced by apache and the plugin but tests aren't that clever. +// defaultOverrides.put("servername", "${localhost.ip}"); +// defaultOverrides.put(variableName(configurationName, "listen1"), "0.0.0.0:${port1}"); +// defaultOverrides.put(variableName(configurationName, "listen2"), "0.0.0.0:${port2}"); +// defaultOverrides.put(variableName(configurationName, "listen3"), "0.0.0.0:${port3}"); +// defaultOverrides.put(variableName(configurationName, "listen4"), "0.0.0.0:${port4}"); +// defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "0.0.0.0:${port1}"); +// } +// +// @Override +// public void beforeTestSetup(TestSetup testSetup) throws Throwable { +// defineRHQ3ResourceKeys(this, testSetup); +// } +// +// @Override +// public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { +// return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null); +// } +// }); +// } +// +// /** +// * Unlike other SNMP tests this one actually succeeds to upgrade because of the messed up discovery that +// * RHQ 3.0.0 would perform. In case of any-address (0.0.0.0), the main vhost would get the MainServer +// * resource key even with SNMP, because RHQ 3 codebase wouldn't be able to match what it think should +// * have been the SNMP record with the actual results from SNMP module. +// * <p> +// * Because of this, RHQ 3 discovers all 5 vhosts and the upgrade code is therefore able to successfully +// * upgrade all of them. +// * +// * @param installPath +// * @param exePath +// * @throws Throwable +// */ +// @Test +// @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) +// @Parameters({"apache2.install.dir", "apache2.exe.path" }) +// public void testWithAnyAddressWithSNMP(final String installPath, final String exePath) throws Throwable { +// testUpgrade(new TestConfiguration() { +// { +// configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; +// +// apacheConfigurationFiles = configuredApacheConfigurationFiles; +// inventoryFile = configuredInventoryFileWithSNMPWithAnyAddress; +// serverRoot = installPath; +// binPath = exePath; +// +// defaultOverrides.put(variableName(configurationName, "listen1"), "0.0.0.0:${port1}"); +// defaultOverrides.put(variableName(configurationName, "listen2"), "0.0.0.0:${port2}"); +// defaultOverrides.put(variableName(configurationName, "listen3"), "0.0.0.0:${port3}"); +// defaultOverrides.put(variableName(configurationName, "listen4"), "0.0.0.0:${port4}"); +// defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "0.0.0.0:${port1}"); +// } +// +// @Override +// public void beforeTestSetup(TestSetup testSetup) throws Throwable { +// defineRHQ3ResourceKeys(this, testSetup); +// } +// +// @Override +// public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { +// return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null); +// } +// }); +// } +// +// @Test +// @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) +// @Parameters({"apache2.install.dir", "apache2.exe.path" }) +// public void testWithWildcardAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable { +// testUpgrade(new TestConfiguration() { +// { +// configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; +// +// apacheConfigurationFiles = configuredApacheConfigurationFiles; +// inventoryFile = configuredInventoryFileWithoutSNMP; +// serverRoot = installPath; +// binPath = exePath; +// +// //just define the servername value without actually setting the ${servername.directive} so that +// //we don't define a servername directive itself but do have a value for the actual server name. +// //this is deduced by apache and the plugin but tests aren't that clever. +// defaultOverrides.put("servername", "${localhost.ip}"); +// defaultOverrides.put(variableName(configurationName, "listen1"), "*:${port1}"); +// defaultOverrides.put(variableName(configurationName, "listen2"), "*:${port2}"); +// defaultOverrides.put(variableName(configurationName, "listen3"), "*:${port3}"); +// defaultOverrides.put(variableName(configurationName, "listen4"), "*:${port4}"); +// defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "*:${port1}"); +// } +// +// @Override +// public void beforeTestSetup(TestSetup testSetup) throws Throwable { +// defineRHQ3ResourceKeys(this, testSetup); +// } +// +// +// @Override +// public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { +// return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null); +// } +// }); +// } +// +// @Test +// @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) +// @Parameters({"apache2.install.dir", "apache2.exe.path" }) +// public void testWithWildcardAddressWithSNMP(final String installPath, final String exePath) throws Throwable { +// testUpgrade(new TestConfiguration() { +// { +// configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; +// +// apacheConfigurationFiles = configuredApacheConfigurationFiles; +// inventoryFile = configuredInventoryFileWithSNMP; +// serverRoot = installPath; +// binPath = exePath; +// +// defaultOverrides.put(variableName(configurationName, "listen1"), "*:${port1}"); +// defaultOverrides.put(variableName(configurationName, "listen2"), "*:${port2}"); +// defaultOverrides.put(variableName(configurationName, "listen3"), "*:${port3}"); +// defaultOverrides.put(variableName(configurationName, "listen4"), "*:${port4}"); +// defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "*:${port1}"); +// } +// +// @Override +// public void beforeTestSetup(TestSetup testSetup) throws Throwable { +// defineRHQ3ResourceKeys(this, testSetup); +// } +// +// @Override +// public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { +// return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null); +// } +// }); +// } +} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java index fa88f8d..4af1879 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java @@ -19,33 +19,12 @@
package org.rhq.plugins.apache.upgrade.rhq3_0_1;
-import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import java.io.StringReader; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.Arrays;
import org.testng.annotations.Parameters; import org.testng.annotations.Test;
-import org.rhq.core.domain.resource.Resource; -import org.rhq.core.domain.resource.ResourceError; -import org.rhq.core.domain.resource.ResourceErrorType; -import org.rhq.core.domain.resource.ResourceType; -import org.rhq.core.util.stream.StreamUtil; -import org.rhq.plugins.apache.ApacheServerComponent; -import org.rhq.plugins.apache.ApacheServerDiscoveryComponent; -import org.rhq.plugins.apache.parser.ApacheDirectiveTree; import org.rhq.plugins.apache.upgrade.UpgradeTestBase; -import org.rhq.plugins.apache.upgrade.UpgradeTestBase.TestConfiguration; -import org.rhq.plugins.apache.upgrade.UpgradeTestBase.TestSetup; -import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig; -import org.rhq.plugins.apache.util.RuntimeApacheConfiguration; -import org.rhq.plugins.apache.util.VirtualHostLegacyResourceKeyUtil; -import org.rhq.test.TokenReplacingReader; import org.rhq.test.pc.PluginContainerSetup;
/** @@ -99,23 +78,12 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - upgradeShouldSucceed = false; }
@Override public void beforeTestSetup(TestSetup testSetup) throws Throwable { defineRHQ3ResourceKeys(this, testSetup); } - - /** - * Do our own tests here, because the generic test method won't do much, since - * we told it that the upgrade won't succeed. - */ - @Override - public void beforeTests(TestSetup setup) throws Throwable { - String failingRK = interpret("${main.rhq3.resource.key}", setup.getInventoryFileReplacements()); - testExpectedFailures(this, setup, 4, failingRK); - } }); }
@@ -130,7 +98,6 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - upgradeShouldSucceed = false;
//just define the servername value without actually setting the ${servername.directive} so that //we don't define a servername directive itself but do have a value for the actual server name. @@ -144,10 +111,24 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase }
@Override - public void beforeTests(TestSetup setup) throws Throwable { - String vhost1RK = interpret("${vhost1.rhq3.resource.key}", setup.getInventoryFileReplacements()); - testExpectedFailures(this, setup, 5, vhost1RK); - } + public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { + //the inventory has main, vhost1, vhost2, vhost3 and vhost4 + //the main vhost uses the URL of the server resource as its RK which is + //setup to be the IP address, whereas vhost1 uses the 'normal' + //discovered RK with uses the domain name of that IP. + //Therefore, unlike in the WithSNMP test cases, we have 5 vhosts discovered + //by RHQ 3.0.1. + //The vhost1 will fail to upgrade because it could be ambiguously matched + //to either main vhost or vhost1. + + return getVHostRKs(setup, new int[] { 0, 2, 3, 4 }, new int[] { 1 }, ResourceKeyFormat.RHQ3); + } + + @Override + public String[] getExpectedResourceKeysWithFailures(TestSetup setup) { + String failedRK = setup.getInventoryFileReplacements().get("vhost1.rhq3.resource.key"); + return new String[] { failedRK }; + } }); }
@@ -162,7 +143,6 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - upgradeShouldSucceed = false;
defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}:${listen1}"); @@ -175,16 +155,6 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase public void beforeTestSetup(TestSetup testSetup) throws Throwable { defineRHQ3ResourceKeys(this, testSetup); } - - /** - * Do our own tests here, because the generic test method won't do much, since - * we told it that the upgrade won't succeed. - */ - @Override - public void beforeTests(TestSetup setup) throws Throwable { - String failingRK = interpret("${main.rhq3.resource.key}", setup.getInventoryFileReplacements()); - testExpectedFailures(this, setup, 4, failingRK); - } }); }
@@ -228,7 +198,6 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - upgradeShouldSucceed = false;
defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}"); @@ -241,16 +210,6 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase public void beforeTestSetup(TestSetup testSetup) throws Throwable { defineRHQ3ResourceKeys(this, testSetup); } - - /** - * Do our own tests here, because the generic test method won't do much, since - * we told it that the upgrade won't succeed. - */ - @Override - public void beforeTests(TestSetup setup) throws Throwable { - String failingRK = interpret("${main.rhq3.resource.key}", setup.getInventoryFileReplacements()); - testExpectedFailures(this, setup, 4, failingRK); - } }); }
@@ -317,7 +276,6 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - upgradeShouldSucceed = false; }
@Override @@ -325,17 +283,30 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase defineRHQ3ResourceKeys(this, testSetup); }
- /** - * Do our own tests here, because the generic test method won't do much, since - * we told it that the upgrade won't succeed. - */ @Override - public void beforeTests(TestSetup setup) throws Throwable { - String mainVHost1RK = interpret("${main.rhq3.resource.key}", setup.getInventoryFileReplacements()); + public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { + //the inventory has main1, main2, vhost2, vhost3 and vhost4 + //vhost1 has the same resource key as the main vhost in RHQ 3.0.0 + //because the upgrade failed for main (because of the ambiguity), + //no discoveries are being made + //therefore we expect the main to have the old resource key and + //vhost2, 3 and 4 to have the new resource keys. + + String[] ret = getVHostRKs(setup, new int[] { 2, 3, 4 }, new int[] { 0 }, ResourceKeyFormat.RHQ3); String mainVhost2RK = interpret("${localhost}:${port1}", setup.getInventoryFileReplacements());
- testExpectedFailures(this, setup, 5, mainVHost1RK, mainVhost2RK); + ret = Arrays.copyOf(ret, ret.length + 1); + ret[ret.length - 1] = mainVhost2RK; + + return ret; } + + @Override + public String[] getExpectedResourceKeysWithFailures(TestSetup setup) { + String mainVhost1RK = setup.getInventoryFileReplacements().get("main.rhq3.resource.key"); + String mainVhost2RK = interpret("${localhost}:${port1}", setup.getInventoryFileReplacements()); + return new String[] { mainVhost1RK, mainVhost2RK }; + } }); }
@@ -428,7 +399,6 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase inventoryFile = configuredInventoryFileWithoutSNMP; serverRoot = installPath; binPath = exePath; - upgradeShouldSucceed = false;
//just define the servername value without actually setting the ${servername.directive} so that //we don't define a servername directive itself but do have a value for the actual server name. @@ -447,9 +417,23 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase }
@Override - public void beforeTests(TestSetup setup) throws Throwable { - String failingRK = interpret("${vhost1.rhq3.resource.key}", setup.getInventoryFileReplacements()); - testExpectedFailures(this, setup, 5, failingRK); + public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { + //the inventory has main, vhost1, vhost2, vhost3 and vhost4 + //the main vhost uses the URL of the server resource as its RK which is + //setup to be the IP address, whereas vhost1 uses the 'normal' + //discovered RK with uses the domain name of that IP. + //Therefore, unlike in the WithSNMP test cases, we have 5 vhosts discovered + //by RHQ 3.0.1. + //The vhost1 will fail to upgrade because it could be ambiguously matched + //to either main vhost or vhost1. + + return getVHostRKs(setup, new int[] { 0, 2, 3, 4 }, new int[] { 1 }, ResourceKeyFormat.RHQ3); + } + + @Override + public String[] getExpectedResourceKeysWithFailures(TestSetup setup) { + String failedRK = setup.getInventoryFileReplacements().get("vhost1.rhq3.resource.key"); + return new String[] { failedRK }; } }); } @@ -466,7 +450,6 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase inventoryFile = configuredInventoryFileWithSNMP; serverRoot = installPath; binPath = exePath; - upgradeShouldSucceed = false;
defaultOverrides.put(variableName(configurationName, "listen1"), "*:${port1}"); defaultOverrides.put(variableName(configurationName, "listen2"), "*:${port2}"); @@ -479,109 +462,6 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase public void beforeTestSetup(TestSetup testSetup) throws Throwable { defineRHQ3ResourceKeys(this, testSetup); } - - /** - * Do our own tests here, because the generic test method won't do much, since - * we told it that the upgrade won't succeed. - */ - @Override - public void beforeTests(TestSetup setup) throws Throwable { - String failingRK = interpret("${main.rhq3.resource.key}", setup.getInventoryFileReplacements()); - testExpectedFailures(this, setup, 4, failingRK); - } }); } - - private void defineRHQ3ResourceKeys(TestConfiguration testConfig, TestSetup setup) throws Exception { - setup.withApacheSetup().init(); - ApacheServerComponent component = setup.withApacheSetup().getExecutionUtil().getServerComponent(); - ApacheDirectiveTree config = component.loadParser(); - config = RuntimeApacheConfiguration.extract(config, component.getCurrentProcessInfo(), component.getCurrentBinaryInfo(), component.getModuleNames(), false); - - DeploymentConfig deployConfig = setup.getDeploymentConfig(); - - VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config); - - Map<String, String> replacements = deployConfig.getTokenReplacements(); - - testConfig.defaultOverrides.put("main.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyMainServerResourceKey()); - - if (deployConfig.vhost1 != null) { - testConfig.defaultOverrides.put("vhost1.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost1.getVHostSpec(replacements))); - } - - if (deployConfig.vhost2 != null) { - testConfig.defaultOverrides.put("vhost2.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost2.getVHostSpec(replacements))); - } - - if (deployConfig.vhost3 != null) { - testConfig.defaultOverrides.put("vhost3.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost3.getVHostSpec(replacements))); - } - - if (deployConfig.vhost4 != null) { - testConfig.defaultOverrides.put("vhost4.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost4.getVHostSpec(replacements))); - } - - setup.withDefaultOverrides(testConfig.defaultOverrides); - } - - private void testExpectedFailures(TestConfiguration testConfig, TestSetup setup, int numberOfVhosts, String... failingRKs) { - //ok, now we should see the resources upgraded in the fake server inventory. - ResourceType serverResourceType = findApachePluginResourceTypeByName("Apache HTTP Server"); - ResourceType vhostResourceType = findApachePluginResourceTypeByName("Apache Virtual Host"); - - Set<Resource> servers = setup.getFakeInventory().findResourcesByType(serverResourceType); - - assertEquals(servers.size(), 1, "There should be exactly one apache server discovered."); - - Resource server = servers.iterator().next(); - - String expectedResourceKey = ApacheServerDiscoveryComponent.formatResourceKey(testConfig.serverRoot, testConfig.serverRoot - + "/conf/httpd.conf"); - - assertEquals(server.getResourceKey(), expectedResourceKey, - "The server resource key doesn't seem to be upgraded."); - - Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(vhostResourceType); - - assertEquals(vhosts.size(), numberOfVhosts, "Unexpected number of vhosts discovered found"); - - //let's check that the main vhost has a an upgrade error attached to it - ApacheServerComponent component = setup.withApacheSetup().getExecutionUtil().getServerComponent(); - ApacheDirectiveTree config = component.loadParser(); - config = RuntimeApacheConfiguration.extract(config, component.getCurrentProcessInfo(), component.getCurrentBinaryInfo(), component.getModuleNames(), false); - VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config); - - Set<Resource> failingResources = new HashSet<Resource>(); - - for(String rk : failingRKs) { - for(Resource r : vhosts) { - if (rk.equals(r.getResourceKey())) { - failingResources.add(r); - break; - } - } - } - - assertEquals(failingResources.size(), failingRKs.length, "Couldn't find all the resources that should have failed."); - - for(Resource failingResource : failingResources) { - List<ResourceError> errors = failingResource.getResourceErrors(ResourceErrorType.UPGRADE); - assertNotNull(errors, "The main vhost doesn't have any upgrade errors."); - assertEquals(errors.size(), 1, "There should be exactly one upgrade error on the main vhost."); - } - - //check that all other vhosts were not upgraded but have no errors - for(Resource r : vhosts) { - if (failingResources.contains(r)) { - continue; - } - - assertEquals(r.getResourceErrors(ResourceErrorType.UPGRADE).size(), 0, "Unexpected number of resource upgrade errors on non-main vhost " + r); - } - } - - private String interpret(String string, Map<String, String> variables) { - return StreamUtil.slurp(new TokenReplacingReader(new StringReader(string), variables)); - } } diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeConfigurationWithIncludesFromRHQ3_0_2Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeConfigurationWithIncludesFromRHQ3_0_2Test.java index 0795ecc..ad0ffe0 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeConfigurationWithIncludesFromRHQ3_0_2Test.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeConfigurationWithIncludesFromRHQ3_0_2Test.java @@ -27,7 +27,8 @@ package org.rhq.plugins.apache.upgrade.rhq3_0_2; public class UpgradeConfigurationWithIncludesFromRHQ3_0_2Test extends UpgradeSimpleConfigurationFromRHQ3_0_2Test {
public UpgradeConfigurationWithIncludesFromRHQ3_0_2Test() { - super("/mocked-inventories/rhq-3.0.2/includes/inventory.xml", "/full-configurations/2.2.x/includes/httpd.conf", + super("/mocked-inventories/rhq-3.0.2/includes/inventory.xml", + "/mocked-inventories/rhq-3.0.2/includes/inventory-single-vhost.xml", "/full-configurations/2.2.x/includes/httpd.conf", "/full-configurations/2.2.x/includes/1.vhost.conf", "/full-configurations/2.2.x/includes/2.vhost.conf"); } } diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeMessyConfigurationFromRHQ3_0_2Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeMessyConfigurationFromRHQ3_0_2Test.java new file mode 100644 index 0000000..f5539a7 --- /dev/null +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeMessyConfigurationFromRHQ3_0_2Test.java @@ -0,0 +1,36 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.plugins.apache.upgrade.rhq3_0_2; + +/** + * + * + * @author Lukas Krejci + */ +public class UpgradeMessyConfigurationFromRHQ3_0_2Test extends UpgradeNestedConfigurationFromRHQ3_0_2Test { + + public UpgradeMessyConfigurationFromRHQ3_0_2Test() { + super("/mocked-inventories/rhq-3.0.2/mess/inventory.xml", + "/mocked-inventories/rhq-3.0.2/mess/inventory-single-vhost.xml", + "/full-configurations/2.2.x/mess/httpd.conf", "/full-configurations/2.2.x/mess/1.vhost.conf", + "/full-configurations/2.2.x/mess/2.vhost.conf"); + } + +} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeNestedConfigurationFromRHQ3_0_2Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeNestedConfigurationFromRHQ3_0_2Test.java new file mode 100644 index 0000000..2e31664 --- /dev/null +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeNestedConfigurationFromRHQ3_0_2Test.java @@ -0,0 +1,206 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.plugins.apache.upgrade.rhq3_0_2; + +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +import org.rhq.plugins.apache.upgrade.UpgradeTestBase; +import org.rhq.plugins.apache.upgrade.UpgradeTestBase.TestSetup; +import org.rhq.test.pc.PluginContainerSetup; + +/** + * + * + * @author Lukas Krejci + */ +public class UpgradeNestedConfigurationFromRHQ3_0_2Test extends UpgradeTestBase { + + private String[] configuredApacheConfigurationFiles; + private String configuredInventoryFile; + private String configuredInventoryFileWithSingleVHost; + + public UpgradeNestedConfigurationFromRHQ3_0_2Test() { + configuredApacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/nested/httpd.conf" }; + configuredInventoryFile = "/mocked-inventories/rhq-3.0.2/nested/inventory.xml"; + configuredInventoryFileWithSingleVHost = "/mocked-inventories/rhq-3.0.2/nested/inventory-single-vhost.xml"; + } + + /** + * @param configuredApacheConfigurationFiles + * @param configuredInventoryFile + */ + protected UpgradeNestedConfigurationFromRHQ3_0_2Test(String configuredInventoryFile, + String configuredInventoryFileWithSingleVHost, + String... configuredApacheConfigurationFiles) { + + this.configuredApacheConfigurationFiles = configuredApacheConfigurationFiles; + this.configuredInventoryFile = configuredInventoryFile; + this.configuredInventoryFileWithSingleVHost = configuredInventoryFileWithSingleVHost; + } + + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testWithResolvableNames(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFile; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + } + + @Override + public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { + return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null); + } + }); + } + + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testWithUnresolvableNames(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFile; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + + defaultOverrides.put(variableName(configurationName, "servername.directive"), + "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), + "ServerName ${unresolvable.host}:${listen1}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), + "ServerName ${unresolvable.host}:${listen2}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), + "ServerName ${unresolvable.host}:${listen3}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), + "ServerName ${unresolvable.host}:${listen4}"); + } + + @Override + public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { + return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null); + } + }); + } + + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testWithNonUniqueNames(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithSingleVHost; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + + defaultOverrides.put(variableName(configurationName, "servername.directive"), + "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), + "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), + "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), + "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), + "ServerName ${unresolvable.host}"); + } + + @Override + public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { + return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null); + } + }); + } + + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testWithAnyAddress(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFile; + serverRoot = installPath; + binPath = exePath; + + //just define the servername value without actually setting the ${servername.directive} so that + //we don't define a servername directive itself but do have a value for the actual server name. + //this is deduced by apache and the plugin but tests aren't that clever. + defaultOverrides.put("servername", "${localhost.ip}"); + defaultOverrides.put(variableName(configurationName, "listen1"), "0.0.0.0:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "0.0.0.0:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "0.0.0.0:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "0.0.0.0:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "0.0.0.0:${port1}"); + } + + @Override + public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { + return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null); + } + }); + } + + /** + * This configuration will fail to upgrade the first vhost, because it doesn't uniquely match to new-style + * vhosts - it could be either a main vhost or vhost1. + */ + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testWithWildcardAddress(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFile; + serverRoot = installPath; + binPath = exePath; + + //just define the servername value without actually setting the ${servername.directive} so that + //we don't define a servername directive itself but do have a value for the actual server name. + //this is deduced by apache and the plugin but tests aren't that clever. + defaultOverrides.put("servername", "${localhost.ip}"); + defaultOverrides.put(variableName(configurationName, "listen1"), "*:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "*:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "*:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "*:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "*:${port1}"); + } + + @Override + public String[] getExpectedResourceKeysAfterUpgrade(TestSetup setup) { + return getVHostRKs(setup, new int[] { 0, 2, 4 }, null, null); + } + }); + } +} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeSimpleConfigurationFromRHQ3_0_2Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeSimpleConfigurationFromRHQ3_0_2Test.java index 2c3de84..38b7368 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeSimpleConfigurationFromRHQ3_0_2Test.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeSimpleConfigurationFromRHQ3_0_2Test.java @@ -34,10 +34,12 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_2Test extends UpgradeTestBase
private String[] configuredApacheConfigurationFiles; private String configuredInventoryFile; - + private String configuredInventoryFileWithSingleVhost; + public UpgradeSimpleConfigurationFromRHQ3_0_2Test() { configuredApacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; configuredInventoryFile = "/mocked-inventories/rhq-3.0.2/simple/inventory.xml"; + configuredInventoryFileWithSingleVhost = "/mocked-inventories/rhq-3.0.2/simple/inventory-single-vhost.xml"; }
/** @@ -45,10 +47,12 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_2Test extends UpgradeTestBase * @param configuredInventoryFile */ protected UpgradeSimpleConfigurationFromRHQ3_0_2Test(String configuredInventoryFile, + String configuredInventoryFileWithSingleVhost, String... configuredApacheConfigurationFiles) {
this.configuredApacheConfigurationFiles = configuredApacheConfigurationFiles; this.configuredInventoryFile = configuredInventoryFile; + this.configuredInventoryFileWithSingleVhost = configuredInventoryFileWithSingleVhost; }
@Test @@ -99,7 +103,7 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_2Test extends UpgradeTestBase testUpgrade(new TestConfiguration() { { apacheConfigurationFiles = configuredApacheConfigurationFiles; - inventoryFile = configuredInventoryFile; + inventoryFile = configuredInventoryFileWithSingleVhost; serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java index b640b59..6183694 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java @@ -24,6 +24,7 @@ import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; +import java.io.Reader; import java.io.StringReader; import java.io.StringWriter; import java.net.InetAddress; @@ -41,6 +42,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.unitils.thirdparty.org.apache.commons.io.FileUtils;
+import org.rhq.core.util.file.FileUtil; import org.rhq.core.util.stream.StreamUtil; import org.rhq.plugins.apache.util.HttpdAddressUtility.Address; import org.rhq.test.TokenReplacingProperties; @@ -100,6 +102,11 @@ public class ApacheDeploymentUtil { }
private String getServerName(Map<String, String> replacements) { + String serverName = getServerName(); + if (serverName == null) { + return null; + } + TokenReplacingReader rdr = new TokenReplacingReader(new StringReader(getServerName()), replacements); StringWriter wrt = new StringWriter(); StreamUtil.copy(rdr, wrt); @@ -224,6 +231,17 @@ public class ApacheDeploymentUtil {
return ret; } + + public VHost getVHost(int number) { + switch (number) { + case 0 : return mainServer; + case 1 : return vhost1; + case 2 : return vhost2; + case 3 : return vhost3; + case 4 : return vhost4; + default: throw new IllegalArgumentException(); + } + } }
public static void addDefaultVariables(Map<String, String> variables, String prefix) { @@ -309,8 +327,8 @@ public class ApacheDeploymentUtil { }
public static void deployConfiguration(File targetConfDirectory, Collection<String> configFilesOnClasspath, - DeploymentConfig config) throws IOException { - List<File> targetFiles = new ArrayList<File>(); + Collection<File> additionalTargetFiles, DeploymentConfig config) throws IOException { + List<File> targetFiles = new ArrayList<File>(additionalTargetFiles); for (String fileOnClassPath : configFilesOnClasspath) { String fileName = new File(fileOnClassPath).getName();
@@ -332,7 +350,7 @@ public class ApacheDeploymentUtil { Map<String, String> replacements = config.getTokenReplacements();
for (File file : configFiles) { - TokenReplacingReader rdr = null; + Reader rdr = null; FileWriter wrt = null;
try { @@ -348,11 +366,31 @@ public class ApacheDeploymentUtil { wrt.write(buffer, 0, cnt); }
+ rdr.close(); wrt.close(); - - tmp.renameTo(file); + + //now overwrite the contents of the original file with the new one. + //we don't just move the new file to the location of the original one + //here to preserve the file permissions and file mode on the original. + FileUtil.copyFile(tmp, file); } catch (IOException e) { LOG.error("Error while replacing the tokens in file '" + file + "'.", e); + + if (rdr != null) { + try { + rdr.close(); + } catch (IOException ioe) { + + } + } + + if (wrt != null) { + try { + wrt.close(); + } catch (IOException ioe) { + + } + } } } } diff --git a/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/includes/httpd.conf b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/includes/httpd.conf index 22f6dac..6f94a77 100644 --- a/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/includes/httpd.conf +++ b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/includes/httpd.conf @@ -11,23 +11,12 @@ ${servername.directive}
DocumentRoot ${document.root}
-DirectoryIndex index.html index.html.var - -TypesConfig conf/mime.types - DefaultType text/plain
ErrorLog logs/error_log
LogLevel debug
-LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined -LogFormat "%h %l %u %t "%r" %>s %b" common -LogFormat "%{Referer}i -> %U" referer -LogFormat "%{User-agent}i" agent - -CustomLog logs/access_log combined - # Apache SNMP LoadModule snmpcommon_module modules/libsnmpcommon.so LoadModule snmpagt_module modules/libsnmpmonagt.so diff --git a/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/mess/1.vhost.conf b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/mess/1.vhost.conf index 39cf84a..cfe3f25 100644 --- a/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/mess/1.vhost.conf +++ b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/mess/1.vhost.conf @@ -5,10 +5,10 @@ </VirtualHost> </IfModule>
-LoadModule proxy_module modules/mod_proxy.so +LoadModule alias_module modules/mod_alias.so
<IfModule snmpcommon_module> -<IfModule mod_proxy.c> +<IfModule mod_alias.c> <VirtualHost ${vhost2.urls}> ${vhost2.servername.directive} ${vhost2.additional.directives} diff --git a/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/mess/httpd.conf b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/mess/httpd.conf index ebc07ac..6f94a77 100644 --- a/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/mess/httpd.conf +++ b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/mess/httpd.conf @@ -11,23 +11,12 @@ ${servername.directive}
DocumentRoot ${document.root}
-DirectoryIndex index.html index.html.var - -TypesConfig conf/mime.types - DefaultType text/plain
ErrorLog logs/error_log
LogLevel debug
-LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined -LogFormat "%h %l %u %t "%r" %>s %b" common -LogFormat "%{Referer}i -> %U" referer -LogFormat "%{User-agent}i" agent - -CustomLog logs/access_log combined - # Apache SNMP LoadModule snmpcommon_module modules/libsnmpcommon.so LoadModule snmpagt_module modules/libsnmpmonagt.so @@ -37,4 +26,4 @@ SNMPVar var
${additional.directives}
-Include *.vhost.conf +Include conf/*.vhost.conf diff --git a/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/nested/httpd.conf b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/nested/httpd.conf index 6112bdc..0d58eed 100644 --- a/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/nested/httpd.conf +++ b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/nested/httpd.conf @@ -11,23 +11,12 @@ ${servername.directive}
DocumentRoot ${document.root}
-DirectoryIndex index.html index.html.var - -TypesConfig conf/mime.types - DefaultType text/plain
ErrorLog logs/error_log
LogLevel debug
-LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined -LogFormat "%h %l %u %t "%r" %>s %b" common -LogFormat "%{Referer}i -> %U" referer -LogFormat "%{User-agent}i" agent - -CustomLog logs/access_log combined - # Apache SNMP LoadModule snmpcommon_module modules/libsnmpcommon.so LoadModule snmpagt_module modules/libsnmpmonagt.so @@ -44,10 +33,10 @@ ${additional.directives} </VirtualHost> </IfModule>
-LoadModule proxy_module modules/mod_proxy.so +LoadModule alias_module modules/mod_alias.so
<IfModule snmpcommon_module> -<IfModule mod_proxy.c> +<IfModule mod_alias.c> <VirtualHost ${vhost2.urls}> ${vhost2.servername.directive} ${vhost2.additional.directives} diff --git a/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/simple/httpd.conf b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/simple/httpd.conf index 87142b4..53e0525 100644 --- a/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/simple/httpd.conf +++ b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/simple/httpd.conf @@ -11,23 +11,12 @@ ${servername.directive}
DocumentRoot ${document.root}
-DirectoryIndex index.html index.html.var - -TypesConfig conf/mime.types - DefaultType text/plain
ErrorLog logs/error_log
LogLevel debug
-LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined -LogFormat "%h %l %u %t "%r" %>s %b" common -LogFormat "%{Referer}i -> %U" referer -LogFormat "%{User-agent}i" agent - -CustomLog logs/access_log combined - # Apache SNMP LoadModule snmpcommon_module modules/libsnmpcommon.so LoadModule snmpagt_module modules/libsnmpmonagt.so diff --git a/modules/plugins/apache/src/test/resources/mime.types b/modules/plugins/apache/src/test/resources/mime.types deleted file mode 100644 index 1ae0097..0000000 --- a/modules/plugins/apache/src/test/resources/mime.types +++ /dev/null @@ -1,1351 +0,0 @@ -# This file maps Internet media types to unique file extension(s). -# Although created for httpd, this file is used by many software systems -# and has been placed in the public domain for unlimited redisribution. -# -# The table below contains both registered and (common) unregistered types. -# A type that has no unique extension can be ignored -- they are listed -# here to guide configurations toward known types and to make it easier to -# identify "new" types. File extensions are also commonly used to indicate -# content languages and encodings, so choose them carefully. -# -# Internet media types should be registered as described in RFC 4288. -# The registry is at http://www.iana.org/assignments/media-types/. -# -# MIME type Extensions -# application/3gpp-ims+xml -# application/activemessage -application/andrew-inset ez -# application/applefile -application/applixware aw -application/atom+xml atom -application/atomcat+xml atomcat -# application/atomicmail -application/atomsvc+xml atomsvc -# application/auth-policy+xml -# application/batch-smtp -# application/beep+xml -# application/cals-1840 -application/ccxml+xml ccxml -# application/cea-2018+xml -# application/cellml+xml -# application/cnrp+xml -# application/commonground -# application/conference-info+xml -# application/cpl+xml -# application/csta+xml -# application/cstadata+xml -application/cu-seeme cu -# application/cybercash -application/davmount+xml davmount -# application/dca-rft -# application/dec-dx -# application/dialog-info+xml -# application/dicom -# application/dns -application/dssc+der dssc -application/dssc+xml xdssc -# application/dvcs -application/ecmascript ecma -# application/edi-consent -# application/edi-x12 -# application/edifact -application/emma+xml emma -# application/epp+xml -application/epub+zip epub -# application/eshop -# application/example -# application/fastinfoset -# application/fastsoap -# application/fits -application/font-tdpfr pfr -# application/h224 -# application/held+xml -# application/http -application/hyperstudio stk -# application/ibe-key-request+xml -# application/ibe-pkg-reply+xml -# application/ibe-pp-data -# application/iges -# application/im-iscomposing+xml -# application/index -# application/index.cmd -# application/index.obj -# application/index.response -# application/index.vnd -# application/iotp -application/ipfix ipfix -# application/ipp -# application/isup -application/java-archive jar -application/java-serialized-object ser -application/java-vm class -application/javascript js -application/json json -# application/kpml-request+xml -# application/kpml-response+xml -application/lost+xml lostxml -application/mac-binhex40 hqx -application/mac-compactpro cpt -# application/macwriteii -application/marc mrc -application/mathematica ma nb mb -application/mathml+xml mathml -# application/mbms-associated-procedure-description+xml -# application/mbms-deregister+xml -# application/mbms-envelope+xml -# application/mbms-msk+xml -# application/mbms-msk-response+xml -# application/mbms-protection-description+xml -# application/mbms-reception-report+xml -# application/mbms-register+xml -# application/mbms-register-response+xml -# application/mbms-user-service-description+xml -application/mbox mbox -# application/media_control+xml -application/mediaservercontrol+xml mscml -# application/mikey -# application/moss-keys -# application/moss-signature -# application/mosskey-data -# application/mosskey-request -application/mp4 mp4s -# application/mpeg4-generic -# application/mpeg4-iod -# application/mpeg4-iod-xmt -application/msword doc dot -application/mxf mxf -# application/nasdata -# application/news-checkgroups -# application/news-groupinfo -# application/news-transmission -# application/nss -# application/ocsp-request -# application/ocsp-response -application/octet-stream bin dms lha lrf lzh so iso dmg dist distz pkg bpk dump elc deploy -application/oda oda -application/oebps-package+xml opf -application/ogg ogx -application/onenote onetoc onetoc2 onetmp onepkg -# application/parityfec -application/patch-ops-error+xml xer -application/pdf pdf -application/pgp-encrypted pgp -# application/pgp-keys -application/pgp-signature asc sig -application/pics-rules prf -# application/pidf+xml -# application/pidf-diff+xml -application/pkcs10 p10 -application/pkcs7-mime p7m p7c -application/pkcs7-signature p7s -application/pkix-cert cer -application/pkix-crl crl -application/pkix-pkipath pkipath -application/pkixcmp pki -application/pls+xml pls -# application/poc-settings+xml -application/postscript ai eps ps -# application/prs.alvestrand.titrax-sheet -application/prs.cww cww -# application/prs.nprend -# application/prs.plucker -# application/qsig -application/rdf+xml rdf -application/reginfo+xml rif -application/relax-ng-compact-syntax rnc -# application/remote-printing -application/resource-lists+xml rl -application/resource-lists-diff+xml rld -# application/riscos -# application/rlmi+xml -application/rls-services+xml rs -application/rsd+xml rsd -application/rss+xml rss -application/rtf rtf -# application/rtx -# application/samlassertion+xml -# application/samlmetadata+xml -application/sbml+xml sbml -application/scvp-cv-request scq -application/scvp-cv-response scs -application/scvp-vp-request spq -application/scvp-vp-response spp -application/sdp sdp -# application/set-payment -application/set-payment-initiation setpay -# application/set-registration -application/set-registration-initiation setreg -# application/sgml -# application/sgml-open-catalog -application/shf+xml shf -# application/sieve -# application/simple-filter+xml -# application/simple-message-summary -# application/simplesymbolcontainer -# application/slate -# application/smil -application/smil+xml smi smil -# application/soap+fastinfoset -# application/soap+xml -application/sparql-query rq -application/sparql-results+xml srx -# application/spirits-event+xml -application/srgs gram -application/srgs+xml grxml -application/ssml+xml ssml -# application/timestamp-query -# application/timestamp-reply -# application/tve-trigger -# application/ulpfec -# application/vemmi -# application/vividence.scriptfile -# application/vnd.3gpp.bsf+xml -application/vnd.3gpp.pic-bw-large plb -application/vnd.3gpp.pic-bw-small psb -application/vnd.3gpp.pic-bw-var pvb -# application/vnd.3gpp.sms -# application/vnd.3gpp2.bcmcsinfo+xml -# application/vnd.3gpp2.sms -application/vnd.3gpp2.tcap tcap -application/vnd.3m.post-it-notes pwn -application/vnd.accpac.simply.aso aso -application/vnd.accpac.simply.imp imp -application/vnd.acucobol acu -application/vnd.acucorp atc acutc -application/vnd.adobe.air-application-installer-package+zip air -# application/vnd.adobe.partial-upload -application/vnd.adobe.xdp+xml xdp -application/vnd.adobe.xfdf xfdf -# application/vnd.aether.imp -application/vnd.airzip.filesecure.azf azf -application/vnd.airzip.filesecure.azs azs -application/vnd.amazon.ebook azw -application/vnd.americandynamics.acc acc -application/vnd.amiga.ami ami -application/vnd.android.package-archive apk -application/vnd.anser-web-certificate-issue-initiation cii -application/vnd.anser-web-funds-transfer-initiation fti -application/vnd.antix.game-component atx -application/vnd.apple.installer+xml mpkg -application/vnd.apple.mpegurl m3u8 -# application/vnd.arastra.swi -application/vnd.aristanetworks.swi swi -application/vnd.audiograph aep -# application/vnd.autopackage -# application/vnd.avistar+xml -application/vnd.blueice.multipass mpm -# application/vnd.bluetooth.ep.oob -application/vnd.bmi bmi -application/vnd.businessobjects rep -# application/vnd.cab-jscript -# application/vnd.canon-cpdl -# application/vnd.canon-lips -# application/vnd.cendio.thinlinc.clientconf -application/vnd.chemdraw+xml cdxml -application/vnd.chipnuts.karaoke-mmd mmd -application/vnd.cinderella cdy -# application/vnd.cirpack.isdn-ext -application/vnd.claymore cla -application/vnd.cloanto.rp9 rp9 -application/vnd.clonk.c4group c4g c4d c4f c4p c4u -# application/vnd.commerce-battelle -application/vnd.commonspace csp -application/vnd.contact.cmsg cdbcmsg -application/vnd.cosmocaller cmc -application/vnd.crick.clicker clkx -application/vnd.crick.clicker.keyboard clkk -application/vnd.crick.clicker.palette clkp -application/vnd.crick.clicker.template clkt -application/vnd.crick.clicker.wordbank clkw -application/vnd.criticaltools.wbs+xml wbs -application/vnd.ctc-posml pml -# application/vnd.ctct.ws+xml -# application/vnd.cups-pdf -# application/vnd.cups-postscript -application/vnd.cups-ppd ppd -# application/vnd.cups-raster -# application/vnd.cups-raw -application/vnd.curl.car car -application/vnd.curl.pcurl pcurl -# application/vnd.cybank -application/vnd.data-vision.rdz rdz -application/vnd.denovo.fcselayout-link fe_launch -# application/vnd.dir-bi.plate-dl-nosuffix -application/vnd.dna dna -application/vnd.dolby.mlp mlp -# application/vnd.dolby.mobile.1 -# application/vnd.dolby.mobile.2 -application/vnd.dpgraph dpg -application/vnd.dreamfactory dfac -# application/vnd.dvb.esgcontainer -# application/vnd.dvb.ipdcdftnotifaccess -# application/vnd.dvb.ipdcesgaccess -# application/vnd.dvb.ipdcroaming -# application/vnd.dvb.iptv.alfec-base -# application/vnd.dvb.iptv.alfec-enhancement -# application/vnd.dvb.notif-aggregate-root+xml -# application/vnd.dvb.notif-container+xml -# application/vnd.dvb.notif-generic+xml -# application/vnd.dvb.notif-ia-msglist+xml -# application/vnd.dvb.notif-ia-registration-request+xml -# application/vnd.dvb.notif-ia-registration-response+xml -# application/vnd.dvb.notif-init+xml -# application/vnd.dxr -application/vnd.dynageo geo -# application/vnd.ecdis-update -application/vnd.ecowin.chart mag -# application/vnd.ecowin.filerequest -# application/vnd.ecowin.fileupdate -# application/vnd.ecowin.series -# application/vnd.ecowin.seriesrequest -# application/vnd.ecowin.seriesupdate -# application/vnd.emclient.accessrequest+xml -application/vnd.enliven nml -application/vnd.epson.esf esf -application/vnd.epson.msf msf -application/vnd.epson.quickanime qam -application/vnd.epson.salt slt -application/vnd.epson.ssf ssf -# application/vnd.ericsson.quickcall -application/vnd.eszigno3+xml es3 et3 -# application/vnd.etsi.aoc+xml -# application/vnd.etsi.cug+xml -# application/vnd.etsi.iptvcommand+xml -# application/vnd.etsi.iptvdiscovery+xml -# application/vnd.etsi.iptvprofile+xml -# application/vnd.etsi.iptvsad-bc+xml -# application/vnd.etsi.iptvsad-cod+xml -# application/vnd.etsi.iptvsad-npvr+xml -# application/vnd.etsi.iptvueprofile+xml -# application/vnd.etsi.mcid+xml -# application/vnd.etsi.sci+xml -# application/vnd.etsi.simservs+xml -# application/vnd.etsi.tsl+xml -# application/vnd.etsi.tsl.der -# application/vnd.eudora.data -application/vnd.ezpix-album ez2 -application/vnd.ezpix-package ez3 -# application/vnd.f-secure.mobile -application/vnd.fdf fdf -application/vnd.fdsn.mseed mseed -application/vnd.fdsn.seed seed dataless -# application/vnd.ffsns -# application/vnd.fints -application/vnd.flographit gph -application/vnd.fluxtime.clip ftc -# application/vnd.font-fontforge-sfd -application/vnd.framemaker fm frame maker book -application/vnd.frogans.fnc fnc -application/vnd.frogans.ltf ltf -application/vnd.fsc.weblaunch fsc -application/vnd.fujitsu.oasys oas -application/vnd.fujitsu.oasys2 oa2 -application/vnd.fujitsu.oasys3 oa3 -application/vnd.fujitsu.oasysgp fg5 -application/vnd.fujitsu.oasysprs bh2 -# application/vnd.fujixerox.art-ex -# application/vnd.fujixerox.art4 -# application/vnd.fujixerox.hbpl -application/vnd.fujixerox.ddd ddd -application/vnd.fujixerox.docuworks xdw -application/vnd.fujixerox.docuworks.binder xbd -# application/vnd.fut-misnet -application/vnd.fuzzysheet fzs -application/vnd.genomatix.tuxedo txd -# application/vnd.geocube+xml -application/vnd.geogebra.file ggb -application/vnd.geogebra.tool ggt -application/vnd.geometry-explorer gex gre -application/vnd.geonext gxt -application/vnd.geoplan g2w -application/vnd.geospace g3w -# application/vnd.globalplatform.card-content-mgt -# application/vnd.globalplatform.card-content-mgt-response -application/vnd.gmx gmx -application/vnd.google-earth.kml+xml kml -application/vnd.google-earth.kmz kmz -application/vnd.grafeq gqf gqs -# application/vnd.gridmp -application/vnd.groove-account gac -application/vnd.groove-help ghf -application/vnd.groove-identity-message gim -application/vnd.groove-injector grv -application/vnd.groove-tool-message gtm -application/vnd.groove-tool-template tpl -application/vnd.groove-vcard vcg -application/vnd.handheld-entertainment+xml zmm -application/vnd.hbci hbci -# application/vnd.hcl-bireports -application/vnd.hhe.lesson-player les -application/vnd.hp-hpgl hpgl -application/vnd.hp-hpid hpid -application/vnd.hp-hps hps -application/vnd.hp-jlyt jlt -application/vnd.hp-pcl pcl -application/vnd.hp-pclxl pclxl -# application/vnd.httphone -application/vnd.hydrostatix.sof-data sfd-hdstx -application/vnd.hzn-3d-crossword x3d -# application/vnd.ibm.afplinedata -# application/vnd.ibm.electronic-media -application/vnd.ibm.minipay mpy -application/vnd.ibm.modcap afp listafp list3820 -application/vnd.ibm.rights-management irm -application/vnd.ibm.secure-container sc -application/vnd.iccprofile icc icm -application/vnd.igloader igl -application/vnd.immervision-ivp ivp -application/vnd.immervision-ivu ivu -# application/vnd.informedcontrol.rms+xml -# application/vnd.informix-visionary -application/vnd.intercon.formnet xpw xpx -# application/vnd.intertrust.digibox -# application/vnd.intertrust.nncp -application/vnd.intu.qbo qbo -application/vnd.intu.qfx qfx -# application/vnd.iptc.g2.conceptitem+xml -# application/vnd.iptc.g2.knowledgeitem+xml -# application/vnd.iptc.g2.newsitem+xml -# application/vnd.iptc.g2.packageitem+xml -application/vnd.ipunplugged.rcprofile rcprofile -application/vnd.irepository.package+xml irp -application/vnd.is-xpr xpr -application/vnd.jam jam -# application/vnd.japannet-directory-service -# application/vnd.japannet-jpnstore-wakeup -# application/vnd.japannet-payment-wakeup -# application/vnd.japannet-registration -# application/vnd.japannet-registration-wakeup -# application/vnd.japannet-setstore-wakeup -# application/vnd.japannet-verification -# application/vnd.japannet-verification-wakeup -application/vnd.jcp.javame.midlet-rms rms -application/vnd.jisp jisp -application/vnd.joost.joda-archive joda -application/vnd.kahootz ktz ktr -application/vnd.kde.karbon karbon -application/vnd.kde.kchart chrt -application/vnd.kde.kformula kfo -application/vnd.kde.kivio flw -application/vnd.kde.kontour kon -application/vnd.kde.kpresenter kpr kpt -application/vnd.kde.kspread ksp -application/vnd.kde.kword kwd kwt -application/vnd.kenameaapp htke -application/vnd.kidspiration kia -application/vnd.kinar kne knp -application/vnd.koan skp skd skt skm -application/vnd.kodak-descriptor sse -# application/vnd.liberty-request+xml -application/vnd.llamagraphics.life-balance.desktop lbd -application/vnd.llamagraphics.life-balance.exchange+xml lbe -application/vnd.lotus-1-2-3 123 -application/vnd.lotus-approach apr -application/vnd.lotus-freelance pre -application/vnd.lotus-notes nsf -application/vnd.lotus-organizer org -application/vnd.lotus-screencam scm -application/vnd.lotus-wordpro lwp -application/vnd.macports.portpkg portpkg -# application/vnd.marlin.drm.actiontoken+xml -# application/vnd.marlin.drm.conftoken+xml -# application/vnd.marlin.drm.license+xml -# application/vnd.marlin.drm.mdcf -application/vnd.mcd mcd -application/vnd.medcalcdata mc1 -application/vnd.mediastation.cdkey cdkey -# application/vnd.meridian-slingshot -application/vnd.mfer mwf -application/vnd.mfmp mfm -application/vnd.micrografx.flo flo -application/vnd.micrografx.igx igx -application/vnd.mif mif -# application/vnd.minisoft-hp3000-save -# application/vnd.mitsubishi.misty-guard.trustweb -application/vnd.mobius.daf daf -application/vnd.mobius.dis dis -application/vnd.mobius.mbk mbk -application/vnd.mobius.mqy mqy -application/vnd.mobius.msl msl -application/vnd.mobius.plc plc -application/vnd.mobius.txf txf -application/vnd.mophun.application mpn -application/vnd.mophun.certificate mpc -# application/vnd.motorola.flexsuite -# application/vnd.motorola.flexsuite.adsi -# application/vnd.motorola.flexsuite.fis -# application/vnd.motorola.flexsuite.gotap -# application/vnd.motorola.flexsuite.kmr -# application/vnd.motorola.flexsuite.ttc -# application/vnd.motorola.flexsuite.wem -# application/vnd.motorola.iprm -application/vnd.mozilla.xul+xml xul -application/vnd.ms-artgalry cil -# application/vnd.ms-asf -application/vnd.ms-cab-compressed cab -application/vnd.ms-excel xls xlm xla xlc xlt xlw -application/vnd.ms-excel.addin.macroenabled.12 xlam -application/vnd.ms-excel.sheet.binary.macroenabled.12 xlsb -application/vnd.ms-excel.sheet.macroenabled.12 xlsm -application/vnd.ms-excel.template.macroenabled.12 xltm -application/vnd.ms-fontobject eot -application/vnd.ms-htmlhelp chm -application/vnd.ms-ims ims -application/vnd.ms-lrm lrm -application/vnd.ms-pki.seccat cat -application/vnd.ms-pki.stl stl -# application/vnd.ms-playready.initiator+xml -application/vnd.ms-powerpoint ppt pps pot -application/vnd.ms-powerpoint.addin.macroenabled.12 ppam -application/vnd.ms-powerpoint.presentation.macroenabled.12 pptm -application/vnd.ms-powerpoint.slide.macroenabled.12 sldm -application/vnd.ms-powerpoint.slideshow.macroenabled.12 ppsm -application/vnd.ms-powerpoint.template.macroenabled.12 potm -application/vnd.ms-project mpp mpt -# application/vnd.ms-tnef -# application/vnd.ms-wmdrm.lic-chlg-req -# application/vnd.ms-wmdrm.lic-resp -# application/vnd.ms-wmdrm.meter-chlg-req -# application/vnd.ms-wmdrm.meter-resp -application/vnd.ms-word.document.macroenabled.12 docm -application/vnd.ms-word.template.macroenabled.12 dotm -application/vnd.ms-works wps wks wcm wdb -application/vnd.ms-wpl wpl -application/vnd.ms-xpsdocument xps -application/vnd.mseq mseq -# application/vnd.msign -# application/vnd.multiad.creator -# application/vnd.multiad.creator.cif -# application/vnd.music-niff -application/vnd.musician mus -application/vnd.muvee.style msty -# application/vnd.ncd.control -# application/vnd.ncd.reference -# application/vnd.nervana -# application/vnd.netfpx -application/vnd.neurolanguage.nlu nlu -application/vnd.noblenet-directory nnd -application/vnd.noblenet-sealer nns -application/vnd.noblenet-web nnw -# application/vnd.nokia.catalogs -# application/vnd.nokia.conml+wbxml -# application/vnd.nokia.conml+xml -# application/vnd.nokia.isds-radio-presets -# application/vnd.nokia.iptv.config+xml -# application/vnd.nokia.landmark+wbxml -# application/vnd.nokia.landmark+xml -# application/vnd.nokia.landmarkcollection+xml -# application/vnd.nokia.n-gage.ac+xml -application/vnd.nokia.n-gage.data ngdat -application/vnd.nokia.n-gage.symbian.install n-gage -# application/vnd.nokia.ncd -# application/vnd.nokia.pcd+wbxml -# application/vnd.nokia.pcd+xml -application/vnd.nokia.radio-preset rpst -application/vnd.nokia.radio-presets rpss -application/vnd.novadigm.edm edm -application/vnd.novadigm.edx edx -application/vnd.novadigm.ext ext -# application/vnd.ntt-local.file-transfer -application/vnd.oasis.opendocument.chart odc -application/vnd.oasis.opendocument.chart-template otc -application/vnd.oasis.opendocument.database odb -application/vnd.oasis.opendocument.formula odf -application/vnd.oasis.opendocument.formula-template odft -application/vnd.oasis.opendocument.graphics odg -application/vnd.oasis.opendocument.graphics-template otg -application/vnd.oasis.opendocument.image odi -application/vnd.oasis.opendocument.image-template oti -application/vnd.oasis.opendocument.presentation odp -application/vnd.oasis.opendocument.presentation-template otp -application/vnd.oasis.opendocument.spreadsheet ods -application/vnd.oasis.opendocument.spreadsheet-template ots -application/vnd.oasis.opendocument.text odt -application/vnd.oasis.opendocument.text-master otm -application/vnd.oasis.opendocument.text-template ott -application/vnd.oasis.opendocument.text-web oth -# application/vnd.obn -application/vnd.olpc-sugar xo -# application/vnd.oma-scws-config -# application/vnd.oma-scws-http-request -# application/vnd.oma-scws-http-response -# application/vnd.oma.bcast.associated-procedure-parameter+xml -# application/vnd.oma.bcast.drm-trigger+xml -# application/vnd.oma.bcast.imd+xml -# application/vnd.oma.bcast.ltkm -# application/vnd.oma.bcast.notification+xml -# application/vnd.oma.bcast.provisioningtrigger -# application/vnd.oma.bcast.sgboot -# application/vnd.oma.bcast.sgdd+xml -# application/vnd.oma.bcast.sgdu -# application/vnd.oma.bcast.simple-symbol-container -# application/vnd.oma.bcast.smartcard-trigger+xml -# application/vnd.oma.bcast.sprov+xml -# application/vnd.oma.bcast.stkm -# application/vnd.oma.dcd -# application/vnd.oma.dcdc -application/vnd.oma.dd2+xml dd2 -# application/vnd.oma.drm.risd+xml -# application/vnd.oma.group-usage-list+xml -# application/vnd.oma.poc.detailed-progress-report+xml -# application/vnd.oma.poc.final-report+xml -# application/vnd.oma.poc.groups+xml -# application/vnd.oma.poc.invocation-descriptor+xml -# application/vnd.oma.poc.optimized-progress-report+xml -# application/vnd.oma.push -# application/vnd.oma.scidm.messages+xml -# application/vnd.oma.xcap-directory+xml -# application/vnd.omads-email+xml -# application/vnd.omads-file+xml -# application/vnd.omads-folder+xml -# application/vnd.omaloc-supl-init -application/vnd.openofficeorg.extension oxt -# application/vnd.openxmlformats-officedocument.custom-properties+xml -# application/vnd.openxmlformats-officedocument.customxmlproperties+xml -# application/vnd.openxmlformats-officedocument.drawing+xml -# application/vnd.openxmlformats-officedocument.drawingml.chart+xml -# application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml -# application/vnd.openxmlformats-officedocument.drawingml.diagramcolors+xml -# application/vnd.openxmlformats-officedocument.drawingml.diagramdata+xml -# application/vnd.openxmlformats-officedocument.drawingml.diagramlayout+xml -# application/vnd.openxmlformats-officedocument.drawingml.diagramstyle+xml -# application/vnd.openxmlformats-officedocument.extended-properties+xml -# application/vnd.openxmlformats-officedocument.presentationml.commentauthors+xml -# application/vnd.openxmlformats-officedocument.presentationml.comments+xml -# application/vnd.openxmlformats-officedocument.presentationml.handoutmaster+xml -# application/vnd.openxmlformats-officedocument.presentationml.notesmaster+xml -# application/vnd.openxmlformats-officedocument.presentationml.notesslide+xml -application/vnd.openxmlformats-officedocument.presentationml.presentation pptx -# application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml -# application/vnd.openxmlformats-officedocument.presentationml.presprops+xml -application/vnd.openxmlformats-officedocument.presentationml.slide sldx -# application/vnd.openxmlformats-officedocument.presentationml.slide+xml -# application/vnd.openxmlformats-officedocument.presentationml.slidelayout+xml -# application/vnd.openxmlformats-officedocument.presentationml.slidemaster+xml -application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx -# application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml -# application/vnd.openxmlformats-officedocument.presentationml.slideupdateinfo+xml -# application/vnd.openxmlformats-officedocument.presentationml.tablestyles+xml -# application/vnd.openxmlformats-officedocument.presentationml.tags+xml -application/vnd.openxmlformats-officedocument.presentationml.template potx -# application/vnd.openxmlformats-officedocument.presentationml.template.main+xml -# application/vnd.openxmlformats-officedocument.presentationml.viewprops+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.calcchain+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.externallink+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcachedefinition+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcacherecords+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.pivottable+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.querytable+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.revisionheaders+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.revisionlog+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.sharedstrings+xml -application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx -# application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.sheetmetadata+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.tablesinglecells+xml -application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx -# application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.usernames+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.volatiledependencies+xml -# application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml -# application/vnd.openxmlformats-officedocument.theme+xml -# application/vnd.openxmlformats-officedocument.themeoverride+xml -# application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml -application/vnd.openxmlformats-officedocument.wordprocessingml.document docx -# application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml -# application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml -# application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml -# application/vnd.openxmlformats-officedocument.wordprocessingml.fonttable+xml -# application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml -# application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml -# application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml -# application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml -# application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml -application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx -# application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml -# application/vnd.openxmlformats-officedocument.wordprocessingml.websettings+xml -# application/vnd.openxmlformats-package.core-properties+xml -# application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml -# application/vnd.osa.netdeploy -# application/vnd.osgi.bundle -application/vnd.osgi.dp dp -# application/vnd.otps.ct-kip+xml -application/vnd.palm pdb pqa oprc -# application/vnd.paos.xml -application/vnd.pawaafile paw -application/vnd.pg.format str -application/vnd.pg.osasli ei6 -# application/vnd.piaccess.application-licence -application/vnd.picsel efif -application/vnd.pmi.widget wg -# application/vnd.poc.group-advertisement+xml -application/vnd.pocketlearn plf -application/vnd.powerbuilder6 pbd -# application/vnd.powerbuilder6-s -# application/vnd.powerbuilder7 -# application/vnd.powerbuilder7-s -# application/vnd.powerbuilder75 -# application/vnd.powerbuilder75-s -# application/vnd.preminet -application/vnd.previewsystems.box box -application/vnd.proteus.magazine mgz -application/vnd.publishare-delta-tree qps -application/vnd.pvi.ptid1 ptid -# application/vnd.pwg-multiplexed -# application/vnd.pwg-xhtml-print+xml -# application/vnd.qualcomm.brew-app-res -application/vnd.quark.quarkxpress qxd qxt qwd qwt qxl qxb -# application/vnd.radisys.moml+xml -# application/vnd.radisys.msml+xml -# application/vnd.radisys.msml-audit+xml -# application/vnd.radisys.msml-audit-conf+xml -# application/vnd.radisys.msml-audit-conn+xml -# application/vnd.radisys.msml-audit-dialog+xml -# application/vnd.radisys.msml-audit-stream+xml -# application/vnd.radisys.msml-conf+xml -# application/vnd.radisys.msml-dialog+xml -# application/vnd.radisys.msml-dialog-base+xml -# application/vnd.radisys.msml-dialog-fax-detect+xml -# application/vnd.radisys.msml-dialog-fax-sendrecv+xml -# application/vnd.radisys.msml-dialog-group+xml -# application/vnd.radisys.msml-dialog-speech+xml -# application/vnd.radisys.msml-dialog-transform+xml -# application/vnd.rapid -application/vnd.realvnc.bed bed -application/vnd.recordare.musicxml mxl -application/vnd.recordare.musicxml+xml musicxml -# application/vnd.renlearn.rlprint -application/vnd.rim.cod cod -application/vnd.rn-realmedia rm -application/vnd.route66.link66+xml link66 -# application/vnd.ruckus.download -# application/vnd.s3sms -application/vnd.sailingtracker.track st -# application/vnd.sbm.cid -# application/vnd.sbm.mid2 -# application/vnd.scribus -# application/vnd.sealed.3df -# application/vnd.sealed.csf -# application/vnd.sealed.doc -# application/vnd.sealed.eml -# application/vnd.sealed.mht -# application/vnd.sealed.net -# application/vnd.sealed.ppt -# application/vnd.sealed.tiff -# application/vnd.sealed.xls -# application/vnd.sealedmedia.softseal.html -# application/vnd.sealedmedia.softseal.pdf -application/vnd.seemail see -application/vnd.sema sema -application/vnd.semd semd -application/vnd.semf semf -application/vnd.shana.informed.formdata ifm -application/vnd.shana.informed.formtemplate itp -application/vnd.shana.informed.interchange iif -application/vnd.shana.informed.package ipk -application/vnd.simtech-mindmapper twd twds -application/vnd.smaf mmf -# application/vnd.smart.notebook -application/vnd.smart.teacher teacher -# application/vnd.software602.filler.form+xml -# application/vnd.software602.filler.form-xml-zip -application/vnd.solent.sdkm+xml sdkm sdkd -application/vnd.spotfire.dxp dxp -application/vnd.spotfire.sfs sfs -# application/vnd.sss-cod -# application/vnd.sss-dtf -# application/vnd.sss-ntf -application/vnd.stardivision.calc sdc -application/vnd.stardivision.draw sda -application/vnd.stardivision.impress sdd -application/vnd.stardivision.math smf -application/vnd.stardivision.writer sdw -application/vnd.stardivision.writer vor -application/vnd.stardivision.writer-global sgl -# application/vnd.street-stream -application/vnd.sun.xml.calc sxc -application/vnd.sun.xml.calc.template stc -application/vnd.sun.xml.draw sxd -application/vnd.sun.xml.draw.template std -application/vnd.sun.xml.impress sxi -application/vnd.sun.xml.impress.template sti -application/vnd.sun.xml.math sxm -application/vnd.sun.xml.writer sxw -application/vnd.sun.xml.writer.global sxg -application/vnd.sun.xml.writer.template stw -# application/vnd.sun.wadl+xml -application/vnd.sus-calendar sus susp -application/vnd.svd svd -# application/vnd.swiftview-ics -application/vnd.symbian.install sis sisx -application/vnd.syncml+xml xsm -application/vnd.syncml.dm+wbxml bdm -application/vnd.syncml.dm+xml xdm -# application/vnd.syncml.dm.notification -# application/vnd.syncml.ds.notification -application/vnd.tao.intent-module-archive tao -application/vnd.tmobile-livetv tmo -application/vnd.trid.tpt tpt -application/vnd.triscape.mxs mxs -application/vnd.trueapp tra -# application/vnd.truedoc -application/vnd.ufdl ufd ufdl -application/vnd.uiq.theme utz -application/vnd.umajin umj -application/vnd.unity unityweb -application/vnd.uoml+xml uoml -# application/vnd.uplanet.alert -# application/vnd.uplanet.alert-wbxml -# application/vnd.uplanet.bearer-choice -# application/vnd.uplanet.bearer-choice-wbxml -# application/vnd.uplanet.cacheop -# application/vnd.uplanet.cacheop-wbxml -# application/vnd.uplanet.channel -# application/vnd.uplanet.channel-wbxml -# application/vnd.uplanet.list -# application/vnd.uplanet.list-wbxml -# application/vnd.uplanet.listcmd -# application/vnd.uplanet.listcmd-wbxml -# application/vnd.uplanet.signal -application/vnd.vcx vcx -# application/vnd.vd-study -# application/vnd.vectorworks -# application/vnd.vidsoft.vidconference -application/vnd.visio vsd vst vss vsw -application/vnd.visionary vis -# application/vnd.vividence.scriptfile -application/vnd.vsf vsf -# application/vnd.wap.sic -# application/vnd.wap.slc -application/vnd.wap.wbxml wbxml -application/vnd.wap.wmlc wmlc -application/vnd.wap.wmlscriptc wmlsc -application/vnd.webturbo wtb -# application/vnd.wfa.wsc -# application/vnd.wmc -# application/vnd.wmf.bootstrap -# application/vnd.wolfram.mathematica -# application/vnd.wolfram.mathematica.package -application/vnd.wolfram.player nbp -application/vnd.wordperfect wpd -application/vnd.wqd wqd -# application/vnd.wrq-hp3000-labelled -application/vnd.wt.stf stf -# application/vnd.wv.csp+wbxml -# application/vnd.wv.csp+xml -# application/vnd.wv.ssp+xml -application/vnd.xara xar -application/vnd.xfdl xfdl -# application/vnd.xfdl.webform -# application/vnd.xmi+xml -# application/vnd.xmpie.cpkg -# application/vnd.xmpie.dpkg -# application/vnd.xmpie.plan -# application/vnd.xmpie.ppkg -# application/vnd.xmpie.xlim -application/vnd.yamaha.hv-dic hvd -application/vnd.yamaha.hv-script hvs -application/vnd.yamaha.hv-voice hvp -application/vnd.yamaha.openscoreformat osf -application/vnd.yamaha.openscoreformat.osfpvg+xml osfpvg -application/vnd.yamaha.smaf-audio saf -application/vnd.yamaha.smaf-phrase spf -application/vnd.yellowriver-custom-menu cmp -application/vnd.zul zir zirz -application/vnd.zzazz.deck+xml zaz -application/voicexml+xml vxml -# application/watcherinfo+xml -# application/whoispp-query -# application/whoispp-response -application/winhlp hlp -# application/wita -# application/wordperfect5.1 -application/wsdl+xml wsdl -application/wspolicy+xml wspolicy -application/x-abiword abw -application/x-ace-compressed ace -application/x-authorware-bin aab x32 u32 vox -application/x-authorware-map aam -application/x-authorware-seg aas -application/x-bcpio bcpio -application/x-bittorrent torrent -application/x-bzip bz -application/x-bzip2 bz2 boz -application/x-cdlink vcd -application/x-chat chat -application/x-chess-pgn pgn -# application/x-compress -application/x-cpio cpio -application/x-csh csh -application/x-debian-package deb udeb -application/x-director dir dcr dxr cst cct cxt w3d fgd swa -application/x-doom wad -application/x-dtbncx+xml ncx -application/x-dtbook+xml dtb -application/x-dtbresource+xml res -application/x-dvi dvi -application/x-font-bdf bdf -# application/x-font-dos -# application/x-font-framemaker -application/x-font-ghostscript gsf -# application/x-font-libgrx -application/x-font-linux-psf psf -application/x-font-otf otf -application/x-font-pcf pcf -application/x-font-snf snf -# application/x-font-speedo -# application/x-font-sunos-news -application/x-font-ttf ttf ttc -application/x-font-type1 pfa pfb pfm afm -# application/x-font-vfont -application/x-futuresplash spl -application/x-gnumeric gnumeric -application/x-gtar gtar -# application/x-gzip -application/x-hdf hdf -application/x-java-jnlp-file jnlp -application/x-latex latex -application/x-mobipocket-ebook prc mobi -application/x-ms-application application -application/x-ms-wmd wmd -application/x-ms-wmz wmz -application/x-ms-xbap xbap -application/x-msaccess mdb -application/x-msbinder obd -application/x-mscardfile crd -application/x-msclip clp -application/x-msdownload exe dll com bat msi -application/x-msmediaview mvb m13 m14 -application/x-msmetafile wmf -application/x-msmoney mny -application/x-mspublisher pub -application/x-msschedule scd -application/x-msterminal trm -application/x-mswrite wri -application/x-netcdf nc cdf -application/x-pkcs12 p12 pfx -application/x-pkcs7-certificates p7b spc -application/x-pkcs7-certreqresp p7r -application/x-rar-compressed rar -application/x-sh sh -application/x-shar shar -application/x-shockwave-flash swf -application/x-silverlight-app xap -application/x-stuffit sit -application/x-stuffitx sitx -application/x-sv4cpio sv4cpio -application/x-sv4crc sv4crc -application/x-tar tar -application/x-tcl tcl -application/x-tex tex -application/x-tex-tfm tfm -application/x-texinfo texinfo texi -application/x-ustar ustar -application/x-wais-source src -application/x-x509-ca-cert der crt -application/x-xfig fig -application/x-xpinstall xpi -# application/x400-bp -# application/xcap-att+xml -# application/xcap-caps+xml -# application/xcap-el+xml -# application/xcap-error+xml -# application/xcap-ns+xml -# application/xcon-conference-info-diff+xml -# application/xcon-conference-info+xml -application/xenc+xml xenc -application/xhtml+xml xhtml xht -# application/xhtml-voice+xml -application/xml xml xsl -application/xml-dtd dtd -# application/xml-external-parsed-entity -# application/xmpp+xml -application/xop+xml xop -application/xslt+xml xslt -application/xspf+xml xspf -application/xv+xml mxml xhvml xvml xvm -application/zip zip -# audio/32kadpcm -# audio/3gpp -# audio/3gpp2 -# audio/ac3 -audio/adpcm adp -# audio/amr -# audio/amr-wb -# audio/amr-wb+ -# audio/asc -# audio/atrac-advanced-lossless -# audio/atrac-x -# audio/atrac3 -audio/basic au snd -# audio/bv16 -# audio/bv32 -# audio/clearmode -# audio/cn -# audio/dat12 -# audio/dls -# audio/dsr-es201108 -# audio/dsr-es202050 -# audio/dsr-es202211 -# audio/dsr-es202212 -# audio/dvi4 -# audio/eac3 -# audio/evrc -# audio/evrc-qcp -# audio/evrc0 -# audio/evrc1 -# audio/evrcb -# audio/evrcb0 -# audio/evrcb1 -# audio/evrcwb -# audio/evrcwb0 -# audio/evrcwb1 -# audio/example -# audio/g719 -# audio/g722 -# audio/g7221 -# audio/g723 -# audio/g726-16 -# audio/g726-24 -# audio/g726-32 -# audio/g726-40 -# audio/g728 -# audio/g729 -# audio/g7291 -# audio/g729d -# audio/g729e -# audio/gsm -# audio/gsm-efr -# audio/ilbc -# audio/l16 -# audio/l20 -# audio/l24 -# audio/l8 -# audio/lpc -audio/midi mid midi kar rmi -# audio/mobile-xmf -audio/mp4 mp4a -# audio/mp4a-latm -# audio/mpa -# audio/mpa-robust -audio/mpeg mpga mp2 mp2a mp3 m2a m3a -# audio/mpeg4-generic -audio/ogg oga ogg spx -# audio/parityfec -# audio/pcma -# audio/pcma-wb -# audio/pcmu-wb -# audio/pcmu -# audio/prs.sid -# audio/qcelp -# audio/red -# audio/rtp-enc-aescm128 -# audio/rtp-midi -# audio/rtx -# audio/smv -# audio/smv0 -# audio/smv-qcp -# audio/sp-midi -# audio/speex -# audio/t140c -# audio/t38 -# audio/telephone-event -# audio/tone -# audio/uemclip -# audio/ulpfec -# audio/vdvi -# audio/vmr-wb -# audio/vnd.3gpp.iufp -# audio/vnd.4sb -# audio/vnd.audiokoz -# audio/vnd.celp -# audio/vnd.cisco.nse -# audio/vnd.cmles.radio-events -# audio/vnd.cns.anp1 -# audio/vnd.cns.inf1 -audio/vnd.digital-winds eol -# audio/vnd.dlna.adts -# audio/vnd.dolby.heaac.1 -# audio/vnd.dolby.heaac.2 -# audio/vnd.dolby.mlp -# audio/vnd.dolby.mps -# audio/vnd.dolby.pl2 -# audio/vnd.dolby.pl2x -# audio/vnd.dolby.pl2z -# audio/vnd.dolby.pulse.1 -audio/vnd.dra dra -audio/vnd.dts dts -audio/vnd.dts.hd dtshd -# audio/vnd.everad.plj -# audio/vnd.hns.audio -audio/vnd.lucent.voice lvp -audio/vnd.ms-playready.media.pya pya -# audio/vnd.nokia.mobile-xmf -# audio/vnd.nortel.vbk -audio/vnd.nuera.ecelp4800 ecelp4800 -audio/vnd.nuera.ecelp7470 ecelp7470 -audio/vnd.nuera.ecelp9600 ecelp9600 -# audio/vnd.octel.sbc -# audio/vnd.qcelp -# audio/vnd.rhetorex.32kadpcm -# audio/vnd.sealedmedia.softseal.mpeg -# audio/vnd.vmx.cvsd -# audio/vorbis -# audio/vorbis-config -audio/x-aac aac -audio/x-aiff aif aiff aifc -audio/x-mpegurl m3u -audio/x-ms-wax wax -audio/x-ms-wma wma -audio/x-pn-realaudio ram ra -audio/x-pn-realaudio-plugin rmp -audio/x-wav wav -chemical/x-cdx cdx -chemical/x-cif cif -chemical/x-cmdf cmdf -chemical/x-cml cml -chemical/x-csml csml -# chemical/x-pdb -chemical/x-xyz xyz -image/bmp bmp -image/cgm cgm -# image/example -# image/fits -image/g3fax g3 -image/gif gif -image/ief ief -# image/jp2 -image/jpeg jpeg jpg jpe -# image/jpm -# image/jpx -# image/naplps -image/png png -image/prs.btif btif -# image/prs.pti -image/svg+xml svg svgz -# image/t38 -image/tiff tiff tif -# image/tiff-fx -image/vnd.adobe.photoshop psd -# image/vnd.cns.inf2 -image/vnd.djvu djvu djv -image/vnd.dwg dwg -image/vnd.dxf dxf -image/vnd.fastbidsheet fbs -image/vnd.fpx fpx -image/vnd.fst fst -image/vnd.fujixerox.edmics-mmr mmr -image/vnd.fujixerox.edmics-rlc rlc -# image/vnd.globalgraphics.pgb -# image/vnd.microsoft.icon -# image/vnd.mix -image/vnd.ms-modi mdi -image/vnd.net-fpx npx -# image/vnd.radiance -# image/vnd.sealed.png -# image/vnd.sealedmedia.softseal.gif -# image/vnd.sealedmedia.softseal.jpg -# image/vnd.svf -image/vnd.wap.wbmp wbmp -image/vnd.xiff xif -image/x-cmu-raster ras -image/x-cmx cmx -image/x-freehand fh fhc fh4 fh5 fh7 -image/x-icon ico -image/x-pcx pcx -image/x-pict pic pct -image/x-portable-anymap pnm -image/x-portable-bitmap pbm -image/x-portable-graymap pgm -image/x-portable-pixmap ppm -image/x-rgb rgb -image/x-xbitmap xbm -image/x-xpixmap xpm -image/x-xwindowdump xwd -# message/cpim -# message/delivery-status -# message/disposition-notification -# message/example -# message/external-body -# message/global -# message/global-delivery-status -# message/global-disposition-notification -# message/global-headers -# message/http -# message/imdn+xml -# message/news -# message/partial -message/rfc822 eml mime -# message/s-http -# message/sip -# message/sipfrag -# message/tracking-status -# message/vnd.si.simp -# model/example -model/iges igs iges -model/mesh msh mesh silo -model/vnd.dwf dwf -# model/vnd.flatland.3dml -model/vnd.gdl gdl -# model/vnd.gs-gdl -# model/vnd.gs.gdl -model/vnd.gtw gtw -# model/vnd.moml+xml -model/vnd.mts mts -# model/vnd.parasolid.transmit.binary -# model/vnd.parasolid.transmit.text -model/vnd.vtu vtu -model/vrml wrl vrml -# multipart/alternative -# multipart/appledouble -# multipart/byteranges -# multipart/digest -# multipart/encrypted -# multipart/example -# multipart/form-data -# multipart/header-set -# multipart/mixed -# multipart/parallel -# multipart/related -# multipart/report -# multipart/signed -# multipart/voice-message -text/calendar ics ifb -text/css css -text/csv csv -# text/directory -# text/dns -# text/ecmascript -# text/enriched -# text/example -text/html html htm -# text/javascript -# text/parityfec -text/plain txt text conf def list log in -# text/prs.fallenstein.rst -text/prs.lines.tag dsc -# text/vnd.radisys.msml-basic-layout -# text/red -# text/rfc822-headers -text/richtext rtx -# text/rtf -# text/rtp-enc-aescm128 -# text/rtx -text/sgml sgml sgm -# text/t140 -text/tab-separated-values tsv -text/troff t tr roff man me ms -# text/ulpfec -text/uri-list uri uris urls -# text/vnd.abc -text/vnd.curl curl -text/vnd.curl.dcurl dcurl -text/vnd.curl.scurl scurl -text/vnd.curl.mcurl mcurl -# text/vnd.dmclientscript -# text/vnd.esmertec.theme-descriptor -text/vnd.fly fly -text/vnd.fmi.flexstor flx -text/vnd.graphviz gv -text/vnd.in3d.3dml 3dml -text/vnd.in3d.spot spot -# text/vnd.iptc.newsml -# text/vnd.iptc.nitf -# text/vnd.latex-z -# text/vnd.motorola.reflex -# text/vnd.ms-mediapackage -# text/vnd.net2phone.commcenter.command -# text/vnd.si.uricatalogue -text/vnd.sun.j2me.app-descriptor jad -# text/vnd.trolltech.linguist -# text/vnd.wap.si -# text/vnd.wap.sl -text/vnd.wap.wml wml -text/vnd.wap.wmlscript wmls -text/x-asm s asm -text/x-c c cc cxx cpp h hh dic -text/x-fortran f for f77 f90 -text/x-pascal p pas -text/x-java-source java -text/x-setext etx -text/x-uuencode uu -text/x-vcalendar vcs -text/x-vcard vcf -# text/xml -# text/xml-external-parsed-entity -video/3gpp 3gp -# video/3gpp-tt -video/3gpp2 3g2 -# video/bmpeg -# video/bt656 -# video/celb -# video/dv -# video/example -video/h261 h261 -video/h263 h263 -# video/h263-1998 -# video/h263-2000 -video/h264 h264 -video/jpeg jpgv -# video/jpeg2000 -video/jpm jpm jpgm -video/mj2 mj2 mjp2 -# video/mp1s -# video/mp2p -# video/mp2t -video/mp4 mp4 mp4v mpg4 -# video/mp4v-es -video/mpeg mpeg mpg mpe m1v m2v -# video/mpeg4-generic -# video/mpv -# video/nv -video/ogg ogv -# video/parityfec -# video/pointer -video/quicktime qt mov -# video/raw -# video/rtp-enc-aescm128 -# video/rtx -# video/smpte292m -# video/ulpfec -# video/vc1 -# video/vnd.cctv -# video/vnd.dlna.mpeg-tts -video/vnd.fvt fvt -# video/vnd.hns.video -# video/vnd.iptvforum.1dparityfec-1010 -# video/vnd.iptvforum.1dparityfec-2005 -# video/vnd.iptvforum.2dparityfec-1010 -# video/vnd.iptvforum.2dparityfec-2005 -# video/vnd.iptvforum.ttsavc -# video/vnd.iptvforum.ttsmpeg2 -# video/vnd.motorola.video -# video/vnd.motorola.videop -video/vnd.mpegurl mxu m4u -video/vnd.ms-playready.media.pyv pyv -# video/vnd.nokia.interleaved-multimedia -# video/vnd.nokia.videovoip -# video/vnd.objectvideo -# video/vnd.sealed.mpeg1 -# video/vnd.sealed.mpeg4 -# video/vnd.sealed.swf -# video/vnd.sealedmedia.softseal.mov -video/vnd.vivo viv -video/x-f4v f4v -video/x-fli fli -video/x-flv flv -video/x-m4v m4v -video/x-ms-asf asf asx -video/x-ms-wm wm -video/x-ms-wmv wmv -video/x-ms-wmx wmx -video/x-ms-wvx wvx -video/x-msvideo avi -video/x-sgi-movie movie -x-conference/x-cooltalk ice diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/includes/inventory-single-vhost.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/includes/inventory-single-vhost.xml new file mode 100644 index 0000000..00ac425 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/includes/inventory-single-vhost.xml @@ -0,0 +1,215 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10004</id> + <uuid>ae8a7a3e-256e-4c0a-9a65-33d534523d92</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost} Apache 2.2.17 (${server.root}/)</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>true</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1307353451273</ctime> + <mtime>1307353509168</mtime> + <itime>1307353509168</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10013</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10012</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10022</id> + <uuid>08290193-c716-4363-b841-8a1d9d83f580</uuid> + <resourceKey>${snmp.identifier}</resourceKey> + <name>Virtual Host ${snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587727</ctime> + <mtime>1307353587727</mtime> + <itime>1307353587721</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10137</id> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10138</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + <propertySimple> + <id>10690</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10689</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/${localhost}0_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10692</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Blocalhost%7D:0/</stringValue> + </propertySimple> + <propertySimple> + <id>10693</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>1</stringValue> + </propertySimple> + <propertySimple> + <id>10691</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>DOWN</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10142</id> + <version>0</version> + <ctime>1307353451273</ctime> + <mtime>1307353451273</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10073</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353737118</ctime> + <mtime>1307353737118</mtime> + <propertySimple> + <id>10365</id> + <name>errorLogMinimumSeverity</name> + <override>false</override> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10366</id> + <name>errorLogIncludesPattern</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10367</id> + <name>snmpAgentCommunity</name> + <override>false</override> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10368</id> + <name>errorLogFilePath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10369</id> + <name>errorLogEventsEnabled</name> + <override>false</override> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10370</id> + <name>snmpAgentHost</name> + <override>false</override> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10713</id> + <name>controlScriptPath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10714</id> + <name>url</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10364</id> + <name>configFile</name> + <override>false</override> + <stringValue>conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10711</id> + <name>executablePath</name> + <override>false</override> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10712</id> + <name>snmpAgentPort</name> + <override>false</override> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10715</id> + <name>serverRoot</name> + <override>false</override> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10003</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/mess/inventory-single-vhost.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/mess/inventory-single-vhost.xml new file mode 100644 index 0000000..00ac425 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/mess/inventory-single-vhost.xml @@ -0,0 +1,215 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10004</id> + <uuid>ae8a7a3e-256e-4c0a-9a65-33d534523d92</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost} Apache 2.2.17 (${server.root}/)</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>true</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1307353451273</ctime> + <mtime>1307353509168</mtime> + <itime>1307353509168</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10013</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10012</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10022</id> + <uuid>08290193-c716-4363-b841-8a1d9d83f580</uuid> + <resourceKey>${snmp.identifier}</resourceKey> + <name>Virtual Host ${snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587727</ctime> + <mtime>1307353587727</mtime> + <itime>1307353587721</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10137</id> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10138</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + <propertySimple> + <id>10690</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10689</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/${localhost}0_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10692</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Blocalhost%7D:0/</stringValue> + </propertySimple> + <propertySimple> + <id>10693</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>1</stringValue> + </propertySimple> + <propertySimple> + <id>10691</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>DOWN</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10142</id> + <version>0</version> + <ctime>1307353451273</ctime> + <mtime>1307353451273</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10073</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353737118</ctime> + <mtime>1307353737118</mtime> + <propertySimple> + <id>10365</id> + <name>errorLogMinimumSeverity</name> + <override>false</override> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10366</id> + <name>errorLogIncludesPattern</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10367</id> + <name>snmpAgentCommunity</name> + <override>false</override> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10368</id> + <name>errorLogFilePath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10369</id> + <name>errorLogEventsEnabled</name> + <override>false</override> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10370</id> + <name>snmpAgentHost</name> + <override>false</override> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10713</id> + <name>controlScriptPath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10714</id> + <name>url</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10364</id> + <name>configFile</name> + <override>false</override> + <stringValue>conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10711</id> + <name>executablePath</name> + <override>false</override> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10712</id> + <name>snmpAgentPort</name> + <override>false</override> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10715</id> + <name>serverRoot</name> + <override>false</override> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10003</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/mess/inventory.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/mess/inventory.xml new file mode 100644 index 0000000..2804e4a --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/mess/inventory.xml @@ -0,0 +1,543 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10004</id> + <uuid>ae8a7a3e-256e-4c0a-9a65-33d534523d92</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost} Apache 2.2.17 (${server.root}/)</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>true</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1307353451273</ctime> + <mtime>1307353509168</mtime> + <itime>1307353509168</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10013</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10012</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10022</id> + <uuid>08290193-c716-4363-b841-8a1d9d83f580</uuid> + <resourceKey>${snmp.identifier}</resourceKey> + <name>Virtual Host ${snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587727</ctime> + <mtime>1307353587727</mtime> + <itime>1307353587721</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10137</id> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10138</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + <propertySimple> + <id>10690</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10689</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/${localhost}0_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10692</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Blocalhost%7D:0/</stringValue> + </propertySimple> + <propertySimple> + <id>10693</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>1</stringValue> + </propertySimple> + <propertySimple> + <id>10691</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>DOWN</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10021</id> + <uuid>3a20d809-7eba-422c-a3ef-baf65804498d</uuid> + <resourceKey>${vhost2.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost2.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587648</ctime> + <mtime>1307353587648</mtime> + <itime>1307353587648</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10135</id> + <version>0</version> + <ctime>1307353587666</ctime> + <mtime>1307353587666</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10136</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587667</ctime> + <mtime>1307353587667</mtime> + <propertySimple> + <id>10685</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10684</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111676_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10687</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost2.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10688</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>4</stringValue> + </propertySimple> + <propertySimple> + <id>10686</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> +<!-- + <childResources> + <id>10023</id> + <uuid>c62c5d75-81dd-4b14-a768-2d8c1fca6c88</uuid> + <resourceKey>${vhost3.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost3.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + <itime>1307353587737</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10139</id> + <version>0</version> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10140</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + <propertySimple> + <id>10695</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10694</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111677_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10697</id> + <name>url</name> + <override>false</override> + <stringValue>http://${vhost3.snmp.identifier}/</stringValue> + </propertySimple> + <propertySimple> + <id>10698</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>3</stringValue> + </propertySimple> + <propertySimple> + <id>10696</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + --> + <!-- + <childResources> + <id>10024</id> + <uuid>d1b59168-8666-4bc0-957e-171bf16eec73</uuid> + <resourceKey>${vhost1.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost1.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + <itime>1307353587750</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10171</id> + <version>0</version> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10172</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + <propertySimple> + <id>10700</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10699</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10702</id> + <name>url</name> + <override>false</override> + <stringValue>http://${vhost1.snmp.identifier}/</stringValue> + </propertySimple> + <propertySimple> + <id>10703</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>5</stringValue> + </propertySimple> + <propertySimple> + <id>10701</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + --> + <childResources> + <id>10025</id> + <uuid>310281d2-60c6-4d7d-bcdc-c51d7969c906</uuid> + <resourceKey>${vhost4.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + <itime>1307353587760</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10173</id> + <version>0</version> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10174</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + <propertySimple> + <id>10705</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10704</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10707</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>2</stringValue> + </propertySimple> + <propertySimple> + <id>10706</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10142</id> + <version>0</version> + <ctime>1307353451273</ctime> + <mtime>1307353451273</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10073</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353737118</ctime> + <mtime>1307353737118</mtime> + <propertySimple> + <id>10365</id> + <name>errorLogMinimumSeverity</name> + <override>false</override> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10366</id> + <name>errorLogIncludesPattern</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10367</id> + <name>snmpAgentCommunity</name> + <override>false</override> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10368</id> + <name>errorLogFilePath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10369</id> + <name>errorLogEventsEnabled</name> + <override>false</override> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10370</id> + <name>snmpAgentHost</name> + <override>false</override> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10713</id> + <name>controlScriptPath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10714</id> + <name>url</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10364</id> + <name>configFile</name> + <override>false</override> + <stringValue>conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10711</id> + <name>executablePath</name> + <override>false</override> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10712</id> + <name>snmpAgentPort</name> + <override>false</override> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10715</id> + <name>serverRoot</name> + <override>false</override> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10003</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/nested/inventory-single-vhost.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/nested/inventory-single-vhost.xml new file mode 100644 index 0000000..00ac425 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/nested/inventory-single-vhost.xml @@ -0,0 +1,215 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10004</id> + <uuid>ae8a7a3e-256e-4c0a-9a65-33d534523d92</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost} Apache 2.2.17 (${server.root}/)</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>true</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1307353451273</ctime> + <mtime>1307353509168</mtime> + <itime>1307353509168</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10013</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10012</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10022</id> + <uuid>08290193-c716-4363-b841-8a1d9d83f580</uuid> + <resourceKey>${snmp.identifier}</resourceKey> + <name>Virtual Host ${snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587727</ctime> + <mtime>1307353587727</mtime> + <itime>1307353587721</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10137</id> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10138</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + <propertySimple> + <id>10690</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10689</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/${localhost}0_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10692</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Blocalhost%7D:0/</stringValue> + </propertySimple> + <propertySimple> + <id>10693</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>1</stringValue> + </propertySimple> + <propertySimple> + <id>10691</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>DOWN</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10142</id> + <version>0</version> + <ctime>1307353451273</ctime> + <mtime>1307353451273</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10073</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353737118</ctime> + <mtime>1307353737118</mtime> + <propertySimple> + <id>10365</id> + <name>errorLogMinimumSeverity</name> + <override>false</override> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10366</id> + <name>errorLogIncludesPattern</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10367</id> + <name>snmpAgentCommunity</name> + <override>false</override> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10368</id> + <name>errorLogFilePath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10369</id> + <name>errorLogEventsEnabled</name> + <override>false</override> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10370</id> + <name>snmpAgentHost</name> + <override>false</override> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10713</id> + <name>controlScriptPath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10714</id> + <name>url</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10364</id> + <name>configFile</name> + <override>false</override> + <stringValue>conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10711</id> + <name>executablePath</name> + <override>false</override> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10712</id> + <name>snmpAgentPort</name> + <override>false</override> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10715</id> + <name>serverRoot</name> + <override>false</override> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10003</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/nested/inventory.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/nested/inventory.xml new file mode 100644 index 0000000..2804e4a --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/nested/inventory.xml @@ -0,0 +1,543 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10004</id> + <uuid>ae8a7a3e-256e-4c0a-9a65-33d534523d92</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost} Apache 2.2.17 (${server.root}/)</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>true</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1307353451273</ctime> + <mtime>1307353509168</mtime> + <itime>1307353509168</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10013</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10012</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10022</id> + <uuid>08290193-c716-4363-b841-8a1d9d83f580</uuid> + <resourceKey>${snmp.identifier}</resourceKey> + <name>Virtual Host ${snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587727</ctime> + <mtime>1307353587727</mtime> + <itime>1307353587721</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10137</id> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10138</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + <propertySimple> + <id>10690</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10689</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/${localhost}0_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10692</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Blocalhost%7D:0/</stringValue> + </propertySimple> + <propertySimple> + <id>10693</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>1</stringValue> + </propertySimple> + <propertySimple> + <id>10691</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>DOWN</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10021</id> + <uuid>3a20d809-7eba-422c-a3ef-baf65804498d</uuid> + <resourceKey>${vhost2.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost2.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587648</ctime> + <mtime>1307353587648</mtime> + <itime>1307353587648</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10135</id> + <version>0</version> + <ctime>1307353587666</ctime> + <mtime>1307353587666</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10136</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587667</ctime> + <mtime>1307353587667</mtime> + <propertySimple> + <id>10685</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10684</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111676_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10687</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost2.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10688</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>4</stringValue> + </propertySimple> + <propertySimple> + <id>10686</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> +<!-- + <childResources> + <id>10023</id> + <uuid>c62c5d75-81dd-4b14-a768-2d8c1fca6c88</uuid> + <resourceKey>${vhost3.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost3.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + <itime>1307353587737</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10139</id> + <version>0</version> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10140</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + <propertySimple> + <id>10695</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10694</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111677_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10697</id> + <name>url</name> + <override>false</override> + <stringValue>http://${vhost3.snmp.identifier}/</stringValue> + </propertySimple> + <propertySimple> + <id>10698</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>3</stringValue> + </propertySimple> + <propertySimple> + <id>10696</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + --> + <!-- + <childResources> + <id>10024</id> + <uuid>d1b59168-8666-4bc0-957e-171bf16eec73</uuid> + <resourceKey>${vhost1.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost1.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + <itime>1307353587750</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10171</id> + <version>0</version> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10172</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + <propertySimple> + <id>10700</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10699</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10702</id> + <name>url</name> + <override>false</override> + <stringValue>http://${vhost1.snmp.identifier}/</stringValue> + </propertySimple> + <propertySimple> + <id>10703</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>5</stringValue> + </propertySimple> + <propertySimple> + <id>10701</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + --> + <childResources> + <id>10025</id> + <uuid>310281d2-60c6-4d7d-bcdc-c51d7969c906</uuid> + <resourceKey>${vhost4.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + <itime>1307353587760</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10173</id> + <version>0</version> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10174</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + <propertySimple> + <id>10705</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10704</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10707</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>2</stringValue> + </propertySimple> + <propertySimple> + <id>10706</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10142</id> + <version>0</version> + <ctime>1307353451273</ctime> + <mtime>1307353451273</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10073</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353737118</ctime> + <mtime>1307353737118</mtime> + <propertySimple> + <id>10365</id> + <name>errorLogMinimumSeverity</name> + <override>false</override> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10366</id> + <name>errorLogIncludesPattern</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10367</id> + <name>snmpAgentCommunity</name> + <override>false</override> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10368</id> + <name>errorLogFilePath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10369</id> + <name>errorLogEventsEnabled</name> + <override>false</override> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10370</id> + <name>snmpAgentHost</name> + <override>false</override> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10713</id> + <name>controlScriptPath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10714</id> + <name>url</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10364</id> + <name>configFile</name> + <override>false</override> + <stringValue>conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10711</id> + <name>executablePath</name> + <override>false</override> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10712</id> + <name>snmpAgentPort</name> + <override>false</override> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10715</id> + <name>serverRoot</name> + <override>false</override> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10003</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/simple/inventory-single-vhost.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/simple/inventory-single-vhost.xml new file mode 100644 index 0000000..00ac425 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/simple/inventory-single-vhost.xml @@ -0,0 +1,215 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10004</id> + <uuid>ae8a7a3e-256e-4c0a-9a65-33d534523d92</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost} Apache 2.2.17 (${server.root}/)</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>true</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1307353451273</ctime> + <mtime>1307353509168</mtime> + <itime>1307353509168</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10013</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10012</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10022</id> + <uuid>08290193-c716-4363-b841-8a1d9d83f580</uuid> + <resourceKey>${snmp.identifier}</resourceKey> + <name>Virtual Host ${snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587727</ctime> + <mtime>1307353587727</mtime> + <itime>1307353587721</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10137</id> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10138</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + <propertySimple> + <id>10690</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10689</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/${localhost}0_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10692</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Blocalhost%7D:0/</stringValue> + </propertySimple> + <propertySimple> + <id>10693</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>1</stringValue> + </propertySimple> + <propertySimple> + <id>10691</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>DOWN</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10142</id> + <version>0</version> + <ctime>1307353451273</ctime> + <mtime>1307353451273</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10073</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353737118</ctime> + <mtime>1307353737118</mtime> + <propertySimple> + <id>10365</id> + <name>errorLogMinimumSeverity</name> + <override>false</override> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10366</id> + <name>errorLogIncludesPattern</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10367</id> + <name>snmpAgentCommunity</name> + <override>false</override> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10368</id> + <name>errorLogFilePath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10369</id> + <name>errorLogEventsEnabled</name> + <override>false</override> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10370</id> + <name>snmpAgentHost</name> + <override>false</override> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10713</id> + <name>controlScriptPath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10714</id> + <name>url</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10364</id> + <name>configFile</name> + <override>false</override> + <stringValue>conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10711</id> + <name>executablePath</name> + <override>false</override> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10712</id> + <name>snmpAgentPort</name> + <override>false</override> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10715</id> + <name>serverRoot</name> + <override>false</override> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10003</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/includes/inventory-with-snmp.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/includes/inventory-with-snmp.xml index ff9d715..8b3e0ff 100644 --- a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/includes/inventory-with-snmp.xml +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/includes/inventory-with-snmp.xml @@ -398,7 +398,7 @@ <propertySimple> <id>10795</id> <name>url</name> - <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + <stringValue>http://$%7Blocalhost.ip%7D:$%7Bport1%7D/</stringValue> </propertySimple> <propertySimple> <id>10709</id> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/mess/inventory-with-snmp.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/mess/inventory-with-snmp.xml new file mode 100644 index 0000000..89bfa5a --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/mess/inventory-with-snmp.xml @@ -0,0 +1,313 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10022</id> + <uuid>e61040b4-d645-44dc-a6b7-460d39f1b625</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost}:${port1}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1308835177519</ctime> + <mtime>1308835282077</mtime> + <itime>1308835282077</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10044</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10101</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10102</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10037</id> + <uuid>b2928cc6-30ab-47fe-8095-e1292887ac18</uuid> + <!-- this resource key is the correct one here. For some reason that I have not investigated but only + experimentally checked, the RHQ 3.0.0 codebase assigns the "MainServer" resource key in this scenario + even if the SNMP is enabled. --> + <resourceKey>${main.rhq4.resource.key}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + <itime>1308835287473</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10188</id> + <version>0</version> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10189</id> + <version>0</version> + <ctime>1308835287474</ctime> + <mtime>1308835287474</mtime> + <propertySimple> + <id>10806</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10805</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10808</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10807</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10038</id> + <uuid>fe8d389e-5a45-4bf2-9f73-0831caca63df</uuid> + <resourceKey>${vhost4.rhq3.resource.key}</resourceKey> + <name>${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <itime>1308835287481</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10190</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10191</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <propertySimple> + <id>10810</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10809</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10812</id> + <name>url</name> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10811</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10174</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10175</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + <propertySimple> + <id>10790</id> + <name>errorLogIncludesPattern</name> + </propertySimple> + <propertySimple> + <id>10783</id> + <name>errorLogMinimumSeverity</name> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>augeasEnabled</name> + <stringValue>no</stringValue> + </propertySimple> + <propertySimple> + <id>10789</id> + <name>errorLogFilePath</name> + </propertySimple> + <propertySimple> + <id>10786</id> + <name>snmpAgentCommunity</name> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10784</id> + <name>snmpAgentHost</name> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10782</id> + <name>errorLogEventsEnabled</name> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10793</id> + <name>controlScriptPath</name> + </propertySimple> + <propertySimple> + <id>10795</id> + <name>url</name> + <stringValue>http://$%7Blocalhost.ip%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10709</id> + <name>augeasModuleName</name> + <stringValue>Httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10794</id> + <name>configFile</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10710</id> + <name>configurationFilesInclusionPatterns</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10788</id> + <name>vhostFilesMask</name> + <stringValue>${server.root}/conf/*</stringValue> + </propertySimple> + <propertySimple> + <id>10787</id> + <name>restartAfterConfigurationUpdate</name> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10792</id> + <name>executablePath</name> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10785</id> + <name>snmpAgentPort</name> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10781</id> + <name>vhostCreationPolicy</name> + <stringValue>vhost-per-file</stringValue> + </propertySimple> + <propertySimple> + <id>10791</id> + <name>serverRoot</name> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/mess/inventory-without-snmp.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/mess/inventory-without-snmp.xml new file mode 100644 index 0000000..b054c63 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/mess/inventory-without-snmp.xml @@ -0,0 +1,310 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10041</id> + <uuid>02f44194-9bb8-44ef-9866-ef7b69eedc0a</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost}:${port1}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>true</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1309116183350</ctime> + <mtime>1309116225316</mtime> + <itime>1309116225316</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10044</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10101</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10102</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10046</id> + <uuid>908ea047-889e-4978-a61f-d96e8b1c6d17</uuid> + <resourceKey>${vhost4.rhq4.resource.key}</resourceKey> + <name>${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635789</ctime> + <mtime>1309117635789</mtime> + <itime>1309117635788</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10241</id> + <version>0</version> + <ctime>1309117635789</ctime> + <mtime>1309117635789</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10242</id> + <version>0</version> + <ctime>1309117635790</ctime> + <mtime>1309117635790</mtime> + <propertySimple> + <id>10858</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10857</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10860</id> + <name>url</name> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10859</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10048</id> + <uuid>704a31f3-7f5f-46c1-9bda-70f2645c9604</uuid> + <resourceKey>${main.rhq4.resource.key}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635810</ctime> + <mtime>1309117635810</mtime> + <itime>1309117635810</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10245</id> + <version>0</version> + <ctime>1309117635811</ctime> + <mtime>1309117635811</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10246</id> + <version>0</version> + <ctime>1309117635811</ctime> + <mtime>1309117635811</mtime> + <propertySimple> + <id>10926</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10925</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10928</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10927</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10201</id> + <version>0</version> + <ctime>1309116183368</ctime> + <mtime>1309116183368</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10211</id> + <version>0</version> + <ctime>1309117523737</ctime> + <mtime>1309117523737</mtime> + <propertySimple> + <id>10863</id> + <name>errorLogIncludesPattern</name> + </propertySimple> + <propertySimple> + <id>10862</id> + <name>errorLogMinimumSeverity</name> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10861</id> + <name>augeasEnabled</name> + <stringValue>no</stringValue> + </propertySimple> + <propertySimple> + <id>10865</id> + <name>errorLogFilePath</name> + </propertySimple> + <propertySimple> + <id>10864</id> + <name>snmpAgentCommunity</name> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10867</id> + <name>snmpAgentHost</name> + <stringValue>${unresolvable.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10866</id> + <name>errorLogEventsEnabled</name> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10869</id> + <name>controlScriptPath</name> + </propertySimple> + <propertySimple> + <id>10868</id> + <name>url</name> + <stringValue>http://$%7Bservername%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10870</id> + <name>augeasModuleName</name> + <stringValue>Httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10871</id> + <name>configFile</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10872</id> + <name>configurationFilesInclusionPatterns</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10873</id> + <name>vhostFilesMask</name> + <stringValue>${server.root}/conf/*</stringValue> + </propertySimple> + <propertySimple> + <id>10874</id> + <name>executablePath</name> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10875</id> + <name>restartAfterConfigurationUpdate</name> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10876</id> + <name>snmpAgentPort</name> + <stringValue>1610</stringValue> + </propertySimple> + <propertySimple> + <id>10877</id> + <name>serverRoot</name> + <stringValue>${server.root}</stringValue> + </propertySimple> + <propertySimple> + <id>10878</id> + <name>vhostCreationPolicy</name> + <stringValue>vhost-per-file</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/nested/inventory-with-snmp.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/nested/inventory-with-snmp.xml new file mode 100644 index 0000000..89bfa5a --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/nested/inventory-with-snmp.xml @@ -0,0 +1,313 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10022</id> + <uuid>e61040b4-d645-44dc-a6b7-460d39f1b625</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost}:${port1}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1308835177519</ctime> + <mtime>1308835282077</mtime> + <itime>1308835282077</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10044</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10101</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10102</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10037</id> + <uuid>b2928cc6-30ab-47fe-8095-e1292887ac18</uuid> + <!-- this resource key is the correct one here. For some reason that I have not investigated but only + experimentally checked, the RHQ 3.0.0 codebase assigns the "MainServer" resource key in this scenario + even if the SNMP is enabled. --> + <resourceKey>${main.rhq4.resource.key}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + <itime>1308835287473</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10188</id> + <version>0</version> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10189</id> + <version>0</version> + <ctime>1308835287474</ctime> + <mtime>1308835287474</mtime> + <propertySimple> + <id>10806</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10805</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10808</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10807</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10038</id> + <uuid>fe8d389e-5a45-4bf2-9f73-0831caca63df</uuid> + <resourceKey>${vhost4.rhq3.resource.key}</resourceKey> + <name>${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <itime>1308835287481</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10190</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10191</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <propertySimple> + <id>10810</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10809</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10812</id> + <name>url</name> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10811</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10174</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10175</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + <propertySimple> + <id>10790</id> + <name>errorLogIncludesPattern</name> + </propertySimple> + <propertySimple> + <id>10783</id> + <name>errorLogMinimumSeverity</name> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>augeasEnabled</name> + <stringValue>no</stringValue> + </propertySimple> + <propertySimple> + <id>10789</id> + <name>errorLogFilePath</name> + </propertySimple> + <propertySimple> + <id>10786</id> + <name>snmpAgentCommunity</name> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10784</id> + <name>snmpAgentHost</name> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10782</id> + <name>errorLogEventsEnabled</name> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10793</id> + <name>controlScriptPath</name> + </propertySimple> + <propertySimple> + <id>10795</id> + <name>url</name> + <stringValue>http://$%7Blocalhost.ip%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10709</id> + <name>augeasModuleName</name> + <stringValue>Httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10794</id> + <name>configFile</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10710</id> + <name>configurationFilesInclusionPatterns</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10788</id> + <name>vhostFilesMask</name> + <stringValue>${server.root}/conf/*</stringValue> + </propertySimple> + <propertySimple> + <id>10787</id> + <name>restartAfterConfigurationUpdate</name> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10792</id> + <name>executablePath</name> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10785</id> + <name>snmpAgentPort</name> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10781</id> + <name>vhostCreationPolicy</name> + <stringValue>vhost-per-file</stringValue> + </propertySimple> + <propertySimple> + <id>10791</id> + <name>serverRoot</name> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/nested/inventory-without-snmp.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/nested/inventory-without-snmp.xml new file mode 100644 index 0000000..b054c63 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/nested/inventory-without-snmp.xml @@ -0,0 +1,310 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10041</id> + <uuid>02f44194-9bb8-44ef-9866-ef7b69eedc0a</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost}:${port1}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>true</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1309116183350</ctime> + <mtime>1309116225316</mtime> + <itime>1309116225316</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10044</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10101</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10102</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10046</id> + <uuid>908ea047-889e-4978-a61f-d96e8b1c6d17</uuid> + <resourceKey>${vhost4.rhq4.resource.key}</resourceKey> + <name>${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635789</ctime> + <mtime>1309117635789</mtime> + <itime>1309117635788</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10241</id> + <version>0</version> + <ctime>1309117635789</ctime> + <mtime>1309117635789</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10242</id> + <version>0</version> + <ctime>1309117635790</ctime> + <mtime>1309117635790</mtime> + <propertySimple> + <id>10858</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10857</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10860</id> + <name>url</name> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10859</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10048</id> + <uuid>704a31f3-7f5f-46c1-9bda-70f2645c9604</uuid> + <resourceKey>${main.rhq4.resource.key}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635810</ctime> + <mtime>1309117635810</mtime> + <itime>1309117635810</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10245</id> + <version>0</version> + <ctime>1309117635811</ctime> + <mtime>1309117635811</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10246</id> + <version>0</version> + <ctime>1309117635811</ctime> + <mtime>1309117635811</mtime> + <propertySimple> + <id>10926</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10925</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10928</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10927</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10201</id> + <version>0</version> + <ctime>1309116183368</ctime> + <mtime>1309116183368</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10211</id> + <version>0</version> + <ctime>1309117523737</ctime> + <mtime>1309117523737</mtime> + <propertySimple> + <id>10863</id> + <name>errorLogIncludesPattern</name> + </propertySimple> + <propertySimple> + <id>10862</id> + <name>errorLogMinimumSeverity</name> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10861</id> + <name>augeasEnabled</name> + <stringValue>no</stringValue> + </propertySimple> + <propertySimple> + <id>10865</id> + <name>errorLogFilePath</name> + </propertySimple> + <propertySimple> + <id>10864</id> + <name>snmpAgentCommunity</name> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10867</id> + <name>snmpAgentHost</name> + <stringValue>${unresolvable.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10866</id> + <name>errorLogEventsEnabled</name> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10869</id> + <name>controlScriptPath</name> + </propertySimple> + <propertySimple> + <id>10868</id> + <name>url</name> + <stringValue>http://$%7Bservername%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10870</id> + <name>augeasModuleName</name> + <stringValue>Httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10871</id> + <name>configFile</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10872</id> + <name>configurationFilesInclusionPatterns</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10873</id> + <name>vhostFilesMask</name> + <stringValue>${server.root}/conf/*</stringValue> + </propertySimple> + <propertySimple> + <id>10874</id> + <name>executablePath</name> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10875</id> + <name>restartAfterConfigurationUpdate</name> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10876</id> + <name>snmpAgentPort</name> + <stringValue>1610</stringValue> + </propertySimple> + <propertySimple> + <id>10877</id> + <name>serverRoot</name> + <stringValue>${server.root}</stringValue> + </propertySimple> + <propertySimple> + <id>10878</id> + <name>vhostCreationPolicy</name> + <stringValue>vhost-per-file</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml index ff9d715..8b3e0ff 100644 --- a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml @@ -398,7 +398,7 @@ <propertySimple> <id>10795</id> <name>url</name> - <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + <stringValue>http://$%7Blocalhost.ip%7D:$%7Bport1%7D/</stringValue> </propertySimple> <propertySimple> <id>10709</id> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/includes/inventory-with-snmp.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/includes/inventory-with-snmp.xml index ff9d715..8b3e0ff 100644 --- a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/includes/inventory-with-snmp.xml +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/includes/inventory-with-snmp.xml @@ -398,7 +398,7 @@ <propertySimple> <id>10795</id> <name>url</name> - <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + <stringValue>http://$%7Blocalhost.ip%7D:$%7Bport1%7D/</stringValue> </propertySimple> <propertySimple> <id>10709</id> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/mess/inventory-with-duplicate-main.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/mess/inventory-with-duplicate-main.xml new file mode 100644 index 0000000..19e4531 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/mess/inventory-with-duplicate-main.xml @@ -0,0 +1,386 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10022</id> + <uuid>e61040b4-d645-44dc-a6b7-460d39f1b625</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost}:${port1}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1308835177519</ctime> + <mtime>1308835282077</mtime> + <itime>1308835282077</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10044</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10101</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10102</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10037</id> + <uuid>b2928cc6-30ab-47fe-8095-e1292887ac18</uuid> + <resourceKey>${main.rhq3.resource.key}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + <itime>1308835287473</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10188</id> + <version>0</version> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10189</id> + <version>0</version> + <ctime>1308835287474</ctime> + <mtime>1308835287474</mtime> + <propertySimple> + <id>10806</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10805</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10808</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10807</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>100371</id> + <uuid>b2928cc6-30ab-47fe-8095-e1292887ac90</uuid> + <resourceKey>${snmp.identifier}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + <itime>1308835287473</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10188</id> + <version>0</version> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10189</id> + <version>0</version> + <ctime>1308835287474</ctime> + <mtime>1308835287474</mtime> + <propertySimple> + <id>10806</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10805</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10808</id> + <name>url</name> + <stringValue>http://$%7Blocalhost.ip%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10807</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10038</id> + <uuid>fe8d389e-5a45-4bf2-9f73-0831caca63df</uuid> + <resourceKey>${vhost4.rhq3.resource.key}</resourceKey> + <name>${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <itime>1308835287481</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10190</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10191</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <propertySimple> + <id>10810</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10809</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10812</id> + <name>url</name> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10811</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10174</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10175</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + <propertySimple> + <id>10790</id> + <name>errorLogIncludesPattern</name> + </propertySimple> + <propertySimple> + <id>10783</id> + <name>errorLogMinimumSeverity</name> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>augeasEnabled</name> + <stringValue>no</stringValue> + </propertySimple> + <propertySimple> + <id>10789</id> + <name>errorLogFilePath</name> + </propertySimple> + <propertySimple> + <id>10786</id> + <name>snmpAgentCommunity</name> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10784</id> + <name>snmpAgentHost</name> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10782</id> + <name>errorLogEventsEnabled</name> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10793</id> + <name>controlScriptPath</name> + </propertySimple> + <propertySimple> + <id>10795</id> + <name>url</name> + <stringValue>http://$%7Blocalhost.ip%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10709</id> + <name>augeasModuleName</name> + <stringValue>Httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10794</id> + <name>configFile</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10710</id> + <name>configurationFilesInclusionPatterns</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10788</id> + <name>vhostFilesMask</name> + <stringValue>${server.root}/conf/*</stringValue> + </propertySimple> + <propertySimple> + <id>10787</id> + <name>restartAfterConfigurationUpdate</name> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10792</id> + <name>executablePath</name> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10785</id> + <name>snmpAgentPort</name> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10781</id> + <name>vhostCreationPolicy</name> + <stringValue>vhost-per-file</stringValue> + </propertySimple> + <propertySimple> + <id>10791</id> + <name>serverRoot</name> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/mess/inventory-with-snmp-anyaddr.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/mess/inventory-with-snmp-anyaddr.xml new file mode 100644 index 0000000..2a09b04 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/mess/inventory-with-snmp-anyaddr.xml @@ -0,0 +1,310 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10022</id> + <uuid>e61040b4-d645-44dc-a6b7-460d39f1b625</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost}:${port1}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1308835177519</ctime> + <mtime>1308835282077</mtime> + <itime>1308835282077</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10044</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10101</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10102</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>20037</id> + <uuid>b2928cc6-30ab-47fe-8095-e1292887ac18</uuid> + <resourceKey>0.0.0.0:${port1}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + <itime>1308835287473</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10188</id> + <version>0</version> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10189</id> + <version>0</version> + <ctime>1308835287474</ctime> + <mtime>1308835287474</mtime> + <propertySimple> + <id>10806</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10805</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10808</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10807</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10038</id> + <uuid>fe8d389e-5a45-4bf2-9f73-0831caca63df</uuid> + <resourceKey>${vhost4.rhq3.resource.key}</resourceKey> + <name>${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <itime>1308835287481</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10190</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10191</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <propertySimple> + <id>10810</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10809</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10812</id> + <name>url</name> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10811</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10174</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10175</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + <propertySimple> + <id>10790</id> + <name>errorLogIncludesPattern</name> + </propertySimple> + <propertySimple> + <id>10783</id> + <name>errorLogMinimumSeverity</name> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>augeasEnabled</name> + <stringValue>no</stringValue> + </propertySimple> + <propertySimple> + <id>10789</id> + <name>errorLogFilePath</name> + </propertySimple> + <propertySimple> + <id>10786</id> + <name>snmpAgentCommunity</name> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10784</id> + <name>snmpAgentHost</name> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10782</id> + <name>errorLogEventsEnabled</name> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10793</id> + <name>controlScriptPath</name> + </propertySimple> + <propertySimple> + <id>10795</id> + <name>url</name> + <stringValue>http://0.0.0.0:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10709</id> + <name>augeasModuleName</name> + <stringValue>Httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10794</id> + <name>configFile</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10710</id> + <name>configurationFilesInclusionPatterns</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10788</id> + <name>vhostFilesMask</name> + <stringValue>${server.root}/conf/*</stringValue> + </propertySimple> + <propertySimple> + <id>10787</id> + <name>restartAfterConfigurationUpdate</name> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10792</id> + <name>executablePath</name> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10785</id> + <name>snmpAgentPort</name> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10781</id> + <name>vhostCreationPolicy</name> + <stringValue>vhost-per-file</stringValue> + </propertySimple> + <propertySimple> + <id>10791</id> + <name>serverRoot</name> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/mess/inventory-with-snmp.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/mess/inventory-with-snmp.xml new file mode 100644 index 0000000..95f21d0 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/mess/inventory-with-snmp.xml @@ -0,0 +1,310 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10022</id> + <uuid>e61040b4-d645-44dc-a6b7-460d39f1b625</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost}:${port1}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1308835177519</ctime> + <mtime>1308835282077</mtime> + <itime>1308835282077</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10044</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10101</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10102</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10037</id> + <uuid>b2928cc6-30ab-47fe-8095-e1292887ac18</uuid> + <resourceKey>${main.rhq3.resource.key}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + <itime>1308835287473</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10188</id> + <version>0</version> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10189</id> + <version>0</version> + <ctime>1308835287474</ctime> + <mtime>1308835287474</mtime> + <propertySimple> + <id>10806</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10805</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10808</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10807</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10038</id> + <uuid>fe8d389e-5a45-4bf2-9f73-0831caca63df</uuid> + <resourceKey>${vhost4.rhq3.resource.key}</resourceKey> + <name>${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <itime>1308835287481</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10190</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10191</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <propertySimple> + <id>10810</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10809</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10812</id> + <name>url</name> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10811</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10174</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10175</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + <propertySimple> + <id>10790</id> + <name>errorLogIncludesPattern</name> + </propertySimple> + <propertySimple> + <id>10783</id> + <name>errorLogMinimumSeverity</name> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>augeasEnabled</name> + <stringValue>no</stringValue> + </propertySimple> + <propertySimple> + <id>10789</id> + <name>errorLogFilePath</name> + </propertySimple> + <propertySimple> + <id>10786</id> + <name>snmpAgentCommunity</name> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10784</id> + <name>snmpAgentHost</name> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10782</id> + <name>errorLogEventsEnabled</name> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10793</id> + <name>controlScriptPath</name> + </propertySimple> + <propertySimple> + <id>10795</id> + <name>url</name> + <stringValue>http://$%7Blocalhost.ip%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10709</id> + <name>augeasModuleName</name> + <stringValue>Httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10794</id> + <name>configFile</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10710</id> + <name>configurationFilesInclusionPatterns</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10788</id> + <name>vhostFilesMask</name> + <stringValue>${server.root}/conf/*</stringValue> + </propertySimple> + <propertySimple> + <id>10787</id> + <name>restartAfterConfigurationUpdate</name> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10792</id> + <name>executablePath</name> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10785</id> + <name>snmpAgentPort</name> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10781</id> + <name>vhostCreationPolicy</name> + <stringValue>vhost-per-file</stringValue> + </propertySimple> + <propertySimple> + <id>10791</id> + <name>serverRoot</name> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/mess/inventory-without-snmp.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/mess/inventory-without-snmp.xml new file mode 100644 index 0000000..b3d2dea --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/mess/inventory-without-snmp.xml @@ -0,0 +1,310 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10041</id> + <uuid>02f44194-9bb8-44ef-9866-ef7b69eedc0a</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost}:${port1}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>true</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1309116183350</ctime> + <mtime>1309116225316</mtime> + <itime>1309116225316</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10044</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10101</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10102</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10046</id> + <uuid>908ea047-889e-4978-a61f-d96e8b1c6d17</uuid> + <resourceKey>${vhost4.rhq3.resource.key}</resourceKey> + <name>${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635789</ctime> + <mtime>1309117635789</mtime> + <itime>1309117635788</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10241</id> + <version>0</version> + <ctime>1309117635789</ctime> + <mtime>1309117635789</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10242</id> + <version>0</version> + <ctime>1309117635790</ctime> + <mtime>1309117635790</mtime> + <propertySimple> + <id>10858</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10857</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10860</id> + <name>url</name> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10859</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10048</id> + <uuid>704a31f3-7f5f-46c1-9bda-70f2645c9604</uuid> + <resourceKey>${main.rhq3.resource.key}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635810</ctime> + <mtime>1309117635810</mtime> + <itime>1309117635810</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10245</id> + <version>0</version> + <ctime>1309117635811</ctime> + <mtime>1309117635811</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10246</id> + <version>0</version> + <ctime>1309117635811</ctime> + <mtime>1309117635811</mtime> + <propertySimple> + <id>10926</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10925</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10928</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10927</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10201</id> + <version>0</version> + <ctime>1309116183368</ctime> + <mtime>1309116183368</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10211</id> + <version>0</version> + <ctime>1309117523737</ctime> + <mtime>1309117523737</mtime> + <propertySimple> + <id>10863</id> + <name>errorLogIncludesPattern</name> + </propertySimple> + <propertySimple> + <id>10862</id> + <name>errorLogMinimumSeverity</name> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10861</id> + <name>augeasEnabled</name> + <stringValue>no</stringValue> + </propertySimple> + <propertySimple> + <id>10865</id> + <name>errorLogFilePath</name> + </propertySimple> + <propertySimple> + <id>10864</id> + <name>snmpAgentCommunity</name> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10867</id> + <name>snmpAgentHost</name> + <stringValue>${unresolvable.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10866</id> + <name>errorLogEventsEnabled</name> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10869</id> + <name>controlScriptPath</name> + </propertySimple> + <propertySimple> + <id>10868</id> + <name>url</name> + <stringValue>http://$%7Bservername%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10870</id> + <name>augeasModuleName</name> + <stringValue>Httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10871</id> + <name>configFile</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10872</id> + <name>configurationFilesInclusionPatterns</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10873</id> + <name>vhostFilesMask</name> + <stringValue>${server.root}/conf/*</stringValue> + </propertySimple> + <propertySimple> + <id>10874</id> + <name>executablePath</name> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10875</id> + <name>restartAfterConfigurationUpdate</name> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10876</id> + <name>snmpAgentPort</name> + <stringValue>1610</stringValue> + </propertySimple> + <propertySimple> + <id>10877</id> + <name>serverRoot</name> + <stringValue>${server.root}</stringValue> + </propertySimple> + <propertySimple> + <id>10878</id> + <name>vhostCreationPolicy</name> + <stringValue>vhost-per-file</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/nested/inventory-with-duplicate-main.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/nested/inventory-with-duplicate-main.xml new file mode 100644 index 0000000..19e4531 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/nested/inventory-with-duplicate-main.xml @@ -0,0 +1,386 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10022</id> + <uuid>e61040b4-d645-44dc-a6b7-460d39f1b625</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost}:${port1}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1308835177519</ctime> + <mtime>1308835282077</mtime> + <itime>1308835282077</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10044</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10101</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10102</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10037</id> + <uuid>b2928cc6-30ab-47fe-8095-e1292887ac18</uuid> + <resourceKey>${main.rhq3.resource.key}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + <itime>1308835287473</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10188</id> + <version>0</version> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10189</id> + <version>0</version> + <ctime>1308835287474</ctime> + <mtime>1308835287474</mtime> + <propertySimple> + <id>10806</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10805</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10808</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10807</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>100371</id> + <uuid>b2928cc6-30ab-47fe-8095-e1292887ac90</uuid> + <resourceKey>${snmp.identifier}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + <itime>1308835287473</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10188</id> + <version>0</version> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10189</id> + <version>0</version> + <ctime>1308835287474</ctime> + <mtime>1308835287474</mtime> + <propertySimple> + <id>10806</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10805</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10808</id> + <name>url</name> + <stringValue>http://$%7Blocalhost.ip%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10807</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10038</id> + <uuid>fe8d389e-5a45-4bf2-9f73-0831caca63df</uuid> + <resourceKey>${vhost4.rhq3.resource.key}</resourceKey> + <name>${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <itime>1308835287481</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10190</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10191</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <propertySimple> + <id>10810</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10809</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10812</id> + <name>url</name> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10811</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10174</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10175</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + <propertySimple> + <id>10790</id> + <name>errorLogIncludesPattern</name> + </propertySimple> + <propertySimple> + <id>10783</id> + <name>errorLogMinimumSeverity</name> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>augeasEnabled</name> + <stringValue>no</stringValue> + </propertySimple> + <propertySimple> + <id>10789</id> + <name>errorLogFilePath</name> + </propertySimple> + <propertySimple> + <id>10786</id> + <name>snmpAgentCommunity</name> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10784</id> + <name>snmpAgentHost</name> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10782</id> + <name>errorLogEventsEnabled</name> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10793</id> + <name>controlScriptPath</name> + </propertySimple> + <propertySimple> + <id>10795</id> + <name>url</name> + <stringValue>http://$%7Blocalhost.ip%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10709</id> + <name>augeasModuleName</name> + <stringValue>Httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10794</id> + <name>configFile</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10710</id> + <name>configurationFilesInclusionPatterns</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10788</id> + <name>vhostFilesMask</name> + <stringValue>${server.root}/conf/*</stringValue> + </propertySimple> + <propertySimple> + <id>10787</id> + <name>restartAfterConfigurationUpdate</name> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10792</id> + <name>executablePath</name> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10785</id> + <name>snmpAgentPort</name> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10781</id> + <name>vhostCreationPolicy</name> + <stringValue>vhost-per-file</stringValue> + </propertySimple> + <propertySimple> + <id>10791</id> + <name>serverRoot</name> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/nested/inventory-with-snmp-anyaddr.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/nested/inventory-with-snmp-anyaddr.xml new file mode 100644 index 0000000..2a09b04 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/nested/inventory-with-snmp-anyaddr.xml @@ -0,0 +1,310 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10022</id> + <uuid>e61040b4-d645-44dc-a6b7-460d39f1b625</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost}:${port1}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1308835177519</ctime> + <mtime>1308835282077</mtime> + <itime>1308835282077</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10044</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10101</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10102</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>20037</id> + <uuid>b2928cc6-30ab-47fe-8095-e1292887ac18</uuid> + <resourceKey>0.0.0.0:${port1}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + <itime>1308835287473</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10188</id> + <version>0</version> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10189</id> + <version>0</version> + <ctime>1308835287474</ctime> + <mtime>1308835287474</mtime> + <propertySimple> + <id>10806</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10805</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10808</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10807</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10038</id> + <uuid>fe8d389e-5a45-4bf2-9f73-0831caca63df</uuid> + <resourceKey>${vhost4.rhq3.resource.key}</resourceKey> + <name>${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <itime>1308835287481</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10190</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10191</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <propertySimple> + <id>10810</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10809</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10812</id> + <name>url</name> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10811</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10174</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10175</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + <propertySimple> + <id>10790</id> + <name>errorLogIncludesPattern</name> + </propertySimple> + <propertySimple> + <id>10783</id> + <name>errorLogMinimumSeverity</name> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>augeasEnabled</name> + <stringValue>no</stringValue> + </propertySimple> + <propertySimple> + <id>10789</id> + <name>errorLogFilePath</name> + </propertySimple> + <propertySimple> + <id>10786</id> + <name>snmpAgentCommunity</name> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10784</id> + <name>snmpAgentHost</name> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10782</id> + <name>errorLogEventsEnabled</name> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10793</id> + <name>controlScriptPath</name> + </propertySimple> + <propertySimple> + <id>10795</id> + <name>url</name> + <stringValue>http://0.0.0.0:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10709</id> + <name>augeasModuleName</name> + <stringValue>Httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10794</id> + <name>configFile</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10710</id> + <name>configurationFilesInclusionPatterns</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10788</id> + <name>vhostFilesMask</name> + <stringValue>${server.root}/conf/*</stringValue> + </propertySimple> + <propertySimple> + <id>10787</id> + <name>restartAfterConfigurationUpdate</name> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10792</id> + <name>executablePath</name> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10785</id> + <name>snmpAgentPort</name> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10781</id> + <name>vhostCreationPolicy</name> + <stringValue>vhost-per-file</stringValue> + </propertySimple> + <propertySimple> + <id>10791</id> + <name>serverRoot</name> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/nested/inventory-with-snmp.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/nested/inventory-with-snmp.xml new file mode 100644 index 0000000..95f21d0 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/nested/inventory-with-snmp.xml @@ -0,0 +1,310 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10022</id> + <uuid>e61040b4-d645-44dc-a6b7-460d39f1b625</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost}:${port1}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1308835177519</ctime> + <mtime>1308835282077</mtime> + <itime>1308835282077</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10044</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10101</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10102</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10037</id> + <uuid>b2928cc6-30ab-47fe-8095-e1292887ac18</uuid> + <resourceKey>${main.rhq3.resource.key}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + <itime>1308835287473</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10188</id> + <version>0</version> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10189</id> + <version>0</version> + <ctime>1308835287474</ctime> + <mtime>1308835287474</mtime> + <propertySimple> + <id>10806</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10805</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10808</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10807</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10038</id> + <uuid>fe8d389e-5a45-4bf2-9f73-0831caca63df</uuid> + <resourceKey>${vhost4.rhq3.resource.key}</resourceKey> + <name>${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <itime>1308835287481</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10190</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10191</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <propertySimple> + <id>10810</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10809</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10812</id> + <name>url</name> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10811</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10174</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10175</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + <propertySimple> + <id>10790</id> + <name>errorLogIncludesPattern</name> + </propertySimple> + <propertySimple> + <id>10783</id> + <name>errorLogMinimumSeverity</name> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>augeasEnabled</name> + <stringValue>no</stringValue> + </propertySimple> + <propertySimple> + <id>10789</id> + <name>errorLogFilePath</name> + </propertySimple> + <propertySimple> + <id>10786</id> + <name>snmpAgentCommunity</name> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10784</id> + <name>snmpAgentHost</name> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10782</id> + <name>errorLogEventsEnabled</name> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10793</id> + <name>controlScriptPath</name> + </propertySimple> + <propertySimple> + <id>10795</id> + <name>url</name> + <stringValue>http://$%7Blocalhost.ip%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10709</id> + <name>augeasModuleName</name> + <stringValue>Httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10794</id> + <name>configFile</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10710</id> + <name>configurationFilesInclusionPatterns</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10788</id> + <name>vhostFilesMask</name> + <stringValue>${server.root}/conf/*</stringValue> + </propertySimple> + <propertySimple> + <id>10787</id> + <name>restartAfterConfigurationUpdate</name> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10792</id> + <name>executablePath</name> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10785</id> + <name>snmpAgentPort</name> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10781</id> + <name>vhostCreationPolicy</name> + <stringValue>vhost-per-file</stringValue> + </propertySimple> + <propertySimple> + <id>10791</id> + <name>serverRoot</name> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/nested/inventory-without-snmp.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/nested/inventory-without-snmp.xml new file mode 100644 index 0000000..b3d2dea --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/nested/inventory-without-snmp.xml @@ -0,0 +1,310 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10041</id> + <uuid>02f44194-9bb8-44ef-9866-ef7b69eedc0a</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost}:${port1}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>true</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1309116183350</ctime> + <mtime>1309116225316</mtime> + <itime>1309116225316</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10044</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10101</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10102</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10046</id> + <uuid>908ea047-889e-4978-a61f-d96e8b1c6d17</uuid> + <resourceKey>${vhost4.rhq3.resource.key}</resourceKey> + <name>${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635789</ctime> + <mtime>1309117635789</mtime> + <itime>1309117635788</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10241</id> + <version>0</version> + <ctime>1309117635789</ctime> + <mtime>1309117635789</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10242</id> + <version>0</version> + <ctime>1309117635790</ctime> + <mtime>1309117635790</mtime> + <propertySimple> + <id>10858</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10857</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10860</id> + <name>url</name> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10859</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10048</id> + <uuid>704a31f3-7f5f-46c1-9bda-70f2645c9604</uuid> + <resourceKey>${main.rhq3.resource.key}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635810</ctime> + <mtime>1309117635810</mtime> + <itime>1309117635810</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10245</id> + <version>0</version> + <ctime>1309117635811</ctime> + <mtime>1309117635811</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10246</id> + <version>0</version> + <ctime>1309117635811</ctime> + <mtime>1309117635811</mtime> + <propertySimple> + <id>10926</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10925</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10928</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10927</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10201</id> + <version>0</version> + <ctime>1309116183368</ctime> + <mtime>1309116183368</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10211</id> + <version>0</version> + <ctime>1309117523737</ctime> + <mtime>1309117523737</mtime> + <propertySimple> + <id>10863</id> + <name>errorLogIncludesPattern</name> + </propertySimple> + <propertySimple> + <id>10862</id> + <name>errorLogMinimumSeverity</name> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10861</id> + <name>augeasEnabled</name> + <stringValue>no</stringValue> + </propertySimple> + <propertySimple> + <id>10865</id> + <name>errorLogFilePath</name> + </propertySimple> + <propertySimple> + <id>10864</id> + <name>snmpAgentCommunity</name> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10867</id> + <name>snmpAgentHost</name> + <stringValue>${unresolvable.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10866</id> + <name>errorLogEventsEnabled</name> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10869</id> + <name>controlScriptPath</name> + </propertySimple> + <propertySimple> + <id>10868</id> + <name>url</name> + <stringValue>http://$%7Bservername%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10870</id> + <name>augeasModuleName</name> + <stringValue>Httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10871</id> + <name>configFile</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10872</id> + <name>configurationFilesInclusionPatterns</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10873</id> + <name>vhostFilesMask</name> + <stringValue>${server.root}/conf/*</stringValue> + </propertySimple> + <propertySimple> + <id>10874</id> + <name>executablePath</name> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10875</id> + <name>restartAfterConfigurationUpdate</name> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10876</id> + <name>snmpAgentPort</name> + <stringValue>1610</stringValue> + </propertySimple> + <propertySimple> + <id>10877</id> + <name>serverRoot</name> + <stringValue>${server.root}</stringValue> + </propertySimple> + <propertySimple> + <id>10878</id> + <name>vhostCreationPolicy</name> + <stringValue>vhost-per-file</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml index ff9d715..8b3e0ff 100644 --- a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml @@ -398,7 +398,7 @@ <propertySimple> <id>10795</id> <name>url</name> - <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + <stringValue>http://$%7Blocalhost.ip%7D:$%7Bport1%7D/</stringValue> </propertySimple> <propertySimple> <id>10709</id> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/includes/inventory-single-vhost.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/includes/inventory-single-vhost.xml new file mode 100644 index 0000000..00ac425 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/includes/inventory-single-vhost.xml @@ -0,0 +1,215 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10004</id> + <uuid>ae8a7a3e-256e-4c0a-9a65-33d534523d92</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost} Apache 2.2.17 (${server.root}/)</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>true</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1307353451273</ctime> + <mtime>1307353509168</mtime> + <itime>1307353509168</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10013</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10012</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10022</id> + <uuid>08290193-c716-4363-b841-8a1d9d83f580</uuid> + <resourceKey>${snmp.identifier}</resourceKey> + <name>Virtual Host ${snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587727</ctime> + <mtime>1307353587727</mtime> + <itime>1307353587721</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10137</id> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10138</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + <propertySimple> + <id>10690</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10689</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/${localhost}0_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10692</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Blocalhost%7D:0/</stringValue> + </propertySimple> + <propertySimple> + <id>10693</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>1</stringValue> + </propertySimple> + <propertySimple> + <id>10691</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>DOWN</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10142</id> + <version>0</version> + <ctime>1307353451273</ctime> + <mtime>1307353451273</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10073</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353737118</ctime> + <mtime>1307353737118</mtime> + <propertySimple> + <id>10365</id> + <name>errorLogMinimumSeverity</name> + <override>false</override> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10366</id> + <name>errorLogIncludesPattern</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10367</id> + <name>snmpAgentCommunity</name> + <override>false</override> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10368</id> + <name>errorLogFilePath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10369</id> + <name>errorLogEventsEnabled</name> + <override>false</override> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10370</id> + <name>snmpAgentHost</name> + <override>false</override> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10713</id> + <name>controlScriptPath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10714</id> + <name>url</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10364</id> + <name>configFile</name> + <override>false</override> + <stringValue>conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10711</id> + <name>executablePath</name> + <override>false</override> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10712</id> + <name>snmpAgentPort</name> + <override>false</override> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10715</id> + <name>serverRoot</name> + <override>false</override> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10003</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/mess/inventory-single-vhost.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/mess/inventory-single-vhost.xml new file mode 100644 index 0000000..00ac425 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/mess/inventory-single-vhost.xml @@ -0,0 +1,215 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10004</id> + <uuid>ae8a7a3e-256e-4c0a-9a65-33d534523d92</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost} Apache 2.2.17 (${server.root}/)</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>true</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1307353451273</ctime> + <mtime>1307353509168</mtime> + <itime>1307353509168</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10013</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10012</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10022</id> + <uuid>08290193-c716-4363-b841-8a1d9d83f580</uuid> + <resourceKey>${snmp.identifier}</resourceKey> + <name>Virtual Host ${snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587727</ctime> + <mtime>1307353587727</mtime> + <itime>1307353587721</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10137</id> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10138</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + <propertySimple> + <id>10690</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10689</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/${localhost}0_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10692</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Blocalhost%7D:0/</stringValue> + </propertySimple> + <propertySimple> + <id>10693</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>1</stringValue> + </propertySimple> + <propertySimple> + <id>10691</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>DOWN</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10142</id> + <version>0</version> + <ctime>1307353451273</ctime> + <mtime>1307353451273</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10073</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353737118</ctime> + <mtime>1307353737118</mtime> + <propertySimple> + <id>10365</id> + <name>errorLogMinimumSeverity</name> + <override>false</override> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10366</id> + <name>errorLogIncludesPattern</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10367</id> + <name>snmpAgentCommunity</name> + <override>false</override> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10368</id> + <name>errorLogFilePath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10369</id> + <name>errorLogEventsEnabled</name> + <override>false</override> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10370</id> + <name>snmpAgentHost</name> + <override>false</override> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10713</id> + <name>controlScriptPath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10714</id> + <name>url</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10364</id> + <name>configFile</name> + <override>false</override> + <stringValue>conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10711</id> + <name>executablePath</name> + <override>false</override> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10712</id> + <name>snmpAgentPort</name> + <override>false</override> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10715</id> + <name>serverRoot</name> + <override>false</override> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10003</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/mess/inventory.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/mess/inventory.xml new file mode 100644 index 0000000..b6a4bc9 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/mess/inventory.xml @@ -0,0 +1,377 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10004</id> + <uuid>ae8a7a3e-256e-4c0a-9a65-33d534523d92</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost} Apache 2.2.17 (${server.root}/)</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>true</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1307353451273</ctime> + <mtime>1307353509168</mtime> + <itime>1307353509168</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10013</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10012</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10022</id> + <uuid>08290193-c716-4363-b841-8a1d9d83f580</uuid> + <resourceKey>${snmp.identifier}</resourceKey> + <name>Virtual Host ${snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587727</ctime> + <mtime>1307353587727</mtime> + <itime>1307353587721</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10137</id> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10138</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + <propertySimple> + <id>10690</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10689</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/${localhost}0_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10692</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Blocalhost%7D:0/</stringValue> + </propertySimple> + <propertySimple> + <id>10693</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>1</stringValue> + </propertySimple> + <propertySimple> + <id>10691</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>DOWN</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10021</id> + <uuid>3a20d809-7eba-422c-a3ef-baf65804498d</uuid> + <resourceKey>${vhost2.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost2.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587648</ctime> + <mtime>1307353587648</mtime> + <itime>1307353587648</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10135</id> + <version>0</version> + <ctime>1307353587666</ctime> + <mtime>1307353587666</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10136</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587667</ctime> + <mtime>1307353587667</mtime> + <propertySimple> + <id>10685</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10684</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111676_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10687</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost2.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10688</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>4</stringValue> + </propertySimple> + <propertySimple> + <id>10686</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10025</id> + <uuid>310281d2-60c6-4d7d-bcdc-c51d7969c906</uuid> + <resourceKey>${vhost4.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + <itime>1307353587760</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10173</id> + <version>0</version> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10174</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + <propertySimple> + <id>10705</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10704</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10707</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>2</stringValue> + </propertySimple> + <propertySimple> + <id>10706</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10142</id> + <version>0</version> + <ctime>1307353451273</ctime> + <mtime>1307353451273</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10073</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353737118</ctime> + <mtime>1307353737118</mtime> + <propertySimple> + <id>10365</id> + <name>errorLogMinimumSeverity</name> + <override>false</override> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10366</id> + <name>errorLogIncludesPattern</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10367</id> + <name>snmpAgentCommunity</name> + <override>false</override> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10368</id> + <name>errorLogFilePath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10369</id> + <name>errorLogEventsEnabled</name> + <override>false</override> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10370</id> + <name>snmpAgentHost</name> + <override>false</override> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10713</id> + <name>controlScriptPath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10714</id> + <name>url</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10364</id> + <name>configFile</name> + <override>false</override> + <stringValue>conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10711</id> + <name>executablePath</name> + <override>false</override> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10712</id> + <name>snmpAgentPort</name> + <override>false</override> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10715</id> + <name>serverRoot</name> + <override>false</override> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10003</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/nested/inventory-single-vhost.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/nested/inventory-single-vhost.xml new file mode 100644 index 0000000..00ac425 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/nested/inventory-single-vhost.xml @@ -0,0 +1,215 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10004</id> + <uuid>ae8a7a3e-256e-4c0a-9a65-33d534523d92</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost} Apache 2.2.17 (${server.root}/)</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>true</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1307353451273</ctime> + <mtime>1307353509168</mtime> + <itime>1307353509168</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10013</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10012</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10022</id> + <uuid>08290193-c716-4363-b841-8a1d9d83f580</uuid> + <resourceKey>${snmp.identifier}</resourceKey> + <name>Virtual Host ${snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587727</ctime> + <mtime>1307353587727</mtime> + <itime>1307353587721</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10137</id> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10138</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + <propertySimple> + <id>10690</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10689</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/${localhost}0_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10692</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Blocalhost%7D:0/</stringValue> + </propertySimple> + <propertySimple> + <id>10693</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>1</stringValue> + </propertySimple> + <propertySimple> + <id>10691</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>DOWN</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10142</id> + <version>0</version> + <ctime>1307353451273</ctime> + <mtime>1307353451273</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10073</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353737118</ctime> + <mtime>1307353737118</mtime> + <propertySimple> + <id>10365</id> + <name>errorLogMinimumSeverity</name> + <override>false</override> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10366</id> + <name>errorLogIncludesPattern</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10367</id> + <name>snmpAgentCommunity</name> + <override>false</override> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10368</id> + <name>errorLogFilePath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10369</id> + <name>errorLogEventsEnabled</name> + <override>false</override> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10370</id> + <name>snmpAgentHost</name> + <override>false</override> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10713</id> + <name>controlScriptPath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10714</id> + <name>url</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10364</id> + <name>configFile</name> + <override>false</override> + <stringValue>conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10711</id> + <name>executablePath</name> + <override>false</override> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10712</id> + <name>snmpAgentPort</name> + <override>false</override> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10715</id> + <name>serverRoot</name> + <override>false</override> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10003</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/nested/inventory.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/nested/inventory.xml new file mode 100644 index 0000000..b6a4bc9 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/nested/inventory.xml @@ -0,0 +1,377 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10004</id> + <uuid>ae8a7a3e-256e-4c0a-9a65-33d534523d92</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost} Apache 2.2.17 (${server.root}/)</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>true</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1307353451273</ctime> + <mtime>1307353509168</mtime> + <itime>1307353509168</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10013</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10012</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10022</id> + <uuid>08290193-c716-4363-b841-8a1d9d83f580</uuid> + <resourceKey>${snmp.identifier}</resourceKey> + <name>Virtual Host ${snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587727</ctime> + <mtime>1307353587727</mtime> + <itime>1307353587721</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10137</id> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10138</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + <propertySimple> + <id>10690</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10689</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/${localhost}0_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10692</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Blocalhost%7D:0/</stringValue> + </propertySimple> + <propertySimple> + <id>10693</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>1</stringValue> + </propertySimple> + <propertySimple> + <id>10691</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>DOWN</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10021</id> + <uuid>3a20d809-7eba-422c-a3ef-baf65804498d</uuid> + <resourceKey>${vhost2.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost2.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587648</ctime> + <mtime>1307353587648</mtime> + <itime>1307353587648</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10135</id> + <version>0</version> + <ctime>1307353587666</ctime> + <mtime>1307353587666</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10136</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587667</ctime> + <mtime>1307353587667</mtime> + <propertySimple> + <id>10685</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10684</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111676_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10687</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost2.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10688</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>4</stringValue> + </propertySimple> + <propertySimple> + <id>10686</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10025</id> + <uuid>310281d2-60c6-4d7d-bcdc-c51d7969c906</uuid> + <resourceKey>${vhost4.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + <itime>1307353587760</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10173</id> + <version>0</version> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10174</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + <propertySimple> + <id>10705</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10704</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10707</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>2</stringValue> + </propertySimple> + <propertySimple> + <id>10706</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10142</id> + <version>0</version> + <ctime>1307353451273</ctime> + <mtime>1307353451273</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10073</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353737118</ctime> + <mtime>1307353737118</mtime> + <propertySimple> + <id>10365</id> + <name>errorLogMinimumSeverity</name> + <override>false</override> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10366</id> + <name>errorLogIncludesPattern</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10367</id> + <name>snmpAgentCommunity</name> + <override>false</override> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10368</id> + <name>errorLogFilePath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10369</id> + <name>errorLogEventsEnabled</name> + <override>false</override> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10370</id> + <name>snmpAgentHost</name> + <override>false</override> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10713</id> + <name>controlScriptPath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10714</id> + <name>url</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10364</id> + <name>configFile</name> + <override>false</override> + <stringValue>conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10711</id> + <name>executablePath</name> + <override>false</override> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10712</id> + <name>snmpAgentPort</name> + <override>false</override> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10715</id> + <name>serverRoot</name> + <override>false</override> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10003</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/simple/inventory-single-vhost.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/simple/inventory-single-vhost.xml new file mode 100644 index 0000000..00ac425 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/simple/inventory-single-vhost.xml @@ -0,0 +1,215 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10004</id> + <uuid>ae8a7a3e-256e-4c0a-9a65-33d534523d92</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost} Apache 2.2.17 (${server.root}/)</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>true</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1307353451273</ctime> + <mtime>1307353509168</mtime> + <itime>1307353509168</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10013</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10012</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10022</id> + <uuid>08290193-c716-4363-b841-8a1d9d83f580</uuid> + <resourceKey>${snmp.identifier}</resourceKey> + <name>Virtual Host ${snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587727</ctime> + <mtime>1307353587727</mtime> + <itime>1307353587721</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10137</id> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10138</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + <propertySimple> + <id>10690</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10689</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/${localhost}0_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10692</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Blocalhost%7D:0/</stringValue> + </propertySimple> + <propertySimple> + <id>10693</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>1</stringValue> + </propertySimple> + <propertySimple> + <id>10691</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>DOWN</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10142</id> + <version>0</version> + <ctime>1307353451273</ctime> + <mtime>1307353451273</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10073</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353737118</ctime> + <mtime>1307353737118</mtime> + <propertySimple> + <id>10365</id> + <name>errorLogMinimumSeverity</name> + <override>false</override> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10366</id> + <name>errorLogIncludesPattern</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10367</id> + <name>snmpAgentCommunity</name> + <override>false</override> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10368</id> + <name>errorLogFilePath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10369</id> + <name>errorLogEventsEnabled</name> + <override>false</override> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10370</id> + <name>snmpAgentHost</name> + <override>false</override> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10713</id> + <name>controlScriptPath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10714</id> + <name>url</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10364</id> + <name>configFile</name> + <override>false</override> + <stringValue>conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10711</id> + <name>executablePath</name> + <override>false</override> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10712</id> + <name>snmpAgentPort</name> + <override>false</override> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10715</id> + <name>serverRoot</name> + <override>false</override> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10003</id> + </productVersion> +</resource> +</objects> +</inventory-dump>
commit 2b8e69408d537ffa7d05c877c20bc5d5d416d2b1 Author: Lukas Krejci lkrejci@redhat.com Date: Thu Jun 30 15:24:37 2011 +0200
adding tests for configuration files with includes.
diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeConfigurationWithIncludesFromRHQ1_3Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeConfigurationWithIncludesFromRHQ1_3Test.java new file mode 100644 index 0000000..95ea298 --- /dev/null +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeConfigurationWithIncludesFromRHQ1_3Test.java @@ -0,0 +1,33 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.plugins.apache.upgrade.rhq1_3_x; + +/** + * + * + * @author Lukas Krejci + */ +public class UpgradeConfigurationWithIncludesFromRHQ1_3Test extends UpgradeSimpleConfigurationFromRHQ1_3Test { + + public UpgradeConfigurationWithIncludesFromRHQ1_3Test() { + super("/mocked-inventories/rhq-1.3.x/includes/inventory.xml", "/full-configurations/2.2.x/includes/httpd.conf", "/full-configurations/2.2.x/includes/1.vhost.conf", "/full-configurations/2.2.x/includes/2.vhost.conf"); + } + +} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeSimpleConfigurationFromRHQ1_3Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeSimpleConfigurationFromRHQ1_3Test.java index 1fd44ba..752c845 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeSimpleConfigurationFromRHQ1_3Test.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeSimpleConfigurationFromRHQ1_3Test.java @@ -29,8 +29,6 @@ import org.testng.annotations.Test;
import org.rhq.core.domain.resource.Resource; import org.rhq.plugins.apache.upgrade.UpgradeTestBase; -import org.rhq.plugins.apache.upgrade.UpgradeTestBase.TestConfiguration; -import org.rhq.plugins.apache.upgrade.UpgradeTestBase.TestSetup; import org.rhq.test.pc.PluginContainerSetup;
/** @@ -41,6 +39,19 @@ import org.rhq.test.pc.PluginContainerSetup; @Test(groups = "apache-integration-tests") public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase {
+ String[] configuredApacheConfigurationFiles; + String configuredInventoryFile; + + public UpgradeSimpleConfigurationFromRHQ1_3Test() { + configuredApacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + configuredInventoryFile = "/mocked-inventories/rhq-1.3.x/simple/inventory.xml"; + } + + protected UpgradeSimpleConfigurationFromRHQ1_3Test(String defaultInventoryFile, String... defaultApacheConfigurationFiles) { + this.configuredApacheConfigurationFiles = defaultApacheConfigurationFiles; + this.configuredInventoryFile = defaultInventoryFile; + } + @Test @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) @Parameters({ "apache2.install.dir", "apache2.exe.path" }) @@ -52,8 +63,8 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase { serverRoot = installPath; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-1.3.x/simple/inventory.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFile; } }); } @@ -69,8 +80,8 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase { serverRoot = installPath; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - apacheConfigurationFiles = new String[] { "/full-configurations/1.3.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-1.3.x/simple/inventory.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFile; }}); }
@@ -81,8 +92,8 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase { testUpgrade(new TestConfiguration() { { configurationName = DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES; - apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-1.3.x/simple/inventory.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFile; serverRoot = installPath; binPath = exePath;
@@ -128,8 +139,8 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase { { configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
- apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-1.3.x/simple/inventory.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFile; serverRoot = installPath; binPath = exePath;
@@ -151,8 +162,8 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase { { configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
- apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-1.3.x/simple/inventory.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFile; serverRoot = installPath; binPath = exePath;
diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeConfigurationWithIncludesFromRHQ3_0_0Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeConfigurationWithIncludesFromRHQ3_0_0Test.java new file mode 100644 index 0000000..7fbe709 --- /dev/null +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeConfigurationWithIncludesFromRHQ3_0_0Test.java @@ -0,0 +1,36 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.plugins.apache.upgrade.rhq3_0_0; + +/** + * + * + * @author Lukas Krejci + */ +public class UpgradeConfigurationWithIncludesFromRHQ3_0_0Test extends UpgradeSimpleConfigurationFromRHQ3_0_0Test { + + public UpgradeConfigurationWithIncludesFromRHQ3_0_0Test() { + super("/mocked-inventories/rhq-3.0.0/includes/inventory-without-snmp.xml", + "/mocked-inventories/rhq-3.0.0/includes/inventory-with-snmp.xml", + "/mocked-inventories/rhq-3.0.0/includes/inventory-with-snmp-anyaddr.xml", + "/full-configurations/2.2.x/includes/httpd.conf", "/full-configurations/2.2.x/includes/1.vhost.conf", + "/full-configurations/2.2.x/includes/2.vhost.conf"); + } +} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java index fb2e360..c4399d9 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java @@ -38,8 +38,6 @@ import org.rhq.plugins.apache.ApacheServerComponent; import org.rhq.plugins.apache.ApacheServerDiscoveryComponent; import org.rhq.plugins.apache.parser.ApacheDirectiveTree; import org.rhq.plugins.apache.upgrade.UpgradeTestBase; -import org.rhq.plugins.apache.upgrade.UpgradeTestBase.TestConfiguration; -import org.rhq.plugins.apache.upgrade.UpgradeTestBase.TestSetup; import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig; import org.rhq.plugins.apache.util.RuntimeApacheConfiguration; import org.rhq.plugins.apache.util.VirtualHostLegacyResourceKeyUtil; @@ -52,6 +50,34 @@ import org.rhq.test.pc.PluginContainerSetup; */ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase {
+ private String[] configuredApacheConfigurationFiles; + private String configuredInventoryFileWithoutSNMP; + private String configuredInventoryFileWithSNMP; + private String configuredInventoryFileWithSNMPWithAnyAddress; + + public UpgradeSimpleConfigurationFromRHQ3_0_0Test() { + configuredInventoryFileWithoutSNMP = "/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml"; + configuredInventoryFileWithSNMP = "/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml"; + configuredInventoryFileWithSNMPWithAnyAddress = "/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp-anyaddr.xml"; + configuredApacheConfigurationFiles = new String[] {"/full-configurations/2.2.x/simple/httpd.conf"}; + } + + + /** + * @param configuredApacheConfigurationFiles + * @param configuredInventoryFileWithoutSNMP + * @param configuredInventoryFileWithSNMP + * @param configuredInventoryFileWithSNMPWithAnyAddress + */ + public UpgradeSimpleConfigurationFromRHQ3_0_0Test(String configuredInventoryFileWithoutSNMP, + String configuredInventoryFileWithSNMP, String configuredInventoryFileWithSNMPWithAnyAddress, + String... configuredApacheConfigurationFiles) { + this.configuredApacheConfigurationFiles = configuredApacheConfigurationFiles; + this.configuredInventoryFileWithoutSNMP = configuredInventoryFileWithoutSNMP; + this.configuredInventoryFileWithSNMP = configuredInventoryFileWithSNMP; + this.configuredInventoryFileWithSNMPWithAnyAddress = configuredInventoryFileWithSNMPWithAnyAddress; + } + /** * This tests the upgrade from RHQ 3.0.0 where the apache server was discovered without SNMP support. * The Main Server URL must have been set in this case, otherwise the component would fail to start @@ -63,8 +89,8 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase public void testWithResolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { testUpgrade(new TestConfiguration() { { - apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; - inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithoutSNMP; serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; @@ -83,8 +109,8 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase public void testWithUnresolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { testUpgrade(new TestConfiguration() { { - apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; - inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithoutSNMP; serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES; @@ -104,8 +130,8 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase public void testWithNonUniqueNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { testUpgrade(new TestConfiguration() { { - apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; - inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithoutSNMP; serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES; @@ -136,8 +162,8 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase public void testWithResolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable { testUpgrade(new TestConfiguration() { { - apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; - inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithSNMP; serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; @@ -166,8 +192,8 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase public void testWithUnresolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable { testUpgrade(new TestConfiguration() { { - apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; - inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithSNMP; serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; @@ -202,8 +228,8 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase public void testWithNonUniqueNamesWithSNMP(final String installDir, final String exePath) throws Throwable { testUpgrade(new TestConfiguration() { { - apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; - inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithSNMP; serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; @@ -240,8 +266,8 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase { configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
- apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithoutSNMP; serverRoot = installPath; binPath = exePath;
@@ -279,8 +305,8 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase { configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
- apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp-anyaddr.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithSNMPWithAnyAddress; serverRoot = installPath; binPath = exePath;
@@ -306,8 +332,8 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase { configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
- apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithoutSNMP; serverRoot = installPath; binPath = exePath;
@@ -332,8 +358,8 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase { configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
- apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithSNMP; serverRoot = installPath; binPath = exePath; upgradeShouldSucceed = false; diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeConfigurationWithIncludesFromRHQ3_0_1Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeConfigurationWithIncludesFromRHQ3_0_1Test.java new file mode 100644 index 0000000..41e7252 --- /dev/null +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeConfigurationWithIncludesFromRHQ3_0_1Test.java @@ -0,0 +1,38 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.plugins.apache.upgrade.rhq3_0_1; + +/** + * + * + * @author Lukas Krejci + */ +public class UpgradeConfigurationWithIncludesFromRHQ3_0_1Test extends UpgradeSimpleConfigurationFromRHQ3_0_1Test { + + + public UpgradeConfigurationWithIncludesFromRHQ3_0_1Test() { + super("/mocked-inventories/rhq-3.0.1/includes/inventory-with-snmp.xml", + "/mocked-inventories/rhq-3.0.1/includes/inventory-without-snmp.xml", + "/mocked-inventories/rhq-3.0.1/includes/inventory-with-snmp-anyaddr.xml", + "/mocked-inventories/rhq-3.0.1/includes/inventory-with-duplicate-main.xml", + "/full-configurations/2.2.x/includes/httpd.conf", "/full-configurations/2.2.x/includes/1.vhost.conf", + "/full-configurations/2.2.x/includes/2.vhost.conf"); + } +} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java index cbd4826..fa88f8d 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java @@ -55,14 +55,47 @@ import org.rhq.test.pc.PluginContainerSetup; */ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase {
+ private String[] configuredApacheConfigurationFiles; + private String configuredInventoryFileWithSNMP; + private String configuredInventoryFileWithoutSNMP; + private String configuredInventoryFileWithSNMPWithAnyAddress; + private String configuredInventoryFileWithDuplicateMain; + + + public UpgradeSimpleConfigurationFromRHQ3_0_1Test() { + configuredApacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; + configuredInventoryFileWithSNMP = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml"; + configuredInventoryFileWithoutSNMP = "/mocked-inventories/rhq-3.0.1/simple/inventory-without-snmp.xml"; + configuredInventoryFileWithSNMPWithAnyAddress = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp-anyaddr.xml"; + configuredInventoryFileWithDuplicateMain = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-duplicate-main.xml"; + } + + /** + * @param configuredApacheConfigurationFiles + * @param configuredInventoryFileWithSNMP + * @param configuredInventoryFileWithoutSNMP + * @param configuredInventoryFileWithSNMPWithAnyAddress + * @param configuredInventoryFileWithDuplicateMain + */ + protected UpgradeSimpleConfigurationFromRHQ3_0_1Test(String configuredInventoryFileWithSNMP, + String configuredInventoryFileWithoutSNMP, String configuredInventoryFileWithSNMPWithAnyAddress, + String configuredInventoryFileWithDuplicateMain, String... configuredApacheConfigurationFiles) { + + this.configuredApacheConfigurationFiles = configuredApacheConfigurationFiles; + this.configuredInventoryFileWithSNMP = configuredInventoryFileWithSNMP; + this.configuredInventoryFileWithoutSNMP = configuredInventoryFileWithoutSNMP; + this.configuredInventoryFileWithSNMPWithAnyAddress = configuredInventoryFileWithSNMPWithAnyAddress; + this.configuredInventoryFileWithDuplicateMain = configuredInventoryFileWithDuplicateMain; + } + @Test @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) @Parameters({"apache2.install.dir", "apache2.exe.path"}) public void testWithResolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable { testUpgrade(new TestConfiguration() { { - apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; - inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithSNMP; serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; @@ -92,8 +125,8 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase public void testWithResolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { testUpgrade(new TestConfiguration() { { - apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; - inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-without-snmp.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithoutSNMP; serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; @@ -124,8 +157,8 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase public void testWithUnresolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable { testUpgrade(new TestConfiguration() { { - apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; - inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithSNMP; serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; @@ -161,8 +194,8 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase public void testWithUnresolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { testUpgrade(new TestConfiguration() { { - apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; - inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-without-snmp.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithoutSNMP; serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; @@ -190,8 +223,8 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase public void testWithNonUniqueNamesWithSNMP(final String installDir, final String exePath) throws Throwable { testUpgrade(new TestConfiguration() { { - apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; - inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithSNMP; serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; @@ -227,8 +260,8 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase public void testWithNonUniqueNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { testUpgrade(new TestConfiguration() { { - apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-without-snmp.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithoutSNMP; serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; @@ -279,8 +312,8 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase public void testDuplicateMainVhostsMarkedAsFailedUpgrade(final String installDir, final String exePath) throws Throwable { testUpgrade(new TestConfiguration() { { - apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; - inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-duplicate-main.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithDuplicateMain; serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; @@ -314,10 +347,10 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase { configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
- apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + apacheConfigurationFiles = configuredApacheConfigurationFiles; //yes, the inventory file can be the same for both the with and without snmp tests because //they both yield the same inventory in this case. - inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp-anyaddr.xml"; + inventoryFile = configuredInventoryFileWithSNMPWithAnyAddress; serverRoot = installPath; binPath = exePath;
@@ -360,8 +393,8 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase { configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
- apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp-anyaddr.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithSNMPWithAnyAddress; serverRoot = installPath; binPath = exePath;
@@ -391,8 +424,8 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase { configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
- apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-without-snmp.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithoutSNMP; serverRoot = installPath; binPath = exePath; upgradeShouldSucceed = false; @@ -429,8 +462,8 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase { configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
- apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFileWithSNMP; serverRoot = installPath; binPath = exePath; upgradeShouldSucceed = false; diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeConfigurationWithIncludesFromRHQ3_0_2Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeConfigurationWithIncludesFromRHQ3_0_2Test.java new file mode 100644 index 0000000..0795ecc --- /dev/null +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeConfigurationWithIncludesFromRHQ3_0_2Test.java @@ -0,0 +1,33 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.plugins.apache.upgrade.rhq3_0_2; + +/** + * + * + * @author Lukas Krejci + */ +public class UpgradeConfigurationWithIncludesFromRHQ3_0_2Test extends UpgradeSimpleConfigurationFromRHQ3_0_2Test { + + public UpgradeConfigurationWithIncludesFromRHQ3_0_2Test() { + super("/mocked-inventories/rhq-3.0.2/includes/inventory.xml", "/full-configurations/2.2.x/includes/httpd.conf", + "/full-configurations/2.2.x/includes/1.vhost.conf", "/full-configurations/2.2.x/includes/2.vhost.conf"); + } +} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeSimpleConfigurationFromRHQ3_0_2Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeSimpleConfigurationFromRHQ3_0_2Test.java index 2e85a4b..2c3de84 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeSimpleConfigurationFromRHQ3_0_2Test.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeSimpleConfigurationFromRHQ3_0_2Test.java @@ -32,14 +32,33 @@ import org.rhq.test.pc.PluginContainerSetup; */ public class UpgradeSimpleConfigurationFromRHQ3_0_2Test extends UpgradeTestBase {
+ private String[] configuredApacheConfigurationFiles; + private String configuredInventoryFile; + + public UpgradeSimpleConfigurationFromRHQ3_0_2Test() { + configuredApacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + configuredInventoryFile = "/mocked-inventories/rhq-3.0.2/simple/inventory.xml"; + } + + /** + * @param configuredApacheConfigurationFiles + * @param configuredInventoryFile + */ + protected UpgradeSimpleConfigurationFromRHQ3_0_2Test(String configuredInventoryFile, + String... configuredApacheConfigurationFiles) { + + this.configuredApacheConfigurationFiles = configuredApacheConfigurationFiles; + this.configuredInventoryFile = configuredInventoryFile; + } + @Test @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) @Parameters({ "apache2.install.dir", "apache2.exe.path" }) public void testWithResolvableNames(final String installDir, final String exePath) throws Throwable { testUpgrade(new TestConfiguration() { { - apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-3.0.2/simple/inventory.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFile; serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; @@ -53,8 +72,8 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_2Test extends UpgradeTestBase public void testWithUnresolvableNames(final String installDir, final String exePath) throws Throwable { testUpgrade(new TestConfiguration() { { - apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-3.0.2/simple/inventory.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFile; serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; @@ -79,8 +98,8 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_2Test extends UpgradeTestBase public void testWithNonUniqueNames(final String installDir, final String exePath) throws Throwable { testUpgrade(new TestConfiguration() { { - apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-3.0.2/simple/inventory.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFile; serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; @@ -107,8 +126,8 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_2Test extends UpgradeTestBase { configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
- apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-3.0.2/simple/inventory.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFile; serverRoot = installPath; binPath = exePath;
@@ -137,8 +156,8 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_2Test extends UpgradeTestBase { configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
- apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-3.0.2/simple/inventory.xml"; + apacheConfigurationFiles = configuredApacheConfigurationFiles; + inventoryFile = configuredInventoryFile; serverRoot = installPath; binPath = exePath;
diff --git a/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/includes/httpd.conf b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/includes/httpd.conf index ebc07ac..22f6dac 100644 --- a/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/includes/httpd.conf +++ b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/includes/httpd.conf @@ -37,4 +37,4 @@ SNMPVar var
${additional.directives}
-Include *.vhost.conf +Include conf/*.vhost.conf diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/includes/inventory.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/includes/inventory.xml new file mode 100644 index 0000000..f8d181d --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/includes/inventory.xml @@ -0,0 +1,539 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10004</id> + <uuid>ae8a7a3e-256e-4c0a-9a65-33d534523d92</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost} Apache 2.2.17 (${server.root}/)</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>true</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1307353451273</ctime> + <mtime>1307353509168</mtime> + <itime>1307353509168</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10013</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10012</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10022</id> + <uuid>08290193-c716-4363-b841-8a1d9d83f580</uuid> + <resourceKey>${snmp.identifier}</resourceKey> + <name>Virtual Host ${snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587727</ctime> + <mtime>1307353587727</mtime> + <itime>1307353587721</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10137</id> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10138</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + <propertySimple> + <id>10690</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10689</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/${localhost}0_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10692</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Blocalhost%7D:0/</stringValue> + </propertySimple> + <propertySimple> + <id>10693</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>1</stringValue> + </propertySimple> + <propertySimple> + <id>10691</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>DOWN</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10021</id> + <uuid>3a20d809-7eba-422c-a3ef-baf65804498d</uuid> + <resourceKey>${vhost2.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost2.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587648</ctime> + <mtime>1307353587648</mtime> + <itime>1307353587648</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10135</id> + <version>0</version> + <ctime>1307353587666</ctime> + <mtime>1307353587666</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10136</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587667</ctime> + <mtime>1307353587667</mtime> + <propertySimple> + <id>10685</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10684</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111676_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10687</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost2.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10688</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>4</stringValue> + </propertySimple> + <propertySimple> + <id>10686</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10023</id> + <uuid>c62c5d75-81dd-4b14-a768-2d8c1fca6c88</uuid> + <resourceKey>${vhost3.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost3.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + <itime>1307353587737</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10139</id> + <version>0</version> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10140</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + <propertySimple> + <id>10695</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10694</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111677_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10697</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost3.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10698</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>3</stringValue> + </propertySimple> + <propertySimple> + <id>10696</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10024</id> + <uuid>d1b59168-8666-4bc0-957e-171bf16eec73</uuid> + <resourceKey>${vhost1.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost1.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + <itime>1307353587750</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10171</id> + <version>0</version> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10172</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + <propertySimple> + <id>10700</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10699</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10702</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost1.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10703</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>5</stringValue> + </propertySimple> + <propertySimple> + <id>10701</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10025</id> + <uuid>310281d2-60c6-4d7d-bcdc-c51d7969c906</uuid> + <resourceKey>${vhost4.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + <itime>1307353587760</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10173</id> + <version>0</version> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10174</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + <propertySimple> + <id>10705</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10704</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10707</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>2</stringValue> + </propertySimple> + <propertySimple> + <id>10706</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10142</id> + <version>0</version> + <ctime>1307353451273</ctime> + <mtime>1307353451273</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10073</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353737118</ctime> + <mtime>1307353737118</mtime> + <propertySimple> + <id>10365</id> + <name>errorLogMinimumSeverity</name> + <override>false</override> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10366</id> + <name>errorLogIncludesPattern</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10367</id> + <name>snmpAgentCommunity</name> + <override>false</override> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10368</id> + <name>errorLogFilePath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10369</id> + <name>errorLogEventsEnabled</name> + <override>false</override> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10370</id> + <name>snmpAgentHost</name> + <override>false</override> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10713</id> + <name>controlScriptPath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10714</id> + <name>url</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10364</id> + <name>configFile</name> + <override>false</override> + <stringValue>conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10711</id> + <name>executablePath</name> + <override>false</override> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10712</id> + <name>snmpAgentPort</name> + <override>false</override> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10715</id> + <name>serverRoot</name> + <override>false</override> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10003</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/includes/inventory-with-snmp-anyaddr.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/includes/inventory-with-snmp-anyaddr.xml new file mode 100644 index 0000000..fc34748 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/includes/inventory-with-snmp-anyaddr.xml @@ -0,0 +1,538 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10022</id> + <uuid>e61040b4-d645-44dc-a6b7-460d39f1b625</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost}:${port1}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1308835177519</ctime> + <mtime>1308835282077</mtime> + <itime>1308835282077</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10044</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10101</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10102</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>20037</id> + <uuid>b2928cc6-30ab-47fe-8095-e1292887ac18</uuid> + <resourceKey>${main.rhq4.resource.key}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + <itime>1308835287473</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10188</id> + <version>0</version> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10189</id> + <version>0</version> + <ctime>1308835287474</ctime> + <mtime>1308835287474</mtime> + <propertySimple> + <id>10806</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10805</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10808</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10807</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10036</id> + <uuid>5eb8fa91-2a4e-4a6e-9cd7-7b1927ea1a3a</uuid> + <resourceKey>${vhost2.rhq3.resource.key}</resourceKey> + <name>${vhost2.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287457</ctime> + <mtime>1308835287457</mtime> + <itime>1308835287457</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10186</id> + <version>0</version> + <ctime>1308835287457</ctime> + <mtime>1308835287457</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10187</id> + <version>0</version> + <ctime>1308835287458</ctime> + <mtime>1308835287458</mtime> + <propertySimple> + <id>10802</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10801</id> + <name>responseTimeLogFile</name> + <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/localhost.localdomain11676_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10804</id> + <name>url</name> + <stringValue>http://$%7Bvhost2.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10803</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10037</id> + <uuid>b2928cc6-30ab-47fe-8095-e1292887ac18</uuid> + <resourceKey>${main.rhq3.resource.key}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + <itime>1308835287473</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10188</id> + <version>0</version> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10189</id> + <version>0</version> + <ctime>1308835287474</ctime> + <mtime>1308835287474</mtime> + <propertySimple> + <id>10806</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10805</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10808</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10807</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10038</id> + <uuid>fe8d389e-5a45-4bf2-9f73-0831caca63df</uuid> + <resourceKey>${vhost4.rhq3.resource.key}</resourceKey> + <name>${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <itime>1308835287481</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10190</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10191</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <propertySimple> + <id>10810</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10809</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10812</id> + <name>url</name> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10811</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10039</id> + <uuid>369d9dee-b4e1-45bf-9ad9-6a5d8cdd563e</uuid> + <resourceKey>${vhost3.rhq3.resource.key}</resourceKey> + <name>${vhost3.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287493</ctime> + <mtime>1308835287493</mtime> + <itime>1308835287492</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10192</id> + <version>0</version> + <ctime>1308835287493</ctime> + <mtime>1308835287493</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10193</id> + <version>0</version> + <ctime>1308835287494</ctime> + <mtime>1308835287494</mtime> + <propertySimple> + <id>10814</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10813</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}logs/localhost.localdomain11677_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10816</id> + <name>url</name> + <stringValue>http://$%7Bvhost3.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10815</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10174</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10175</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + <propertySimple> + <id>10790</id> + <name>errorLogIncludesPattern</name> + </propertySimple> + <propertySimple> + <id>10783</id> + <name>errorLogMinimumSeverity</name> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>augeasEnabled</name> + <stringValue>no</stringValue> + </propertySimple> + <propertySimple> + <id>10789</id> + <name>errorLogFilePath</name> + </propertySimple> + <propertySimple> + <id>10786</id> + <name>snmpAgentCommunity</name> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10784</id> + <name>snmpAgentHost</name> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10782</id> + <name>errorLogEventsEnabled</name> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10793</id> + <name>controlScriptPath</name> + </propertySimple> + <propertySimple> + <id>10795</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10709</id> + <name>augeasModuleName</name> + <stringValue>Httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10794</id> + <name>configFile</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10710</id> + <name>configurationFilesInclusionPatterns</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10788</id> + <name>vhostFilesMask</name> + <stringValue>${server.root}/conf/*</stringValue> + </propertySimple> + <propertySimple> + <id>10787</id> + <name>restartAfterConfigurationUpdate</name> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10792</id> + <name>executablePath</name> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10785</id> + <name>snmpAgentPort</name> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10781</id> + <name>vhostCreationPolicy</name> + <stringValue>vhost-per-file</stringValue> + </propertySimple> + <propertySimple> + <id>10791</id> + <name>serverRoot</name> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/includes/inventory-with-snmp.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/includes/inventory-with-snmp.xml new file mode 100644 index 0000000..ff9d715 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/includes/inventory-with-snmp.xml @@ -0,0 +1,462 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10022</id> + <uuid>e61040b4-d645-44dc-a6b7-460d39f1b625</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost}:${port1}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1308835177519</ctime> + <mtime>1308835282077</mtime> + <itime>1308835282077</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10044</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10101</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10102</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10036</id> + <uuid>5eb8fa91-2a4e-4a6e-9cd7-7b1927ea1a3a</uuid> + <resourceKey>${vhost2.rhq3.resource.key}</resourceKey> + <name>${vhost2.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287457</ctime> + <mtime>1308835287457</mtime> + <itime>1308835287457</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10186</id> + <version>0</version> + <ctime>1308835287457</ctime> + <mtime>1308835287457</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10187</id> + <version>0</version> + <ctime>1308835287458</ctime> + <mtime>1308835287458</mtime> + <propertySimple> + <id>10802</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10801</id> + <name>responseTimeLogFile</name> + <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/localhost.localdomain11676_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10804</id> + <name>url</name> + <stringValue>http://$%7Bvhost2.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10803</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10037</id> + <uuid>b2928cc6-30ab-47fe-8095-e1292887ac18</uuid> + <resourceKey>${main.rhq3.resource.key}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + <itime>1308835287473</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10188</id> + <version>0</version> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10189</id> + <version>0</version> + <ctime>1308835287474</ctime> + <mtime>1308835287474</mtime> + <propertySimple> + <id>10806</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10805</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10808</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10807</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10038</id> + <uuid>fe8d389e-5a45-4bf2-9f73-0831caca63df</uuid> + <resourceKey>${vhost4.rhq3.resource.key}</resourceKey> + <name>${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <itime>1308835287481</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10190</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10191</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <propertySimple> + <id>10810</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10809</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10812</id> + <name>url</name> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10811</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10039</id> + <uuid>369d9dee-b4e1-45bf-9ad9-6a5d8cdd563e</uuid> + <resourceKey>${vhost3.rhq3.resource.key}</resourceKey> + <name>${vhost3.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287493</ctime> + <mtime>1308835287493</mtime> + <itime>1308835287492</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10192</id> + <version>0</version> + <ctime>1308835287493</ctime> + <mtime>1308835287493</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10193</id> + <version>0</version> + <ctime>1308835287494</ctime> + <mtime>1308835287494</mtime> + <propertySimple> + <id>10814</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10813</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}logs/localhost.localdomain11677_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10816</id> + <name>url</name> + <stringValue>http://$%7Bvhost3.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10815</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10174</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10175</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + <propertySimple> + <id>10790</id> + <name>errorLogIncludesPattern</name> + </propertySimple> + <propertySimple> + <id>10783</id> + <name>errorLogMinimumSeverity</name> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>augeasEnabled</name> + <stringValue>no</stringValue> + </propertySimple> + <propertySimple> + <id>10789</id> + <name>errorLogFilePath</name> + </propertySimple> + <propertySimple> + <id>10786</id> + <name>snmpAgentCommunity</name> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10784</id> + <name>snmpAgentHost</name> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10782</id> + <name>errorLogEventsEnabled</name> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10793</id> + <name>controlScriptPath</name> + </propertySimple> + <propertySimple> + <id>10795</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10709</id> + <name>augeasModuleName</name> + <stringValue>Httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10794</id> + <name>configFile</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10710</id> + <name>configurationFilesInclusionPatterns</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10788</id> + <name>vhostFilesMask</name> + <stringValue>${server.root}/conf/*</stringValue> + </propertySimple> + <propertySimple> + <id>10787</id> + <name>restartAfterConfigurationUpdate</name> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10792</id> + <name>executablePath</name> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10785</id> + <name>snmpAgentPort</name> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10781</id> + <name>vhostCreationPolicy</name> + <stringValue>vhost-per-file</stringValue> + </propertySimple> + <propertySimple> + <id>10791</id> + <name>serverRoot</name> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/includes/inventory-without-snmp.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/includes/inventory-without-snmp.xml new file mode 100644 index 0000000..590b10f --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/includes/inventory-without-snmp.xml @@ -0,0 +1,538 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10041</id> + <uuid>02f44194-9bb8-44ef-9866-ef7b69eedc0a</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost}:${port1}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>true</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1309116183350</ctime> + <mtime>1309116225316</mtime> + <itime>1309116225316</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10044</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10101</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10102</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10046</id> + <uuid>908ea047-889e-4978-a61f-d96e8b1c6d17</uuid> + <resourceKey>${vhost4.rhq4.resource.key}</resourceKey> + <name>${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635789</ctime> + <mtime>1309117635789</mtime> + <itime>1309117635788</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10241</id> + <version>0</version> + <ctime>1309117635789</ctime> + <mtime>1309117635789</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10242</id> + <version>0</version> + <ctime>1309117635790</ctime> + <mtime>1309117635790</mtime> + <propertySimple> + <id>10858</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10857</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10860</id> + <name>url</name> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10859</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10047</id> + <uuid>5fccc52b-8003-42ed-aa69-0b146c783e91</uuid> + <resourceKey>${vhost3.rhq4.resource.key}</resourceKey> + <name>${vhost3.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635802</ctime> + <mtime>1309117635802</mtime> + <itime>1309117635802</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10243</id> + <version>0</version> + <ctime>1309117635802</ctime> + <mtime>1309117635802</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10244</id> + <version>0</version> + <ctime>1309117635802</ctime> + <mtime>1309117635802</mtime> + <propertySimple> + <id>10922</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10921</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11677_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10924</id> + <name>url</name> + <stringValue>http://$%7Bvhost3.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10923</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10048</id> + <uuid>704a31f3-7f5f-46c1-9bda-70f2645c9604</uuid> + <resourceKey>${main.rhq4.resource.key}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635810</ctime> + <mtime>1309117635810</mtime> + <itime>1309117635810</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10245</id> + <version>0</version> + <ctime>1309117635811</ctime> + <mtime>1309117635811</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10246</id> + <version>0</version> + <ctime>1309117635811</ctime> + <mtime>1309117635811</mtime> + <propertySimple> + <id>10926</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10925</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10928</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10927</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10049</id> + <uuid>03638606-623b-4218-bd23-42e04db0e296</uuid> + <resourceKey>${vhost2.rhq4.resource.key}</resourceKey> + <name>${vhost2.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635819</ctime> + <mtime>1309117635819</mtime> + <itime>1309117635818</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10247</id> + <version>0</version> + <ctime>1309117635819</ctime> + <mtime>1309117635819</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10248</id> + <version>0</version> + <ctime>1309117635819</ctime> + <mtime>1309117635819</mtime> + <propertySimple> + <id>10930</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10929</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11676_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10932</id> + <name>url</name> + <stringValue>http://$%7Bvhost2.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10931</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10050</id> + <uuid>ae880c2d-747d-492d-8586-a47ab5791b0e</uuid> + <resourceKey>${vhost1.rhq4.resource.key}</resourceKey> + <name>${vhost1.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635829</ctime> + <mtime>1309117635829</mtime> + <itime>1309117635829</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10249</id> + <version>0</version> + <ctime>1309117635829</ctime> + <mtime>1309117635829</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10250</id> + <version>0</version> + <ctime>1309117635829</ctime> + <mtime>1309117635829</mtime> + <propertySimple> + <id>10934</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10933</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10936</id> + <name>url</name> + <stringValue>http://$%7Bvhost1.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10935</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10201</id> + <version>0</version> + <ctime>1309116183368</ctime> + <mtime>1309116183368</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10211</id> + <version>0</version> + <ctime>1309117523737</ctime> + <mtime>1309117523737</mtime> + <propertySimple> + <id>10863</id> + <name>errorLogIncludesPattern</name> + </propertySimple> + <propertySimple> + <id>10862</id> + <name>errorLogMinimumSeverity</name> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10861</id> + <name>augeasEnabled</name> + <stringValue>no</stringValue> + </propertySimple> + <propertySimple> + <id>10865</id> + <name>errorLogFilePath</name> + </propertySimple> + <propertySimple> + <id>10864</id> + <name>snmpAgentCommunity</name> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10867</id> + <name>snmpAgentHost</name> + <stringValue>${unresolvable.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10866</id> + <name>errorLogEventsEnabled</name> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10869</id> + <name>controlScriptPath</name> + </propertySimple> + <propertySimple> + <id>10868</id> + <name>url</name> + <stringValue>http://$%7Bservername%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10870</id> + <name>augeasModuleName</name> + <stringValue>Httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10871</id> + <name>configFile</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10872</id> + <name>configurationFilesInclusionPatterns</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10873</id> + <name>vhostFilesMask</name> + <stringValue>${server.root}/conf/*</stringValue> + </propertySimple> + <propertySimple> + <id>10874</id> + <name>executablePath</name> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10875</id> + <name>restartAfterConfigurationUpdate</name> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10876</id> + <name>snmpAgentPort</name> + <stringValue>1610</stringValue> + </propertySimple> + <propertySimple> + <id>10877</id> + <name>serverRoot</name> + <stringValue>${server.root}</stringValue> + </propertySimple> + <propertySimple> + <id>10878</id> + <name>vhostCreationPolicy</name> + <stringValue>vhost-per-file</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/includes/inventory-with-duplicate-main.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/includes/inventory-with-duplicate-main.xml new file mode 100644 index 0000000..78fc9dd --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/includes/inventory-with-duplicate-main.xml @@ -0,0 +1,538 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10022</id> + <uuid>e61040b4-d645-44dc-a6b7-460d39f1b625</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost}:${port1}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1308835177519</ctime> + <mtime>1308835282077</mtime> + <itime>1308835282077</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10044</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10101</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10102</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10036</id> + <uuid>5eb8fa91-2a4e-4a6e-9cd7-7b1927ea1a3a</uuid> + <resourceKey>${vhost2.rhq3.resource.key}</resourceKey> + <name>${vhost2.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287457</ctime> + <mtime>1308835287457</mtime> + <itime>1308835287457</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10186</id> + <version>0</version> + <ctime>1308835287457</ctime> + <mtime>1308835287457</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10187</id> + <version>0</version> + <ctime>1308835287458</ctime> + <mtime>1308835287458</mtime> + <propertySimple> + <id>10802</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10801</id> + <name>responseTimeLogFile</name> + <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/localhost.localdomain11676_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10804</id> + <name>url</name> + <stringValue>http://$%7Bvhost2.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10803</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10037</id> + <uuid>b2928cc6-30ab-47fe-8095-e1292887ac18</uuid> + <resourceKey>${main.rhq3.resource.key}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + <itime>1308835287473</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10188</id> + <version>0</version> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10189</id> + <version>0</version> + <ctime>1308835287474</ctime> + <mtime>1308835287474</mtime> + <propertySimple> + <id>10806</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10805</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10808</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10807</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>100371</id> + <uuid>b2928cc6-30ab-47fe-8095-e1292887ac90</uuid> + <resourceKey>${localhost}:${port1}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + <itime>1308835287473</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10188</id> + <version>0</version> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10189</id> + <version>0</version> + <ctime>1308835287474</ctime> + <mtime>1308835287474</mtime> + <propertySimple> + <id>10806</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10805</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10808</id> + <name>url</name> + <stringValue>http://$%7Blocalhost.ip%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10807</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10038</id> + <uuid>fe8d389e-5a45-4bf2-9f73-0831caca63df</uuid> + <resourceKey>${vhost4.rhq3.resource.key}</resourceKey> + <name>${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <itime>1308835287481</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10190</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10191</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <propertySimple> + <id>10810</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10809</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10812</id> + <name>url</name> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10811</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10039</id> + <uuid>369d9dee-b4e1-45bf-9ad9-6a5d8cdd563e</uuid> + <resourceKey>${vhost3.rhq3.resource.key}</resourceKey> + <name>${vhost3.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287493</ctime> + <mtime>1308835287493</mtime> + <itime>1308835287492</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10192</id> + <version>0</version> + <ctime>1308835287493</ctime> + <mtime>1308835287493</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10193</id> + <version>0</version> + <ctime>1308835287494</ctime> + <mtime>1308835287494</mtime> + <propertySimple> + <id>10814</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10813</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}logs/localhost.localdomain11677_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10816</id> + <name>url</name> + <stringValue>http://$%7Bvhost3.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10815</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10174</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10175</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + <propertySimple> + <id>10790</id> + <name>errorLogIncludesPattern</name> + </propertySimple> + <propertySimple> + <id>10783</id> + <name>errorLogMinimumSeverity</name> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>augeasEnabled</name> + <stringValue>no</stringValue> + </propertySimple> + <propertySimple> + <id>10789</id> + <name>errorLogFilePath</name> + </propertySimple> + <propertySimple> + <id>10786</id> + <name>snmpAgentCommunity</name> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10784</id> + <name>snmpAgentHost</name> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10782</id> + <name>errorLogEventsEnabled</name> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10793</id> + <name>controlScriptPath</name> + </propertySimple> + <propertySimple> + <id>10795</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10709</id> + <name>augeasModuleName</name> + <stringValue>Httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10794</id> + <name>configFile</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10710</id> + <name>configurationFilesInclusionPatterns</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10788</id> + <name>vhostFilesMask</name> + <stringValue>${server.root}/conf/*</stringValue> + </propertySimple> + <propertySimple> + <id>10787</id> + <name>restartAfterConfigurationUpdate</name> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10792</id> + <name>executablePath</name> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10785</id> + <name>snmpAgentPort</name> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10781</id> + <name>vhostCreationPolicy</name> + <stringValue>vhost-per-file</stringValue> + </propertySimple> + <propertySimple> + <id>10791</id> + <name>serverRoot</name> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/includes/inventory-with-snmp-anyaddr.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/includes/inventory-with-snmp-anyaddr.xml new file mode 100644 index 0000000..47d502d --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/includes/inventory-with-snmp-anyaddr.xml @@ -0,0 +1,538 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10022</id> + <uuid>e61040b4-d645-44dc-a6b7-460d39f1b625</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost}:${port1}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1308835177519</ctime> + <mtime>1308835282077</mtime> + <itime>1308835282077</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10044</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10101</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10102</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>20037</id> + <uuid>b2928cc6-30ab-47fe-8095-e1292887ac18</uuid> + <resourceKey>0.0.0.0:${port1}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + <itime>1308835287473</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10188</id> + <version>0</version> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10189</id> + <version>0</version> + <ctime>1308835287474</ctime> + <mtime>1308835287474</mtime> + <propertySimple> + <id>10806</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10805</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10808</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10807</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10036</id> + <uuid>5eb8fa91-2a4e-4a6e-9cd7-7b1927ea1a3a</uuid> + <resourceKey>${vhost2.rhq3.resource.key}</resourceKey> + <name>${vhost2.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287457</ctime> + <mtime>1308835287457</mtime> + <itime>1308835287457</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10186</id> + <version>0</version> + <ctime>1308835287457</ctime> + <mtime>1308835287457</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10187</id> + <version>0</version> + <ctime>1308835287458</ctime> + <mtime>1308835287458</mtime> + <propertySimple> + <id>10802</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10801</id> + <name>responseTimeLogFile</name> + <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/localhost.localdomain11676_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10804</id> + <name>url</name> + <stringValue>http://$%7Bvhost2.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10803</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10037</id> + <uuid>b2928cc6-30ab-47fe-8095-e1292887ac18</uuid> + <resourceKey>${main.rhq3.resource.key}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + <itime>1308835287473</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10188</id> + <version>0</version> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10189</id> + <version>0</version> + <ctime>1308835287474</ctime> + <mtime>1308835287474</mtime> + <propertySimple> + <id>10806</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10805</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10808</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10807</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10038</id> + <uuid>fe8d389e-5a45-4bf2-9f73-0831caca63df</uuid> + <resourceKey>${vhost4.rhq3.resource.key}</resourceKey> + <name>${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <itime>1308835287481</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10190</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10191</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <propertySimple> + <id>10810</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10809</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10812</id> + <name>url</name> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10811</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10039</id> + <uuid>369d9dee-b4e1-45bf-9ad9-6a5d8cdd563e</uuid> + <resourceKey>${vhost3.rhq3.resource.key}</resourceKey> + <name>${vhost3.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287493</ctime> + <mtime>1308835287493</mtime> + <itime>1308835287492</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10192</id> + <version>0</version> + <ctime>1308835287493</ctime> + <mtime>1308835287493</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10193</id> + <version>0</version> + <ctime>1308835287494</ctime> + <mtime>1308835287494</mtime> + <propertySimple> + <id>10814</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10813</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}logs/localhost.localdomain11677_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10816</id> + <name>url</name> + <stringValue>http://$%7Bvhost3.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10815</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10174</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10175</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + <propertySimple> + <id>10790</id> + <name>errorLogIncludesPattern</name> + </propertySimple> + <propertySimple> + <id>10783</id> + <name>errorLogMinimumSeverity</name> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>augeasEnabled</name> + <stringValue>no</stringValue> + </propertySimple> + <propertySimple> + <id>10789</id> + <name>errorLogFilePath</name> + </propertySimple> + <propertySimple> + <id>10786</id> + <name>snmpAgentCommunity</name> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10784</id> + <name>snmpAgentHost</name> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10782</id> + <name>errorLogEventsEnabled</name> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10793</id> + <name>controlScriptPath</name> + </propertySimple> + <propertySimple> + <id>10795</id> + <name>url</name> + <stringValue>http://0.0.0.0:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10709</id> + <name>augeasModuleName</name> + <stringValue>Httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10794</id> + <name>configFile</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10710</id> + <name>configurationFilesInclusionPatterns</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10788</id> + <name>vhostFilesMask</name> + <stringValue>${server.root}/conf/*</stringValue> + </propertySimple> + <propertySimple> + <id>10787</id> + <name>restartAfterConfigurationUpdate</name> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10792</id> + <name>executablePath</name> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10785</id> + <name>snmpAgentPort</name> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10781</id> + <name>vhostCreationPolicy</name> + <stringValue>vhost-per-file</stringValue> + </propertySimple> + <propertySimple> + <id>10791</id> + <name>serverRoot</name> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/includes/inventory-with-snmp.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/includes/inventory-with-snmp.xml new file mode 100644 index 0000000..ff9d715 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/includes/inventory-with-snmp.xml @@ -0,0 +1,462 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10022</id> + <uuid>e61040b4-d645-44dc-a6b7-460d39f1b625</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost}:${port1}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1308835177519</ctime> + <mtime>1308835282077</mtime> + <itime>1308835282077</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10044</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10101</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10102</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10036</id> + <uuid>5eb8fa91-2a4e-4a6e-9cd7-7b1927ea1a3a</uuid> + <resourceKey>${vhost2.rhq3.resource.key}</resourceKey> + <name>${vhost2.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287457</ctime> + <mtime>1308835287457</mtime> + <itime>1308835287457</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10186</id> + <version>0</version> + <ctime>1308835287457</ctime> + <mtime>1308835287457</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10187</id> + <version>0</version> + <ctime>1308835287458</ctime> + <mtime>1308835287458</mtime> + <propertySimple> + <id>10802</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10801</id> + <name>responseTimeLogFile</name> + <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/localhost.localdomain11676_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10804</id> + <name>url</name> + <stringValue>http://$%7Bvhost2.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10803</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10037</id> + <uuid>b2928cc6-30ab-47fe-8095-e1292887ac18</uuid> + <resourceKey>${main.rhq3.resource.key}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + <itime>1308835287473</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10188</id> + <version>0</version> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10189</id> + <version>0</version> + <ctime>1308835287474</ctime> + <mtime>1308835287474</mtime> + <propertySimple> + <id>10806</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10805</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10808</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10807</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10038</id> + <uuid>fe8d389e-5a45-4bf2-9f73-0831caca63df</uuid> + <resourceKey>${vhost4.rhq3.resource.key}</resourceKey> + <name>${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <itime>1308835287481</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10190</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10191</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <propertySimple> + <id>10810</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10809</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10812</id> + <name>url</name> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10811</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10039</id> + <uuid>369d9dee-b4e1-45bf-9ad9-6a5d8cdd563e</uuid> + <resourceKey>${vhost3.rhq3.resource.key}</resourceKey> + <name>${vhost3.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287493</ctime> + <mtime>1308835287493</mtime> + <itime>1308835287492</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10192</id> + <version>0</version> + <ctime>1308835287493</ctime> + <mtime>1308835287493</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10193</id> + <version>0</version> + <ctime>1308835287494</ctime> + <mtime>1308835287494</mtime> + <propertySimple> + <id>10814</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10813</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}logs/localhost.localdomain11677_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10816</id> + <name>url</name> + <stringValue>http://$%7Bvhost3.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10815</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10174</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10175</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + <propertySimple> + <id>10790</id> + <name>errorLogIncludesPattern</name> + </propertySimple> + <propertySimple> + <id>10783</id> + <name>errorLogMinimumSeverity</name> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>augeasEnabled</name> + <stringValue>no</stringValue> + </propertySimple> + <propertySimple> + <id>10789</id> + <name>errorLogFilePath</name> + </propertySimple> + <propertySimple> + <id>10786</id> + <name>snmpAgentCommunity</name> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10784</id> + <name>snmpAgentHost</name> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10782</id> + <name>errorLogEventsEnabled</name> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10793</id> + <name>controlScriptPath</name> + </propertySimple> + <propertySimple> + <id>10795</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10709</id> + <name>augeasModuleName</name> + <stringValue>Httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10794</id> + <name>configFile</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10710</id> + <name>configurationFilesInclusionPatterns</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10788</id> + <name>vhostFilesMask</name> + <stringValue>${server.root}/conf/*</stringValue> + </propertySimple> + <propertySimple> + <id>10787</id> + <name>restartAfterConfigurationUpdate</name> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10792</id> + <name>executablePath</name> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10785</id> + <name>snmpAgentPort</name> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10781</id> + <name>vhostCreationPolicy</name> + <stringValue>vhost-per-file</stringValue> + </propertySimple> + <propertySimple> + <id>10791</id> + <name>serverRoot</name> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/includes/inventory-without-snmp.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/includes/inventory-without-snmp.xml new file mode 100644 index 0000000..44ea502 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/includes/inventory-without-snmp.xml @@ -0,0 +1,538 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10041</id> + <uuid>02f44194-9bb8-44ef-9866-ef7b69eedc0a</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost}:${port1}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>true</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1309116183350</ctime> + <mtime>1309116225316</mtime> + <itime>1309116225316</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10044</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10101</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10102</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10046</id> + <uuid>908ea047-889e-4978-a61f-d96e8b1c6d17</uuid> + <resourceKey>${vhost4.rhq3.resource.key}</resourceKey> + <name>${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635789</ctime> + <mtime>1309117635789</mtime> + <itime>1309117635788</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10241</id> + <version>0</version> + <ctime>1309117635789</ctime> + <mtime>1309117635789</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10242</id> + <version>0</version> + <ctime>1309117635790</ctime> + <mtime>1309117635790</mtime> + <propertySimple> + <id>10858</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10857</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10860</id> + <name>url</name> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10859</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10047</id> + <uuid>5fccc52b-8003-42ed-aa69-0b146c783e91</uuid> + <resourceKey>${vhost3.rhq3.resource.key}</resourceKey> + <name>${vhost3.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635802</ctime> + <mtime>1309117635802</mtime> + <itime>1309117635802</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10243</id> + <version>0</version> + <ctime>1309117635802</ctime> + <mtime>1309117635802</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10244</id> + <version>0</version> + <ctime>1309117635802</ctime> + <mtime>1309117635802</mtime> + <propertySimple> + <id>10922</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10921</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11677_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10924</id> + <name>url</name> + <stringValue>http://$%7Bvhost3.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10923</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10048</id> + <uuid>704a31f3-7f5f-46c1-9bda-70f2645c9604</uuid> + <resourceKey>${main.rhq3.resource.key}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635810</ctime> + <mtime>1309117635810</mtime> + <itime>1309117635810</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10245</id> + <version>0</version> + <ctime>1309117635811</ctime> + <mtime>1309117635811</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10246</id> + <version>0</version> + <ctime>1309117635811</ctime> + <mtime>1309117635811</mtime> + <propertySimple> + <id>10926</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10925</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10928</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10927</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10049</id> + <uuid>03638606-623b-4218-bd23-42e04db0e296</uuid> + <resourceKey>${vhost2.rhq3.resource.key}</resourceKey> + <name>${vhost2.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635819</ctime> + <mtime>1309117635819</mtime> + <itime>1309117635818</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10247</id> + <version>0</version> + <ctime>1309117635819</ctime> + <mtime>1309117635819</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10248</id> + <version>0</version> + <ctime>1309117635819</ctime> + <mtime>1309117635819</mtime> + <propertySimple> + <id>10930</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10929</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11676_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10932</id> + <name>url</name> + <stringValue>http://$%7Bvhost2.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10931</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10050</id> + <uuid>ae880c2d-747d-492d-8586-a47ab5791b0e</uuid> + <resourceKey>${vhost1.rhq3.resource.key}</resourceKey> + <name>${vhost1.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635829</ctime> + <mtime>1309117635829</mtime> + <itime>1309117635829</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10249</id> + <version>0</version> + <ctime>1309117635829</ctime> + <mtime>1309117635829</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10250</id> + <version>0</version> + <ctime>1309117635829</ctime> + <mtime>1309117635829</mtime> + <propertySimple> + <id>10934</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10933</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10936</id> + <name>url</name> + <stringValue>http://$%7Bvhost1.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10935</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10201</id> + <version>0</version> + <ctime>1309116183368</ctime> + <mtime>1309116183368</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10211</id> + <version>0</version> + <ctime>1309117523737</ctime> + <mtime>1309117523737</mtime> + <propertySimple> + <id>10863</id> + <name>errorLogIncludesPattern</name> + </propertySimple> + <propertySimple> + <id>10862</id> + <name>errorLogMinimumSeverity</name> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10861</id> + <name>augeasEnabled</name> + <stringValue>no</stringValue> + </propertySimple> + <propertySimple> + <id>10865</id> + <name>errorLogFilePath</name> + </propertySimple> + <propertySimple> + <id>10864</id> + <name>snmpAgentCommunity</name> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10867</id> + <name>snmpAgentHost</name> + <stringValue>${unresolvable.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10866</id> + <name>errorLogEventsEnabled</name> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10869</id> + <name>controlScriptPath</name> + </propertySimple> + <propertySimple> + <id>10868</id> + <name>url</name> + <stringValue>http://$%7Bservername%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10870</id> + <name>augeasModuleName</name> + <stringValue>Httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10871</id> + <name>configFile</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10872</id> + <name>configurationFilesInclusionPatterns</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10873</id> + <name>vhostFilesMask</name> + <stringValue>${server.root}/conf/*</stringValue> + </propertySimple> + <propertySimple> + <id>10874</id> + <name>executablePath</name> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10875</id> + <name>restartAfterConfigurationUpdate</name> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10876</id> + <name>snmpAgentPort</name> + <stringValue>1610</stringValue> + </propertySimple> + <propertySimple> + <id>10877</id> + <name>serverRoot</name> + <stringValue>${server.root}</stringValue> + </propertySimple> + <propertySimple> + <id>10878</id> + <name>vhostCreationPolicy</name> + <stringValue>vhost-per-file</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/includes/inventory.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/includes/inventory.xml new file mode 100644 index 0000000..f8d181d --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/includes/inventory.xml @@ -0,0 +1,539 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10004</id> + <uuid>ae8a7a3e-256e-4c0a-9a65-33d534523d92</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost} Apache 2.2.17 (${server.root}/)</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>true</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1307353451273</ctime> + <mtime>1307353509168</mtime> + <itime>1307353509168</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10013</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10012</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10022</id> + <uuid>08290193-c716-4363-b841-8a1d9d83f580</uuid> + <resourceKey>${snmp.identifier}</resourceKey> + <name>Virtual Host ${snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587727</ctime> + <mtime>1307353587727</mtime> + <itime>1307353587721</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10137</id> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10138</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + <propertySimple> + <id>10690</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10689</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/${localhost}0_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10692</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Blocalhost%7D:0/</stringValue> + </propertySimple> + <propertySimple> + <id>10693</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>1</stringValue> + </propertySimple> + <propertySimple> + <id>10691</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>DOWN</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10021</id> + <uuid>3a20d809-7eba-422c-a3ef-baf65804498d</uuid> + <resourceKey>${vhost2.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost2.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587648</ctime> + <mtime>1307353587648</mtime> + <itime>1307353587648</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10135</id> + <version>0</version> + <ctime>1307353587666</ctime> + <mtime>1307353587666</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10136</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587667</ctime> + <mtime>1307353587667</mtime> + <propertySimple> + <id>10685</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10684</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111676_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10687</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost2.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10688</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>4</stringValue> + </propertySimple> + <propertySimple> + <id>10686</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10023</id> + <uuid>c62c5d75-81dd-4b14-a768-2d8c1fca6c88</uuid> + <resourceKey>${vhost3.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost3.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + <itime>1307353587737</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10139</id> + <version>0</version> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10140</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + <propertySimple> + <id>10695</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10694</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111677_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10697</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost3.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10698</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>3</stringValue> + </propertySimple> + <propertySimple> + <id>10696</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10024</id> + <uuid>d1b59168-8666-4bc0-957e-171bf16eec73</uuid> + <resourceKey>${vhost1.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost1.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + <itime>1307353587750</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10171</id> + <version>0</version> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10172</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + <propertySimple> + <id>10700</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10699</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10702</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost1.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10703</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>5</stringValue> + </propertySimple> + <propertySimple> + <id>10701</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10025</id> + <uuid>310281d2-60c6-4d7d-bcdc-c51d7969c906</uuid> + <resourceKey>${vhost4.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + <itime>1307353587760</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10173</id> + <version>0</version> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10174</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + <propertySimple> + <id>10705</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10704</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10707</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>2</stringValue> + </propertySimple> + <propertySimple> + <id>10706</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10142</id> + <version>0</version> + <ctime>1307353451273</ctime> + <mtime>1307353451273</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10073</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353737118</ctime> + <mtime>1307353737118</mtime> + <propertySimple> + <id>10365</id> + <name>errorLogMinimumSeverity</name> + <override>false</override> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10366</id> + <name>errorLogIncludesPattern</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10367</id> + <name>snmpAgentCommunity</name> + <override>false</override> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10368</id> + <name>errorLogFilePath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10369</id> + <name>errorLogEventsEnabled</name> + <override>false</override> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10370</id> + <name>snmpAgentHost</name> + <override>false</override> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10713</id> + <name>controlScriptPath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10714</id> + <name>url</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10364</id> + <name>configFile</name> + <override>false</override> + <stringValue>conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10711</id> + <name>executablePath</name> + <override>false</override> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10712</id> + <name>snmpAgentPort</name> + <override>false</override> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10715</id> + <name>serverRoot</name> + <override>false</override> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10003</id> + </productVersion> +</resource> +</objects> +</inventory-dump>
commit 9841eb6d2e0561a66183415a9db24bf8219d1bd1 Author: Lukas Krejci lkrejci@redhat.com Date: Thu Jun 30 10:58:26 2011 +0200
added upgrade tests for RHQ 3.0.2
diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeSimpleConfigurationFromRHQ3_0_2Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeSimpleConfigurationFromRHQ3_0_2Test.java new file mode 100644 index 0000000..2e85a4b --- /dev/null +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_2/UpgradeSimpleConfigurationFromRHQ3_0_2Test.java @@ -0,0 +1,157 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.plugins.apache.upgrade.rhq3_0_2; + +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +import org.rhq.plugins.apache.upgrade.UpgradeTestBase; +import org.rhq.test.pc.PluginContainerSetup; + +/** + * + * + * @author Lukas Krejci + */ +public class UpgradeSimpleConfigurationFromRHQ3_0_2Test extends UpgradeTestBase { + + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testWithResolvableNames(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-3.0.2/simple/inventory.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + } + }); + } + + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testWithUnresolvableNames(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-3.0.2/simple/inventory.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + + defaultOverrides.put(variableName(configurationName, "servername.directive"), + "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), + "ServerName ${unresolvable.host}:${listen1}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), + "ServerName ${unresolvable.host}:${listen2}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), + "ServerName ${unresolvable.host}:${listen3}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), + "ServerName ${unresolvable.host}:${listen4}"); + } + }); + } + + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testWithNonUniqueNames(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-3.0.2/simple/inventory.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + + defaultOverrides.put(variableName(configurationName, "servername.directive"), + "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), + "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), + "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), + "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), + "ServerName ${unresolvable.host}"); + } + }); + } + + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testWithAnyAddress(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-3.0.2/simple/inventory.xml"; + serverRoot = installPath; + binPath = exePath; + + //just define the servername value without actually setting the ${servername.directive} so that + //we don't define a servername directive itself but do have a value for the actual server name. + //this is deduced by apache and the plugin but tests aren't that clever. + defaultOverrides.put("servername", "${localhost.ip}"); + defaultOverrides.put(variableName(configurationName, "listen1"), "0.0.0.0:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "0.0.0.0:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "0.0.0.0:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "0.0.0.0:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "0.0.0.0:${port1}"); + } + }); + } + + /** + * This configuration will fail to upgrade the first vhost, because it doesn't uniquely match to new-style + * vhosts - it could be either a main vhost or vhost1. + */ + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testWithWildcardAddress(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-3.0.2/simple/inventory.xml"; + serverRoot = installPath; + binPath = exePath; + + //just define the servername value without actually setting the ${servername.directive} so that + //we don't define a servername directive itself but do have a value for the actual server name. + //this is deduced by apache and the plugin but tests aren't that clever. + defaultOverrides.put("servername", "${localhost.ip}"); + defaultOverrides.put(variableName(configurationName, "listen1"), "*:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "*:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "*:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "*:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "*:${port1}"); + } + }); + } +} diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/simple/inventory.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/simple/inventory.xml new file mode 100644 index 0000000..f8d181d --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.2/simple/inventory.xml @@ -0,0 +1,539 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10004</id> + <uuid>ae8a7a3e-256e-4c0a-9a65-33d534523d92</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost} Apache 2.2.17 (${server.root}/)</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>true</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1307353451273</ctime> + <mtime>1307353509168</mtime> + <itime>1307353509168</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10013</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10012</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10022</id> + <uuid>08290193-c716-4363-b841-8a1d9d83f580</uuid> + <resourceKey>${snmp.identifier}</resourceKey> + <name>Virtual Host ${snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587727</ctime> + <mtime>1307353587727</mtime> + <itime>1307353587721</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10137</id> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10138</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + <propertySimple> + <id>10690</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10689</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/${localhost}0_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10692</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Blocalhost%7D:0/</stringValue> + </propertySimple> + <propertySimple> + <id>10693</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>1</stringValue> + </propertySimple> + <propertySimple> + <id>10691</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>DOWN</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10021</id> + <uuid>3a20d809-7eba-422c-a3ef-baf65804498d</uuid> + <resourceKey>${vhost2.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost2.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587648</ctime> + <mtime>1307353587648</mtime> + <itime>1307353587648</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10135</id> + <version>0</version> + <ctime>1307353587666</ctime> + <mtime>1307353587666</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10136</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587667</ctime> + <mtime>1307353587667</mtime> + <propertySimple> + <id>10685</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10684</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111676_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10687</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost2.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10688</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>4</stringValue> + </propertySimple> + <propertySimple> + <id>10686</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10023</id> + <uuid>c62c5d75-81dd-4b14-a768-2d8c1fca6c88</uuid> + <resourceKey>${vhost3.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost3.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + <itime>1307353587737</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10139</id> + <version>0</version> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10140</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + <propertySimple> + <id>10695</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10694</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111677_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10697</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost3.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10698</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>3</stringValue> + </propertySimple> + <propertySimple> + <id>10696</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10024</id> + <uuid>d1b59168-8666-4bc0-957e-171bf16eec73</uuid> + <resourceKey>${vhost1.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost1.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + <itime>1307353587750</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10171</id> + <version>0</version> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10172</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + <propertySimple> + <id>10700</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10699</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10702</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost1.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10703</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>5</stringValue> + </propertySimple> + <propertySimple> + <id>10701</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10025</id> + <uuid>310281d2-60c6-4d7d-bcdc-c51d7969c906</uuid> + <resourceKey>${vhost4.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + <itime>1307353587760</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10173</id> + <version>0</version> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10174</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + <propertySimple> + <id>10705</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10704</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10707</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>2</stringValue> + </propertySimple> + <propertySimple> + <id>10706</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10142</id> + <version>0</version> + <ctime>1307353451273</ctime> + <mtime>1307353451273</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10073</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353737118</ctime> + <mtime>1307353737118</mtime> + <propertySimple> + <id>10365</id> + <name>errorLogMinimumSeverity</name> + <override>false</override> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10366</id> + <name>errorLogIncludesPattern</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10367</id> + <name>snmpAgentCommunity</name> + <override>false</override> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10368</id> + <name>errorLogFilePath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10369</id> + <name>errorLogEventsEnabled</name> + <override>false</override> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10370</id> + <name>snmpAgentHost</name> + <override>false</override> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10713</id> + <name>controlScriptPath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10714</id> + <name>url</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10364</id> + <name>configFile</name> + <override>false</override> + <stringValue>conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10711</id> + <name>executablePath</name> + <override>false</override> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10712</id> + <name>snmpAgentPort</name> + <override>false</override> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10715</id> + <name>serverRoot</name> + <override>false</override> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10003</id> + </productVersion> +</resource> +</objects> +</inventory-dump>
commit 6c2b6624c0d2e9a8ff64f6cc74264696580d5b2a Author: Lukas Krejci lkrejci@redhat.com Date: Thu Jun 30 10:58:05 2011 +0200
make the tests compile again.
diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java index 358df93..9d7e632 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java @@ -86,7 +86,7 @@ public class UpgradeTestBase extends PluginContainerTest {
private static final Log LOG = LogFactory.getLog(UpgradeTestBase.class);
- protected class TestSetup { + public class TestSetup { private String configurationName; private FakeServerInventory fakeInventory = new FakeServerInventory(); private String inventoryFile; @@ -387,7 +387,7 @@ public class UpgradeTestBase extends PluginContainerTest { } }
- protected static class TestConfiguration { + public static class TestConfiguration { public String[] apacheConfigurationFiles; public String inventoryFile; public String configurationName;
commit 10e1e2d205a9ad5f13c2e541f92e678eb059d819 Author: Lukas Krejci lkrejci@redhat.com Date: Wed Jun 29 17:11:43 2011 +0200
moved upgrade test classes to new packages so that we won't have a gazillion test classes in the root package.
diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ1_3Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ1_3Test.java deleted file mode 100644 index 8d1fe22..0000000 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ1_3Test.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2011 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.plugins.apache; - -import java.util.Comparator; -import java.util.HashMap; -import java.util.Set; -import java.util.TreeSet; - -import org.testng.annotations.Parameters; -import org.testng.annotations.Test; - -import org.rhq.core.domain.resource.Resource; -import org.rhq.test.pc.PluginContainerSetup; - -/** - * - * - * @author Lukas Krejci - */ -@Test(groups = "apache-integration-tests") -public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase { - - @Test - @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) - @Parameters({ "apache2.install.dir", "apache2.exe.path" }) - public void testWithResolvableServerNames_Apache2(final String installPath, final String exePath) - throws Throwable { - - testUpgrade(new TestConfiguration() { - { - serverRoot = installPath; - binPath = exePath; - configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-1.3.x/simple/inventory.xml"; - } - }); - } - - @Test(enabled = false) - //ApacheServerOperationsDelegate doesn't work with apache 1.3 - @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) - @Parameters({ "apache1.install.dir", "apache1.exe.path" }) - public void testWithResolvableServerNames_Apache1(final String installPath, final String exePath) - throws Throwable { - - testUpgrade(new TestConfiguration() {{ - serverRoot = installPath; - binPath = exePath; - configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - apacheConfigurationFiles = new String[] { "/full-configurations/1.3.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-1.3.x/simple/inventory.xml"; - }}); - } - - @Test - @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) - @Parameters({ "apache2.install.dir", "apache2.exe.path" }) - public void testWithNonUniqueServerNames_Apache2(final String installPath, final String exePath) throws Throwable { - testUpgrade(new TestConfiguration() { - { - configurationName = DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES; - apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-1.3.x/simple/inventory.xml"; - serverRoot = installPath; - binPath = exePath; - - - defaultOverrides = new HashMap<String, String>(); - defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); - defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}"); - defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}"); - defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}"); - defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}"); - } - - @Override - public void beforePluginContainerStart(TestSetup setup) { - //in this scenario, the RHQ 1.3 would only discover 1 vhost (and the main vhost), because they would have the same resource key - //due to the same ServerName. I need to process the default inventory to reflect that otherwise I would get upgrade - //failures. - - Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(findApachePluginResourceTypeByName("Apache Virtual Host")); - Set<Resource> uniques = new TreeSet<Resource>(new Comparator<Resource>() { - public int compare(Resource a, Resource b) { - return a.getResourceKey().compareTo(b.getResourceKey()); - } - }); - - for(Resource vhost : vhosts) { - if (uniques.contains(vhost)) { - //remove the vhost from the server's inventory - setup.getFakeInventory().removeResource(vhost); - } else { - uniques.add(vhost); - } - } - } - }); - } - - @Test - @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) - @Parameters({"apache2.install.dir", "apache2.exe.path" }) - public void testWithAnyAddress(final String installPath, final String exePath) throws Throwable { - testUpgrade(new TestConfiguration() { - { - configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; - - apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-1.3.x/simple/inventory.xml"; - serverRoot = installPath; - binPath = exePath; - - defaultOverrides = new HashMap<String, String>(); - defaultOverrides.put(variableName(configurationName, "listen1"), "0.0.0.0:${port1}"); - defaultOverrides.put(variableName(configurationName, "listen2"), "0.0.0.0:${port2}"); - defaultOverrides.put(variableName(configurationName, "listen3"), "0.0.0.0:${port3}"); - defaultOverrides.put(variableName(configurationName, "listen4"), "0.0.0.0:${port4}"); - defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "0.0.0.0:${port1}"); - } - }); - } - - @Test - @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) - @Parameters({"apache2.install.dir", "apache2.exe.path" }) - public void testWithWildcardAddress(final String installPath, final String exePath) throws Throwable { - testUpgrade(new TestConfiguration() { - { - configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; - - apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-1.3.x/simple/inventory.xml"; - serverRoot = installPath; - binPath = exePath; - - defaultOverrides = new HashMap<String, String>(); - defaultOverrides.put(variableName(configurationName, "listen1"), "*:${port1}"); - defaultOverrides.put(variableName(configurationName, "listen2"), "*:${port2}"); - defaultOverrides.put(variableName(configurationName, "listen3"), "*:${port3}"); - defaultOverrides.put(variableName(configurationName, "listen4"), "*:${port4}"); - defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "*:${port1}"); - } - }); - } -} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java deleted file mode 100644 index d3e5c86..0000000 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java +++ /dev/null @@ -1,444 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2011 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.plugins.apache; - - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.testng.annotations.Parameters; -import org.testng.annotations.Test; - -import org.rhq.core.domain.resource.Resource; -import org.rhq.core.domain.resource.ResourceError; -import org.rhq.core.domain.resource.ResourceErrorType; -import org.rhq.core.domain.resource.ResourceType; -import org.rhq.plugins.apache.parser.ApacheDirectiveTree; -import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig; -import org.rhq.plugins.apache.util.RuntimeApacheConfiguration; -import org.rhq.plugins.apache.util.VirtualHostLegacyResourceKeyUtil; -import org.rhq.test.pc.PluginContainerSetup; - -/** - * - * - * @author Lukas Krejci - */ -public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase { - - /** - * This tests the upgrade from RHQ 3.0.0 where the apache server was discovered without SNMP support. - * The Main Server URL must have been set in this case, otherwise the component would fail to start - * and therefore the vhost discovery wouldn't even take place. - */ - @Test - @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}, numberOfInitialDiscoveries = 2) - @Parameters({"apache2.install.dir", "apache2.exe.path"}) - public void testWithResolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { - testUpgrade(new TestConfiguration() { - { - apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; - inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml"; - serverRoot = installDir; - binPath = exePath; - configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - - //just define the servername value without actually setting the ${servername.directive} so that - //we don't define a servername directive itself but do have a value for the actual server name. - //this is deduced by apache and the plugin but tests aren't that clever. - defaultOverrides.put("servername", "${localhost}"); - } - }); - } - - @Test - @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}, numberOfInitialDiscoveries = 2) - @Parameters({"apache2.install.dir", "apache2.exe.path"}) - public void testWithUnresolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { - testUpgrade(new TestConfiguration() { - { - apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; - inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml"; - serverRoot = installDir; - binPath = exePath; - configurationName = DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES; - - defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); - defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}:${listen1}"); - defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}:${listen2}"); - defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}:${listen3}"); - defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}:${listen4}"); - } - }); - } - - @Test - @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}, numberOfInitialDiscoveries = 2) - @Parameters({"apache2.install.dir", "apache2.exe.path"}) - public void testWithNonUniqueNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { - testUpgrade(new TestConfiguration() { - { - apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; - inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml"; - serverRoot = installDir; - binPath = exePath; - configurationName = DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES; - - defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); - defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}"); - defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}"); - defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}"); - defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}"); - } - }); - } - - /** - * This tests the upgrade from RHQ 3.0.0 where the Apache server was discovered with the following: - * <p> - * <ol> - * <li> SNMP enabled - * <li> Main URL set or unset (it doesn't make a difference here) - * </ol> - * @param installDir - * @param exePath - * @throws Throwable - */ - @Test - @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) - @Parameters({"apache2.install.dir", "apache2.exe.path"}) - public void testWithResolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable { - testUpgrade(new TestConfiguration() { - { - apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; - inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml"; - serverRoot = installDir; - binPath = exePath; - configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - upgradeShouldSucceed = false; - } - - @Override - public void beforeTestSetup(TestSetup testSetup) throws Throwable { - beforeTestSetupWithSNMP(this, testSetup); - } - - /** - * Do our own tests here, because the generic test method won't do much, since - * we told it that the upgrade won't succeed. - */ - @Override - public void beforeTests(TestSetup setup) throws Throwable { - testWithSNMP(this, setup); - } - }); - } - - @Test - @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) - @Parameters({"apache2.install.dir", "apache2.exe.path"}) - public void testWithUnresolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable { - testUpgrade(new TestConfiguration() { - { - apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; - inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml"; - serverRoot = installDir; - binPath = exePath; - configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - upgradeShouldSucceed = false; - - defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); - defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}:${listen1}"); - defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}:${listen2}"); - defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}:${listen3}"); - defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}:${listen4}"); - } - - @Override - public void beforeTestSetup(TestSetup testSetup) throws Throwable { - beforeTestSetupWithSNMP(this, testSetup); - } - - /** - * Do our own tests here, because the generic test method won't do much, since - * we told it that the upgrade won't succeed. - */ - @Override - public void beforeTests(TestSetup setup) throws Throwable { - testWithSNMP(this, setup); - } - }); - } - - @Test - @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) - @Parameters({"apache2.install.dir", "apache2.exe.path"}) - public void testWithNonUniqueNamesWithSNMP(final String installDir, final String exePath) throws Throwable { - testUpgrade(new TestConfiguration() { - { - apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; - inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml"; - serverRoot = installDir; - binPath = exePath; - configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - upgradeShouldSucceed = false; - - defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); - defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}"); - defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}"); - defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}"); - defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}"); - } - - @Override - public void beforeTestSetup(TestSetup testSetup) throws Throwable { - beforeTestSetupWithSNMP(this, testSetup); - } - - /** - * Do our own tests here, because the generic test method won't do much, since - * we told it that the upgrade won't succeed. - */ - @Override - public void beforeTests(TestSetup setup) throws Throwable { - testWithSNMP(this, setup); - } - }); - } - - @Test - @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) - @Parameters({"apache2.install.dir", "apache2.exe.path" }) - public void testWithAnyAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable { - testUpgrade(new TestConfiguration() { - { - configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; - - apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml"; - serverRoot = installPath; - binPath = exePath; - - //just define the servername value without actually setting the ${servername.directive} so that - //we don't define a servername directive itself but do have a value for the actual server name. - //this is deduced by apache and the plugin but tests aren't that clever. - defaultOverrides.put("servername", "${localhost}"); - defaultOverrides.put(variableName(configurationName, "listen1"), "0.0.0.0:${port1}"); - defaultOverrides.put(variableName(configurationName, "listen2"), "0.0.0.0:${port2}"); - defaultOverrides.put(variableName(configurationName, "listen3"), "0.0.0.0:${port3}"); - defaultOverrides.put(variableName(configurationName, "listen4"), "0.0.0.0:${port4}"); - defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "0.0.0.0:${port1}"); - } - }); - } - - /** - * Unlike other SNMP tests this one actually succeeds to upgrade because of the messed up discovery that - * RHQ 3.0.0 would perform. In case of any-address (0.0.0.0), the main vhost would get the MainServer - * resource key even with SNMP, because RHQ 3 codebase wouldn't be able to match what it think should - * have been the SNMP record with the actual results from SNMP module. - * <p> - * Because of this, RHQ 3 discovers all 5 vhosts and the upgrade code is therefore able to successfully - * upgrade all of them. - * - * @param installPath - * @param exePath - * @throws Throwable - */ - @Test - @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) - @Parameters({"apache2.install.dir", "apache2.exe.path" }) - public void testWithAnyAddressWithSNMP(final String installPath, final String exePath) throws Throwable { - testUpgrade(new TestConfiguration() { - { - configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; - - apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp-anyaddr.xml"; - serverRoot = installPath; - binPath = exePath; - - defaultOverrides.put(variableName(configurationName, "listen1"), "0.0.0.0:${port1}"); - defaultOverrides.put(variableName(configurationName, "listen2"), "0.0.0.0:${port2}"); - defaultOverrides.put(variableName(configurationName, "listen3"), "0.0.0.0:${port3}"); - defaultOverrides.put(variableName(configurationName, "listen4"), "0.0.0.0:${port4}"); - defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "0.0.0.0:${port1}"); - } - - @Override - public void beforeTestSetup(TestSetup testSetup) throws Throwable { - beforeTestSetupWithSNMP(this, testSetup); - } - }); - } - - @Test - @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) - @Parameters({"apache2.install.dir", "apache2.exe.path" }) - public void testWithWildcardAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable { - testUpgrade(new TestConfiguration() { - { - configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; - - apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml"; - serverRoot = installPath; - binPath = exePath; - - //just define the servername value without actually setting the ${servername.directive} so that - //we don't define a servername directive itself but do have a value for the actual server name. - //this is deduced by apache and the plugin but tests aren't that clever. - defaultOverrides.put("servername", "${localhost}"); - defaultOverrides.put(variableName(configurationName, "listen1"), "*:${port1}"); - defaultOverrides.put(variableName(configurationName, "listen2"), "*:${port2}"); - defaultOverrides.put(variableName(configurationName, "listen3"), "*:${port3}"); - defaultOverrides.put(variableName(configurationName, "listen4"), "*:${port4}"); - defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "*:${port1}"); - } - }); - } - - @Test - @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) - @Parameters({"apache2.install.dir", "apache2.exe.path" }) - public void testWithWildcardAddressWithSNMP(final String installPath, final String exePath) throws Throwable { - testUpgrade(new TestConfiguration() { - { - configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; - - apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml"; - serverRoot = installPath; - binPath = exePath; - upgradeShouldSucceed = false; - - defaultOverrides.put(variableName(configurationName, "listen1"), "*:${port1}"); - defaultOverrides.put(variableName(configurationName, "listen2"), "*:${port2}"); - defaultOverrides.put(variableName(configurationName, "listen3"), "*:${port3}"); - defaultOverrides.put(variableName(configurationName, "listen4"), "*:${port4}"); - defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "*:${port1}"); - } - - @Override - public void beforeTestSetup(TestSetup testSetup) throws Throwable { - beforeTestSetupWithSNMP(this, testSetup); - } - - /** - * Do our own tests here, because the generic test method won't do much, since - * we told it that the upgrade won't succeed. - */ - @Override - public void beforeTests(TestSetup setup) throws Throwable { - testWithSNMP(this, setup); - } - }); - } - - private void beforeTestSetupWithSNMP(TestConfiguration testConfig, TestSetup setup) throws Exception { - setup.withApacheSetup().init(); - ApacheServerComponent component = setup.withApacheSetup().getExecutionUtil().getServerComponent(); - ApacheDirectiveTree config = component.loadParser(); - config = RuntimeApacheConfiguration.extract(config, component.getCurrentProcessInfo(), component.getCurrentBinaryInfo(), component.getModuleNames(), false); - - DeploymentConfig deployConfig = setup.getDeploymentConfig(); - - VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config); - - Map<String, String> replacements = deployConfig.getTokenReplacements(); - - testConfig.defaultOverrides.put("main.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyMainServerResourceKey()); - - if (deployConfig.vhost1 != null) { - testConfig.defaultOverrides.put("vhost1.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost1.getVHostSpec(replacements))); - } - - if (deployConfig.vhost2 != null) { - testConfig.defaultOverrides.put("vhost2.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost2.getVHostSpec(replacements))); - } - - if (deployConfig.vhost3 != null) { - testConfig.defaultOverrides.put("vhost3.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost3.getVHostSpec(replacements))); - } - - if (deployConfig.vhost4 != null) { - testConfig.defaultOverrides.put("vhost4.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost4.getVHostSpec(replacements))); - } - - setup.withDefaultOverrides(testConfig.defaultOverrides); - } - - private void testWithSNMP(TestConfiguration testConfig, TestSetup setup) { - //ok, now we should see the resources upgraded in the fake server inventory. - ResourceType serverResourceType = findApachePluginResourceTypeByName("Apache HTTP Server"); - ResourceType vhostResourceType = findApachePluginResourceTypeByName("Apache Virtual Host"); - - Set<Resource> servers = setup.getFakeInventory().findResourcesByType(serverResourceType); - - assertEquals(servers.size(), 1, "There should be exactly one apache server discovered."); - - Resource server = servers.iterator().next(); - - String expectedResourceKey = ApacheServerDiscoveryComponent.formatResourceKey(testConfig.serverRoot, testConfig.serverRoot - + "/conf/httpd.conf"); - - assertEquals(server.getResourceKey(), expectedResourceKey, - "The server resource key doesn't seem to be upgraded."); - - Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(vhostResourceType); - - assertEquals(vhosts.size(), 4, "Unexpected number of vhosts discovered found"); - - //let's check that the main vhost has a an upgrade error attached to it - ApacheServerComponent component = setup.withApacheSetup().getExecutionUtil().getServerComponent(); - ApacheDirectiveTree config = component.loadParser(); - config = RuntimeApacheConfiguration.extract(config, component.getCurrentProcessInfo(), component.getCurrentBinaryInfo(), component.getModuleNames(), false); - VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config); - - String mainVhostRK = keyUtil.getRHQ3NonSNMPLegacyMainServerResourceKey(); - - Resource mainVhost = null; - for(Resource r : vhosts) { - if (mainVhostRK.equals(r.getResourceKey())) { - mainVhost = r; - break; - } - } - - assertNotNull(mainVhost, "Couldn't find the main vhost with the expected resource key '" + mainVhostRK + "'."); - - List<ResourceError> errors = mainVhost.getResourceErrors(ResourceErrorType.UPGRADE); - assertNotNull(errors, "The main vhost doesn't have any upgrade errors."); - assertEquals(errors.size(), 1, "There should be exactly one upgrade error on the main vhost."); - - //check that all other vhosts were not upgraded but have no errors - for(Resource r : vhosts) { - if (r.equals(mainVhost)) { - continue; - } - - assertEquals(r.getResourceErrors(ResourceErrorType.UPGRADE).size(), 0, "Unexpected number of resource upgrade errors on non-main vhost " + r); - } - } -} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java deleted file mode 100644 index b43d3f3..0000000 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java +++ /dev/null @@ -1,549 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2011 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.plugins.apache; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import java.io.StringReader; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.testng.annotations.Parameters; -import org.testng.annotations.Test; - -import org.rhq.core.domain.resource.Resource; -import org.rhq.core.domain.resource.ResourceError; -import org.rhq.core.domain.resource.ResourceErrorType; -import org.rhq.core.domain.resource.ResourceType; -import org.rhq.core.util.stream.StreamUtil; -import org.rhq.plugins.apache.parser.ApacheDirectiveTree; -import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig; -import org.rhq.plugins.apache.util.RuntimeApacheConfiguration; -import org.rhq.plugins.apache.util.VirtualHostLegacyResourceKeyUtil; -import org.rhq.test.TokenReplacingReader; -import org.rhq.test.pc.PluginContainerSetup; - -/** - * - * - * @author Lukas Krejci - */ -public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase { - - @Test - @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) - @Parameters({"apache2.install.dir", "apache2.exe.path"}) - public void testWithResolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable { - testUpgrade(new TestConfiguration() { - { - apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; - inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml"; - serverRoot = installDir; - binPath = exePath; - configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - upgradeShouldSucceed = false; - } - - @Override - public void beforeTestSetup(TestSetup testSetup) throws Throwable { - defineRHQ3ResourceKeys(this, testSetup); - } - - /** - * Do our own tests here, because the generic test method won't do much, since - * we told it that the upgrade won't succeed. - */ - @Override - public void beforeTests(TestSetup setup) throws Throwable { - String failingRK = interpret("${main.rhq3.resource.key}", setup.getInventoryFileReplacements()); - testExpectedFailures(this, setup, 4, failingRK); - } - }); - } - - @Test - @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) - @Parameters({"apache2.install.dir", "apache2.exe.path"}) - public void testWithResolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { - testUpgrade(new TestConfiguration() { - { - apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; - inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-without-snmp.xml"; - serverRoot = installDir; - binPath = exePath; - configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - upgradeShouldSucceed = false; - - //just define the servername value without actually setting the ${servername.directive} so that - //we don't define a servername directive itself but do have a value for the actual server name. - //this is deduced by apache and the plugin but tests aren't that clever. - defaultOverrides.put("servername", "${localhost.ip}"); - } - - @Override - public void beforeTestSetup(TestSetup testSetup) throws Throwable { - defineRHQ3ResourceKeys(this, testSetup); - } - - @Override - public void beforeTests(TestSetup setup) throws Throwable { - String vhost1RK = interpret("${vhost1.rhq3.resource.key}", setup.getInventoryFileReplacements()); - testExpectedFailures(this, setup, 5, vhost1RK); - } - }); - } - - @Test - @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) - @Parameters({"apache2.install.dir", "apache2.exe.path"}) - public void testWithUnresolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable { - testUpgrade(new TestConfiguration() { - { - apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; - inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml"; - serverRoot = installDir; - binPath = exePath; - configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - upgradeShouldSucceed = false; - - defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); - defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}:${listen1}"); - defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}:${listen2}"); - defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}:${listen3}"); - defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}:${listen4}"); - } - - @Override - public void beforeTestSetup(TestSetup testSetup) throws Throwable { - defineRHQ3ResourceKeys(this, testSetup); - } - - /** - * Do our own tests here, because the generic test method won't do much, since - * we told it that the upgrade won't succeed. - */ - @Override - public void beforeTests(TestSetup setup) throws Throwable { - String failingRK = interpret("${main.rhq3.resource.key}", setup.getInventoryFileReplacements()); - testExpectedFailures(this, setup, 4, failingRK); - } - }); - } - - @Test - @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) - @Parameters({"apache2.install.dir", "apache2.exe.path"}) - public void testWithUnresolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { - testUpgrade(new TestConfiguration() { - { - apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; - inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-without-snmp.xml"; - serverRoot = installDir; - binPath = exePath; - configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - - defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); - //we use this in the serialized inventory to init the URL of the main server. The localhost.ip is actually what - //the RHQ 301 discovers even though unresolvable.host is specified in the ServerName directive. - defaultOverrides.put("servername", "${localhost.ip}"); - defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}:${port1}"); - defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}:${port2}"); - defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}:${port3}"); - defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}:${port4}"); - } - - @Override - public void beforeTestSetup(TestSetup testSetup) throws Throwable { - defineRHQ3ResourceKeys(this, testSetup); - } - }); - } - - @Test - @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) - @Parameters({"apache2.install.dir", "apache2.exe.path"}) - public void testWithNonUniqueNamesWithSNMP(final String installDir, final String exePath) throws Throwable { - testUpgrade(new TestConfiguration() { - { - apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; - inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml"; - serverRoot = installDir; - binPath = exePath; - configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - upgradeShouldSucceed = false; - - defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); - defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}"); - defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}"); - defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}"); - defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}"); - } - - @Override - public void beforeTestSetup(TestSetup testSetup) throws Throwable { - defineRHQ3ResourceKeys(this, testSetup); - } - - /** - * Do our own tests here, because the generic test method won't do much, since - * we told it that the upgrade won't succeed. - */ - @Override - public void beforeTests(TestSetup setup) throws Throwable { - String failingRK = interpret("${main.rhq3.resource.key}", setup.getInventoryFileReplacements()); - testExpectedFailures(this, setup, 4, failingRK); - } - }); - } - - @Test - @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) - @Parameters({"apache2.install.dir", "apache2.exe.path"}) - public void testWithNonUniqueNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { - testUpgrade(new TestConfiguration() { - { - apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-without-snmp.xml"; - serverRoot = installDir; - binPath = exePath; - configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - - //we use this in the serialized inventory to init the URL of the main server. The localhost.ip is actually what - //the RHQ 301 discovers even though unresolvable.host is specified in the ServerName directive. - defaultOverrides.put("servername", "${localhost.ip}"); - defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); - defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), - "ServerName ${unresolvable.host}"); - defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), - "ServerName ${unresolvable.host}"); - defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), - "ServerName ${unresolvable.host}"); - defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), - "ServerName ${unresolvable.host}"); - } - - @Override - public void beforeTestSetup(TestSetup testSetup) throws Throwable { - defineRHQ3ResourceKeys(this, testSetup); - } - }); - } - - /** - * The duplicate Main vhosts "condition" was triggered by: - * <ol> - * <li>Disabling SNMP by putting in an invalid hostname - * <li>Changing the URL of the apache server to some "other" value - * <li>Running discovery - * </ol> - * From that point on, 2 Main vhosts live in the inventory and the inventory has the "rest" - * of the resource keys coming from the SNMP based discovery. - * <p> - * It is not possible to recover from such condition automatically during - * the resource upgrade, so the only thing we need to check here is that - * the two main vhosts are marked as failed upgrade and that the rest of the vhosts - * are not upgraded and have no upgrade errors attached. - * - * @param installDir - * @param exePath - * @throws Throwable - */ - @Test - @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) - @Parameters({"apache2.install.dir", "apache2.exe.path"}) - public void testDuplicateMainVhostsMarkedAsFailedUpgrade(final String installDir, final String exePath) throws Throwable { - testUpgrade(new TestConfiguration() { - { - apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; - inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-duplicate-main.xml"; - serverRoot = installDir; - binPath = exePath; - configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - upgradeShouldSucceed = false; - } - - @Override - public void beforeTestSetup(TestSetup testSetup) throws Throwable { - defineRHQ3ResourceKeys(this, testSetup); - } - - /** - * Do our own tests here, because the generic test method won't do much, since - * we told it that the upgrade won't succeed. - */ - @Override - public void beforeTests(TestSetup setup) throws Throwable { - String mainVHost1RK = interpret("${main.rhq3.resource.key}", setup.getInventoryFileReplacements()); - String mainVhost2RK = interpret("${localhost}:${port1}", setup.getInventoryFileReplacements()); - - testExpectedFailures(this, setup, 5, mainVHost1RK, mainVhost2RK); - } - }); - } - - @Test - @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) - @Parameters({"apache2.install.dir", "apache2.exe.path" }) - public void testWithAnyAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable { - testUpgrade(new TestConfiguration() { - { - configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; - - apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - //yes, the inventory file can be the same for both the with and without snmp tests because - //they both yield the same inventory in this case. - inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp-anyaddr.xml"; - serverRoot = installPath; - binPath = exePath; - - //just define the servername value without actually setting the ${servername.directive} so that - //we don't define a servername directive itself but do have a value for the actual server name. - //this is deduced by apache and the plugin but tests aren't that clever. - defaultOverrides.put("servername", "${localhost.ip}"); - defaultOverrides.put(variableName(configurationName, "listen1"), "0.0.0.0:${port1}"); - defaultOverrides.put(variableName(configurationName, "listen2"), "0.0.0.0:${port2}"); - defaultOverrides.put(variableName(configurationName, "listen3"), "0.0.0.0:${port3}"); - defaultOverrides.put(variableName(configurationName, "listen4"), "0.0.0.0:${port4}"); - defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "0.0.0.0:${port1}"); - } - - @Override - public void beforeTestSetup(TestSetup testSetup) throws Throwable { - defineRHQ3ResourceKeys(this, testSetup); - } - }); - } - - /** - * Unlike other SNMP tests this one actually succeeds to upgrade because of the messed up discovery that - * RHQ 3.0.0 would perform. In case of any-address (0.0.0.0), the main vhost would get the MainServer - * resource key even with SNMP, because RHQ 3 codebase wouldn't be able to match what it think should - * have been the SNMP record with the actual results from SNMP module. - * <p> - * Because of this, RHQ 3 discovers all 5 vhosts and the upgrade code is therefore able to successfully - * upgrade all of them. - * - * @param installPath - * @param exePath - * @throws Throwable - */ - @Test - @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) - @Parameters({"apache2.install.dir", "apache2.exe.path" }) - public void testWithAnyAddressWithSNMP(final String installPath, final String exePath) throws Throwable { - testUpgrade(new TestConfiguration() { - { - configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; - - apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp-anyaddr.xml"; - serverRoot = installPath; - binPath = exePath; - - defaultOverrides.put(variableName(configurationName, "listen1"), "0.0.0.0:${port1}"); - defaultOverrides.put(variableName(configurationName, "listen2"), "0.0.0.0:${port2}"); - defaultOverrides.put(variableName(configurationName, "listen3"), "0.0.0.0:${port3}"); - defaultOverrides.put(variableName(configurationName, "listen4"), "0.0.0.0:${port4}"); - defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "0.0.0.0:${port1}"); - } - - @Override - public void beforeTestSetup(TestSetup testSetup) throws Throwable { - defineRHQ3ResourceKeys(this, testSetup); - } - }); - } - - /** - * This configuration will fail to upgrade the first vhost, because it doesn't uniquely match to new-style - * vhosts - it could be either a main vhost or vhost1. - */ - @Test - @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) - @Parameters({"apache2.install.dir", "apache2.exe.path" }) - public void testWithWildcardAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable { - testUpgrade(new TestConfiguration() { - { - configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; - - apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-without-snmp.xml"; - serverRoot = installPath; - binPath = exePath; - upgradeShouldSucceed = false; - - //just define the servername value without actually setting the ${servername.directive} so that - //we don't define a servername directive itself but do have a value for the actual server name. - //this is deduced by apache and the plugin but tests aren't that clever. - defaultOverrides.put("servername", "${localhost.ip}"); - defaultOverrides.put(variableName(configurationName, "listen1"), "*:${port1}"); - defaultOverrides.put(variableName(configurationName, "listen2"), "*:${port2}"); - defaultOverrides.put(variableName(configurationName, "listen3"), "*:${port3}"); - defaultOverrides.put(variableName(configurationName, "listen4"), "*:${port4}"); - defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "*:${port1}"); - } - - @Override - public void beforeTestSetup(TestSetup testSetup) throws Throwable { - defineRHQ3ResourceKeys(this, testSetup); - } - - @Override - public void beforeTests(TestSetup setup) throws Throwable { - String failingRK = interpret("${vhost1.rhq3.resource.key}", setup.getInventoryFileReplacements()); - testExpectedFailures(this, setup, 5, failingRK); - } - }); - } - - @Test - @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) - @Parameters({"apache2.install.dir", "apache2.exe.path" }) - public void testWithWildcardAddressWithSNMP(final String installPath, final String exePath) throws Throwable { - testUpgrade(new TestConfiguration() { - { - configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; - - apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; - inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml"; - serverRoot = installPath; - binPath = exePath; - upgradeShouldSucceed = false; - - defaultOverrides.put(variableName(configurationName, "listen1"), "*:${port1}"); - defaultOverrides.put(variableName(configurationName, "listen2"), "*:${port2}"); - defaultOverrides.put(variableName(configurationName, "listen3"), "*:${port3}"); - defaultOverrides.put(variableName(configurationName, "listen4"), "*:${port4}"); - defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "*:${port1}"); - } - - @Override - public void beforeTestSetup(TestSetup testSetup) throws Throwable { - defineRHQ3ResourceKeys(this, testSetup); - } - - /** - * Do our own tests here, because the generic test method won't do much, since - * we told it that the upgrade won't succeed. - */ - @Override - public void beforeTests(TestSetup setup) throws Throwable { - String failingRK = interpret("${main.rhq3.resource.key}", setup.getInventoryFileReplacements()); - testExpectedFailures(this, setup, 4, failingRK); - } - }); - } - - private void defineRHQ3ResourceKeys(TestConfiguration testConfig, TestSetup setup) throws Exception { - setup.withApacheSetup().init(); - ApacheServerComponent component = setup.withApacheSetup().getExecutionUtil().getServerComponent(); - ApacheDirectiveTree config = component.loadParser(); - config = RuntimeApacheConfiguration.extract(config, component.getCurrentProcessInfo(), component.getCurrentBinaryInfo(), component.getModuleNames(), false); - - DeploymentConfig deployConfig = setup.getDeploymentConfig(); - - VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config); - - Map<String, String> replacements = deployConfig.getTokenReplacements(); - - testConfig.defaultOverrides.put("main.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyMainServerResourceKey()); - - if (deployConfig.vhost1 != null) { - testConfig.defaultOverrides.put("vhost1.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost1.getVHostSpec(replacements))); - } - - if (deployConfig.vhost2 != null) { - testConfig.defaultOverrides.put("vhost2.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost2.getVHostSpec(replacements))); - } - - if (deployConfig.vhost3 != null) { - testConfig.defaultOverrides.put("vhost3.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost3.getVHostSpec(replacements))); - } - - if (deployConfig.vhost4 != null) { - testConfig.defaultOverrides.put("vhost4.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost4.getVHostSpec(replacements))); - } - - setup.withDefaultOverrides(testConfig.defaultOverrides); - } - - private void testExpectedFailures(TestConfiguration testConfig, TestSetup setup, int numberOfVhosts, String... failingRKs) { - //ok, now we should see the resources upgraded in the fake server inventory. - ResourceType serverResourceType = findApachePluginResourceTypeByName("Apache HTTP Server"); - ResourceType vhostResourceType = findApachePluginResourceTypeByName("Apache Virtual Host"); - - Set<Resource> servers = setup.getFakeInventory().findResourcesByType(serverResourceType); - - assertEquals(servers.size(), 1, "There should be exactly one apache server discovered."); - - Resource server = servers.iterator().next(); - - String expectedResourceKey = ApacheServerDiscoveryComponent.formatResourceKey(testConfig.serverRoot, testConfig.serverRoot - + "/conf/httpd.conf"); - - assertEquals(server.getResourceKey(), expectedResourceKey, - "The server resource key doesn't seem to be upgraded."); - - Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(vhostResourceType); - - assertEquals(vhosts.size(), numberOfVhosts, "Unexpected number of vhosts discovered found"); - - //let's check that the main vhost has a an upgrade error attached to it - ApacheServerComponent component = setup.withApacheSetup().getExecutionUtil().getServerComponent(); - ApacheDirectiveTree config = component.loadParser(); - config = RuntimeApacheConfiguration.extract(config, component.getCurrentProcessInfo(), component.getCurrentBinaryInfo(), component.getModuleNames(), false); - VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config); - - Set<Resource> failingResources = new HashSet<Resource>(); - - for(String rk : failingRKs) { - for(Resource r : vhosts) { - if (rk.equals(r.getResourceKey())) { - failingResources.add(r); - break; - } - } - } - - assertEquals(failingResources.size(), failingRKs.length, "Couldn't find all the resources that should have failed."); - - for(Resource failingResource : failingResources) { - List<ResourceError> errors = failingResource.getResourceErrors(ResourceErrorType.UPGRADE); - assertNotNull(errors, "The main vhost doesn't have any upgrade errors."); - assertEquals(errors.size(), 1, "There should be exactly one upgrade error on the main vhost."); - } - - //check that all other vhosts were not upgraded but have no errors - for(Resource r : vhosts) { - if (failingResources.contains(r)) { - continue; - } - - assertEquals(r.getResourceErrors(ResourceErrorType.UPGRADE).size(), 0, "Unexpected number of resource upgrade errors on non-main vhost " + r); - } - } - - private String interpret(String string, Map<String, String> variables) { - return StreamUtil.slurp(new TokenReplacingReader(new StringReader(string), variables)); - } -} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java deleted file mode 100644 index 831b2d8..0000000 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java +++ /dev/null @@ -1,596 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2011 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.plugins.apache; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import java.io.File; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.net.InetAddress; -import java.net.URI; -import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jmock.Expectations; -import org.testng.annotations.BeforeClass; - -import org.rhq.core.clientapi.agent.metadata.PluginMetadataParser; -import org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil; -import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor; -import org.rhq.core.clientapi.server.discovery.InventoryReport; -import org.rhq.core.domain.discovery.AvailabilityReport; -import org.rhq.core.domain.resource.InventoryStatus; -import org.rhq.core.domain.resource.Resource; -import org.rhq.core.domain.resource.ResourceError; -import org.rhq.core.domain.resource.ResourceType; -import org.rhq.core.pc.ServerServices; -import org.rhq.core.pc.upgrade.FakeServerInventory; -import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; -import org.rhq.core.pluginapi.inventory.PluginContainerDeployment; -import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; -import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; -import org.rhq.core.system.SystemInfoFactory; -import org.rhq.plugins.apache.parser.ApacheConfigReader; -import org.rhq.plugins.apache.parser.ApacheDirectiveTree; -import org.rhq.plugins.apache.parser.ApacheParser; -import org.rhq.plugins.apache.parser.ApacheParserImpl; -import org.rhq.plugins.apache.util.ApacheDeploymentUtil; -import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig; -import org.rhq.plugins.apache.util.ApacheExecutionUtil; -import org.rhq.plugins.apache.util.HttpdAddressUtility; -import org.rhq.plugins.apache.util.VHostSpec; -import org.rhq.test.ObjectCollectionSerializer; -import org.rhq.test.TokenReplacingReader; -import org.rhq.test.pc.PluginContainerTest; - - -/** - * Base class for the upgrade test classes. - * - * @author Lukas Krejci - */ -public class UpgradeTestBase extends PluginContainerTest { - - private static final Log LOG = LogFactory.getLog(UpgradeTestBase.class); - - protected class TestSetup { - private String configurationName; - private FakeServerInventory fakeInventory = new FakeServerInventory(); - private String inventoryFile; - private Resource platform; - private ApacheSetup apacheSetup = new ApacheSetup(); - private DeploymentConfig deploymentConfig; - private Map<String, String> defaultOverrides = new HashMap<String, String>(); - private Map<String, String> inventoryFileReplacements; - - public class ApacheSetup { - private String serverRoot; - private String exePath; - private Collection<String> configurationFiles; - private ApacheExecutionUtil execution; - private boolean deploy = true; - - private ApacheSetup() { - - } - - public ApacheSetup withServerRoot(String serverRoot) { - this.serverRoot = serverRoot; - //auto-define the server root property as if it was passed on the commandline - System.getProperties().put(configurationName + ".server.root", serverRoot); - deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName, defaultOverrides); - return this; - } - - public ApacheSetup withExePath(String exePath) { - this.exePath = exePath; - return this; - } - - public ApacheSetup withConfigurationFiles(String... classPathUris) { - return withConfigurationFiles(Arrays.asList(classPathUris)); - } - - public ApacheSetup withConfigurationFiles(Collection<String> classPathUris) { - this.configurationFiles = classPathUris; - return this; - } - - public ApacheSetup withDeploymentOnSetup() { - this.deploy = true; - return this; - } - - public ApacheSetup withNoDeploymentOnSetup() { - this.deploy = false; - return this; - } - - public ApacheExecutionUtil getExecutionUtil() { - return execution; - } - - public void init() throws Exception { - File serverRootDir = new File(serverRoot); - - assertTrue(serverRootDir.exists(), "The configured server root denotes a non-existant directory: '" - + serverRootDir + "'."); - - File confDir = new File(serverRootDir, "conf"); - - assertTrue(confDir.exists(), - "The configured server root denotes a directory that doesn't have a 'conf' subdirectory. This is unexpected."); - - String confFilePath = confDir.getAbsolutePath() + File.separatorChar + "httpd.conf"; - - String snmpHost = null; - int snmpPort = 0; - String pingUrl = null; - - if (configurationName != null) { - if (deploy) { - ApacheDeploymentUtil.deployConfiguration(confDir, configurationFiles, deploymentConfig); - } - - //ok, now try to find the ping URL. The best thing is to actually invoke - //the same code the apache server discovery does. - ApacheDirectiveTree tree = new ApacheDirectiveTree(); - ApacheParser parser = new ApacheParserImpl(tree, serverRootDir.getAbsolutePath()); - ApacheConfigReader.buildTree(confFilePath, parser); - - //XXX this hardcodes apache2 as the only option we have... - HttpdAddressUtility.Address addrToUse = HttpdAddressUtility.APACHE_2_x.getMainServerSampleAddress(tree, null, -1); - pingUrl = addrToUse.toString(); - - snmpHost = deploymentConfig.snmpHost; - snmpPort = deploymentConfig.snmpPort; - } - - execution = new ApacheExecutionUtil(findApachePluginResourceTypeByName("Apache HTTP Server"), - serverRoot, exePath, confFilePath, pingUrl, - snmpHost, snmpPort); - execution.init(); - } - - private void doSetup() throws Exception { - init(); - execution.invokeOperation("start"); - } - - public TestSetup setup() throws Exception { - return TestSetup.this.setup(); - } - } - - public TestSetup(String configurationName) { - this.configurationName = configurationName; - deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName, defaultOverrides); - } - - public TestSetup withInventoryFrom(String classPathUri) { - inventoryFile = classPathUri; - return this; - } - - public TestSetup withDefaultOverrides(Map<String, String> defaultOverrides) { - this.defaultOverrides = defaultOverrides == null ? new HashMap<String, String>() : defaultOverrides; - deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName, this.defaultOverrides); - return this; - } - - public TestSetup withPlatformResource(Resource platform) { - this.platform = platform; - return this; - } - - public ApacheSetup withApacheSetup() { - return apacheSetup; - } - - public TestSetup withDefaultExpectations() throws Exception { - context.checking(new Expectations() { - { - addDefaultExceptations(this); - } - }); - - return this; - } - - @SuppressWarnings("unchecked") - public void addDefaultExceptations(Expectations expectations) throws Exception { - ServerServices ss = getCurrentPluginContainerConfiguration().getServerServices(); - - expectations.allowing(ss.getDiscoveryServerService()).mergeInventoryReport( - expectations.with(Expectations.any(InventoryReport.class))); - expectations.will(fakeInventory.mergeInventoryReport(InventoryStatus.COMMITTED)); - - expectations.allowing(ss.getDiscoveryServerService()).upgradeResources( - expectations.with(Expectations.any(Set.class))); - expectations.will(fakeInventory.upgradeResources()); - - expectations.allowing(ss.getDiscoveryServerService()).getResources( - expectations.with(Expectations.any(Set.class)), expectations.with(Expectations.any(boolean.class))); - expectations.will(fakeInventory.getResources()); - - expectations.allowing(ss.getDiscoveryServerService()).setResourceError(expectations.with(Expectations.any(ResourceError.class))); - expectations.will(fakeInventory.setResourceError()); - - expectations.allowing(ss.getDiscoveryServerService()).mergeAvailabilityReport( - expectations.with(Expectations.any(AvailabilityReport.class))); - - expectations.allowing(ss.getDiscoveryServerService()).postProcessNewlyCommittedResources( - expectations.with(Expectations.any(Set.class))); - - expectations.allowing(ss.getDiscoveryServerService()).clearResourceConfigError( - expectations.with(Expectations.any(int.class))); - - expectations.ignoring(ss.getBundleServerService()); - expectations.ignoring(ss.getConfigurationServerService()); - expectations.ignoring(ss.getContentServerService()); - expectations.ignoring(ss.getCoreServerService()); - expectations.ignoring(ss.getEventServerService()); - expectations.ignoring(ss.getMeasurementServerService()); - expectations.ignoring(ss.getOperationServerService()); - expectations.ignoring(ss.getResourceFactoryServerService()); - } - - public FakeServerInventory getFakeInventory() { - return fakeInventory; - } - - public DeploymentConfig getDeploymentConfig() { - return deploymentConfig; - } - - public TestSetup setup() throws Exception { - apacheSetup.doSetup(); - - Map<String, String> replacements = deploymentConfig.getTokenReplacements(); - replacements.put("server.root", apacheSetup.serverRoot); - replacements.put("exe.path", apacheSetup.exePath); - - ApacheDeploymentUtil.addDefaultVariables(replacements, null); - - HttpdAddressUtility addressUtility = apacheSetup.getExecutionUtil().getServerComponent() - .getAddressUtility(); - ApacheDirectiveTree runtimeConfig = apacheSetup.getExecutionUtil().getRuntimeConfiguration(); - - replacements.put("snmp.identifier", - addressUtility.getHttpdInternalMainServerAddressRepresentation(runtimeConfig).toString(false, false)); - - replacements.put("main.rhq4.resource.key", ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY); - - VHostSpec vhost1 = deploymentConfig.vhost1 == null ? null : deploymentConfig.vhost1.getVHostSpec(replacements); - VHostSpec vhost2 = deploymentConfig.vhost2 == null ? null : deploymentConfig.vhost2.getVHostSpec(replacements); - VHostSpec vhost3 = deploymentConfig.vhost3 == null ? null : deploymentConfig.vhost3.getVHostSpec(replacements); - VHostSpec vhost4 = deploymentConfig.vhost4 == null ? null : deploymentConfig.vhost4.getVHostSpec(replacements); - - if (vhost1 != null) { - replacements.put( - "vhost1.snmp.identifier", - addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost1.hosts.get(0), - vhost1.serverName).toString(false, false)); - - replacements.put( - "vhost1.rhq4.resource.key", - ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - vhost1.serverName, vhost1.hosts)); - } - - if (vhost2 != null) { - replacements.put( - "vhost2.snmp.identifier", - addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost2.hosts.get(0), - vhost2.serverName).toString(false, false)); - - replacements.put( - "vhost2.rhq4.resource.key", - ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - vhost2.serverName, vhost2.hosts)); - } - - if (vhost3 != null) { - replacements.put( - "vhost3.snmp.identifier", - addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost3.hosts.get(0), - vhost3.serverName).toString(false, false)); - - replacements.put( - "vhost3.rhq4.resource.key", - ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - vhost3.serverName, vhost3.hosts)); - } - - if (vhost4 != null) { - replacements.put( - "vhost4.snmp.identifier", - addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost4.hosts.get(0), - vhost4.serverName).toString(false, false)); - - replacements.put( - "vhost4.rhq4.resource.key", - ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - vhost4.serverName, vhost4.hosts)); - } - - //let the user override everything we just did - replacements.putAll(defaultOverrides); - - inventoryFileReplacements = replacements; - - InputStream dataStream = getClass().getResourceAsStream(inventoryFile); - - Reader rdr = new TokenReplacingReader(new InputStreamReader(dataStream), replacements); - - @SuppressWarnings("unchecked") - List<Resource> inventory = (List<Resource>) new ObjectCollectionSerializer().deserialize(rdr); - - //fix up the parent relationships, because they might not be reconstructed correctly by - //JAXB - we're missing XmlID and XmlIDRef annotations in our model - fixupParent(null, inventory); - - fakeInventory.prepopulateInventory(platform, inventory); - - return this; - } - - /** - * After the setup, this returns all the variables used to update the tokens in the inventory file. - * - * @return - */ - public Map<String, String> getInventoryFileReplacements() { - return inventoryFileReplacements; - } - - private void fixupParent(Resource parent, Collection<Resource> children) { - for (Resource child : children) { - child.setParentResource(parent); - if (child.getChildResources() != null) { - fixupParent(child, child.getChildResources()); - } - } - } - } - - protected static class TestConfiguration { - public String[] apacheConfigurationFiles; - public String inventoryFile; - public String configurationName; - public String serverRoot; - public String binPath; - public Map<String, String> defaultOverrides = new HashMap<String, String>(); - public boolean upgradeShouldSucceed = true; - - public void beforeTestSetup(TestSetup testSetup) throws Throwable { - - } - - public void beforePluginContainerStart(TestSetup setup) throws Throwable { - - } - - public void beforeTests(TestSetup setup) throws Throwable { - - } - } - - protected static final String PLATFORM_PLUGIN = "file:target/itest/plugins/rhq-platform-plugin-for-apache-test.jar"; - protected static final String AUGEAS_PLUGIN = "file:target/itest/plugins/rhq-augeas-plugin-for-apache-test.jar"; - protected static final String APACHE_PLUGIN = "file:target/itest/plugins/rhq-apache-plugin-for-apache-test.jar"; - - protected static final String DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES = "simpleWithResolvableServerNames"; - protected static final String DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES = "simpleWithUnresolvableServerNames"; - protected static final String DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS = "simpleWithWildcardListens"; - - private List<ResourceType> resourceTypesInApachePlugin; - protected Resource platform; - - @BeforeClass - public void parseResourceTypesFromApachePlugin() throws Exception { - resourceTypesInApachePlugin = getResourceTypesInPlugin(APACHE_PLUGIN); - platform = discoverPlatform(); - } - - protected ResourceType findApachePluginResourceTypeByName(String resourceTypeName) { - for (ResourceType rt : resourceTypesInApachePlugin) { - if (resourceTypeName.equals(rt.getName())) { - return rt; - } - } - - return null; - } - - protected void testUpgrade(TestConfiguration testConfiguration) throws Throwable { - final TestSetup setup = new TestSetup(testConfiguration.configurationName); - boolean testFailed = false; - try { - - String[] configFiles = Arrays.copyOf(testConfiguration.apacheConfigurationFiles, testConfiguration.apacheConfigurationFiles.length + 2); - configFiles[testConfiguration.apacheConfigurationFiles.length] = "/snmpd.conf"; - configFiles[testConfiguration.apacheConfigurationFiles.length + 1] = "/mime.types"; - - setup.withInventoryFrom(testConfiguration.inventoryFile) - .withPlatformResource(platform).withDefaultExpectations().withDefaultOverrides(testConfiguration.defaultOverrides) - .withApacheSetup().withConfigurationFiles(configFiles) - .withServerRoot(testConfiguration.serverRoot).withExePath(testConfiguration.binPath); - - testConfiguration.beforeTestSetup(setup); - - setup.setup(); - - testConfiguration.beforePluginContainerStart(setup); - - startConfiguredPluginContainer(); - - testConfiguration.beforeTests(setup); - - if (!testConfiguration.upgradeShouldSucceed) { - return; - } - - //ok, now we should see the resources upgraded in the fake server inventory. - ResourceType serverResourceType = findApachePluginResourceTypeByName("Apache HTTP Server"); - ResourceType vhostResourceType = findApachePluginResourceTypeByName("Apache Virtual Host"); - - Set<Resource> servers = setup.getFakeInventory().findResourcesByType(serverResourceType); - - assertEquals(servers.size(), 1, "There should be exactly one apache server discovered."); - - Resource server = servers.iterator().next(); - - String expectedResourceKey = ApacheServerDiscoveryComponent.formatResourceKey(testConfiguration.serverRoot, testConfiguration.serverRoot - + "/conf/httpd.conf"); - - assertEquals(server.getResourceKey(), expectedResourceKey, - "The server resource key doesn't seem to be upgraded."); - - Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(vhostResourceType); - - assertEquals(vhosts.size(), 5, "Unexpected number of vhosts discovered found"); - - List<String> expectedResourceKeys = new ArrayList<String>(5); - - DeploymentConfig dc = setup.getDeploymentConfig(); - Map<String, String> replacements = dc.getTokenReplacements(); - - VHostSpec vh1 = dc.vhost1.getVHostSpec(replacements); - VHostSpec vh2 = dc.vhost2.getVHostSpec(replacements); - VHostSpec vh3 = dc.vhost3.getVHostSpec(replacements); - VHostSpec vh4 = dc.vhost4.getVHostSpec(replacements); - - expectedResourceKeys.add(ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY); - expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - vh1.serverName, vh1.hosts)); - expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - vh2.serverName, vh2.hosts)); - expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - vh3.serverName, vh3.hosts)); - expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - vh4.serverName, vh4.hosts)); - - for (Resource vhost : vhosts) { - assertTrue(expectedResourceKeys.contains(vhost.getResourceKey()), - "Unexpected virtual host resource key: '" + vhost.getResourceKey() + "'. Only expecting " + expectedResourceKeys); - } - } catch (Throwable t) { - testFailed = true; - LOG.error("Error during test upgrade execution.", t); - throw t; - } finally { - try { - setup.withApacheSetup().getExecutionUtil().invokeOperation("stop"); - } catch (Exception e) { - if (testFailed) { - LOG.error("Failed to stop apache.", e); - } else { - throw e; - } - } - } - } - - private static List<ResourceType> getResourceTypesInPlugin(String pluginUri) throws Exception { - PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(new URI(pluginUri).toURL()); - PluginMetadataParser parser = new PluginMetadataParser(descriptor, - Collections.<String, PluginMetadataParser> emptyMap()); - - return parser.getAllTypes(); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - private static Resource discoverPlatform() throws Exception { - PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(new URI(PLATFORM_PLUGIN) - .toURL()); - PluginMetadataParser parser = new PluginMetadataParser(descriptor, - Collections.<String, PluginMetadataParser> emptyMap()); - - List<ResourceType> platformTypes = parser.getAllTypes(); - - for (ResourceType rt : platformTypes) { - Class discoveryClass = Class.forName(parser.getDiscoveryComponentClass(rt)); - - ResourceDiscoveryComponent discoveryComponent = (ResourceDiscoveryComponent) discoveryClass.newInstance(); - - ResourceDiscoveryContext context = new ResourceDiscoveryContext(rt, null, null, - SystemInfoFactory.createSystemInfo(), null, null, PluginContainerDeployment.AGENT); - - Set<DiscoveredResourceDetails> results = discoveryComponent.discoverResources(context); - - if (!results.isEmpty()) { - DiscoveredResourceDetails details = results.iterator().next(); - - Resource platform = new Resource(); - - platform.setDescription(details.getResourceDescription()); - platform.setResourceKey(details.getResourceKey()); - platform.setName(details.getResourceName()); - platform.setVersion(details.getResourceVersion()); - platform.setPluginConfiguration(details.getPluginConfiguration()); - platform.setResourceType(rt); - platform.setUuid(UUID.randomUUID().toString()); - platform.setId(1); - - return platform; - } - } - - return null; - } - - protected static String variableName(String prefix, String name) { - StringBuilder bld = new StringBuilder(); - if (prefix != null && !prefix.isEmpty()) { - bld.append(prefix).append("."); - } - - bld.append(name); - - return bld.toString(); - } - - protected static InetAddress determineLocalhost() { - try { - return InetAddress.getLocalHost(); - } catch (UnknownHostException e) { - try { - return InetAddress.getByName("127.0.0.1"); - } catch (UnknownHostException ee) { - //doesn't happen - return null; - } - } - } -} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java new file mode 100644 index 0000000..358df93 --- /dev/null +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java @@ -0,0 +1,599 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.plugins.apache.upgrade; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.io.File; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.net.InetAddress; +import java.net.URI; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jmock.Expectations; +import org.testng.annotations.BeforeClass; + +import org.rhq.core.clientapi.agent.metadata.PluginMetadataParser; +import org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil; +import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor; +import org.rhq.core.clientapi.server.discovery.InventoryReport; +import org.rhq.core.domain.discovery.AvailabilityReport; +import org.rhq.core.domain.resource.InventoryStatus; +import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.resource.ResourceError; +import org.rhq.core.domain.resource.ResourceType; +import org.rhq.core.pc.ServerServices; +import org.rhq.core.pc.upgrade.FakeServerInventory; +import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; +import org.rhq.core.pluginapi.inventory.PluginContainerDeployment; +import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; +import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; +import org.rhq.core.system.SystemInfoFactory; +import org.rhq.plugins.apache.ApacheServerDiscoveryComponent; +import org.rhq.plugins.apache.ApacheVirtualHostServiceComponent; +import org.rhq.plugins.apache.ApacheVirtualHostServiceDiscoveryComponent; +import org.rhq.plugins.apache.parser.ApacheConfigReader; +import org.rhq.plugins.apache.parser.ApacheDirectiveTree; +import org.rhq.plugins.apache.parser.ApacheParser; +import org.rhq.plugins.apache.parser.ApacheParserImpl; +import org.rhq.plugins.apache.util.ApacheDeploymentUtil; +import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig; +import org.rhq.plugins.apache.util.ApacheExecutionUtil; +import org.rhq.plugins.apache.util.HttpdAddressUtility; +import org.rhq.plugins.apache.util.VHostSpec; +import org.rhq.test.ObjectCollectionSerializer; +import org.rhq.test.TokenReplacingReader; +import org.rhq.test.pc.PluginContainerTest; + + +/** + * Base class for the upgrade test classes. + * + * @author Lukas Krejci + */ +public class UpgradeTestBase extends PluginContainerTest { + + private static final Log LOG = LogFactory.getLog(UpgradeTestBase.class); + + protected class TestSetup { + private String configurationName; + private FakeServerInventory fakeInventory = new FakeServerInventory(); + private String inventoryFile; + private Resource platform; + private ApacheSetup apacheSetup = new ApacheSetup(); + private DeploymentConfig deploymentConfig; + private Map<String, String> defaultOverrides = new HashMap<String, String>(); + private Map<String, String> inventoryFileReplacements; + + public class ApacheSetup { + private String serverRoot; + private String exePath; + private Collection<String> configurationFiles; + private ApacheExecutionUtil execution; + private boolean deploy = true; + + private ApacheSetup() { + + } + + public ApacheSetup withServerRoot(String serverRoot) { + this.serverRoot = serverRoot; + //auto-define the server root property as if it was passed on the commandline + System.getProperties().put(configurationName + ".server.root", serverRoot); + deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName, defaultOverrides); + return this; + } + + public ApacheSetup withExePath(String exePath) { + this.exePath = exePath; + return this; + } + + public ApacheSetup withConfigurationFiles(String... classPathUris) { + return withConfigurationFiles(Arrays.asList(classPathUris)); + } + + public ApacheSetup withConfigurationFiles(Collection<String> classPathUris) { + this.configurationFiles = classPathUris; + return this; + } + + public ApacheSetup withDeploymentOnSetup() { + this.deploy = true; + return this; + } + + public ApacheSetup withNoDeploymentOnSetup() { + this.deploy = false; + return this; + } + + public ApacheExecutionUtil getExecutionUtil() { + return execution; + } + + public void init() throws Exception { + File serverRootDir = new File(serverRoot); + + assertTrue(serverRootDir.exists(), "The configured server root denotes a non-existant directory: '" + + serverRootDir + "'."); + + File confDir = new File(serverRootDir, "conf"); + + assertTrue(confDir.exists(), + "The configured server root denotes a directory that doesn't have a 'conf' subdirectory. This is unexpected."); + + String confFilePath = confDir.getAbsolutePath() + File.separatorChar + "httpd.conf"; + + String snmpHost = null; + int snmpPort = 0; + String pingUrl = null; + + if (configurationName != null) { + if (deploy) { + ApacheDeploymentUtil.deployConfiguration(confDir, configurationFiles, deploymentConfig); + } + + //ok, now try to find the ping URL. The best thing is to actually invoke + //the same code the apache server discovery does. + ApacheDirectiveTree tree = new ApacheDirectiveTree(); + ApacheParser parser = new ApacheParserImpl(tree, serverRootDir.getAbsolutePath()); + ApacheConfigReader.buildTree(confFilePath, parser); + + //XXX this hardcodes apache2 as the only option we have... + HttpdAddressUtility.Address addrToUse = HttpdAddressUtility.APACHE_2_x.getMainServerSampleAddress(tree, null, -1); + pingUrl = addrToUse.toString(); + + snmpHost = deploymentConfig.snmpHost; + snmpPort = deploymentConfig.snmpPort; + } + + execution = new ApacheExecutionUtil(findApachePluginResourceTypeByName("Apache HTTP Server"), + serverRoot, exePath, confFilePath, pingUrl, + snmpHost, snmpPort); + execution.init(); + } + + private void doSetup() throws Exception { + init(); + execution.invokeOperation("start"); + } + + public TestSetup setup() throws Exception { + return TestSetup.this.setup(); + } + } + + public TestSetup(String configurationName) { + this.configurationName = configurationName; + deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName, defaultOverrides); + } + + public TestSetup withInventoryFrom(String classPathUri) { + inventoryFile = classPathUri; + return this; + } + + public TestSetup withDefaultOverrides(Map<String, String> defaultOverrides) { + this.defaultOverrides = defaultOverrides == null ? new HashMap<String, String>() : defaultOverrides; + deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName, this.defaultOverrides); + return this; + } + + public TestSetup withPlatformResource(Resource platform) { + this.platform = platform; + return this; + } + + public ApacheSetup withApacheSetup() { + return apacheSetup; + } + + public TestSetup withDefaultExpectations() throws Exception { + context.checking(new Expectations() { + { + addDefaultExceptations(this); + } + }); + + return this; + } + + @SuppressWarnings("unchecked") + public void addDefaultExceptations(Expectations expectations) throws Exception { + ServerServices ss = getCurrentPluginContainerConfiguration().getServerServices(); + + expectations.allowing(ss.getDiscoveryServerService()).mergeInventoryReport( + expectations.with(Expectations.any(InventoryReport.class))); + expectations.will(fakeInventory.mergeInventoryReport(InventoryStatus.COMMITTED)); + + expectations.allowing(ss.getDiscoveryServerService()).upgradeResources( + expectations.with(Expectations.any(Set.class))); + expectations.will(fakeInventory.upgradeResources()); + + expectations.allowing(ss.getDiscoveryServerService()).getResources( + expectations.with(Expectations.any(Set.class)), expectations.with(Expectations.any(boolean.class))); + expectations.will(fakeInventory.getResources()); + + expectations.allowing(ss.getDiscoveryServerService()).setResourceError(expectations.with(Expectations.any(ResourceError.class))); + expectations.will(fakeInventory.setResourceError()); + + expectations.allowing(ss.getDiscoveryServerService()).mergeAvailabilityReport( + expectations.with(Expectations.any(AvailabilityReport.class))); + + expectations.allowing(ss.getDiscoveryServerService()).postProcessNewlyCommittedResources( + expectations.with(Expectations.any(Set.class))); + + expectations.allowing(ss.getDiscoveryServerService()).clearResourceConfigError( + expectations.with(Expectations.any(int.class))); + + expectations.ignoring(ss.getBundleServerService()); + expectations.ignoring(ss.getConfigurationServerService()); + expectations.ignoring(ss.getContentServerService()); + expectations.ignoring(ss.getCoreServerService()); + expectations.ignoring(ss.getEventServerService()); + expectations.ignoring(ss.getMeasurementServerService()); + expectations.ignoring(ss.getOperationServerService()); + expectations.ignoring(ss.getResourceFactoryServerService()); + } + + public FakeServerInventory getFakeInventory() { + return fakeInventory; + } + + public DeploymentConfig getDeploymentConfig() { + return deploymentConfig; + } + + public TestSetup setup() throws Exception { + apacheSetup.doSetup(); + + Map<String, String> replacements = deploymentConfig.getTokenReplacements(); + replacements.put("server.root", apacheSetup.serverRoot); + replacements.put("exe.path", apacheSetup.exePath); + + ApacheDeploymentUtil.addDefaultVariables(replacements, null); + + HttpdAddressUtility addressUtility = apacheSetup.getExecutionUtil().getServerComponent() + .getAddressUtility(); + ApacheDirectiveTree runtimeConfig = apacheSetup.getExecutionUtil().getRuntimeConfiguration(); + + replacements.put("snmp.identifier", + addressUtility.getHttpdInternalMainServerAddressRepresentation(runtimeConfig).toString(false, false)); + + replacements.put("main.rhq4.resource.key", ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY); + + VHostSpec vhost1 = deploymentConfig.vhost1 == null ? null : deploymentConfig.vhost1.getVHostSpec(replacements); + VHostSpec vhost2 = deploymentConfig.vhost2 == null ? null : deploymentConfig.vhost2.getVHostSpec(replacements); + VHostSpec vhost3 = deploymentConfig.vhost3 == null ? null : deploymentConfig.vhost3.getVHostSpec(replacements); + VHostSpec vhost4 = deploymentConfig.vhost4 == null ? null : deploymentConfig.vhost4.getVHostSpec(replacements); + + if (vhost1 != null) { + replacements.put( + "vhost1.snmp.identifier", + addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost1.hosts.get(0), + vhost1.serverName).toString(false, false)); + + replacements.put( + "vhost1.rhq4.resource.key", + ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( + vhost1.serverName, vhost1.hosts)); + } + + if (vhost2 != null) { + replacements.put( + "vhost2.snmp.identifier", + addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost2.hosts.get(0), + vhost2.serverName).toString(false, false)); + + replacements.put( + "vhost2.rhq4.resource.key", + ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( + vhost2.serverName, vhost2.hosts)); + } + + if (vhost3 != null) { + replacements.put( + "vhost3.snmp.identifier", + addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost3.hosts.get(0), + vhost3.serverName).toString(false, false)); + + replacements.put( + "vhost3.rhq4.resource.key", + ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( + vhost3.serverName, vhost3.hosts)); + } + + if (vhost4 != null) { + replacements.put( + "vhost4.snmp.identifier", + addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost4.hosts.get(0), + vhost4.serverName).toString(false, false)); + + replacements.put( + "vhost4.rhq4.resource.key", + ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( + vhost4.serverName, vhost4.hosts)); + } + + //let the user override everything we just did + replacements.putAll(defaultOverrides); + + inventoryFileReplacements = replacements; + + InputStream dataStream = getClass().getResourceAsStream(inventoryFile); + + Reader rdr = new TokenReplacingReader(new InputStreamReader(dataStream), replacements); + + @SuppressWarnings("unchecked") + List<Resource> inventory = (List<Resource>) new ObjectCollectionSerializer().deserialize(rdr); + + //fix up the parent relationships, because they might not be reconstructed correctly by + //JAXB - we're missing XmlID and XmlIDRef annotations in our model + fixupParent(null, inventory); + + fakeInventory.prepopulateInventory(platform, inventory); + + return this; + } + + /** + * After the setup, this returns all the variables used to update the tokens in the inventory file. + * + * @return + */ + public Map<String, String> getInventoryFileReplacements() { + return inventoryFileReplacements; + } + + private void fixupParent(Resource parent, Collection<Resource> children) { + for (Resource child : children) { + child.setParentResource(parent); + if (child.getChildResources() != null) { + fixupParent(child, child.getChildResources()); + } + } + } + } + + protected static class TestConfiguration { + public String[] apacheConfigurationFiles; + public String inventoryFile; + public String configurationName; + public String serverRoot; + public String binPath; + public Map<String, String> defaultOverrides = new HashMap<String, String>(); + public boolean upgradeShouldSucceed = true; + + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + + } + + public void beforePluginContainerStart(TestSetup setup) throws Throwable { + + } + + public void beforeTests(TestSetup setup) throws Throwable { + + } + } + + protected static final String PLATFORM_PLUGIN = "file:target/itest/plugins/rhq-platform-plugin-for-apache-test.jar"; + protected static final String AUGEAS_PLUGIN = "file:target/itest/plugins/rhq-augeas-plugin-for-apache-test.jar"; + protected static final String APACHE_PLUGIN = "file:target/itest/plugins/rhq-apache-plugin-for-apache-test.jar"; + + protected static final String DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES = "simpleWithResolvableServerNames"; + protected static final String DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES = "simpleWithUnresolvableServerNames"; + protected static final String DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS = "simpleWithWildcardListens"; + + private List<ResourceType> resourceTypesInApachePlugin; + protected Resource platform; + + @BeforeClass + public void parseResourceTypesFromApachePlugin() throws Exception { + resourceTypesInApachePlugin = getResourceTypesInPlugin(APACHE_PLUGIN); + platform = discoverPlatform(); + } + + protected ResourceType findApachePluginResourceTypeByName(String resourceTypeName) { + for (ResourceType rt : resourceTypesInApachePlugin) { + if (resourceTypeName.equals(rt.getName())) { + return rt; + } + } + + return null; + } + + protected void testUpgrade(TestConfiguration testConfiguration) throws Throwable { + final TestSetup setup = new TestSetup(testConfiguration.configurationName); + boolean testFailed = false; + try { + + String[] configFiles = Arrays.copyOf(testConfiguration.apacheConfigurationFiles, testConfiguration.apacheConfigurationFiles.length + 2); + configFiles[testConfiguration.apacheConfigurationFiles.length] = "/snmpd.conf"; + configFiles[testConfiguration.apacheConfigurationFiles.length + 1] = "/mime.types"; + + setup.withInventoryFrom(testConfiguration.inventoryFile) + .withPlatformResource(platform).withDefaultExpectations().withDefaultOverrides(testConfiguration.defaultOverrides) + .withApacheSetup().withConfigurationFiles(configFiles) + .withServerRoot(testConfiguration.serverRoot).withExePath(testConfiguration.binPath); + + testConfiguration.beforeTestSetup(setup); + + setup.setup(); + + testConfiguration.beforePluginContainerStart(setup); + + startConfiguredPluginContainer(); + + testConfiguration.beforeTests(setup); + + if (!testConfiguration.upgradeShouldSucceed) { + return; + } + + //ok, now we should see the resources upgraded in the fake server inventory. + ResourceType serverResourceType = findApachePluginResourceTypeByName("Apache HTTP Server"); + ResourceType vhostResourceType = findApachePluginResourceTypeByName("Apache Virtual Host"); + + Set<Resource> servers = setup.getFakeInventory().findResourcesByType(serverResourceType); + + assertEquals(servers.size(), 1, "There should be exactly one apache server discovered."); + + Resource server = servers.iterator().next(); + + String expectedResourceKey = ApacheServerDiscoveryComponent.formatResourceKey(testConfiguration.serverRoot, testConfiguration.serverRoot + + "/conf/httpd.conf"); + + assertEquals(server.getResourceKey(), expectedResourceKey, + "The server resource key doesn't seem to be upgraded."); + + Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(vhostResourceType); + + assertEquals(vhosts.size(), 5, "Unexpected number of vhosts discovered found"); + + List<String> expectedResourceKeys = new ArrayList<String>(5); + + DeploymentConfig dc = setup.getDeploymentConfig(); + Map<String, String> replacements = dc.getTokenReplacements(); + + VHostSpec vh1 = dc.vhost1.getVHostSpec(replacements); + VHostSpec vh2 = dc.vhost2.getVHostSpec(replacements); + VHostSpec vh3 = dc.vhost3.getVHostSpec(replacements); + VHostSpec vh4 = dc.vhost4.getVHostSpec(replacements); + + expectedResourceKeys.add(ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY); + expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( + vh1.serverName, vh1.hosts)); + expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( + vh2.serverName, vh2.hosts)); + expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( + vh3.serverName, vh3.hosts)); + expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( + vh4.serverName, vh4.hosts)); + + for (Resource vhost : vhosts) { + assertTrue(expectedResourceKeys.contains(vhost.getResourceKey()), + "Unexpected virtual host resource key: '" + vhost.getResourceKey() + "'. Only expecting " + expectedResourceKeys); + } + } catch (Throwable t) { + testFailed = true; + LOG.error("Error during test upgrade execution.", t); + throw t; + } finally { + try { + setup.withApacheSetup().getExecutionUtil().invokeOperation("stop"); + } catch (Exception e) { + if (testFailed) { + LOG.error("Failed to stop apache.", e); + } else { + throw e; + } + } + } + } + + private static List<ResourceType> getResourceTypesInPlugin(String pluginUri) throws Exception { + PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(new URI(pluginUri).toURL()); + PluginMetadataParser parser = new PluginMetadataParser(descriptor, + Collections.<String, PluginMetadataParser> emptyMap()); + + return parser.getAllTypes(); + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + private static Resource discoverPlatform() throws Exception { + PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(new URI(PLATFORM_PLUGIN) + .toURL()); + PluginMetadataParser parser = new PluginMetadataParser(descriptor, + Collections.<String, PluginMetadataParser> emptyMap()); + + List<ResourceType> platformTypes = parser.getAllTypes(); + + for (ResourceType rt : platformTypes) { + Class discoveryClass = Class.forName(parser.getDiscoveryComponentClass(rt)); + + ResourceDiscoveryComponent discoveryComponent = (ResourceDiscoveryComponent) discoveryClass.newInstance(); + + ResourceDiscoveryContext context = new ResourceDiscoveryContext(rt, null, null, + SystemInfoFactory.createSystemInfo(), null, null, PluginContainerDeployment.AGENT); + + Set<DiscoveredResourceDetails> results = discoveryComponent.discoverResources(context); + + if (!results.isEmpty()) { + DiscoveredResourceDetails details = results.iterator().next(); + + Resource platform = new Resource(); + + platform.setDescription(details.getResourceDescription()); + platform.setResourceKey(details.getResourceKey()); + platform.setName(details.getResourceName()); + platform.setVersion(details.getResourceVersion()); + platform.setPluginConfiguration(details.getPluginConfiguration()); + platform.setResourceType(rt); + platform.setUuid(UUID.randomUUID().toString()); + platform.setId(1); + + return platform; + } + } + + return null; + } + + protected static String variableName(String prefix, String name) { + StringBuilder bld = new StringBuilder(); + if (prefix != null && !prefix.isEmpty()) { + bld.append(prefix).append("."); + } + + bld.append(name); + + return bld.toString(); + } + + protected static InetAddress determineLocalhost() { + try { + return InetAddress.getLocalHost(); + } catch (UnknownHostException e) { + try { + return InetAddress.getByName("127.0.0.1"); + } catch (UnknownHostException ee) { + //doesn't happen + return null; + } + } + } +} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeSimpleConfigurationFromRHQ1_3Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeSimpleConfigurationFromRHQ1_3Test.java new file mode 100644 index 0000000..1fd44ba --- /dev/null +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq1_3_x/UpgradeSimpleConfigurationFromRHQ1_3Test.java @@ -0,0 +1,168 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.plugins.apache.upgrade.rhq1_3_x; + +import java.util.Comparator; +import java.util.HashMap; +import java.util.Set; +import java.util.TreeSet; + +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +import org.rhq.core.domain.resource.Resource; +import org.rhq.plugins.apache.upgrade.UpgradeTestBase; +import org.rhq.plugins.apache.upgrade.UpgradeTestBase.TestConfiguration; +import org.rhq.plugins.apache.upgrade.UpgradeTestBase.TestSetup; +import org.rhq.test.pc.PluginContainerSetup; + +/** + * + * + * @author Lukas Krejci + */ +@Test(groups = "apache-integration-tests") +public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase { + + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testWithResolvableServerNames_Apache2(final String installPath, final String exePath) + throws Throwable { + + testUpgrade(new TestConfiguration() { + { + serverRoot = installPath; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-1.3.x/simple/inventory.xml"; + } + }); + } + + @Test(enabled = false) + //ApacheServerOperationsDelegate doesn't work with apache 1.3 + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache1.install.dir", "apache1.exe.path" }) + public void testWithResolvableServerNames_Apache1(final String installPath, final String exePath) + throws Throwable { + + testUpgrade(new TestConfiguration() {{ + serverRoot = installPath; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + apacheConfigurationFiles = new String[] { "/full-configurations/1.3.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-1.3.x/simple/inventory.xml"; + }}); + } + + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testWithNonUniqueServerNames_Apache2(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES; + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-1.3.x/simple/inventory.xml"; + serverRoot = installPath; + binPath = exePath; + + + defaultOverrides = new HashMap<String, String>(); + defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}"); + } + + @Override + public void beforePluginContainerStart(TestSetup setup) { + //in this scenario, the RHQ 1.3 would only discover 1 vhost (and the main vhost), because they would have the same resource key + //due to the same ServerName. I need to process the default inventory to reflect that otherwise I would get upgrade + //failures. + + Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(findApachePluginResourceTypeByName("Apache Virtual Host")); + Set<Resource> uniques = new TreeSet<Resource>(new Comparator<Resource>() { + public int compare(Resource a, Resource b) { + return a.getResourceKey().compareTo(b.getResourceKey()); + } + }); + + for(Resource vhost : vhosts) { + if (uniques.contains(vhost)) { + //remove the vhost from the server's inventory + setup.getFakeInventory().removeResource(vhost); + } else { + uniques.add(vhost); + } + } + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path" }) + public void testWithAnyAddress(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-1.3.x/simple/inventory.xml"; + serverRoot = installPath; + binPath = exePath; + + defaultOverrides = new HashMap<String, String>(); + defaultOverrides.put(variableName(configurationName, "listen1"), "0.0.0.0:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "0.0.0.0:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "0.0.0.0:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "0.0.0.0:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "0.0.0.0:${port1}"); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path" }) + public void testWithWildcardAddress(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-1.3.x/simple/inventory.xml"; + serverRoot = installPath; + binPath = exePath; + + defaultOverrides = new HashMap<String, String>(); + defaultOverrides.put(variableName(configurationName, "listen1"), "*:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "*:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "*:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "*:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "*:${port1}"); + } + }); + } +} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java new file mode 100644 index 0000000..fb2e360 --- /dev/null +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_0/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java @@ -0,0 +1,449 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.plugins.apache.upgrade.rhq3_0_0; + + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.resource.ResourceError; +import org.rhq.core.domain.resource.ResourceErrorType; +import org.rhq.core.domain.resource.ResourceType; +import org.rhq.plugins.apache.ApacheServerComponent; +import org.rhq.plugins.apache.ApacheServerDiscoveryComponent; +import org.rhq.plugins.apache.parser.ApacheDirectiveTree; +import org.rhq.plugins.apache.upgrade.UpgradeTestBase; +import org.rhq.plugins.apache.upgrade.UpgradeTestBase.TestConfiguration; +import org.rhq.plugins.apache.upgrade.UpgradeTestBase.TestSetup; +import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig; +import org.rhq.plugins.apache.util.RuntimeApacheConfiguration; +import org.rhq.plugins.apache.util.VirtualHostLegacyResourceKeyUtil; +import org.rhq.test.pc.PluginContainerSetup; + +/** + * + * + * @author Lukas Krejci + */ +public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase { + + /** + * This tests the upgrade from RHQ 3.0.0 where the apache server was discovered without SNMP support. + * The Main Server URL must have been set in this case, otherwise the component would fail to start + * and therefore the vhost discovery wouldn't even take place. + */ + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}, numberOfInitialDiscoveries = 2) + @Parameters({"apache2.install.dir", "apache2.exe.path"}) + public void testWithResolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; + inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + + //just define the servername value without actually setting the ${servername.directive} so that + //we don't define a servername directive itself but do have a value for the actual server name. + //this is deduced by apache and the plugin but tests aren't that clever. + defaultOverrides.put("servername", "${localhost}"); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}, numberOfInitialDiscoveries = 2) + @Parameters({"apache2.install.dir", "apache2.exe.path"}) + public void testWithUnresolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; + inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES; + + defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}:${listen1}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}:${listen2}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}:${listen3}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}:${listen4}"); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}, numberOfInitialDiscoveries = 2) + @Parameters({"apache2.install.dir", "apache2.exe.path"}) + public void testWithNonUniqueNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; + inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES; + + defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}"); + } + }); + } + + /** + * This tests the upgrade from RHQ 3.0.0 where the Apache server was discovered with the following: + * <p> + * <ol> + * <li> SNMP enabled + * <li> Main URL set or unset (it doesn't make a difference here) + * </ol> + * @param installDir + * @param exePath + * @throws Throwable + */ + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path"}) + public void testWithResolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; + inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + upgradeShouldSucceed = false; + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + beforeTestSetupWithSNMP(this, testSetup); + } + + /** + * Do our own tests here, because the generic test method won't do much, since + * we told it that the upgrade won't succeed. + */ + @Override + public void beforeTests(TestSetup setup) throws Throwable { + testWithSNMP(this, setup); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path"}) + public void testWithUnresolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; + inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + upgradeShouldSucceed = false; + + defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}:${listen1}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}:${listen2}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}:${listen3}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}:${listen4}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + beforeTestSetupWithSNMP(this, testSetup); + } + + /** + * Do our own tests here, because the generic test method won't do much, since + * we told it that the upgrade won't succeed. + */ + @Override + public void beforeTests(TestSetup setup) throws Throwable { + testWithSNMP(this, setup); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path"}) + public void testWithNonUniqueNamesWithSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; + inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + upgradeShouldSucceed = false; + + defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + beforeTestSetupWithSNMP(this, testSetup); + } + + /** + * Do our own tests here, because the generic test method won't do much, since + * we told it that the upgrade won't succeed. + */ + @Override + public void beforeTests(TestSetup setup) throws Throwable { + testWithSNMP(this, setup); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path" }) + public void testWithAnyAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml"; + serverRoot = installPath; + binPath = exePath; + + //just define the servername value without actually setting the ${servername.directive} so that + //we don't define a servername directive itself but do have a value for the actual server name. + //this is deduced by apache and the plugin but tests aren't that clever. + defaultOverrides.put("servername", "${localhost}"); + defaultOverrides.put(variableName(configurationName, "listen1"), "0.0.0.0:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "0.0.0.0:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "0.0.0.0:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "0.0.0.0:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "0.0.0.0:${port1}"); + } + }); + } + + /** + * Unlike other SNMP tests this one actually succeeds to upgrade because of the messed up discovery that + * RHQ 3.0.0 would perform. In case of any-address (0.0.0.0), the main vhost would get the MainServer + * resource key even with SNMP, because RHQ 3 codebase wouldn't be able to match what it think should + * have been the SNMP record with the actual results from SNMP module. + * <p> + * Because of this, RHQ 3 discovers all 5 vhosts and the upgrade code is therefore able to successfully + * upgrade all of them. + * + * @param installPath + * @param exePath + * @throws Throwable + */ + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path" }) + public void testWithAnyAddressWithSNMP(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp-anyaddr.xml"; + serverRoot = installPath; + binPath = exePath; + + defaultOverrides.put(variableName(configurationName, "listen1"), "0.0.0.0:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "0.0.0.0:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "0.0.0.0:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "0.0.0.0:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "0.0.0.0:${port1}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + beforeTestSetupWithSNMP(this, testSetup); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path" }) + public void testWithWildcardAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml"; + serverRoot = installPath; + binPath = exePath; + + //just define the servername value without actually setting the ${servername.directive} so that + //we don't define a servername directive itself but do have a value for the actual server name. + //this is deduced by apache and the plugin but tests aren't that clever. + defaultOverrides.put("servername", "${localhost}"); + defaultOverrides.put(variableName(configurationName, "listen1"), "*:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "*:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "*:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "*:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "*:${port1}"); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path" }) + public void testWithWildcardAddressWithSNMP(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml"; + serverRoot = installPath; + binPath = exePath; + upgradeShouldSucceed = false; + + defaultOverrides.put(variableName(configurationName, "listen1"), "*:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "*:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "*:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "*:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "*:${port1}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + beforeTestSetupWithSNMP(this, testSetup); + } + + /** + * Do our own tests here, because the generic test method won't do much, since + * we told it that the upgrade won't succeed. + */ + @Override + public void beforeTests(TestSetup setup) throws Throwable { + testWithSNMP(this, setup); + } + }); + } + + private void beforeTestSetupWithSNMP(TestConfiguration testConfig, TestSetup setup) throws Exception { + setup.withApacheSetup().init(); + ApacheServerComponent component = setup.withApacheSetup().getExecutionUtil().getServerComponent(); + ApacheDirectiveTree config = component.loadParser(); + config = RuntimeApacheConfiguration.extract(config, component.getCurrentProcessInfo(), component.getCurrentBinaryInfo(), component.getModuleNames(), false); + + DeploymentConfig deployConfig = setup.getDeploymentConfig(); + + VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config); + + Map<String, String> replacements = deployConfig.getTokenReplacements(); + + testConfig.defaultOverrides.put("main.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyMainServerResourceKey()); + + if (deployConfig.vhost1 != null) { + testConfig.defaultOverrides.put("vhost1.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost1.getVHostSpec(replacements))); + } + + if (deployConfig.vhost2 != null) { + testConfig.defaultOverrides.put("vhost2.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost2.getVHostSpec(replacements))); + } + + if (deployConfig.vhost3 != null) { + testConfig.defaultOverrides.put("vhost3.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost3.getVHostSpec(replacements))); + } + + if (deployConfig.vhost4 != null) { + testConfig.defaultOverrides.put("vhost4.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost4.getVHostSpec(replacements))); + } + + setup.withDefaultOverrides(testConfig.defaultOverrides); + } + + private void testWithSNMP(TestConfiguration testConfig, TestSetup setup) { + //ok, now we should see the resources upgraded in the fake server inventory. + ResourceType serverResourceType = findApachePluginResourceTypeByName("Apache HTTP Server"); + ResourceType vhostResourceType = findApachePluginResourceTypeByName("Apache Virtual Host"); + + Set<Resource> servers = setup.getFakeInventory().findResourcesByType(serverResourceType); + + assertEquals(servers.size(), 1, "There should be exactly one apache server discovered."); + + Resource server = servers.iterator().next(); + + String expectedResourceKey = ApacheServerDiscoveryComponent.formatResourceKey(testConfig.serverRoot, testConfig.serverRoot + + "/conf/httpd.conf"); + + assertEquals(server.getResourceKey(), expectedResourceKey, + "The server resource key doesn't seem to be upgraded."); + + Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(vhostResourceType); + + assertEquals(vhosts.size(), 4, "Unexpected number of vhosts discovered found"); + + //let's check that the main vhost has a an upgrade error attached to it + ApacheServerComponent component = setup.withApacheSetup().getExecutionUtil().getServerComponent(); + ApacheDirectiveTree config = component.loadParser(); + config = RuntimeApacheConfiguration.extract(config, component.getCurrentProcessInfo(), component.getCurrentBinaryInfo(), component.getModuleNames(), false); + VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config); + + String mainVhostRK = keyUtil.getRHQ3NonSNMPLegacyMainServerResourceKey(); + + Resource mainVhost = null; + for(Resource r : vhosts) { + if (mainVhostRK.equals(r.getResourceKey())) { + mainVhost = r; + break; + } + } + + assertNotNull(mainVhost, "Couldn't find the main vhost with the expected resource key '" + mainVhostRK + "'."); + + List<ResourceError> errors = mainVhost.getResourceErrors(ResourceErrorType.UPGRADE); + assertNotNull(errors, "The main vhost doesn't have any upgrade errors."); + assertEquals(errors.size(), 1, "There should be exactly one upgrade error on the main vhost."); + + //check that all other vhosts were not upgraded but have no errors + for(Resource r : vhosts) { + if (r.equals(mainVhost)) { + continue; + } + + assertEquals(r.getResourceErrors(ResourceErrorType.UPGRADE).size(), 0, "Unexpected number of resource upgrade errors on non-main vhost " + r); + } + } +} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java new file mode 100644 index 0000000..cbd4826 --- /dev/null +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/upgrade/rhq3_0_1/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java @@ -0,0 +1,554 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.plugins.apache.upgrade.rhq3_0_1; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +import java.io.StringReader; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.resource.ResourceError; +import org.rhq.core.domain.resource.ResourceErrorType; +import org.rhq.core.domain.resource.ResourceType; +import org.rhq.core.util.stream.StreamUtil; +import org.rhq.plugins.apache.ApacheServerComponent; +import org.rhq.plugins.apache.ApacheServerDiscoveryComponent; +import org.rhq.plugins.apache.parser.ApacheDirectiveTree; +import org.rhq.plugins.apache.upgrade.UpgradeTestBase; +import org.rhq.plugins.apache.upgrade.UpgradeTestBase.TestConfiguration; +import org.rhq.plugins.apache.upgrade.UpgradeTestBase.TestSetup; +import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig; +import org.rhq.plugins.apache.util.RuntimeApacheConfiguration; +import org.rhq.plugins.apache.util.VirtualHostLegacyResourceKeyUtil; +import org.rhq.test.TokenReplacingReader; +import org.rhq.test.pc.PluginContainerSetup; + +/** + * + * + * @author Lukas Krejci + */ +public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase { + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path"}) + public void testWithResolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; + inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + upgradeShouldSucceed = false; + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + defineRHQ3ResourceKeys(this, testSetup); + } + + /** + * Do our own tests here, because the generic test method won't do much, since + * we told it that the upgrade won't succeed. + */ + @Override + public void beforeTests(TestSetup setup) throws Throwable { + String failingRK = interpret("${main.rhq3.resource.key}", setup.getInventoryFileReplacements()); + testExpectedFailures(this, setup, 4, failingRK); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path"}) + public void testWithResolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; + inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-without-snmp.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + upgradeShouldSucceed = false; + + //just define the servername value without actually setting the ${servername.directive} so that + //we don't define a servername directive itself but do have a value for the actual server name. + //this is deduced by apache and the plugin but tests aren't that clever. + defaultOverrides.put("servername", "${localhost.ip}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + defineRHQ3ResourceKeys(this, testSetup); + } + + @Override + public void beforeTests(TestSetup setup) throws Throwable { + String vhost1RK = interpret("${vhost1.rhq3.resource.key}", setup.getInventoryFileReplacements()); + testExpectedFailures(this, setup, 5, vhost1RK); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path"}) + public void testWithUnresolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; + inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + upgradeShouldSucceed = false; + + defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}:${listen1}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}:${listen2}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}:${listen3}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}:${listen4}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + defineRHQ3ResourceKeys(this, testSetup); + } + + /** + * Do our own tests here, because the generic test method won't do much, since + * we told it that the upgrade won't succeed. + */ + @Override + public void beforeTests(TestSetup setup) throws Throwable { + String failingRK = interpret("${main.rhq3.resource.key}", setup.getInventoryFileReplacements()); + testExpectedFailures(this, setup, 4, failingRK); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path"}) + public void testWithUnresolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; + inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-without-snmp.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + + defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); + //we use this in the serialized inventory to init the URL of the main server. The localhost.ip is actually what + //the RHQ 301 discovers even though unresolvable.host is specified in the ServerName directive. + defaultOverrides.put("servername", "${localhost.ip}"); + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}:${port1}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}:${port2}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}:${port3}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}:${port4}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + defineRHQ3ResourceKeys(this, testSetup); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path"}) + public void testWithNonUniqueNamesWithSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; + inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + upgradeShouldSucceed = false; + + defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + defineRHQ3ResourceKeys(this, testSetup); + } + + /** + * Do our own tests here, because the generic test method won't do much, since + * we told it that the upgrade won't succeed. + */ + @Override + public void beforeTests(TestSetup setup) throws Throwable { + String failingRK = interpret("${main.rhq3.resource.key}", setup.getInventoryFileReplacements()); + testExpectedFailures(this, setup, 4, failingRK); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path"}) + public void testWithNonUniqueNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-without-snmp.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + + //we use this in the serialized inventory to init the URL of the main server. The localhost.ip is actually what + //the RHQ 301 discovers even though unresolvable.host is specified in the ServerName directive. + defaultOverrides.put("servername", "${localhost.ip}"); + defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), + "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), + "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), + "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), + "ServerName ${unresolvable.host}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + defineRHQ3ResourceKeys(this, testSetup); + } + }); + } + + /** + * The duplicate Main vhosts "condition" was triggered by: + * <ol> + * <li>Disabling SNMP by putting in an invalid hostname + * <li>Changing the URL of the apache server to some "other" value + * <li>Running discovery + * </ol> + * From that point on, 2 Main vhosts live in the inventory and the inventory has the "rest" + * of the resource keys coming from the SNMP based discovery. + * <p> + * It is not possible to recover from such condition automatically during + * the resource upgrade, so the only thing we need to check here is that + * the two main vhosts are marked as failed upgrade and that the rest of the vhosts + * are not upgraded and have no upgrade errors attached. + * + * @param installDir + * @param exePath + * @throws Throwable + */ + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path"}) + public void testDuplicateMainVhostsMarkedAsFailedUpgrade(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; + inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-duplicate-main.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + upgradeShouldSucceed = false; + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + defineRHQ3ResourceKeys(this, testSetup); + } + + /** + * Do our own tests here, because the generic test method won't do much, since + * we told it that the upgrade won't succeed. + */ + @Override + public void beforeTests(TestSetup setup) throws Throwable { + String mainVHost1RK = interpret("${main.rhq3.resource.key}", setup.getInventoryFileReplacements()); + String mainVhost2RK = interpret("${localhost}:${port1}", setup.getInventoryFileReplacements()); + + testExpectedFailures(this, setup, 5, mainVHost1RK, mainVhost2RK); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path" }) + public void testWithAnyAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + //yes, the inventory file can be the same for both the with and without snmp tests because + //they both yield the same inventory in this case. + inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp-anyaddr.xml"; + serverRoot = installPath; + binPath = exePath; + + //just define the servername value without actually setting the ${servername.directive} so that + //we don't define a servername directive itself but do have a value for the actual server name. + //this is deduced by apache and the plugin but tests aren't that clever. + defaultOverrides.put("servername", "${localhost.ip}"); + defaultOverrides.put(variableName(configurationName, "listen1"), "0.0.0.0:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "0.0.0.0:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "0.0.0.0:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "0.0.0.0:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "0.0.0.0:${port1}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + defineRHQ3ResourceKeys(this, testSetup); + } + }); + } + + /** + * Unlike other SNMP tests this one actually succeeds to upgrade because of the messed up discovery that + * RHQ 3.0.0 would perform. In case of any-address (0.0.0.0), the main vhost would get the MainServer + * resource key even with SNMP, because RHQ 3 codebase wouldn't be able to match what it think should + * have been the SNMP record with the actual results from SNMP module. + * <p> + * Because of this, RHQ 3 discovers all 5 vhosts and the upgrade code is therefore able to successfully + * upgrade all of them. + * + * @param installPath + * @param exePath + * @throws Throwable + */ + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path" }) + public void testWithAnyAddressWithSNMP(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp-anyaddr.xml"; + serverRoot = installPath; + binPath = exePath; + + defaultOverrides.put(variableName(configurationName, "listen1"), "0.0.0.0:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "0.0.0.0:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "0.0.0.0:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "0.0.0.0:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "0.0.0.0:${port1}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + defineRHQ3ResourceKeys(this, testSetup); + } + }); + } + + /** + * This configuration will fail to upgrade the first vhost, because it doesn't uniquely match to new-style + * vhosts - it could be either a main vhost or vhost1. + */ + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path" }) + public void testWithWildcardAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-without-snmp.xml"; + serverRoot = installPath; + binPath = exePath; + upgradeShouldSucceed = false; + + //just define the servername value without actually setting the ${servername.directive} so that + //we don't define a servername directive itself but do have a value for the actual server name. + //this is deduced by apache and the plugin but tests aren't that clever. + defaultOverrides.put("servername", "${localhost.ip}"); + defaultOverrides.put(variableName(configurationName, "listen1"), "*:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "*:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "*:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "*:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "*:${port1}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + defineRHQ3ResourceKeys(this, testSetup); + } + + @Override + public void beforeTests(TestSetup setup) throws Throwable { + String failingRK = interpret("${vhost1.rhq3.resource.key}", setup.getInventoryFileReplacements()); + testExpectedFailures(this, setup, 5, failingRK); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path" }) + public void testWithWildcardAddressWithSNMP(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml"; + serverRoot = installPath; + binPath = exePath; + upgradeShouldSucceed = false; + + defaultOverrides.put(variableName(configurationName, "listen1"), "*:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "*:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "*:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "*:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "*:${port1}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + defineRHQ3ResourceKeys(this, testSetup); + } + + /** + * Do our own tests here, because the generic test method won't do much, since + * we told it that the upgrade won't succeed. + */ + @Override + public void beforeTests(TestSetup setup) throws Throwable { + String failingRK = interpret("${main.rhq3.resource.key}", setup.getInventoryFileReplacements()); + testExpectedFailures(this, setup, 4, failingRK); + } + }); + } + + private void defineRHQ3ResourceKeys(TestConfiguration testConfig, TestSetup setup) throws Exception { + setup.withApacheSetup().init(); + ApacheServerComponent component = setup.withApacheSetup().getExecutionUtil().getServerComponent(); + ApacheDirectiveTree config = component.loadParser(); + config = RuntimeApacheConfiguration.extract(config, component.getCurrentProcessInfo(), component.getCurrentBinaryInfo(), component.getModuleNames(), false); + + DeploymentConfig deployConfig = setup.getDeploymentConfig(); + + VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config); + + Map<String, String> replacements = deployConfig.getTokenReplacements(); + + testConfig.defaultOverrides.put("main.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyMainServerResourceKey()); + + if (deployConfig.vhost1 != null) { + testConfig.defaultOverrides.put("vhost1.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost1.getVHostSpec(replacements))); + } + + if (deployConfig.vhost2 != null) { + testConfig.defaultOverrides.put("vhost2.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost2.getVHostSpec(replacements))); + } + + if (deployConfig.vhost3 != null) { + testConfig.defaultOverrides.put("vhost3.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost3.getVHostSpec(replacements))); + } + + if (deployConfig.vhost4 != null) { + testConfig.defaultOverrides.put("vhost4.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost4.getVHostSpec(replacements))); + } + + setup.withDefaultOverrides(testConfig.defaultOverrides); + } + + private void testExpectedFailures(TestConfiguration testConfig, TestSetup setup, int numberOfVhosts, String... failingRKs) { + //ok, now we should see the resources upgraded in the fake server inventory. + ResourceType serverResourceType = findApachePluginResourceTypeByName("Apache HTTP Server"); + ResourceType vhostResourceType = findApachePluginResourceTypeByName("Apache Virtual Host"); + + Set<Resource> servers = setup.getFakeInventory().findResourcesByType(serverResourceType); + + assertEquals(servers.size(), 1, "There should be exactly one apache server discovered."); + + Resource server = servers.iterator().next(); + + String expectedResourceKey = ApacheServerDiscoveryComponent.formatResourceKey(testConfig.serverRoot, testConfig.serverRoot + + "/conf/httpd.conf"); + + assertEquals(server.getResourceKey(), expectedResourceKey, + "The server resource key doesn't seem to be upgraded."); + + Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(vhostResourceType); + + assertEquals(vhosts.size(), numberOfVhosts, "Unexpected number of vhosts discovered found"); + + //let's check that the main vhost has a an upgrade error attached to it + ApacheServerComponent component = setup.withApacheSetup().getExecutionUtil().getServerComponent(); + ApacheDirectiveTree config = component.loadParser(); + config = RuntimeApacheConfiguration.extract(config, component.getCurrentProcessInfo(), component.getCurrentBinaryInfo(), component.getModuleNames(), false); + VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config); + + Set<Resource> failingResources = new HashSet<Resource>(); + + for(String rk : failingRKs) { + for(Resource r : vhosts) { + if (rk.equals(r.getResourceKey())) { + failingResources.add(r); + break; + } + } + } + + assertEquals(failingResources.size(), failingRKs.length, "Couldn't find all the resources that should have failed."); + + for(Resource failingResource : failingResources) { + List<ResourceError> errors = failingResource.getResourceErrors(ResourceErrorType.UPGRADE); + assertNotNull(errors, "The main vhost doesn't have any upgrade errors."); + assertEquals(errors.size(), 1, "There should be exactly one upgrade error on the main vhost."); + } + + //check that all other vhosts were not upgraded but have no errors + for(Resource r : vhosts) { + if (failingResources.contains(r)) { + continue; + } + + assertEquals(r.getResourceErrors(ResourceErrorType.UPGRADE).size(), 0, "Unexpected number of resource upgrade errors on non-main vhost " + r); + } + } + + private String interpret(String string, Map<String, String> variables) { + return StreamUtil.slurp(new TokenReplacingReader(new StringReader(string), variables)); + } +}
commit 3280b0bd86bf5fe68765cfa72c37cc7af8e4b853 Author: Lukas Krejci lkrejci@redhat.com Date: Wed Jun 29 17:08:00 2011 +0200
added tests for handling the any-address and wildcard address during upgrade to the simple config tests, finished up the tests for RHQ 3.0.1 for simple config.
diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ1_3Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ1_3Test.java index 135c2aa..8d1fe22 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ1_3Test.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ1_3Test.java @@ -115,5 +115,51 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase { } } }); - } + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path" }) + public void testWithAnyAddress(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-1.3.x/simple/inventory.xml"; + serverRoot = installPath; + binPath = exePath; + + defaultOverrides = new HashMap<String, String>(); + defaultOverrides.put(variableName(configurationName, "listen1"), "0.0.0.0:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "0.0.0.0:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "0.0.0.0:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "0.0.0.0:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "0.0.0.0:${port1}"); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path" }) + public void testWithWildcardAddress(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-1.3.x/simple/inventory.xml"; + serverRoot = installPath; + binPath = exePath; + + defaultOverrides = new HashMap<String, String>(); + defaultOverrides.put(variableName(configurationName, "listen1"), "*:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "*:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "*:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "*:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "*:${port1}"); + } + }); + } } diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java index 8d0c03b..d3e5c86 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java @@ -23,7 +23,6 @@ package org.rhq.plugins.apache; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull;
-import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -64,6 +63,11 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + + //just define the servername value without actually setting the ${servername.directive} so that + //we don't define a servername directive itself but do have a value for the actual server name. + //this is deduced by apache and the plugin but tests aren't that clever. + defaultOverrides.put("servername", "${localhost}"); } }); } @@ -80,7 +84,6 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES;
- defaultOverrides = new HashMap<String, String>(); defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}:${listen1}"); defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}:${listen2}"); @@ -102,7 +105,6 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES;
- defaultOverrides = new HashMap<String, String>(); defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}"); defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}"); @@ -134,9 +136,7 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - upgradeShouldSucceed = false; - - defaultOverrides = new HashMap<String, String>(); + upgradeShouldSucceed = false; }
@Override @@ -168,7 +168,6 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; upgradeShouldSucceed = false;
- defaultOverrides = new HashMap<String, String>(); defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}:${listen1}"); defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}:${listen2}"); @@ -205,7 +204,6 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; upgradeShouldSucceed = false;
- defaultOverrides = new HashMap<String, String>(); defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}"); defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}"); @@ -229,6 +227,135 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase }); }
+ @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path" }) + public void testWithAnyAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml"; + serverRoot = installPath; + binPath = exePath; + + //just define the servername value without actually setting the ${servername.directive} so that + //we don't define a servername directive itself but do have a value for the actual server name. + //this is deduced by apache and the plugin but tests aren't that clever. + defaultOverrides.put("servername", "${localhost}"); + defaultOverrides.put(variableName(configurationName, "listen1"), "0.0.0.0:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "0.0.0.0:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "0.0.0.0:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "0.0.0.0:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "0.0.0.0:${port1}"); + } + }); + } + + /** + * Unlike other SNMP tests this one actually succeeds to upgrade because of the messed up discovery that + * RHQ 3.0.0 would perform. In case of any-address (0.0.0.0), the main vhost would get the MainServer + * resource key even with SNMP, because RHQ 3 codebase wouldn't be able to match what it think should + * have been the SNMP record with the actual results from SNMP module. + * <p> + * Because of this, RHQ 3 discovers all 5 vhosts and the upgrade code is therefore able to successfully + * upgrade all of them. + * + * @param installPath + * @param exePath + * @throws Throwable + */ + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path" }) + public void testWithAnyAddressWithSNMP(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp-anyaddr.xml"; + serverRoot = installPath; + binPath = exePath; + + defaultOverrides.put(variableName(configurationName, "listen1"), "0.0.0.0:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "0.0.0.0:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "0.0.0.0:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "0.0.0.0:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "0.0.0.0:${port1}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + beforeTestSetupWithSNMP(this, testSetup); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path" }) + public void testWithWildcardAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml"; + serverRoot = installPath; + binPath = exePath; + + //just define the servername value without actually setting the ${servername.directive} so that + //we don't define a servername directive itself but do have a value for the actual server name. + //this is deduced by apache and the plugin but tests aren't that clever. + defaultOverrides.put("servername", "${localhost}"); + defaultOverrides.put(variableName(configurationName, "listen1"), "*:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "*:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "*:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "*:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "*:${port1}"); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path" }) + public void testWithWildcardAddressWithSNMP(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml"; + serverRoot = installPath; + binPath = exePath; + upgradeShouldSucceed = false; + + defaultOverrides.put(variableName(configurationName, "listen1"), "*:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "*:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "*:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "*:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "*:${port1}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + beforeTestSetupWithSNMP(this, testSetup); + } + + /** + * Do our own tests here, because the generic test method won't do much, since + * we told it that the upgrade won't succeed. + */ + @Override + public void beforeTests(TestSetup setup) throws Throwable { + testWithSNMP(this, setup); + } + }); + } + private void beforeTestSetupWithSNMP(TestConfiguration testConfig, TestSetup setup) throws Exception { setup.withApacheSetup().init(); ApacheServerComponent component = setup.withApacheSetup().getExecutionUtil().getServerComponent(); diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java index 5938889..b43d3f3 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java @@ -23,7 +23,7 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull;
import java.io.StringReader; -import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -62,13 +62,11 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; upgradeShouldSucceed = false; - - defaultOverrides = new HashMap<String, String>(); }
@Override public void beforeTestSetup(TestSetup testSetup) throws Throwable { - beforeTestSetupWithSNMP(this, testSetup); + defineRHQ3ResourceKeys(this, testSetup); }
/** @@ -77,7 +75,8 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase */ @Override public void beforeTests(TestSetup setup) throws Throwable { - testWithSNMP(this, setup); + String failingRK = interpret("${main.rhq3.resource.key}", setup.getInventoryFileReplacements()); + testExpectedFailures(this, setup, 4, failingRK); } }); } @@ -85,6 +84,38 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase @Test @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) @Parameters({"apache2.install.dir", "apache2.exe.path"}) + public void testWithResolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; + inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-without-snmp.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + upgradeShouldSucceed = false; + + //just define the servername value without actually setting the ${servername.directive} so that + //we don't define a servername directive itself but do have a value for the actual server name. + //this is deduced by apache and the plugin but tests aren't that clever. + defaultOverrides.put("servername", "${localhost.ip}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + defineRHQ3ResourceKeys(this, testSetup); + } + + @Override + public void beforeTests(TestSetup setup) throws Throwable { + String vhost1RK = interpret("${vhost1.rhq3.resource.key}", setup.getInventoryFileReplacements()); + testExpectedFailures(this, setup, 5, vhost1RK); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path"}) public void testWithUnresolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable { testUpgrade(new TestConfiguration() { { @@ -95,7 +126,6 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; upgradeShouldSucceed = false;
- defaultOverrides = new HashMap<String, String>(); defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}:${listen1}"); defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}:${listen2}"); @@ -105,7 +135,7 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
@Override public void beforeTestSetup(TestSetup testSetup) throws Throwable { - beforeTestSetupWithSNMP(this, testSetup); + defineRHQ3ResourceKeys(this, testSetup); }
/** @@ -114,7 +144,37 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase */ @Override public void beforeTests(TestSetup setup) throws Throwable { - testWithSNMP(this, setup); + String failingRK = interpret("${main.rhq3.resource.key}", setup.getInventoryFileReplacements()); + testExpectedFailures(this, setup, 4, failingRK); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path"}) + public void testWithUnresolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; + inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-without-snmp.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + + defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); + //we use this in the serialized inventory to init the URL of the main server. The localhost.ip is actually what + //the RHQ 301 discovers even though unresolvable.host is specified in the ServerName directive. + defaultOverrides.put("servername", "${localhost.ip}"); + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}:${port1}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}:${port2}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}:${port3}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}:${port4}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + defineRHQ3ResourceKeys(this, testSetup); } }); } @@ -132,7 +192,6 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; upgradeShouldSucceed = false;
- defaultOverrides = new HashMap<String, String>(); defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}"); defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}"); @@ -142,7 +201,7 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
@Override public void beforeTestSetup(TestSetup testSetup) throws Throwable { - beforeTestSetupWithSNMP(this, testSetup); + defineRHQ3ResourceKeys(this, testSetup); }
/** @@ -151,7 +210,41 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase */ @Override public void beforeTests(TestSetup setup) throws Throwable { - testWithSNMP(this, setup); + String failingRK = interpret("${main.rhq3.resource.key}", setup.getInventoryFileReplacements()); + testExpectedFailures(this, setup, 4, failingRK); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path"}) + public void testWithNonUniqueNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-without-snmp.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + + //we use this in the serialized inventory to init the URL of the main server. The localhost.ip is actually what + //the RHQ 301 discovers even though unresolvable.host is specified in the ServerName directive. + defaultOverrides.put("servername", "${localhost.ip}"); + defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), + "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), + "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), + "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), + "ServerName ${unresolvable.host}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + defineRHQ3ResourceKeys(this, testSetup); } }); } @@ -187,13 +280,11 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; upgradeShouldSucceed = false; - - defaultOverrides = new HashMap<String, String>(); }
@Override public void beforeTestSetup(TestSetup testSetup) throws Throwable { - beforeTestSetupWithSNMP(this, testSetup); + defineRHQ3ResourceKeys(this, testSetup); }
/** @@ -202,73 +293,168 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase */ @Override public void beforeTests(TestSetup setup) throws Throwable { - //ok, now we should see the resources upgraded in the fake server inventory. - ResourceType serverResourceType = findApachePluginResourceTypeByName("Apache HTTP Server"); - ResourceType vhostResourceType = findApachePluginResourceTypeByName("Apache Virtual Host"); - - Set<Resource> servers = setup.getFakeInventory().findResourcesByType(serverResourceType); - - assertEquals(servers.size(), 1, "There should be exactly one apache server discovered."); - - Resource server = servers.iterator().next(); - - String expectedResourceKey = ApacheServerDiscoveryComponent.formatResourceKey(this.serverRoot, this.serverRoot - + "/conf/httpd.conf"); - - assertEquals(server.getResourceKey(), expectedResourceKey, - "The server resource key doesn't seem to be upgraded."); - - Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(vhostResourceType); - - assertEquals(vhosts.size(), 5, "Unexpected number of vhosts discovered found"); - - //let's check that the main vhost has a an upgrade error attached to it - ApacheServerComponent component = setup.withApacheSetup().getExecutionUtil().getServerComponent(); - ApacheDirectiveTree config = component.loadParser(); - config = RuntimeApacheConfiguration.extract(config, component.getCurrentProcessInfo(), component.getCurrentBinaryInfo(), component.getModuleNames(), false); - VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config); - - String mainVhost1RK = keyUtil.getRHQ3NonSNMPLegacyMainServerResourceKey(); - String mainVhost2RK = interpret("${localhost.ip}:${listen1}", setup.getInventoryFileReplacements()); - Resource mainVhost1 = null; - Resource mainVhost2 = null; - for(Resource r : vhosts) { - if (mainVhost1RK.equals(r.getResourceKey())) { - mainVhost1 = r; - break; - } - } - for(Resource r : vhosts) { - if (mainVhost2RK.equals(r.getResourceKey())) { - mainVhost2 = r; - break; - } - } + String mainVHost1RK = interpret("${main.rhq3.resource.key}", setup.getInventoryFileReplacements()); + String mainVhost2RK = interpret("${localhost}:${port1}", setup.getInventoryFileReplacements());
- assertNotNull(mainVhost1, "Couldn't find the main vhost with the expected resource key '" + mainVhost1RK + "'."); - assertNotNull(mainVhost2, "Couldn't find the main vhost with the expected resource key '" + mainVhost2RK + "'."); + testExpectedFailures(this, setup, 5, mainVHost1RK, mainVhost2RK); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path" }) + public void testWithAnyAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + //yes, the inventory file can be the same for both the with and without snmp tests because + //they both yield the same inventory in this case. + inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp-anyaddr.xml"; + serverRoot = installPath; + binPath = exePath; + + //just define the servername value without actually setting the ${servername.directive} so that + //we don't define a servername directive itself but do have a value for the actual server name. + //this is deduced by apache and the plugin but tests aren't that clever. + defaultOverrides.put("servername", "${localhost.ip}"); + defaultOverrides.put(variableName(configurationName, "listen1"), "0.0.0.0:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "0.0.0.0:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "0.0.0.0:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "0.0.0.0:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "0.0.0.0:${port1}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + defineRHQ3ResourceKeys(this, testSetup); + } + }); + } + + /** + * Unlike other SNMP tests this one actually succeeds to upgrade because of the messed up discovery that + * RHQ 3.0.0 would perform. In case of any-address (0.0.0.0), the main vhost would get the MainServer + * resource key even with SNMP, because RHQ 3 codebase wouldn't be able to match what it think should + * have been the SNMP record with the actual results from SNMP module. + * <p> + * Because of this, RHQ 3 discovers all 5 vhosts and the upgrade code is therefore able to successfully + * upgrade all of them. + * + * @param installPath + * @param exePath + * @throws Throwable + */ + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path" }) + public void testWithAnyAddressWithSNMP(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
- List<ResourceError> errors = mainVhost1.getResourceErrors(ResourceErrorType.UPGRADE); - assertNotNull(errors, "The main vhost doesn't have any upgrade errors."); - assertEquals(errors.size(), 1, "There should be exactly one upgrade error on the main vhost."); + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp-anyaddr.xml"; + serverRoot = installPath; + binPath = exePath; + + defaultOverrides.put(variableName(configurationName, "listen1"), "0.0.0.0:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "0.0.0.0:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "0.0.0.0:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "0.0.0.0:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "0.0.0.0:${port1}"); + }
- errors = mainVhost2.getResourceErrors(ResourceErrorType.UPGRADE); - assertNotNull(errors, "The main vhost doesn't have any upgrade errors."); - assertEquals(errors.size(), 1, "There should be exactly one upgrade error on the main vhost."); + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + defineRHQ3ResourceKeys(this, testSetup); + } + }); + } + + /** + * This configuration will fail to upgrade the first vhost, because it doesn't uniquely match to new-style + * vhosts - it could be either a main vhost or vhost1. + */ + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path" }) + public void testWithWildcardAddressWithoutSNMP(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS;
- //check that all other vhosts were not upgraded but have no errors - for(Resource r : vhosts) { - if (r.equals(mainVhost1) || r.equals(mainVhost2)) { - continue; - } - - assertEquals(r.getResourceErrors(ResourceErrorType.UPGRADE).size(), 0, "Unexpected number of resource upgrade errors on non-main vhost " + r); - } + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-without-snmp.xml"; + serverRoot = installPath; + binPath = exePath; + upgradeShouldSucceed = false; + + //just define the servername value without actually setting the ${servername.directive} so that + //we don't define a servername directive itself but do have a value for the actual server name. + //this is deduced by apache and the plugin but tests aren't that clever. + defaultOverrides.put("servername", "${localhost.ip}"); + defaultOverrides.put(variableName(configurationName, "listen1"), "*:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "*:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "*:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "*:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "*:${port1}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + defineRHQ3ResourceKeys(this, testSetup); + } + + @Override + public void beforeTests(TestSetup setup) throws Throwable { + String failingRK = interpret("${vhost1.rhq3.resource.key}", setup.getInventoryFileReplacements()); + testExpectedFailures(this, setup, 5, failingRK); } }); }
- private void beforeTestSetupWithSNMP(TestConfiguration testConfig, TestSetup setup) throws Exception { + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path" }) + public void testWithWildcardAddressWithSNMP(final String installPath, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS; + + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml"; + serverRoot = installPath; + binPath = exePath; + upgradeShouldSucceed = false; + + defaultOverrides.put(variableName(configurationName, "listen1"), "*:${port1}"); + defaultOverrides.put(variableName(configurationName, "listen2"), "*:${port2}"); + defaultOverrides.put(variableName(configurationName, "listen3"), "*:${port3}"); + defaultOverrides.put(variableName(configurationName, "listen4"), "*:${port4}"); + defaultOverrides.put(variableName(configurationName, "vhost1.urls"), "*:${port1}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + defineRHQ3ResourceKeys(this, testSetup); + } + + /** + * Do our own tests here, because the generic test method won't do much, since + * we told it that the upgrade won't succeed. + */ + @Override + public void beforeTests(TestSetup setup) throws Throwable { + String failingRK = interpret("${main.rhq3.resource.key}", setup.getInventoryFileReplacements()); + testExpectedFailures(this, setup, 4, failingRK); + } + }); + } + + private void defineRHQ3ResourceKeys(TestConfiguration testConfig, TestSetup setup) throws Exception { setup.withApacheSetup().init(); ApacheServerComponent component = setup.withApacheSetup().getExecutionUtil().getServerComponent(); ApacheDirectiveTree config = component.loadParser(); @@ -301,7 +487,7 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase setup.withDefaultOverrides(testConfig.defaultOverrides); }
- private void testWithSNMP(TestConfiguration testConfig, TestSetup setup) { + private void testExpectedFailures(TestConfiguration testConfig, TestSetup setup, int numberOfVhosts, String... failingRKs) { //ok, now we should see the resources upgraded in the fake server inventory. ResourceType serverResourceType = findApachePluginResourceTypeByName("Apache HTTP Server"); ResourceType vhostResourceType = findApachePluginResourceTypeByName("Apache Virtual Host"); @@ -320,7 +506,7 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase
Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(vhostResourceType);
- assertEquals(vhosts.size(), 4, "Unexpected number of vhosts discovered found"); + assertEquals(vhosts.size(), numberOfVhosts, "Unexpected number of vhosts discovered found");
//let's check that the main vhost has a an upgrade error attached to it ApacheServerComponent component = setup.withApacheSetup().getExecutionUtil().getServerComponent(); @@ -328,25 +514,28 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase config = RuntimeApacheConfiguration.extract(config, component.getCurrentProcessInfo(), component.getCurrentBinaryInfo(), component.getModuleNames(), false); VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config);
- String mainVhostRK = keyUtil.getRHQ3NonSNMPLegacyMainServerResourceKey(); + Set<Resource> failingResources = new HashSet<Resource>();
- Resource mainVhost = null; - for(Resource r : vhosts) { - if (mainVhostRK.equals(r.getResourceKey())) { - mainVhost = r; - break; + for(String rk : failingRKs) { + for(Resource r : vhosts) { + if (rk.equals(r.getResourceKey())) { + failingResources.add(r); + break; + } } }
- assertNotNull(mainVhost, "Couldn't find the main vhost with the expected resource key '" + mainVhostRK + "'."); + assertEquals(failingResources.size(), failingRKs.length, "Couldn't find all the resources that should have failed.");
- List<ResourceError> errors = mainVhost.getResourceErrors(ResourceErrorType.UPGRADE); - assertNotNull(errors, "The main vhost doesn't have any upgrade errors."); - assertEquals(errors.size(), 1, "There should be exactly one upgrade error on the main vhost."); + for(Resource failingResource : failingResources) { + List<ResourceError> errors = failingResource.getResourceErrors(ResourceErrorType.UPGRADE); + assertNotNull(errors, "The main vhost doesn't have any upgrade errors."); + assertEquals(errors.size(), 1, "There should be exactly one upgrade error on the main vhost."); + }
//check that all other vhosts were not upgraded but have no errors for(Resource r : vhosts) { - if (r.equals(mainVhost)) { + if (failingResources.contains(r)) { continue; }
diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java index 59c1348..831b2d8 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java @@ -60,10 +60,12 @@ import org.rhq.core.pluginapi.inventory.PluginContainerDeployment; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; import org.rhq.core.system.SystemInfoFactory; +import org.rhq.plugins.apache.parser.ApacheConfigReader; import org.rhq.plugins.apache.parser.ApacheDirectiveTree; +import org.rhq.plugins.apache.parser.ApacheParser; +import org.rhq.plugins.apache.parser.ApacheParserImpl; import org.rhq.plugins.apache.util.ApacheDeploymentUtil; import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig; -import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig.VHost; import org.rhq.plugins.apache.util.ApacheExecutionUtil; import org.rhq.plugins.apache.util.HttpdAddressUtility; import org.rhq.plugins.apache.util.VHostSpec; @@ -149,6 +151,8 @@ public class UpgradeTestBase extends PluginContainerTest { assertTrue(confDir.exists(), "The configured server root denotes a directory that doesn't have a 'conf' subdirectory. This is unexpected.");
+ String confFilePath = confDir.getAbsolutePath() + File.separatorChar + "httpd.conf"; + String snmpHost = null; int snmpPort = 0; String pingUrl = null; @@ -157,13 +161,15 @@ public class UpgradeTestBase extends PluginContainerTest { if (deploy) { ApacheDeploymentUtil.deployConfiguration(confDir, configurationFiles, deploymentConfig); } - - HttpdAddressUtility.Address addr = deploymentConfig.mainServer.address1; - HttpdAddressUtility.Address addrToUse = new HttpdAddressUtility.Address(null, null, - HttpdAddressUtility.Address.NO_PORT_SPECIFIED_VALUE); - addrToUse.scheme = addr.scheme == null ? "http" : addr.scheme; - addrToUse.host = addr.host == null ? "localhost" : addr.host; - addrToUse.port = addr.port; + + //ok, now try to find the ping URL. The best thing is to actually invoke + //the same code the apache server discovery does. + ApacheDirectiveTree tree = new ApacheDirectiveTree(); + ApacheParser parser = new ApacheParserImpl(tree, serverRootDir.getAbsolutePath()); + ApacheConfigReader.buildTree(confFilePath, parser); + + //XXX this hardcodes apache2 as the only option we have... + HttpdAddressUtility.Address addrToUse = HttpdAddressUtility.APACHE_2_x.getMainServerSampleAddress(tree, null, -1); pingUrl = addrToUse.toString();
snmpHost = deploymentConfig.snmpHost; @@ -171,7 +177,7 @@ public class UpgradeTestBase extends PluginContainerTest { }
execution = new ApacheExecutionUtil(findApachePluginResourceTypeByName("Apache HTTP Server"), - serverRoot, exePath, confDir.getAbsolutePath() + File.separatorChar + "httpd.conf", pingUrl, + serverRoot, exePath, confFilePath, pingUrl, snmpHost, snmpPort); execution.init(); } @@ -384,7 +390,7 @@ public class UpgradeTestBase extends PluginContainerTest { public String configurationName; public String serverRoot; public String binPath; - public Map<String, String> defaultOverrides; + public Map<String, String> defaultOverrides = new HashMap<String, String>(); public boolean upgradeShouldSucceed = true;
public void beforeTestSetup(TestSetup testSetup) throws Throwable { @@ -406,6 +412,7 @@ public class UpgradeTestBase extends PluginContainerTest {
protected static final String DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES = "simpleWithResolvableServerNames"; protected static final String DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES = "simpleWithUnresolvableServerNames"; + protected static final String DEPLOYMENT_SIMPLE_WITH_WILDCARD_LISTENS = "simpleWithWildcardListens";
private List<ResourceType> resourceTypesInApachePlugin; protected Resource platform; @@ -573,4 +580,17 @@ public class UpgradeTestBase extends PluginContainerTest {
return bld.toString(); } + + protected static InetAddress determineLocalhost() { + try { + return InetAddress.getLocalHost(); + } catch (UnknownHostException e) { + try { + return InetAddress.getByName("127.0.0.1"); + } catch (UnknownHostException ee) { + //doesn't happen + return null; + } + } + } } diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java index 232741f..b640b59 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java @@ -159,9 +159,7 @@ public class ApacheDeploymentUtil { : serverNameDirective);
String serverName = getServerName(); - if (serverName != null) { - tokenReplacements.put(prefix + SERVERNAME, serverName); - } + tokenReplacements.put(prefix + SERVERNAME, serverName == null ? "" : serverName);
String dirs = ""; if (!additionalDirectives.isEmpty()) { diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp-anyaddr.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp-anyaddr.xml new file mode 100644 index 0000000..fc34748 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp-anyaddr.xml @@ -0,0 +1,538 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10022</id> + <uuid>e61040b4-d645-44dc-a6b7-460d39f1b625</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost}:${port1}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1308835177519</ctime> + <mtime>1308835282077</mtime> + <itime>1308835282077</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10044</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10101</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10102</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>20037</id> + <uuid>b2928cc6-30ab-47fe-8095-e1292887ac18</uuid> + <resourceKey>${main.rhq4.resource.key}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + <itime>1308835287473</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10188</id> + <version>0</version> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10189</id> + <version>0</version> + <ctime>1308835287474</ctime> + <mtime>1308835287474</mtime> + <propertySimple> + <id>10806</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10805</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10808</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10807</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10036</id> + <uuid>5eb8fa91-2a4e-4a6e-9cd7-7b1927ea1a3a</uuid> + <resourceKey>${vhost2.rhq3.resource.key}</resourceKey> + <name>${vhost2.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287457</ctime> + <mtime>1308835287457</mtime> + <itime>1308835287457</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10186</id> + <version>0</version> + <ctime>1308835287457</ctime> + <mtime>1308835287457</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10187</id> + <version>0</version> + <ctime>1308835287458</ctime> + <mtime>1308835287458</mtime> + <propertySimple> + <id>10802</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10801</id> + <name>responseTimeLogFile</name> + <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/localhost.localdomain11676_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10804</id> + <name>url</name> + <stringValue>http://$%7Bvhost2.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10803</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10037</id> + <uuid>b2928cc6-30ab-47fe-8095-e1292887ac18</uuid> + <resourceKey>${main.rhq3.resource.key}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + <itime>1308835287473</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10188</id> + <version>0</version> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10189</id> + <version>0</version> + <ctime>1308835287474</ctime> + <mtime>1308835287474</mtime> + <propertySimple> + <id>10806</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10805</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10808</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10807</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10038</id> + <uuid>fe8d389e-5a45-4bf2-9f73-0831caca63df</uuid> + <resourceKey>${vhost4.rhq3.resource.key}</resourceKey> + <name>${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <itime>1308835287481</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10190</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10191</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <propertySimple> + <id>10810</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10809</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10812</id> + <name>url</name> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10811</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10039</id> + <uuid>369d9dee-b4e1-45bf-9ad9-6a5d8cdd563e</uuid> + <resourceKey>${vhost3.rhq3.resource.key}</resourceKey> + <name>${vhost3.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287493</ctime> + <mtime>1308835287493</mtime> + <itime>1308835287492</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10192</id> + <version>0</version> + <ctime>1308835287493</ctime> + <mtime>1308835287493</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10193</id> + <version>0</version> + <ctime>1308835287494</ctime> + <mtime>1308835287494</mtime> + <propertySimple> + <id>10814</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10813</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}logs/localhost.localdomain11677_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10816</id> + <name>url</name> + <stringValue>http://$%7Bvhost3.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10815</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10174</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10175</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + <propertySimple> + <id>10790</id> + <name>errorLogIncludesPattern</name> + </propertySimple> + <propertySimple> + <id>10783</id> + <name>errorLogMinimumSeverity</name> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>augeasEnabled</name> + <stringValue>no</stringValue> + </propertySimple> + <propertySimple> + <id>10789</id> + <name>errorLogFilePath</name> + </propertySimple> + <propertySimple> + <id>10786</id> + <name>snmpAgentCommunity</name> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10784</id> + <name>snmpAgentHost</name> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10782</id> + <name>errorLogEventsEnabled</name> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10793</id> + <name>controlScriptPath</name> + </propertySimple> + <propertySimple> + <id>10795</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10709</id> + <name>augeasModuleName</name> + <stringValue>Httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10794</id> + <name>configFile</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10710</id> + <name>configurationFilesInclusionPatterns</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10788</id> + <name>vhostFilesMask</name> + <stringValue>${server.root}/conf/*</stringValue> + </propertySimple> + <propertySimple> + <id>10787</id> + <name>restartAfterConfigurationUpdate</name> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10792</id> + <name>executablePath</name> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10785</id> + <name>snmpAgentPort</name> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10781</id> + <name>vhostCreationPolicy</name> + <stringValue>vhost-per-file</stringValue> + </propertySimple> + <propertySimple> + <id>10791</id> + <name>serverRoot</name> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml index 3d41813..ff9d715 100644 --- a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml @@ -9,7 +9,7 @@ <id>10022</id> <uuid>e61040b4-d645-44dc-a6b7-460d39f1b625</uuid> <resourceKey>${server.root}</resourceKey> - <name>${localhost}:${listen1}</name> + <name>${localhost}:${port1}</name> <inventoryStatus>COMMITTED</inventoryStatus> <connected>false</connected> <version>2.2.17</version> @@ -179,7 +179,7 @@ <propertySimple> <id>10808</id> <name>url</name> - <stringValue>http://$%7Blocalhost%7D:$%7Blisten1%7D/</stringValue> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> </propertySimple> <propertySimple> <id>10807</id> @@ -398,7 +398,7 @@ <propertySimple> <id>10795</id> <name>url</name> - <stringValue>http://$%7Blocalhost%7D:$%7Blisten1%7D/</stringValue> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> </propertySimple> <propertySimple> <id>10709</id> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml index 76269db..590b10f 100644 --- a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml @@ -9,7 +9,7 @@ <id>10041</id> <uuid>02f44194-9bb8-44ef-9866-ef7b69eedc0a</uuid> <resourceKey>${server.root}</resourceKey> - <name>${localhost}:${listen1}</name> + <name>${localhost}:${port1}</name> <inventoryStatus>COMMITTED</inventoryStatus> <connected>true</connected> <version>2.2.17</version> @@ -255,7 +255,7 @@ <propertySimple> <id>10928</id> <name>url</name> - <stringValue>http://$%7Blocalhost%7D:$%7Blisten1%7D/</stringValue> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> </propertySimple> <propertySimple> <id>10927</id> @@ -351,7 +351,7 @@ <id>10050</id> <uuid>ae880c2d-747d-492d-8586-a47ab5791b0e</uuid> <resourceKey>${vhost1.rhq4.resource.key}</resourceKey> - <name>${vhos1.snmp.identifier}</name> + <name>${vhost1.snmp.identifier}</name> <inventoryStatus>COMMITTED</inventoryStatus> <connected>false</connected> <version></version> @@ -474,7 +474,7 @@ <propertySimple> <id>10868</id> <name>url</name> - <stringValue>http://$%7Bservername%7D:$%7Blisten1%7D/</stringValue> + <stringValue>http://$%7Bservername%7D:$%7Bport1%7D/</stringValue> </propertySimple> <propertySimple> <id>10870</id> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-with-duplicate-main.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-with-duplicate-main.xml index 999914d..78fc9dd 100644 --- a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-with-duplicate-main.xml +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-with-duplicate-main.xml @@ -9,7 +9,7 @@ <id>10022</id> <uuid>e61040b4-d645-44dc-a6b7-460d39f1b625</uuid> <resourceKey>${server.root}</resourceKey> - <name>${localhost}:${listen1}</name> + <name>${localhost}:${port1}</name> <inventoryStatus>COMMITTED</inventoryStatus> <connected>false</connected> <version>2.2.17</version> @@ -179,7 +179,7 @@ <propertySimple> <id>10808</id> <name>url</name> - <stringValue>http://$%7Blocalhost%7D:$%7Blisten1%7D/</stringValue> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> </propertySimple> <propertySimple> <id>10807</id> @@ -198,7 +198,7 @@ <childResources> <id>100371</id> <uuid>b2928cc6-30ab-47fe-8095-e1292887ac90</uuid> - <resourceKey>${localhost.ip}:${listen1}</resourceKey> + <resourceKey>${localhost}:${port1}</resourceKey> <name>Main</name> <inventoryStatus>COMMITTED</inventoryStatus> <connected>false</connected> @@ -255,7 +255,7 @@ <propertySimple> <id>10808</id> <name>url</name> - <stringValue>http://$%7Blocalhost.ip%7D:$%7Blisten1%7D/</stringValue> + <stringValue>http://$%7Blocalhost.ip%7D:$%7Bport1%7D/</stringValue> </propertySimple> <propertySimple> <id>10807</id> @@ -474,7 +474,7 @@ <propertySimple> <id>10795</id> <name>url</name> - <stringValue>http://$%7Blocalhost%7D:$%7Blisten1%7D/</stringValue> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> </propertySimple> <propertySimple> <id>10709</id> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp-anyaddr.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp-anyaddr.xml new file mode 100644 index 0000000..47d502d --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp-anyaddr.xml @@ -0,0 +1,538 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10022</id> + <uuid>e61040b4-d645-44dc-a6b7-460d39f1b625</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost}:${port1}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1308835177519</ctime> + <mtime>1308835282077</mtime> + <itime>1308835282077</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10044</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10101</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10102</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>20037</id> + <uuid>b2928cc6-30ab-47fe-8095-e1292887ac18</uuid> + <resourceKey>0.0.0.0:${port1}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + <itime>1308835287473</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10188</id> + <version>0</version> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10189</id> + <version>0</version> + <ctime>1308835287474</ctime> + <mtime>1308835287474</mtime> + <propertySimple> + <id>10806</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10805</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10808</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10807</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10036</id> + <uuid>5eb8fa91-2a4e-4a6e-9cd7-7b1927ea1a3a</uuid> + <resourceKey>${vhost2.rhq3.resource.key}</resourceKey> + <name>${vhost2.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287457</ctime> + <mtime>1308835287457</mtime> + <itime>1308835287457</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10186</id> + <version>0</version> + <ctime>1308835287457</ctime> + <mtime>1308835287457</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10187</id> + <version>0</version> + <ctime>1308835287458</ctime> + <mtime>1308835287458</mtime> + <propertySimple> + <id>10802</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10801</id> + <name>responseTimeLogFile</name> + <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/localhost.localdomain11676_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10804</id> + <name>url</name> + <stringValue>http://$%7Bvhost2.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10803</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10037</id> + <uuid>b2928cc6-30ab-47fe-8095-e1292887ac18</uuid> + <resourceKey>${main.rhq3.resource.key}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + <itime>1308835287473</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10188</id> + <version>0</version> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10189</id> + <version>0</version> + <ctime>1308835287474</ctime> + <mtime>1308835287474</mtime> + <propertySimple> + <id>10806</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10805</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10808</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10807</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10038</id> + <uuid>fe8d389e-5a45-4bf2-9f73-0831caca63df</uuid> + <resourceKey>${vhost4.rhq3.resource.key}</resourceKey> + <name>${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <itime>1308835287481</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10190</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10191</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <propertySimple> + <id>10810</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10809</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10812</id> + <name>url</name> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10811</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10039</id> + <uuid>369d9dee-b4e1-45bf-9ad9-6a5d8cdd563e</uuid> + <resourceKey>${vhost3.rhq3.resource.key}</resourceKey> + <name>${vhost3.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287493</ctime> + <mtime>1308835287493</mtime> + <itime>1308835287492</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10192</id> + <version>0</version> + <ctime>1308835287493</ctime> + <mtime>1308835287493</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10193</id> + <version>0</version> + <ctime>1308835287494</ctime> + <mtime>1308835287494</mtime> + <propertySimple> + <id>10814</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10813</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}logs/localhost.localdomain11677_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10816</id> + <name>url</name> + <stringValue>http://$%7Bvhost3.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10815</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10174</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10175</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + <propertySimple> + <id>10790</id> + <name>errorLogIncludesPattern</name> + </propertySimple> + <propertySimple> + <id>10783</id> + <name>errorLogMinimumSeverity</name> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>augeasEnabled</name> + <stringValue>no</stringValue> + </propertySimple> + <propertySimple> + <id>10789</id> + <name>errorLogFilePath</name> + </propertySimple> + <propertySimple> + <id>10786</id> + <name>snmpAgentCommunity</name> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10784</id> + <name>snmpAgentHost</name> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10782</id> + <name>errorLogEventsEnabled</name> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10793</id> + <name>controlScriptPath</name> + </propertySimple> + <propertySimple> + <id>10795</id> + <name>url</name> + <stringValue>http://0.0.0.0:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10709</id> + <name>augeasModuleName</name> + <stringValue>Httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10794</id> + <name>configFile</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10710</id> + <name>configurationFilesInclusionPatterns</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10788</id> + <name>vhostFilesMask</name> + <stringValue>${server.root}/conf/*</stringValue> + </propertySimple> + <propertySimple> + <id>10787</id> + <name>restartAfterConfigurationUpdate</name> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10792</id> + <name>executablePath</name> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10785</id> + <name>snmpAgentPort</name> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10781</id> + <name>vhostCreationPolicy</name> + <stringValue>vhost-per-file</stringValue> + </propertySimple> + <propertySimple> + <id>10791</id> + <name>serverRoot</name> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml index 3d41813..ff9d715 100644 --- a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml @@ -9,7 +9,7 @@ <id>10022</id> <uuid>e61040b4-d645-44dc-a6b7-460d39f1b625</uuid> <resourceKey>${server.root}</resourceKey> - <name>${localhost}:${listen1}</name> + <name>${localhost}:${port1}</name> <inventoryStatus>COMMITTED</inventoryStatus> <connected>false</connected> <version>2.2.17</version> @@ -179,7 +179,7 @@ <propertySimple> <id>10808</id> <name>url</name> - <stringValue>http://$%7Blocalhost%7D:$%7Blisten1%7D/</stringValue> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> </propertySimple> <propertySimple> <id>10807</id> @@ -398,7 +398,7 @@ <propertySimple> <id>10795</id> <name>url</name> - <stringValue>http://$%7Blocalhost%7D:$%7Blisten1%7D/</stringValue> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> </propertySimple> <propertySimple> <id>10709</id> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-without-snmp.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-without-snmp.xml new file mode 100644 index 0000000..44ea502 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-without-snmp.xml @@ -0,0 +1,538 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10041</id> + <uuid>02f44194-9bb8-44ef-9866-ef7b69eedc0a</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost}:${port1}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>true</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1309116183350</ctime> + <mtime>1309116225316</mtime> + <itime>1309116225316</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10044</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10101</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10102</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10046</id> + <uuid>908ea047-889e-4978-a61f-d96e8b1c6d17</uuid> + <resourceKey>${vhost4.rhq3.resource.key}</resourceKey> + <name>${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635789</ctime> + <mtime>1309117635789</mtime> + <itime>1309117635788</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10241</id> + <version>0</version> + <ctime>1309117635789</ctime> + <mtime>1309117635789</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10242</id> + <version>0</version> + <ctime>1309117635790</ctime> + <mtime>1309117635790</mtime> + <propertySimple> + <id>10858</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10857</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10860</id> + <name>url</name> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10859</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10047</id> + <uuid>5fccc52b-8003-42ed-aa69-0b146c783e91</uuid> + <resourceKey>${vhost3.rhq3.resource.key}</resourceKey> + <name>${vhost3.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635802</ctime> + <mtime>1309117635802</mtime> + <itime>1309117635802</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10243</id> + <version>0</version> + <ctime>1309117635802</ctime> + <mtime>1309117635802</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10244</id> + <version>0</version> + <ctime>1309117635802</ctime> + <mtime>1309117635802</mtime> + <propertySimple> + <id>10922</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10921</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11677_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10924</id> + <name>url</name> + <stringValue>http://$%7Bvhost3.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10923</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10048</id> + <uuid>704a31f3-7f5f-46c1-9bda-70f2645c9604</uuid> + <resourceKey>${main.rhq3.resource.key}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635810</ctime> + <mtime>1309117635810</mtime> + <itime>1309117635810</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10245</id> + <version>0</version> + <ctime>1309117635811</ctime> + <mtime>1309117635811</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10246</id> + <version>0</version> + <ctime>1309117635811</ctime> + <mtime>1309117635811</mtime> + <propertySimple> + <id>10926</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10925</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10928</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10927</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10049</id> + <uuid>03638606-623b-4218-bd23-42e04db0e296</uuid> + <resourceKey>${vhost2.rhq3.resource.key}</resourceKey> + <name>${vhost2.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635819</ctime> + <mtime>1309117635819</mtime> + <itime>1309117635818</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10247</id> + <version>0</version> + <ctime>1309117635819</ctime> + <mtime>1309117635819</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10248</id> + <version>0</version> + <ctime>1309117635819</ctime> + <mtime>1309117635819</mtime> + <propertySimple> + <id>10930</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10929</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11676_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10932</id> + <name>url</name> + <stringValue>http://$%7Bvhost2.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10931</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10050</id> + <uuid>ae880c2d-747d-492d-8586-a47ab5791b0e</uuid> + <resourceKey>${vhost1.rhq3.resource.key}</resourceKey> + <name>${vhost1.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635829</ctime> + <mtime>1309117635829</mtime> + <itime>1309117635829</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10249</id> + <version>0</version> + <ctime>1309117635829</ctime> + <mtime>1309117635829</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10250</id> + <version>0</version> + <ctime>1309117635829</ctime> + <mtime>1309117635829</mtime> + <propertySimple> + <id>10934</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10933</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10936</id> + <name>url</name> + <stringValue>http://$%7Bvhost1.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10935</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10201</id> + <version>0</version> + <ctime>1309116183368</ctime> + <mtime>1309116183368</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10211</id> + <version>0</version> + <ctime>1309117523737</ctime> + <mtime>1309117523737</mtime> + <propertySimple> + <id>10863</id> + <name>errorLogIncludesPattern</name> + </propertySimple> + <propertySimple> + <id>10862</id> + <name>errorLogMinimumSeverity</name> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10861</id> + <name>augeasEnabled</name> + <stringValue>no</stringValue> + </propertySimple> + <propertySimple> + <id>10865</id> + <name>errorLogFilePath</name> + </propertySimple> + <propertySimple> + <id>10864</id> + <name>snmpAgentCommunity</name> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10867</id> + <name>snmpAgentHost</name> + <stringValue>${unresolvable.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10866</id> + <name>errorLogEventsEnabled</name> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10869</id> + <name>controlScriptPath</name> + </propertySimple> + <propertySimple> + <id>10868</id> + <name>url</name> + <stringValue>http://$%7Bservername%7D:$%7Bport1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10870</id> + <name>augeasModuleName</name> + <stringValue>Httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10871</id> + <name>configFile</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10872</id> + <name>configurationFilesInclusionPatterns</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10873</id> + <name>vhostFilesMask</name> + <stringValue>${server.root}/conf/*</stringValue> + </propertySimple> + <propertySimple> + <id>10874</id> + <name>executablePath</name> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10875</id> + <name>restartAfterConfigurationUpdate</name> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10876</id> + <name>snmpAgentPort</name> + <stringValue>1610</stringValue> + </propertySimple> + <propertySimple> + <id>10877</id> + <name>serverRoot</name> + <stringValue>${server.root}</stringValue> + </propertySimple> + <propertySimple> + <id>10878</id> + <name>vhostCreationPolicy</name> + <stringValue>vhost-per-file</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> +</objects> +</inventory-dump>
commit f019479e86c88a7702fc61a6955f5449501b3818 Author: Lukas Krejci lkrejci@redhat.com Date: Tue Jun 28 17:05:38 2011 +0200
Added a batch of tests for RHQ 3.0.1. More to come..
diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java new file mode 100644 index 0000000..5938889 --- /dev/null +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_1Test.java @@ -0,0 +1,360 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.plugins.apache; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +import java.io.StringReader; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.resource.ResourceError; +import org.rhq.core.domain.resource.ResourceErrorType; +import org.rhq.core.domain.resource.ResourceType; +import org.rhq.core.util.stream.StreamUtil; +import org.rhq.plugins.apache.parser.ApacheDirectiveTree; +import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig; +import org.rhq.plugins.apache.util.RuntimeApacheConfiguration; +import org.rhq.plugins.apache.util.VirtualHostLegacyResourceKeyUtil; +import org.rhq.test.TokenReplacingReader; +import org.rhq.test.pc.PluginContainerSetup; + +/** + * + * + * @author Lukas Krejci + */ +public class UpgradeSimpleConfigurationFromRHQ3_0_1Test extends UpgradeTestBase { + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path"}) + public void testWithResolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; + inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + upgradeShouldSucceed = false; + + defaultOverrides = new HashMap<String, String>(); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + beforeTestSetupWithSNMP(this, testSetup); + } + + /** + * Do our own tests here, because the generic test method won't do much, since + * we told it that the upgrade won't succeed. + */ + @Override + public void beforeTests(TestSetup setup) throws Throwable { + testWithSNMP(this, setup); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path"}) + public void testWithUnresolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; + inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + upgradeShouldSucceed = false; + + defaultOverrides = new HashMap<String, String>(); + defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}:${listen1}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}:${listen2}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}:${listen3}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}:${listen4}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + beforeTestSetupWithSNMP(this, testSetup); + } + + /** + * Do our own tests here, because the generic test method won't do much, since + * we told it that the upgrade won't succeed. + */ + @Override + public void beforeTests(TestSetup setup) throws Throwable { + testWithSNMP(this, setup); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path"}) + public void testWithNonUniqueNamesWithSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; + inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + upgradeShouldSucceed = false; + + defaultOverrides = new HashMap<String, String>(); + defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + beforeTestSetupWithSNMP(this, testSetup); + } + + /** + * Do our own tests here, because the generic test method won't do much, since + * we told it that the upgrade won't succeed. + */ + @Override + public void beforeTests(TestSetup setup) throws Throwable { + testWithSNMP(this, setup); + } + }); + } + + /** + * The duplicate Main vhosts "condition" was triggered by: + * <ol> + * <li>Disabling SNMP by putting in an invalid hostname + * <li>Changing the URL of the apache server to some "other" value + * <li>Running discovery + * </ol> + * From that point on, 2 Main vhosts live in the inventory and the inventory has the "rest" + * of the resource keys coming from the SNMP based discovery. + * <p> + * It is not possible to recover from such condition automatically during + * the resource upgrade, so the only thing we need to check here is that + * the two main vhosts are marked as failed upgrade and that the rest of the vhosts + * are not upgraded and have no upgrade errors attached. + * + * @param installDir + * @param exePath + * @throws Throwable + */ + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path"}) + public void testDuplicateMainVhostsMarkedAsFailedUpgrade(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; + inventoryFile = "/mocked-inventories/rhq-3.0.1/simple/inventory-with-duplicate-main.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + upgradeShouldSucceed = false; + + defaultOverrides = new HashMap<String, String>(); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + beforeTestSetupWithSNMP(this, testSetup); + } + + /** + * Do our own tests here, because the generic test method won't do much, since + * we told it that the upgrade won't succeed. + */ + @Override + public void beforeTests(TestSetup setup) throws Throwable { + //ok, now we should see the resources upgraded in the fake server inventory. + ResourceType serverResourceType = findApachePluginResourceTypeByName("Apache HTTP Server"); + ResourceType vhostResourceType = findApachePluginResourceTypeByName("Apache Virtual Host"); + + Set<Resource> servers = setup.getFakeInventory().findResourcesByType(serverResourceType); + + assertEquals(servers.size(), 1, "There should be exactly one apache server discovered."); + + Resource server = servers.iterator().next(); + + String expectedResourceKey = ApacheServerDiscoveryComponent.formatResourceKey(this.serverRoot, this.serverRoot + + "/conf/httpd.conf"); + + assertEquals(server.getResourceKey(), expectedResourceKey, + "The server resource key doesn't seem to be upgraded."); + + Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(vhostResourceType); + + assertEquals(vhosts.size(), 5, "Unexpected number of vhosts discovered found"); + + //let's check that the main vhost has a an upgrade error attached to it + ApacheServerComponent component = setup.withApacheSetup().getExecutionUtil().getServerComponent(); + ApacheDirectiveTree config = component.loadParser(); + config = RuntimeApacheConfiguration.extract(config, component.getCurrentProcessInfo(), component.getCurrentBinaryInfo(), component.getModuleNames(), false); + VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config); + + String mainVhost1RK = keyUtil.getRHQ3NonSNMPLegacyMainServerResourceKey(); + String mainVhost2RK = interpret("${localhost.ip}:${listen1}", setup.getInventoryFileReplacements()); + Resource mainVhost1 = null; + Resource mainVhost2 = null; + for(Resource r : vhosts) { + if (mainVhost1RK.equals(r.getResourceKey())) { + mainVhost1 = r; + break; + } + } + for(Resource r : vhosts) { + if (mainVhost2RK.equals(r.getResourceKey())) { + mainVhost2 = r; + break; + } + } + + assertNotNull(mainVhost1, "Couldn't find the main vhost with the expected resource key '" + mainVhost1RK + "'."); + assertNotNull(mainVhost2, "Couldn't find the main vhost with the expected resource key '" + mainVhost2RK + "'."); + + List<ResourceError> errors = mainVhost1.getResourceErrors(ResourceErrorType.UPGRADE); + assertNotNull(errors, "The main vhost doesn't have any upgrade errors."); + assertEquals(errors.size(), 1, "There should be exactly one upgrade error on the main vhost."); + + errors = mainVhost2.getResourceErrors(ResourceErrorType.UPGRADE); + assertNotNull(errors, "The main vhost doesn't have any upgrade errors."); + assertEquals(errors.size(), 1, "There should be exactly one upgrade error on the main vhost."); + + //check that all other vhosts were not upgraded but have no errors + for(Resource r : vhosts) { + if (r.equals(mainVhost1) || r.equals(mainVhost2)) { + continue; + } + + assertEquals(r.getResourceErrors(ResourceErrorType.UPGRADE).size(), 0, "Unexpected number of resource upgrade errors on non-main vhost " + r); + } + } + }); + } + + private void beforeTestSetupWithSNMP(TestConfiguration testConfig, TestSetup setup) throws Exception { + setup.withApacheSetup().init(); + ApacheServerComponent component = setup.withApacheSetup().getExecutionUtil().getServerComponent(); + ApacheDirectiveTree config = component.loadParser(); + config = RuntimeApacheConfiguration.extract(config, component.getCurrentProcessInfo(), component.getCurrentBinaryInfo(), component.getModuleNames(), false); + + DeploymentConfig deployConfig = setup.getDeploymentConfig(); + + VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config); + + Map<String, String> replacements = deployConfig.getTokenReplacements(); + + testConfig.defaultOverrides.put("main.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyMainServerResourceKey()); + + if (deployConfig.vhost1 != null) { + testConfig.defaultOverrides.put("vhost1.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost1.getVHostSpec(replacements))); + } + + if (deployConfig.vhost2 != null) { + testConfig.defaultOverrides.put("vhost2.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost2.getVHostSpec(replacements))); + } + + if (deployConfig.vhost3 != null) { + testConfig.defaultOverrides.put("vhost3.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost3.getVHostSpec(replacements))); + } + + if (deployConfig.vhost4 != null) { + testConfig.defaultOverrides.put("vhost4.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost4.getVHostSpec(replacements))); + } + + setup.withDefaultOverrides(testConfig.defaultOverrides); + } + + private void testWithSNMP(TestConfiguration testConfig, TestSetup setup) { + //ok, now we should see the resources upgraded in the fake server inventory. + ResourceType serverResourceType = findApachePluginResourceTypeByName("Apache HTTP Server"); + ResourceType vhostResourceType = findApachePluginResourceTypeByName("Apache Virtual Host"); + + Set<Resource> servers = setup.getFakeInventory().findResourcesByType(serverResourceType); + + assertEquals(servers.size(), 1, "There should be exactly one apache server discovered."); + + Resource server = servers.iterator().next(); + + String expectedResourceKey = ApacheServerDiscoveryComponent.formatResourceKey(testConfig.serverRoot, testConfig.serverRoot + + "/conf/httpd.conf"); + + assertEquals(server.getResourceKey(), expectedResourceKey, + "The server resource key doesn't seem to be upgraded."); + + Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(vhostResourceType); + + assertEquals(vhosts.size(), 4, "Unexpected number of vhosts discovered found"); + + //let's check that the main vhost has a an upgrade error attached to it + ApacheServerComponent component = setup.withApacheSetup().getExecutionUtil().getServerComponent(); + ApacheDirectiveTree config = component.loadParser(); + config = RuntimeApacheConfiguration.extract(config, component.getCurrentProcessInfo(), component.getCurrentBinaryInfo(), component.getModuleNames(), false); + VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config); + + String mainVhostRK = keyUtil.getRHQ3NonSNMPLegacyMainServerResourceKey(); + + Resource mainVhost = null; + for(Resource r : vhosts) { + if (mainVhostRK.equals(r.getResourceKey())) { + mainVhost = r; + break; + } + } + + assertNotNull(mainVhost, "Couldn't find the main vhost with the expected resource key '" + mainVhostRK + "'."); + + List<ResourceError> errors = mainVhost.getResourceErrors(ResourceErrorType.UPGRADE); + assertNotNull(errors, "The main vhost doesn't have any upgrade errors."); + assertEquals(errors.size(), 1, "There should be exactly one upgrade error on the main vhost."); + + //check that all other vhosts were not upgraded but have no errors + for(Resource r : vhosts) { + if (r.equals(mainVhost)) { + continue; + } + + assertEquals(r.getResourceErrors(ResourceErrorType.UPGRADE).size(), 0, "Unexpected number of resource upgrade errors on non-main vhost " + r); + } + } + + private String interpret(String string, Map<String, String> variables) { + return StreamUtil.slurp(new TokenReplacingReader(new StringReader(string), variables)); + } +} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java index 9726250..59c1348 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java @@ -89,7 +89,8 @@ public class UpgradeTestBase extends PluginContainerTest { private ApacheSetup apacheSetup = new ApacheSetup(); private DeploymentConfig deploymentConfig; private Map<String, String> defaultOverrides = new HashMap<String, String>(); - + private Map<String, String> inventoryFileReplacements; + public class ApacheSetup { private String serverRoot; private String exePath; @@ -272,7 +273,8 @@ public class UpgradeTestBase extends PluginContainerTest { Map<String, String> replacements = deploymentConfig.getTokenReplacements(); replacements.put("server.root", apacheSetup.serverRoot); replacements.put("exe.path", apacheSetup.exePath); - replacements.put("localhost", determineLocalhost()); + + ApacheDeploymentUtil.addDefaultVariables(replacements, null);
HttpdAddressUtility addressUtility = apacheSetup.getExecutionUtil().getServerComponent() .getAddressUtility(); @@ -339,6 +341,8 @@ public class UpgradeTestBase extends PluginContainerTest { //let the user override everything we just did replacements.putAll(defaultOverrides);
+ inventoryFileReplacements = replacements; + InputStream dataStream = getClass().getResourceAsStream(inventoryFile);
Reader rdr = new TokenReplacingReader(new InputStreamReader(dataStream), replacements); @@ -355,6 +359,15 @@ public class UpgradeTestBase extends PluginContainerTest { return this; }
+ /** + * After the setup, this returns all the variables used to update the tokens in the inventory file. + * + * @return + */ + public Map<String, String> getInventoryFileReplacements() { + return inventoryFileReplacements; + } + private void fixupParent(Resource parent, Collection<Resource> children) { for (Resource child : children) { child.setParentResource(parent); @@ -363,14 +376,6 @@ public class UpgradeTestBase extends PluginContainerTest { } } } - - private String determineLocalhost() { - try { - return InetAddress.getLocalHost().getCanonicalHostName(); - } catch (UnknownHostException e) { - return "127.0.0.1"; - } - } }
protected static class TestConfiguration { diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml index eb2f7c7..76269db 100644 --- a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml @@ -474,7 +474,7 @@ <propertySimple> <id>10868</id> <name>url</name> - <stringValue>http://$%7Blocalhost%7D:$%7Blisten1%7D/</stringValue> + <stringValue>http://$%7Bservername%7D:$%7Blisten1%7D/</stringValue> </propertySimple> <propertySimple> <id>10870</id> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-with-duplicate-main.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-with-duplicate-main.xml new file mode 100644 index 0000000..999914d --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-with-duplicate-main.xml @@ -0,0 +1,538 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10022</id> + <uuid>e61040b4-d645-44dc-a6b7-460d39f1b625</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost}:${listen1}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1308835177519</ctime> + <mtime>1308835282077</mtime> + <itime>1308835282077</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10044</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10101</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10102</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10036</id> + <uuid>5eb8fa91-2a4e-4a6e-9cd7-7b1927ea1a3a</uuid> + <resourceKey>${vhost2.rhq3.resource.key}</resourceKey> + <name>${vhost2.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287457</ctime> + <mtime>1308835287457</mtime> + <itime>1308835287457</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10186</id> + <version>0</version> + <ctime>1308835287457</ctime> + <mtime>1308835287457</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10187</id> + <version>0</version> + <ctime>1308835287458</ctime> + <mtime>1308835287458</mtime> + <propertySimple> + <id>10802</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10801</id> + <name>responseTimeLogFile</name> + <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/localhost.localdomain11676_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10804</id> + <name>url</name> + <stringValue>http://$%7Bvhost2.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10803</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10037</id> + <uuid>b2928cc6-30ab-47fe-8095-e1292887ac18</uuid> + <resourceKey>${main.rhq3.resource.key}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + <itime>1308835287473</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10188</id> + <version>0</version> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10189</id> + <version>0</version> + <ctime>1308835287474</ctime> + <mtime>1308835287474</mtime> + <propertySimple> + <id>10806</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10805</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10808</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Blisten1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10807</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>100371</id> + <uuid>b2928cc6-30ab-47fe-8095-e1292887ac90</uuid> + <resourceKey>${localhost.ip}:${listen1}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + <itime>1308835287473</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10188</id> + <version>0</version> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10189</id> + <version>0</version> + <ctime>1308835287474</ctime> + <mtime>1308835287474</mtime> + <propertySimple> + <id>10806</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10805</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10808</id> + <name>url</name> + <stringValue>http://$%7Blocalhost.ip%7D:$%7Blisten1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10807</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10038</id> + <uuid>fe8d389e-5a45-4bf2-9f73-0831caca63df</uuid> + <resourceKey>${vhost4.rhq3.resource.key}</resourceKey> + <name>${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <itime>1308835287481</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10190</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10191</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <propertySimple> + <id>10810</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10809</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10812</id> + <name>url</name> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10811</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10039</id> + <uuid>369d9dee-b4e1-45bf-9ad9-6a5d8cdd563e</uuid> + <resourceKey>${vhost3.rhq3.resource.key}</resourceKey> + <name>${vhost3.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287493</ctime> + <mtime>1308835287493</mtime> + <itime>1308835287492</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10192</id> + <version>0</version> + <ctime>1308835287493</ctime> + <mtime>1308835287493</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10193</id> + <version>0</version> + <ctime>1308835287494</ctime> + <mtime>1308835287494</mtime> + <propertySimple> + <id>10814</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10813</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}logs/localhost.localdomain11677_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10816</id> + <name>url</name> + <stringValue>http://$%7Bvhost3.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10815</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10174</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10175</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + <propertySimple> + <id>10790</id> + <name>errorLogIncludesPattern</name> + </propertySimple> + <propertySimple> + <id>10783</id> + <name>errorLogMinimumSeverity</name> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>augeasEnabled</name> + <stringValue>no</stringValue> + </propertySimple> + <propertySimple> + <id>10789</id> + <name>errorLogFilePath</name> + </propertySimple> + <propertySimple> + <id>10786</id> + <name>snmpAgentCommunity</name> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10784</id> + <name>snmpAgentHost</name> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10782</id> + <name>errorLogEventsEnabled</name> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10793</id> + <name>controlScriptPath</name> + </propertySimple> + <propertySimple> + <id>10795</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Blisten1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10709</id> + <name>augeasModuleName</name> + <stringValue>Httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10794</id> + <name>configFile</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10710</id> + <name>configurationFilesInclusionPatterns</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10788</id> + <name>vhostFilesMask</name> + <stringValue>${server.root}/conf/*</stringValue> + </propertySimple> + <propertySimple> + <id>10787</id> + <name>restartAfterConfigurationUpdate</name> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10792</id> + <name>executablePath</name> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10785</id> + <name>snmpAgentPort</name> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10781</id> + <name>vhostCreationPolicy</name> + <stringValue>vhost-per-file</stringValue> + </propertySimple> + <propertySimple> + <id>10791</id> + <name>serverRoot</name> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml new file mode 100644 index 0000000..3d41813 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.1/simple/inventory-with-snmp.xml @@ -0,0 +1,462 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10022</id> + <uuid>e61040b4-d645-44dc-a6b7-460d39f1b625</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost}:${listen1}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1308835177519</ctime> + <mtime>1308835282077</mtime> + <itime>1308835282077</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10044</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10101</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10102</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10036</id> + <uuid>5eb8fa91-2a4e-4a6e-9cd7-7b1927ea1a3a</uuid> + <resourceKey>${vhost2.rhq3.resource.key}</resourceKey> + <name>${vhost2.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287457</ctime> + <mtime>1308835287457</mtime> + <itime>1308835287457</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10186</id> + <version>0</version> + <ctime>1308835287457</ctime> + <mtime>1308835287457</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10187</id> + <version>0</version> + <ctime>1308835287458</ctime> + <mtime>1308835287458</mtime> + <propertySimple> + <id>10802</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10801</id> + <name>responseTimeLogFile</name> + <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/localhost.localdomain11676_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10804</id> + <name>url</name> + <stringValue>http://$%7Bvhost2.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10803</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10037</id> + <uuid>b2928cc6-30ab-47fe-8095-e1292887ac18</uuid> + <resourceKey>${main.rhq3.resource.key}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + <itime>1308835287473</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10188</id> + <version>0</version> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10189</id> + <version>0</version> + <ctime>1308835287474</ctime> + <mtime>1308835287474</mtime> + <propertySimple> + <id>10806</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10805</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10808</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Blisten1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10807</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10038</id> + <uuid>fe8d389e-5a45-4bf2-9f73-0831caca63df</uuid> + <resourceKey>${vhost4.rhq3.resource.key}</resourceKey> + <name>${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <itime>1308835287481</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10190</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10191</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <propertySimple> + <id>10810</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10809</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10812</id> + <name>url</name> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10811</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10039</id> + <uuid>369d9dee-b4e1-45bf-9ad9-6a5d8cdd563e</uuid> + <resourceKey>${vhost3.rhq3.resource.key}</resourceKey> + <name>${vhost3.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287493</ctime> + <mtime>1308835287493</mtime> + <itime>1308835287492</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10192</id> + <version>0</version> + <ctime>1308835287493</ctime> + <mtime>1308835287493</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10193</id> + <version>0</version> + <ctime>1308835287494</ctime> + <mtime>1308835287494</mtime> + <propertySimple> + <id>10814</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10813</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}logs/localhost.localdomain11677_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10816</id> + <name>url</name> + <stringValue>http://$%7Bvhost3.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10815</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10174</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10175</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + <propertySimple> + <id>10790</id> + <name>errorLogIncludesPattern</name> + </propertySimple> + <propertySimple> + <id>10783</id> + <name>errorLogMinimumSeverity</name> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>augeasEnabled</name> + <stringValue>no</stringValue> + </propertySimple> + <propertySimple> + <id>10789</id> + <name>errorLogFilePath</name> + </propertySimple> + <propertySimple> + <id>10786</id> + <name>snmpAgentCommunity</name> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10784</id> + <name>snmpAgentHost</name> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10782</id> + <name>errorLogEventsEnabled</name> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10793</id> + <name>controlScriptPath</name> + </propertySimple> + <propertySimple> + <id>10795</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Blisten1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10709</id> + <name>augeasModuleName</name> + <stringValue>Httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10794</id> + <name>configFile</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10710</id> + <name>configurationFilesInclusionPatterns</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10788</id> + <name>vhostFilesMask</name> + <stringValue>${server.root}/conf/*</stringValue> + </propertySimple> + <propertySimple> + <id>10787</id> + <name>restartAfterConfigurationUpdate</name> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10792</id> + <name>executablePath</name> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10785</id> + <name>snmpAgentPort</name> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10781</id> + <name>vhostCreationPolicy</name> + <stringValue>vhost-per-file</stringValue> + </propertySimple> + <propertySimple> + <id>10791</id> + <name>serverRoot</name> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> +</objects> +</inventory-dump>
commit e1e0c171b991c623ba2a4eeb69d88b97690989aa Author: Lukas Krejci lkrejci@redhat.com Date: Tue Jun 28 15:53:21 2011 +0200
Adding slurp(Reader) to StreamUtil to complete the set of methods using readers/writers.
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/stream/StreamUtil.java b/modules/core/util/src/main/java/org/rhq/core/util/stream/StreamUtil.java index 19f56ac..be0446b 100644 --- a/modules/core/util/src/main/java/org/rhq/core/util/stream/StreamUtil.java +++ b/modules/core/util/src/main/java/org/rhq/core/util/stream/StreamUtil.java @@ -34,6 +34,7 @@ import java.io.ObjectOutputStream; import java.io.OutputStream; import java.io.Reader; import java.io.Serializable; +import java.io.StringWriter; import java.io.Writer;
import org.apache.commons.logging.Log; @@ -75,6 +76,19 @@ public class StreamUtil { }
/** + * Equivalent of {@link #slurp(InputStream)} but using a reader instead of input stream. + * + * @param reader + * @return + * @throws RuntimeException + */ + public static String slurp(Reader reader) throws RuntimeException { + StringWriter wrt = new StringWriter(); + copy(reader, wrt); + return wrt.toString(); + } + + /** * Copies data from the input stream to the output stream. Upon completion or on an exception, the streams will be * closed. *
commit 0b208d23a6f5d49f39bc916afc8ee2e57430d6e1 Author: Lukas Krejci lkrejci@redhat.com Date: Mon Jun 27 16:34:15 2011 +0200
Finish up the tests for RHQ 3.0.0
diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java index 5d4bb1d..8d0c03b 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java @@ -135,92 +135,183 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; upgradeShouldSucceed = false; + + defaultOverrides = new HashMap<String, String>(); }
@Override public void beforeTestSetup(TestSetup testSetup) throws Throwable { - testSetup.withApacheSetup().init(); - ApacheServerComponent component = testSetup.withApacheSetup().getExecutionUtil().getServerComponent(); - ApacheDirectiveTree config = component.loadParser(); - config = RuntimeApacheConfiguration.extract(config, component.getCurrentProcessInfo(), component.getCurrentBinaryInfo(), component.getModuleNames(), false); + beforeTestSetupWithSNMP(this, testSetup); + }
- DeploymentConfig deployConfig = testSetup.getDeploymentConfig(); - - VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config); - - Map<String, String> replacements = deployConfig.getTokenReplacements(); + /** + * Do our own tests here, because the generic test method won't do much, since + * we told it that the upgrade won't succeed. + */ + @Override + public void beforeTests(TestSetup setup) throws Throwable { + testWithSNMP(this, setup); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path"}) + public void testWithUnresolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; + inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + upgradeShouldSucceed = false;
defaultOverrides = new HashMap<String, String>(); - defaultOverrides.put("main.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyMainServerResourceKey()); - - if (deployConfig.vhost1 != null) { - defaultOverrides.put("vhost1.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost1.getVHostSpec(replacements))); - } - - if (deployConfig.vhost2 != null) { - defaultOverrides.put("vhost2.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost2.getVHostSpec(replacements))); - } - - if (deployConfig.vhost3 != null) { - defaultOverrides.put("vhost3.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost3.getVHostSpec(replacements))); - } - - if (deployConfig.vhost4 != null) { - defaultOverrides.put("vhost4.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost4.getVHostSpec(replacements))); - } + defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}:${listen1}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}:${listen2}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}:${listen3}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}:${listen4}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + beforeTestSetupWithSNMP(this, testSetup); + } + + /** + * Do our own tests here, because the generic test method won't do much, since + * we told it that the upgrade won't succeed. + */ + @Override + public void beforeTests(TestSetup setup) throws Throwable { + testWithSNMP(this, setup); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path"}) + public void testWithNonUniqueNamesWithSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; + inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + upgradeShouldSucceed = false;
- testSetup.withDefaultOverrides(defaultOverrides); + defaultOverrides = new HashMap<String, String>(); + defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}"); + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + beforeTestSetupWithSNMP(this, testSetup); }
/** - * Do our own tests here, because the test method won't do much, since + * Do our own tests here, because the generic test method won't do much, since * we told it that the upgrade won't succeed. */ @Override public void beforeTests(TestSetup setup) throws Throwable { - //ok, now we should see the resources upgraded in the fake server inventory. - ResourceType serverResourceType = findApachePluginResourceTypeByName("Apache HTTP Server"); - ResourceType vhostResourceType = findApachePluginResourceTypeByName("Apache Virtual Host"); - - Set<Resource> servers = setup.getFakeInventory().findResourcesByType(serverResourceType); + testWithSNMP(this, setup); + } + }); + } + + private void beforeTestSetupWithSNMP(TestConfiguration testConfig, TestSetup setup) throws Exception { + setup.withApacheSetup().init(); + ApacheServerComponent component = setup.withApacheSetup().getExecutionUtil().getServerComponent(); + ApacheDirectiveTree config = component.loadParser(); + config = RuntimeApacheConfiguration.extract(config, component.getCurrentProcessInfo(), component.getCurrentBinaryInfo(), component.getModuleNames(), false);
- assertEquals(servers.size(), 1, "There should be exactly one apache server discovered."); + DeploymentConfig deployConfig = setup.getDeploymentConfig(); + + VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config); + + Map<String, String> replacements = deployConfig.getTokenReplacements();
- Resource server = servers.iterator().next(); + testConfig.defaultOverrides.put("main.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyMainServerResourceKey());
- String expectedResourceKey = ApacheServerDiscoveryComponent.formatResourceKey(this.serverRoot, this.serverRoot - + "/conf/httpd.conf"); + if (deployConfig.vhost1 != null) { + testConfig.defaultOverrides.put("vhost1.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost1.getVHostSpec(replacements))); + }
- assertEquals(server.getResourceKey(), expectedResourceKey, - "The server resource key doesn't seem to be upgraded."); + if (deployConfig.vhost2 != null) { + testConfig.defaultOverrides.put("vhost2.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost2.getVHostSpec(replacements))); + }
- Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(vhostResourceType); + if (deployConfig.vhost3 != null) { + testConfig.defaultOverrides.put("vhost3.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost3.getVHostSpec(replacements))); + }
- assertEquals(vhosts.size(), 4, "Unexpected number of vhosts discovered found"); + if (deployConfig.vhost4 != null) { + testConfig.defaultOverrides.put("vhost4.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost4.getVHostSpec(replacements))); + } + + setup.withDefaultOverrides(testConfig.defaultOverrides); + } + + private void testWithSNMP(TestConfiguration testConfig, TestSetup setup) { + //ok, now we should see the resources upgraded in the fake server inventory. + ResourceType serverResourceType = findApachePluginResourceTypeByName("Apache HTTP Server"); + ResourceType vhostResourceType = findApachePluginResourceTypeByName("Apache Virtual Host");
- //let's check that the main vhost has a an upgrade error attached to it - ApacheServerComponent component = setup.withApacheSetup().getExecutionUtil().getServerComponent(); - ApacheDirectiveTree config = component.loadParser(); - config = RuntimeApacheConfiguration.extract(config, component.getCurrentProcessInfo(), component.getCurrentBinaryInfo(), component.getModuleNames(), false); - VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config); + Set<Resource> servers = setup.getFakeInventory().findResourcesByType(serverResourceType);
- String mainVhostRK = keyUtil.getRHQ3NonSNMPLegacyMainServerResourceKey(); - - Resource mainVhost = null; - for(Resource r : vhosts) { - if (mainVhostRK.equals(r.getResourceKey())) { - mainVhost = r; - break; - } - } - - assertNotNull(mainVhost, "Couldn't find the main vhost with the expected resource key '" + mainVhostRK + "'."); - - List<ResourceError> errors = mainVhost.getResourceErrors(ResourceErrorType.UPGRADE); - assertNotNull(errors, "The main vhost doesn't have any upgrade errors."); - assertEquals(errors.size(), 1, "There should be exactly one upgrade error on the main vhost."); + assertEquals(servers.size(), 1, "There should be exactly one apache server discovered."); + + Resource server = servers.iterator().next(); + + String expectedResourceKey = ApacheServerDiscoveryComponent.formatResourceKey(testConfig.serverRoot, testConfig.serverRoot + + "/conf/httpd.conf"); + + assertEquals(server.getResourceKey(), expectedResourceKey, + "The server resource key doesn't seem to be upgraded."); + + Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(vhostResourceType); + + assertEquals(vhosts.size(), 4, "Unexpected number of vhosts discovered found"); + + //let's check that the main vhost has a an upgrade error attached to it + ApacheServerComponent component = setup.withApacheSetup().getExecutionUtil().getServerComponent(); + ApacheDirectiveTree config = component.loadParser(); + config = RuntimeApacheConfiguration.extract(config, component.getCurrentProcessInfo(), component.getCurrentBinaryInfo(), component.getModuleNames(), false); + VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config); + + String mainVhostRK = keyUtil.getRHQ3NonSNMPLegacyMainServerResourceKey(); + + Resource mainVhost = null; + for(Resource r : vhosts) { + if (mainVhostRK.equals(r.getResourceKey())) { + mainVhost = r; + break; } - }); + } + + assertNotNull(mainVhost, "Couldn't find the main vhost with the expected resource key '" + mainVhostRK + "'."); + + List<ResourceError> errors = mainVhost.getResourceErrors(ResourceErrorType.UPGRADE); + assertNotNull(errors, "The main vhost doesn't have any upgrade errors."); + assertEquals(errors.size(), 1, "There should be exactly one upgrade error on the main vhost."); + + //check that all other vhosts were not upgraded but have no errors + for(Resource r : vhosts) { + if (r.equals(mainVhost)) { + continue; + } + + assertEquals(r.getResourceErrors(ResourceErrorType.UPGRADE).size(), 0, "Unexpected number of resource upgrade errors on non-main vhost " + r); + } } - }
commit 4aff7c7212efe091e96ae9e3ae0eeb11e9a06212 Author: Lukas Krejci lkrejci@redhat.com Date: Mon Jun 27 15:15:14 2011 +0200
Make it possible for the TokenReplacingReader to resolve references to other tokens in token values and used that capability to be able to parametrize nearly every value during the tests. Added copy() methods to the StreamUtil that can consume reader and writer instead of the streams to aid me in using the TokenReplacingReader.
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/stream/StreamUtil.java b/modules/core/util/src/main/java/org/rhq/core/util/stream/StreamUtil.java index e970b83..19f56ac 100644 --- a/modules/core/util/src/main/java/org/rhq/core/util/stream/StreamUtil.java +++ b/modules/core/util/src/main/java/org/rhq/core/util/stream/StreamUtil.java @@ -23,6 +23,8 @@ package org.rhq.core.util.stream;
import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.BufferedWriter; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -30,7 +32,9 @@ import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStream; +import java.io.Reader; import java.io.Serializable; +import java.io.Writer;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -86,6 +90,19 @@ public class StreamUtil { }
/** + * Equivalent of {@link #copy(InputStream, OutputStream)} but using reader and writer instead + * of streams. + * + * @param rdr + * @param wrt + * @return + * @throws RuntimeException + */ + public static long copy(Reader rdr, Writer wrt) throws RuntimeException { + return copy(rdr, wrt, true); + } + + /** * Copies data from the input stream to the output stream. Upon completion or on an exception, the streams will be * closed but only if <code>closeStreams</code> is <code>true</code>. If <code>closeStreams</code> is <code> * false</code>, the streams are left open; the caller has the reponsibility to close them. @@ -136,6 +153,47 @@ public class StreamUtil { }
/** + * Equivalent of {@link #copy(InputStream, OutputStream, boolean)} only using reader and writer + * instead of input stream and output stream. + * + * @param rdr + * @param wrt + * @param closeStreams + * @return + * @throws RuntimeException + */ + public static long copy(Reader rdr, Writer wrt, boolean closeStreams) throws RuntimeException { + try { + long numCharsCopied = 0; + char[] buffer = new char[32768]; + + int cnt; + while((cnt = rdr.read(buffer)) != -1) { + numCharsCopied += cnt; + wrt.write(buffer, 0, cnt); + } + + return numCharsCopied; + } catch (IOException e) { + throw new RuntimeException("Reader could not have been copied to the writer.", e); + } finally { + if (closeStreams) { + try { + rdr.close(); + } catch (IOException ioe) { + LOG.warn("Reader could not be closed.", ioe); + } + + try { + wrt.close(); + } catch (IOException ioe) { + LOG.warn("Writer could not be closed.", ioe); + } + } + } + } + + /** * Copies data from the input stream to the output stream. The caller has the reponsibility to close them. This * method allows you to copy a byte range from the input stream. The start byte is the index (where the first byte * of the stream is index #0) that starts to be copied. <code>length</code> indicates how many bytes to copy, a diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java index 311033d..5d4bb1d 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java @@ -25,6 +25,7 @@ import static org.testng.Assert.assertNotNull;
import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Set;
import org.testng.annotations.Parameters; @@ -67,6 +68,50 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase }); }
+ @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}, numberOfInitialDiscoveries = 2) + @Parameters({"apache2.install.dir", "apache2.exe.path"}) + public void testWithUnresolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; + inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES; + + defaultOverrides = new HashMap<String, String>(); + defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}:${listen1}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}:${listen2}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}:${listen3}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}:${listen4}"); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}, numberOfInitialDiscoveries = 2) + @Parameters({"apache2.install.dir", "apache2.exe.path"}) + public void testWithNonUniqueNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; + inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES; + + defaultOverrides = new HashMap<String, String>(); + defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}"); + } + }); + } + /** * This tests the upgrade from RHQ 3.0.0 where the Apache server was discovered with the following: * <p> @@ -103,23 +148,25 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase
VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config);
+ Map<String, String> replacements = deployConfig.getTokenReplacements(); + defaultOverrides = new HashMap<String, String>(); defaultOverrides.put("main.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyMainServerResourceKey());
if (deployConfig.vhost1 != null) { - defaultOverrides.put("vhost1.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost1.getVHostSpec())); + defaultOverrides.put("vhost1.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost1.getVHostSpec(replacements))); }
if (deployConfig.vhost2 != null) { - defaultOverrides.put("vhost2.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost2.getVHostSpec())); + defaultOverrides.put("vhost2.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost2.getVHostSpec(replacements))); }
if (deployConfig.vhost3 != null) { - defaultOverrides.put("vhost3.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost3.getVHostSpec())); + defaultOverrides.put("vhost3.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost3.getVHostSpec(replacements))); }
if (deployConfig.vhost4 != null) { - defaultOverrides.put("vhost4.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost4.getVHostSpec())); + defaultOverrides.put("vhost4.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost4.getVHostSpec(replacements))); }
testSetup.withDefaultOverrides(defaultOverrides); diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java index 38f349e..9726250 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java @@ -63,8 +63,10 @@ import org.rhq.core.system.SystemInfoFactory; import org.rhq.plugins.apache.parser.ApacheDirectiveTree; import org.rhq.plugins.apache.util.ApacheDeploymentUtil; import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig; +import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig.VHost; import org.rhq.plugins.apache.util.ApacheExecutionUtil; import org.rhq.plugins.apache.util.HttpdAddressUtility; +import org.rhq.plugins.apache.util.VHostSpec; import org.rhq.test.ObjectCollectionSerializer; import org.rhq.test.TokenReplacingReader; import org.rhq.test.pc.PluginContainerTest; @@ -281,61 +283,57 @@ public class UpgradeTestBase extends PluginContainerTest {
replacements.put("main.rhq4.resource.key", ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY);
- String vhost1Address = deploymentConfig.vhost1 == null ? null : deploymentConfig.vhost1.address1.toString( - false, false); - String vhost2Address = deploymentConfig.vhost2 == null ? null : deploymentConfig.vhost2.address1.toString( - false, false); - String vhost3Address = deploymentConfig.vhost3 == null ? null : deploymentConfig.vhost3.address1.toString( - false, false); - String vhost4Address = deploymentConfig.vhost4 == null ? null : deploymentConfig.vhost4.address1.toString( - false, false); - - if (vhost1Address != null) { + VHostSpec vhost1 = deploymentConfig.vhost1 == null ? null : deploymentConfig.vhost1.getVHostSpec(replacements); + VHostSpec vhost2 = deploymentConfig.vhost2 == null ? null : deploymentConfig.vhost2.getVHostSpec(replacements); + VHostSpec vhost3 = deploymentConfig.vhost3 == null ? null : deploymentConfig.vhost3.getVHostSpec(replacements); + VHostSpec vhost4 = deploymentConfig.vhost4 == null ? null : deploymentConfig.vhost4.getVHostSpec(replacements); + + if (vhost1 != null) { replacements.put( "vhost1.snmp.identifier", - addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost1Address, - deploymentConfig.vhost1.getServerName()).toString(false, false)); + addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost1.hosts.get(0), + vhost1.serverName).toString(false, false));
replacements.put( "vhost1.rhq4.resource.key", ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - deploymentConfig.vhost1.getServerName(), deploymentConfig.vhost1.getAddresses())); + vhost1.serverName, vhost1.hosts)); }
- if (vhost2Address != null) { + if (vhost2 != null) { replacements.put( "vhost2.snmp.identifier", - addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost2Address, - deploymentConfig.vhost2.getServerName()).toString(false, false)); + addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost2.hosts.get(0), + vhost2.serverName).toString(false, false));
replacements.put( "vhost2.rhq4.resource.key", ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - deploymentConfig.vhost2.getServerName(), deploymentConfig.vhost2.getAddresses())); + vhost2.serverName, vhost2.hosts)); }
- if (vhost3Address != null) { + if (vhost3 != null) { replacements.put( "vhost3.snmp.identifier", - addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost3Address, - deploymentConfig.vhost3.getServerName()).toString(false, false)); + addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost3.hosts.get(0), + vhost3.serverName).toString(false, false));
replacements.put( "vhost3.rhq4.resource.key", ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - deploymentConfig.vhost3.getServerName(), deploymentConfig.vhost3.getAddresses())); + vhost3.serverName, vhost3.hosts)); }
- if (vhost4Address != null) { + if (vhost4 != null) { replacements.put( "vhost4.snmp.identifier", - addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost4Address, - deploymentConfig.vhost4.getServerName()).toString(false, false)); + addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost4.hosts.get(0), + vhost4.serverName).toString(false, false));
replacements.put( "vhost4.rhq4.resource.key", ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - deploymentConfig.vhost4.getServerName(), deploymentConfig.vhost4.getAddresses())); + vhost4.serverName, vhost4.hosts)); }
//let the user override everything we just did @@ -474,16 +472,22 @@ public class UpgradeTestBase extends PluginContainerTest { List<String> expectedResourceKeys = new ArrayList<String>(5);
DeploymentConfig dc = setup.getDeploymentConfig(); - + Map<String, String> replacements = dc.getTokenReplacements(); + + VHostSpec vh1 = dc.vhost1.getVHostSpec(replacements); + VHostSpec vh2 = dc.vhost2.getVHostSpec(replacements); + VHostSpec vh3 = dc.vhost3.getVHostSpec(replacements); + VHostSpec vh4 = dc.vhost4.getVHostSpec(replacements); + expectedResourceKeys.add(ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY); expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - dc.vhost1.getServerName(), dc.vhost1.getAddresses())); + vh1.serverName, vh1.hosts)); expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - dc.vhost2.getServerName(), dc.vhost2.getAddresses())); + vh2.serverName, vh2.hosts)); expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - dc.vhost3.getServerName(), dc.vhost3.getAddresses())); + vh3.serverName, vh3.hosts)); expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - dc.vhost4.getServerName(), dc.vhost4.getAddresses())); + vh4.serverName, vh4.hosts));
for (Resource vhost : vhosts) { assertTrue(expectedResourceKeys.contains(vhost.getResourceKey()), diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java index be73319..232741f 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java @@ -19,23 +19,29 @@
package org.rhq.plugins.apache.util;
+import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; +import java.io.StringReader; +import java.io.StringWriter; import java.net.InetAddress; import java.net.URL; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.Iterator; import java.util.List; +import java.util.ListIterator; import java.util.Map;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.unitils.thirdparty.org.apache.commons.io.FileUtils;
+import org.rhq.core.util.stream.StreamUtil; import org.rhq.plugins.apache.util.HttpdAddressUtility.Address; import org.rhq.test.TokenReplacingProperties; import org.rhq.test.TokenReplacingReader; @@ -76,7 +82,7 @@ public class ApacheDeploymentUtil { public String serverNameDirective = null; public final List<String> additionalDirectives = new ArrayList<String>();
- public String getServerName() { + private String getServerName() { String serverName = null; if (serverNameDirective != null && serverNameDirective.startsWith("ServerName")) { int startIdx = serverNameDirective.indexOf(' '); @@ -93,14 +99,21 @@ public class ApacheDeploymentUtil { return serverName; }
- public VHostSpec getVHostSpec() { + private String getServerName(Map<String, String> replacements) { + TokenReplacingReader rdr = new TokenReplacingReader(new StringReader(getServerName()), replacements); + StringWriter wrt = new StringWriter(); + StreamUtil.copy(rdr, wrt); + return wrt.toString(); + } + + public VHostSpec getVHostSpec(Map<String, String> replacements) { VHostSpec ret = new VHostSpec(); - ret.serverName = getServerName(); - ret.hosts = getAddresses(); + ret.serverName = getServerName(replacements); + ret.hosts = getAddresses(replacements); return ret; }
- public List<String> getAddresses() { + private List<String> getAddresses() { ArrayList<String> ret = new ArrayList<String>(); if (address1 != null) { ret.add(address1.toString()); @@ -118,6 +131,21 @@ public class ApacheDeploymentUtil { return ret; }
+ public List<String> getAddresses(Map<String, String> replacements) { + List<String> addresses = getAddresses(); + ListIterator<String> it = addresses.listIterator(); + while(it.hasNext()) { + String addr = it.next(); + + TokenReplacingReader rdr = new TokenReplacingReader(new StringReader(addr), replacements); + StringWriter wrt = new StringWriter(); + StreamUtil.copy(rdr, wrt); + it.set(wrt.toString()); + } + + return addresses; + } + private void addToTokenReplacements(int ordinal, Map<String, String> tokenReplacements) { String prefix = null;
@@ -184,7 +212,7 @@ public class ApacheDeploymentUtil { }
public Map<String, String> getTokenReplacements() { - HashMap<String, String> ret = new HashMap<String, String>(); + Map<String, String> ret = new TokenReplacingProperties(new HashMap<String, String>());
ret.put(SERVER_ROOT, serverRoot == null ? "" : serverRoot); ret.put(DOCUMENT_ROOT, documentRoot == null ? "" : documentRoot); diff --git a/modules/test-utils/src/main/java/org/rhq/test/TokenReplacingProperties.java b/modules/test-utils/src/main/java/org/rhq/test/TokenReplacingProperties.java index 0b9e87d..5708ee3 100644 --- a/modules/test-utils/src/main/java/org/rhq/test/TokenReplacingProperties.java +++ b/modules/test-utils/src/main/java/org/rhq/test/TokenReplacingProperties.java @@ -22,10 +22,8 @@ package org.rhq.test; import java.io.IOException; import java.io.Reader; import java.io.StringReader; -import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collection; -import java.util.Deque; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -65,7 +63,6 @@ public class TokenReplacingProperties extends HashMap<String, String> { private static final long serialVersionUID = 1L;
private Map<String, String> wrapped; - private Deque<String> currentResolutionStack = new ArrayDeque<String>(); private Map<Object, String> resolved = new HashMap<Object, String>();
private class Entry implements Map.Entry<String, String> { @@ -146,22 +143,14 @@ public class TokenReplacingProperties extends HashMap<String, String> { return resolved.get(key); }
- if (currentResolutionStack.contains(key)) { - throw new IllegalArgumentException("Property '" + key + "' indirectly references itself in its value."); - } - String rawValue = getRaw(key);
if (rawValue == null) { return null; }
- currentResolutionStack.push(key.toString()); - String ret = readAll(new TokenReplacingReader(new StringReader(rawValue.toString()), this));
- currentResolutionStack.pop(); - resolved.put(key, ret);
return ret; diff --git a/modules/test-utils/src/main/java/org/rhq/test/TokenReplacingReader.java b/modules/test-utils/src/main/java/org/rhq/test/TokenReplacingReader.java index 35ba2d2..bc5aef6 100644 --- a/modules/test-utils/src/main/java/org/rhq/test/TokenReplacingReader.java +++ b/modules/test-utils/src/main/java/org/rhq/test/TokenReplacingReader.java @@ -22,7 +22,11 @@ package org.rhq.test; import java.io.IOException; import java.io.PushbackReader; import java.io.Reader; +import java.io.StringReader; import java.nio.CharBuffer; +import java.util.ArrayDeque; +import java.util.Deque; +import java.util.HashMap; import java.util.Map;
/** @@ -39,12 +43,23 @@ public class TokenReplacingReader extends Reader { private String tokenValue = null; private int tokenValueIndex = 0; private boolean escaping = false; + private Deque<String> activeTokens; + private Map<String, String> resolvedTokens;
public TokenReplacingReader(Reader source, Map<String, String> tokens) { this.pushbackReader = new PushbackReader(source, 2); this.tokens = tokens; + this.activeTokens = new ArrayDeque<String>(); + this.resolvedTokens = new HashMap<String, String>(); }
+ protected TokenReplacingReader(String source, Map<String, String> tokens, Deque<String> activeTokens, Map<String, String> resolvedTokens) { + pushbackReader = new PushbackReader(new StringReader(source)); + this.tokens = tokens; + this.activeTokens = activeTokens; + this.resolvedTokens = resolvedTokens; + } + public int read(CharBuffer target) throws IOException { throw new RuntimeException("Operation Not Supported"); } @@ -88,12 +103,16 @@ public class TokenReplacingReader extends Reader { data = this.pushbackReader.read(); }
- this.tokenValue = tokens.get(this.tokenNameBuffer.toString()); - - if (this.tokenValue == null) { - this.tokenValue = "${" + this.tokenNameBuffer.toString() + "}"; + String tokenName = tokenNameBuffer.toString(); + + if (resolvedTokens.containsKey(tokenName)) { + tokenValue = resolvedTokens.get(tokenName); + } else { + tokenValue = resolveToken(tokenName); }
+ tokenValueIndex = 0; + if (!this.tokenValue.isEmpty()) { return this.tokenValue.charAt(this.tokenValueIndex++); } else { @@ -143,4 +162,40 @@ public class TokenReplacingReader extends Reader { public void reset() throws IOException { throw new IOException("reset() not supported on TokenReplacingReader."); } + + private String readAll(Reader r) throws IOException { + int c; + StringBuilder bld = new StringBuilder(); + while((c = r.read()) >= 0) { + bld.append((char)c); + } + + return bld.toString(); + } + + private String resolveToken(String tokenName) throws IOException { + if (activeTokens.contains(tokenName)) { + throw new IllegalArgumentException("Token '" + tokenName + "' (indirectly) contains reference to itself in its value."); + } + + activeTokens.push(tokenName); + + String tokenValue = tokens.get(tokenName); + + if (tokenValue != null) { + if (tokenValue.contains("${")) { + TokenReplacingReader childReader = new TokenReplacingReader(tokenValue, tokens, activeTokens, resolvedTokens); + + tokenValue = readAll(childReader); + } + } else { + tokenValue = "${" + tokenName + "}"; + } + + resolvedTokens.put(tokenName, tokenValue); + + activeTokens.pop(); + + return tokenValue; + } }
commit ced0cf7f6b8f8d56d3eaf0c5150a8189f051d474 Author: Lukas Krejci lkrejci@redhat.com Date: Mon Jun 27 11:51:22 2011 +0200
added some docs on what each of the RHQ 3.0.0 test tests, small correction in the inventory file.
diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java index 38fc049..311033d 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java @@ -47,10 +47,11 @@ import org.rhq.test.pc.PluginContainerSetup; */ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase {
- //TODO override the *.rhq3.resource.key variables in each test to define whether - //the resource key was discovered without SNMP, with SNMP, with Main Server URL set, - //or not - + /** + * This tests the upgrade from RHQ 3.0.0 where the apache server was discovered without SNMP support. + * The Main Server URL must have been set in this case, otherwise the component would fail to start + * and therefore the vhost discovery wouldn't even take place. + */ @Test @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}, numberOfInitialDiscoveries = 2) @Parameters({"apache2.install.dir", "apache2.exe.path"}) @@ -65,7 +66,18 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase } }); } - + + /** + * This tests the upgrade from RHQ 3.0.0 where the Apache server was discovered with the following: + * <p> + * <ol> + * <li> SNMP enabled + * <li> Main URL set or unset (it doesn't make a difference here) + * </ol> + * @param installDir + * @param exePath + * @throws Throwable + */ @Test @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) @Parameters({"apache2.install.dir", "apache2.exe.path"}) diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml index 5961b3e..eb2f7c7 100644 --- a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml @@ -9,7 +9,7 @@ <id>10041</id> <uuid>02f44194-9bb8-44ef-9866-ef7b69eedc0a</uuid> <resourceKey>${server.root}</resourceKey> - <name>${localhost}:{listen1}</name> + <name>${localhost}:${listen1}</name> <inventoryStatus>COMMITTED</inventoryStatus> <connected>true</connected> <version>2.2.17</version>
commit daf1e1a4fbf2b8781258969291207dffa9d470da Author: Lukas Krejci lkrejci@redhat.com Date: Sun Jun 26 23:23:55 2011 +0200
actually figured out how RHQ 3.0.0 discovered vhosts without SNMP support and added tests for it. Some minor fixes in the RHQ 3.0.0 with SNMP test.
diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java index 386a871..38fc049 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java @@ -51,68 +51,29 @@ public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase //the resource key was discovered without SNMP, with SNMP, with Main Server URL set, //or not
- //TODO the default inventory.xml uses discovery results without snmp active. with SNMP active, all 5 vhost - //would discovered in RHQ 3. This test should therefore use a different inventory file. - @Test(enabled = false) //this fails until the above todo is implemented + @Test @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}, numberOfInitialDiscoveries = 2) @Parameters({"apache2.install.dir", "apache2.exe.path"}) - public void testWithResolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable { + public void testWithResolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { testUpgrade(new TestConfiguration() { { apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; - inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory.xml"; + inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml"; serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; } - - @Override - public void beforeTestSetup(TestSetup testSetup) throws Throwable { - testSetup.withApacheSetup().init(); - ApacheServerComponent component = testSetup.withApacheSetup().getExecutionUtil().getServerComponent(); - ApacheDirectiveTree config = component.loadParser(); - config = RuntimeApacheConfiguration.extract(config, component.getCurrentProcessInfo(), component.getCurrentBinaryInfo(), component.getModuleNames(), false); - - DeploymentConfig deployConfig = testSetup.getDeploymentConfig(); - - VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config); - - defaultOverrides = new HashMap<String, String>(); - defaultOverrides.put("main.rhq3.resource.key", keyUtil.getRHQ3SNMPLikeResourceKey(keyUtil.getRHQ3NonSNMPLegacyMainServerResourceKey())); - - if (deployConfig.vhost1 != null) { - String rhq3Key = keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost1.getVHostSpec()); - defaultOverrides.put("vhost1.rhq3.resource.key", keyUtil.getRHQ3SNMPLikeResourceKey(rhq3Key)); - } - - if (deployConfig.vhost2 != null) { - String rhq3Key = keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost2.getVHostSpec()); - defaultOverrides.put("vhost2.rhq3.resource.key", keyUtil.getRHQ3SNMPLikeResourceKey(rhq3Key)); - } - - if (deployConfig.vhost3 != null) { - String rhq3Key = keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost3.getVHostSpec()); - defaultOverrides.put("vhost3.rhq3.resource.key", keyUtil.getRHQ3SNMPLikeResourceKey(rhq3Key)); - } - - if (deployConfig.vhost4 != null) { - String rhq3Key = keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost4.getVHostSpec()); - defaultOverrides.put("vhost4.rhq3.resource.key", keyUtil.getRHQ3SNMPLikeResourceKey(rhq3Key)); - } - - testSetup.withDefaultOverrides(defaultOverrides); - } }); }
@Test @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) @Parameters({"apache2.install.dir", "apache2.exe.path"}) - public void testWithResolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { + public void testWithResolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable { testUpgrade(new TestConfiguration() { { apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; - inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory.xml"; + inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml"; serverRoot = installDir; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java index 96260a6..38f349e 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java @@ -279,6 +279,8 @@ public class UpgradeTestBase extends PluginContainerTest { replacements.put("snmp.identifier", addressUtility.getHttpdInternalMainServerAddressRepresentation(runtimeConfig).toString(false, false));
+ replacements.put("main.rhq4.resource.key", ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY); + String vhost1Address = deploymentConfig.vhost1 == null ? null : deploymentConfig.vhost1.address1.toString( false, false); String vhost2Address = deploymentConfig.vhost2 == null ? null : deploymentConfig.vhost2.address1.toString( @@ -293,6 +295,11 @@ public class UpgradeTestBase extends PluginContainerTest { "vhost1.snmp.identifier", addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost1Address, deploymentConfig.vhost1.getServerName()).toString(false, false)); + + replacements.put( + "vhost1.rhq4.resource.key", + ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( + deploymentConfig.vhost1.getServerName(), deploymentConfig.vhost1.getAddresses())); }
if (vhost2Address != null) { @@ -300,6 +307,11 @@ public class UpgradeTestBase extends PluginContainerTest { "vhost2.snmp.identifier", addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost2Address, deploymentConfig.vhost2.getServerName()).toString(false, false)); + + replacements.put( + "vhost2.rhq4.resource.key", + ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( + deploymentConfig.vhost2.getServerName(), deploymentConfig.vhost2.getAddresses())); }
if (vhost3Address != null) { @@ -307,6 +319,11 @@ public class UpgradeTestBase extends PluginContainerTest { "vhost3.snmp.identifier", addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost3Address, deploymentConfig.vhost3.getServerName()).toString(false, false)); + + replacements.put( + "vhost3.rhq4.resource.key", + ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( + deploymentConfig.vhost3.getServerName(), deploymentConfig.vhost3.getAddresses())); }
if (vhost4Address != null) { @@ -314,6 +331,11 @@ public class UpgradeTestBase extends PluginContainerTest { "vhost4.snmp.identifier", addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost4Address, deploymentConfig.vhost4.getServerName()).toString(false, false)); + + replacements.put( + "vhost4.rhq4.resource.key", + ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( + deploymentConfig.vhost4.getServerName(), deploymentConfig.vhost4.getAddresses())); }
//let the user override everything we just did diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml new file mode 100644 index 0000000..3d41813 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-with-snmp.xml @@ -0,0 +1,462 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10022</id> + <uuid>e61040b4-d645-44dc-a6b7-460d39f1b625</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost}:${listen1}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1308835177519</ctime> + <mtime>1308835282077</mtime> + <itime>1308835282077</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10044</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10101</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10102</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10036</id> + <uuid>5eb8fa91-2a4e-4a6e-9cd7-7b1927ea1a3a</uuid> + <resourceKey>${vhost2.rhq3.resource.key}</resourceKey> + <name>${vhost2.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287457</ctime> + <mtime>1308835287457</mtime> + <itime>1308835287457</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10186</id> + <version>0</version> + <ctime>1308835287457</ctime> + <mtime>1308835287457</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10187</id> + <version>0</version> + <ctime>1308835287458</ctime> + <mtime>1308835287458</mtime> + <propertySimple> + <id>10802</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10801</id> + <name>responseTimeLogFile</name> + <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/localhost.localdomain11676_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10804</id> + <name>url</name> + <stringValue>http://$%7Bvhost2.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10803</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10037</id> + <uuid>b2928cc6-30ab-47fe-8095-e1292887ac18</uuid> + <resourceKey>${main.rhq3.resource.key}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + <itime>1308835287473</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10188</id> + <version>0</version> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10189</id> + <version>0</version> + <ctime>1308835287474</ctime> + <mtime>1308835287474</mtime> + <propertySimple> + <id>10806</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10805</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10808</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Blisten1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10807</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10038</id> + <uuid>fe8d389e-5a45-4bf2-9f73-0831caca63df</uuid> + <resourceKey>${vhost4.rhq3.resource.key}</resourceKey> + <name>${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <itime>1308835287481</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10190</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10191</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <propertySimple> + <id>10810</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10809</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10812</id> + <name>url</name> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10811</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10039</id> + <uuid>369d9dee-b4e1-45bf-9ad9-6a5d8cdd563e</uuid> + <resourceKey>${vhost3.rhq3.resource.key}</resourceKey> + <name>${vhost3.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287493</ctime> + <mtime>1308835287493</mtime> + <itime>1308835287492</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10192</id> + <version>0</version> + <ctime>1308835287493</ctime> + <mtime>1308835287493</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10193</id> + <version>0</version> + <ctime>1308835287494</ctime> + <mtime>1308835287494</mtime> + <propertySimple> + <id>10814</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10813</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}logs/localhost.localdomain11677_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10816</id> + <name>url</name> + <stringValue>http://$%7Bvhost3.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10815</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10174</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10175</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + <propertySimple> + <id>10790</id> + <name>errorLogIncludesPattern</name> + </propertySimple> + <propertySimple> + <id>10783</id> + <name>errorLogMinimumSeverity</name> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>augeasEnabled</name> + <stringValue>no</stringValue> + </propertySimple> + <propertySimple> + <id>10789</id> + <name>errorLogFilePath</name> + </propertySimple> + <propertySimple> + <id>10786</id> + <name>snmpAgentCommunity</name> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10784</id> + <name>snmpAgentHost</name> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10782</id> + <name>errorLogEventsEnabled</name> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10793</id> + <name>controlScriptPath</name> + </propertySimple> + <propertySimple> + <id>10795</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Blisten1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10709</id> + <name>augeasModuleName</name> + <stringValue>Httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10794</id> + <name>configFile</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10710</id> + <name>configurationFilesInclusionPatterns</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10788</id> + <name>vhostFilesMask</name> + <stringValue>${server.root}/conf/*</stringValue> + </propertySimple> + <propertySimple> + <id>10787</id> + <name>restartAfterConfigurationUpdate</name> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10792</id> + <name>executablePath</name> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10785</id> + <name>snmpAgentPort</name> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10781</id> + <name>vhostCreationPolicy</name> + <stringValue>vhost-per-file</stringValue> + </propertySimple> + <propertySimple> + <id>10791</id> + <name>serverRoot</name> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml new file mode 100644 index 0000000..5961b3e --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory-without-snmp.xml @@ -0,0 +1,538 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10041</id> + <uuid>02f44194-9bb8-44ef-9866-ef7b69eedc0a</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost}:{listen1}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>true</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1309116183350</ctime> + <mtime>1309116225316</mtime> + <itime>1309116225316</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10044</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10101</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10102</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10046</id> + <uuid>908ea047-889e-4978-a61f-d96e8b1c6d17</uuid> + <resourceKey>${vhost4.rhq4.resource.key}</resourceKey> + <name>${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635789</ctime> + <mtime>1309117635789</mtime> + <itime>1309117635788</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10241</id> + <version>0</version> + <ctime>1309117635789</ctime> + <mtime>1309117635789</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10242</id> + <version>0</version> + <ctime>1309117635790</ctime> + <mtime>1309117635790</mtime> + <propertySimple> + <id>10858</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10857</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10860</id> + <name>url</name> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10859</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10047</id> + <uuid>5fccc52b-8003-42ed-aa69-0b146c783e91</uuid> + <resourceKey>${vhost3.rhq4.resource.key}</resourceKey> + <name>${vhost3.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635802</ctime> + <mtime>1309117635802</mtime> + <itime>1309117635802</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10243</id> + <version>0</version> + <ctime>1309117635802</ctime> + <mtime>1309117635802</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10244</id> + <version>0</version> + <ctime>1309117635802</ctime> + <mtime>1309117635802</mtime> + <propertySimple> + <id>10922</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10921</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11677_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10924</id> + <name>url</name> + <stringValue>http://$%7Bvhost3.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10923</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10048</id> + <uuid>704a31f3-7f5f-46c1-9bda-70f2645c9604</uuid> + <resourceKey>${main.rhq4.resource.key}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635810</ctime> + <mtime>1309117635810</mtime> + <itime>1309117635810</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10245</id> + <version>0</version> + <ctime>1309117635811</ctime> + <mtime>1309117635811</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10246</id> + <version>0</version> + <ctime>1309117635811</ctime> + <mtime>1309117635811</mtime> + <propertySimple> + <id>10926</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10925</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10928</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Blisten1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10927</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10049</id> + <uuid>03638606-623b-4218-bd23-42e04db0e296</uuid> + <resourceKey>${vhost2.rhq4.resource.key}</resourceKey> + <name>${vhost2.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635819</ctime> + <mtime>1309117635819</mtime> + <itime>1309117635818</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10247</id> + <version>0</version> + <ctime>1309117635819</ctime> + <mtime>1309117635819</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10248</id> + <version>0</version> + <ctime>1309117635819</ctime> + <mtime>1309117635819</mtime> + <propertySimple> + <id>10930</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10929</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11676_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10932</id> + <name>url</name> + <stringValue>http://$%7Bvhost2.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10931</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10050</id> + <uuid>ae880c2d-747d-492d-8586-a47ab5791b0e</uuid> + <resourceKey>${vhost1.rhq4.resource.key}</resourceKey> + <name>${vhos1.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1309117635829</ctime> + <mtime>1309117635829</mtime> + <itime>1309117635829</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10249</id> + <version>0</version> + <ctime>1309117635829</ctime> + <mtime>1309117635829</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10250</id> + <version>0</version> + <ctime>1309117635829</ctime> + <mtime>1309117635829</mtime> + <propertySimple> + <id>10934</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10933</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10936</id> + <name>url</name> + <stringValue>http://$%7Bvhost1.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10935</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10201</id> + <version>0</version> + <ctime>1309116183368</ctime> + <mtime>1309116183368</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10211</id> + <version>0</version> + <ctime>1309117523737</ctime> + <mtime>1309117523737</mtime> + <propertySimple> + <id>10863</id> + <name>errorLogIncludesPattern</name> + </propertySimple> + <propertySimple> + <id>10862</id> + <name>errorLogMinimumSeverity</name> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10861</id> + <name>augeasEnabled</name> + <stringValue>no</stringValue> + </propertySimple> + <propertySimple> + <id>10865</id> + <name>errorLogFilePath</name> + </propertySimple> + <propertySimple> + <id>10864</id> + <name>snmpAgentCommunity</name> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10867</id> + <name>snmpAgentHost</name> + <stringValue>${unresolvable.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10866</id> + <name>errorLogEventsEnabled</name> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10869</id> + <name>controlScriptPath</name> + </propertySimple> + <propertySimple> + <id>10868</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Blisten1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10870</id> + <name>augeasModuleName</name> + <stringValue>Httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10871</id> + <name>configFile</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10872</id> + <name>configurationFilesInclusionPatterns</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10873</id> + <name>vhostFilesMask</name> + <stringValue>${server.root}/conf/*</stringValue> + </propertySimple> + <propertySimple> + <id>10874</id> + <name>executablePath</name> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10875</id> + <name>restartAfterConfigurationUpdate</name> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10876</id> + <name>snmpAgentPort</name> + <stringValue>1610</stringValue> + </propertySimple> + <propertySimple> + <id>10877</id> + <name>serverRoot</name> + <stringValue>${server.root}</stringValue> + </propertySimple> + <propertySimple> + <id>10878</id> + <name>vhostCreationPolicy</name> + <stringValue>vhost-per-file</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory.xml deleted file mode 100644 index be89240..0000000 --- a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory.xml +++ /dev/null @@ -1,462 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<inventory-dump> -<classes-used> -<class>org.rhq.core.domain.resource.Resource</class> -</classes-used> -<objects> - -<resource> - <id>10022</id> - <uuid>e61040b4-d645-44dc-a6b7-460d39f1b625</uuid> - <resourceKey>${server.root}</resourceKey> - <name>${localhost}:${listen1}</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version>2.2.17</version> - <description>Apache Web Server</description> - <ctime>1308835177519</ctime> - <mtime>1308835282077</mtime> - <itime>1308835282077</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVER</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <description>an Apache HTTP Server instance</description> - <id>10044</id> - <name>Apache HTTP Server</name> - <plugin>Apache</plugin> - <pluginConfigurationDefinition> - <configurationFormat>STRUCTURED</configurationFormat> - <id>10101</id> - <propertyDefinitions/> - </pluginConfigurationDefinition> - <resourceConfigurationDefinition> - <configurationFormat>STRUCTURED</configurationFormat> - <id>10102</id> - <propertyDefinitions/> - </resourceConfigurationDefinition> - <singleton>false</singleton> - <supportsManualAdd>true</supportsManualAdd> - </resourceType> - <childResources> - <id>10036</id> - <uuid>5eb8fa91-2a4e-4a6e-9cd7-7b1927ea1a3a</uuid> - <resourceKey>localhost.localdomain:11676</resourceKey> - <name>localhost.localdomain:11676</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description></description> - <ctime>1308835287457</ctime> - <mtime>1308835287457</mtime> - <itime>1308835287457</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>BOTH</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10046</id> - <name>Apache Virtual Host</name> - <plugin>Apache</plugin> - <pluginConfigurationDefinition> - <configurationFormat>STRUCTURED</configurationFormat> - <id>10112</id> - <propertyDefinitions/> - </pluginConfigurationDefinition> - <resourceConfigurationDefinition> - <configurationFormat>STRUCTURED</configurationFormat> - <id>10113</id> - <propertyDefinitions/> - </resourceConfigurationDefinition> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10186</id> - <version>0</version> - <ctime>1308835287457</ctime> - <mtime>1308835287457</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10187</id> - <version>0</version> - <ctime>1308835287458</ctime> - <mtime>1308835287458</mtime> - <propertySimple> - <id>10802</id> - <name>responseTimeUrlExcludes</name> - </propertySimple> - <propertySimple> - <id>10801</id> - <name>responseTimeLogFile</name> - <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/localhost.localdomain11676_rt.log</stringValue> - </propertySimple> - <propertySimple> - <id>10804</id> - <name>url</name> - <stringValue>http://localhost.localdomain:11676/</stringValue> - </propertySimple> - <propertySimple> - <id>10803</id> - <name>responseTimeUrlTransforms</name> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> - </childResources> - <childResources> - <id>10037</id> - <uuid>b2928cc6-30ab-47fe-8095-e1292887ac18</uuid> - <resourceKey>${main.rhq3.resource.key}</resourceKey> - <name>Main</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description></description> - <ctime>1308835287473</ctime> - <mtime>1308835287473</mtime> - <itime>1308835287473</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>BOTH</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10046</id> - <name>Apache Virtual Host</name> - <plugin>Apache</plugin> - <pluginConfigurationDefinition> - <configurationFormat>STRUCTURED</configurationFormat> - <id>10112</id> - <propertyDefinitions/> - </pluginConfigurationDefinition> - <resourceConfigurationDefinition> - <configurationFormat>STRUCTURED</configurationFormat> - <id>10113</id> - <propertyDefinitions/> - </resourceConfigurationDefinition> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10188</id> - <version>0</version> - <ctime>1308835287473</ctime> - <mtime>1308835287473</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10189</id> - <version>0</version> - <ctime>1308835287474</ctime> - <mtime>1308835287474</mtime> - <propertySimple> - <id>10806</id> - <name>responseTimeUrlExcludes</name> - </propertySimple> - <propertySimple> - <id>10805</id> - <name>responseTimeLogFile</name> - <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> - </propertySimple> - <propertySimple> - <id>10808</id> - <name>url</name> - <stringValue>http://$%7Bsnmp.identifier%7D/</stringValue> - </propertySimple> - <propertySimple> - <id>10807</id> - <name>responseTimeUrlTransforms</name> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> - </childResources> - <childResources> - <id>10038</id> - <uuid>fe8d389e-5a45-4bf2-9f73-0831caca63df</uuid> - <resourceKey>${vhost4.rhq3.resource.key}</resourceKey> - <name>${vhost4.snmp.identifier}</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description></description> - <ctime>1308835287482</ctime> - <mtime>1308835287482</mtime> - <itime>1308835287481</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>BOTH</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10046</id> - <name>Apache Virtual Host</name> - <plugin>Apache</plugin> - <pluginConfigurationDefinition> - <configurationFormat>STRUCTURED</configurationFormat> - <id>10112</id> - <propertyDefinitions/> - </pluginConfigurationDefinition> - <resourceConfigurationDefinition> - <configurationFormat>STRUCTURED</configurationFormat> - <id>10113</id> - <propertyDefinitions/> - </resourceConfigurationDefinition> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10190</id> - <version>0</version> - <ctime>1308835287482</ctime> - <mtime>1308835287482</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10191</id> - <version>0</version> - <ctime>1308835287482</ctime> - <mtime>1308835287482</mtime> - <propertySimple> - <id>10810</id> - <name>responseTimeUrlExcludes</name> - </propertySimple> - <propertySimple> - <id>10809</id> - <name>responseTimeLogFile</name> - <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> - </propertySimple> - <propertySimple> - <id>10812</id> - <name>url</name> - <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> - </propertySimple> - <propertySimple> - <id>10811</id> - <name>responseTimeUrlTransforms</name> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> - </childResources> - <childResources> - <id>10039</id> - <uuid>369d9dee-b4e1-45bf-9ad9-6a5d8cdd563e</uuid> - <resourceKey>${vhost3.rhq3.resource.key}</resourceKey> - <name>${vhost3.snmp.identifier}</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description></description> - <ctime>1308835287493</ctime> - <mtime>1308835287493</mtime> - <itime>1308835287492</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>BOTH</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10046</id> - <name>Apache Virtual Host</name> - <plugin>Apache</plugin> - <pluginConfigurationDefinition> - <configurationFormat>STRUCTURED</configurationFormat> - <id>10112</id> - <propertyDefinitions/> - </pluginConfigurationDefinition> - <resourceConfigurationDefinition> - <configurationFormat>STRUCTURED</configurationFormat> - <id>10113</id> - <propertyDefinitions/> - </resourceConfigurationDefinition> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10192</id> - <version>0</version> - <ctime>1308835287493</ctime> - <mtime>1308835287493</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10193</id> - <version>0</version> - <ctime>1308835287494</ctime> - <mtime>1308835287494</mtime> - <propertySimple> - <id>10814</id> - <name>responseTimeUrlExcludes</name> - </propertySimple> - <propertySimple> - <id>10813</id> - <name>responseTimeLogFile</name> - <stringValue>${server.root}logs/localhost.localdomain11677_rt.log</stringValue> - </propertySimple> - <propertySimple> - <id>10816</id> - <name>url</name> - <stringValue>http://$%7Bvhost3.snmp.identifier%7D/</stringValue> - </propertySimple> - <propertySimple> - <id>10815</id> - <name>responseTimeUrlTransforms</name> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> - </childResources> - <resourceConfiguration> - <id>10174</id> - <version>0</version> - <ctime>1308835177520</ctime> - <mtime>1308835177520</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10175</id> - <version>0</version> - <ctime>1308835177520</ctime> - <mtime>1308835177520</mtime> - <propertySimple> - <id>10790</id> - <name>errorLogIncludesPattern</name> - </propertySimple> - <propertySimple> - <id>10783</id> - <name>errorLogMinimumSeverity</name> - <stringValue>error</stringValue> - </propertySimple> - <propertySimple> - <id>10708</id> - <name>augeasEnabled</name> - <stringValue>no</stringValue> - </propertySimple> - <propertySimple> - <id>10789</id> - <name>errorLogFilePath</name> - </propertySimple> - <propertySimple> - <id>10786</id> - <name>snmpAgentCommunity</name> - <stringValue>public</stringValue> - </propertySimple> - <propertySimple> - <id>10784</id> - <name>snmpAgentHost</name> - <stringValue>${snmp.host}</stringValue> - </propertySimple> - <propertySimple> - <id>10782</id> - <name>errorLogEventsEnabled</name> - <stringValue>false</stringValue> - </propertySimple> - <propertySimple> - <id>10793</id> - <name>controlScriptPath</name> - </propertySimple> - <propertySimple> - <id>10795</id> - <name>url</name> - <stringValue>http://$%7Blocalhost%7D:$%7Blisten1%7D/</stringValue> - </propertySimple> - <propertySimple> - <id>10709</id> - <name>augeasModuleName</name> - <stringValue>Httpd</stringValue> - </propertySimple> - <propertySimple> - <id>10794</id> - <name>configFile</name> - <stringValue>${server.root}/conf/httpd.conf</stringValue> - </propertySimple> - <propertySimple> - <id>10710</id> - <name>configurationFilesInclusionPatterns</name> - <stringValue>${server.root}/conf/httpd.conf</stringValue> - </propertySimple> - <propertySimple> - <id>10788</id> - <name>vhostFilesMask</name> - <stringValue>${server.root}/conf/*</stringValue> - </propertySimple> - <propertySimple> - <id>10787</id> - <name>restartAfterConfigurationUpdate</name> - <stringValue>true</stringValue> - </propertySimple> - <propertySimple> - <id>10792</id> - <name>executablePath</name> - <stringValue>${exe.path}</stringValue> - </propertySimple> - <propertySimple> - <id>10785</id> - <name>snmpAgentPort</name> - <stringValue>${snmp.port}</stringValue> - </propertySimple> - <propertySimple> - <id>10781</id> - <name>vhostCreationPolicy</name> - <stringValue>vhost-per-file</stringValue> - </propertySimple> - <propertySimple> - <id>10791</id> - <name>serverRoot</name> - <stringValue>${server.root}</stringValue> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> - <productVersion> - <id>10004</id> - </productVersion> -</resource> -</objects> -</inventory-dump>
commit 968b9a1aba058c407e14af1b17063f33677addd9 Author: Lukas Krejci lkrejci@redhat.com Date: Fri Jun 24 17:59:32 2011 +0200
Basic set of tests for upgrade from RHQ 3.0.0 codebase using the simple apache configuration.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/VHostSpec.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/VHostSpec.java index 0e269ee..62940c2 100644 --- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/VHostSpec.java +++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/VHostSpec.java @@ -42,6 +42,10 @@ public class VHostSpec { return ret; }
+ public VHostSpec() { + + } + public VHostSpec(ApacheDirective vhostDirective) { hosts = new ArrayList<String>(vhostDirective.getValues());
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/VirtualHostLegacyResourceKeyUtil.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/VirtualHostLegacyResourceKeyUtil.java index c1f98aa..3f6a15c 100644 --- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/VirtualHostLegacyResourceKeyUtil.java +++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/VirtualHostLegacyResourceKeyUtil.java @@ -71,6 +71,37 @@ public class VirtualHostLegacyResourceKeyUtil { * @return possible resource keys of the main server. */ public Set<String> getLegacyMainServerResourceKeys() { + Set<String> ret = new HashSet<String>(); + + String key = getRHQ3NonSNMPLegacyMainServerResourceKey(); + + ret.add(key); + + String snmpKey = getRHQ3SNMPLikeResourceKey(key); + + if (snmpKey != null) { + ret.add(snmpKey); + } + + ret.add(addressUtility.getHttpdInternalMainServerAddressRepresentation(runtimeConfig).toString(false, false)); + + return ret; + } + + /** + * A resource key for the main vhost that would be returned by the RHQ 3 codebase + * if SNMP wasn't enabled during discovery. + * <p> + * Note that this can return 2 different values depending on whether the URL property + * in the parent apache server's plugin configuration is set or not. + * <p> + * Because the resource key is dependent on a value manually entered by the user (albeit + * autodetected during discovery), no attempt is made to guess what values that property + * could have had. Only the current value is used. + * + * @return + */ + public String getRHQ3NonSNMPLegacyMainServerResourceKey() { String mainServerUrl = serverComponent.getServerUrl();
String key = null; @@ -92,32 +123,45 @@ public class VirtualHostLegacyResourceKeyUtil { key = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY; }
+ return key; + } + + /** + * Returns a list of possible resource keys that the RHQ 3 code could generate for the specified + * vhost. + * <p> + * As with {@link #getLegacyMainServerResourceKeys()} the resulting set will contain all the various + * resource keys that could have been found by past versions of the plugin. + * + * @param vhost + * @return the possible vhosts + */ + public Set<String> getLegacyVirtualHostResourceKeys(VHostSpec vhost) { + String key = getRHQ3NonSNMPLegacyVirtualHostResourceKey(vhost); + Set<String> ret = new HashSet<String>();
ret.add(key);
- String snmpKey = getSNMPResourceKey(key); - + String snmpKey = getRHQ3SNMPLikeResourceKey(key); if (snmpKey != null) { ret.add(snmpKey); }
- ret.add(addressUtility.getHttpdInternalMainServerAddressRepresentation(runtimeConfig).toString(false, false)); + String snmpKeyFromRhq1 = addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost.hosts.get(0), vhost.serverName).toString(false, false); + ret.add(snmpKeyFromRhq1);
return ret; }
/** - * Returns a list of possible resource keys that the RHQ 3 code could generate for the specified - * vhost. - * <p> - * As with {@link #getLegacyMainServerResourceKeys()} the resulting set will contain all the various - * resource keys that could have been found by past versions of the plugin. + * A resource key for given vhost that would be returned by RHQ 3 if SNMP wasn't enabled during + * discovery. * * @param vhost - * @return the possible vhosts + * @return */ - public Set<String> getLegacyVirtualHostResourceKeys(VHostSpec vhost) { + public String getRHQ3NonSNMPLegacyVirtualHostResourceKey(VHostSpec vhost) { String host = vhost.hosts.get(0); HttpdAddressUtility.Address hostAddr = HttpdAddressUtility.Address.parse(host); if (vhost.serverName != null) { @@ -132,24 +176,18 @@ public class VirtualHostLegacyResourceKeyUtil { } catch (UnknownHostException e) { }
- String key = hostAddr.host + ":" + hostAddr.port; - - Set<String> ret = new HashSet<String>(); - - ret.add(key); - - String snmpKey = getSNMPResourceKey(key); - if (snmpKey != null) { - ret.add(snmpKey); - } - - String snmpKeyFromRhq1 = addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost.hosts.get(0), vhost.serverName).toString(false, false); - ret.add(snmpKeyFromRhq1); - - return ret; + return hostAddr.host + ":" + hostAddr.port; }
- private String getSNMPResourceKey(String nonSnmpResourceKey) { + /** + * Returns an "SNMP" resource key that would have been resolved out of the non-snmp resource key + * by the RHQ 3 code-base. Note that the returned key actually isn't what SNMP module would + * actually return. + * + * @param nonSnmpResourceKey + * @return + */ + public String getRHQ3SNMPLikeResourceKey(String nonSnmpResourceKey) { int idx = getMatchingWwwServiceIndex(nonSnmpResourceKey);
if (idx < 0) { diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ1_3Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ1_3Test.java index 13a9c4a..135c2aa 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ1_3Test.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ1_3Test.java @@ -19,25 +19,15 @@
package org.rhq.plugins.apache;
-import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import java.util.ArrayList; import java.util.Comparator; import java.util.HashMap; -import java.util.List; -import java.util.Map; import java.util.Set; import java.util.TreeSet;
-import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.testng.annotations.Parameters; import org.testng.annotations.Test;
import org.rhq.core.domain.resource.Resource; -import org.rhq.core.domain.resource.ResourceType; -import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig; import org.rhq.test.pc.PluginContainerSetup;
/** @@ -47,44 +37,7 @@ import org.rhq.test.pc.PluginContainerSetup; */ @Test(groups = "apache-integration-tests") public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase { - private static final Log LOG = LogFactory.getLog(UpgradeSimpleConfigurationFromRHQ1_3Test.class); - - private enum Apache { - V_1_3_x { - public String getConfigDirName() { - return "1.3.x"; - } - }, - - V_2_2_x { - public String getConfigDirName() { - return "2.2.x"; - } - };
- public abstract String getConfigDirName(); - } - - private static class TestConfiguration { - public Apache version; - public String configurationName; - public String serverRoot; - public String binPath; - public Map<String, String> defaultOverrides; - - public void beforeTestSetup(TestSetup testSetup) { - - } - - public void beforePluginContainerStart(TestSetup setup) { - - } - - public void beforeTests() { - - } - } - @Test @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) @Parameters({ "apache2.install.dir", "apache2.exe.path" }) @@ -96,7 +49,8 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase { serverRoot = installPath; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - version = Apache.V_2_2_x; + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-1.3.x/simple/inventory.xml"; } }); } @@ -112,7 +66,8 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase { serverRoot = installPath; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - version = Apache.V_1_3_x; + apacheConfigurationFiles = new String[] { "/full-configurations/1.3.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-1.3.x/simple/inventory.xml"; }}); }
@@ -123,9 +78,11 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase { testUpgrade(new TestConfiguration() { { configurationName = DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES; + apacheConfigurationFiles = new String[] { "/full-configurations/2.2.x/simple/httpd.conf" }; + inventoryFile = "/mocked-inventories/rhq-1.3.x/simple/inventory.xml"; serverRoot = installPath; binPath = exePath; - version = Apache.V_2_2_x; +
defaultOverrides = new HashMap<String, String>(); defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); @@ -158,78 +115,5 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase { } } }); - } - - private void testUpgrade(TestConfiguration testConfiguration) throws Throwable { - final TestSetup setup = new TestSetup(testConfiguration.configurationName); - boolean testFailed = false; - try { - testConfiguration.beforeTestSetup(setup); - - String configPath = "/full-configurations/" + testConfiguration.version.getConfigDirName() + "/simple/httpd.conf"; - - setup.withInventoryFrom("/mocked-inventories/rhq-1.3.x/simple/inventory.xml") - .withPlatformResource(platform).withDefaultExpectations().withDefaultOverrides(testConfiguration.defaultOverrides) - .withApacheSetup().withConfigurationFiles(configPath, "/snmpd.conf", "/mime.types") - .withServerRoot(testConfiguration.serverRoot).withExePath(testConfiguration.binPath).setup(); - - testConfiguration.beforePluginContainerStart(setup); - - startConfiguredPluginContainer(); - - testConfiguration.beforeTests(); - - //ok, now we should see the resources upgraded in the fake server inventory. - ResourceType serverResourceType = findApachePluginResourceTypeByName("Apache HTTP Server"); - ResourceType vhostResourceType = findApachePluginResourceTypeByName("Apache Virtual Host"); - - Set<Resource> servers = setup.getFakeInventory().findResourcesByType(serverResourceType); - - assertEquals(servers.size(), 1, "There should be exactly one apache server discovered."); - - Resource server = servers.iterator().next(); - - String expectedResourceKey = ApacheServerDiscoveryComponent.formatResourceKey(testConfiguration.serverRoot, testConfiguration.serverRoot - + "/conf/httpd.conf"); - - assertEquals(server.getResourceKey(), expectedResourceKey, - "The server resource key doesn't seem to be upgraded."); - - Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(vhostResourceType); - - assertEquals(vhosts.size(), 5, "Unexpected number of vhosts discovered found"); - - List<String> expectedResourceKeys = new ArrayList<String>(5); - - DeploymentConfig dc = setup.getDeploymentConfig(); - - expectedResourceKeys.add(ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY); - expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - dc.vhost1.getServerName(), dc.vhost1.getAddresses())); - expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - dc.vhost2.getServerName(), dc.vhost2.getAddresses())); - expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - dc.vhost3.getServerName(), dc.vhost3.getAddresses())); - expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - dc.vhost4.getServerName(), dc.vhost4.getAddresses())); - - for (Resource vhost : vhosts) { - assertTrue(expectedResourceKeys.contains(vhost.getResourceKey()), - "Unexpected virtual host resource key: '" + vhost.getResourceKey() + "'. Only expecting " + expectedResourceKeys); - } - } catch (Throwable t) { - testFailed = true; - throw t; - } finally { - try { - setup.withApacheSetup().getExecutionUtil().invokeOperation("stop"); - } catch (Exception e) { - if (testFailed) { - LOG.error("Failed to stop apache.", e); - } else { - throw e; - } - } - } - } + } } diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java new file mode 100644 index 0000000..386a871 --- /dev/null +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ3_0_0Test.java @@ -0,0 +1,206 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.plugins.apache; + + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +import java.util.HashMap; +import java.util.List; +import java.util.Set; + +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.resource.ResourceError; +import org.rhq.core.domain.resource.ResourceErrorType; +import org.rhq.core.domain.resource.ResourceType; +import org.rhq.plugins.apache.parser.ApacheDirectiveTree; +import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig; +import org.rhq.plugins.apache.util.RuntimeApacheConfiguration; +import org.rhq.plugins.apache.util.VirtualHostLegacyResourceKeyUtil; +import org.rhq.test.pc.PluginContainerSetup; + +/** + * + * + * @author Lukas Krejci + */ +public class UpgradeSimpleConfigurationFromRHQ3_0_0Test extends UpgradeTestBase { + + //TODO override the *.rhq3.resource.key variables in each test to define whether + //the resource key was discovered without SNMP, with SNMP, with Main Server URL set, + //or not + + //TODO the default inventory.xml uses discovery results without snmp active. with SNMP active, all 5 vhost + //would discovered in RHQ 3. This test should therefore use a different inventory file. + @Test(enabled = false) //this fails until the above todo is implemented + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}, numberOfInitialDiscoveries = 2) + @Parameters({"apache2.install.dir", "apache2.exe.path"}) + public void testWithResolvableNamesWithSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; + inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + testSetup.withApacheSetup().init(); + ApacheServerComponent component = testSetup.withApacheSetup().getExecutionUtil().getServerComponent(); + ApacheDirectiveTree config = component.loadParser(); + config = RuntimeApacheConfiguration.extract(config, component.getCurrentProcessInfo(), component.getCurrentBinaryInfo(), component.getModuleNames(), false); + + DeploymentConfig deployConfig = testSetup.getDeploymentConfig(); + + VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config); + + defaultOverrides = new HashMap<String, String>(); + defaultOverrides.put("main.rhq3.resource.key", keyUtil.getRHQ3SNMPLikeResourceKey(keyUtil.getRHQ3NonSNMPLegacyMainServerResourceKey())); + + if (deployConfig.vhost1 != null) { + String rhq3Key = keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost1.getVHostSpec()); + defaultOverrides.put("vhost1.rhq3.resource.key", keyUtil.getRHQ3SNMPLikeResourceKey(rhq3Key)); + } + + if (deployConfig.vhost2 != null) { + String rhq3Key = keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost2.getVHostSpec()); + defaultOverrides.put("vhost2.rhq3.resource.key", keyUtil.getRHQ3SNMPLikeResourceKey(rhq3Key)); + } + + if (deployConfig.vhost3 != null) { + String rhq3Key = keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost3.getVHostSpec()); + defaultOverrides.put("vhost3.rhq3.resource.key", keyUtil.getRHQ3SNMPLikeResourceKey(rhq3Key)); + } + + if (deployConfig.vhost4 != null) { + String rhq3Key = keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost4.getVHostSpec()); + defaultOverrides.put("vhost4.rhq3.resource.key", keyUtil.getRHQ3SNMPLikeResourceKey(rhq3Key)); + } + + testSetup.withDefaultOverrides(defaultOverrides); + } + }); + } + + @Test + @PluginContainerSetup(plugins = {PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN}) + @Parameters({"apache2.install.dir", "apache2.exe.path"}) + public void testWithResolvableNamesWithoutSNMP(final String installDir, final String exePath) throws Throwable { + testUpgrade(new TestConfiguration() { + { + apacheConfigurationFiles = new String[]{"/full-configurations/2.2.x/simple/httpd.conf"}; + inventoryFile = "/mocked-inventories/rhq-3.0.0/simple/inventory.xml"; + serverRoot = installDir; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + upgradeShouldSucceed = false; + } + + @Override + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + testSetup.withApacheSetup().init(); + ApacheServerComponent component = testSetup.withApacheSetup().getExecutionUtil().getServerComponent(); + ApacheDirectiveTree config = component.loadParser(); + config = RuntimeApacheConfiguration.extract(config, component.getCurrentProcessInfo(), component.getCurrentBinaryInfo(), component.getModuleNames(), false); + + DeploymentConfig deployConfig = testSetup.getDeploymentConfig(); + + VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config); + + defaultOverrides = new HashMap<String, String>(); + defaultOverrides.put("main.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyMainServerResourceKey()); + + if (deployConfig.vhost1 != null) { + defaultOverrides.put("vhost1.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost1.getVHostSpec())); + } + + if (deployConfig.vhost2 != null) { + defaultOverrides.put("vhost2.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost2.getVHostSpec())); + } + + if (deployConfig.vhost3 != null) { + defaultOverrides.put("vhost3.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost3.getVHostSpec())); + } + + if (deployConfig.vhost4 != null) { + defaultOverrides.put("vhost4.rhq3.resource.key", keyUtil.getRHQ3NonSNMPLegacyVirtualHostResourceKey(deployConfig.vhost4.getVHostSpec())); + } + + testSetup.withDefaultOverrides(defaultOverrides); + } + + /** + * Do our own tests here, because the test method won't do much, since + * we told it that the upgrade won't succeed. + */ + @Override + public void beforeTests(TestSetup setup) throws Throwable { + //ok, now we should see the resources upgraded in the fake server inventory. + ResourceType serverResourceType = findApachePluginResourceTypeByName("Apache HTTP Server"); + ResourceType vhostResourceType = findApachePluginResourceTypeByName("Apache Virtual Host"); + + Set<Resource> servers = setup.getFakeInventory().findResourcesByType(serverResourceType); + + assertEquals(servers.size(), 1, "There should be exactly one apache server discovered."); + + Resource server = servers.iterator().next(); + + String expectedResourceKey = ApacheServerDiscoveryComponent.formatResourceKey(this.serverRoot, this.serverRoot + + "/conf/httpd.conf"); + + assertEquals(server.getResourceKey(), expectedResourceKey, + "The server resource key doesn't seem to be upgraded."); + + Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(vhostResourceType); + + assertEquals(vhosts.size(), 4, "Unexpected number of vhosts discovered found"); + + //let's check that the main vhost has a an upgrade error attached to it + ApacheServerComponent component = setup.withApacheSetup().getExecutionUtil().getServerComponent(); + ApacheDirectiveTree config = component.loadParser(); + config = RuntimeApacheConfiguration.extract(config, component.getCurrentProcessInfo(), component.getCurrentBinaryInfo(), component.getModuleNames(), false); + VirtualHostLegacyResourceKeyUtil keyUtil = new VirtualHostLegacyResourceKeyUtil(component, config); + + String mainVhostRK = keyUtil.getRHQ3NonSNMPLegacyMainServerResourceKey(); + + Resource mainVhost = null; + for(Resource r : vhosts) { + if (mainVhostRK.equals(r.getResourceKey())) { + mainVhost = r; + break; + } + } + + assertNotNull(mainVhost, "Couldn't find the main vhost with the expected resource key '" + mainVhostRK + "'."); + + List<ResourceError> errors = mainVhost.getResourceErrors(ResourceErrorType.UPGRADE); + assertNotNull(errors, "The main vhost doesn't have any upgrade errors."); + assertEquals(errors.size(), 1, "There should be exactly one upgrade error on the main vhost."); + } + }); + } + +} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java index 16bd06b..96260a6 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java @@ -19,6 +19,7 @@
package org.rhq.plugins.apache;
+import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue;
import java.io.File; @@ -28,6 +29,7 @@ import java.io.Reader; import java.net.InetAddress; import java.net.URI; import java.net.UnknownHostException; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -37,6 +39,8 @@ import java.util.Map; import java.util.Set; import java.util.UUID;
+import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.jmock.Expectations; import org.testng.annotations.BeforeClass;
@@ -73,6 +77,8 @@ import org.rhq.test.pc.PluginContainerTest; */ public class UpgradeTestBase extends PluginContainerTest {
+ private static final Log LOG = LogFactory.getLog(UpgradeTestBase.class); + protected class TestSetup { private String configurationName; private FakeServerInventory fakeInventory = new FakeServerInventory(); @@ -310,6 +316,9 @@ public class UpgradeTestBase extends PluginContainerTest { deploymentConfig.vhost4.getServerName()).toString(false, false)); }
+ //let the user override everything we just did + replacements.putAll(defaultOverrides); + InputStream dataStream = getClass().getResourceAsStream(inventoryFile);
Reader rdr = new TokenReplacingReader(new InputStreamReader(dataStream), replacements); @@ -344,6 +353,28 @@ public class UpgradeTestBase extends PluginContainerTest { } }
+ protected static class TestConfiguration { + public String[] apacheConfigurationFiles; + public String inventoryFile; + public String configurationName; + public String serverRoot; + public String binPath; + public Map<String, String> defaultOverrides; + public boolean upgradeShouldSucceed = true; + + public void beforeTestSetup(TestSetup testSetup) throws Throwable { + + } + + public void beforePluginContainerStart(TestSetup setup) throws Throwable { + + } + + public void beforeTests(TestSetup setup) throws Throwable { + + } + } + protected static final String PLATFORM_PLUGIN = "file:target/itest/plugins/rhq-platform-plugin-for-apache-test.jar"; protected static final String AUGEAS_PLUGIN = "file:target/itest/plugins/rhq-augeas-plugin-for-apache-test.jar"; protected static final String APACHE_PLUGIN = "file:target/itest/plugins/rhq-apache-plugin-for-apache-test.jar"; @@ -370,6 +401,89 @@ public class UpgradeTestBase extends PluginContainerTest { return null; }
+ protected void testUpgrade(TestConfiguration testConfiguration) throws Throwable { + final TestSetup setup = new TestSetup(testConfiguration.configurationName); + boolean testFailed = false; + try { + + String[] configFiles = Arrays.copyOf(testConfiguration.apacheConfigurationFiles, testConfiguration.apacheConfigurationFiles.length + 2); + configFiles[testConfiguration.apacheConfigurationFiles.length] = "/snmpd.conf"; + configFiles[testConfiguration.apacheConfigurationFiles.length + 1] = "/mime.types"; + + setup.withInventoryFrom(testConfiguration.inventoryFile) + .withPlatformResource(platform).withDefaultExpectations().withDefaultOverrides(testConfiguration.defaultOverrides) + .withApacheSetup().withConfigurationFiles(configFiles) + .withServerRoot(testConfiguration.serverRoot).withExePath(testConfiguration.binPath); + + testConfiguration.beforeTestSetup(setup); + + setup.setup(); + + testConfiguration.beforePluginContainerStart(setup); + + startConfiguredPluginContainer(); + + testConfiguration.beforeTests(setup); + + if (!testConfiguration.upgradeShouldSucceed) { + return; + } + + //ok, now we should see the resources upgraded in the fake server inventory. + ResourceType serverResourceType = findApachePluginResourceTypeByName("Apache HTTP Server"); + ResourceType vhostResourceType = findApachePluginResourceTypeByName("Apache Virtual Host"); + + Set<Resource> servers = setup.getFakeInventory().findResourcesByType(serverResourceType); + + assertEquals(servers.size(), 1, "There should be exactly one apache server discovered."); + + Resource server = servers.iterator().next(); + + String expectedResourceKey = ApacheServerDiscoveryComponent.formatResourceKey(testConfiguration.serverRoot, testConfiguration.serverRoot + + "/conf/httpd.conf"); + + assertEquals(server.getResourceKey(), expectedResourceKey, + "The server resource key doesn't seem to be upgraded."); + + Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(vhostResourceType); + + assertEquals(vhosts.size(), 5, "Unexpected number of vhosts discovered found"); + + List<String> expectedResourceKeys = new ArrayList<String>(5); + + DeploymentConfig dc = setup.getDeploymentConfig(); + + expectedResourceKeys.add(ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY); + expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( + dc.vhost1.getServerName(), dc.vhost1.getAddresses())); + expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( + dc.vhost2.getServerName(), dc.vhost2.getAddresses())); + expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( + dc.vhost3.getServerName(), dc.vhost3.getAddresses())); + expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( + dc.vhost4.getServerName(), dc.vhost4.getAddresses())); + + for (Resource vhost : vhosts) { + assertTrue(expectedResourceKeys.contains(vhost.getResourceKey()), + "Unexpected virtual host resource key: '" + vhost.getResourceKey() + "'. Only expecting " + expectedResourceKeys); + } + } catch (Throwable t) { + testFailed = true; + LOG.error("Error during test upgrade execution.", t); + throw t; + } finally { + try { + setup.withApacheSetup().getExecutionUtil().invokeOperation("stop"); + } catch (Exception e) { + if (testFailed) { + LOG.error("Failed to stop apache.", e); + } else { + throw e; + } + } + } + } + private static List<ResourceType> getResourceTypesInPlugin(String pluginUri) throws Exception { PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(new URI(pluginUri).toURL()); PluginMetadataParser parser = new PluginMetadataParser(descriptor, diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java index 97abce3..be73319 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java @@ -93,6 +93,13 @@ public class ApacheDeploymentUtil { return serverName; }
+ public VHostSpec getVHostSpec() { + VHostSpec ret = new VHostSpec(); + ret.serverName = getServerName(); + ret.hosts = getAddresses(); + return ret; + } + public List<String> getAddresses() { ArrayList<String> ret = new ArrayList<String>(); if (address1 != null) { diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/simple/inventory.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/simple/inventory.xml index 1aa8b38..f8d181d 100644 --- a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/simple/inventory.xml +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/simple/inventory.xml @@ -486,7 +486,7 @@ <id>10370</id> <name>snmpAgentHost</name> <override>false</override> - <stringValue>127.0.0.1</stringValue> + <stringValue>${snmp.host}</stringValue> </propertySimple> <propertySimple> <id>10713</id> @@ -514,7 +514,7 @@ <id>10712</id> <name>snmpAgentPort</name> <override>false</override> - <stringValue>1610</stringValue> + <stringValue>${snmp.port}</stringValue> </propertySimple> <propertySimple> <id>10715</id> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory.xml new file mode 100644 index 0000000..be89240 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-3.0.0/simple/inventory.xml @@ -0,0 +1,462 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10022</id> + <uuid>e61040b4-d645-44dc-a6b7-460d39f1b625</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost}:${listen1}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1308835177519</ctime> + <mtime>1308835282077</mtime> + <itime>1308835282077</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10044</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10101</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10102</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10036</id> + <uuid>5eb8fa91-2a4e-4a6e-9cd7-7b1927ea1a3a</uuid> + <resourceKey>localhost.localdomain:11676</resourceKey> + <name>localhost.localdomain:11676</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287457</ctime> + <mtime>1308835287457</mtime> + <itime>1308835287457</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10186</id> + <version>0</version> + <ctime>1308835287457</ctime> + <mtime>1308835287457</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10187</id> + <version>0</version> + <ctime>1308835287458</ctime> + <mtime>1308835287458</mtime> + <propertySimple> + <id>10802</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10801</id> + <name>responseTimeLogFile</name> + <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/localhost.localdomain11676_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10804</id> + <name>url</name> + <stringValue>http://localhost.localdomain:11676/</stringValue> + </propertySimple> + <propertySimple> + <id>10803</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10037</id> + <uuid>b2928cc6-30ab-47fe-8095-e1292887ac18</uuid> + <resourceKey>${main.rhq3.resource.key}</resourceKey> + <name>Main</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + <itime>1308835287473</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10188</id> + <version>0</version> + <ctime>1308835287473</ctime> + <mtime>1308835287473</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10189</id> + <version>0</version> + <ctime>1308835287474</ctime> + <mtime>1308835287474</mtime> + <propertySimple> + <id>10806</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10805</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10808</id> + <name>url</name> + <stringValue>http://$%7Bsnmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10807</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10038</id> + <uuid>fe8d389e-5a45-4bf2-9f73-0831caca63df</uuid> + <resourceKey>${vhost4.rhq3.resource.key}</resourceKey> + <name>${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <itime>1308835287481</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10190</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10191</id> + <version>0</version> + <ctime>1308835287482</ctime> + <mtime>1308835287482</mtime> + <propertySimple> + <id>10810</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10809</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}/logs/localhost.localdomain11678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10812</id> + <name>url</name> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10811</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10039</id> + <uuid>369d9dee-b4e1-45bf-9ad9-6a5d8cdd563e</uuid> + <resourceKey>${vhost3.rhq3.resource.key}</resourceKey> + <name>${vhost3.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description></description> + <ctime>1308835287493</ctime> + <mtime>1308835287493</mtime> + <itime>1308835287492</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10046</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10112</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <resourceConfigurationDefinition> + <configurationFormat>STRUCTURED</configurationFormat> + <id>10113</id> + <propertyDefinitions/> + </resourceConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10192</id> + <version>0</version> + <ctime>1308835287493</ctime> + <mtime>1308835287493</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10193</id> + <version>0</version> + <ctime>1308835287494</ctime> + <mtime>1308835287494</mtime> + <propertySimple> + <id>10814</id> + <name>responseTimeUrlExcludes</name> + </propertySimple> + <propertySimple> + <id>10813</id> + <name>responseTimeLogFile</name> + <stringValue>${server.root}logs/localhost.localdomain11677_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10816</id> + <name>url</name> + <stringValue>http://$%7Bvhost3.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10815</id> + <name>responseTimeUrlTransforms</name> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10174</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10175</id> + <version>0</version> + <ctime>1308835177520</ctime> + <mtime>1308835177520</mtime> + <propertySimple> + <id>10790</id> + <name>errorLogIncludesPattern</name> + </propertySimple> + <propertySimple> + <id>10783</id> + <name>errorLogMinimumSeverity</name> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>augeasEnabled</name> + <stringValue>no</stringValue> + </propertySimple> + <propertySimple> + <id>10789</id> + <name>errorLogFilePath</name> + </propertySimple> + <propertySimple> + <id>10786</id> + <name>snmpAgentCommunity</name> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10784</id> + <name>snmpAgentHost</name> + <stringValue>${snmp.host}</stringValue> + </propertySimple> + <propertySimple> + <id>10782</id> + <name>errorLogEventsEnabled</name> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10793</id> + <name>controlScriptPath</name> + </propertySimple> + <propertySimple> + <id>10795</id> + <name>url</name> + <stringValue>http://$%7Blocalhost%7D:$%7Blisten1%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10709</id> + <name>augeasModuleName</name> + <stringValue>Httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10794</id> + <name>configFile</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10710</id> + <name>configurationFilesInclusionPatterns</name> + <stringValue>${server.root}/conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10788</id> + <name>vhostFilesMask</name> + <stringValue>${server.root}/conf/*</stringValue> + </propertySimple> + <propertySimple> + <id>10787</id> + <name>restartAfterConfigurationUpdate</name> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10792</id> + <name>executablePath</name> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10785</id> + <name>snmpAgentPort</name> + <stringValue>${snmp.port}</stringValue> + </propertySimple> + <propertySimple> + <id>10781</id> + <name>vhostCreationPolicy</name> + <stringValue>vhost-per-file</stringValue> + </propertySimple> + <propertySimple> + <id>10791</id> + <name>serverRoot</name> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> +</objects> +</inventory-dump>
commit f234bd208c3b0e5344fe8e235237c58063985326 Author: Lukas Krejci lkrejci@redhat.com Date: Thu Jun 23 13:23:43 2011 +0200
make the tests actually compile
diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ1_3Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ1_3Test.java index af809a5..13a9c4a 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ1_3Test.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ1_3Test.java @@ -91,7 +91,7 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase { public void testWithResolvableServerNames_Apache2(final String installPath, final String exePath) throws Throwable {
- testUpgradeFromRHQ1_3(new TestConfiguration() { + testUpgrade(new TestConfiguration() { { serverRoot = installPath; binPath = exePath; @@ -108,7 +108,7 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase { public void testWithResolvableServerNames_Apache1(final String installPath, final String exePath) throws Throwable {
- testUpgradeFromRHQ1_3(new TestConfiguration() {{ + testUpgrade(new TestConfiguration() {{ serverRoot = installPath; binPath = exePath; configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; @@ -120,7 +120,7 @@ public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase { @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) @Parameters({ "apache2.install.dir", "apache2.exe.path" }) public void testWithNonUniqueServerNames_Apache2(final String installPath, final String exePath) throws Throwable { - testUpgradeFromRHQ1_3(new TestConfiguration() { + testUpgrade(new TestConfiguration() { { configurationName = DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES; serverRoot = installPath;
commit 44049422b33901613c769fd1fab60c211427089a Author: Lukas Krejci lkrejci@redhat.com Date: Thu Jun 23 13:22:58 2011 +0200
fix removing of the resources in the fake server inventory.
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java index 4d5dc7d..17beb1e 100644 --- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java +++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java @@ -277,6 +277,9 @@ public class FakeServerInventory { if (parent != null) { parent.getChildResources().remove(r); } + for(Resource child : r.getChildResources()) { + removeResource(child); + } }
private Resource fakePersist(Resource agentSideResource, InventoryStatus requiredInventoryStatus,
commit f15678e57cb7001b4120c38b3ca0b5cf9d62e745 Author: Lukas Krejci lkrejci@redhat.com Date: Thu Jun 23 13:22:40 2011 +0200
Throw more appropriate (or documented) exceptions.
diff --git a/modules/test-utils/src/main/java/org/rhq/test/TokenReplacingReader.java b/modules/test-utils/src/main/java/org/rhq/test/TokenReplacingReader.java index 22a3167..35ba2d2 100644 --- a/modules/test-utils/src/main/java/org/rhq/test/TokenReplacingReader.java +++ b/modules/test-utils/src/main/java/org/rhq/test/TokenReplacingReader.java @@ -125,7 +125,7 @@ public class TokenReplacingReader extends Reader { }
public long skip(long n) throws IOException { - throw new RuntimeException("Operation Not Supported"); + throw new UnsupportedOperationException("skip() not supported on TokenReplacingReader."); }
public boolean ready() throws IOException { @@ -137,10 +137,10 @@ public class TokenReplacingReader extends Reader { }
public void mark(int readAheadLimit) throws IOException { - throw new RuntimeException("Operation Not Supported"); + throw new IOException("mark() not supported on TokenReplacingReader."); }
public void reset() throws IOException { - throw new RuntimeException("Operation Not Supported"); + throw new IOException("reset() not supported on TokenReplacingReader."); } }
commit b93c6ce9baf853bbdc69d7cfc85032cd63fcbccd Author: Lukas Krejci lkrejci@redhat.com Date: Thu Jun 23 13:22:09 2011 +0200
Renamed the UpgradeSimpleConfigurationWithResolvableServerNamesTest to UpgradeSimpleConfigurationFromRHQ1_3Test to better describe what is actually being tested and to support better fragmentation of the tests we are going to have into standalone test classes.
diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ1_3Test.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ1_3Test.java new file mode 100644 index 0000000..af809a5 --- /dev/null +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationFromRHQ1_3Test.java @@ -0,0 +1,235 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.plugins.apache; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.resource.ResourceType; +import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig; +import org.rhq.test.pc.PluginContainerSetup; + +/** + * + * + * @author Lukas Krejci + */ +@Test(groups = "apache-integration-tests") +public class UpgradeSimpleConfigurationFromRHQ1_3Test extends UpgradeTestBase { + private static final Log LOG = LogFactory.getLog(UpgradeSimpleConfigurationFromRHQ1_3Test.class); + + private enum Apache { + V_1_3_x { + public String getConfigDirName() { + return "1.3.x"; + } + }, + + V_2_2_x { + public String getConfigDirName() { + return "2.2.x"; + } + }; + + public abstract String getConfigDirName(); + } + + private static class TestConfiguration { + public Apache version; + public String configurationName; + public String serverRoot; + public String binPath; + public Map<String, String> defaultOverrides; + + public void beforeTestSetup(TestSetup testSetup) { + + } + + public void beforePluginContainerStart(TestSetup setup) { + + } + + public void beforeTests() { + + } + } + + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testWithResolvableServerNames_Apache2(final String installPath, final String exePath) + throws Throwable { + + testUpgradeFromRHQ1_3(new TestConfiguration() { + { + serverRoot = installPath; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + version = Apache.V_2_2_x; + } + }); + } + + @Test(enabled = false) + //ApacheServerOperationsDelegate doesn't work with apache 1.3 + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache1.install.dir", "apache1.exe.path" }) + public void testWithResolvableServerNames_Apache1(final String installPath, final String exePath) + throws Throwable { + + testUpgradeFromRHQ1_3(new TestConfiguration() {{ + serverRoot = installPath; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + version = Apache.V_1_3_x; + }}); + } + + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testWithNonUniqueServerNames_Apache2(final String installPath, final String exePath) throws Throwable { + testUpgradeFromRHQ1_3(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES; + serverRoot = installPath; + binPath = exePath; + version = Apache.V_2_2_x; + + defaultOverrides = new HashMap<String, String>(); + defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}"); + } + + @Override + public void beforePluginContainerStart(TestSetup setup) { + //in this scenario, the RHQ 1.3 would only discover 1 vhost (and the main vhost), because they would have the same resource key + //due to the same ServerName. I need to process the default inventory to reflect that otherwise I would get upgrade + //failures. + + Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(findApachePluginResourceTypeByName("Apache Virtual Host")); + Set<Resource> uniques = new TreeSet<Resource>(new Comparator<Resource>() { + public int compare(Resource a, Resource b) { + return a.getResourceKey().compareTo(b.getResourceKey()); + } + }); + + for(Resource vhost : vhosts) { + if (uniques.contains(vhost)) { + //remove the vhost from the server's inventory + setup.getFakeInventory().removeResource(vhost); + } else { + uniques.add(vhost); + } + } + } + }); + } + + private void testUpgrade(TestConfiguration testConfiguration) throws Throwable { + final TestSetup setup = new TestSetup(testConfiguration.configurationName); + boolean testFailed = false; + try { + testConfiguration.beforeTestSetup(setup); + + String configPath = "/full-configurations/" + testConfiguration.version.getConfigDirName() + "/simple/httpd.conf"; + + setup.withInventoryFrom("/mocked-inventories/rhq-1.3.x/simple/inventory.xml") + .withPlatformResource(platform).withDefaultExpectations().withDefaultOverrides(testConfiguration.defaultOverrides) + .withApacheSetup().withConfigurationFiles(configPath, "/snmpd.conf", "/mime.types") + .withServerRoot(testConfiguration.serverRoot).withExePath(testConfiguration.binPath).setup(); + + testConfiguration.beforePluginContainerStart(setup); + + startConfiguredPluginContainer(); + + testConfiguration.beforeTests(); + + //ok, now we should see the resources upgraded in the fake server inventory. + ResourceType serverResourceType = findApachePluginResourceTypeByName("Apache HTTP Server"); + ResourceType vhostResourceType = findApachePluginResourceTypeByName("Apache Virtual Host"); + + Set<Resource> servers = setup.getFakeInventory().findResourcesByType(serverResourceType); + + assertEquals(servers.size(), 1, "There should be exactly one apache server discovered."); + + Resource server = servers.iterator().next(); + + String expectedResourceKey = ApacheServerDiscoveryComponent.formatResourceKey(testConfiguration.serverRoot, testConfiguration.serverRoot + + "/conf/httpd.conf"); + + assertEquals(server.getResourceKey(), expectedResourceKey, + "The server resource key doesn't seem to be upgraded."); + + Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(vhostResourceType); + + assertEquals(vhosts.size(), 5, "Unexpected number of vhosts discovered found"); + + List<String> expectedResourceKeys = new ArrayList<String>(5); + + DeploymentConfig dc = setup.getDeploymentConfig(); + + expectedResourceKeys.add(ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY); + expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( + dc.vhost1.getServerName(), dc.vhost1.getAddresses())); + expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( + dc.vhost2.getServerName(), dc.vhost2.getAddresses())); + expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( + dc.vhost3.getServerName(), dc.vhost3.getAddresses())); + expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( + dc.vhost4.getServerName(), dc.vhost4.getAddresses())); + + for (Resource vhost : vhosts) { + assertTrue(expectedResourceKeys.contains(vhost.getResourceKey()), + "Unexpected virtual host resource key: '" + vhost.getResourceKey() + "'. Only expecting " + expectedResourceKeys); + } + } catch (Throwable t) { + testFailed = true; + throw t; + } finally { + try { + setup.withApacheSetup().getExecutionUtil().invokeOperation("stop"); + } catch (Exception e) { + if (testFailed) { + LOG.error("Failed to stop apache.", e); + } else { + throw e; + } + } + } + } +} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationWithResolvableServerNamesTest.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationWithResolvableServerNamesTest.java deleted file mode 100644 index f887b83..0000000 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationWithResolvableServerNamesTest.java +++ /dev/null @@ -1,235 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2011 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.plugins.apache; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.testng.annotations.Parameters; -import org.testng.annotations.Test; - -import org.rhq.core.domain.resource.Resource; -import org.rhq.core.domain.resource.ResourceType; -import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig; -import org.rhq.test.pc.PluginContainerSetup; - -/** - * - * - * @author Lukas Krejci - */ -@Test(groups = "apache-integration-tests") -public class UpgradeSimpleConfigurationWithResolvableServerNamesTest extends UpgradeTestBase { - private static final Log LOG = LogFactory.getLog(UpgradeSimpleConfigurationWithResolvableServerNamesTest.class); - - private enum Apache { - V_1_3_x { - public String getConfigDirName() { - return "1.3.x"; - } - }, - - V_2_2_x { - public String getConfigDirName() { - return "2.2.x"; - } - }; - - public abstract String getConfigDirName(); - } - - private static class TestConfiguration { - public Apache version; - public String configurationName; - public String serverRoot; - public String binPath; - public Map<String, String> defaultOverrides; - - public void beforeTestSetup(TestSetup testSetup) { - - } - - public void beforePluginContainerStart(TestSetup setup) { - - } - - public void beforeTests() { - - } - } - - @Test - @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) - @Parameters({ "apache2.install.dir", "apache2.exe.path" }) - public void testWithResolvableServerNames_Apache2_upgradeFromRHQ1_3(final String installPath, final String exePath) - throws Throwable { - - testUpgradeFromRHQ1_3(new TestConfiguration() { - { - serverRoot = installPath; - binPath = exePath; - configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - version = Apache.V_2_2_x; - } - }); - } - - @Test(enabled = false) - //ApacheServerOperationsDelegate doesn't work with apache 1.3 - @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) - @Parameters({ "apache1.install.dir", "apache1.exe.path" }) - public void testWithResolvableServerNames_Apache1_upgradeFromRHQ1_3(final String installPath, final String exePath) - throws Throwable { - - testUpgradeFromRHQ1_3(new TestConfiguration() {{ - serverRoot = installPath; - binPath = exePath; - configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; - version = Apache.V_1_3_x; - }}); - } - - @Test - @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) - @Parameters({ "apache2.install.dir", "apache2.exe.path" }) - public void testWithUnresolvableServerNames_Apache2_upgradeFromRHQ1_3(final String installPath, final String exePath) throws Throwable { - testUpgradeFromRHQ1_3(new TestConfiguration() { - { - configurationName = DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES; - serverRoot = installPath; - binPath = exePath; - version = Apache.V_2_2_x; - - defaultOverrides = new HashMap<String, String>(); - defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); - defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}"); - defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}"); - defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}"); - defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}"); - } - - @Override - public void beforePluginContainerStart(TestSetup setup) { - //in this scenario, the RHQ 1.3 would only discover 1 vhost (and the main vhost), because they would have the same resource key - //due to the same ServerName. I need to process the default inventory to reflect that otherwise I would get upgrade - //failures. - - Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(findApachePluginResourceTypeByName("Apache Virtual Host")); - Set<Resource> uniques = new TreeSet<Resource>(new Comparator<Resource>() { - public int compare(Resource a, Resource b) { - return a.getResourceKey().compareTo(b.getResourceKey()); - } - }); - - for(Resource vhost : vhosts) { - if (uniques.contains(vhost)) { - //remove the vhost from the server's inventory - setup.getFakeInventory().removeResource(vhost); - } else { - uniques.add(vhost); - } - } - } - }); - } - - private void testUpgradeFromRHQ1_3(TestConfiguration testConfiguration) throws Throwable { - final TestSetup setup = new TestSetup(testConfiguration.configurationName); - boolean testFailed = false; - try { - testConfiguration.beforeTestSetup(setup); - - String configPath = "/full-configurations/" + testConfiguration.version.getConfigDirName() + "/simple/httpd.conf"; - - setup.withInventoryFrom("/mocked-inventories/rhq-1.3.x/simple/inventory.xml") - .withPlatformResource(platform).withDefaultExpectations().withDefaultOverrides(testConfiguration.defaultOverrides) - .withApacheSetup().withConfigurationFiles(configPath, "/snmpd.conf", "/mime.types") - .withServerRoot(testConfiguration.serverRoot).withExePath(testConfiguration.binPath).setup(); - - testConfiguration.beforePluginContainerStart(setup); - - startConfiguredPluginContainer(); - - testConfiguration.beforeTests(); - - //ok, now we should see the resources upgraded in the fake server inventory. - ResourceType serverResourceType = findApachePluginResourceTypeByName("Apache HTTP Server"); - ResourceType vhostResourceType = findApachePluginResourceTypeByName("Apache Virtual Host"); - - Set<Resource> servers = setup.getFakeInventory().findResourcesByType(serverResourceType); - - assertEquals(servers.size(), 1, "There should be exactly one apache server discovered."); - - Resource server = servers.iterator().next(); - - String expectedResourceKey = ApacheServerDiscoveryComponent.formatResourceKey(testConfiguration.serverRoot, testConfiguration.serverRoot - + "/conf/httpd.conf"); - - assertEquals(server.getResourceKey(), expectedResourceKey, - "The server resource key doesn't seem to be upgraded."); - - Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(vhostResourceType); - - assertEquals(vhosts.size(), 5, "Unexpected number of vhosts discovered found"); - - List<String> expectedResourceKeys = new ArrayList<String>(5); - - DeploymentConfig dc = setup.getDeploymentConfig(); - - expectedResourceKeys.add(ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY); - expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - dc.vhost1.getServerName(), dc.vhost1.getAddresses())); - expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - dc.vhost2.getServerName(), dc.vhost2.getAddresses())); - expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - dc.vhost3.getServerName(), dc.vhost3.getAddresses())); - expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( - dc.vhost4.getServerName(), dc.vhost4.getAddresses())); - - for (Resource vhost : vhosts) { - assertTrue(expectedResourceKeys.contains(vhost.getResourceKey()), - "Unexpected virtual host resource key: '" + vhost.getResourceKey() + "'. Only expecting " + expectedResourceKeys); - } - } catch (Throwable t) { - testFailed = true; - throw t; - } finally { - try { - setup.withApacheSetup().getExecutionUtil().invokeOperation("stop"); - } catch (Exception e) { - if (testFailed) { - LOG.error("Failed to stop apache.", e); - } else { - throw e; - } - } - } - } -}
commit 5a02ee97caf19a7f9945976f4fb22934574f7a36 Author: Lukas Krejci lkrejci@redhat.com Date: Wed Jun 22 18:17:07 2011 +0200
better message in TestNG reports
diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationWithResolvableServerNamesTest.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationWithResolvableServerNamesTest.java index 2ba6108..f887b83 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationWithResolvableServerNamesTest.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationWithResolvableServerNamesTest.java @@ -215,7 +215,7 @@ public class UpgradeSimpleConfigurationWithResolvableServerNamesTest extends Upg
for (Resource vhost : vhosts) { assertTrue(expectedResourceKeys.contains(vhost.getResourceKey()), - "Unexpected virtual host resource key: '" + vhost.getResourceKey() + "'."); + "Unexpected virtual host resource key: '" + vhost.getResourceKey() + "'. Only expecting " + expectedResourceKeys); } } catch (Throwable t) { testFailed = true;
commit ac3bee9ff340818cda04d0613c1cb44b8893a643 Author: Lukas Krejci lkrejci@redhat.com Date: Wed Jun 22 18:14:07 2011 +0200
Adding a test for upgrading apache that has 4 vhosts using the same servername (that uses an unresolvable hostname) from RHQ 1.3.x to the latest code. A bunch of fixes all around the place to make stuff more overridable from code rather than only from the system properties.
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java index 5f8a922..4d5dc7d 100644 --- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java +++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java @@ -271,6 +271,14 @@ public class FakeServerInventory { return result; }
+ public void removeResource(Resource r) { + resourceStore.remove(r.getUuid()); + Resource parent = r.getParentResource(); + if (parent != null) { + parent.getChildResources().remove(r); + } + } + private Resource fakePersist(Resource agentSideResource, InventoryStatus requiredInventoryStatus, Set<String> inProgressUUIds) { Resource persisted = resourceStore.get(agentSideResource.getUuid()); @@ -307,11 +315,18 @@ public class FakeServerInventory { persisted.setParentResource(parent); }
- Set<Resource> childResources = persisted.getChildResources(); + //persist the children + Set<Resource> childResources = new LinkedHashSet<Resource>(); for (Resource child : agentSideResource.getChildResources()) { childResources.add(fakePersist(child, requiredInventoryStatus, inProgressUUIds)); } - + //now update the list with whatever the persisted resource contained in the past + //i.e. we prefer the current results from the agent but keep the children we used to + //have in the past. This is the same behavior as the actual RHQ server has. + childResources.addAll(persisted.getChildResources()); + + persisted.setChildResources(childResources); + inProgressUUIds.remove(agentSideResource.getUuid());
return persisted; diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationWithResolvableServerNamesTest.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationWithResolvableServerNamesTest.java index b196654..2ba6108 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationWithResolvableServerNamesTest.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationWithResolvableServerNamesTest.java @@ -23,8 +23,12 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue;
import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Set; +import java.util.TreeSet;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -44,54 +48,137 @@ import org.rhq.test.pc.PluginContainerSetup; @Test(groups = "apache-integration-tests") public class UpgradeSimpleConfigurationWithResolvableServerNamesTest extends UpgradeTestBase { private static final Log LOG = LogFactory.getLog(UpgradeSimpleConfigurationWithResolvableServerNamesTest.class); - + private enum Apache { - V_1_3_x{ + V_1_3_x { public String getConfigDirName() { return "1.3.x"; } }, - + V_2_2_x { public String getConfigDirName() { return "2.2.x"; } }; - + public abstract String getConfigDirName(); } + + private static class TestConfiguration { + public Apache version; + public String configurationName; + public String serverRoot; + public String binPath; + public Map<String, String> defaultOverrides; + + public void beforeTestSetup(TestSetup testSetup) { + + } + + public void beforePluginContainerStart(TestSetup setup) { + + } + + public void beforeTests() { + + } + } + @Test @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) @Parameters({ "apache2.install.dir", "apache2.exe.path" }) - public void testSimpleConfigurationWithResolvableServerNames_Apache2_upgradeFromRHQ1_3( - String apacheInstallationDirectory, String exePath) throws Throwable { - - testUpgradeFromRHQ1_3(Apache.V_2_2_x, DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES, apacheInstallationDirectory, exePath); + public void testWithResolvableServerNames_Apache2_upgradeFromRHQ1_3(final String installPath, final String exePath) + throws Throwable { + + testUpgradeFromRHQ1_3(new TestConfiguration() { + { + serverRoot = installPath; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + version = Apache.V_2_2_x; + } + }); }
- @Test(enabled = false) //ApacheServerOperationsDelegate doesn't work with apache 1.3 + @Test(enabled = false) + //ApacheServerOperationsDelegate doesn't work with apache 1.3 @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) @Parameters({ "apache1.install.dir", "apache1.exe.path" }) - public void testSimpleConfigurationWithResolvableServerNames_Apache1_upgradeFromRHQ1_3( - String apacheInstallationDirectory, String exePath) throws Throwable { + public void testWithResolvableServerNames_Apache1_upgradeFromRHQ1_3(final String installPath, final String exePath) + throws Throwable { + + testUpgradeFromRHQ1_3(new TestConfiguration() {{ + serverRoot = installPath; + binPath = exePath; + configurationName = DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES; + version = Apache.V_1_3_x; + }}); + }
- testUpgradeFromRHQ1_3(Apache.V_1_3_x, DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES, apacheInstallationDirectory, exePath); + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testWithUnresolvableServerNames_Apache2_upgradeFromRHQ1_3(final String installPath, final String exePath) throws Throwable { + testUpgradeFromRHQ1_3(new TestConfiguration() { + { + configurationName = DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES; + serverRoot = installPath; + binPath = exePath; + version = Apache.V_2_2_x; + + defaultOverrides = new HashMap<String, String>(); + defaultOverrides.put(variableName(configurationName, "servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost1.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost2.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost3.servername.directive"), "ServerName ${unresolvable.host}"); + defaultOverrides.put(variableName(configurationName, "vhost4.servername.directive"), "ServerName ${unresolvable.host}"); + } + + @Override + public void beforePluginContainerStart(TestSetup setup) { + //in this scenario, the RHQ 1.3 would only discover 1 vhost (and the main vhost), because they would have the same resource key + //due to the same ServerName. I need to process the default inventory to reflect that otherwise I would get upgrade + //failures. + + Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(findApachePluginResourceTypeByName("Apache Virtual Host")); + Set<Resource> uniques = new TreeSet<Resource>(new Comparator<Resource>() { + public int compare(Resource a, Resource b) { + return a.getResourceKey().compareTo(b.getResourceKey()); + } + }); + + for(Resource vhost : vhosts) { + if (uniques.contains(vhost)) { + //remove the vhost from the server's inventory + setup.getFakeInventory().removeResource(vhost); + } else { + uniques.add(vhost); + } + } + } + }); }
- private void testUpgradeFromRHQ1_3(Apache version, String configurationName, String serverRoot, String binPath) throws Throwable { - final TestSetup setup = new TestSetup(configurationName); + private void testUpgradeFromRHQ1_3(TestConfiguration testConfiguration) throws Throwable { + final TestSetup setup = new TestSetup(testConfiguration.configurationName); boolean testFailed = false; try { + testConfiguration.beforeTestSetup(setup);
- String configPath = "/full-configurations/" + version.getConfigDirName() + "/simple/httpd.conf"; - - setup.withInventoryFrom("/mocked-inventories/rhq-1.3.x/includes/inventory.xml") - .withPlatformResource(platform).withDefaultExpectations().withApacheSetup() - .withConfigurationFiles(configPath, "/snmpd.conf", "/mime.types") - .withServerRoot(serverRoot).withExePath(binPath).setup(); + String configPath = "/full-configurations/" + testConfiguration.version.getConfigDirName() + "/simple/httpd.conf"; + + setup.withInventoryFrom("/mocked-inventories/rhq-1.3.x/simple/inventory.xml") + .withPlatformResource(platform).withDefaultExpectations().withDefaultOverrides(testConfiguration.defaultOverrides) + .withApacheSetup().withConfigurationFiles(configPath, "/snmpd.conf", "/mime.types") + .withServerRoot(testConfiguration.serverRoot).withExePath(testConfiguration.binPath).setup();
+ testConfiguration.beforePluginContainerStart(setup); + startConfiguredPluginContainer();
+ testConfiguration.beforeTests(); + //ok, now we should see the resources upgraded in the fake server inventory. ResourceType serverResourceType = findApachePluginResourceTypeByName("Apache HTTP Server"); ResourceType vhostResourceType = findApachePluginResourceTypeByName("Apache Virtual Host"); @@ -102,7 +189,7 @@ public class UpgradeSimpleConfigurationWithResolvableServerNamesTest extends Upg
Resource server = servers.iterator().next();
- String expectedResourceKey = ApacheServerDiscoveryComponent.formatResourceKey(serverRoot, serverRoot + String expectedResourceKey = ApacheServerDiscoveryComponent.formatResourceKey(testConfiguration.serverRoot, testConfiguration.serverRoot + "/conf/httpd.conf");
assertEquals(server.getResourceKey(), expectedResourceKey, @@ -110,7 +197,7 @@ public class UpgradeSimpleConfigurationWithResolvableServerNamesTest extends Upg
Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(vhostResourceType);
- assertEquals(vhosts.size(), 5, "There should be 5 vhosts discovered but found " + vhosts.size()); + assertEquals(vhosts.size(), 5, "Unexpected number of vhosts discovered found");
List<String> expectedResourceKeys = new ArrayList<String>(5);
diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java index e44dc99..16bd06b 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java @@ -31,15 +31,14 @@ import java.net.UnknownHostException; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID;
import org.jmock.Expectations; -import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; -import org.testng.annotations.Parameters;
import org.rhq.core.clientapi.agent.metadata.PluginMetadataParser; import org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil; @@ -81,7 +80,8 @@ public class UpgradeTestBase extends PluginContainerTest { private Resource platform; private ApacheSetup apacheSetup = new ApacheSetup(); private DeploymentConfig deploymentConfig; - + private Map<String, String> defaultOverrides = new HashMap<String, String>(); + public class ApacheSetup { private String serverRoot; private String exePath; @@ -97,7 +97,7 @@ public class UpgradeTestBase extends PluginContainerTest { this.serverRoot = serverRoot; //auto-define the server root property as if it was passed on the commandline System.getProperties().put(configurationName + ".server.root", serverRoot); - deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName); + deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName, defaultOverrides); return this; }
@@ -179,14 +179,20 @@ public class UpgradeTestBase extends PluginContainerTest {
public TestSetup(String configurationName) { this.configurationName = configurationName; - deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName); + deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName, defaultOverrides); }
public TestSetup withInventoryFrom(String classPathUri) { inventoryFile = classPathUri; return this; } - + + public TestSetup withDefaultOverrides(Map<String, String> defaultOverrides) { + this.defaultOverrides = defaultOverrides == null ? new HashMap<String, String>() : defaultOverrides; + deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName, this.defaultOverrides); + return this; + } + public TestSetup withPlatformResource(Resource platform) { this.platform = platform; return this; @@ -255,7 +261,7 @@ public class UpgradeTestBase extends PluginContainerTest { public TestSetup setup() throws Exception { apacheSetup.doSetup();
- Map<String, String> replacements = deploymentConfig.getTokenReplacements(); + Map<String, String> replacements = deploymentConfig.getTokenReplacements(); replacements.put("server.root", apacheSetup.serverRoot); replacements.put("exe.path", apacheSetup.exePath); replacements.put("localhost", determineLocalhost()); @@ -412,4 +418,14 @@ public class UpgradeTestBase extends PluginContainerTest { return null; }
+ protected static String variableName(String prefix, String name) { + StringBuilder bld = new StringBuilder(); + if (prefix != null && !prefix.isEmpty()) { + bld.append(prefix).append("."); + } + + bld.append(name); + + return bld.toString(); + } } diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java index 59e5d7e..97abce3 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java @@ -203,30 +203,36 @@ public class ApacheDeploymentUtil { checkOrAddDefault(variables, "port3", "11677"); checkOrAddDefault(variables, "port4", "11678");
- checkOrAddDefault(variables, prefix + ".listen1", "${port1}"); - checkOrAddDefault(variables, prefix + ".listen2", "${port2}"); - checkOrAddDefault(variables, prefix + ".listen3", "${port3}"); - checkOrAddDefault(variables, prefix + ".listen4", "${port4}"); - - checkOrAddDefault(variables, prefix + ".vhost1.servername", "${localhost}:${port1}"); - checkOrAddDefault(variables, prefix + ".vhost1.urls", "${" + prefix + ".vhost1.servername}"); - checkOrAddDefault(variables, prefix + ".vhost1.servername.directive", "ServerName ${" + prefix - + ".vhost1.servername}"); - - checkOrAddDefault(variables, prefix + ".vhost2.servername", "${localhost}:${port2}"); - checkOrAddDefault(variables, prefix + ".vhost2.urls", "${" + prefix + ".vhost2.servername}"); - checkOrAddDefault(variables, prefix + ".vhost2.servername.directive", "ServerName ${" + prefix - + ".vhost2.servername}"); - - checkOrAddDefault(variables, prefix + ".vhost3.servername", "${localhost}:${port3}"); - checkOrAddDefault(variables, prefix + ".vhost3.urls", "${" + prefix + ".vhost3.servername}"); - checkOrAddDefault(variables, prefix + ".vhost3.servername.directive", "ServerName ${" + prefix - + ".vhost3.servername}"); - - checkOrAddDefault(variables, prefix + ".vhost4.servername", "${localhost}:${port4}"); - checkOrAddDefault(variables, prefix + ".vhost4.urls", "${" + prefix + ".vhost4.servername}"); - checkOrAddDefault(variables, prefix + ".vhost4.servername.directive", "ServerName ${" + prefix - + ".vhost4.servername}"); + if (prefix != null && !prefix.trim().isEmpty()) { + prefix += "."; + } else { + prefix = ""; + } + + checkOrAddDefault(variables, prefix + "listen1", "${port1}"); + checkOrAddDefault(variables, prefix + "listen2", "${port2}"); + checkOrAddDefault(variables, prefix + "listen3", "${port3}"); + checkOrAddDefault(variables, prefix + "listen4", "${port4}"); + + checkOrAddDefault(variables, prefix + "vhost1.servername", "${localhost}:${port1}"); + checkOrAddDefault(variables, prefix + "vhost1.urls", "${" + prefix + "vhost1.servername}"); + checkOrAddDefault(variables, prefix + "vhost1.servername.directive", "ServerName ${" + prefix + + "vhost1.servername}"); + + checkOrAddDefault(variables, prefix + "vhost2.servername", "${localhost}:${port2}"); + checkOrAddDefault(variables, prefix + "vhost2.urls", "${" + prefix + "vhost2.servername}"); + checkOrAddDefault(variables, prefix + "vhost2.servername.directive", "ServerName ${" + prefix + + "vhost2.servername}"); + + checkOrAddDefault(variables, prefix + "vhost3.servername", "${localhost}:${port3}"); + checkOrAddDefault(variables, prefix + "vhost3.urls", "${" + prefix + "vhost3.servername}"); + checkOrAddDefault(variables, prefix + "vhost3.servername.directive", "ServerName ${" + prefix + + "vhost3.servername}"); + + checkOrAddDefault(variables, prefix + "vhost4.servername", "${localhost}:${port4}"); + checkOrAddDefault(variables, prefix + "vhost4.urls", "${" + prefix + "vhost4.servername}"); + checkOrAddDefault(variables, prefix + "vhost4.servername.directive", "ServerName ${" + prefix + + "vhost4.servername}"); }
private static void checkOrAddDefault(Map<String, String> map, String key, String value) { @@ -234,12 +240,13 @@ public class ApacheDeploymentUtil { map.put(key, value); } } - - public static DeploymentConfig getDeploymentConfigurationFromSystemProperties(String variablesPrefix) { + + public static DeploymentConfig getDeploymentConfigurationFromSystemProperties(String variablesPrefix, Map<String, String> defaultOverrides) { DeploymentConfig ret = new DeploymentConfig();
- Map<String, String> properties = new TokenReplacingProperties(System.getProperties()); + TokenReplacingProperties properties = new TokenReplacingProperties(defaultOverrides); addDefaultVariables(properties, variablesPrefix); + properties.putAll(System.getProperties());
variablesPrefix += ".";
diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/includes/inventory.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/includes/inventory.xml deleted file mode 100644 index c3a82eb..0000000 --- a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/includes/inventory.xml +++ /dev/null @@ -1,539 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<inventory-dump> -<classes-used> -<class>org.rhq.core.domain.resource.Resource</class> -</classes-used> -<objects> - -<resource> - <id>10004</id> - <uuid>ae8a7a3e-256e-4c0a-9a65-33d534523d92</uuid> - <resourceKey>${server.root}</resourceKey> - <name>${localhost} Apache 2.2.17 (${server.root}/)</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>true</connected> - <version>2.2.17</version> - <description>Apache Web Server</description> - <ctime>1307353451273</ctime> - <mtime>1307353509168</mtime> - <itime>1307353509168</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVER</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <description>an Apache HTTP Server instance</description> - <id>10013</id> - <name>Apache HTTP Server</name> - <plugin>Apache</plugin> - <pluginConfigurationDefinition> - <id>10012</id> - <propertyDefinitions/> - </pluginConfigurationDefinition> - <singleton>false</singleton> - <supportsManualAdd>true</supportsManualAdd> - </resourceType> - <childResources> - <id>10022</id> - <uuid>08290193-c716-4363-b841-8a1d9d83f580</uuid> - <resourceKey>${localhost}:0</resourceKey> - <name>Virtual Host ${localhost}:0</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> - <ctime>1307353587727</ctime> - <mtime>1307353587727</mtime> - <itime>1307353587721</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10014</id> - <name>Apache Virtual Host</name> - <plugin>Apache</plugin> - <pluginConfigurationDefinition> - <id>10013</id> - <propertyDefinitions/> - </pluginConfigurationDefinition> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10137</id> - <version>0</version> - <ctime>1307353587728</ctime> - <mtime>1307353587728</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10138</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353587728</ctime> - <mtime>1307353587728</mtime> - <propertySimple> - <id>10690</id> - <name>responseTimeUrlExcludes</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10689</id> - <name>responseTimeLogFile</name> - <override>false</override> - <stringValue>${server.root}/logs/${localhost}0_rt.log</stringValue> - </propertySimple> - <propertySimple> - <id>10692</id> - <name>url</name> - <override>false</override> - <stringValue>http://$%7Blocalhost%7D:0/</stringValue> - </propertySimple> - <propertySimple> - <id>10693</id> - <name>snmpWwwServiceIndex</name> - <override>false</override> - <stringValue>1</stringValue> - </propertySimple> - <propertySimple> - <id>10691</id> - <name>responseTimeUrlTransforms</name> - <override>false</override> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>DOWN</availabilityType> - </currentAvailability> - </childResources> - <childResources> - <id>10021</id> - <uuid>3a20d809-7eba-422c-a3ef-baf65804498d</uuid> - <resourceKey>${vhost2.snmp.identifier}</resourceKey> - <name>Virtual Host ${vhost2.snmp.identifier}</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> - <ctime>1307353587648</ctime> - <mtime>1307353587648</mtime> - <itime>1307353587648</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10014</id> - <name>Apache Virtual Host</name> - <plugin>Apache</plugin> - <pluginConfigurationDefinition> - <id>10013</id> - <propertyDefinitions/> - </pluginConfigurationDefinition> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10135</id> - <version>0</version> - <ctime>1307353587666</ctime> - <mtime>1307353587666</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10136</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353587667</ctime> - <mtime>1307353587667</mtime> - <propertySimple> - <id>10685</id> - <name>responseTimeUrlExcludes</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10684</id> - <name>responseTimeLogFile</name> - <override>false</override> - <stringValue>${server.root}/logs/127.0.0.111676_rt.log</stringValue> - </propertySimple> - <propertySimple> - <id>10687</id> - <name>url</name> - <override>false</override> - <stringValue>http://$%7Bvhost2.snmp.identifier%7D/</stringValue> - </propertySimple> - <propertySimple> - <id>10688</id> - <name>snmpWwwServiceIndex</name> - <override>false</override> - <stringValue>4</stringValue> - </propertySimple> - <propertySimple> - <id>10686</id> - <name>responseTimeUrlTransforms</name> - <override>false</override> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> - </childResources> - <childResources> - <id>10023</id> - <uuid>c62c5d75-81dd-4b14-a768-2d8c1fca6c88</uuid> - <resourceKey>${vhost3.snmp.identifier}</resourceKey> - <name>Virtual Host ${vhost3.snmp.identifier}</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> - <ctime>1307353587738</ctime> - <mtime>1307353587738</mtime> - <itime>1307353587737</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10014</id> - <name>Apache Virtual Host</name> - <plugin>Apache</plugin> - <pluginConfigurationDefinition> - <id>10013</id> - <propertyDefinitions/> - </pluginConfigurationDefinition> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10139</id> - <version>0</version> - <ctime>1307353587738</ctime> - <mtime>1307353587738</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10140</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353587738</ctime> - <mtime>1307353587738</mtime> - <propertySimple> - <id>10695</id> - <name>responseTimeUrlExcludes</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10694</id> - <name>responseTimeLogFile</name> - <override>false</override> - <stringValue>${server.root}/logs/127.0.0.111677_rt.log</stringValue> - </propertySimple> - <propertySimple> - <id>10697</id> - <name>url</name> - <override>false</override> - <stringValue>http://$%7Bvhost3.snmp.identifier%7D/</stringValue> - </propertySimple> - <propertySimple> - <id>10698</id> - <name>snmpWwwServiceIndex</name> - <override>false</override> - <stringValue>3</stringValue> - </propertySimple> - <propertySimple> - <id>10696</id> - <name>responseTimeUrlTransforms</name> - <override>false</override> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> - </childResources> - <childResources> - <id>10024</id> - <uuid>d1b59168-8666-4bc0-957e-171bf16eec73</uuid> - <resourceKey>${vhost1.snmp.identifier}</resourceKey> - <name>Virtual Host ${vhost1.snmp.identifier}</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> - <ctime>1307353587751</ctime> - <mtime>1307353587751</mtime> - <itime>1307353587750</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10014</id> - <name>Apache Virtual Host</name> - <plugin>Apache</plugin> - <pluginConfigurationDefinition> - <id>10013</id> - <propertyDefinitions/> - </pluginConfigurationDefinition> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10171</id> - <version>0</version> - <ctime>1307353587751</ctime> - <mtime>1307353587751</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10172</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353587751</ctime> - <mtime>1307353587751</mtime> - <propertySimple> - <id>10700</id> - <name>responseTimeUrlExcludes</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10699</id> - <name>responseTimeLogFile</name> - <override>false</override> - <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> - </propertySimple> - <propertySimple> - <id>10702</id> - <name>url</name> - <override>false</override> - <stringValue>http://$%7Bvhost1.snmp.identifier%7D/</stringValue> - </propertySimple> - <propertySimple> - <id>10703</id> - <name>snmpWwwServiceIndex</name> - <override>false</override> - <stringValue>5</stringValue> - </propertySimple> - <propertySimple> - <id>10701</id> - <name>responseTimeUrlTransforms</name> - <override>false</override> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> - </childResources> - <childResources> - <id>10025</id> - <uuid>310281d2-60c6-4d7d-bcdc-c51d7969c906</uuid> - <resourceKey>${vhost4.snmp.identifier}</resourceKey> - <name>Virtual Host ${vhost4.snmp.identifier}</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> - <ctime>1307353587761</ctime> - <mtime>1307353587761</mtime> - <itime>1307353587760</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10014</id> - <name>Apache Virtual Host</name> - <plugin>Apache</plugin> - <pluginConfigurationDefinition> - <id>10013</id> - <propertyDefinitions/> - </pluginConfigurationDefinition> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10173</id> - <version>0</version> - <ctime>1307353587761</ctime> - <mtime>1307353587761</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10174</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353587761</ctime> - <mtime>1307353587761</mtime> - <propertySimple> - <id>10705</id> - <name>responseTimeUrlExcludes</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10704</id> - <name>responseTimeLogFile</name> - <override>false</override> - <stringValue>${server.root}/logs/127.0.0.111678_rt.log</stringValue> - </propertySimple> - <propertySimple> - <id>10707</id> - <name>url</name> - <override>false</override> - <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> - </propertySimple> - <propertySimple> - <id>10708</id> - <name>snmpWwwServiceIndex</name> - <override>false</override> - <stringValue>2</stringValue> - </propertySimple> - <propertySimple> - <id>10706</id> - <name>responseTimeUrlTransforms</name> - <override>false</override> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> - </childResources> - <resourceConfiguration> - <id>10142</id> - <version>0</version> - <ctime>1307353451273</ctime> - <mtime>1307353451273</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10073</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353737118</ctime> - <mtime>1307353737118</mtime> - <propertySimple> - <id>10365</id> - <name>errorLogMinimumSeverity</name> - <override>false</override> - <stringValue>error</stringValue> - </propertySimple> - <propertySimple> - <id>10366</id> - <name>errorLogIncludesPattern</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10367</id> - <name>snmpAgentCommunity</name> - <override>false</override> - <stringValue>public</stringValue> - </propertySimple> - <propertySimple> - <id>10368</id> - <name>errorLogFilePath</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10369</id> - <name>errorLogEventsEnabled</name> - <override>false</override> - <stringValue>false</stringValue> - </propertySimple> - <propertySimple> - <id>10370</id> - <name>snmpAgentHost</name> - <override>false</override> - <stringValue>127.0.0.1</stringValue> - </propertySimple> - <propertySimple> - <id>10713</id> - <name>controlScriptPath</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10714</id> - <name>url</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10364</id> - <name>configFile</name> - <override>false</override> - <stringValue>conf/httpd.conf</stringValue> - </propertySimple> - <propertySimple> - <id>10711</id> - <name>executablePath</name> - <override>false</override> - <stringValue>${exe.path}</stringValue> - </propertySimple> - <propertySimple> - <id>10712</id> - <name>snmpAgentPort</name> - <override>false</override> - <stringValue>1610</stringValue> - </propertySimple> - <propertySimple> - <id>10715</id> - <name>serverRoot</name> - <override>false</override> - <stringValue>${server.root}</stringValue> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> - <productVersion> - <id>10003</id> - </productVersion> -</resource> -</objects> -</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/simple/inventory.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/simple/inventory.xml new file mode 100644 index 0000000..1aa8b38 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/simple/inventory.xml @@ -0,0 +1,539 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10004</id> + <uuid>ae8a7a3e-256e-4c0a-9a65-33d534523d92</uuid> + <resourceKey>${server.root}</resourceKey> + <name>${localhost} Apache 2.2.17 (${server.root}/)</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>true</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1307353451273</ctime> + <mtime>1307353509168</mtime> + <itime>1307353509168</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10013</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10012</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <childResources> + <id>10022</id> + <uuid>08290193-c716-4363-b841-8a1d9d83f580</uuid> + <resourceKey>${snmp.identifier}</resourceKey> + <name>Virtual Host ${snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587727</ctime> + <mtime>1307353587727</mtime> + <itime>1307353587721</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10137</id> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10138</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + <propertySimple> + <id>10690</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10689</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/${localhost}0_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10692</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Blocalhost%7D:0/</stringValue> + </propertySimple> + <propertySimple> + <id>10693</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>1</stringValue> + </propertySimple> + <propertySimple> + <id>10691</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>DOWN</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10021</id> + <uuid>3a20d809-7eba-422c-a3ef-baf65804498d</uuid> + <resourceKey>${vhost2.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost2.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587648</ctime> + <mtime>1307353587648</mtime> + <itime>1307353587648</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10135</id> + <version>0</version> + <ctime>1307353587666</ctime> + <mtime>1307353587666</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10136</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587667</ctime> + <mtime>1307353587667</mtime> + <propertySimple> + <id>10685</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10684</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111676_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10687</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost2.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10688</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>4</stringValue> + </propertySimple> + <propertySimple> + <id>10686</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10023</id> + <uuid>c62c5d75-81dd-4b14-a768-2d8c1fca6c88</uuid> + <resourceKey>${vhost3.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost3.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + <itime>1307353587737</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10139</id> + <version>0</version> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10140</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + <propertySimple> + <id>10695</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10694</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111677_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10697</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost3.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10698</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>3</stringValue> + </propertySimple> + <propertySimple> + <id>10696</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10024</id> + <uuid>d1b59168-8666-4bc0-957e-171bf16eec73</uuid> + <resourceKey>${vhost1.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost1.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + <itime>1307353587750</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10171</id> + <version>0</version> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10172</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + <propertySimple> + <id>10700</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10699</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10702</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost1.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10703</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>5</stringValue> + </propertySimple> + <propertySimple> + <id>10701</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10025</id> + <uuid>310281d2-60c6-4d7d-bcdc-c51d7969c906</uuid> + <resourceKey>${vhost4.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + <itime>1307353587760</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10173</id> + <version>0</version> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10174</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + <propertySimple> + <id>10705</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10704</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10707</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>2</stringValue> + </propertySimple> + <propertySimple> + <id>10706</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <resourceConfiguration> + <id>10142</id> + <version>0</version> + <ctime>1307353451273</ctime> + <mtime>1307353451273</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10073</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353737118</ctime> + <mtime>1307353737118</mtime> + <propertySimple> + <id>10365</id> + <name>errorLogMinimumSeverity</name> + <override>false</override> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10366</id> + <name>errorLogIncludesPattern</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10367</id> + <name>snmpAgentCommunity</name> + <override>false</override> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10368</id> + <name>errorLogFilePath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10369</id> + <name>errorLogEventsEnabled</name> + <override>false</override> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10370</id> + <name>snmpAgentHost</name> + <override>false</override> + <stringValue>127.0.0.1</stringValue> + </propertySimple> + <propertySimple> + <id>10713</id> + <name>controlScriptPath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10714</id> + <name>url</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10364</id> + <name>configFile</name> + <override>false</override> + <stringValue>conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10711</id> + <name>executablePath</name> + <override>false</override> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10712</id> + <name>snmpAgentPort</name> + <override>false</override> + <stringValue>1610</stringValue> + </propertySimple> + <propertySimple> + <id>10715</id> + <name>serverRoot</name> + <override>false</override> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10003</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/test-utils/src/main/java/org/rhq/test/TokenReplacingProperties.java b/modules/test-utils/src/main/java/org/rhq/test/TokenReplacingProperties.java index 9e359cb..0b9e87d 100644 --- a/modules/test-utils/src/main/java/org/rhq/test/TokenReplacingProperties.java +++ b/modules/test-utils/src/main/java/org/rhq/test/TokenReplacingProperties.java @@ -136,8 +136,7 @@ public class TokenReplacingProperties extends HashMap<String, String> { @SuppressWarnings("unchecked") public TokenReplacingProperties(Properties properties) { @SuppressWarnings("rawtypes") - Map map = (Map<Object, Object>) properties; - + Map map = properties; this.wrapped = (Map<String, String>) map; }
@@ -186,6 +185,12 @@ public class TokenReplacingProperties extends HashMap<String, String> { wrapped.putAll(m); }
+ public void putAll(Properties properties) { + for(String propName : properties.stringPropertyNames()) { + put(propName, properties.getProperty(propName)); + } + } + @Override public void clear() { wrapped.clear();
commit baa0518946919469e26fb92f32510428e49aece8 Author: Lukas Krejci lkrejci@redhat.com Date: Tue Jun 21 14:46:47 2011 +0200
An attempt to test the support for Apache 1.3, TokenReplacingMap renamed to TokenReplacingProperties and moved to test-utils - it's a generic reusable class.
diff --git a/modules/plugins/apache/pom.xml b/modules/plugins/apache/pom.xml index ebfc749..65d1bb2 100644 --- a/modules/plugins/apache/pom.xml +++ b/modules/plugins/apache/pom.xml @@ -246,20 +246,25 @@ <apache1.install.dir>PASS THIS IN FROM THE COMMAND LINE</apache1.install.dir> <apache1.exe.path>bin/httpd</apache1.exe.path>
- <port1><!-- defaults to 11675--></port1> - <port2><!-- defaults to 11676--></port2> - <port3><!-- defaults to 11677--></port3> - <port4><!-- defaults to 11678--></port4> - <localhost><!-- defaults to the actual localhost hostname --></localhost> - <unresolvable.host><!-- defaults to 'unreachable.host.com' --></unresolvable.host> - + <!-- generic configurations --> + <!-- + <port1>defaults to 11675</port1> + <port2>defaults to 11676</port2> + <port3>defaults to 11677</port3> + <port4>defaults to 11678</port4> + <localhost>defaults to the actual localhost hostname</localhost> + <localhost.ip>defaults to the actual localhost ip</localhost.ip> + <unresolvable.host>defaults to 'unreachable.host.com'</unresolvable.host> + --> + <!-- configuration of individual upgrade tests --> <!-- + <*.server.root>defaults to whatever path is passed to the tests - i.e. either apache2.install.dir or apache1.install.dir</*.server.root> <*.document.root>defaults to 'htdocs'</*.document.root> <*.listen1>defaults to ${port1}</*.listen1> - <*.listen2>defaults to '${port2}'</*.listen2> - <*.listen3>defaults to '${port3}'</*.listen3> - <*.listen4>defaults to '${port4}'</*.listen4> + <*.listen2>defaults to ${port2}</*.listen2> + <*.listen3>defaults to ${port3}</*.listen3> + <*.listen4>defaults to ${port4}</*.listen4> <*.servername.directive>defaults to ''</*.servername.directive> <*.additional.directives>defaults to ''</*.additional.directives> <*.vhost1.urls>defaults to '${localhost}:${port1}'</*.vhost1.urls> @@ -274,9 +279,7 @@ <*.vhost4.urls>defaults to '${localhost}:${port4}'</*.vhost4.urls> <*.vhost4.servername.directive>defaults to 'ServerName ${localhost}:${port4}'</*.vhost4.servername.directive> <*.vhost4.additional.directives>defaults to ''</*.vhost4.additional.directives> - --> - - <simpleWithResolvableServerNames.server.root>${apache2.install.dir}</simpleWithResolvableServerNames.server.root> + -->
</systemPropertyVariables> </configuration> diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationWithResolvableServerNamesTest.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationWithResolvableServerNamesTest.java new file mode 100644 index 0000000..b196654 --- /dev/null +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeSimpleConfigurationWithResolvableServerNamesTest.java @@ -0,0 +1,148 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.plugins.apache; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.resource.ResourceType; +import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig; +import org.rhq.test.pc.PluginContainerSetup; + +/** + * + * + * @author Lukas Krejci + */ +@Test(groups = "apache-integration-tests") +public class UpgradeSimpleConfigurationWithResolvableServerNamesTest extends UpgradeTestBase { + private static final Log LOG = LogFactory.getLog(UpgradeSimpleConfigurationWithResolvableServerNamesTest.class); + + private enum Apache { + V_1_3_x{ + public String getConfigDirName() { + return "1.3.x"; + } + }, + + V_2_2_x { + public String getConfigDirName() { + return "2.2.x"; + } + }; + + public abstract String getConfigDirName(); + } + @Test + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testSimpleConfigurationWithResolvableServerNames_Apache2_upgradeFromRHQ1_3( + String apacheInstallationDirectory, String exePath) throws Throwable { + + testUpgradeFromRHQ1_3(Apache.V_2_2_x, DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES, apacheInstallationDirectory, exePath); + } + + @Test(enabled = false) //ApacheServerOperationsDelegate doesn't work with apache 1.3 + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache1.install.dir", "apache1.exe.path" }) + public void testSimpleConfigurationWithResolvableServerNames_Apache1_upgradeFromRHQ1_3( + String apacheInstallationDirectory, String exePath) throws Throwable { + + testUpgradeFromRHQ1_3(Apache.V_1_3_x, DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES, apacheInstallationDirectory, exePath); + } + + private void testUpgradeFromRHQ1_3(Apache version, String configurationName, String serverRoot, String binPath) throws Throwable { + final TestSetup setup = new TestSetup(configurationName); + boolean testFailed = false; + try { + + String configPath = "/full-configurations/" + version.getConfigDirName() + "/simple/httpd.conf"; + + setup.withInventoryFrom("/mocked-inventories/rhq-1.3.x/includes/inventory.xml") + .withPlatformResource(platform).withDefaultExpectations().withApacheSetup() + .withConfigurationFiles(configPath, "/snmpd.conf", "/mime.types") + .withServerRoot(serverRoot).withExePath(binPath).setup(); + + startConfiguredPluginContainer(); + + //ok, now we should see the resources upgraded in the fake server inventory. + ResourceType serverResourceType = findApachePluginResourceTypeByName("Apache HTTP Server"); + ResourceType vhostResourceType = findApachePluginResourceTypeByName("Apache Virtual Host"); + + Set<Resource> servers = setup.getFakeInventory().findResourcesByType(serverResourceType); + + assertEquals(servers.size(), 1, "There should be exactly one apache server discovered."); + + Resource server = servers.iterator().next(); + + String expectedResourceKey = ApacheServerDiscoveryComponent.formatResourceKey(serverRoot, serverRoot + + "/conf/httpd.conf"); + + assertEquals(server.getResourceKey(), expectedResourceKey, + "The server resource key doesn't seem to be upgraded."); + + Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(vhostResourceType); + + assertEquals(vhosts.size(), 5, "There should be 5 vhosts discovered but found " + vhosts.size()); + + List<String> expectedResourceKeys = new ArrayList<String>(5); + + DeploymentConfig dc = setup.getDeploymentConfig(); + + expectedResourceKeys.add(ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY); + expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( + dc.vhost1.getServerName(), dc.vhost1.getAddresses())); + expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( + dc.vhost2.getServerName(), dc.vhost2.getAddresses())); + expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( + dc.vhost3.getServerName(), dc.vhost3.getAddresses())); + expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey( + dc.vhost4.getServerName(), dc.vhost4.getAddresses())); + + for (Resource vhost : vhosts) { + assertTrue(expectedResourceKeys.contains(vhost.getResourceKey()), + "Unexpected virtual host resource key: '" + vhost.getResourceKey() + "'."); + } + } catch (Throwable t) { + testFailed = true; + throw t; + } finally { + try { + setup.withApacheSetup().getExecutionUtil().invokeOperation("stop"); + } catch (Exception e) { + if (testFailed) { + LOG.error("Failed to stop apache.", e); + } else { + throw e; + } + } + } + } +} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java deleted file mode 100644 index 056fead..0000000 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2011 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.plugins.apache; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.testng.annotations.Parameters; -import org.testng.annotations.Test; - -import org.rhq.core.domain.resource.Resource; -import org.rhq.core.domain.resource.ResourceType; -import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig; -import org.rhq.test.pc.PluginContainerSetup; - -/** - * - * - * @author Lukas Krejci - */ -@Test(groups = "apache-integration-tests") -public class UpgradeTest extends UpgradeTestBase { - - @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) - @Parameters({ "apache2.install.dir", "apache2.exe.path" }) - public void testSimpleConfigurationWithResolvableServerNames_Apache2_upgradeFromRHQ1_3( - String apacheInstallationDirectory, String exePath) throws Exception { - - final TestSetup setup = new TestSetup(DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES) - .withInventoryFrom("/mocked-inventories/rhq-1.3.x/includes/inventory.xml").withPlatformResource(platform) - .withDefaultExpectations().withApacheSetup() - .withConfigurationFiles("/full-configurations/simple/httpd.conf", "/snmpd.conf", "/mime.types") - .withServerRoot(apacheInstallationDirectory).withExePath(exePath).setup(); - - startConfiguredPluginContainer(); - - //ok, now we should see the resources upgraded in the fake server inventory. - ResourceType serverResourceType = findApachePluginResourceTypeByName("Apache HTTP Server"); - ResourceType vhostResourceType = findApachePluginResourceTypeByName("Apache Virtual Host"); - - Set<Resource> servers = setup.getFakeInventory().findResourcesByType(serverResourceType); - - assertTrue(servers.size() == 1, "There should be exactly one apache server discovered."); - - Resource server = servers.iterator().next(); - - String expectedResourceKey = ApacheServerDiscoveryComponent.formatResourceKey(apacheInstallationDirectory, - apacheInstallationDirectory + "/conf/httpd.conf"); - - assertEquals(server.getResourceKey(), expectedResourceKey, - "The server resource key doesn't seem to be upgraded."); - - Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(vhostResourceType); - - assertTrue(vhosts.size() == 5, "There should be 5 vhosts discovered but found " + vhosts.size()); - - List<String> expectedResourceKeys = new ArrayList<String>(5); - - DeploymentConfig dc = setup.getDeploymentConfig(); - - expectedResourceKeys.add(ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY); - expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(dc.vhost1.getServerName(), dc.vhost1.getAddresses())); - expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(dc.vhost2.getServerName(), dc.vhost2.getAddresses())); - expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(dc.vhost3.getServerName(), dc.vhost3.getAddresses())); - expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(dc.vhost4.getServerName(), dc.vhost4.getAddresses())); - - for(Resource vhost : vhosts) { - assertTrue(expectedResourceKeys.contains(vhost.getResourceKey()), "Unexpected virtual host resource key: '" + vhost.getResourceKey() + "'."); - } - } -} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java index 2c6f4f2..e44dc99 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java @@ -88,13 +88,16 @@ public class UpgradeTestBase extends PluginContainerTest { private Collection<String> configurationFiles; private ApacheExecutionUtil execution; private boolean deploy = true; - + private ApacheSetup() {
}
public ApacheSetup withServerRoot(String serverRoot) { this.serverRoot = serverRoot; + //auto-define the server root property as if it was passed on the commandline + System.getProperties().put(configurationName + ".server.root", serverRoot); + deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName); return this; }
@@ -166,7 +169,7 @@ public class UpgradeTestBase extends PluginContainerTest {
private void doSetup() throws Exception { init(); - execution.invokeOperation("restart", "start"); + execution.invokeOperation("start"); }
public TestSetup setup() throws Exception { @@ -252,7 +255,7 @@ public class UpgradeTestBase extends PluginContainerTest { public TestSetup setup() throws Exception { apacheSetup.doSetup();
- Map<String, String> replacements = deploymentConfig.getTokenReplacements(); + Map<String, String> replacements = deploymentConfig.getTokenReplacements(); replacements.put("server.root", apacheSetup.serverRoot); replacements.put("exe.path", apacheSetup.exePath); replacements.put("localhost", determineLocalhost()); @@ -351,18 +354,6 @@ public class UpgradeTestBase extends PluginContainerTest { platform = discoverPlatform(); }
- @AfterClass - @Parameters({ "apache2.install.dir", "apache2.exe.path" }) - public void shutdownApache(String apacheInstallationDirectory, String exePath) throws Exception { - - //it really doesn't matter which configuration i use here - TestSetup.ApacheSetup apacheSetup = new TestSetup(DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES) - .withApacheSetup().withServerRoot(apacheInstallationDirectory).withExePath(exePath) - .withNoDeploymentOnSetup(); - apacheSetup.init(); - apacheSetup.getExecutionUtil().invokeOperation("stop"); - } - protected ResourceType findApachePluginResourceTypeByName(String resourceTypeName) { for (ResourceType rt : resourceTypesInApachePlugin) { if (resourceTypeName.equals(rt.getName())) { diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java index 3db6181..59e5d7e 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java @@ -19,30 +19,25 @@
package org.rhq.plugins.apache.util;
-import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; -import java.io.Reader; -import java.io.StringReader; import java.net.InetAddress; import java.net.URL; import java.net.UnknownHostException; -import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collection; -import java.util.Deque; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.unitils.thirdparty.org.apache.commons.io.FileUtils;
import org.rhq.plugins.apache.util.HttpdAddressUtility.Address; +import org.rhq.test.TokenReplacingProperties; import org.rhq.test.TokenReplacingReader;
/** @@ -53,7 +48,7 @@ import org.rhq.test.TokenReplacingReader; public class ApacheDeploymentUtil {
private static final Log LOG = LogFactory.getLog(ApacheDeploymentUtil.class); - + private static final String VHOST = "vhost"; private static final String SERVER_ROOT = "server.root"; private static final String ADDITIONAL_DIRECTIVES = "additional.directives"; @@ -67,11 +62,11 @@ public class ApacheDeploymentUtil { private static final String SNMP_HOST = "snmp.host"; private static final String DOCUMENT_ROOT = "document.root"; private static final String URLS = "urls"; - + private ApacheDeploymentUtil() { - + } - + public static class DeploymentConfig { public static class VHost { public Address address1 = new Address(null, null, Address.NO_PORT_SPECIFIED_VALUE); @@ -80,7 +75,7 @@ public class ApacheDeploymentUtil { public Address address4 = null; public String serverNameDirective = null; public final List<String> additionalDirectives = new ArrayList<String>(); - + public String getServerName() { String serverName = null; if (serverNameDirective != null && serverNameDirective.startsWith("ServerName")) { @@ -89,15 +84,15 @@ public class ApacheDeploymentUtil { while (serverNameDirective.charAt(startIdx) == ' ') { ++startIdx; } - + serverName = serverNameDirective.substring(startIdx); serverName = serverName.trim(); } } - + return serverName; } - + public List<String> getAddresses() { ArrayList<String> ret = new ArrayList<String>(); if (address1 != null) { @@ -112,36 +107,37 @@ public class ApacheDeploymentUtil { if (address4 != null) { ret.add(address4.toString()); } - + return ret; } - + private void addToTokenReplacements(int ordinal, Map<String, String> tokenReplacements) { String prefix = null; - + if (ordinal == 0) { - prefix = ""; + prefix = ""; } else { - prefix = VHOST + ordinal + "."; + prefix = VHOST + ordinal + "."; } - - tokenReplacements.put(prefix + SERVERNAME_DIRECTIVE, serverNameDirective == null ? "" : serverNameDirective); - + + tokenReplacements.put(prefix + SERVERNAME_DIRECTIVE, serverNameDirective == null ? "" + : serverNameDirective); + String serverName = getServerName(); if (serverName != null) { tokenReplacements.put(prefix + SERVERNAME, serverName); } - + String dirs = ""; if (!additionalDirectives.isEmpty()) { String newline = System.getProperty("line.separator"); - for(String dir : additionalDirectives) { + for (String dir : additionalDirectives) { dirs += dir + newline; - } + } }
tokenReplacements.put(prefix + ADDITIONAL_DIRECTIVES, dirs); - + if (ordinal != 0) { String urls = address1.toString(false, false); if (address2 != null) { @@ -153,7 +149,7 @@ public class ApacheDeploymentUtil { if (address4 != null) { urls += " " + address4.toString(false, false); } - + tokenReplacements.put(prefix + URLS, urls); } else { tokenReplacements.put(LISTEN1, address1 == null ? "" : address1.toString(false, false)); @@ -163,7 +159,7 @@ public class ApacheDeploymentUtil { } } } - + public String serverRoot = null; public String documentRoot = "hdocs"; public String snmpHost = "localhost"; @@ -173,16 +169,16 @@ public class ApacheDeploymentUtil { public final VHost vhost2 = new VHost(); public final VHost vhost3 = new VHost(); public final VHost vhost4 = new VHost(); - + { mainServer.address2 = new Address(null, null, Address.NO_PORT_SPECIFIED_VALUE); mainServer.address3 = new Address(null, null, Address.NO_PORT_SPECIFIED_VALUE); mainServer.address4 = new Address(null, null, Address.NO_PORT_SPECIFIED_VALUE); } - + public Map<String, String> getTokenReplacements() { HashMap<String, String> ret = new HashMap<String, String>(); - + ret.put(SERVER_ROOT, serverRoot == null ? "" : serverRoot); ret.put(DOCUMENT_ROOT, documentRoot == null ? "" : documentRoot); ret.put(SNMP_HOST, snmpHost == null ? "" : snmpHost); @@ -191,60 +187,65 @@ public class ApacheDeploymentUtil { vhost1.addToTokenReplacements(1, ret); vhost2.addToTokenReplacements(2, ret); vhost3.addToTokenReplacements(3, ret); - vhost4.addToTokenReplacements(4, ret); - + vhost4.addToTokenReplacements(4, ret); + return ret; } } - + public static void addDefaultVariables(Map<String, String> variables, String prefix) { - String localhost = determineLocalhost(); - checkOrAddDefault(variables, "localhost", localhost); + InetAddress localhost = determineLocalhost(); + checkOrAddDefault(variables, "localhost", localhost.getHostName()); + checkOrAddDefault(variables, "localhost.ip", localhost.getHostAddress()); checkOrAddDefault(variables, "unresolvable.host", "unreachable.host.com"); checkOrAddDefault(variables, "port1", "11675"); checkOrAddDefault(variables, "port2", "11676"); checkOrAddDefault(variables, "port3", "11677"); checkOrAddDefault(variables, "port4", "11678"); - + checkOrAddDefault(variables, prefix + ".listen1", "${port1}"); checkOrAddDefault(variables, prefix + ".listen2", "${port2}"); checkOrAddDefault(variables, prefix + ".listen3", "${port3}"); checkOrAddDefault(variables, prefix + ".listen4", "${port4}"); - + checkOrAddDefault(variables, prefix + ".vhost1.servername", "${localhost}:${port1}"); checkOrAddDefault(variables, prefix + ".vhost1.urls", "${" + prefix + ".vhost1.servername}"); - checkOrAddDefault(variables, prefix + ".vhost1.servername.directive", "ServerName ${" + prefix + ".vhost1.servername}"); - + checkOrAddDefault(variables, prefix + ".vhost1.servername.directive", "ServerName ${" + prefix + + ".vhost1.servername}"); + checkOrAddDefault(variables, prefix + ".vhost2.servername", "${localhost}:${port2}"); checkOrAddDefault(variables, prefix + ".vhost2.urls", "${" + prefix + ".vhost2.servername}"); - checkOrAddDefault(variables, prefix + ".vhost2.servername.directive", "ServerName ${" + prefix + ".vhost2.servername}"); - + checkOrAddDefault(variables, prefix + ".vhost2.servername.directive", "ServerName ${" + prefix + + ".vhost2.servername}"); + checkOrAddDefault(variables, prefix + ".vhost3.servername", "${localhost}:${port3}"); checkOrAddDefault(variables, prefix + ".vhost3.urls", "${" + prefix + ".vhost3.servername}"); - checkOrAddDefault(variables, prefix + ".vhost3.servername.directive", "ServerName ${" + prefix + ".vhost3.servername}"); - + checkOrAddDefault(variables, prefix + ".vhost3.servername.directive", "ServerName ${" + prefix + + ".vhost3.servername}"); + checkOrAddDefault(variables, prefix + ".vhost4.servername", "${localhost}:${port4}"); checkOrAddDefault(variables, prefix + ".vhost4.urls", "${" + prefix + ".vhost4.servername}"); - checkOrAddDefault(variables, prefix + ".vhost4.servername.directive", "ServerName ${" + prefix + ".vhost4.servername}"); + checkOrAddDefault(variables, prefix + ".vhost4.servername.directive", "ServerName ${" + prefix + + ".vhost4.servername}"); } - + private static void checkOrAddDefault(Map<String, String> map, String key, String value) { if (!map.containsKey(key)) { map.put(key, value); } } - + public static DeploymentConfig getDeploymentConfigurationFromSystemProperties(String variablesPrefix) { DeploymentConfig ret = new DeploymentConfig(); - - Map<String, String> properties = new TokenReplacingMap(System.getProperties()); + + Map<String, String> properties = new TokenReplacingProperties(System.getProperties()); addDefaultVariables(properties, variablesPrefix); - + variablesPrefix += "."; - + ret.serverRoot = properties.get(variablesPrefix + SERVER_ROOT); ret.documentRoot = properties.get(variablesPrefix + DOCUMENT_ROOT); - ret.documentRoot = ret.documentRoot == null ? "htdocs" : ret.documentRoot; + ret.documentRoot = ret.documentRoot == null ? "htdocs" : ret.documentRoot; ret.snmpHost = properties.get(variablesPrefix + SNMP_HOST); ret.snmpHost = ret.snmpHost == null ? "localhost" : ret.snmpHost; String snmpPort = properties.get(variablesPrefix + SNMP_PORT); @@ -255,10 +256,10 @@ public class ApacheDeploymentUtil { ret.mainServer.address3 = HttpdAddressUtility.parseListen(properties.get(variablesPrefix + LISTEN3)); ret.mainServer.address4 = HttpdAddressUtility.parseListen(properties.get(variablesPrefix + LISTEN4)); ret.mainServer.serverNameDirective = properties.get(variablesPrefix + SERVERNAME_DIRECTIVE); - + String additionalDirectives = properties.get(variablesPrefix + ADDITIONAL_DIRECTIVES); fillAdditionalDirectives(additionalDirectives, ret.mainServer.additionalDirectives); - + readVHostConfigFromProperties(ret.vhost1, variablesPrefix + VHOST + 1, properties); readVHostConfigFromProperties(ret.vhost2, variablesPrefix + VHOST + 2, properties); readVHostConfigFromProperties(ret.vhost3, variablesPrefix + VHOST + 3, properties); @@ -266,68 +267,71 @@ public class ApacheDeploymentUtil {
return ret; } - - public static void deployConfiguration(File targetConfDirectory, Collection<String> configFilesOnClasspath, DeploymentConfig config) throws IOException { + + public static void deployConfiguration(File targetConfDirectory, Collection<String> configFilesOnClasspath, + DeploymentConfig config) throws IOException { List<File> targetFiles = new ArrayList<File>(); - for(String fileOnClassPath : configFilesOnClasspath) { + for (String fileOnClassPath : configFilesOnClasspath) { String fileName = new File(fileOnClassPath).getName(); - + File targetFile = new File(targetConfDirectory, fileName); - + URL fileUrl = ApacheDeploymentUtil.class.getResource(fileOnClassPath); - + FileUtils.copyURLToFile(fileUrl, targetFile); - + targetFiles.add(targetFile); } - + replaceTokensInConfigFiles(targetFiles, config); } - + private static void replaceTokensInConfigFiles(List<File> configFiles, DeploymentConfig config) { char[] buffer = new char[8192]; - + Map<String, String> replacements = config.getTokenReplacements(); - - for(File file : configFiles) { + + for (File file : configFiles) { TokenReplacingReader rdr = null; FileWriter wrt = null; - + try { - rdr = new TokenReplacingReader(new FileReader(file), replacements); - - File tmp = File.createTempFile("apache-deployment-util", null); - - wrt = new FileWriter(tmp); - - int cnt = -1; - - while ((cnt = rdr.read(buffer)) != -1) { - wrt.write(buffer, 0, cnt); - } - - wrt.close(); - - tmp.renameTo(file); + rdr = new TokenReplacingReader(new FileReader(file), replacements); + + File tmp = File.createTempFile("apache-deployment-util", null); + + wrt = new FileWriter(tmp); + + int cnt = -1; + + while ((cnt = rdr.read(buffer)) != -1) { + wrt.write(buffer, 0, cnt); + } + + wrt.close(); + + tmp.renameTo(file); } catch (IOException e) { LOG.error("Error while replacing the tokens in file '" + file + "'.", e); } } }
- private static void readVHostConfigFromProperties(DeploymentConfig.VHost vhost, String prefix, Map<String, String> properties) { + private static void readVHostConfigFromProperties(DeploymentConfig.VHost vhost, String prefix, + Map<String, String> properties) { prefix += "."; - + String addrsString = properties.get(prefix + URLS); - + if (addrsString == null) { - throw new IllegalStateException("The system property '" + prefix + "urls' doesn't exist. It is needed to define the vhost."); + throw new IllegalStateException("The system property '" + prefix + + "urls' doesn't exist. It is needed to define the vhost."); } - + String[] addrs = addrsString.split("[ \t]+"); - + //the fallthroughs below are intentional - switch(addrs.length) { + switch (addrs.length) { case 4: vhost.address4 = Address.parse(addrs[3], null); case 3: @@ -338,138 +342,34 @@ public class ApacheDeploymentUtil { vhost.address1 = Address.parse(addrs[0], null); break; default: - throw new IllegalStateException("The system property '" + prefix + "urls' specified " + addrs.length + " addresses. Only 1-4 addresses are supported."); + throw new IllegalStateException("The system property '" + prefix + "urls' specified " + addrs.length + + " addresses. Only 1-4 addresses are supported."); } - + vhost.serverNameDirective = properties.get(prefix + SERVERNAME_DIRECTIVE); - + String additionalDirectives = properties.get(prefix + ADDITIONAL_DIRECTIVES); fillAdditionalDirectives(additionalDirectives, vhost.additionalDirectives); } - + private static void fillAdditionalDirectives(String additionalDirectivesString, List<String> additionalDirectives) { if (additionalDirectivesString != null) { - for(String dir : additionalDirectivesString.split("\n")) { + for (String dir : additionalDirectivesString.split("\n")) { additionalDirectives.add(dir); } } } - - private static String determineLocalhost() { + + private static InetAddress determineLocalhost() { try { - return InetAddress.getLocalHost().getCanonicalHostName(); + return InetAddress.getLocalHost(); } catch (UnknownHostException e) { - return "127.0.0.1"; - } - } - - private static class TokenReplacingMap extends HashMap<String, String> { - private static final long serialVersionUID = 1L; - - @SuppressWarnings("rawtypes") - private Map wrapped; - private Deque<String> currentResolutionStack = new ArrayDeque<String>(); - private Map<Object, String> resolved = new HashMap<Object, String>(); - - public TokenReplacingMap(Map<?, ?> wrapped) { - this.wrapped = wrapped; - } - - @Override - public String get(Object key) { - return get((String) key); - } - - public String get(String key) { - if (resolved.containsKey(key)) { - return resolved.get(key); - } - - if (currentResolutionStack.contains(key)) { - throw new IllegalArgumentException("Property '" + key + "' indirectly references itself in its value."); - } - - Object rawValue = wrapped.get(key); - - if (rawValue == null) { - return null; - } - - currentResolutionStack.push(key); - - String ret = readAll(new TokenReplacingReader(new StringReader(rawValue.toString()), this)); - - currentResolutionStack.pop(); - - resolved.put(key, ret); - - return ret; - } - - @Override - public String put(String key, String value) { - return (String) wrapped.put(key, value); - } - - @Override - public void putAll(Map<? extends String, ? extends String> m) { - wrapped.putAll(m); - } - - @Override - public void clear() { - wrapped.clear(); - resolved.clear(); - } - - @Override - public boolean containsKey(Object key) { - return wrapped.containsKey(key); - } - - @Override - public Set<String> keySet() { - return (Set<String>) wrapped.keySet(); - } - - @Override - public boolean containsValue(Object value) { - return wrapped.containsValue(value); - } - - @Override - public Set<Map.Entry<String, String>> entrySet() { - throw new UnsupportedOperationException(); - } - - @Override - public String remove(Object key) { - resolved.remove(key); - return wrapped.remove(key).toString(); - } - - @Override - public int size() { - return wrapped.size(); - } - - @Override - public Collection<String> values() { - throw new UnsupportedOperationException(); - } - - private String readAll(Reader rdr) { - int in = -1; - StringBuilder bld = new StringBuilder(); try { - while((in = rdr.read()) != -1) { - bld.append((char) in); - } - } catch (IOException e) { - throw new IllegalStateException("Exception while reading a string.", e); + return InetAddress.getByName("127.0.0.1"); + } catch (UnknownHostException u) { + //doesn't happen + return null; } - - return bld.toString(); } }; } diff --git a/modules/plugins/apache/src/test/resources/full-configurations/1.3.x/includes/1.vhost.conf b/modules/plugins/apache/src/test/resources/full-configurations/1.3.x/includes/1.vhost.conf new file mode 100644 index 0000000..7b56cae --- /dev/null +++ b/modules/plugins/apache/src/test/resources/full-configurations/1.3.x/includes/1.vhost.conf @@ -0,0 +1,9 @@ +<VirtualHost ${vhost1.urls}> + ${vhost1.servername.directive} + ${vhost1.additional.directives} +</VirtualHost> + +<VirtualHost ${vhost2.urls}> + ${vhost2.servername.directive} + ${vhost2.additional.directives} +</VirtualHost> diff --git a/modules/plugins/apache/src/test/resources/full-configurations/1.3.x/includes/2.vhost.conf b/modules/plugins/apache/src/test/resources/full-configurations/1.3.x/includes/2.vhost.conf new file mode 100644 index 0000000..b4a7725 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/full-configurations/1.3.x/includes/2.vhost.conf @@ -0,0 +1,9 @@ +<VirtualHost ${vhost3.urls}> + ${vhost3.servername.directive} + ${vhost3.additional.directives} +</VirtualHost> + +<VirtualHost ${vhost4.urls}> + ${vhost4.servername.directive} + ${vhost4.additional.directives} +</VirtualHost> diff --git a/modules/plugins/apache/src/test/resources/full-configurations/1.3.x/includes/httpd.conf b/modules/plugins/apache/src/test/resources/full-configurations/1.3.x/includes/httpd.conf new file mode 100644 index 0000000..ebc07ac --- /dev/null +++ b/modules/plugins/apache/src/test/resources/full-configurations/1.3.x/includes/httpd.conf @@ -0,0 +1,40 @@ +ServerRoot ${server.root} + +Listen ${listen1} +Listen ${listen2} +Listen ${listen3} +Listen ${listen4} + +ServerAdmin root@localhost + +${servername.directive} + +DocumentRoot ${document.root} + +DirectoryIndex index.html index.html.var + +TypesConfig conf/mime.types + +DefaultType text/plain + +ErrorLog logs/error_log + +LogLevel debug + +LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined +LogFormat "%h %l %u %t "%r" %>s %b" common +LogFormat "%{Referer}i -> %U" referer +LogFormat "%{User-agent}i" agent + +CustomLog logs/access_log combined + +# Apache SNMP +LoadModule snmpcommon_module modules/libsnmpcommon.so +LoadModule snmpagt_module modules/libsnmpmonagt.so +SNMPConf conf +SNMPVar var +# End of apache SNMP + +${additional.directives} + +Include *.vhost.conf diff --git a/modules/plugins/apache/src/test/resources/full-configurations/1.3.x/mess/1.vhost.conf b/modules/plugins/apache/src/test/resources/full-configurations/1.3.x/mess/1.vhost.conf new file mode 100644 index 0000000..39cf84a --- /dev/null +++ b/modules/plugins/apache/src/test/resources/full-configurations/1.3.x/mess/1.vhost.conf @@ -0,0 +1,17 @@ +<IfModule not_loaded_module> + <VirtualHost ${vhost1.urls}> + ${vhost1.servername.directive} + ${vhost1.additional.directives} + </VirtualHost> +</IfModule> + +LoadModule proxy_module modules/mod_proxy.so + +<IfModule snmpcommon_module> +<IfModule mod_proxy.c> + <VirtualHost ${vhost2.urls}> + ${vhost2.servername.directive} + ${vhost2.additional.directives} + </VirtualHost> +</IfModule> +</IfModule> diff --git a/modules/plugins/apache/src/test/resources/full-configurations/1.3.x/mess/2.vhost.conf b/modules/plugins/apache/src/test/resources/full-configurations/1.3.x/mess/2.vhost.conf new file mode 100644 index 0000000..37854b6 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/full-configurations/1.3.x/mess/2.vhost.conf @@ -0,0 +1,13 @@ +<IfModule snmpcommon_module> +<IfModule mod_unknown.c> + <VirtualHost ${vhost3.urls}> + ${vhost3.servername.directive} + ${vhost3.additional.directives} + </VirtualHost> +</IfModule> +</IfModule> + +<VirtualHost ${vhost4.urls}> + ${vhost4.servername.directive} + ${vhost4.additional.directives} +</VirtualHost> diff --git a/modules/plugins/apache/src/test/resources/full-configurations/1.3.x/mess/httpd.conf b/modules/plugins/apache/src/test/resources/full-configurations/1.3.x/mess/httpd.conf new file mode 100644 index 0000000..ebc07ac --- /dev/null +++ b/modules/plugins/apache/src/test/resources/full-configurations/1.3.x/mess/httpd.conf @@ -0,0 +1,40 @@ +ServerRoot ${server.root} + +Listen ${listen1} +Listen ${listen2} +Listen ${listen3} +Listen ${listen4} + +ServerAdmin root@localhost + +${servername.directive} + +DocumentRoot ${document.root} + +DirectoryIndex index.html index.html.var + +TypesConfig conf/mime.types + +DefaultType text/plain + +ErrorLog logs/error_log + +LogLevel debug + +LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined +LogFormat "%h %l %u %t "%r" %>s %b" common +LogFormat "%{Referer}i -> %U" referer +LogFormat "%{User-agent}i" agent + +CustomLog logs/access_log combined + +# Apache SNMP +LoadModule snmpcommon_module modules/libsnmpcommon.so +LoadModule snmpagt_module modules/libsnmpmonagt.so +SNMPConf conf +SNMPVar var +# End of apache SNMP + +${additional.directives} + +Include *.vhost.conf diff --git a/modules/plugins/apache/src/test/resources/full-configurations/1.3.x/nested/httpd.conf b/modules/plugins/apache/src/test/resources/full-configurations/1.3.x/nested/httpd.conf new file mode 100644 index 0000000..6112bdc --- /dev/null +++ b/modules/plugins/apache/src/test/resources/full-configurations/1.3.x/nested/httpd.conf @@ -0,0 +1,68 @@ +ServerRoot ${server.root} + +Listen ${listen1} +Listen ${listen2} +Listen ${listen3} +Listen ${listen4} + +ServerAdmin root@localhost + +${servername.directive} + +DocumentRoot ${document.root} + +DirectoryIndex index.html index.html.var + +TypesConfig conf/mime.types + +DefaultType text/plain + +ErrorLog logs/error_log + +LogLevel debug + +LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined +LogFormat "%h %l %u %t "%r" %>s %b" common +LogFormat "%{Referer}i -> %U" referer +LogFormat "%{User-agent}i" agent + +CustomLog logs/access_log combined + +# Apache SNMP +LoadModule snmpcommon_module modules/libsnmpcommon.so +LoadModule snmpagt_module modules/libsnmpmonagt.so +SNMPConf conf +SNMPVar var +# End of apache SNMP + +${additional.directives} + +<IfModule not_loaded_module> + <VirtualHost ${vhost1.urls}> + ${vhost1.servername.directive} + ${vhost1.additional.directives} + </VirtualHost> +</IfModule> + +LoadModule proxy_module modules/mod_proxy.so + +<IfModule snmpcommon_module> +<IfModule mod_proxy.c> + <VirtualHost ${vhost2.urls}> + ${vhost2.servername.directive} + ${vhost2.additional.directives} + </VirtualHost> +</IfModule> + +<IfModule mod_unknown.c> + <VirtualHost ${vhost3.urls}> + ${vhost3.servername.directive} + ${vhost3.additional.directives} + </VirtualHost> +</IfModule> +</IfModule> + +<VirtualHost ${vhost4.urls}> + ${vhost4.servername.directive} + ${vhost4.additional.directives} +</VirtualHost> diff --git a/modules/plugins/apache/src/test/resources/full-configurations/1.3.x/simple/httpd.conf b/modules/plugins/apache/src/test/resources/full-configurations/1.3.x/simple/httpd.conf new file mode 100644 index 0000000..f14b48e --- /dev/null +++ b/modules/plugins/apache/src/test/resources/full-configurations/1.3.x/simple/httpd.conf @@ -0,0 +1,47 @@ +ServerRoot ${server.root} + +Listen ${listen1} +Listen ${listen2} +Listen ${listen3} +Listen ${listen4} + +ServerAdmin root@localhost + +${servername.directive} + +DocumentRoot ${document.root} + +DefaultType text/plain + +ErrorLog logs/error_log + +LogLevel debug + +# Apache SNMP +#LoadModule snmp_agt_module libexec/libsnmp_agt.so +#AddModule covalent-snmp-v13.c +#SNMPConf conf +#SNMPVar var +# End of apache SNMP + +${additional.directives} + +<VirtualHost ${vhost1.urls}> + ${vhost1.servername.directive} + ${vhost1.additional.directives} +</VirtualHost> + +<VirtualHost ${vhost2.urls}> + ${vhost2.servername.directive} + ${vhost2.additional.directives} +</VirtualHost> + +<VirtualHost ${vhost3.urls}> + ${vhost3.servername.directive} + ${vhost3.additional.directives} +</VirtualHost> + +<VirtualHost ${vhost4.urls}> + ${vhost4.servername.directive} + ${vhost4.additional.directives} +</VirtualHost> diff --git a/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/includes/1.vhost.conf b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/includes/1.vhost.conf new file mode 100644 index 0000000..7b56cae --- /dev/null +++ b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/includes/1.vhost.conf @@ -0,0 +1,9 @@ +<VirtualHost ${vhost1.urls}> + ${vhost1.servername.directive} + ${vhost1.additional.directives} +</VirtualHost> + +<VirtualHost ${vhost2.urls}> + ${vhost2.servername.directive} + ${vhost2.additional.directives} +</VirtualHost> diff --git a/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/includes/2.vhost.conf b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/includes/2.vhost.conf new file mode 100644 index 0000000..b4a7725 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/includes/2.vhost.conf @@ -0,0 +1,9 @@ +<VirtualHost ${vhost3.urls}> + ${vhost3.servername.directive} + ${vhost3.additional.directives} +</VirtualHost> + +<VirtualHost ${vhost4.urls}> + ${vhost4.servername.directive} + ${vhost4.additional.directives} +</VirtualHost> diff --git a/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/includes/httpd.conf b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/includes/httpd.conf new file mode 100644 index 0000000..ebc07ac --- /dev/null +++ b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/includes/httpd.conf @@ -0,0 +1,40 @@ +ServerRoot ${server.root} + +Listen ${listen1} +Listen ${listen2} +Listen ${listen3} +Listen ${listen4} + +ServerAdmin root@localhost + +${servername.directive} + +DocumentRoot ${document.root} + +DirectoryIndex index.html index.html.var + +TypesConfig conf/mime.types + +DefaultType text/plain + +ErrorLog logs/error_log + +LogLevel debug + +LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined +LogFormat "%h %l %u %t "%r" %>s %b" common +LogFormat "%{Referer}i -> %U" referer +LogFormat "%{User-agent}i" agent + +CustomLog logs/access_log combined + +# Apache SNMP +LoadModule snmpcommon_module modules/libsnmpcommon.so +LoadModule snmpagt_module modules/libsnmpmonagt.so +SNMPConf conf +SNMPVar var +# End of apache SNMP + +${additional.directives} + +Include *.vhost.conf diff --git a/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/mess/1.vhost.conf b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/mess/1.vhost.conf new file mode 100644 index 0000000..39cf84a --- /dev/null +++ b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/mess/1.vhost.conf @@ -0,0 +1,17 @@ +<IfModule not_loaded_module> + <VirtualHost ${vhost1.urls}> + ${vhost1.servername.directive} + ${vhost1.additional.directives} + </VirtualHost> +</IfModule> + +LoadModule proxy_module modules/mod_proxy.so + +<IfModule snmpcommon_module> +<IfModule mod_proxy.c> + <VirtualHost ${vhost2.urls}> + ${vhost2.servername.directive} + ${vhost2.additional.directives} + </VirtualHost> +</IfModule> +</IfModule> diff --git a/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/mess/2.vhost.conf b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/mess/2.vhost.conf new file mode 100644 index 0000000..37854b6 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/mess/2.vhost.conf @@ -0,0 +1,13 @@ +<IfModule snmpcommon_module> +<IfModule mod_unknown.c> + <VirtualHost ${vhost3.urls}> + ${vhost3.servername.directive} + ${vhost3.additional.directives} + </VirtualHost> +</IfModule> +</IfModule> + +<VirtualHost ${vhost4.urls}> + ${vhost4.servername.directive} + ${vhost4.additional.directives} +</VirtualHost> diff --git a/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/mess/httpd.conf b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/mess/httpd.conf new file mode 100644 index 0000000..ebc07ac --- /dev/null +++ b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/mess/httpd.conf @@ -0,0 +1,40 @@ +ServerRoot ${server.root} + +Listen ${listen1} +Listen ${listen2} +Listen ${listen3} +Listen ${listen4} + +ServerAdmin root@localhost + +${servername.directive} + +DocumentRoot ${document.root} + +DirectoryIndex index.html index.html.var + +TypesConfig conf/mime.types + +DefaultType text/plain + +ErrorLog logs/error_log + +LogLevel debug + +LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined +LogFormat "%h %l %u %t "%r" %>s %b" common +LogFormat "%{Referer}i -> %U" referer +LogFormat "%{User-agent}i" agent + +CustomLog logs/access_log combined + +# Apache SNMP +LoadModule snmpcommon_module modules/libsnmpcommon.so +LoadModule snmpagt_module modules/libsnmpmonagt.so +SNMPConf conf +SNMPVar var +# End of apache SNMP + +${additional.directives} + +Include *.vhost.conf diff --git a/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/nested/httpd.conf b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/nested/httpd.conf new file mode 100644 index 0000000..6112bdc --- /dev/null +++ b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/nested/httpd.conf @@ -0,0 +1,68 @@ +ServerRoot ${server.root} + +Listen ${listen1} +Listen ${listen2} +Listen ${listen3} +Listen ${listen4} + +ServerAdmin root@localhost + +${servername.directive} + +DocumentRoot ${document.root} + +DirectoryIndex index.html index.html.var + +TypesConfig conf/mime.types + +DefaultType text/plain + +ErrorLog logs/error_log + +LogLevel debug + +LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined +LogFormat "%h %l %u %t "%r" %>s %b" common +LogFormat "%{Referer}i -> %U" referer +LogFormat "%{User-agent}i" agent + +CustomLog logs/access_log combined + +# Apache SNMP +LoadModule snmpcommon_module modules/libsnmpcommon.so +LoadModule snmpagt_module modules/libsnmpmonagt.so +SNMPConf conf +SNMPVar var +# End of apache SNMP + +${additional.directives} + +<IfModule not_loaded_module> + <VirtualHost ${vhost1.urls}> + ${vhost1.servername.directive} + ${vhost1.additional.directives} + </VirtualHost> +</IfModule> + +LoadModule proxy_module modules/mod_proxy.so + +<IfModule snmpcommon_module> +<IfModule mod_proxy.c> + <VirtualHost ${vhost2.urls}> + ${vhost2.servername.directive} + ${vhost2.additional.directives} + </VirtualHost> +</IfModule> + +<IfModule mod_unknown.c> + <VirtualHost ${vhost3.urls}> + ${vhost3.servername.directive} + ${vhost3.additional.directives} + </VirtualHost> +</IfModule> +</IfModule> + +<VirtualHost ${vhost4.urls}> + ${vhost4.servername.directive} + ${vhost4.additional.directives} +</VirtualHost> diff --git a/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/simple/httpd.conf b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/simple/httpd.conf new file mode 100644 index 0000000..87142b4 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/full-configurations/2.2.x/simple/httpd.conf @@ -0,0 +1,58 @@ +ServerRoot ${server.root} + +Listen ${listen1} +Listen ${listen2} +Listen ${listen3} +Listen ${listen4} + +ServerAdmin root@localhost + +${servername.directive} + +DocumentRoot ${document.root} + +DirectoryIndex index.html index.html.var + +TypesConfig conf/mime.types + +DefaultType text/plain + +ErrorLog logs/error_log + +LogLevel debug + +LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined +LogFormat "%h %l %u %t "%r" %>s %b" common +LogFormat "%{Referer}i -> %U" referer +LogFormat "%{User-agent}i" agent + +CustomLog logs/access_log combined + +# Apache SNMP +LoadModule snmpcommon_module modules/libsnmpcommon.so +LoadModule snmpagt_module modules/libsnmpmonagt.so +SNMPConf conf +SNMPVar var +# End of apache SNMP + +${additional.directives} + +<VirtualHost ${vhost1.urls}> + ${vhost1.servername.directive} + ${vhost1.additional.directives} +</VirtualHost> + +<VirtualHost ${vhost2.urls}> + ${vhost2.servername.directive} + ${vhost2.additional.directives} +</VirtualHost> + +<VirtualHost ${vhost3.urls}> + ${vhost3.servername.directive} + ${vhost3.additional.directives} +</VirtualHost> + +<VirtualHost ${vhost4.urls}> + ${vhost4.servername.directive} + ${vhost4.additional.directives} +</VirtualHost> diff --git a/modules/plugins/apache/src/test/resources/full-configurations/includes/1.vhost.conf b/modules/plugins/apache/src/test/resources/full-configurations/includes/1.vhost.conf deleted file mode 100644 index 7b56cae..0000000 --- a/modules/plugins/apache/src/test/resources/full-configurations/includes/1.vhost.conf +++ /dev/null @@ -1,9 +0,0 @@ -<VirtualHost ${vhost1.urls}> - ${vhost1.servername.directive} - ${vhost1.additional.directives} -</VirtualHost> - -<VirtualHost ${vhost2.urls}> - ${vhost2.servername.directive} - ${vhost2.additional.directives} -</VirtualHost> diff --git a/modules/plugins/apache/src/test/resources/full-configurations/includes/2.vhost.conf b/modules/plugins/apache/src/test/resources/full-configurations/includes/2.vhost.conf deleted file mode 100644 index b4a7725..0000000 --- a/modules/plugins/apache/src/test/resources/full-configurations/includes/2.vhost.conf +++ /dev/null @@ -1,9 +0,0 @@ -<VirtualHost ${vhost3.urls}> - ${vhost3.servername.directive} - ${vhost3.additional.directives} -</VirtualHost> - -<VirtualHost ${vhost4.urls}> - ${vhost4.servername.directive} - ${vhost4.additional.directives} -</VirtualHost> diff --git a/modules/plugins/apache/src/test/resources/full-configurations/includes/httpd.conf b/modules/plugins/apache/src/test/resources/full-configurations/includes/httpd.conf deleted file mode 100644 index ebc07ac..0000000 --- a/modules/plugins/apache/src/test/resources/full-configurations/includes/httpd.conf +++ /dev/null @@ -1,40 +0,0 @@ -ServerRoot ${server.root} - -Listen ${listen1} -Listen ${listen2} -Listen ${listen3} -Listen ${listen4} - -ServerAdmin root@localhost - -${servername.directive} - -DocumentRoot ${document.root} - -DirectoryIndex index.html index.html.var - -TypesConfig conf/mime.types - -DefaultType text/plain - -ErrorLog logs/error_log - -LogLevel debug - -LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined -LogFormat "%h %l %u %t "%r" %>s %b" common -LogFormat "%{Referer}i -> %U" referer -LogFormat "%{User-agent}i" agent - -CustomLog logs/access_log combined - -# Apache SNMP -LoadModule snmpcommon_module modules/libsnmpcommon.so -LoadModule snmpagt_module modules/libsnmpmonagt.so -SNMPConf conf -SNMPVar var -# End of apache SNMP - -${additional.directives} - -Include *.vhost.conf diff --git a/modules/plugins/apache/src/test/resources/full-configurations/mess/1.vhost.conf b/modules/plugins/apache/src/test/resources/full-configurations/mess/1.vhost.conf deleted file mode 100644 index 39cf84a..0000000 --- a/modules/plugins/apache/src/test/resources/full-configurations/mess/1.vhost.conf +++ /dev/null @@ -1,17 +0,0 @@ -<IfModule not_loaded_module> - <VirtualHost ${vhost1.urls}> - ${vhost1.servername.directive} - ${vhost1.additional.directives} - </VirtualHost> -</IfModule> - -LoadModule proxy_module modules/mod_proxy.so - -<IfModule snmpcommon_module> -<IfModule mod_proxy.c> - <VirtualHost ${vhost2.urls}> - ${vhost2.servername.directive} - ${vhost2.additional.directives} - </VirtualHost> -</IfModule> -</IfModule> diff --git a/modules/plugins/apache/src/test/resources/full-configurations/mess/2.vhost.conf b/modules/plugins/apache/src/test/resources/full-configurations/mess/2.vhost.conf deleted file mode 100644 index 37854b6..0000000 --- a/modules/plugins/apache/src/test/resources/full-configurations/mess/2.vhost.conf +++ /dev/null @@ -1,13 +0,0 @@ -<IfModule snmpcommon_module> -<IfModule mod_unknown.c> - <VirtualHost ${vhost3.urls}> - ${vhost3.servername.directive} - ${vhost3.additional.directives} - </VirtualHost> -</IfModule> -</IfModule> - -<VirtualHost ${vhost4.urls}> - ${vhost4.servername.directive} - ${vhost4.additional.directives} -</VirtualHost> diff --git a/modules/plugins/apache/src/test/resources/full-configurations/mess/httpd.conf b/modules/plugins/apache/src/test/resources/full-configurations/mess/httpd.conf deleted file mode 100644 index ebc07ac..0000000 --- a/modules/plugins/apache/src/test/resources/full-configurations/mess/httpd.conf +++ /dev/null @@ -1,40 +0,0 @@ -ServerRoot ${server.root} - -Listen ${listen1} -Listen ${listen2} -Listen ${listen3} -Listen ${listen4} - -ServerAdmin root@localhost - -${servername.directive} - -DocumentRoot ${document.root} - -DirectoryIndex index.html index.html.var - -TypesConfig conf/mime.types - -DefaultType text/plain - -ErrorLog logs/error_log - -LogLevel debug - -LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined -LogFormat "%h %l %u %t "%r" %>s %b" common -LogFormat "%{Referer}i -> %U" referer -LogFormat "%{User-agent}i" agent - -CustomLog logs/access_log combined - -# Apache SNMP -LoadModule snmpcommon_module modules/libsnmpcommon.so -LoadModule snmpagt_module modules/libsnmpmonagt.so -SNMPConf conf -SNMPVar var -# End of apache SNMP - -${additional.directives} - -Include *.vhost.conf diff --git a/modules/plugins/apache/src/test/resources/full-configurations/nested/httpd.conf b/modules/plugins/apache/src/test/resources/full-configurations/nested/httpd.conf deleted file mode 100644 index 6112bdc..0000000 --- a/modules/plugins/apache/src/test/resources/full-configurations/nested/httpd.conf +++ /dev/null @@ -1,68 +0,0 @@ -ServerRoot ${server.root} - -Listen ${listen1} -Listen ${listen2} -Listen ${listen3} -Listen ${listen4} - -ServerAdmin root@localhost - -${servername.directive} - -DocumentRoot ${document.root} - -DirectoryIndex index.html index.html.var - -TypesConfig conf/mime.types - -DefaultType text/plain - -ErrorLog logs/error_log - -LogLevel debug - -LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined -LogFormat "%h %l %u %t "%r" %>s %b" common -LogFormat "%{Referer}i -> %U" referer -LogFormat "%{User-agent}i" agent - -CustomLog logs/access_log combined - -# Apache SNMP -LoadModule snmpcommon_module modules/libsnmpcommon.so -LoadModule snmpagt_module modules/libsnmpmonagt.so -SNMPConf conf -SNMPVar var -# End of apache SNMP - -${additional.directives} - -<IfModule not_loaded_module> - <VirtualHost ${vhost1.urls}> - ${vhost1.servername.directive} - ${vhost1.additional.directives} - </VirtualHost> -</IfModule> - -LoadModule proxy_module modules/mod_proxy.so - -<IfModule snmpcommon_module> -<IfModule mod_proxy.c> - <VirtualHost ${vhost2.urls}> - ${vhost2.servername.directive} - ${vhost2.additional.directives} - </VirtualHost> -</IfModule> - -<IfModule mod_unknown.c> - <VirtualHost ${vhost3.urls}> - ${vhost3.servername.directive} - ${vhost3.additional.directives} - </VirtualHost> -</IfModule> -</IfModule> - -<VirtualHost ${vhost4.urls}> - ${vhost4.servername.directive} - ${vhost4.additional.directives} -</VirtualHost> diff --git a/modules/plugins/apache/src/test/resources/full-configurations/simple/httpd.conf b/modules/plugins/apache/src/test/resources/full-configurations/simple/httpd.conf deleted file mode 100644 index 87142b4..0000000 --- a/modules/plugins/apache/src/test/resources/full-configurations/simple/httpd.conf +++ /dev/null @@ -1,58 +0,0 @@ -ServerRoot ${server.root} - -Listen ${listen1} -Listen ${listen2} -Listen ${listen3} -Listen ${listen4} - -ServerAdmin root@localhost - -${servername.directive} - -DocumentRoot ${document.root} - -DirectoryIndex index.html index.html.var - -TypesConfig conf/mime.types - -DefaultType text/plain - -ErrorLog logs/error_log - -LogLevel debug - -LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined -LogFormat "%h %l %u %t "%r" %>s %b" common -LogFormat "%{Referer}i -> %U" referer -LogFormat "%{User-agent}i" agent - -CustomLog logs/access_log combined - -# Apache SNMP -LoadModule snmpcommon_module modules/libsnmpcommon.so -LoadModule snmpagt_module modules/libsnmpmonagt.so -SNMPConf conf -SNMPVar var -# End of apache SNMP - -${additional.directives} - -<VirtualHost ${vhost1.urls}> - ${vhost1.servername.directive} - ${vhost1.additional.directives} -</VirtualHost> - -<VirtualHost ${vhost2.urls}> - ${vhost2.servername.directive} - ${vhost2.additional.directives} -</VirtualHost> - -<VirtualHost ${vhost3.urls}> - ${vhost3.servername.directive} - ${vhost3.additional.directives} -</VirtualHost> - -<VirtualHost ${vhost4.urls}> - ${vhost4.servername.directive} - ${vhost4.additional.directives} -</VirtualHost> diff --git a/modules/test-utils/src/main/java/org/rhq/test/TokenReplacingProperties.java b/modules/test-utils/src/main/java/org/rhq/test/TokenReplacingProperties.java new file mode 100644 index 0000000..9e359cb --- /dev/null +++ b/modules/test-utils/src/main/java/org/rhq/test/TokenReplacingProperties.java @@ -0,0 +1,306 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.test; + +import java.io.IOException; +import java.io.Reader; +import java.io.StringReader; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Deque; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + + +/** + * This map is basically an extension of the {@link Properties} class that can resolve the references + * to values of other keys inside the values. + * <p> + * I.e., if the map is initialized with the following mappings: + * <p> + * <code> + * name => world <br /> + * hello => Hello ${name}! + * </code> + * <p> + * then the call to: + * <p> + * <code> + * get("hello") + * </code> + * <p> + * will return: + * <code> + * "Hello world!" + * </code> + * <p> + * To access and modify the underlying unprocessed values, one can use the "raw" counterparts of the standard + * map methods (e.g. instead of {@link #get(Object)}, use {@link #getRaw(Object)}, etc.). + * + * @author Lukas Krejci + */ +public class TokenReplacingProperties extends HashMap<String, String> { + private static final long serialVersionUID = 1L; + + private Map<String, String> wrapped; + private Deque<String> currentResolutionStack = new ArrayDeque<String>(); + private Map<Object, String> resolved = new HashMap<Object, String>(); + + private class Entry implements Map.Entry<String, String> { + private Map.Entry<String, String> wrapped; + private boolean process; + + public Entry(Map.Entry<String, String> wrapped, boolean process) { + this.wrapped = wrapped; + this.process = process; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + + if (!(obj instanceof Entry)) { + return false; + } + + Entry other = (Entry) obj; + + String key = wrapped.getKey(); + String otherKey = other.getKey(); + String value = getValue(); + String otherValue = other.getValue(); + + return (key == null ? otherKey == null : key.equals(otherKey)) && + (value == null ? otherValue == null : value.equals(otherValue)); + } + + public String getKey() { + return wrapped.getKey(); + } + + public String getValue() { + if (process) { + return get(wrapped.getKey()); + } else { + return wrapped.getValue(); + } + } + + @Override + public int hashCode() { + String key = wrapped.getKey(); + String value = getValue(); + return (key == null ? 0 : key.hashCode()) ^ + (value == null ? 0 : value.hashCode()); + } + + public String setValue(String value) { + resolved.remove(wrapped.getKey()); + return wrapped.setValue(value); + } + + @Override + public String toString() { + return wrapped.toString(); + } + } + + public TokenReplacingProperties(Map<String, String> wrapped) { + this.wrapped = wrapped; + } + + @SuppressWarnings("unchecked") + public TokenReplacingProperties(Properties properties) { + @SuppressWarnings("rawtypes") + Map map = (Map<Object, Object>) properties; + + this.wrapped = (Map<String, String>) map; + } + + @Override + public String get(Object key) { + if (resolved.containsKey(key)) { + return resolved.get(key); + } + + if (currentResolutionStack.contains(key)) { + throw new IllegalArgumentException("Property '" + key + "' indirectly references itself in its value."); + } + + String rawValue = getRaw(key); + + if (rawValue == null) { + return null; + } + + currentResolutionStack.push(key.toString()); + + String ret = readAll(new TokenReplacingReader(new StringReader(rawValue.toString()), this)); + + currentResolutionStack.pop(); + + resolved.put(key, ret); + + return ret; + } + + public String getRaw(Object key) { + return wrapped.get(key); + } + + @Override + public String put(String key, String value) { + resolved.remove(key); + return wrapped.put(key, value); + } + + @Override + public void putAll(Map<? extends String, ? extends String> m) { + for(String key : m.keySet()) { + resolved.remove(key); + } + wrapped.putAll(m); + } + + @Override + public void clear() { + wrapped.clear(); + resolved.clear(); + } + + @Override + public boolean containsKey(Object key) { + return wrapped.containsKey(key); + } + + @Override + public Set<String> keySet() { + return wrapped.keySet(); + } + + @Override + public boolean containsValue(Object value) { + for(String key : keySet()) { + String thisVal = get(key); + if (thisVal == null) { + if (value == null) { + return true; + } + } else { + if (thisVal.equals(value)) { + return true; + } + } + } + + return false; + } + + /** + * Checks whether this map contains the unprocessed value. + * + * @param value + * @return + */ + public boolean containsRawValue(Object value) { + return wrapped.containsValue(value); + } + + /** + * The returned set <b>IS NOT</b> backed by this map + * (unlike in the default map implementations). + * <p> + * The {@link java.util.Map.Entry#setValue(Object)} method + * does modify this map though. + */ + @Override + public Set<Map.Entry<String, String>> entrySet() { + Set<Map.Entry<String, String>> ret = new HashSet<Map.Entry<String, String>>(); + for(Map.Entry<String, String> entry : wrapped.entrySet()) { + ret.add(new Entry(entry, true)); + } + + return ret; + } + + public Set<Map.Entry<String, String>> getRawEntrySet() { + Set<Map.Entry<String, String>> ret = new HashSet<Map.Entry<String, String>>(); + for(Map.Entry<String, String> entry : wrapped.entrySet()) { + ret.add(new Entry(entry, false)); + } + + return ret; + } + + @Override + public String remove(Object key) { + resolved.remove(key); + return wrapped.remove(key).toString(); + } + + @Override + public int size() { + return wrapped.size(); + } + + /** + * Unlike in the default implementation the collection returned + * from this method <b>IS NOT</b> backed by this map. + */ + @Override + public Collection<String> values() { + List<String> ret = new ArrayList<String>(); + for(String key : keySet()) { + ret.add(get(key)); + } + + return ret; + } + + public Collection<String> getRawValues() { + List<String> ret = new ArrayList<String>(); + for(String key : keySet()) { + ret.add(wrapped.get(key)); + } + + return ret; + } + + private String readAll(Reader rdr) { + int in = -1; + StringBuilder bld = new StringBuilder(); + try { + while ((in = rdr.read()) != -1) { + bld.append((char) in); + } + } catch (IOException e) { + throw new IllegalStateException("Exception while reading a string.", e); + } + + return bld.toString(); + } +} \ No newline at end of file
commit 31a67b57f4c3d8a21c3b3088967d6b84095399db Author: Lukas Krejci lkrejci@redhat.com Date: Mon Jun 20 18:30:51 2011 +0200
support for system properties defined by referencing other system properties and reduce the number of needed configuration properties in the pom.xml
diff --git a/modules/plugins/apache/pom.xml b/modules/plugins/apache/pom.xml index a7a6bf5..ebfc749 100644 --- a/modules/plugins/apache/pom.xml +++ b/modules/plugins/apache/pom.xml @@ -246,28 +246,38 @@ <apache1.install.dir>PASS THIS IN FROM THE COMMAND LINE</apache1.install.dir> <apache1.exe.path>bin/httpd</apache1.exe.path>
+ <port1><!-- defaults to 11675--></port1> + <port2><!-- defaults to 11676--></port2> + <port3><!-- defaults to 11677--></port3> + <port4><!-- defaults to 11678--></port4> + <localhost><!-- defaults to the actual localhost hostname --></localhost> + <unresolvable.host><!-- defaults to 'unreachable.host.com' --></unresolvable.host> + <!-- configuration of individual upgrade tests --> + <!-- + <*.document.root>defaults to 'htdocs'</*.document.root> + <*.listen1>defaults to ${port1}</*.listen1> + <*.listen2>defaults to '${port2}'</*.listen2> + <*.listen3>defaults to '${port3}'</*.listen3> + <*.listen4>defaults to '${port4}'</*.listen4> + <*.servername.directive>defaults to ''</*.servername.directive> + <*.additional.directives>defaults to ''</*.additional.directives> + <*.vhost1.urls>defaults to '${localhost}:${port1}'</*.vhost1.urls> + <*.vhost1.servername.directive>defaults to 'ServerName ${localhost}:${port1}'</*.vhost1.servername.directive> + <*.vhost1.additional.directives>defaults to ''</*.vhost1.additional.directives> + <*.vhost2.urls>defaults to '${localhost}:${port2}'</*.vhost2.urls> + <*.vhost2.servername.directive>defaults to 'ServerName ${localhost}:${port2}'</*.vhost2.servername.directive> + <*.vhost2.additional.directives>defaults to ''</*.vhost2.additional.directives> + <*.vhost3.urls>defaults to '${localhost}:${port3}'</*.vhost3.urls> + <*.vhost3.servername.directive>defaults to 'ServerName ${localhost}:${port3}'</*.vhost3.servername.directive> + <*.vhost3.additional.directives>defaults to ''</*.vhost3.additional.directives> + <*.vhost4.urls>defaults to '${localhost}:${port4}'</*.vhost4.urls> + <*.vhost4.servername.directive>defaults to 'ServerName ${localhost}:${port4}'</*.vhost4.servername.directive> + <*.vhost4.additional.directives>defaults to ''</*.vhost4.additional.directives> + --> + <simpleWithResolvableServerNames.server.root>${apache2.install.dir}</simpleWithResolvableServerNames.server.root> - <!-- this is defaulted to "htdocs" --> - <simpleWithResolvableServerNames.document.root></simpleWithResolvableServerNames.document.root> - <simpleWithResolvableServerNames.listen1>11675</simpleWithResolvableServerNames.listen1> - <simpleWithResolvableServerNames.listen2>11676</simpleWithResolvableServerNames.listen2> - <simpleWithResolvableServerNames.listen3>11677</simpleWithResolvableServerNames.listen3> - <simpleWithResolvableServerNames.listen4>11678</simpleWithResolvableServerNames.listen4> - <simpleWithResolvableServerNames.servername.directive></simpleWithResolvableServerNames.servername.directive> - <simpleWithResolvableServerNames.additional.directives></simpleWithResolvableServerNames.additional.directives> - <simpleWithResolvableServerNames.vhost1.urls>127.0.0.1:11675</simpleWithResolvableServerNames.vhost1.urls> - <simpleWithResolvableServerNames.vhost1.servername.directive>ServerName 127.0.0.1:11675</simpleWithResolvableServerNames.vhost1.servername.directive> - <simpleWithResolvableServerNames.vhost1.additional.directives></simpleWithResolvableServerNames.vhost1.additional.directives> - <simpleWithResolvableServerNames.vhost2.urls>127.0.0.1:11676</simpleWithResolvableServerNames.vhost2.urls> - <simpleWithResolvableServerNames.vhost2.servername.directive>ServerName 127.0.0.1:11676</simpleWithResolvableServerNames.vhost2.servername.directive> - <simpleWithResolvableServerNames.vhost2.additional.directives></simpleWithResolvableServerNames.vhost2.additional.directives> - <simpleWithResolvableServerNames.vhost3.urls>127.0.0.1:11677</simpleWithResolvableServerNames.vhost3.urls> - <simpleWithResolvableServerNames.vhost3.servername.directive>ServerName 127.0.0.1:11677</simpleWithResolvableServerNames.vhost3.servername.directive> - <simpleWithResolvableServerNames.vhost3.additional.directives></simpleWithResolvableServerNames.vhost3.additional.directives> - <simpleWithResolvableServerNames.vhost4.urls>127.0.0.1:11678</simpleWithResolvableServerNames.vhost4.urls> - <simpleWithResolvableServerNames.vhost4.servername.directive>ServerName 127.0.0.1:11678</simpleWithResolvableServerNames.vhost4.servername.directive> - <simpleWithResolvableServerNames.vhost4.additional.directives></simpleWithResolvableServerNames.vhost4.additional.directives> + </systemPropertyVariables> </configuration> </execution> diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java index 524370e..3db6181 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java @@ -19,16 +19,24 @@
package org.rhq.plugins.apache.util;
+import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; +import java.io.Reader; +import java.io.StringReader; +import java.net.InetAddress; import java.net.URL; +import java.net.UnknownHostException; +import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collection; +import java.util.Deque; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -75,7 +83,7 @@ public class ApacheDeploymentUtil {
public String getServerName() { String serverName = null; - if (serverNameDirective != null) { + if (serverNameDirective != null && serverNameDirective.startsWith("ServerName")) { int startIdx = serverNameDirective.indexOf(' '); if (startIdx >= 0) { while (serverNameDirective.charAt(startIdx) == ' ') { @@ -189,28 +197,72 @@ public class ApacheDeploymentUtil { } }
+ public static void addDefaultVariables(Map<String, String> variables, String prefix) { + String localhost = determineLocalhost(); + checkOrAddDefault(variables, "localhost", localhost); + checkOrAddDefault(variables, "unresolvable.host", "unreachable.host.com"); + checkOrAddDefault(variables, "port1", "11675"); + checkOrAddDefault(variables, "port2", "11676"); + checkOrAddDefault(variables, "port3", "11677"); + checkOrAddDefault(variables, "port4", "11678"); + + checkOrAddDefault(variables, prefix + ".listen1", "${port1}"); + checkOrAddDefault(variables, prefix + ".listen2", "${port2}"); + checkOrAddDefault(variables, prefix + ".listen3", "${port3}"); + checkOrAddDefault(variables, prefix + ".listen4", "${port4}"); + + checkOrAddDefault(variables, prefix + ".vhost1.servername", "${localhost}:${port1}"); + checkOrAddDefault(variables, prefix + ".vhost1.urls", "${" + prefix + ".vhost1.servername}"); + checkOrAddDefault(variables, prefix + ".vhost1.servername.directive", "ServerName ${" + prefix + ".vhost1.servername}"); + + checkOrAddDefault(variables, prefix + ".vhost2.servername", "${localhost}:${port2}"); + checkOrAddDefault(variables, prefix + ".vhost2.urls", "${" + prefix + ".vhost2.servername}"); + checkOrAddDefault(variables, prefix + ".vhost2.servername.directive", "ServerName ${" + prefix + ".vhost2.servername}"); + + checkOrAddDefault(variables, prefix + ".vhost3.servername", "${localhost}:${port3}"); + checkOrAddDefault(variables, prefix + ".vhost3.urls", "${" + prefix + ".vhost3.servername}"); + checkOrAddDefault(variables, prefix + ".vhost3.servername.directive", "ServerName ${" + prefix + ".vhost3.servername}"); + + checkOrAddDefault(variables, prefix + ".vhost4.servername", "${localhost}:${port4}"); + checkOrAddDefault(variables, prefix + ".vhost4.urls", "${" + prefix + ".vhost4.servername}"); + checkOrAddDefault(variables, prefix + ".vhost4.servername.directive", "ServerName ${" + prefix + ".vhost4.servername}"); + } + + private static void checkOrAddDefault(Map<String, String> map, String key, String value) { + if (!map.containsKey(key)) { + map.put(key, value); + } + } + public static DeploymentConfig getDeploymentConfigurationFromSystemProperties(String variablesPrefix) { DeploymentConfig ret = new DeploymentConfig();
+ Map<String, String> properties = new TokenReplacingMap(System.getProperties()); + addDefaultVariables(properties, variablesPrefix); + variablesPrefix += ".";
- ret.serverRoot = System.getProperty(variablesPrefix + SERVER_ROOT); - ret.documentRoot = System.getProperty(variablesPrefix + DOCUMENT_ROOT, "htdocs"); - ret.snmpHost = System.getProperty(variablesPrefix + SNMP_HOST, "localhost"); - ret.snmpPort = Integer.parseInt(System.getProperty(variablesPrefix + SNMP_PORT, "1610")); - ret.mainServer.address1 = HttpdAddressUtility.parseListen(System.getProperty(variablesPrefix + LISTEN1)); - ret.mainServer.address2 = HttpdAddressUtility.parseListen(System.getProperty(variablesPrefix + LISTEN2)); - ret.mainServer.address3 = HttpdAddressUtility.parseListen(System.getProperty(variablesPrefix + LISTEN3)); - ret.mainServer.address4 = HttpdAddressUtility.parseListen(System.getProperty(variablesPrefix + LISTEN4)); - ret.mainServer.serverNameDirective = System.getProperty(variablesPrefix + SERVERNAME_DIRECTIVE); - - String additionalDirectives = System.getProperty(variablesPrefix + ADDITIONAL_DIRECTIVES); + ret.serverRoot = properties.get(variablesPrefix + SERVER_ROOT); + ret.documentRoot = properties.get(variablesPrefix + DOCUMENT_ROOT); + ret.documentRoot = ret.documentRoot == null ? "htdocs" : ret.documentRoot; + ret.snmpHost = properties.get(variablesPrefix + SNMP_HOST); + ret.snmpHost = ret.snmpHost == null ? "localhost" : ret.snmpHost; + String snmpPort = properties.get(variablesPrefix + SNMP_PORT); + snmpPort = snmpPort == null ? "1610" : snmpPort; + ret.snmpPort = Integer.parseInt(snmpPort); + ret.mainServer.address1 = HttpdAddressUtility.parseListen(properties.get(variablesPrefix + LISTEN1)); + ret.mainServer.address2 = HttpdAddressUtility.parseListen(properties.get(variablesPrefix + LISTEN2)); + ret.mainServer.address3 = HttpdAddressUtility.parseListen(properties.get(variablesPrefix + LISTEN3)); + ret.mainServer.address4 = HttpdAddressUtility.parseListen(properties.get(variablesPrefix + LISTEN4)); + ret.mainServer.serverNameDirective = properties.get(variablesPrefix + SERVERNAME_DIRECTIVE); + + String additionalDirectives = properties.get(variablesPrefix + ADDITIONAL_DIRECTIVES); fillAdditionalDirectives(additionalDirectives, ret.mainServer.additionalDirectives);
- readVHostConfigFromSystemProperties(ret.vhost1, variablesPrefix + VHOST + 1); - readVHostConfigFromSystemProperties(ret.vhost2, variablesPrefix + VHOST + 2); - readVHostConfigFromSystemProperties(ret.vhost3, variablesPrefix + VHOST + 3); - readVHostConfigFromSystemProperties(ret.vhost4, variablesPrefix + VHOST + 4); + readVHostConfigFromProperties(ret.vhost1, variablesPrefix + VHOST + 1, properties); + readVHostConfigFromProperties(ret.vhost2, variablesPrefix + VHOST + 2, properties); + readVHostConfigFromProperties(ret.vhost3, variablesPrefix + VHOST + 3, properties); + readVHostConfigFromProperties(ret.vhost4, variablesPrefix + VHOST + 4, properties);
return ret; } @@ -263,10 +315,10 @@ public class ApacheDeploymentUtil { } }
- private static void readVHostConfigFromSystemProperties(DeploymentConfig.VHost vhost, String prefix) { + private static void readVHostConfigFromProperties(DeploymentConfig.VHost vhost, String prefix, Map<String, String> properties) { prefix += ".";
- String addrsString = System.getProperty(prefix + URLS); + String addrsString = properties.get(prefix + URLS);
if (addrsString == null) { throw new IllegalStateException("The system property '" + prefix + "urls' doesn't exist. It is needed to define the vhost."); @@ -289,9 +341,9 @@ public class ApacheDeploymentUtil { throw new IllegalStateException("The system property '" + prefix + "urls' specified " + addrs.length + " addresses. Only 1-4 addresses are supported."); }
- vhost.serverNameDirective = System.getProperty(prefix + SERVERNAME_DIRECTIVE); + vhost.serverNameDirective = properties.get(prefix + SERVERNAME_DIRECTIVE);
- String additionalDirectives = System.getProperty(prefix + ADDITIONAL_DIRECTIVES); + String additionalDirectives = properties.get(prefix + ADDITIONAL_DIRECTIVES); fillAdditionalDirectives(additionalDirectives, vhost.additionalDirectives); }
@@ -302,4 +354,122 @@ public class ApacheDeploymentUtil { } } } + + private static String determineLocalhost() { + try { + return InetAddress.getLocalHost().getCanonicalHostName(); + } catch (UnknownHostException e) { + return "127.0.0.1"; + } + } + + private static class TokenReplacingMap extends HashMap<String, String> { + private static final long serialVersionUID = 1L; + + @SuppressWarnings("rawtypes") + private Map wrapped; + private Deque<String> currentResolutionStack = new ArrayDeque<String>(); + private Map<Object, String> resolved = new HashMap<Object, String>(); + + public TokenReplacingMap(Map<?, ?> wrapped) { + this.wrapped = wrapped; + } + + @Override + public String get(Object key) { + return get((String) key); + } + + public String get(String key) { + if (resolved.containsKey(key)) { + return resolved.get(key); + } + + if (currentResolutionStack.contains(key)) { + throw new IllegalArgumentException("Property '" + key + "' indirectly references itself in its value."); + } + + Object rawValue = wrapped.get(key); + + if (rawValue == null) { + return null; + } + + currentResolutionStack.push(key); + + String ret = readAll(new TokenReplacingReader(new StringReader(rawValue.toString()), this)); + + currentResolutionStack.pop(); + + resolved.put(key, ret); + + return ret; + } + + @Override + public String put(String key, String value) { + return (String) wrapped.put(key, value); + } + + @Override + public void putAll(Map<? extends String, ? extends String> m) { + wrapped.putAll(m); + } + + @Override + public void clear() { + wrapped.clear(); + resolved.clear(); + } + + @Override + public boolean containsKey(Object key) { + return wrapped.containsKey(key); + } + + @Override + public Set<String> keySet() { + return (Set<String>) wrapped.keySet(); + } + + @Override + public boolean containsValue(Object value) { + return wrapped.containsValue(value); + } + + @Override + public Set<Map.Entry<String, String>> entrySet() { + throw new UnsupportedOperationException(); + } + + @Override + public String remove(Object key) { + resolved.remove(key); + return wrapped.remove(key).toString(); + } + + @Override + public int size() { + return wrapped.size(); + } + + @Override + public Collection<String> values() { + throw new UnsupportedOperationException(); + } + + private String readAll(Reader rdr) { + int in = -1; + StringBuilder bld = new StringBuilder(); + try { + while((in = rdr.read()) != -1) { + bld.append((char) in); + } + } catch (IOException e) { + throw new IllegalStateException("Exception while reading a string.", e); + } + + return bld.toString(); + } + }; }
commit 2197c9572aabb70e76d1f6f721c8e58aad6b5ef5 Author: Lukas Krejci lkrejci@redhat.com Date: Mon Jun 20 18:19:57 2011 +0200
docs
diff --git a/modules/test-utils/src/main/java/org/rhq/test/ObjectCollectionSerializer.java b/modules/test-utils/src/main/java/org/rhq/test/ObjectCollectionSerializer.java index d3a3cab..c10c34e 100644 --- a/modules/test-utils/src/main/java/org/rhq/test/ObjectCollectionSerializer.java +++ b/modules/test-utils/src/main/java/org/rhq/test/ObjectCollectionSerializer.java @@ -133,11 +133,17 @@ public class ObjectCollectionSerializer { out.append("</inventory-dump>\n"); }
+ /** + * @see #deserialize(XMLStreamReader) + */ public List<?> deserialize(InputStream inputStream) throws IOException, XMLStreamException, ClassNotFoundException, JAXBException { XMLStreamReader rdr = XMLInputFactory.newFactory().createXMLStreamReader(inputStream); return deserialize(rdr); }
+ /** + * @see #deserialize(XMLStreamReader) + */ public List<?> deserialize(Reader inputReader) throws IOException, XMLStreamException, ClassNotFoundException, JAXBException { XMLStreamReader rdr = XMLInputFactory.newFactory().createXMLStreamReader(inputReader); return deserialize(rdr);
commit 400c9c6253f7aeabdb6ee0b9107845f6f854462a Author: Lukas Krejci lkrejci@redhat.com Date: Mon Jun 20 18:19:42 2011 +0200
abstract out the functionality that will be common to all upgrade tests to a base class so that we can have more freedom in splitting stuff up
diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java index 861c5e8..056fead 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java @@ -22,63 +22,17 @@ package org.rhq.plugins.apache; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue;
-import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.net.InetAddress; -import java.net.URI; -import java.net.UnknownHostException; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.UUID;
-import org.jmock.Expectations; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Parameters; import org.testng.annotations.Test;
-import org.rhq.core.clientapi.agent.metadata.PluginMetadataParser; -import org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil; -import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor; -import org.rhq.core.clientapi.server.discovery.InventoryReport; -import org.rhq.core.domain.configuration.Configuration; -import org.rhq.core.domain.configuration.PropertySimple; -import org.rhq.core.domain.discovery.AvailabilityReport; -import org.rhq.core.domain.resource.InventoryStatus; import org.rhq.core.domain.resource.Resource; -import org.rhq.core.domain.resource.ResourceError; import org.rhq.core.domain.resource.ResourceType; -import org.rhq.core.pc.ServerServices; -import org.rhq.core.pc.upgrade.FakeServerInventory; -import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; -import org.rhq.core.pluginapi.inventory.PluginContainerDeployment; -import org.rhq.core.pluginapi.inventory.ResourceContext; -import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; -import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; -import org.rhq.core.system.ProcessInfo; -import org.rhq.core.system.SystemInfo; -import org.rhq.core.system.SystemInfoFactory; -import org.rhq.plugins.apache.parser.ApacheDirectiveTree; -import org.rhq.plugins.apache.util.ApacheDeploymentUtil; import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig; -import org.rhq.plugins.apache.util.ApacheExecutionUtil; -import org.rhq.plugins.apache.util.HttpdAddressUtility; -import org.rhq.plugins.apache.util.MockApacheBinaryInfo; -import org.rhq.plugins.apache.util.MockProcessInfo; -import org.rhq.plugins.platform.PlatformComponent; -import org.rhq.test.ObjectCollectionSerializer; -import org.rhq.test.TokenReplacingReader; import org.rhq.test.pc.PluginContainerSetup; -import org.rhq.test.pc.PluginContainerTest;
/** * @@ -86,296 +40,7 @@ import org.rhq.test.pc.PluginContainerTest; * @author Lukas Krejci */ @Test(groups = "apache-integration-tests") -public class UpgradeTest extends PluginContainerTest { - - private static final String PLATFORM_PLUGIN = "file:target/itest/plugins/rhq-platform-plugin-for-apache-test.jar"; - private static final String AUGEAS_PLUGIN = "file:target/itest/plugins/rhq-augeas-plugin-for-apache-test.jar"; - private static final String APACHE_PLUGIN = "file:target/itest/plugins/rhq-apache-plugin-for-apache-test.jar"; - - private static final String DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES = "simpleWithResolvableServerNames"; - - private List<ResourceType> resourceTypesInApachePlugin; - - private Resource platform; - - private class TestSetup { - private String configurationName; - private FakeServerInventory fakeInventory = new FakeServerInventory(); - private String inventoryFile; - private Resource platform; - private ApacheSetup apacheSetup = new ApacheSetup(); - private DeploymentConfig deploymentConfig; - - public class ApacheSetup { - private String serverRoot; - private String exePath; - private Collection<String> configurationFiles; - private ApacheExecutionUtil execution; - private boolean deploy = true; - - private ApacheSetup() { - - } - - public ApacheSetup withServerRoot(String serverRoot) { - this.serverRoot = serverRoot; - return this; - } - - public ApacheSetup withExePath(String exePath) { - this.exePath = exePath; - return this; - } - - public ApacheSetup withConfigurationFiles(String... classPathUris) { - return withConfigurationFiles(Arrays.asList(classPathUris)); - } - - public ApacheSetup withConfigurationFiles(Collection<String> classPathUris) { - this.configurationFiles = classPathUris; - return this; - } - - public ApacheSetup withDeploymentOnSetup() { - this.deploy = true; - return this; - } - - public ApacheSetup withNoDeploymentOnSetup() { - this.deploy = false; - return this; - } - - public ApacheExecutionUtil getExecutionUtil() { - return execution; - } - - public void init() throws Exception { - File serverRootDir = new File(serverRoot); - - assertTrue(serverRootDir.exists(), "The configured server root denotes a non-existant directory: '" - + serverRootDir + "'."); - - File confDir = new File(serverRootDir, "conf"); - - assertTrue(confDir.exists(), - "The configured server root denotes a directory that doesn't have a 'conf' subdirectory. This is unexpected."); - - String snmpHost = null; - int snmpPort = 0; - String pingUrl = null; - - if (configurationName != null) { - if (deploy) { - ApacheDeploymentUtil.deployConfiguration(confDir, configurationFiles, deploymentConfig); - } - - HttpdAddressUtility.Address addr = deploymentConfig.mainServer.address1; - HttpdAddressUtility.Address addrToUse = new HttpdAddressUtility.Address(null, null, - HttpdAddressUtility.Address.NO_PORT_SPECIFIED_VALUE); - addrToUse.scheme = addr.scheme == null ? "http" : addr.scheme; - addrToUse.host = addr.host == null ? "localhost" : addr.host; - addrToUse.port = addr.port; - pingUrl = addrToUse.toString(); - - snmpHost = deploymentConfig.snmpHost; - snmpPort = deploymentConfig.snmpPort; - } - - execution = new ApacheExecutionUtil(findApachePluginResourceTypeByName("Apache HTTP Server"), - serverRoot, exePath, confDir.getAbsolutePath() + File.separatorChar + "httpd.conf", pingUrl, - snmpHost, snmpPort); - execution.init(); - } - - private void doSetup() throws Exception { - init(); - execution.invokeOperation("restart", "start"); - } - - public TestSetup setup() throws Exception { - return TestSetup.this.setup(); - } - } - - public TestSetup(String configurationName) { - this.configurationName = configurationName; - deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName); - } - - public TestSetup withInventoryFrom(String classPathUri) { - inventoryFile = classPathUri; - return this; - } - - public TestSetup withPlatformResource(Resource platform) { - this.platform = platform; - return this; - } - - public ApacheSetup withApacheSetup() { - return apacheSetup; - } - - public TestSetup withDefaultExpectations() throws Exception { - context.checking(new Expectations() { - { - addDefaultExceptations(this); - } - }); - - return this; - } - - @SuppressWarnings("unchecked") - public void addDefaultExceptations(Expectations expectations) throws Exception { - ServerServices ss = getCurrentPluginContainerConfiguration().getServerServices(); - - expectations.allowing(ss.getDiscoveryServerService()).mergeInventoryReport( - expectations.with(Expectations.any(InventoryReport.class))); - expectations.will(fakeInventory.mergeInventoryReport(InventoryStatus.COMMITTED)); - - expectations.allowing(ss.getDiscoveryServerService()).upgradeResources( - expectations.with(Expectations.any(Set.class))); - expectations.will(fakeInventory.upgradeResources()); - - expectations.allowing(ss.getDiscoveryServerService()).getResources( - expectations.with(Expectations.any(Set.class)), expectations.with(Expectations.any(boolean.class))); - expectations.will(fakeInventory.getResources()); - - expectations.allowing(ss.getDiscoveryServerService()).setResourceError(expectations.with(Expectations.any(ResourceError.class))); - expectations.will(fakeInventory.setResourceError()); - - expectations.allowing(ss.getDiscoveryServerService()).mergeAvailabilityReport( - expectations.with(Expectations.any(AvailabilityReport.class))); - - expectations.allowing(ss.getDiscoveryServerService()).postProcessNewlyCommittedResources( - expectations.with(Expectations.any(Set.class))); - - expectations.allowing(ss.getDiscoveryServerService()).clearResourceConfigError( - expectations.with(Expectations.any(int.class))); - - expectations.ignoring(ss.getBundleServerService()); - expectations.ignoring(ss.getConfigurationServerService()); - expectations.ignoring(ss.getContentServerService()); - expectations.ignoring(ss.getCoreServerService()); - expectations.ignoring(ss.getEventServerService()); - expectations.ignoring(ss.getMeasurementServerService()); - expectations.ignoring(ss.getOperationServerService()); - expectations.ignoring(ss.getResourceFactoryServerService()); - } - - public FakeServerInventory getFakeInventory() { - return fakeInventory; - } - - public DeploymentConfig getDeploymentConfig() { - return deploymentConfig; - } - - public TestSetup setup() throws Exception { - apacheSetup.doSetup(); - - Map<String, String> replacements = deploymentConfig.getTokenReplacements(); - replacements.put("server.root", apacheSetup.serverRoot); - replacements.put("exe.path", apacheSetup.exePath); - replacements.put("localhost", determineLocalhost()); - - HttpdAddressUtility addressUtility = apacheSetup.getExecutionUtil().getServerComponent() - .getAddressUtility(); - ApacheDirectiveTree runtimeConfig = apacheSetup.getExecutionUtil().getRuntimeConfiguration(); - - replacements.put("snmp.identifier", - addressUtility.getHttpdInternalMainServerAddressRepresentation(runtimeConfig).toString(false, false)); - - String vhost1Address = deploymentConfig.vhost1 == null ? null : deploymentConfig.vhost1.address1.toString( - false, false); - String vhost2Address = deploymentConfig.vhost2 == null ? null : deploymentConfig.vhost2.address1.toString( - false, false); - String vhost3Address = deploymentConfig.vhost3 == null ? null : deploymentConfig.vhost3.address1.toString( - false, false); - String vhost4Address = deploymentConfig.vhost4 == null ? null : deploymentConfig.vhost4.address1.toString( - false, false); - - if (vhost1Address != null) { - replacements.put( - "vhost1.snmp.identifier", - addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost1Address, - deploymentConfig.vhost1.getServerName()).toString(false, false)); - } - - if (vhost2Address != null) { - replacements.put( - "vhost2.snmp.identifier", - addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost2Address, - deploymentConfig.vhost2.getServerName()).toString(false, false)); - } - - if (vhost3Address != null) { - replacements.put( - "vhost3.snmp.identifier", - addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost3Address, - deploymentConfig.vhost3.getServerName()).toString(false, false)); - } - - if (vhost4Address != null) { - replacements.put( - "vhost4.snmp.identifier", - addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost4Address, - deploymentConfig.vhost4.getServerName()).toString(false, false)); - } - - InputStream dataStream = getClass().getResourceAsStream(inventoryFile); - - Reader rdr = new TokenReplacingReader(new InputStreamReader(dataStream), replacements); - - @SuppressWarnings("unchecked") - List<Resource> inventory = (List<Resource>) new ObjectCollectionSerializer().deserialize(rdr); - - //fix up the parent relationships, because they might not be reconstructed correctly by - //JAXB - we're missing XmlID and XmlIDRef annotations in our model - fixupParent(null, inventory); - - fakeInventory.prepopulateInventory(platform, inventory); - - return this; - } - - private void fixupParent(Resource parent, Collection<Resource> children) { - for (Resource child : children) { - child.setParentResource(parent); - if (child.getChildResources() != null) { - fixupParent(child, child.getChildResources()); - } - } - } - - private String determineLocalhost() { - try { - return InetAddress.getLocalHost().getCanonicalHostName(); - } catch (UnknownHostException e) { - return "127.0.0.1"; - } - } - } - - @BeforeClass - public void parseResourceTypesFromApachePlugin() throws Exception { - resourceTypesInApachePlugin = getResourceTypesInPlugin(APACHE_PLUGIN); - platform = discoverPlatform(); - } - - @AfterClass - @Parameters({ "apache2.install.dir", "apache2.exe.path" }) - public void shutdownApache(String apacheInstallationDirectory, String exePath) throws Exception { - - //it really doesn't matter which configuration i use here - TestSetup.ApacheSetup apacheSetup = new TestSetup(DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES) - .withApacheSetup().withServerRoot(apacheInstallationDirectory).withExePath(exePath) - .withNoDeploymentOnSetup(); - apacheSetup.init(); - apacheSetup.getExecutionUtil().invokeOperation("stop"); - } +public class UpgradeTest extends UpgradeTestBase {
@PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) @Parameters({ "apache2.install.dir", "apache2.exe.path" }) @@ -424,62 +89,4 @@ public class UpgradeTest extends PluginContainerTest { assertTrue(expectedResourceKeys.contains(vhost.getResourceKey()), "Unexpected virtual host resource key: '" + vhost.getResourceKey() + "'."); } } - - private ResourceType findApachePluginResourceTypeByName(String resourceTypeName) { - for (ResourceType rt : resourceTypesInApachePlugin) { - if (resourceTypeName.equals(rt.getName())) { - return rt; - } - } - - return null; - } - - private static List<ResourceType> getResourceTypesInPlugin(String pluginUri) throws Exception { - PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(new URI(pluginUri).toURL()); - PluginMetadataParser parser = new PluginMetadataParser(descriptor, - Collections.<String, PluginMetadataParser> emptyMap()); - - return parser.getAllTypes(); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - private static Resource discoverPlatform() throws Exception { - PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(new URI(PLATFORM_PLUGIN) - .toURL()); - PluginMetadataParser parser = new PluginMetadataParser(descriptor, - Collections.<String, PluginMetadataParser> emptyMap()); - - List<ResourceType> platformTypes = parser.getAllTypes(); - - for (ResourceType rt : platformTypes) { - Class discoveryClass = Class.forName(parser.getDiscoveryComponentClass(rt)); - - ResourceDiscoveryComponent discoveryComponent = (ResourceDiscoveryComponent) discoveryClass.newInstance(); - - ResourceDiscoveryContext context = new ResourceDiscoveryContext(rt, null, null, - SystemInfoFactory.createSystemInfo(), null, null, PluginContainerDeployment.AGENT); - - Set<DiscoveredResourceDetails> results = discoveryComponent.discoverResources(context); - - if (!results.isEmpty()) { - DiscoveredResourceDetails details = results.iterator().next(); - - Resource platform = new Resource(); - - platform.setDescription(details.getResourceDescription()); - platform.setResourceKey(details.getResourceKey()); - platform.setName(details.getResourceName()); - platform.setVersion(details.getResourceVersion()); - platform.setPluginConfiguration(details.getPluginConfiguration()); - platform.setResourceType(rt); - platform.setUuid(UUID.randomUUID().toString()); - platform.setId(1); - - return platform; - } - } - - return null; - } } diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java new file mode 100644 index 0000000..2c6f4f2 --- /dev/null +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java @@ -0,0 +1,424 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.plugins.apache; + +import static org.testng.Assert.assertTrue; + +import java.io.File; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.net.InetAddress; +import java.net.URI; +import java.net.UnknownHostException; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; + +import org.jmock.Expectations; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Parameters; + +import org.rhq.core.clientapi.agent.metadata.PluginMetadataParser; +import org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil; +import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor; +import org.rhq.core.clientapi.server.discovery.InventoryReport; +import org.rhq.core.domain.discovery.AvailabilityReport; +import org.rhq.core.domain.resource.InventoryStatus; +import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.resource.ResourceError; +import org.rhq.core.domain.resource.ResourceType; +import org.rhq.core.pc.ServerServices; +import org.rhq.core.pc.upgrade.FakeServerInventory; +import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; +import org.rhq.core.pluginapi.inventory.PluginContainerDeployment; +import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; +import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; +import org.rhq.core.system.SystemInfoFactory; +import org.rhq.plugins.apache.parser.ApacheDirectiveTree; +import org.rhq.plugins.apache.util.ApacheDeploymentUtil; +import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig; +import org.rhq.plugins.apache.util.ApacheExecutionUtil; +import org.rhq.plugins.apache.util.HttpdAddressUtility; +import org.rhq.test.ObjectCollectionSerializer; +import org.rhq.test.TokenReplacingReader; +import org.rhq.test.pc.PluginContainerTest; + + +/** + * Base class for the upgrade test classes. + * + * @author Lukas Krejci + */ +public class UpgradeTestBase extends PluginContainerTest { + + protected class TestSetup { + private String configurationName; + private FakeServerInventory fakeInventory = new FakeServerInventory(); + private String inventoryFile; + private Resource platform; + private ApacheSetup apacheSetup = new ApacheSetup(); + private DeploymentConfig deploymentConfig; + + public class ApacheSetup { + private String serverRoot; + private String exePath; + private Collection<String> configurationFiles; + private ApacheExecutionUtil execution; + private boolean deploy = true; + + private ApacheSetup() { + + } + + public ApacheSetup withServerRoot(String serverRoot) { + this.serverRoot = serverRoot; + return this; + } + + public ApacheSetup withExePath(String exePath) { + this.exePath = exePath; + return this; + } + + public ApacheSetup withConfigurationFiles(String... classPathUris) { + return withConfigurationFiles(Arrays.asList(classPathUris)); + } + + public ApacheSetup withConfigurationFiles(Collection<String> classPathUris) { + this.configurationFiles = classPathUris; + return this; + } + + public ApacheSetup withDeploymentOnSetup() { + this.deploy = true; + return this; + } + + public ApacheSetup withNoDeploymentOnSetup() { + this.deploy = false; + return this; + } + + public ApacheExecutionUtil getExecutionUtil() { + return execution; + } + + public void init() throws Exception { + File serverRootDir = new File(serverRoot); + + assertTrue(serverRootDir.exists(), "The configured server root denotes a non-existant directory: '" + + serverRootDir + "'."); + + File confDir = new File(serverRootDir, "conf"); + + assertTrue(confDir.exists(), + "The configured server root denotes a directory that doesn't have a 'conf' subdirectory. This is unexpected."); + + String snmpHost = null; + int snmpPort = 0; + String pingUrl = null; + + if (configurationName != null) { + if (deploy) { + ApacheDeploymentUtil.deployConfiguration(confDir, configurationFiles, deploymentConfig); + } + + HttpdAddressUtility.Address addr = deploymentConfig.mainServer.address1; + HttpdAddressUtility.Address addrToUse = new HttpdAddressUtility.Address(null, null, + HttpdAddressUtility.Address.NO_PORT_SPECIFIED_VALUE); + addrToUse.scheme = addr.scheme == null ? "http" : addr.scheme; + addrToUse.host = addr.host == null ? "localhost" : addr.host; + addrToUse.port = addr.port; + pingUrl = addrToUse.toString(); + + snmpHost = deploymentConfig.snmpHost; + snmpPort = deploymentConfig.snmpPort; + } + + execution = new ApacheExecutionUtil(findApachePluginResourceTypeByName("Apache HTTP Server"), + serverRoot, exePath, confDir.getAbsolutePath() + File.separatorChar + "httpd.conf", pingUrl, + snmpHost, snmpPort); + execution.init(); + } + + private void doSetup() throws Exception { + init(); + execution.invokeOperation("restart", "start"); + } + + public TestSetup setup() throws Exception { + return TestSetup.this.setup(); + } + } + + public TestSetup(String configurationName) { + this.configurationName = configurationName; + deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName); + } + + public TestSetup withInventoryFrom(String classPathUri) { + inventoryFile = classPathUri; + return this; + } + + public TestSetup withPlatformResource(Resource platform) { + this.platform = platform; + return this; + } + + public ApacheSetup withApacheSetup() { + return apacheSetup; + } + + public TestSetup withDefaultExpectations() throws Exception { + context.checking(new Expectations() { + { + addDefaultExceptations(this); + } + }); + + return this; + } + + @SuppressWarnings("unchecked") + public void addDefaultExceptations(Expectations expectations) throws Exception { + ServerServices ss = getCurrentPluginContainerConfiguration().getServerServices(); + + expectations.allowing(ss.getDiscoveryServerService()).mergeInventoryReport( + expectations.with(Expectations.any(InventoryReport.class))); + expectations.will(fakeInventory.mergeInventoryReport(InventoryStatus.COMMITTED)); + + expectations.allowing(ss.getDiscoveryServerService()).upgradeResources( + expectations.with(Expectations.any(Set.class))); + expectations.will(fakeInventory.upgradeResources()); + + expectations.allowing(ss.getDiscoveryServerService()).getResources( + expectations.with(Expectations.any(Set.class)), expectations.with(Expectations.any(boolean.class))); + expectations.will(fakeInventory.getResources()); + + expectations.allowing(ss.getDiscoveryServerService()).setResourceError(expectations.with(Expectations.any(ResourceError.class))); + expectations.will(fakeInventory.setResourceError()); + + expectations.allowing(ss.getDiscoveryServerService()).mergeAvailabilityReport( + expectations.with(Expectations.any(AvailabilityReport.class))); + + expectations.allowing(ss.getDiscoveryServerService()).postProcessNewlyCommittedResources( + expectations.with(Expectations.any(Set.class))); + + expectations.allowing(ss.getDiscoveryServerService()).clearResourceConfigError( + expectations.with(Expectations.any(int.class))); + + expectations.ignoring(ss.getBundleServerService()); + expectations.ignoring(ss.getConfigurationServerService()); + expectations.ignoring(ss.getContentServerService()); + expectations.ignoring(ss.getCoreServerService()); + expectations.ignoring(ss.getEventServerService()); + expectations.ignoring(ss.getMeasurementServerService()); + expectations.ignoring(ss.getOperationServerService()); + expectations.ignoring(ss.getResourceFactoryServerService()); + } + + public FakeServerInventory getFakeInventory() { + return fakeInventory; + } + + public DeploymentConfig getDeploymentConfig() { + return deploymentConfig; + } + + public TestSetup setup() throws Exception { + apacheSetup.doSetup(); + + Map<String, String> replacements = deploymentConfig.getTokenReplacements(); + replacements.put("server.root", apacheSetup.serverRoot); + replacements.put("exe.path", apacheSetup.exePath); + replacements.put("localhost", determineLocalhost()); + + HttpdAddressUtility addressUtility = apacheSetup.getExecutionUtil().getServerComponent() + .getAddressUtility(); + ApacheDirectiveTree runtimeConfig = apacheSetup.getExecutionUtil().getRuntimeConfiguration(); + + replacements.put("snmp.identifier", + addressUtility.getHttpdInternalMainServerAddressRepresentation(runtimeConfig).toString(false, false)); + + String vhost1Address = deploymentConfig.vhost1 == null ? null : deploymentConfig.vhost1.address1.toString( + false, false); + String vhost2Address = deploymentConfig.vhost2 == null ? null : deploymentConfig.vhost2.address1.toString( + false, false); + String vhost3Address = deploymentConfig.vhost3 == null ? null : deploymentConfig.vhost3.address1.toString( + false, false); + String vhost4Address = deploymentConfig.vhost4 == null ? null : deploymentConfig.vhost4.address1.toString( + false, false); + + if (vhost1Address != null) { + replacements.put( + "vhost1.snmp.identifier", + addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost1Address, + deploymentConfig.vhost1.getServerName()).toString(false, false)); + } + + if (vhost2Address != null) { + replacements.put( + "vhost2.snmp.identifier", + addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost2Address, + deploymentConfig.vhost2.getServerName()).toString(false, false)); + } + + if (vhost3Address != null) { + replacements.put( + "vhost3.snmp.identifier", + addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost3Address, + deploymentConfig.vhost3.getServerName()).toString(false, false)); + } + + if (vhost4Address != null) { + replacements.put( + "vhost4.snmp.identifier", + addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost4Address, + deploymentConfig.vhost4.getServerName()).toString(false, false)); + } + + InputStream dataStream = getClass().getResourceAsStream(inventoryFile); + + Reader rdr = new TokenReplacingReader(new InputStreamReader(dataStream), replacements); + + @SuppressWarnings("unchecked") + List<Resource> inventory = (List<Resource>) new ObjectCollectionSerializer().deserialize(rdr); + + //fix up the parent relationships, because they might not be reconstructed correctly by + //JAXB - we're missing XmlID and XmlIDRef annotations in our model + fixupParent(null, inventory); + + fakeInventory.prepopulateInventory(platform, inventory); + + return this; + } + + private void fixupParent(Resource parent, Collection<Resource> children) { + for (Resource child : children) { + child.setParentResource(parent); + if (child.getChildResources() != null) { + fixupParent(child, child.getChildResources()); + } + } + } + + private String determineLocalhost() { + try { + return InetAddress.getLocalHost().getCanonicalHostName(); + } catch (UnknownHostException e) { + return "127.0.0.1"; + } + } + } + + protected static final String PLATFORM_PLUGIN = "file:target/itest/plugins/rhq-platform-plugin-for-apache-test.jar"; + protected static final String AUGEAS_PLUGIN = "file:target/itest/plugins/rhq-augeas-plugin-for-apache-test.jar"; + protected static final String APACHE_PLUGIN = "file:target/itest/plugins/rhq-apache-plugin-for-apache-test.jar"; + + protected static final String DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES = "simpleWithResolvableServerNames"; + protected static final String DEPLOYMENT_SIMPLE_WITH_UNRESOLVABLE_SERVER_NAMES = "simpleWithUnresolvableServerNames"; + + private List<ResourceType> resourceTypesInApachePlugin; + protected Resource platform; + + @BeforeClass + public void parseResourceTypesFromApachePlugin() throws Exception { + resourceTypesInApachePlugin = getResourceTypesInPlugin(APACHE_PLUGIN); + platform = discoverPlatform(); + } + + @AfterClass + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void shutdownApache(String apacheInstallationDirectory, String exePath) throws Exception { + + //it really doesn't matter which configuration i use here + TestSetup.ApacheSetup apacheSetup = new TestSetup(DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES) + .withApacheSetup().withServerRoot(apacheInstallationDirectory).withExePath(exePath) + .withNoDeploymentOnSetup(); + apacheSetup.init(); + apacheSetup.getExecutionUtil().invokeOperation("stop"); + } + + protected ResourceType findApachePluginResourceTypeByName(String resourceTypeName) { + for (ResourceType rt : resourceTypesInApachePlugin) { + if (resourceTypeName.equals(rt.getName())) { + return rt; + } + } + + return null; + } + + private static List<ResourceType> getResourceTypesInPlugin(String pluginUri) throws Exception { + PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(new URI(pluginUri).toURL()); + PluginMetadataParser parser = new PluginMetadataParser(descriptor, + Collections.<String, PluginMetadataParser> emptyMap()); + + return parser.getAllTypes(); + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + private static Resource discoverPlatform() throws Exception { + PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(new URI(PLATFORM_PLUGIN) + .toURL()); + PluginMetadataParser parser = new PluginMetadataParser(descriptor, + Collections.<String, PluginMetadataParser> emptyMap()); + + List<ResourceType> platformTypes = parser.getAllTypes(); + + for (ResourceType rt : platformTypes) { + Class discoveryClass = Class.forName(parser.getDiscoveryComponentClass(rt)); + + ResourceDiscoveryComponent discoveryComponent = (ResourceDiscoveryComponent) discoveryClass.newInstance(); + + ResourceDiscoveryContext context = new ResourceDiscoveryContext(rt, null, null, + SystemInfoFactory.createSystemInfo(), null, null, PluginContainerDeployment.AGENT); + + Set<DiscoveredResourceDetails> results = discoveryComponent.discoverResources(context); + + if (!results.isEmpty()) { + DiscoveredResourceDetails details = results.iterator().next(); + + Resource platform = new Resource(); + + platform.setDescription(details.getResourceDescription()); + platform.setResourceKey(details.getResourceKey()); + platform.setName(details.getResourceName()); + platform.setVersion(details.getResourceVersion()); + platform.setPluginConfiguration(details.getPluginConfiguration()); + platform.setResourceType(rt); + platform.setUuid(UUID.randomUUID().toString()); + platform.setId(1); + + return platform; + } + } + + return null; + } + +}
commit 3cef7ad8dda423efd80d35d2adfb809bad934824 Author: Lukas Krejci lkrejci@redhat.com Date: Mon Jun 20 16:07:00 2011 +0200
Moving the TokenReplacingReader to test-utils, because it's a generic thing that can be reused by others.
diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java index 5bbdb11..861c5e8 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java @@ -74,9 +74,9 @@ import org.rhq.plugins.apache.util.ApacheExecutionUtil; import org.rhq.plugins.apache.util.HttpdAddressUtility; import org.rhq.plugins.apache.util.MockApacheBinaryInfo; import org.rhq.plugins.apache.util.MockProcessInfo; -import org.rhq.plugins.apache.util.TokenReplacingReader; import org.rhq.plugins.platform.PlatformComponent; import org.rhq.test.ObjectCollectionSerializer; +import org.rhq.test.TokenReplacingReader; import org.rhq.test.pc.PluginContainerSetup; import org.rhq.test.pc.PluginContainerTest;
diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java index 3893b56..524370e 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java @@ -35,6 +35,7 @@ import org.apache.commons.logging.LogFactory; import org.unitils.thirdparty.org.apache.commons.io.FileUtils;
import org.rhq.plugins.apache.util.HttpdAddressUtility.Address; +import org.rhq.test.TokenReplacingReader;
/** * diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/TokenReplacingReader.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/TokenReplacingReader.java deleted file mode 100644 index 7ebf48b..0000000 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/TokenReplacingReader.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2011 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.plugins.apache.util; - -import java.io.IOException; -import java.io.PushbackReader; -import java.io.Reader; -import java.nio.CharBuffer; -import java.util.Map; - -/** - * Copied from http://tutorials.jenkov.com/java-howto/replace-strings-in-streams-arrays-fil... - * with fixes to {@link #read(char[], int, int)} and added support for escaping. - * - * @author Lukas Krejci - */ -public class TokenReplacingReader extends Reader { - - private PushbackReader pushbackReader = null; - private Map<String, String> tokens = null; - private StringBuilder tokenNameBuffer = new StringBuilder(); - private String tokenValue = null; - private int tokenValueIndex = 0; - private boolean escaping = false; - - public TokenReplacingReader(Reader source, Map<String, String> tokens) { - this.pushbackReader = new PushbackReader(source, 2); - this.tokens = tokens; - } - - public int read(CharBuffer target) throws IOException { - throw new RuntimeException("Operation Not Supported"); - } - - public int read() throws IOException { - if (this.tokenValue != null) { - if (this.tokenValueIndex < this.tokenValue.length()) { - return this.tokenValue.charAt(this.tokenValueIndex++); - } - if (this.tokenValueIndex == this.tokenValue.length()) { - this.tokenValue = null; - this.tokenValueIndex = 0; - } - } - - int data = this.pushbackReader.read(); - - if (escaping) { - escaping = false; - return data; - } - - if (data == '\') { - escaping = true; - return data; - } - - if (data != '$') - return data; - - data = this.pushbackReader.read(); - if (data != '{') { - this.pushbackReader.unread(data); - return '$'; - } - this.tokenNameBuffer.delete(0, this.tokenNameBuffer.length()); - - data = this.pushbackReader.read(); - while (data != '}') { - this.tokenNameBuffer.append((char) data); - data = this.pushbackReader.read(); - } - - this.tokenValue = tokens.get(this.tokenNameBuffer.toString()); - - if (this.tokenValue == null) { - this.tokenValue = "${" + this.tokenNameBuffer.toString() + "}"; - } - - if (!this.tokenValue.isEmpty()) { - return this.tokenValue.charAt(this.tokenValueIndex++); - } else { - return read(); - } - } - - public int read(char cbuf[]) throws IOException { - return read(cbuf, 0, cbuf.length); - } - - public int read(char cbuf[], int off, int len) throws IOException { - int i = 0; - for (; i < len; i++) { - int nextChar = read(); - if (nextChar == -1) { - if (i == 0) { - i = -1; - } - break; - } - cbuf[off + i] = (char) nextChar; - } - return i; - } - - public void close() throws IOException { - this.pushbackReader.close(); - } - - public long skip(long n) throws IOException { - throw new RuntimeException("Operation Not Supported"); - } - - public boolean ready() throws IOException { - return this.pushbackReader.ready(); - } - - public boolean markSupported() { - return false; - } - - public void mark(int readAheadLimit) throws IOException { - throw new RuntimeException("Operation Not Supported"); - } - - public void reset() throws IOException { - throw new RuntimeException("Operation Not Supported"); - } -} diff --git a/modules/test-utils/src/main/java/org/rhq/test/TokenReplacingReader.java b/modules/test-utils/src/main/java/org/rhq/test/TokenReplacingReader.java new file mode 100644 index 0000000..22a3167 --- /dev/null +++ b/modules/test-utils/src/main/java/org/rhq/test/TokenReplacingReader.java @@ -0,0 +1,146 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.test; + +import java.io.IOException; +import java.io.PushbackReader; +import java.io.Reader; +import java.nio.CharBuffer; +import java.util.Map; + +/** + * Copied from http://tutorials.jenkov.com/java-howto/replace-strings-in-streams-arrays-fil... + * with fixes to {@link #read(char[], int, int)} and added support for escaping. + * + * @author Lukas Krejci + */ +public class TokenReplacingReader extends Reader { + + private PushbackReader pushbackReader = null; + private Map<String, String> tokens = null; + private StringBuilder tokenNameBuffer = new StringBuilder(); + private String tokenValue = null; + private int tokenValueIndex = 0; + private boolean escaping = false; + + public TokenReplacingReader(Reader source, Map<String, String> tokens) { + this.pushbackReader = new PushbackReader(source, 2); + this.tokens = tokens; + } + + public int read(CharBuffer target) throws IOException { + throw new RuntimeException("Operation Not Supported"); + } + + public int read() throws IOException { + if (this.tokenValue != null) { + if (this.tokenValueIndex < this.tokenValue.length()) { + return this.tokenValue.charAt(this.tokenValueIndex++); + } + if (this.tokenValueIndex == this.tokenValue.length()) { + this.tokenValue = null; + this.tokenValueIndex = 0; + } + } + + int data = this.pushbackReader.read(); + + if (escaping) { + escaping = false; + return data; + } + + if (data == '\') { + escaping = true; + return data; + } + + if (data != '$') + return data; + + data = this.pushbackReader.read(); + if (data != '{') { + this.pushbackReader.unread(data); + return '$'; + } + this.tokenNameBuffer.delete(0, this.tokenNameBuffer.length()); + + data = this.pushbackReader.read(); + while (data != '}') { + this.tokenNameBuffer.append((char) data); + data = this.pushbackReader.read(); + } + + this.tokenValue = tokens.get(this.tokenNameBuffer.toString()); + + if (this.tokenValue == null) { + this.tokenValue = "${" + this.tokenNameBuffer.toString() + "}"; + } + + if (!this.tokenValue.isEmpty()) { + return this.tokenValue.charAt(this.tokenValueIndex++); + } else { + return read(); + } + } + + public int read(char cbuf[]) throws IOException { + return read(cbuf, 0, cbuf.length); + } + + public int read(char cbuf[], int off, int len) throws IOException { + int i = 0; + for (; i < len; i++) { + int nextChar = read(); + if (nextChar == -1) { + if (i == 0) { + i = -1; + } + break; + } + cbuf[off + i] = (char) nextChar; + } + return i; + } + + public void close() throws IOException { + this.pushbackReader.close(); + } + + public long skip(long n) throws IOException { + throw new RuntimeException("Operation Not Supported"); + } + + public boolean ready() throws IOException { + return this.pushbackReader.ready(); + } + + public boolean markSupported() { + return false; + } + + public void mark(int readAheadLimit) throws IOException { + throw new RuntimeException("Operation Not Supported"); + } + + public void reset() throws IOException { + throw new RuntimeException("Operation Not Supported"); + } +}
commit 558acc8ac6475c1729864a9b4259ac154f4df6b4 Author: Lukas Krejci lkrejci@redhat.com Date: Mon Jun 20 16:02:24 2011 +0200
The agents will report plugin config errors with inventory as we have it in the apache tests. Expect that.
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java index fd07d72..5f8a922 100644 --- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java +++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java @@ -126,6 +126,27 @@ public class FakeServerInventory { }; }
+ public synchronized CustomAction setResourceError() { + return new CustomAction("setResourceError") { + public Object invoke(Invocation invocation) throws Throwable { + synchronized(FakeServerInventory.this) { + throwIfFailing(); + + ResourceError error = (ResourceError) invocation.getParameter(0); + + Resource serverSideResource = resourceStore.get(error.getResource().getUuid()); + + if (serverSideResource != null) { + List<ResourceError> currentErrors = serverSideResource.getResourceErrors(); + currentErrors.add(error); + } + + return null; + } + } + }; + } + public synchronized CustomAction upgradeResources() { return new CustomAction("upgradeServerSideInventory") { @SuppressWarnings({ "serial", "unchecked" }) diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java index c1725c3..5bbdb11 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java @@ -55,6 +55,7 @@ import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.discovery.AvailabilityReport; import org.rhq.core.domain.resource.InventoryStatus; import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.resource.ResourceError; import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.pc.ServerServices; import org.rhq.core.pc.upgrade.FakeServerInventory; @@ -242,6 +243,9 @@ public class UpgradeTest extends PluginContainerTest { expectations.with(Expectations.any(Set.class)), expectations.with(Expectations.any(boolean.class))); expectations.will(fakeInventory.getResources());
+ expectations.allowing(ss.getDiscoveryServerService()).setResourceError(expectations.with(Expectations.any(ResourceError.class))); + expectations.will(fakeInventory.setResourceError()); + expectations.allowing(ss.getDiscoveryServerService()).mergeAvailabilityReport( expectations.with(Expectations.any(AvailabilityReport.class)));
@@ -250,7 +254,7 @@ public class UpgradeTest extends PluginContainerTest {
expectations.allowing(ss.getDiscoveryServerService()).clearResourceConfigError( expectations.with(Expectations.any(int.class))); - + expectations.ignoring(ss.getBundleServerService()); expectations.ignoring(ss.getConfigurationServerService()); expectations.ignoring(ss.getContentServerService());
commit e50c68fa724b66bfb7460859f2774a62797d0e8f Author: Lukas Krejci lkrejci@redhat.com Date: Mon Jun 20 16:01:27 2011 +0200
Catch the exceptions when activating the resources after the resource upgrade.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java index 915c8e0..c659b8e 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java @@ -36,6 +36,7 @@ import org.rhq.core.domain.resource.ResourceUpgradeReport; import org.rhq.core.pc.PluginContainer; import org.rhq.core.pc.inventory.InventoryManager; import org.rhq.core.pc.inventory.ResourceContainer; +import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; import org.rhq.core.pluginapi.inventory.ResourceComponent; import org.rhq.core.pluginapi.inventory.ResourceContext; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; @@ -212,7 +213,13 @@ public class ResourceUpgradeDelegate { ResourceContainer container = inventoryManager.getResourceContainer(request.getResourceId()); if (container != null) { Resource resource = container.getResource(); - inventoryManager.activateResource(resource, container, true); + try { + inventoryManager.activateResource(resource, container, true); + } catch (InvalidPluginConfigurationException e) { + log.debug("Resource [" + resource + "] failed to start up after upgrade.", e); + } catch (Throwable t) { + log.error("Failed to activate the resource [" + resource + "] after upgrade.", t); + } } } } catch (Throwable t) {
commit fb6e7aaf4e43359f9ede3969902386ba75e7f7a1 Author: Lukas Krejci lkrejci@redhat.com Date: Mon Jun 20 16:00:20 2011 +0200
Server never deletes resources based on their absence in the reports from the agents. Behave the same in the fake server inventory.
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java index 0f13e29..fd07d72 100644 --- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java +++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java @@ -286,8 +286,7 @@ public class FakeServerInventory { persisted.setParentResource(parent); }
- Set<Resource> childResources = new HashSet<Resource>(); - persisted.setChildResources(childResources); + Set<Resource> childResources = persisted.getChildResources(); for (Resource child : agentSideResource.getChildResources()) { childResources.add(fakePersist(child, requiredInventoryStatus, inProgressUUIds)); }
commit cf93304d2d42acae6f8ce42be44a5e72a3268066 Author: Lukas Krejci lkrejci@redhat.com Date: Fri Jun 17 16:42:47 2011 +0200
Don't assume that the httpd conf path is absolute - it isn't in the RHQ 1.x inventories. This fix is needed to correctly upgrade from RHQ 1.x to RHQ 4.1.x.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java index 08ff372..565fd3c 100644 --- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java +++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java @@ -645,6 +645,14 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen
public static String formatResourceKey(String serverRoot, String httpdConf) { serverRoot = FileUtils.getCanonicalPath(serverRoot); + + //we could have inherited the configuration from + //RHQ 1.x times, when the httpdConf was relative. + File httpdConfF = new File(httpdConf); + if (!httpdConfF.isAbsolute()) { + httpdConfF = new File(serverRoot, httpdConf); + httpdConf = httpdConfF.getAbsolutePath(); + } httpdConf = FileUtils.getCanonicalPath(httpdConf);
return serverRoot + "||" + httpdConf;
commit abe95cffc03171ef2f9e602ba9788f33180e60d0 Author: Lukas Krejci lkrejci@redhat.com Date: Fri Jun 17 16:41:40 2011 +0200
Always include scheme in the main server sample address. This fix is needed due to changes made in the address utility to support the comprehensive plugin tests.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java index 45f883d..874d4e3 100644 --- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java +++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java @@ -328,6 +328,9 @@ public enum HttpdAddressUtility { for (Address address : addressesToMatch) { if (isAddressConforming(address, limitToHost, limitToPort, false)) { substituteWildcards(ag, address); + if (address.scheme == null) { + address.scheme = "http"; + } return address; } }
commit e1fce148784f05f121f8250665a0404eb3900d01 Author: Lukas Krejci lkrejci@redhat.com Date: Fri Jun 17 16:40:32 2011 +0200
More work on the apache tests infrastructure. The execution of the operations and working with the apache server resource component has been abstracted out into standalone class so that we can do more tricks.
diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java index 2492cb7..c1725c3 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java @@ -23,10 +23,14 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue;
import java.io.File; +import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; +import java.net.InetAddress; import java.net.URI; +import java.net.UnknownHostException; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -59,11 +63,16 @@ import org.rhq.core.pluginapi.inventory.PluginContainerDeployment; import org.rhq.core.pluginapi.inventory.ResourceContext; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; +import org.rhq.core.system.ProcessInfo; import org.rhq.core.system.SystemInfo; import org.rhq.core.system.SystemInfoFactory; +import org.rhq.plugins.apache.parser.ApacheDirectiveTree; import org.rhq.plugins.apache.util.ApacheDeploymentUtil; import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig; +import org.rhq.plugins.apache.util.ApacheExecutionUtil; import org.rhq.plugins.apache.util.HttpdAddressUtility; +import org.rhq.plugins.apache.util.MockApacheBinaryInfo; +import org.rhq.plugins.apache.util.MockProcessInfo; import org.rhq.plugins.apache.util.TokenReplacingReader; import org.rhq.plugins.platform.PlatformComponent; import org.rhq.test.ObjectCollectionSerializer; @@ -88,26 +97,20 @@ public class UpgradeTest extends PluginContainerTest {
private Resource platform;
- private static class DiscoveryInput { - public String serverRootPath; - public String exePath; - public String httpdConfPath; - public String snmpHost; - public int snmpPort; - public String pingUrl; - } - private class TestSetup { private String configurationName; private FakeServerInventory fakeInventory = new FakeServerInventory(); private String inventoryFile; private Resource platform; private ApacheSetup apacheSetup = new ApacheSetup(); + private DeploymentConfig deploymentConfig;
public class ApacheSetup { private String serverRoot; private String exePath; private Collection<String> configurationFiles; + private ApacheExecutionUtil execution; + private boolean deploy = true;
private ApacheSetup() {
@@ -132,65 +135,71 @@ public class UpgradeTest extends PluginContainerTest { return this; }
- private void doSetup() throws Exception { - prepareApacheForTest(TestSetup.this.configurationName, serverRoot, exePath, configurationFiles); + public ApacheSetup withDeploymentOnSetup() { + this.deploy = true; + return this; }
- public TestSetup setup() throws Exception { - return TestSetup.this.setup(); + public ApacheSetup withNoDeploymentOnSetup() { + this.deploy = false; + return this; }
- private void prepareApacheForTest(String configurationName, String apacheInstallationDirectory, - String apacheExePath, Collection<String> configurationFiles) throws Exception { - File apacheInstallationDir = new File(apacheInstallationDirectory); + public ApacheExecutionUtil getExecutionUtil() { + return execution; + }
- assertTrue(apacheInstallationDir.exists(), - "The 'apache2.install.dir' system property denotes a non-existant directory: '" - + apacheInstallationDirectory + "'."); + public void init() throws Exception { + File serverRootDir = new File(serverRoot);
- File confDir = new File(apacheInstallationDir, "conf"); + assertTrue(serverRootDir.exists(), "The configured server root denotes a non-existant directory: '" + + serverRootDir + "'.");
- assertTrue( - confDir.exists(), - "The 'apache2.install.dir' system property denotes a directory that doesn't have a 'conf' subdirectory. This is unexpected."); + File confDir = new File(serverRootDir, "conf");
- DeploymentConfig deploymentConfig = ApacheDeploymentUtil - .getDeploymentConfigurationFromSystemProperties(configurationName); + assertTrue(confDir.exists(), + "The configured server root denotes a directory that doesn't have a 'conf' subdirectory. This is unexpected.");
- ApacheDeploymentUtil.deployConfiguration(confDir, configurationFiles, deploymentConfig); + String snmpHost = null; + int snmpPort = 0; + String pingUrl = null;
- DiscoveryInput discoveryInput = new DiscoveryInput(); - discoveryInput.serverRootPath = apacheInstallationDirectory; - discoveryInput.exePath = apacheExePath; - discoveryInput.httpdConfPath = confDir.getAbsolutePath() + File.separatorChar + "httpd.conf"; - discoveryInput.snmpHost = deploymentConfig.snmpHost; - discoveryInput.snmpPort = deploymentConfig.snmpPort; + if (configurationName != null) { + if (deploy) { + ApacheDeploymentUtil.deployConfiguration(confDir, configurationFiles, deploymentConfig); + }
- HttpdAddressUtility.Address addr = deploymentConfig.mainServer.address1; - HttpdAddressUtility.Address addrToUse = new HttpdAddressUtility.Address(null, null, - HttpdAddressUtility.Address.NO_PORT_SPECIFIED_VALUE); - addrToUse.scheme = addr.scheme == null ? "http" : addr.scheme; - addrToUse.host = addr.host == null ? "localhost" : addr.host; - addrToUse.port = addr.port; + HttpdAddressUtility.Address addr = deploymentConfig.mainServer.address1; + HttpdAddressUtility.Address addrToUse = new HttpdAddressUtility.Address(null, null, + HttpdAddressUtility.Address.NO_PORT_SPECIFIED_VALUE); + addrToUse.scheme = addr.scheme == null ? "http" : addr.scheme; + addrToUse.host = addr.host == null ? "localhost" : addr.host; + addrToUse.port = addr.port; + pingUrl = addrToUse.toString();
- discoveryInput.pingUrl = addrToUse.toString(); + snmpHost = deploymentConfig.snmpHost; + snmpPort = deploymentConfig.snmpPort; + }
- restartApache(discoveryInput); + execution = new ApacheExecutionUtil(findApachePluginResourceTypeByName("Apache HTTP Server"), + serverRoot, exePath, confDir.getAbsolutePath() + File.separatorChar + "httpd.conf", pingUrl, + snmpHost, snmpPort); + execution.init(); }
- private void restartApache(DiscoveryInput discoveryInput) throws Exception { - ApacheServerComponent serverComponent = findAndStartServerComponent(discoveryInput); + private void doSetup() throws Exception { + init(); + execution.invokeOperation("restart", "start"); + }
- try { - serverComponent.invokeOperation("restart", null); - } catch (Exception e) { - serverComponent.invokeOperation("start", null); - } + public TestSetup setup() throws Exception { + return TestSetup.this.setup(); } }
public TestSetup(String configurationName) { this.configurationName = configurationName; + deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName); }
public TestSetup withInventoryFrom(String classPathUri) { @@ -220,28 +229,97 @@ public class UpgradeTest extends PluginContainerTest { @SuppressWarnings("unchecked") public void addDefaultExceptations(Expectations expectations) throws Exception { ServerServices ss = getCurrentPluginContainerConfiguration().getServerServices(); - - expectations.allowing(ss.getDiscoveryServerService()).mergeInventoryReport(expectations.with(Expectations.any(InventoryReport.class))); + + expectations.allowing(ss.getDiscoveryServerService()).mergeInventoryReport( + expectations.with(Expectations.any(InventoryReport.class))); expectations.will(fakeInventory.mergeInventoryReport(InventoryStatus.COMMITTED));
- expectations.allowing(ss.getDiscoveryServerService()).upgradeResources(expectations.with(Expectations.any(Set.class))); + expectations.allowing(ss.getDiscoveryServerService()).upgradeResources( + expectations.with(Expectations.any(Set.class))); expectations.will(fakeInventory.upgradeResources()); - - expectations.allowing(ss.getDiscoveryServerService()).getResources(expectations.with(Expectations.any(Set.class)), expectations.with(Expectations.any(boolean.class))); + + expectations.allowing(ss.getDiscoveryServerService()).getResources( + expectations.with(Expectations.any(Set.class)), expectations.with(Expectations.any(boolean.class))); expectations.will(fakeInventory.getResources()); - - expectations.allowing(ss.getDiscoveryServerService()).mergeAvailabilityReport(expectations.with(Expectations.any(AvailabilityReport.class))); - expectations.allowing(ss.getDiscoveryServerService()).postProcessNewlyCommittedResources(expectations.with(Expectations.any(Set.class))); + + expectations.allowing(ss.getDiscoveryServerService()).mergeAvailabilityReport( + expectations.with(Expectations.any(AvailabilityReport.class))); + + expectations.allowing(ss.getDiscoveryServerService()).postProcessNewlyCommittedResources( + expectations.with(Expectations.any(Set.class))); + + expectations.allowing(ss.getDiscoveryServerService()).clearResourceConfigError( + expectations.with(Expectations.any(int.class))); + + expectations.ignoring(ss.getBundleServerService()); + expectations.ignoring(ss.getConfigurationServerService()); + expectations.ignoring(ss.getContentServerService()); + expectations.ignoring(ss.getCoreServerService()); + expectations.ignoring(ss.getEventServerService()); + expectations.ignoring(ss.getMeasurementServerService()); + expectations.ignoring(ss.getOperationServerService()); + expectations.ignoring(ss.getResourceFactoryServerService()); } - + public FakeServerInventory getFakeInventory() { return fakeInventory; }
+ public DeploymentConfig getDeploymentConfig() { + return deploymentConfig; + } + public TestSetup setup() throws Exception { - Map<String, String> replacements = new HashMap<String, String>(); + apacheSetup.doSetup(); + + Map<String, String> replacements = deploymentConfig.getTokenReplacements(); replacements.put("server.root", apacheSetup.serverRoot); replacements.put("exe.path", apacheSetup.exePath); + replacements.put("localhost", determineLocalhost()); + + HttpdAddressUtility addressUtility = apacheSetup.getExecutionUtil().getServerComponent() + .getAddressUtility(); + ApacheDirectiveTree runtimeConfig = apacheSetup.getExecutionUtil().getRuntimeConfiguration(); + + replacements.put("snmp.identifier", + addressUtility.getHttpdInternalMainServerAddressRepresentation(runtimeConfig).toString(false, false)); + + String vhost1Address = deploymentConfig.vhost1 == null ? null : deploymentConfig.vhost1.address1.toString( + false, false); + String vhost2Address = deploymentConfig.vhost2 == null ? null : deploymentConfig.vhost2.address1.toString( + false, false); + String vhost3Address = deploymentConfig.vhost3 == null ? null : deploymentConfig.vhost3.address1.toString( + false, false); + String vhost4Address = deploymentConfig.vhost4 == null ? null : deploymentConfig.vhost4.address1.toString( + false, false); + + if (vhost1Address != null) { + replacements.put( + "vhost1.snmp.identifier", + addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost1Address, + deploymentConfig.vhost1.getServerName()).toString(false, false)); + } + + if (vhost2Address != null) { + replacements.put( + "vhost2.snmp.identifier", + addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost2Address, + deploymentConfig.vhost2.getServerName()).toString(false, false)); + } + + if (vhost3Address != null) { + replacements.put( + "vhost3.snmp.identifier", + addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost3Address, + deploymentConfig.vhost3.getServerName()).toString(false, false)); + } + + if (vhost4Address != null) { + replacements.put( + "vhost4.snmp.identifier", + addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost4Address, + deploymentConfig.vhost4.getServerName()).toString(false, false)); + }
InputStream dataStream = getClass().getResourceAsStream(inventoryFile);
@@ -249,18 +327,16 @@ public class UpgradeTest extends PluginContainerTest {
@SuppressWarnings("unchecked") List<Resource> inventory = (List<Resource>) new ObjectCollectionSerializer().deserialize(rdr); - + //fix up the parent relationships, because they might not be reconstructed correctly by //JAXB - we're missing XmlID and XmlIDRef annotations in our model fixupParent(null, inventory); - - fakeInventory.prepopulateInventory(platform, inventory);
- apacheSetup.doSetup(); + fakeInventory.prepopulateInventory(platform, inventory);
return this; } - + private void fixupParent(Resource parent, Collection<Resource> children) { for (Resource child : children) { child.setParentResource(parent); @@ -269,6 +345,14 @@ public class UpgradeTest extends PluginContainerTest { } } } + + private String determineLocalhost() { + try { + return InetAddress.getLocalHost().getCanonicalHostName(); + } catch (UnknownHostException e) { + return "127.0.0.1"; + } + } }
@BeforeClass @@ -281,32 +365,12 @@ public class UpgradeTest extends PluginContainerTest { @Parameters({ "apache2.install.dir", "apache2.exe.path" }) public void shutdownApache(String apacheInstallationDirectory, String exePath) throws Exception {
- File apacheInstallationDir = new File(apacheInstallationDirectory); - File confDir = new File(apacheInstallationDir, "conf"); - //it really doesn't matter which configuration i use here - DeploymentConfig deploymentConfig = ApacheDeploymentUtil - .getDeploymentConfigurationFromSystemProperties(DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES); - - DiscoveryInput discoveryInput = new DiscoveryInput(); - discoveryInput.serverRootPath = apacheInstallationDirectory; - discoveryInput.exePath = exePath; - discoveryInput.httpdConfPath = confDir.getAbsolutePath() + File.separatorChar + "httpd.conf"; - discoveryInput.snmpHost = deploymentConfig.snmpHost; - discoveryInput.snmpPort = deploymentConfig.snmpPort; - - HttpdAddressUtility.Address addr = deploymentConfig.mainServer.address1; - HttpdAddressUtility.Address addrToUse = new HttpdAddressUtility.Address(null, null, - HttpdAddressUtility.Address.NO_PORT_SPECIFIED_VALUE); - addrToUse.scheme = addr.scheme == null ? "http" : addr.scheme; - addrToUse.host = addr.host == null ? "localhost" : addr.host; - addrToUse.port = addr.port; - - discoveryInput.pingUrl = addrToUse.toString(); - - ApacheServerComponent serverComponent = findAndStartServerComponent(discoveryInput); - - serverComponent.invokeOperation("stop", null); + TestSetup.ApacheSetup apacheSetup = new TestSetup(DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES) + .withApacheSetup().withServerRoot(apacheInstallationDirectory).withExePath(exePath) + .withNoDeploymentOnSetup(); + apacheSetup.init(); + apacheSetup.getExecutionUtil().invokeOperation("stop"); }
@PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) @@ -338,7 +402,23 @@ public class UpgradeTest extends PluginContainerTest { assertEquals(server.getResourceKey(), expectedResourceKey, "The server resource key doesn't seem to be upgraded.");
- //TODO test the vhosts + Set<Resource> vhosts = setup.getFakeInventory().findResourcesByType(vhostResourceType); + + assertTrue(vhosts.size() == 5, "There should be 5 vhosts discovered but found " + vhosts.size()); + + List<String> expectedResourceKeys = new ArrayList<String>(5); + + DeploymentConfig dc = setup.getDeploymentConfig(); + + expectedResourceKeys.add(ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY); + expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(dc.vhost1.getServerName(), dc.vhost1.getAddresses())); + expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(dc.vhost2.getServerName(), dc.vhost2.getAddresses())); + expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(dc.vhost3.getServerName(), dc.vhost3.getAddresses())); + expectedResourceKeys.add(ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(dc.vhost4.getServerName(), dc.vhost4.getAddresses())); + + for(Resource vhost : vhosts) { + assertTrue(expectedResourceKeys.contains(vhost.getResourceKey()), "Unexpected virtual host resource key: '" + vhost.getResourceKey() + "'."); + } }
private ResourceType findApachePluginResourceTypeByName(String resourceTypeName) { @@ -391,46 +471,11 @@ public class UpgradeTest extends PluginContainerTest { platform.setResourceType(rt); platform.setUuid(UUID.randomUUID().toString()); platform.setId(1); - + return platform; } }
return null; } - - private ApacheServerComponent findAndStartServerComponent(DiscoveryInput discoveryInput) throws Exception { - ApacheServerDiscoveryComponent discoveryComponent = new ApacheServerDiscoveryComponent(); - - ResourceType resourceType = findApachePluginResourceTypeByName("Apache HTTP Server"); - SystemInfo systemInfo = SystemInfoFactory.createSystemInfo(); - - ResourceDiscoveryContext<PlatformComponent> discoveryContext = new ResourceDiscoveryContext<PlatformComponent>( - resourceType, null, null, systemInfo, null, null, PluginContainerDeployment.AGENT); - - Configuration config = discoveryContext.getDefaultPluginConfiguration(); - config.put(new PropertySimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_SERVER_ROOT, - discoveryInput.serverRootPath)); - config - .put(new PropertySimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_EXECUTABLE_PATH, discoveryInput.exePath)); - config - .put(new PropertySimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_HTTPD_CONF, discoveryInput.httpdConfPath)); - config - .put(new PropertySimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_SNMP_AGENT_HOST, discoveryInput.snmpHost)); - config - .put(new PropertySimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_SNMP_AGENT_PORT, discoveryInput.snmpPort)); - config.put(new PropertySimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_URL, discoveryInput.pingUrl)); - - DiscoveredResourceDetails result = discoveryComponent.discoverResource(config, discoveryContext); - - ApacheServerComponent serverComponent = new ApacheServerComponent(); - - Resource resource = new Resource(result.getResourceKey(), null, resourceType); - resource.setPluginConfiguration(config); - ResourceContext<PlatformComponent> resourceContext = new ResourceContext<PlatformComponent>(resource, null, - null, systemInfo, null, null, null, null, null, null, null, null); - - serverComponent.start(resourceContext); - return serverComponent; - } } diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java index 2a19526..3893b56 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java @@ -49,6 +49,7 @@ public class ApacheDeploymentUtil { private static final String SERVER_ROOT = "server.root"; private static final String ADDITIONAL_DIRECTIVES = "additional.directives"; private static final String SERVERNAME_DIRECTIVE = "servername.directive"; + private static final String SERVERNAME = "servername"; private static final String LISTEN4 = "listen4"; private static final String LISTEN3 = "listen3"; private static final String LISTEN2 = "listen2"; @@ -71,6 +72,41 @@ public class ApacheDeploymentUtil { public String serverNameDirective = null; public final List<String> additionalDirectives = new ArrayList<String>();
+ public String getServerName() { + String serverName = null; + if (serverNameDirective != null) { + int startIdx = serverNameDirective.indexOf(' '); + if (startIdx >= 0) { + while (serverNameDirective.charAt(startIdx) == ' ') { + ++startIdx; + } + + serverName = serverNameDirective.substring(startIdx); + serverName = serverName.trim(); + } + } + + return serverName; + } + + public List<String> getAddresses() { + ArrayList<String> ret = new ArrayList<String>(); + if (address1 != null) { + ret.add(address1.toString()); + } + if (address2 != null) { + ret.add(address2.toString()); + } + if (address3 != null) { + ret.add(address3.toString()); + } + if (address4 != null) { + ret.add(address4.toString()); + } + + return ret; + } + private void addToTokenReplacements(int ordinal, Map<String, String> tokenReplacements) { String prefix = null;
@@ -82,6 +118,11 @@ public class ApacheDeploymentUtil {
tokenReplacements.put(prefix + SERVERNAME_DIRECTIVE, serverNameDirective == null ? "" : serverNameDirective);
+ String serverName = getServerName(); + if (serverName != null) { + tokenReplacements.put(prefix + SERVERNAME, serverName); + } + String dirs = ""; if (!additionalDirectives.isEmpty()) { String newline = System.getProperty("line.separator"); diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheExecutionUtil.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheExecutionUtil.java new file mode 100644 index 0000000..e8b5e51 --- /dev/null +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheExecutionUtil.java @@ -0,0 +1,147 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.plugins.apache.util; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.domain.configuration.PropertySimple; +import org.rhq.core.domain.resource.ProcessScan; +import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.resource.ResourceType; +import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; +import org.rhq.core.pluginapi.inventory.PluginContainerDeployment; +import org.rhq.core.pluginapi.inventory.ProcessScanResult; +import org.rhq.core.pluginapi.inventory.ResourceContext; +import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; +import org.rhq.core.system.ProcessInfo; +import org.rhq.core.system.SystemInfo; +import org.rhq.core.system.SystemInfoFactory; +import org.rhq.core.system.pquery.ProcessInfoQuery; +import org.rhq.plugins.apache.ApacheServerComponent; +import org.rhq.plugins.apache.ApacheServerDiscoveryComponent; +import org.rhq.plugins.apache.parser.ApacheDirectiveTree; +import org.rhq.plugins.platform.PlatformComponent; + +/** + * + * + * @author Lukas Krejci + */ +public class ApacheExecutionUtil { + + private ResourceType apacheServerResourceType; + private ApacheServerComponent serverComponent; + private ResourceContext<PlatformComponent> resourceContext; + private String serverRootPath; + private String exePath; + private String httpdConfPath; + private String snmpHost; + private int snmpPort; + private String pingUrl; + + public ApacheExecutionUtil(ResourceType apacheServerResourceType, String serverRootPath, String exePath, + String httpdConfPath, String pingUrl, String snmpHost, int snmpPort) { + + this.apacheServerResourceType = apacheServerResourceType; + this.serverRootPath = serverRootPath; + this.exePath = exePath; + this.httpdConfPath = httpdConfPath; + this.snmpHost = snmpHost; + this.snmpPort = snmpPort; + this.pingUrl = pingUrl; + } + + public void init() throws Exception { + ApacheServerDiscoveryComponent discoveryComponent = new ApacheServerDiscoveryComponent(); + + SystemInfo systemInfo = SystemInfoFactory.createSystemInfo(); + + ResourceDiscoveryContext<PlatformComponent> discoveryContext = new ResourceDiscoveryContext<PlatformComponent>( + apacheServerResourceType, null, null, systemInfo, scanProcesses(systemInfo), null, + PluginContainerDeployment.AGENT); + + Configuration config = discoveryContext.getDefaultPluginConfiguration(); + config.put(new PropertySimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_SERVER_ROOT, serverRootPath)); + config.put(new PropertySimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_EXECUTABLE_PATH, exePath)); + config.put(new PropertySimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_HTTPD_CONF, httpdConfPath)); + config.put(new PropertySimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_SNMP_AGENT_HOST, snmpHost)); + config.put(new PropertySimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_SNMP_AGENT_PORT, snmpPort)); + config.put(new PropertySimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_URL, pingUrl)); + + DiscoveredResourceDetails result = discoveryComponent.discoverResource(config, discoveryContext); + + serverComponent = new ApacheServerComponent(); + + Resource resource = new Resource(result.getResourceKey(), null, apacheServerResourceType); + resource.setPluginConfiguration(config); + resourceContext = new ResourceContext<PlatformComponent>(resource, null, + discoveryComponent, systemInfo, null, null, null, null, null, null, null, null); + + serverComponent.start(resourceContext); + } + + public void invokeOperation(String... operationAndBackupOpsInCaseOfFailure) throws Exception { + Exception lastError = null; + for (String op : operationAndBackupOpsInCaseOfFailure) { + try { + serverComponent.invokeOperation(op, new Configuration()); + return; + } catch (Exception e) { + lastError = e; + } + } + + throw lastError; + } + + public ResourceContext<PlatformComponent> getResourceContext() { + return resourceContext; + } + + public ApacheDirectiveTree getRuntimeConfiguration() { + ApacheDirectiveTree config = serverComponent.loadParser(); + return RuntimeApacheConfiguration.extract(config, resourceContext.getNativeProcess(), new ApacheBinaryInfo( + exePath), serverComponent.getModuleNames(), true); + } + + public ApacheServerComponent getServerComponent() { + return serverComponent; + } + + private List<ProcessScanResult> scanProcesses(SystemInfo systemInfo) { + List<ProcessScanResult> scanResults = new ArrayList<ProcessScanResult>(); + Set<ProcessScan> processScans = apacheServerResourceType.getProcessScans(); + if (processScans != null && !processScans.isEmpty()) { + ProcessInfoQuery piq = new ProcessInfoQuery(systemInfo.getAllProcesses()); + for (ProcessScan processScan : processScans) { + List<ProcessInfo> queryResults = piq.query(processScan.getQuery()); + if ((queryResults != null) && (queryResults.size() > 0)) { + for (ProcessInfo autoDiscoveredProcess : queryResults) { + scanResults.add(new ProcessScanResult(processScan, autoDiscoveredProcess)); + } + } + } + } + return scanResults; + } +}
commit 76a248c78fe8f104cc6305613a82d1fccf468d07 Author: Lukas Krejci lkrejci@redhat.com Date: Fri Jun 17 16:37:37 2011 +0200
Don't create a new collection whenever Configuration.getProperties() is called. We can get away with just a single instance.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java index ce88dce..099041c 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java @@ -156,6 +156,82 @@ public class Configuration implements Serializable, Cloneable, AbstractPropertyM @XmlTransient private Map<String, Property> properties = new LinkedHashMap<String, Property>();
+ private class PropertiesProxy implements Collection<Property> { + + public int size() { + return properties.size(); + } + + public boolean isEmpty() { + return properties.isEmpty(); + } + + public boolean contains(Object o) { + return properties.containsValue(o); + } + + public Iterator<Property> iterator() { + return properties.values().iterator(); + } + + public Object[] toArray() { + return properties.values().toArray(); + } + + public <T> T[] toArray(T[] a) { + return properties.values().toArray(a); + } + + public boolean add(Property e) { + put(e); + return true; //we always allow adding an element even if it is already present + } + + public boolean remove(Object o) { + return properties.values().remove(o); + } + + public boolean containsAll(Collection<?> c) { + return properties.values().containsAll(c); + } + + public boolean addAll(Collection<? extends Property> c) { + boolean ret = false; + for(Property p : c) { + ret = ret || add(p); + } + + return ret; + } + + public boolean removeAll(Collection<?> c) { + boolean ret = false; + for(Object o : c) { + ret = ret || remove(o); + } + + return ret; + } + + public boolean retainAll(Collection<?> c) { + boolean ret = false; + ArrayList<Property> ps = new ArrayList<Property>(properties.values()); + for(Property p : ps) { + if (!c.contains(p)) { + ret = ret || remove(p); + } + } + + return ret; + } + + public void clear() { + properties.clear(); + } + } + + private transient PropertiesProxy propertiesProxy = new PropertiesProxy(); + @OneToMany(mappedBy = "configuration", fetch = FetchType.EAGER) @Cascade( { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.DELETE_ORPHAN }) private Set<RawConfiguration> rawConfigurations = new HashSet<RawConfiguration>(); @@ -337,79 +413,7 @@ public class Configuration implements Serializable, Cloneable, AbstractPropertyM @XmlElementRef(name = "PropertySimple", type = PropertySimple.class), @XmlElementRef(name = "PropertyMap", type = PropertyMap.class) }) public Collection<Property> getProperties() { - return new Collection<Property>() { - - public int size() { - return properties.size(); - } - - public boolean isEmpty() { - return properties.isEmpty(); - } - - public boolean contains(Object o) { - return properties.containsValue(o); - } - - public Iterator<Property> iterator() { - return properties.values().iterator(); - } - - public Object[] toArray() { - return properties.values().toArray(); - } - - public <T> T[] toArray(T[] a) { - return properties.values().toArray(a); - } - - public boolean add(Property e) { - put(e); - return true; //we always allow adding an element even if it is already present - } - - public boolean remove(Object o) { - return properties.values().remove(o); - } - - public boolean containsAll(Collection<?> c) { - return properties.values().containsAll(c); - } - - public boolean addAll(Collection<? extends Property> c) { - boolean ret = false; - for(Property p : c) { - ret = ret || add(p); - } - - return ret; - } - - public boolean removeAll(Collection<?> c) { - boolean ret = false; - for(Object o : c) { - ret = ret || remove(o); - } - - return ret; - } - - public boolean retainAll(Collection<?> c) { - boolean ret = false; - ArrayList<Property> ps = new ArrayList<Property>(properties.values()); - for(Property p : ps) { - if (!c.contains(p)) { - ret = ret || remove(p); - } - } - - return ret; - } - - public void clear() { - properties.clear(); - } - }; + return propertiesProxy; }
public void setProperties(Collection<Property> properties) {
commit bc40722aaf2000731f003968bd97a3b09247c304 Author: Lukas Krejci lkrejci@redhat.com Date: Thu Jun 16 12:17:01 2011 +0200
Modifying the basic apache test to shutdown the plugin container after its finished and not to pollute the source dir outside of target directory.
diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/ApachePluginTest.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/ApachePluginTest.java index 5a6cc7e..af99d04 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/ApachePluginTest.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/ApachePluginTest.java @@ -25,7 +25,10 @@ import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; + +import org.testng.annotations.AfterClass; import org.testng.annotations.AfterSuite; +import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; import org.rhq.core.clientapi.server.discovery.InventoryReport; @@ -50,16 +53,19 @@ import org.rhq.core.pluginapi.measurement.MeasurementFacet; public class ApachePluginTest { private static final String PLUGIN_NAME = "Apache";
- @BeforeSuite + @BeforeClass public void start() { //System.out.println("java.class.path=" + System.getProperty("java.class.path")); //System.out.println("java.library.path=" + System.getProperty("java.library.path")); try { File pluginDir = new File("target/itest/plugins"); + File dataDir = new File("target/itest/plugins-data"); + dataDir.mkdir(); PluginContainerConfiguration pcConfig = new PluginContainerConfiguration(); pcConfig.setPluginFinder(new FileSystemPluginFinder(pluginDir)); pcConfig.setPluginDirectory(pluginDir); - + pcConfig.setDataDirectory(dataDir); + pcConfig.setInsideAgent(false); PluginContainer.getInstance().setConfiguration(pcConfig); PluginContainer container = PluginContainer.getInstance(); @@ -77,7 +83,7 @@ public class ApachePluginTest { } }
- @AfterSuite + @AfterClass public void stop() { PluginContainer.getInstance().shutdown(); }
commit ec20fdd0a1645d47461922553c1aed0a9c2bf01f Author: Lukas Krejci lkrejci@redhat.com Date: Thu Jun 16 12:15:36 2011 +0200
removing a temp file
diff --git a/modules/helpers/inventory-serializer/inventory-rhq-1.3.0.xml b/modules/helpers/inventory-serializer/inventory-rhq-1.3.0.xml deleted file mode 100644 index 792c742..0000000 --- a/modules/helpers/inventory-serializer/inventory-rhq-1.3.0.xml +++ /dev/null @@ -1,544 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<inventory-dump> -<classes-used> -<class>org.rhq.core.domain.resource.Resource</class> -</classes-used> -<objects> - -<resource> - <id>10004</id> - <uuid>ae8a7a3e-256e-4c0a-9a65-33d534523d92</uuid> - <resourceKey>/home/metlos/Progs/apache-2.2.17/build</resourceKey> - <name>localhost.localdomain Apache 2.2.17 (/home/metlos/Progs/apache-2.2.17/build/)</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>true</connected> - <version>2.2.17</version> - <description>Apache Web Server</description> - <ctime>1307353451273</ctime> - <mtime>1307353509168</mtime> - <itime>1307353509168</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVER</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <description>an Apache HTTP Server instance</description> - <id>10013</id> - <name>Apache HTTP Server</name> - <plugin>Apache</plugin> - <pluginConfigurationDefinition> - <id>10012</id> - <propertyDefinitions/> - </pluginConfigurationDefinition> - <singleton>false</singleton> - <supportsManualAdd>true</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10142</id> - <version>0</version> - <ctime>1307353451273</ctime> - <mtime>1307353451273</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10073</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353737118</ctime> - <mtime>1307353737118</mtime> - <propertySimple> - <id>10365</id> - <name>errorLogMinimumSeverity</name> - <override>false</override> - <stringValue>error</stringValue> - </propertySimple> - <propertySimple> - <id>10366</id> - <name>errorLogIncludesPattern</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10367</id> - <name>snmpAgentCommunity</name> - <override>false</override> - <stringValue>public</stringValue> - </propertySimple> - <propertySimple> - <id>10368</id> - <name>errorLogFilePath</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10369</id> - <name>errorLogEventsEnabled</name> - <override>false</override> - <stringValue>false</stringValue> - </propertySimple> - <propertySimple> - <id>10370</id> - <name>snmpAgentHost</name> - <override>false</override> - <stringValue>127.0.0.1</stringValue> - </propertySimple> - <propertySimple> - <id>10713</id> - <name>controlScriptPath</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10714</id> - <name>url</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10364</id> - <name>configFile</name> - <override>false</override> - <stringValue>conf/httpd.conf</stringValue> - </propertySimple> - <propertySimple> - <id>10711</id> - <name>executablePath</name> - <override>false</override> - <stringValue>/home/metlos/Progs/apache-2.2.17/build/bin/httpd</stringValue> - </propertySimple> - <propertySimple> - <id>10712</id> - <name>snmpAgentPort</name> - <override>false</override> - <stringValue>1610</stringValue> - </propertySimple> - <propertySimple> - <id>10715</id> - <name>serverRoot</name> - <override>false</override> - <stringValue>/home/metlos/Progs/apache-2.2.17/build</stringValue> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> - <productVersion> - <id>10003</id> - </productVersion> -</resource> - -<resource> - <id>10021</id> - <uuid>3a20d809-7eba-422c-a3ef-baf65804498d</uuid> - <resourceKey>127.0.0.1:11676</resourceKey> - <name>Virtual Host 127.0.0.1:11676</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> - <ctime>1307353587648</ctime> - <mtime>1307353587648</mtime> - <itime>1307353587648</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10014</id> - <name>Apache Virtual Host</name> - <plugin>Apache</plugin> - <pluginConfigurationDefinition> - <id>10013</id> - <propertyDefinitions/> - </pluginConfigurationDefinition> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10135</id> - <version>0</version> - <ctime>1307353587666</ctime> - <mtime>1307353587666</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10136</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353587667</ctime> - <mtime>1307353587667</mtime> - <propertySimple> - <id>10685</id> - <name>responseTimeUrlExcludes</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10684</id> - <name>responseTimeLogFile</name> - <override>false</override> - <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/127.0.0.111676_rt.log</stringValue> - </propertySimple> - <propertySimple> - <id>10687</id> - <name>url</name> - <override>false</override> - <stringValue>http://127.0.0.1:11676/</stringValue> - </propertySimple> - <propertySimple> - <id>10688</id> - <name>snmpWwwServiceIndex</name> - <override>false</override> - <stringValue>4</stringValue> - </propertySimple> - <propertySimple> - <id>10686</id> - <name>responseTimeUrlTransforms</name> - <override>false</override> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> -</resource> - -<resource> - <id>10022</id> - <uuid>08290193-c716-4363-b841-8a1d9d83f580</uuid> - <resourceKey>localhost.localdomain:0</resourceKey> - <name>Virtual Host localhost.localdomain:0</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> - <ctime>1307353587727</ctime> - <mtime>1307353587727</mtime> - <itime>1307353587721</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10014</id> - <name>Apache Virtual Host</name> - <plugin>Apache</plugin> - <pluginConfigurationDefinition> - <id>10013</id> - <propertyDefinitions/> - </pluginConfigurationDefinition> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10137</id> - <version>0</version> - <ctime>1307353587728</ctime> - <mtime>1307353587728</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10138</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353587728</ctime> - <mtime>1307353587728</mtime> - <propertySimple> - <id>10690</id> - <name>responseTimeUrlExcludes</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10689</id> - <name>responseTimeLogFile</name> - <override>false</override> - <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/localhost.localdomain0_rt.log</stringValue> - </propertySimple> - <propertySimple> - <id>10692</id> - <name>url</name> - <override>false</override> - <stringValue>http://localhost.localdomain:0/</stringValue> - </propertySimple> - <propertySimple> - <id>10693</id> - <name>snmpWwwServiceIndex</name> - <override>false</override> - <stringValue>1</stringValue> - </propertySimple> - <propertySimple> - <id>10691</id> - <name>responseTimeUrlTransforms</name> - <override>false</override> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>DOWN</availabilityType> - </currentAvailability> -</resource> - -<resource> - <id>10023</id> - <uuid>c62c5d75-81dd-4b14-a768-2d8c1fca6c88</uuid> - <resourceKey>127.0.0.1:11677</resourceKey> - <name>Virtual Host 127.0.0.1:11677</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> - <ctime>1307353587738</ctime> - <mtime>1307353587738</mtime> - <itime>1307353587737</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10014</id> - <name>Apache Virtual Host</name> - <plugin>Apache</plugin> - <pluginConfigurationDefinition> - <id>10013</id> - <propertyDefinitions/> - </pluginConfigurationDefinition> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10139</id> - <version>0</version> - <ctime>1307353587738</ctime> - <mtime>1307353587738</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10140</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353587738</ctime> - <mtime>1307353587738</mtime> - <propertySimple> - <id>10695</id> - <name>responseTimeUrlExcludes</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10694</id> - <name>responseTimeLogFile</name> - <override>false</override> - <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/127.0.0.111677_rt.log</stringValue> - </propertySimple> - <propertySimple> - <id>10697</id> - <name>url</name> - <override>false</override> - <stringValue>http://127.0.0.1:11677/</stringValue> - </propertySimple> - <propertySimple> - <id>10698</id> - <name>snmpWwwServiceIndex</name> - <override>false</override> - <stringValue>3</stringValue> - </propertySimple> - <propertySimple> - <id>10696</id> - <name>responseTimeUrlTransforms</name> - <override>false</override> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> -</resource> - -<resource> - <id>10024</id> - <uuid>d1b59168-8666-4bc0-957e-171bf16eec73</uuid> - <resourceKey>127.0.0.1:11675</resourceKey> - <name>Virtual Host 127.0.0.1:11675</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> - <ctime>1307353587751</ctime> - <mtime>1307353587751</mtime> - <itime>1307353587750</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10014</id> - <name>Apache Virtual Host</name> - <plugin>Apache</plugin> - <pluginConfigurationDefinition> - <id>10013</id> - <propertyDefinitions/> - </pluginConfigurationDefinition> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10171</id> - <version>0</version> - <ctime>1307353587751</ctime> - <mtime>1307353587751</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10172</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353587751</ctime> - <mtime>1307353587751</mtime> - <propertySimple> - <id>10700</id> - <name>responseTimeUrlExcludes</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10699</id> - <name>responseTimeLogFile</name> - <override>false</override> - <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/127.0.0.111675_rt.log</stringValue> - </propertySimple> - <propertySimple> - <id>10702</id> - <name>url</name> - <override>false</override> - <stringValue>http://127.0.0.1:11675/</stringValue> - </propertySimple> - <propertySimple> - <id>10703</id> - <name>snmpWwwServiceIndex</name> - <override>false</override> - <stringValue>5</stringValue> - </propertySimple> - <propertySimple> - <id>10701</id> - <name>responseTimeUrlTransforms</name> - <override>false</override> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> -</resource> - -<resource> - <id>10025</id> - <uuid>310281d2-60c6-4d7d-bcdc-c51d7969c906</uuid> - <resourceKey>127.0.0.1:11678</resourceKey> - <name>Virtual Host 127.0.0.1:11678</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> - <ctime>1307353587761</ctime> - <mtime>1307353587761</mtime> - <itime>1307353587760</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10014</id> - <name>Apache Virtual Host</name> - <plugin>Apache</plugin> - <pluginConfigurationDefinition> - <id>10013</id> - <propertyDefinitions/> - </pluginConfigurationDefinition> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10173</id> - <version>0</version> - <ctime>1307353587761</ctime> - <mtime>1307353587761</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10174</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353587761</ctime> - <mtime>1307353587761</mtime> - <propertySimple> - <id>10705</id> - <name>responseTimeUrlExcludes</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10704</id> - <name>responseTimeLogFile</name> - <override>false</override> - <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/127.0.0.111678_rt.log</stringValue> - </propertySimple> - <propertySimple> - <id>10707</id> - <name>url</name> - <override>false</override> - <stringValue>http://127.0.0.1:11678/</stringValue> - </propertySimple> - <propertySimple> - <id>10708</id> - <name>snmpWwwServiceIndex</name> - <override>false</override> - <stringValue>2</stringValue> - </propertySimple> - <propertySimple> - <id>10706</id> - <name>responseTimeUrlTransforms</name> - <override>false</override> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> -</resource> -</objects> -</inventory-dump>
commit da3f626dae8ac26fbd9e8acc985a60dad0418f95 Author: Lukas Krejci lkrejci@redhat.com Date: Thu Jun 16 12:08:06 2011 +0200
regenerated the persisted inventory to include the child resources so that it is more easily reconstructed in the proper resource hierarchy.
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java index 1daad90..0f13e29 100644 --- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java +++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java @@ -84,8 +84,9 @@ public class FakeServerInventory { }
public synchronized void prepopulateInventory(Resource platform, Collection<Resource> topLevelServers) { - this.platform = platform; + this.platform = fakePersist(platform, InventoryStatus.COMMITTED, new HashSet<String>()); for (Resource res : topLevelServers) { + res.setParentResource(this.platform); fakePersist(res, InventoryStatus.COMMITTED, new HashSet<String>()); } } @@ -277,8 +278,10 @@ public class FakeServerInventory {
Resource parent = agentSideResource.getParentResource(); if (parent != null && parent != Resource.ROOT) { - persisted.setParentResource(fakePersist(agentSideResource.getParentResource(), requiredInventoryStatus, - inProgressUUIds)); + parent = fakePersist(agentSideResource.getParentResource(), requiredInventoryStatus, + inProgressUUIds); + persisted.setParentResource(parent); + parent.getChildResources().add(persisted); } else { persisted.setParentResource(parent); } diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java index e539eaa..2492cb7 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java @@ -23,7 +23,6 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue;
import java.io.File; -import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; @@ -35,9 +34,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; - -import javax.xml.bind.JAXBException; -import javax.xml.stream.XMLStreamException; +import java.util.UUID;
import org.jmock.Expectations; import org.testng.annotations.AfterClass; @@ -48,10 +45,10 @@ import org.testng.annotations.Test; import org.rhq.core.clientapi.agent.metadata.PluginMetadataParser; import org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil; import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor; -import org.rhq.core.clientapi.server.discovery.InvalidInventoryReportException; import org.rhq.core.clientapi.server.discovery.InventoryReport; import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.PropertySimple; +import org.rhq.core.domain.discovery.AvailabilityReport; import org.rhq.core.domain.resource.InventoryStatus; import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.ResourceType; @@ -78,7 +75,7 @@ import org.rhq.test.pc.PluginContainerTest; * * @author Lukas Krejci */ -@Test +@Test(groups = "apache-integration-tests") public class UpgradeTest extends PluginContainerTest {
private static final String PLATFORM_PLUGIN = "file:target/itest/plugins/rhq-platform-plugin-for-apache-test.jar"; @@ -211,21 +208,32 @@ public class UpgradeTest extends PluginContainerTest { }
public TestSetup withDefaultExpectations() throws Exception { - final ServerServices ss = getCurrentPluginContainerConfiguration().getServerServices(); - context.checking(new Expectations() { { - allowing(ss.getDiscoveryServerService()).mergeInventoryReport(with(any(InventoryReport.class))); - will(fakeInventory.mergeInventoryReport(InventoryStatus.COMMITTED)); - - allowing(ss.getDiscoveryServerService()).upgradeResources(with(any(Set.class))); - will(fakeInventory.upgradeResources()); + addDefaultExceptations(this); } });
return this; }
+ @SuppressWarnings("unchecked") + public void addDefaultExceptations(Expectations expectations) throws Exception { + ServerServices ss = getCurrentPluginContainerConfiguration().getServerServices(); + + expectations.allowing(ss.getDiscoveryServerService()).mergeInventoryReport(expectations.with(Expectations.any(InventoryReport.class))); + expectations.will(fakeInventory.mergeInventoryReport(InventoryStatus.COMMITTED)); + + expectations.allowing(ss.getDiscoveryServerService()).upgradeResources(expectations.with(Expectations.any(Set.class))); + expectations.will(fakeInventory.upgradeResources()); + + expectations.allowing(ss.getDiscoveryServerService()).getResources(expectations.with(Expectations.any(Set.class)), expectations.with(Expectations.any(boolean.class))); + expectations.will(fakeInventory.getResources()); + + expectations.allowing(ss.getDiscoveryServerService()).mergeAvailabilityReport(expectations.with(Expectations.any(AvailabilityReport.class))); + expectations.allowing(ss.getDiscoveryServerService()).postProcessNewlyCommittedResources(expectations.with(Expectations.any(Set.class))); + } + public FakeServerInventory getFakeInventory() { return fakeInventory; } @@ -241,14 +249,26 @@ public class UpgradeTest extends PluginContainerTest {
@SuppressWarnings("unchecked") List<Resource> inventory = (List<Resource>) new ObjectCollectionSerializer().deserialize(rdr); - - fakeInventory = new FakeServerInventory(); + + //fix up the parent relationships, because they might not be reconstructed correctly by + //JAXB - we're missing XmlID and XmlIDRef annotations in our model + fixupParent(null, inventory); + fakeInventory.prepopulateInventory(platform, inventory);
apacheSetup.doSetup();
return this; } + + private void fixupParent(Resource parent, Collection<Resource> children) { + for (Resource child : children) { + child.setParentResource(parent); + if (child.getChildResources() != null) { + fixupParent(child, child.getChildResources()); + } + } + } }
@BeforeClass @@ -312,11 +332,11 @@ public class UpgradeTest extends PluginContainerTest {
Resource server = servers.iterator().next();
-// String expectedResourceKey = ApacheServerDiscoveryComponent.formatResourceKey(apacheInstallationDirectory, -// apacheInstallationDirectory + "/conf/httpd.conf"); -// -// assertEquals(server.getResourceKey(), expectedResourceKey, -// "The server resource key doesn't seem to be upgraded."); + String expectedResourceKey = ApacheServerDiscoveryComponent.formatResourceKey(apacheInstallationDirectory, + apacheInstallationDirectory + "/conf/httpd.conf"); + + assertEquals(server.getResourceKey(), expectedResourceKey, + "The server resource key doesn't seem to be upgraded.");
//TODO test the vhosts } @@ -369,7 +389,9 @@ public class UpgradeTest extends PluginContainerTest { platform.setVersion(details.getResourceVersion()); platform.setPluginConfiguration(details.getPluginConfiguration()); platform.setResourceType(rt); - + platform.setUuid(UUID.randomUUID().toString()); + platform.setId(1); + return platform; } } diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/generating.query b/modules/plugins/apache/src/test/resources/mocked-inventories/generating.query new file mode 100644 index 0000000..f7f3140 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/generating.query @@ -0,0 +1 @@ +SELECT DISTINCT r FROM org.rhq.core.domain.resource.Resource r INNER JOIN FETCH r.pluginConfiguration INNER JOIN FETCH r.resourceConfiguration INNER JOIN FETCH r.childResources ch INNER JOIN FETCH ch.pluginConfiguration INNER JOIN FETCH ch.resourceConfiguration WHERE r.resourceType.name = 'Apache HTTP Server' diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/includes/inventory.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/includes/inventory.xml index 1aabda1..c3a82eb 100644 --- a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/includes/inventory.xml +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/includes/inventory.xml @@ -9,7 +9,7 @@ <id>10004</id> <uuid>ae8a7a3e-256e-4c0a-9a65-33d534523d92</uuid> <resourceKey>${server.root}</resourceKey> - <name>localhost.localdomain Apache 2.2.17 (${server.root}/)</name> + <name>${localhost} Apache 2.2.17 (${server.root}/)</name> <inventoryStatus>COMMITTED</inventoryStatus> <connected>true</connected> <version>2.2.17</version> @@ -37,6 +37,411 @@ <singleton>false</singleton> <supportsManualAdd>true</supportsManualAdd> </resourceType> + <childResources> + <id>10022</id> + <uuid>08290193-c716-4363-b841-8a1d9d83f580</uuid> + <resourceKey>${localhost}:0</resourceKey> + <name>Virtual Host ${localhost}:0</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587727</ctime> + <mtime>1307353587727</mtime> + <itime>1307353587721</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10137</id> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10138</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + <propertySimple> + <id>10690</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10689</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/${localhost}0_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10692</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Blocalhost%7D:0/</stringValue> + </propertySimple> + <propertySimple> + <id>10693</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>1</stringValue> + </propertySimple> + <propertySimple> + <id>10691</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>DOWN</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10021</id> + <uuid>3a20d809-7eba-422c-a3ef-baf65804498d</uuid> + <resourceKey>${vhost2.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost2.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587648</ctime> + <mtime>1307353587648</mtime> + <itime>1307353587648</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10135</id> + <version>0</version> + <ctime>1307353587666</ctime> + <mtime>1307353587666</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10136</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587667</ctime> + <mtime>1307353587667</mtime> + <propertySimple> + <id>10685</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10684</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111676_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10687</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost2.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10688</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>4</stringValue> + </propertySimple> + <propertySimple> + <id>10686</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10023</id> + <uuid>c62c5d75-81dd-4b14-a768-2d8c1fca6c88</uuid> + <resourceKey>${vhost3.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost3.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + <itime>1307353587737</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10139</id> + <version>0</version> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10140</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + <propertySimple> + <id>10695</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10694</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111677_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10697</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost3.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10698</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>3</stringValue> + </propertySimple> + <propertySimple> + <id>10696</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10024</id> + <uuid>d1b59168-8666-4bc0-957e-171bf16eec73</uuid> + <resourceKey>${vhost1.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost1.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + <itime>1307353587750</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10171</id> + <version>0</version> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10172</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + <propertySimple> + <id>10700</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10699</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10702</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost1.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10703</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>5</stringValue> + </propertySimple> + <propertySimple> + <id>10701</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> + <childResources> + <id>10025</id> + <uuid>310281d2-60c6-4d7d-bcdc-c51d7969c906</uuid> + <resourceKey>${vhost4.snmp.identifier}</resourceKey> + <name>Virtual Host ${vhost4.snmp.identifier}</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + <itime>1307353587760</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10173</id> + <version>0</version> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10174</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + <propertySimple> + <id>10705</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10704</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10707</id> + <name>url</name> + <override>false</override> + <stringValue>http://$%7Bvhost4.snmp.identifier%7D/</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>2</stringValue> + </propertySimple> + <propertySimple> + <id>10706</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + </childResources> <resourceConfiguration> <id>10142</id> <version>0</version> @@ -130,415 +535,5 @@ <id>10003</id> </productVersion> </resource> - -<resource> - <id>10021</id> - <uuid>3a20d809-7eba-422c-a3ef-baf65804498d</uuid> - <resourceKey>127.0.0.1:11676</resourceKey> - <name>Virtual Host 127.0.0.1:11676</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> - <ctime>1307353587648</ctime> - <mtime>1307353587648</mtime> - <itime>1307353587648</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10014</id> - <name>Apache Virtual Host</name> - <plugin>Apache</plugin> - <pluginConfigurationDefinition> - <id>10013</id> - <propertyDefinitions/> - </pluginConfigurationDefinition> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10135</id> - <version>0</version> - <ctime>1307353587666</ctime> - <mtime>1307353587666</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10136</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353587667</ctime> - <mtime>1307353587667</mtime> - <propertySimple> - <id>10685</id> - <name>responseTimeUrlExcludes</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10684</id> - <name>responseTimeLogFile</name> - <override>false</override> - <stringValue>${server.root}/logs/127.0.0.111676_rt.log</stringValue> - </propertySimple> - <propertySimple> - <id>10687</id> - <name>url</name> - <override>false</override> - <stringValue>http://127.0.0.1:11676/</stringValue> - </propertySimple> - <propertySimple> - <id>10688</id> - <name>snmpWwwServiceIndex</name> - <override>false</override> - <stringValue>4</stringValue> - </propertySimple> - <propertySimple> - <id>10686</id> - <name>responseTimeUrlTransforms</name> - <override>false</override> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> -</resource> - -<resource> - <id>10022</id> - <uuid>08290193-c716-4363-b841-8a1d9d83f580</uuid> - <resourceKey>localhost.localdomain:0</resourceKey> - <name>Virtual Host localhost.localdomain:0</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> - <ctime>1307353587727</ctime> - <mtime>1307353587727</mtime> - <itime>1307353587721</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10014</id> - <name>Apache Virtual Host</name> - <plugin>Apache</plugin> - <pluginConfigurationDefinition> - <id>10013</id> - <propertyDefinitions/> - </pluginConfigurationDefinition> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10137</id> - <version>0</version> - <ctime>1307353587728</ctime> - <mtime>1307353587728</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10138</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353587728</ctime> - <mtime>1307353587728</mtime> - <propertySimple> - <id>10690</id> - <name>responseTimeUrlExcludes</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10689</id> - <name>responseTimeLogFile</name> - <override>false</override> - <stringValue>${server.root}/logs/localhost.localdomain0_rt.log</stringValue> - </propertySimple> - <propertySimple> - <id>10692</id> - <name>url</name> - <override>false</override> - <stringValue>http://localhost.localdomain:0/</stringValue> - </propertySimple> - <propertySimple> - <id>10693</id> - <name>snmpWwwServiceIndex</name> - <override>false</override> - <stringValue>1</stringValue> - </propertySimple> - <propertySimple> - <id>10691</id> - <name>responseTimeUrlTransforms</name> - <override>false</override> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>DOWN</availabilityType> - </currentAvailability> -</resource> - -<resource> - <id>10023</id> - <uuid>c62c5d75-81dd-4b14-a768-2d8c1fca6c88</uuid> - <resourceKey>127.0.0.1:11677</resourceKey> - <name>Virtual Host 127.0.0.1:11677</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> - <ctime>1307353587738</ctime> - <mtime>1307353587738</mtime> - <itime>1307353587737</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10014</id> - <name>Apache Virtual Host</name> - <plugin>Apache</plugin> - <pluginConfigurationDefinition> - <id>10013</id> - <propertyDefinitions/> - </pluginConfigurationDefinition> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10139</id> - <version>0</version> - <ctime>1307353587738</ctime> - <mtime>1307353587738</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10140</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353587738</ctime> - <mtime>1307353587738</mtime> - <propertySimple> - <id>10695</id> - <name>responseTimeUrlExcludes</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10694</id> - <name>responseTimeLogFile</name> - <override>false</override> - <stringValue>${server.root}/logs/127.0.0.111677_rt.log</stringValue> - </propertySimple> - <propertySimple> - <id>10697</id> - <name>url</name> - <override>false</override> - <stringValue>http://127.0.0.1:11677/</stringValue> - </propertySimple> - <propertySimple> - <id>10698</id> - <name>snmpWwwServiceIndex</name> - <override>false</override> - <stringValue>3</stringValue> - </propertySimple> - <propertySimple> - <id>10696</id> - <name>responseTimeUrlTransforms</name> - <override>false</override> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> -</resource> - -<resource> - <id>10024</id> - <uuid>d1b59168-8666-4bc0-957e-171bf16eec73</uuid> - <resourceKey>127.0.0.1:11675</resourceKey> - <name>Virtual Host 127.0.0.1:11675</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> - <ctime>1307353587751</ctime> - <mtime>1307353587751</mtime> - <itime>1307353587750</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10014</id> - <name>Apache Virtual Host</name> - <plugin>Apache</plugin> - <pluginConfigurationDefinition> - <id>10013</id> - <propertyDefinitions/> - </pluginConfigurationDefinition> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10171</id> - <version>0</version> - <ctime>1307353587751</ctime> - <mtime>1307353587751</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10172</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353587751</ctime> - <mtime>1307353587751</mtime> - <propertySimple> - <id>10700</id> - <name>responseTimeUrlExcludes</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10699</id> - <name>responseTimeLogFile</name> - <override>false</override> - <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> - </propertySimple> - <propertySimple> - <id>10702</id> - <name>url</name> - <override>false</override> - <stringValue>http://127.0.0.1:11675/</stringValue> - </propertySimple> - <propertySimple> - <id>10703</id> - <name>snmpWwwServiceIndex</name> - <override>false</override> - <stringValue>5</stringValue> - </propertySimple> - <propertySimple> - <id>10701</id> - <name>responseTimeUrlTransforms</name> - <override>false</override> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> -</resource> - -<resource> - <id>10025</id> - <uuid>310281d2-60c6-4d7d-bcdc-c51d7969c906</uuid> - <resourceKey>127.0.0.1:11678</resourceKey> - <name>Virtual Host 127.0.0.1:11678</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> - <ctime>1307353587761</ctime> - <mtime>1307353587761</mtime> - <itime>1307353587760</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10014</id> - <name>Apache Virtual Host</name> - <plugin>Apache</plugin> - <pluginConfigurationDefinition> - <id>10013</id> - <propertyDefinitions/> - </pluginConfigurationDefinition> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10173</id> - <version>0</version> - <ctime>1307353587761</ctime> - <mtime>1307353587761</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10174</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353587761</ctime> - <mtime>1307353587761</mtime> - <propertySimple> - <id>10705</id> - <name>responseTimeUrlExcludes</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10704</id> - <name>responseTimeLogFile</name> - <override>false</override> - <stringValue>${server.root}/logs/127.0.0.111678_rt.log</stringValue> - </propertySimple> - <propertySimple> - <id>10707</id> - <name>url</name> - <override>false</override> - <stringValue>http://127.0.0.1:11678/</stringValue> - </propertySimple> - <propertySimple> - <id>10708</id> - <name>snmpWwwServiceIndex</name> - <override>false</override> - <stringValue>2</stringValue> - </propertySimple> - <propertySimple> - <id>10706</id> - <name>responseTimeUrlTransforms</name> - <override>false</override> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> -</resource> </objects> </inventory-dump>
commit a1ddb9d7b527d3f8fe05c88831637add713a0e17 Author: Lukas Krejci lkrejci@redhat.com Date: Thu Jun 16 12:03:14 2011 +0200
Fixing the implementation of the proxy collection of configuration properties returned from Configuration.getProperties()
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java index cf1ce4e..ce88dce 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java @@ -364,8 +364,7 @@ public class Configuration implements Serializable, Cloneable, AbstractPropertyM }
public boolean add(Property e) { - properties.put(e.getName(), e); - e.setConfiguration(Configuration.this); + put(e); return true; //we always allow adding an element even if it is already present }
@@ -374,7 +373,7 @@ public class Configuration implements Serializable, Cloneable, AbstractPropertyM }
public boolean containsAll(Collection<?> c) { - return false; + return properties.values().containsAll(c); }
public boolean addAll(Collection<? extends Property> c) {
commit d4e6f85418ff299734a3fa719c2ef4c216760c03 Author: Lukas Krejci lkrejci@redhat.com Date: Wed Jun 15 10:35:25 2011 +0200
refactoring the token replacement in the config and inventory export files to be more efficient. everything should ready for the actual tests now
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java index d3b54aa..1daad90 100644 --- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java +++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java @@ -26,11 +26,13 @@ package org.rhq.core.pc.upgrade; import static org.testng.Assert.fail;
import java.lang.reflect.Field; +import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashSet; +import java.util.List; import java.util.Map; import java.util.Set;
@@ -81,6 +83,13 @@ public class FakeServerInventory { this.failing = failing; }
+ public synchronized void prepopulateInventory(Resource platform, Collection<Resource> topLevelServers) { + this.platform = platform; + for (Resource res : topLevelServers) { + fakePersist(res, InventoryStatus.COMMITTED, new HashSet<String>()); + } + } + public synchronized CustomAction mergeInventoryReport(final InventoryStatus requiredInventoryStatus) { return new CustomAction("updateServerSideInventory") { public Object invoke(Invocation invocation) throws Throwable { @@ -248,6 +257,9 @@ public class FakeServerInventory { } if (persisted == null) { persisted = new Resource(); + if (agentSideResource.getId() != 0 && counter < agentSideResource.getId()) { + counter = agentSideResource.getId() - 1; + } persisted.setId(++counter); persisted.setUuid(agentSideResource.getUuid()); resourceStore.put(persisted.getUuid(), persisted); diff --git a/modules/helpers/inventory-serializer/inventory-rhq-1.3.0.xml b/modules/helpers/inventory-serializer/inventory-rhq-1.3.0.xml new file mode 100644 index 0000000..792c742 --- /dev/null +++ b/modules/helpers/inventory-serializer/inventory-rhq-1.3.0.xml @@ -0,0 +1,544 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10004</id> + <uuid>ae8a7a3e-256e-4c0a-9a65-33d534523d92</uuid> + <resourceKey>/home/metlos/Progs/apache-2.2.17/build</resourceKey> + <name>localhost.localdomain Apache 2.2.17 (/home/metlos/Progs/apache-2.2.17/build/)</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>true</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1307353451273</ctime> + <mtime>1307353509168</mtime> + <itime>1307353509168</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10013</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10012</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10142</id> + <version>0</version> + <ctime>1307353451273</ctime> + <mtime>1307353451273</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10073</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353737118</ctime> + <mtime>1307353737118</mtime> + <propertySimple> + <id>10365</id> + <name>errorLogMinimumSeverity</name> + <override>false</override> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10366</id> + <name>errorLogIncludesPattern</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10367</id> + <name>snmpAgentCommunity</name> + <override>false</override> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10368</id> + <name>errorLogFilePath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10369</id> + <name>errorLogEventsEnabled</name> + <override>false</override> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10370</id> + <name>snmpAgentHost</name> + <override>false</override> + <stringValue>127.0.0.1</stringValue> + </propertySimple> + <propertySimple> + <id>10713</id> + <name>controlScriptPath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10714</id> + <name>url</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10364</id> + <name>configFile</name> + <override>false</override> + <stringValue>conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10711</id> + <name>executablePath</name> + <override>false</override> + <stringValue>/home/metlos/Progs/apache-2.2.17/build/bin/httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10712</id> + <name>snmpAgentPort</name> + <override>false</override> + <stringValue>1610</stringValue> + </propertySimple> + <propertySimple> + <id>10715</id> + <name>serverRoot</name> + <override>false</override> + <stringValue>/home/metlos/Progs/apache-2.2.17/build</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10003</id> + </productVersion> +</resource> + +<resource> + <id>10021</id> + <uuid>3a20d809-7eba-422c-a3ef-baf65804498d</uuid> + <resourceKey>127.0.0.1:11676</resourceKey> + <name>Virtual Host 127.0.0.1:11676</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587648</ctime> + <mtime>1307353587648</mtime> + <itime>1307353587648</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10135</id> + <version>0</version> + <ctime>1307353587666</ctime> + <mtime>1307353587666</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10136</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587667</ctime> + <mtime>1307353587667</mtime> + <propertySimple> + <id>10685</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10684</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/127.0.0.111676_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10687</id> + <name>url</name> + <override>false</override> + <stringValue>http://127.0.0.1:11676/</stringValue> + </propertySimple> + <propertySimple> + <id>10688</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>4</stringValue> + </propertySimple> + <propertySimple> + <id>10686</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> +</resource> + +<resource> + <id>10022</id> + <uuid>08290193-c716-4363-b841-8a1d9d83f580</uuid> + <resourceKey>localhost.localdomain:0</resourceKey> + <name>Virtual Host localhost.localdomain:0</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587727</ctime> + <mtime>1307353587727</mtime> + <itime>1307353587721</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10137</id> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10138</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + <propertySimple> + <id>10690</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10689</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/localhost.localdomain0_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10692</id> + <name>url</name> + <override>false</override> + <stringValue>http://localhost.localdomain:0/</stringValue> + </propertySimple> + <propertySimple> + <id>10693</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>1</stringValue> + </propertySimple> + <propertySimple> + <id>10691</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>DOWN</availabilityType> + </currentAvailability> +</resource> + +<resource> + <id>10023</id> + <uuid>c62c5d75-81dd-4b14-a768-2d8c1fca6c88</uuid> + <resourceKey>127.0.0.1:11677</resourceKey> + <name>Virtual Host 127.0.0.1:11677</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + <itime>1307353587737</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10139</id> + <version>0</version> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10140</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + <propertySimple> + <id>10695</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10694</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/127.0.0.111677_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10697</id> + <name>url</name> + <override>false</override> + <stringValue>http://127.0.0.1:11677/</stringValue> + </propertySimple> + <propertySimple> + <id>10698</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>3</stringValue> + </propertySimple> + <propertySimple> + <id>10696</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> +</resource> + +<resource> + <id>10024</id> + <uuid>d1b59168-8666-4bc0-957e-171bf16eec73</uuid> + <resourceKey>127.0.0.1:11675</resourceKey> + <name>Virtual Host 127.0.0.1:11675</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + <itime>1307353587750</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10171</id> + <version>0</version> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10172</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + <propertySimple> + <id>10700</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10699</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10702</id> + <name>url</name> + <override>false</override> + <stringValue>http://127.0.0.1:11675/</stringValue> + </propertySimple> + <propertySimple> + <id>10703</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>5</stringValue> + </propertySimple> + <propertySimple> + <id>10701</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> +</resource> + +<resource> + <id>10025</id> + <uuid>310281d2-60c6-4d7d-bcdc-c51d7969c906</uuid> + <resourceKey>127.0.0.1:11678</resourceKey> + <name>Virtual Host 127.0.0.1:11678</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + <itime>1307353587760</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10173</id> + <version>0</version> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10174</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + <propertySimple> + <id>10705</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10704</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/127.0.0.111678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10707</id> + <name>url</name> + <override>false</override> + <stringValue>http://127.0.0.1:11678/</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>2</stringValue> + </propertySimple> + <propertySimple> + <id>10706</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> +</resource> +</objects> +</inventory-dump> diff --git a/modules/helpers/inventory-serializer/inventory-rhq-2.3.0.xml b/modules/helpers/inventory-serializer/inventory-rhq-2.3.0.xml deleted file mode 100644 index b70f83e..0000000 --- a/modules/helpers/inventory-serializer/inventory-rhq-2.3.0.xml +++ /dev/null @@ -1,1423 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<inventory-dump> -<classes-used> -<class>org.rhq.core.domain.resource.Resource</class> -</classes-used> -<objects> - -<resource> - <id>10001</id> - <uuid>7e83a3c0-2b25-4631-8a69-a15fa14b5565</uuid> - <resourceKey>localhost.localdomain</resourceKey> - <name>localhost.localdomain</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version>Linux 2.6.35.13-91.fc14.i686.PAE</version> - <description>Linux Operating System</description> - <ctime>1307353451263</ctime> - <mtime>1307353509094</mtime> - <itime>1307353509094</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>PLATFORM</category> - <createDeletePolicy>BOTH</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <description>Linux Operating System</description> - <id>10003</id> - <name>Linux</name> - <plugin>Platforms</plugin> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10126</id> - <version>0</version> - <ctime>1307353451263</ctime> - <mtime>1307353451263</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10127</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353451263</ctime> - <mtime>1307353451263</mtime> - <propertyList> - <id>10582</id> - <name>logs</name> - </propertyList> - <propertySimple> - <id>10581</id> - <name>metadataCacheTimeout</name> - <override>false</override> - <stringValue>1800</stringValue> - </propertySimple> - <propertySimple> - <id>10558</id> - <name>enableContentDiscovery</name> - <override>false</override> - <stringValue>false</stringValue> - </propertySimple> - <propertySimple> - <id>10559</id> - <name>enableInternalYumServer</name> - <override>false</override> - <stringValue>false</stringValue> - </propertySimple> - <propertySimple> - <id>10560</id> - <name>yumPort</name> - <override>false</override> - <stringValue>9080</stringValue> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> - <productVersion> - <id>10001</id> - </productVersion> -</resource> - -<resource> - <id>10002</id> - <uuid>aabcc93d-29cc-48f7-bfd4-73e0c319d281</uuid> - <resourceKey>localhost.localdomain RHQ Agent</resourceKey> - <name>localhost.localdomain RHQ Agent</name> - <inventoryStatus>NEW</inventoryStatus> - <connected>false</connected> - <version>1.3.1.GA</version> - <description>RHQ Management Agent</description> - <ctime>1307353451265</ctime> - <mtime>1307353451265</mtime> - <itime>1307353451262</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVER</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <description>Management Agent</description> - <id>10030</id> - <name>RHQ Agent</name> - <plugin>RHQAgent</plugin> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10128</id> - <version>0</version> - <ctime>1307353451265</ctime> - <mtime>1307353451265</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10129</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353451265</ctime> - <mtime>1307353451265</mtime> - <propertySimple> - <id>10584</id> - <name>snapshotLogEnabled</name> - <override>false</override> - <stringValue>true</stringValue> - </propertySimple> - <propertyList> - <id>10586</id> - <name>logEventSources</name> - <list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="propertyMap"> - <id>10593</id> - <name>logEventSource</name> - <map> - <entry> - <key>enabled</key> - <value xsi:type="propertySimple"> - <id>10595</id> - <name>enabled</name> - <override>false</override> - <stringValue>false</stringValue> - </value> - </entry> - <entry> - <key>logFilePath</key> - <value xsi:type="propertySimple"> - <id>10594</id> - <name>logFilePath</name> - <override>false</override> - <stringValue>/home/metlos/Projects/java/jon/qa/jon/jon-server-2.3.1.GA/agent/rhq-agent/logs/command-trace.log</stringValue> - </value> - </entry> - <entry> - <key>includesPattern</key> - <value xsi:type="propertySimple"> - <id>10597</id> - <name>includesPattern</name> - <override>false</override> - </value> - </entry> - <entry> - <key>minimumSeverity</key> - <value xsi:type="propertySimple"> - <id>10598</id> - <name>minimumSeverity</name> - <override>false</override> - </value> - </entry> - <entry> - <key>dateFormat</key> - <value xsi:type="propertySimple"> - <id>10596</id> - <name>dateFormat</name> - <override>false</override> - </value> - </entry> - </map> - </list> - <list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="propertyMap"> - <id>10587</id> - <name>logEventSource</name> - <map> - <entry> - <key>enabled</key> - <value xsi:type="propertySimple"> - <id>10589</id> - <name>enabled</name> - <override>false</override> - <stringValue>false</stringValue> - </value> - </entry> - <entry> - <key>logFilePath</key> - <value xsi:type="propertySimple"> - <id>10588</id> - <name>logFilePath</name> - <override>false</override> - <stringValue>/home/metlos/Projects/java/jon/qa/jon/jon-server-2.3.1.GA/agent/rhq-agent/logs/agent.log</stringValue> - </value> - </entry> - <entry> - <key>includesPattern</key> - <value xsi:type="propertySimple"> - <id>10592</id> - <name>includesPattern</name> - <override>false</override> - </value> - </entry> - <entry> - <key>minimumSeverity</key> - <value xsi:type="propertySimple"> - <id>10590</id> - <name>minimumSeverity</name> - <override>false</override> - <stringValue>ERROR</stringValue> - </value> - </entry> - <entry> - <key>dateFormat</key> - <value xsi:type="propertySimple"> - <id>10591</id> - <name>dateFormat</name> - <override>false</override> - </value> - </entry> - </map> - </list> - </propertyList> - <propertySimple> - <id>10585</id> - <name>snapshotDataEnabled</name> - <override>false</override> - <stringValue>true</stringValue> - </propertySimple> - <propertySimple> - <id>10583</id> - <name>snapshotConfigEnabled</name> - <override>false</override> - <stringValue>true</stringValue> - </propertySimple> - <propertySimple> - <id>10600</id> - <name>type</name> - <override>false</override> - <stringValue>org.mc4j.ems.connection.support.metadata.InternalVMTypeDescriptor</stringValue> - </propertySimple> - <propertySimple> - <id>10599</id> - <name>connectorAddress</name> - <override>false</override> - <stringValue>Local Connection</stringValue> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability/> - <productVersion> - <id>10002</id> - </productVersion> -</resource> - -<resource> - <id>10003</id> - <uuid>76127b54-4551-48f7-9fde-5323f9ac6162</uuid> - <resourceKey>jdbc:postgresql://127.0.0.1:5432/postgres</resourceKey> - <name>Postgres [postgres]</name> - <inventoryStatus>NEW</inventoryStatus> - <connected>false</connected> - <version></version> - <description>Postgres relational database server</description> - <ctime>1307353451270</ctime> - <mtime>1307353451270</mtime> - <itime>1307353451262</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVER</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <description>PostgreSQL Server</description> - <id>10031</id> - <name>Postgres Server</name> - <plugin>Postgres</plugin> - <singleton>false</singleton> - <supportsManualAdd>true</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10130</id> - <version>0</version> - <ctime>1307353451270</ctime> - <mtime>1307353451270</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10141</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353451271</ctime> - <mtime>1307353451271</mtime> - <propertySimple> - <id>10602</id> - <name>port</name> - <override>false</override> - <stringValue>5432</stringValue> - </propertySimple> - <propertySimple> - <id>10603</id> - <name>db</name> - <override>false</override> - <stringValue>postgres</stringValue> - </propertySimple> - <propertySimple> - <id>10601</id> - <name>host</name> - <override>false</override> - <stringValue>127.0.0.1</stringValue> - </propertySimple> - <propertySimple> - <id>10605</id> - <name>principal</name> - <override>false</override> - <stringValue>postgres</stringValue> - </propertySimple> - <propertySimple> - <id>10608</id> - <name>configFile</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10604</id> - <name>driverClass</name> - <override>false</override> - <stringValue>org.postgresql.Driver</stringValue> - </propertySimple> - <propertySimple> - <id>10606</id> - <name>credentials</name> - <override>false</override> - <stringValue>postgres</stringValue> - </propertySimple> - <propertySimple> - <id>10607</id> - <name>pgdataDir</name> - <override>false</override> - <stringValue>/var/lib/pgsql/data</stringValue> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability/> -</resource> - -<resource> - <id>10005</id> - <uuid>c83c5747-295d-4605-b24f-33aff62839ba</uuid> - <resourceKey>virbr1</resourceKey> - <name>virbr1</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>12:2F:62:56:07:92</description> - <ctime>1307353510534</ctime> - <mtime>1307353510534</mtime> - <itime>1307353510533</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10002</id> - <name>Network Adapter</name> - <plugin>Platforms</plugin> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10144</id> - <version>0</version> - <ctime>1307353510534</ctime> - <mtime>1307353510534</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10145</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353510534</ctime> - <mtime>1307353510534</mtime> - <propertySimple> - <id>10661</id> - <name>macAddress</name> - <override>false</override> - <stringValue>12:2F:62:56:07:92</stringValue> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> -</resource> - -<resource> - <id>10006</id> - <uuid>98130e3c-5cf3-4ba1-b16a-8bb247f11496</uuid> - <resourceKey>wlan0</resourceKey> - <name>wlan0</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>00:22:FA:5F:D3:80</description> - <ctime>1307353510550</ctime> - <mtime>1307353510550</mtime> - <itime>1307353510550</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10002</id> - <name>Network Adapter</name> - <plugin>Platforms</plugin> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10146</id> - <version>0</version> - <ctime>1307353510550</ctime> - <mtime>1307353510550</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10147</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353510551</ctime> - <mtime>1307353510551</mtime> - <propertySimple> - <id>10662</id> - <name>macAddress</name> - <override>false</override> - <stringValue>00:22:FA:5F:D3:80</stringValue> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> -</resource> - -<resource> - <id>10007</id> - <uuid>4cb96df3-cc42-4f57-94cd-73cc048db673</uuid> - <resourceKey>virbr0</resourceKey> - <name>virbr0</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>6E:8F:FF:79:B9:D6</description> - <ctime>1307353510557</ctime> - <mtime>1307353510557</mtime> - <itime>1307353510557</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10002</id> - <name>Network Adapter</name> - <plugin>Platforms</plugin> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10148</id> - <version>0</version> - <ctime>1307353510557</ctime> - <mtime>1307353510557</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10149</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353510557</ctime> - <mtime>1307353510557</mtime> - <propertySimple> - <id>10663</id> - <name>macAddress</name> - <override>false</override> - <stringValue>6E:8F:FF:79:B9:D6</stringValue> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> -</resource> - -<resource> - <id>10008</id> - <uuid>4e59f9ef-fd91-4ec4-8da5-e617e4abf376</uuid> - <resourceKey>tun0</resourceKey> - <name>tun0</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>00:00:00:00:00:00</description> - <ctime>1307353510566</ctime> - <mtime>1307353510566</mtime> - <itime>1307353510565</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10002</id> - <name>Network Adapter</name> - <plugin>Platforms</plugin> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10150</id> - <version>0</version> - <ctime>1307353510566</ctime> - <mtime>1307353510566</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10151</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353510566</ctime> - <mtime>1307353510566</mtime> - <propertySimple> - <id>10664</id> - <name>macAddress</name> - <override>false</override> - <stringValue>00:00:00:00:00:00</stringValue> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> -</resource> - -<resource> - <id>10009</id> - <uuid>dd39bfe4-9368-43a9-9c25-ab5e9c2cdc6a</uuid> - <resourceKey>lo</resourceKey> - <name>lo</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>00:00:00:00:00:00</description> - <ctime>1307353510572</ctime> - <mtime>1307353510572</mtime> - <itime>1307353510572</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10002</id> - <name>Network Adapter</name> - <plugin>Platforms</plugin> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10152</id> - <version>0</version> - <ctime>1307353510572</ctime> - <mtime>1307353510572</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10153</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353510573</ctime> - <mtime>1307353510573</mtime> - <propertySimple> - <id>10665</id> - <name>macAddress</name> - <override>false</override> - <stringValue>00:00:00:00:00:00</stringValue> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> -</resource> - -<resource> - <id>10010</id> - <uuid>0c86b8a7-33b0-4b67-9178-2bb6cbd4fb34</uuid> - <resourceKey>eth0</resourceKey> - <name>eth0</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>00:1C:25:A1:F6:58</description> - <ctime>1307353510580</ctime> - <mtime>1307353510580</mtime> - <itime>1307353510579</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10002</id> - <name>Network Adapter</name> - <plugin>Platforms</plugin> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10154</id> - <version>0</version> - <ctime>1307353510580</ctime> - <mtime>1307353510580</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10155</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353510580</ctime> - <mtime>1307353510580</mtime> - <propertySimple> - <id>10666</id> - <name>macAddress</name> - <override>false</override> - <stringValue>00:1C:25:A1:F6:58</stringValue> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> -</resource> - -<resource> - <id>10011</id> - <uuid>bf1e848c-88aa-4406-bf00-bf80a1825843</uuid> - <resourceKey>/boot</resourceKey> - <name>localhost.localdomain File System (local) /boot</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>/dev/sda1: /boot</description> - <ctime>1307353510586</ctime> - <mtime>1307353510586</mtime> - <itime>1307353510586</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10004</id> - <name>File System</name> - <plugin>Platforms</plugin> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10156</id> - <version>0</version> - <ctime>1307353510586</ctime> - <mtime>1307353510586</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10157</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353510587</ctime> - <mtime>1307353510587</mtime> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> -</resource> - -<resource> - <id>10012</id> - <uuid>6a12505a-c668-447b-b178-7993554ca093</uuid> - <resourceKey>/</resourceKey> - <name>localhost.localdomain File System (local) /</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>/dev/mapper/VolGroup-lv_root: /</description> - <ctime>1307353510594</ctime> - <mtime>1307353510594</mtime> - <itime>1307353510593</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10004</id> - <name>File System</name> - <plugin>Platforms</plugin> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10158</id> - <version>0</version> - <ctime>1307353510594</ctime> - <mtime>1307353510594</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10159</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353510594</ctime> - <mtime>1307353510594</mtime> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> -</resource> - -<resource> - <id>10013</id> - <uuid>983dff97-dfc4-4ec5-97c7-e2f9287399ef</uuid> - <resourceKey>1</resourceKey> - <name>CPU 1</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version>Core(TM)2 Duo CPU T9600 @ 2.80GHz</version> - <description>Intel Core(TM)2 Duo CPU T9600 @ 2.80GHz</description> - <ctime>1307353510600</ctime> - <mtime>1307353510600</mtime> - <itime>1307353510599</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10006</id> - <name>CPU</name> - <plugin>Platforms</plugin> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10160</id> - <version>0</version> - <ctime>1307353510600</ctime> - <mtime>1307353510600</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10161</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353510600</ctime> - <mtime>1307353510600</mtime> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> - <productVersion> - <id>10004</id> - </productVersion> -</resource> - -<resource> - <id>10014</id> - <uuid>fb1dd111-07ab-40f4-9040-263dc0324728</uuid> - <resourceKey>0</resourceKey> - <name>CPU 0</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version>Core(TM)2 Duo CPU T9600 @ 2.80GHz</version> - <description>Intel Core(TM)2 Duo CPU T9600 @ 2.80GHz</description> - <ctime>1307353510610</ctime> - <mtime>1307353510610</mtime> - <itime>1307353510610</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10006</id> - <name>CPU</name> - <plugin>Platforms</plugin> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10162</id> - <version>0</version> - <ctime>1307353510611</ctime> - <mtime>1307353510611</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10163</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353510611</ctime> - <mtime>1307353510611</mtime> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> - <productVersion> - <id>10004</id> - </productVersion> -</resource> - -<resource> - <id>10021</id> - <uuid>3a20d809-7eba-422c-a3ef-baf65804498d</uuid> - <resourceKey>127.0.0.1:11676</resourceKey> - <name>Virtual Host 127.0.0.1:11676</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> - <ctime>1307353587648</ctime> - <mtime>1307353587648</mtime> - <itime>1307353587648</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10014</id> - <name>Apache Virtual Host</name> - <plugin>Apache</plugin> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10135</id> - <version>0</version> - <ctime>1307353587666</ctime> - <mtime>1307353587666</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10136</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353587667</ctime> - <mtime>1307353587667</mtime> - <propertySimple> - <id>10685</id> - <name>responseTimeUrlExcludes</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10684</id> - <name>responseTimeLogFile</name> - <override>false</override> - <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/127.0.0.111676_rt.log</stringValue> - </propertySimple> - <propertySimple> - <id>10687</id> - <name>url</name> - <override>false</override> - <stringValue>http://127.0.0.1:11676/</stringValue> - </propertySimple> - <propertySimple> - <id>10688</id> - <name>snmpWwwServiceIndex</name> - <override>false</override> - <stringValue>4</stringValue> - </propertySimple> - <propertySimple> - <id>10686</id> - <name>responseTimeUrlTransforms</name> - <override>false</override> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> -</resource> - -<resource> - <id>10022</id> - <uuid>08290193-c716-4363-b841-8a1d9d83f580</uuid> - <resourceKey>localhost.localdomain:0</resourceKey> - <name>Virtual Host localhost.localdomain:0</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> - <ctime>1307353587727</ctime> - <mtime>1307353587727</mtime> - <itime>1307353587721</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10014</id> - <name>Apache Virtual Host</name> - <plugin>Apache</plugin> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10137</id> - <version>0</version> - <ctime>1307353587728</ctime> - <mtime>1307353587728</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10138</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353587728</ctime> - <mtime>1307353587728</mtime> - <propertySimple> - <id>10690</id> - <name>responseTimeUrlExcludes</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10689</id> - <name>responseTimeLogFile</name> - <override>false</override> - <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/localhost.localdomain0_rt.log</stringValue> - </propertySimple> - <propertySimple> - <id>10692</id> - <name>url</name> - <override>false</override> - <stringValue>http://localhost.localdomain:0/</stringValue> - </propertySimple> - <propertySimple> - <id>10693</id> - <name>snmpWwwServiceIndex</name> - <override>false</override> - <stringValue>1</stringValue> - </propertySimple> - <propertySimple> - <id>10691</id> - <name>responseTimeUrlTransforms</name> - <override>false</override> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>DOWN</availabilityType> - </currentAvailability> -</resource> - -<resource> - <id>10023</id> - <uuid>c62c5d75-81dd-4b14-a768-2d8c1fca6c88</uuid> - <resourceKey>127.0.0.1:11677</resourceKey> - <name>Virtual Host 127.0.0.1:11677</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> - <ctime>1307353587738</ctime> - <mtime>1307353587738</mtime> - <itime>1307353587737</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10014</id> - <name>Apache Virtual Host</name> - <plugin>Apache</plugin> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10139</id> - <version>0</version> - <ctime>1307353587738</ctime> - <mtime>1307353587738</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10140</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353587738</ctime> - <mtime>1307353587738</mtime> - <propertySimple> - <id>10695</id> - <name>responseTimeUrlExcludes</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10694</id> - <name>responseTimeLogFile</name> - <override>false</override> - <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/127.0.0.111677_rt.log</stringValue> - </propertySimple> - <propertySimple> - <id>10697</id> - <name>url</name> - <override>false</override> - <stringValue>http://127.0.0.1:11677/</stringValue> - </propertySimple> - <propertySimple> - <id>10698</id> - <name>snmpWwwServiceIndex</name> - <override>false</override> - <stringValue>3</stringValue> - </propertySimple> - <propertySimple> - <id>10696</id> - <name>responseTimeUrlTransforms</name> - <override>false</override> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> -</resource> - -<resource> - <id>10024</id> - <uuid>d1b59168-8666-4bc0-957e-171bf16eec73</uuid> - <resourceKey>127.0.0.1:11675</resourceKey> - <name>Virtual Host 127.0.0.1:11675</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> - <ctime>1307353587751</ctime> - <mtime>1307353587751</mtime> - <itime>1307353587750</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10014</id> - <name>Apache Virtual Host</name> - <plugin>Apache</plugin> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10171</id> - <version>0</version> - <ctime>1307353587751</ctime> - <mtime>1307353587751</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10172</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353587751</ctime> - <mtime>1307353587751</mtime> - <propertySimple> - <id>10700</id> - <name>responseTimeUrlExcludes</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10699</id> - <name>responseTimeLogFile</name> - <override>false</override> - <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/127.0.0.111675_rt.log</stringValue> - </propertySimple> - <propertySimple> - <id>10702</id> - <name>url</name> - <override>false</override> - <stringValue>http://127.0.0.1:11675/</stringValue> - </propertySimple> - <propertySimple> - <id>10703</id> - <name>snmpWwwServiceIndex</name> - <override>false</override> - <stringValue>5</stringValue> - </propertySimple> - <propertySimple> - <id>10701</id> - <name>responseTimeUrlTransforms</name> - <override>false</override> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> -</resource> - -<resource> - <id>10025</id> - <uuid>310281d2-60c6-4d7d-bcdc-c51d7969c906</uuid> - <resourceKey>127.0.0.1:11678</resourceKey> - <name>Virtual Host 127.0.0.1:11678</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>false</connected> - <version></version> - <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> - <ctime>1307353587761</ctime> - <mtime>1307353587761</mtime> - <itime>1307353587760</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVICE</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <id>10014</id> - <name>Apache Virtual Host</name> - <plugin>Apache</plugin> - <singleton>false</singleton> - <supportsManualAdd>false</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10173</id> - <version>0</version> - <ctime>1307353587761</ctime> - <mtime>1307353587761</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10174</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353587761</ctime> - <mtime>1307353587761</mtime> - <propertySimple> - <id>10705</id> - <name>responseTimeUrlExcludes</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10704</id> - <name>responseTimeLogFile</name> - <override>false</override> - <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/127.0.0.111678_rt.log</stringValue> - </propertySimple> - <propertySimple> - <id>10707</id> - <name>url</name> - <override>false</override> - <stringValue>http://127.0.0.1:11678/</stringValue> - </propertySimple> - <propertySimple> - <id>10708</id> - <name>snmpWwwServiceIndex</name> - <override>false</override> - <stringValue>2</stringValue> - </propertySimple> - <propertySimple> - <id>10706</id> - <name>responseTimeUrlTransforms</name> - <override>false</override> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> -</resource> - -<resource> - <id>10004</id> - <uuid>ae8a7a3e-256e-4c0a-9a65-33d534523d92</uuid> - <resourceKey>/home/metlos/Progs/apache-2.2.17/build</resourceKey> - <name>localhost.localdomain Apache 2.2.17 (/home/metlos/Progs/apache-2.2.17/build/)</name> - <inventoryStatus>COMMITTED</inventoryStatus> - <connected>true</connected> - <version>2.2.17</version> - <description>Apache Web Server</description> - <ctime>1307353451273</ctime> - <mtime>1307353509168</mtime> - <itime>1307353509168</itime> - <modifiedBy> - <factive>false</factive> - <fsystem>false</fsystem> - <id>1</id> - </modifiedBy> - <resourceType> - <category>SERVER</category> - <createDeletePolicy>NEITHER</createDeletePolicy> - <creationDataType>CONFIGURATION</creationDataType> - <description>an Apache HTTP Server instance</description> - <id>10013</id> - <name>Apache HTTP Server</name> - <plugin>Apache</plugin> - <singleton>false</singleton> - <supportsManualAdd>true</supportsManualAdd> - </resourceType> - <resourceConfiguration> - <id>10142</id> - <version>0</version> - <ctime>1307353451273</ctime> - <mtime>1307353451273</mtime> - </resourceConfiguration> - <pluginConfiguration> - <id>10073</id> - <notes>null</notes> - <version>0</version> - <ctime>1307353737118</ctime> - <mtime>1307353737118</mtime> - <propertySimple> - <id>10365</id> - <name>errorLogMinimumSeverity</name> - <override>false</override> - <stringValue>error</stringValue> - </propertySimple> - <propertySimple> - <id>10366</id> - <name>errorLogIncludesPattern</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10367</id> - <name>snmpAgentCommunity</name> - <override>false</override> - <stringValue>public</stringValue> - </propertySimple> - <propertySimple> - <id>10368</id> - <name>errorLogFilePath</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10369</id> - <name>errorLogEventsEnabled</name> - <override>false</override> - <stringValue>false</stringValue> - </propertySimple> - <propertySimple> - <id>10370</id> - <name>snmpAgentHost</name> - <override>false</override> - <stringValue>127.0.0.1</stringValue> - </propertySimple> - <propertySimple> - <id>10713</id> - <name>controlScriptPath</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10714</id> - <name>url</name> - <override>false</override> - </propertySimple> - <propertySimple> - <id>10364</id> - <name>configFile</name> - <override>false</override> - <stringValue>conf/httpd.conf</stringValue> - </propertySimple> - <propertySimple> - <id>10711</id> - <name>executablePath</name> - <override>false</override> - <stringValue>/home/metlos/Progs/apache-2.2.17/build/bin/httpd</stringValue> - </propertySimple> - <propertySimple> - <id>10712</id> - <name>snmpAgentPort</name> - <override>false</override> - <stringValue>1610</stringValue> - </propertySimple> - <propertySimple> - <id>10715</id> - <name>serverRoot</name> - <override>false</override> - <stringValue>/home/metlos/Progs/apache-2.2.17/build</stringValue> - </propertySimple> - </pluginConfiguration> - <agent> - <backFilled>false</backFilled> - <id>10001</id> - <port>0</port> - </agent> - <currentAvailability> - <availabilityType>UP</availabilityType> - </currentAvailability> - <productVersion> - <id>10003</id> - </productVersion> -</resource> -</objects> -</inventory-dump> diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java index 0e798b8..e539eaa 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java @@ -19,13 +19,25 @@
package org.rhq.plugins.apache;
+import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue;
import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; import java.net.URI; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.xml.bind.JAXBException; +import javax.xml.stream.XMLStreamException;
import org.jmock.Expectations; import org.testng.annotations.AfterClass; @@ -36,22 +48,28 @@ import org.testng.annotations.Test; import org.rhq.core.clientapi.agent.metadata.PluginMetadataParser; import org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil; import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor; +import org.rhq.core.clientapi.server.discovery.InvalidInventoryReportException; import org.rhq.core.clientapi.server.discovery.InventoryReport; import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.PropertySimple; +import org.rhq.core.domain.resource.InventoryStatus; import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.pc.ServerServices; +import org.rhq.core.pc.upgrade.FakeServerInventory; import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; import org.rhq.core.pluginapi.inventory.PluginContainerDeployment; import org.rhq.core.pluginapi.inventory.ResourceContext; +import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; import org.rhq.core.system.SystemInfo; import org.rhq.core.system.SystemInfoFactory; import org.rhq.plugins.apache.util.ApacheDeploymentUtil; import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig; import org.rhq.plugins.apache.util.HttpdAddressUtility; +import org.rhq.plugins.apache.util.TokenReplacingReader; import org.rhq.plugins.platform.PlatformComponent; +import org.rhq.test.ObjectCollectionSerializer; import org.rhq.test.pc.PluginContainerSetup; import org.rhq.test.pc.PluginContainerTest;
@@ -71,6 +89,8 @@ public class UpgradeTest extends PluginContainerTest {
private List<ResourceType> resourceTypesInApachePlugin;
+ private Resource platform; + private static class DiscoveryInput { public String serverRootPath; public String exePath; @@ -80,28 +100,174 @@ public class UpgradeTest extends PluginContainerTest { public String pingUrl; }
+ private class TestSetup { + private String configurationName; + private FakeServerInventory fakeInventory = new FakeServerInventory(); + private String inventoryFile; + private Resource platform; + private ApacheSetup apacheSetup = new ApacheSetup(); + + public class ApacheSetup { + private String serverRoot; + private String exePath; + private Collection<String> configurationFiles; + + private ApacheSetup() { + + } + + public ApacheSetup withServerRoot(String serverRoot) { + this.serverRoot = serverRoot; + return this; + } + + public ApacheSetup withExePath(String exePath) { + this.exePath = exePath; + return this; + } + + public ApacheSetup withConfigurationFiles(String... classPathUris) { + return withConfigurationFiles(Arrays.asList(classPathUris)); + } + + public ApacheSetup withConfigurationFiles(Collection<String> classPathUris) { + this.configurationFiles = classPathUris; + return this; + } + + private void doSetup() throws Exception { + prepareApacheForTest(TestSetup.this.configurationName, serverRoot, exePath, configurationFiles); + } + + public TestSetup setup() throws Exception { + return TestSetup.this.setup(); + } + + private void prepareApacheForTest(String configurationName, String apacheInstallationDirectory, + String apacheExePath, Collection<String> configurationFiles) throws Exception { + File apacheInstallationDir = new File(apacheInstallationDirectory); + + assertTrue(apacheInstallationDir.exists(), + "The 'apache2.install.dir' system property denotes a non-existant directory: '" + + apacheInstallationDirectory + "'."); + + File confDir = new File(apacheInstallationDir, "conf"); + + assertTrue( + confDir.exists(), + "The 'apache2.install.dir' system property denotes a directory that doesn't have a 'conf' subdirectory. This is unexpected."); + + DeploymentConfig deploymentConfig = ApacheDeploymentUtil + .getDeploymentConfigurationFromSystemProperties(configurationName); + + ApacheDeploymentUtil.deployConfiguration(confDir, configurationFiles, deploymentConfig); + + DiscoveryInput discoveryInput = new DiscoveryInput(); + discoveryInput.serverRootPath = apacheInstallationDirectory; + discoveryInput.exePath = apacheExePath; + discoveryInput.httpdConfPath = confDir.getAbsolutePath() + File.separatorChar + "httpd.conf"; + discoveryInput.snmpHost = deploymentConfig.snmpHost; + discoveryInput.snmpPort = deploymentConfig.snmpPort; + + HttpdAddressUtility.Address addr = deploymentConfig.mainServer.address1; + HttpdAddressUtility.Address addrToUse = new HttpdAddressUtility.Address(null, null, + HttpdAddressUtility.Address.NO_PORT_SPECIFIED_VALUE); + addrToUse.scheme = addr.scheme == null ? "http" : addr.scheme; + addrToUse.host = addr.host == null ? "localhost" : addr.host; + addrToUse.port = addr.port; + + discoveryInput.pingUrl = addrToUse.toString(); + + restartApache(discoveryInput); + } + + private void restartApache(DiscoveryInput discoveryInput) throws Exception { + ApacheServerComponent serverComponent = findAndStartServerComponent(discoveryInput); + + try { + serverComponent.invokeOperation("restart", null); + } catch (Exception e) { + serverComponent.invokeOperation("start", null); + } + } + } + + public TestSetup(String configurationName) { + this.configurationName = configurationName; + } + + public TestSetup withInventoryFrom(String classPathUri) { + inventoryFile = classPathUri; + return this; + } + + public TestSetup withPlatformResource(Resource platform) { + this.platform = platform; + return this; + } + + public ApacheSetup withApacheSetup() { + return apacheSetup; + } + + public TestSetup withDefaultExpectations() throws Exception { + final ServerServices ss = getCurrentPluginContainerConfiguration().getServerServices(); + + context.checking(new Expectations() { + { + allowing(ss.getDiscoveryServerService()).mergeInventoryReport(with(any(InventoryReport.class))); + will(fakeInventory.mergeInventoryReport(InventoryStatus.COMMITTED)); + + allowing(ss.getDiscoveryServerService()).upgradeResources(with(any(Set.class))); + will(fakeInventory.upgradeResources()); + } + }); + + return this; + } + + public FakeServerInventory getFakeInventory() { + return fakeInventory; + } + + public TestSetup setup() throws Exception { + Map<String, String> replacements = new HashMap<String, String>(); + replacements.put("server.root", apacheSetup.serverRoot); + replacements.put("exe.path", apacheSetup.exePath); + + InputStream dataStream = getClass().getResourceAsStream(inventoryFile); + + Reader rdr = new TokenReplacingReader(new InputStreamReader(dataStream), replacements); + + @SuppressWarnings("unchecked") + List<Resource> inventory = (List<Resource>) new ObjectCollectionSerializer().deserialize(rdr); + + fakeInventory = new FakeServerInventory(); + fakeInventory.prepopulateInventory(platform, inventory); + + apacheSetup.doSetup(); + + return this; + } + } + @BeforeClass public void parseResourceTypesFromApachePlugin() throws Exception { - PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(new URI(APACHE_PLUGIN) - .toURL()); - PluginMetadataParser parser = new PluginMetadataParser(descriptor, - Collections.<String, PluginMetadataParser> emptyMap()); - - resourceTypesInApachePlugin = parser.getAllTypes(); + resourceTypesInApachePlugin = getResourceTypesInPlugin(APACHE_PLUGIN); + platform = discoverPlatform(); }
@AfterClass @Parameters({ "apache2.install.dir", "apache2.exe.path" }) - public void shutdownApache(String apacheInstallationDirectory, - String exePath) throws Exception { - + public void shutdownApache(String apacheInstallationDirectory, String exePath) throws Exception { + File apacheInstallationDir = new File(apacheInstallationDirectory); File confDir = new File(apacheInstallationDir, "conf"); - + //it really doesn't matter which configuration i use here DeploymentConfig deploymentConfig = ApacheDeploymentUtil .getDeploymentConfigurationFromSystemProperties(DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES); - + DiscoveryInput discoveryInput = new DiscoveryInput(); discoveryInput.serverRootPath = apacheInstallationDirectory; discoveryInput.exePath = exePath; @@ -122,71 +288,93 @@ public class UpgradeTest extends PluginContainerTest {
serverComponent.invokeOperation("stop", null); } - + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) @Parameters({ "apache2.install.dir", "apache2.exe.path" }) - public void testSimpleConfigurationWithResolvableServerNames_Apache2_upgradeFromRHQ1_3(String apacheInstallationDirectory, - String exePath) throws Exception { - - final ServerServices ss = getCurrentPluginContainerConfiguration().getServerServices(); - - context.checking(new Expectations() { - { - allowing(ss.getDiscoveryServerService().mergeInventoryReport(with(any(InventoryReport.class)))); - //will(/* push the mocked inventory down to the agent */); - } - }); + public void testSimpleConfigurationWithResolvableServerNames_Apache2_upgradeFromRHQ1_3( + String apacheInstallationDirectory, String exePath) throws Exception {
- prepareApacheForTest(DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES, apacheInstallationDirectory, exePath, - Arrays.asList("/full-configurations/simple/httpd.conf", "/snmpd.conf")); + final TestSetup setup = new TestSetup(DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES) + .withInventoryFrom("/mocked-inventories/rhq-1.3.x/includes/inventory.xml").withPlatformResource(platform) + .withDefaultExpectations().withApacheSetup() + .withConfigurationFiles("/full-configurations/simple/httpd.conf", "/snmpd.conf", "/mime.types") + .withServerRoot(apacheInstallationDirectory).withExePath(exePath).setup();
startConfiguredPluginContainer(); - - //TODO check the results of the upgrade - }
- private void prepareApacheForTest(String configurationName, String apacheInstallationDirectory, - String apacheExePath, List<String> configurationFiles) throws Exception { - File apacheInstallationDir = new File(apacheInstallationDirectory); + //ok, now we should see the resources upgraded in the fake server inventory. + ResourceType serverResourceType = findApachePluginResourceTypeByName("Apache HTTP Server"); + ResourceType vhostResourceType = findApachePluginResourceTypeByName("Apache Virtual Host");
- assertTrue(apacheInstallationDir.exists(), - "The 'apache2.install.dir' system property denotes a non-existant directory: '" - + apacheInstallationDirectory + "'."); + Set<Resource> servers = setup.getFakeInventory().findResourcesByType(serverResourceType);
- File confDir = new File(apacheInstallationDir, "conf"); + assertTrue(servers.size() == 1, "There should be exactly one apache server discovered.");
- assertTrue( - confDir.exists(), - "The 'apache2.install.dir' system property denotes a directory that doesn't have a 'conf' subdirectory. This is unexpected."); + Resource server = servers.iterator().next();
- DeploymentConfig deploymentConfig = ApacheDeploymentUtil - .getDeploymentConfigurationFromSystemProperties(configurationName); +// String expectedResourceKey = ApacheServerDiscoveryComponent.formatResourceKey(apacheInstallationDirectory, +// apacheInstallationDirectory + "/conf/httpd.conf"); +// +// assertEquals(server.getResourceKey(), expectedResourceKey, +// "The server resource key doesn't seem to be upgraded.");
- ApacheDeploymentUtil.deployConfiguration(confDir, configurationFiles, deploymentConfig); + //TODO test the vhosts + }
- DiscoveryInput discoveryInput = new DiscoveryInput(); - discoveryInput.serverRootPath = apacheInstallationDirectory; - discoveryInput.exePath = apacheExePath; - discoveryInput.httpdConfPath = confDir.getAbsolutePath() + File.separatorChar + "httpd.conf"; - discoveryInput.snmpHost = deploymentConfig.snmpHost; - discoveryInput.snmpPort = deploymentConfig.snmpPort; + private ResourceType findApachePluginResourceTypeByName(String resourceTypeName) { + for (ResourceType rt : resourceTypesInApachePlugin) { + if (resourceTypeName.equals(rt.getName())) { + return rt; + } + }
- HttpdAddressUtility.Address addr = deploymentConfig.mainServer.address1; - HttpdAddressUtility.Address addrToUse = new HttpdAddressUtility.Address(null, null, - HttpdAddressUtility.Address.NO_PORT_SPECIFIED_VALUE); - addrToUse.scheme = addr.scheme == null ? "http" : addr.scheme; - addrToUse.host = addr.host == null ? "localhost" : addr.host; - addrToUse.port = addr.port; + return null; + }
- discoveryInput.pingUrl = addrToUse.toString(); + private static List<ResourceType> getResourceTypesInPlugin(String pluginUri) throws Exception { + PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(new URI(pluginUri).toURL()); + PluginMetadataParser parser = new PluginMetadataParser(descriptor, + Collections.<String, PluginMetadataParser> emptyMap());
- restartApache(discoveryInput); + return parser.getAllTypes(); }
- private void restartApache(DiscoveryInput discoveryInput) throws Exception { - ApacheServerComponent serverComponent = findAndStartServerComponent(discoveryInput); + @SuppressWarnings({ "rawtypes", "unchecked" }) + private static Resource discoverPlatform() throws Exception { + PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(new URI(PLATFORM_PLUGIN) + .toURL()); + PluginMetadataParser parser = new PluginMetadataParser(descriptor, + Collections.<String, PluginMetadataParser> emptyMap()); + + List<ResourceType> platformTypes = parser.getAllTypes(); + + for (ResourceType rt : platformTypes) { + Class discoveryClass = Class.forName(parser.getDiscoveryComponentClass(rt)); + + ResourceDiscoveryComponent discoveryComponent = (ResourceDiscoveryComponent) discoveryClass.newInstance(); + + ResourceDiscoveryContext context = new ResourceDiscoveryContext(rt, null, null, + SystemInfoFactory.createSystemInfo(), null, null, PluginContainerDeployment.AGENT); + + Set<DiscoveredResourceDetails> results = discoveryComponent.discoverResources(context); + + if (!results.isEmpty()) { + DiscoveredResourceDetails details = results.iterator().next(); + + Resource platform = new Resource();
- serverComponent.invokeOperation("restart", null); + platform.setDescription(details.getResourceDescription()); + platform.setResourceKey(details.getResourceKey()); + platform.setName(details.getResourceName()); + platform.setVersion(details.getResourceVersion()); + platform.setPluginConfiguration(details.getPluginConfiguration()); + platform.setResourceType(rt); + + return platform; + } + } + + return null; }
private ApacheServerComponent findAndStartServerComponent(DiscoveryInput discoveryInput) throws Exception { @@ -223,14 +411,4 @@ public class UpgradeTest extends PluginContainerTest { serverComponent.start(resourceContext); return serverComponent; } - - private ResourceType findApachePluginResourceTypeByName(String resourceTypeName) { - for (ResourceType rt : resourceTypesInApachePlugin) { - if (resourceTypeName.equals(rt.getName())) { - return rt; - } - } - - return null; - } } diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java index 0e22cd4..2a19526 100644 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java @@ -19,16 +19,16 @@
package org.rhq.plugins.apache.util;
-import java.io.BufferedReader; import java.io.File; -import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; -import java.io.Writer; import java.net.URL; import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; import java.util.List; +import java.util.Map;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -45,6 +45,19 @@ public class ApacheDeploymentUtil {
private static final Log LOG = LogFactory.getLog(ApacheDeploymentUtil.class);
+ private static final String VHOST = "vhost"; + private static final String SERVER_ROOT = "server.root"; + private static final String ADDITIONAL_DIRECTIVES = "additional.directives"; + private static final String SERVERNAME_DIRECTIVE = "servername.directive"; + private static final String LISTEN4 = "listen4"; + private static final String LISTEN3 = "listen3"; + private static final String LISTEN2 = "listen2"; + private static final String LISTEN1 = "listen1"; + private static final String SNMP_PORT = "snmp.port"; + private static final String SNMP_HOST = "snmp.host"; + private static final String DOCUMENT_ROOT = "document.root"; + private static final String URLS = "urls"; + private ApacheDeploymentUtil() {
} @@ -57,6 +70,48 @@ public class ApacheDeploymentUtil { public Address address4 = null; public String serverNameDirective = null; public final List<String> additionalDirectives = new ArrayList<String>(); + + private void addToTokenReplacements(int ordinal, Map<String, String> tokenReplacements) { + String prefix = null; + + if (ordinal == 0) { + prefix = ""; + } else { + prefix = VHOST + ordinal + "."; + } + + tokenReplacements.put(prefix + SERVERNAME_DIRECTIVE, serverNameDirective == null ? "" : serverNameDirective); + + String dirs = ""; + if (!additionalDirectives.isEmpty()) { + String newline = System.getProperty("line.separator"); + for(String dir : additionalDirectives) { + dirs += dir + newline; + } + } + + tokenReplacements.put(prefix + ADDITIONAL_DIRECTIVES, dirs); + + if (ordinal != 0) { + String urls = address1.toString(false, false); + if (address2 != null) { + urls += " " + address2.toString(false, false); + } + if (address3 != null) { + urls += " " + address3.toString(false, false); + } + if (address4 != null) { + urls += " " + address4.toString(false, false); + } + + tokenReplacements.put(prefix + URLS, urls); + } else { + tokenReplacements.put(LISTEN1, address1 == null ? "" : address1.toString(false, false)); + tokenReplacements.put(LISTEN2, address2 == null ? "" : address2.toString(false, false)); + tokenReplacements.put(LISTEN3, address3 == null ? "" : address3.toString(false, false)); + tokenReplacements.put(LISTEN4, address4 == null ? "" : address4.toString(false, false)); + } + } }
public String serverRoot = null; @@ -74,33 +129,51 @@ public class ApacheDeploymentUtil { mainServer.address3 = new Address(null, null, Address.NO_PORT_SPECIFIED_VALUE); mainServer.address4 = new Address(null, null, Address.NO_PORT_SPECIFIED_VALUE); } + + public Map<String, String> getTokenReplacements() { + HashMap<String, String> ret = new HashMap<String, String>(); + + ret.put(SERVER_ROOT, serverRoot == null ? "" : serverRoot); + ret.put(DOCUMENT_ROOT, documentRoot == null ? "" : documentRoot); + ret.put(SNMP_HOST, snmpHost == null ? "" : snmpHost); + ret.put(SNMP_PORT, Integer.toString(snmpPort)); + mainServer.addToTokenReplacements(0, ret); + vhost1.addToTokenReplacements(1, ret); + vhost2.addToTokenReplacements(2, ret); + vhost3.addToTokenReplacements(3, ret); + vhost4.addToTokenReplacements(4, ret); + + return ret; + } }
public static DeploymentConfig getDeploymentConfigurationFromSystemProperties(String variablesPrefix) { DeploymentConfig ret = new DeploymentConfig();
- ret.serverRoot = System.getProperty(variablesPrefix + ".server.root"); - ret.documentRoot = System.getProperty(variablesPrefix + ".document.root", "htdocs"); - ret.snmpHost = System.getProperty(variablesPrefix + ".snmp.host", "localhost"); - ret.snmpPort = Integer.parseInt(System.getProperty(variablesPrefix + ".snmp.port", "1610")); - ret.mainServer.address1 = HttpdAddressUtility.parseListen(System.getProperty(variablesPrefix + ".listen1")); - ret.mainServer.address2 = HttpdAddressUtility.parseListen(System.getProperty(variablesPrefix + ".listen2")); - ret.mainServer.address3 = HttpdAddressUtility.parseListen(System.getProperty(variablesPrefix + ".listen3")); - ret.mainServer.address4 = HttpdAddressUtility.parseListen(System.getProperty(variablesPrefix + ".listen4")); - ret.mainServer.serverNameDirective = System.getProperty(variablesPrefix + ".servername.directive"); + variablesPrefix += "."; + + ret.serverRoot = System.getProperty(variablesPrefix + SERVER_ROOT); + ret.documentRoot = System.getProperty(variablesPrefix + DOCUMENT_ROOT, "htdocs"); + ret.snmpHost = System.getProperty(variablesPrefix + SNMP_HOST, "localhost"); + ret.snmpPort = Integer.parseInt(System.getProperty(variablesPrefix + SNMP_PORT, "1610")); + ret.mainServer.address1 = HttpdAddressUtility.parseListen(System.getProperty(variablesPrefix + LISTEN1)); + ret.mainServer.address2 = HttpdAddressUtility.parseListen(System.getProperty(variablesPrefix + LISTEN2)); + ret.mainServer.address3 = HttpdAddressUtility.parseListen(System.getProperty(variablesPrefix + LISTEN3)); + ret.mainServer.address4 = HttpdAddressUtility.parseListen(System.getProperty(variablesPrefix + LISTEN4)); + ret.mainServer.serverNameDirective = System.getProperty(variablesPrefix + SERVERNAME_DIRECTIVE);
- String additionalDirectives = System.getProperty(variablesPrefix + ".additional.directives"); + String additionalDirectives = System.getProperty(variablesPrefix + ADDITIONAL_DIRECTIVES); fillAdditionalDirectives(additionalDirectives, ret.mainServer.additionalDirectives);
- readVHostConfigFromSystemProperties(ret.vhost1, variablesPrefix + ".vhost1"); - readVHostConfigFromSystemProperties(ret.vhost2, variablesPrefix + ".vhost2"); - readVHostConfigFromSystemProperties(ret.vhost3, variablesPrefix + ".vhost3"); - readVHostConfigFromSystemProperties(ret.vhost4, variablesPrefix + ".vhost4"); + readVHostConfigFromSystemProperties(ret.vhost1, variablesPrefix + VHOST + 1); + readVHostConfigFromSystemProperties(ret.vhost2, variablesPrefix + VHOST + 2); + readVHostConfigFromSystemProperties(ret.vhost3, variablesPrefix + VHOST + 3); + readVHostConfigFromSystemProperties(ret.vhost4, variablesPrefix + VHOST + 4);
return ret; }
- public static void deployConfiguration(File targetConfDirectory, List<String> configFilesOnClasspath, DeploymentConfig config) throws IOException { + public static void deployConfiguration(File targetConfDirectory, Collection<String> configFilesOnClasspath, DeploymentConfig config) throws IOException { List<File> targetFiles = new ArrayList<File>(); for(String fileOnClassPath : configFilesOnClasspath) { String fileName = new File(fileOnClassPath).getName(); @@ -119,123 +192,42 @@ public class ApacheDeploymentUtil {
private static void replaceTokensInConfigFiles(List<File> configFiles, DeploymentConfig config) { char[] buffer = new char[8192]; - StringBuilder wholeFile = new StringBuilder(); + + Map<String, String> replacements = config.getTokenReplacements(); + for(File file : configFiles) { - BufferedReader rdr = null; - boolean errorOccured = false; + TokenReplacingReader rdr = null; + FileWriter wrt = null; + try { - rdr = new BufferedReader(new FileReader(file)); - - int cnt = -1; - - while ((cnt = rdr.read(buffer)) != -1) { - wholeFile.append(buffer, 0, cnt); - } - } catch (FileNotFoundException e) { - LOG.error("File '" + file + "' not found.", e); - errorOccured = true; - } catch (IOException e) { - LOG.error("Error while reading file '" + file + "'.", e); - errorOccured = true; - } - - if (rdr != null) { - try { - rdr.close(); - } catch (IOException e) { - LOG.error("Failed to close the file '" + file + "'."); - } - } - - if (errorOccured) { - continue; + rdr = new TokenReplacingReader(new FileReader(file), replacements); + + File tmp = File.createTempFile("apache-deployment-util", null); + + wrt = new FileWriter(tmp); + + int cnt = -1; + + while ((cnt = rdr.read(buffer)) != -1) { + wrt.write(buffer, 0, cnt); }
- String newFileContents = replaceTokens(wholeFile, config); + wrt.close();
- Writer wrt = null; - try { - wrt = new FileWriter(file); - - wrt.write(newFileContents); + tmp.renameTo(file); } catch (IOException e) { - LOG.error("Error while writing to the configuration file '" + file + "'.", e); - } finally { - try { - wrt.close(); - } catch (IOException e) { - LOG.error("Failed to close the file '" + file + "'.", e); - } + LOG.error("Error while replacing the tokens in file '" + file + "'.", e); } } }
- private static String replaceTokens(CharSequence input, DeploymentConfig config) { - String s = input.toString(); - - s = s.replaceAll("\$SERVER_ROOT", config.serverRoot); - s = s.replaceAll("\$DOCUMENT_ROOT", config.documentRoot); - s = s.replaceAll("\$SNMP_HOST", config.snmpHost); - s = s.replaceAll("\$SNMP_PORT", Integer.toString(config.snmpPort)); - s = s.replaceAll("\$LISTEN_1", config.mainServer.address1.toString()); - s = s.replaceAll("\$LISTEN_2", config.mainServer.address2.toString()); - s = s.replaceAll("\$LISTEN_3", config.mainServer.address3.toString()); - s = s.replaceAll("\$LISTEN_4", config.mainServer.address4.toString()); - s = s.replaceAll("\$SNMP_HOST", config.snmpHost); - - s = replaceVHostTokens(s, 0, config.mainServer); - s = replaceVHostTokens(s, 1, config.vhost1); - s = replaceVHostTokens(s, 2, config.vhost2); - s = replaceVHostTokens(s, 3, config.vhost3); - s = replaceVHostTokens(s, 4, config.vhost4); - - return s; - } - - private static String replaceVHostTokens(String input, int vhostNumber, DeploymentConfig.VHost vhost) { - String serverNameToken = getVhostOrMainServerToken(vhostNumber, "SERVER_NAME_DIRECTIVE"); - String urlsToken = getVhostOrMainServerToken(vhostNumber, "URLS"); - String additionalDirectivesToken = getVhostOrMainServerToken(vhostNumber, "ADDITIONAL_DIRECTIVES"); - - input = input.replaceAll(serverNameToken, vhost.serverNameDirective == null ? "" : vhost.serverNameDirective); - - if (vhostNumber > 0) { - String urls = vhost.address1.toString(false, false); - if (vhost.address2 != null) { - urls += " " + vhost.address2.toString(false, false); - } - if (vhost.address3 != null) { - urls += " " + vhost.address3.toString(false, false); - } - if (vhost.address4 != null) { - urls += " " + vhost.address4.toString(false, false); - } - - input = input.replaceAll(urlsToken, urls); - } - - String additionalDirectives = ""; - if (!vhost.additionalDirectives.isEmpty()) { - String newline = System.getProperty("line.separator"); - for(String dir : vhost.additionalDirectives) { - additionalDirectives += dir + newline; - } - } - - input = input.replaceAll(additionalDirectivesToken, additionalDirectives); - - return input; - } - - private static String getVhostOrMainServerToken(int vhostNumber, String tokenBody) { - return "\$" + (vhostNumber == 0 ? "" : ("VHOST" + vhostNumber + "_")) + tokenBody; - } - private static void readVHostConfigFromSystemProperties(DeploymentConfig.VHost vhost, String prefix) { - String addrsString = System.getProperty(prefix + ".urls"); + prefix += "."; + + String addrsString = System.getProperty(prefix + URLS);
if (addrsString == null) { - throw new IllegalStateException("The system property '" + prefix + ".urls' doesn't exist. It is needed to define the vhost."); + throw new IllegalStateException("The system property '" + prefix + "urls' doesn't exist. It is needed to define the vhost."); }
String[] addrs = addrsString.split("[ \t]+"); @@ -252,12 +244,12 @@ public class ApacheDeploymentUtil { vhost.address1 = Address.parse(addrs[0], null); break; default: - throw new IllegalStateException("The system property '" + prefix + ".urls' specified " + addrs.length + " addresses. Only 1-4 addresses are supported."); + throw new IllegalStateException("The system property '" + prefix + "urls' specified " + addrs.length + " addresses. Only 1-4 addresses are supported."); }
- vhost.serverNameDirective = System.getProperty(prefix + ".servername.directive"); + vhost.serverNameDirective = System.getProperty(prefix + SERVERNAME_DIRECTIVE);
- String additionalDirectives = System.getProperty(prefix + ".additional.directives"); + String additionalDirectives = System.getProperty(prefix + ADDITIONAL_DIRECTIVES); fillAdditionalDirectives(additionalDirectives, vhost.additionalDirectives); }
diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/FakeInventory.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/FakeInventory.java deleted file mode 100644 index a4d0193..0000000 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/FakeInventory.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2011 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.plugins.apache.util; - -import java.util.Collection; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Set; - -/** - * - * - * @author Lukas Krejci - */ -public class FakeInventory { - - HashMap<Class<?>, Set<Object>> database = new HashMap<Class<?>, Set<Object>>(); - - private static final Comparator<Object> EQUALS_COMPARATOR = new Comparator<Object>() { - @Override - public int compare(Object a, Object b) { - if (a == null ? b == null : a.equals(b)) { - return 0; - } - return 1; - } - }; - - public boolean insert(Object o) { - Class<?> c = o.getClass(); - - Set<Object> objects = database.get(c); - - if (objects == null) { - objects = new HashSet<Object>(); - } - - return objects.add(o); - } - - public void insertAll(Object... objects) { - for(Object o : objects) { - insert(o); - } - } - - public void insertAll(Collection<Object> objects) { - for(Object o : objects) { - insert(o); - } - } - - @SuppressWarnings("unchecked") - public <T> T get(T prototype) { - return get(prototype, (Class<T>) prototype.getClass()); - } - - public <T> T get(T prototype, Class<T> clazz) { - return get(prototype, clazz, EQUALS_COMPARATOR); - } - - public <T> T get(T prototype, Class<T> clazz, Comparator<? super T> comparator) { - Set<Object> objects = database.get(clazz); - - if (objects == null) { - return null; - } - - for (Object o : objects) { - T cast = clazz.cast(o); - if (comparator.compare(cast, prototype) == 0) { - return cast; - } - } - - return null; - } -} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/TokenReplacingReader.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/TokenReplacingReader.java new file mode 100644 index 0000000..7ebf48b --- /dev/null +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/TokenReplacingReader.java @@ -0,0 +1,146 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.plugins.apache.util; + +import java.io.IOException; +import java.io.PushbackReader; +import java.io.Reader; +import java.nio.CharBuffer; +import java.util.Map; + +/** + * Copied from http://tutorials.jenkov.com/java-howto/replace-strings-in-streams-arrays-fil... + * with fixes to {@link #read(char[], int, int)} and added support for escaping. + * + * @author Lukas Krejci + */ +public class TokenReplacingReader extends Reader { + + private PushbackReader pushbackReader = null; + private Map<String, String> tokens = null; + private StringBuilder tokenNameBuffer = new StringBuilder(); + private String tokenValue = null; + private int tokenValueIndex = 0; + private boolean escaping = false; + + public TokenReplacingReader(Reader source, Map<String, String> tokens) { + this.pushbackReader = new PushbackReader(source, 2); + this.tokens = tokens; + } + + public int read(CharBuffer target) throws IOException { + throw new RuntimeException("Operation Not Supported"); + } + + public int read() throws IOException { + if (this.tokenValue != null) { + if (this.tokenValueIndex < this.tokenValue.length()) { + return this.tokenValue.charAt(this.tokenValueIndex++); + } + if (this.tokenValueIndex == this.tokenValue.length()) { + this.tokenValue = null; + this.tokenValueIndex = 0; + } + } + + int data = this.pushbackReader.read(); + + if (escaping) { + escaping = false; + return data; + } + + if (data == '\') { + escaping = true; + return data; + } + + if (data != '$') + return data; + + data = this.pushbackReader.read(); + if (data != '{') { + this.pushbackReader.unread(data); + return '$'; + } + this.tokenNameBuffer.delete(0, this.tokenNameBuffer.length()); + + data = this.pushbackReader.read(); + while (data != '}') { + this.tokenNameBuffer.append((char) data); + data = this.pushbackReader.read(); + } + + this.tokenValue = tokens.get(this.tokenNameBuffer.toString()); + + if (this.tokenValue == null) { + this.tokenValue = "${" + this.tokenNameBuffer.toString() + "}"; + } + + if (!this.tokenValue.isEmpty()) { + return this.tokenValue.charAt(this.tokenValueIndex++); + } else { + return read(); + } + } + + public int read(char cbuf[]) throws IOException { + return read(cbuf, 0, cbuf.length); + } + + public int read(char cbuf[], int off, int len) throws IOException { + int i = 0; + for (; i < len; i++) { + int nextChar = read(); + if (nextChar == -1) { + if (i == 0) { + i = -1; + } + break; + } + cbuf[off + i] = (char) nextChar; + } + return i; + } + + public void close() throws IOException { + this.pushbackReader.close(); + } + + public long skip(long n) throws IOException { + throw new RuntimeException("Operation Not Supported"); + } + + public boolean ready() throws IOException { + return this.pushbackReader.ready(); + } + + public boolean markSupported() { + return false; + } + + public void mark(int readAheadLimit) throws IOException { + throw new RuntimeException("Operation Not Supported"); + } + + public void reset() throws IOException { + throw new RuntimeException("Operation Not Supported"); + } +} diff --git a/modules/plugins/apache/src/test/resources/full-configurations/includes/1.vhost.conf b/modules/plugins/apache/src/test/resources/full-configurations/includes/1.vhost.conf index 3d0cbb8..7b56cae 100644 --- a/modules/plugins/apache/src/test/resources/full-configurations/includes/1.vhost.conf +++ b/modules/plugins/apache/src/test/resources/full-configurations/includes/1.vhost.conf @@ -1,9 +1,9 @@ -<VirtualHost $VHOST1_URLS> - $VHOST1_SERVER_NAME_DIRECTIVE - $VHOST1_ADDITIONAL_DIRECTIVES +<VirtualHost ${vhost1.urls}> + ${vhost1.servername.directive} + ${vhost1.additional.directives} </VirtualHost>
-<VirtualHost $VHOST2_URLS> - $VHOST2_SERVER_NAME_DIRECTIVE - $VHOST2_ADDITIONAL_DIRECTIVES +<VirtualHost ${vhost2.urls}> + ${vhost2.servername.directive} + ${vhost2.additional.directives} </VirtualHost> diff --git a/modules/plugins/apache/src/test/resources/full-configurations/includes/2.vhost.conf b/modules/plugins/apache/src/test/resources/full-configurations/includes/2.vhost.conf index 5a5025e..b4a7725 100644 --- a/modules/plugins/apache/src/test/resources/full-configurations/includes/2.vhost.conf +++ b/modules/plugins/apache/src/test/resources/full-configurations/includes/2.vhost.conf @@ -1,9 +1,9 @@ -<VirtualHost $VHOST3_URLS> - $VHOST3_SERVER_NAME_DIRECTIVE - $VHOST3_ADDITIONAL_DIRECTIVES +<VirtualHost ${vhost3.urls}> + ${vhost3.servername.directive} + ${vhost3.additional.directives} </VirtualHost>
-<VirtualHost $VHOST4_URLS> - $VHOST4_SERVER_NAME_DIRECTIVE - $VHOST4_ADDITIONAL_DIRECTIVES +<VirtualHost ${vhost4.urls}> + ${vhost4.servername.directive} + ${vhost4.additional.directives} </VirtualHost> diff --git a/modules/plugins/apache/src/test/resources/full-configurations/includes/httpd.conf b/modules/plugins/apache/src/test/resources/full-configurations/includes/httpd.conf index d0cf67c..ebc07ac 100644 --- a/modules/plugins/apache/src/test/resources/full-configurations/includes/httpd.conf +++ b/modules/plugins/apache/src/test/resources/full-configurations/includes/httpd.conf @@ -1,15 +1,15 @@ -ServerRoot $SERVER_ROOT +ServerRoot ${server.root}
-Listen $LISTEN_1 -Listen $LISTEN_2 -Listen $LISTEN_3 -Listen $LISTEN_4 +Listen ${listen1} +Listen ${listen2} +Listen ${listen3} +Listen ${listen4}
ServerAdmin root@localhost
-$SERVER_NAME_DIRECTIVE +${servername.directive}
-DocumentRoot $DOCUMENT_ROOT +DocumentRoot ${document.root}
DirectoryIndex index.html index.html.var
@@ -35,6 +35,6 @@ SNMPConf conf SNMPVar var # End of apache SNMP
-$ADDITIONAL_DIRECTIVES +${additional.directives}
Include *.vhost.conf diff --git a/modules/plugins/apache/src/test/resources/full-configurations/mess/1.vhost.conf b/modules/plugins/apache/src/test/resources/full-configurations/mess/1.vhost.conf index 1898969..39cf84a 100644 --- a/modules/plugins/apache/src/test/resources/full-configurations/mess/1.vhost.conf +++ b/modules/plugins/apache/src/test/resources/full-configurations/mess/1.vhost.conf @@ -1,7 +1,7 @@ <IfModule not_loaded_module> - <VirtualHost $VHOST1_URLS> - $VHOST1_SERVER_NAME_DIRECTIVE - $VHOST1_ADDITIONAL_DIRECTIVES + <VirtualHost ${vhost1.urls}> + ${vhost1.servername.directive} + ${vhost1.additional.directives} </VirtualHost> </IfModule>
@@ -9,9 +9,9 @@ LoadModule proxy_module modules/mod_proxy.so
<IfModule snmpcommon_module> <IfModule mod_proxy.c> - <VirtualHost $VHOST2_URLS> - $VHOST2_SERVER_NAME_DIRECTIVE - $VHOST2_ADDITIONAL_DIRECTIVES + <VirtualHost ${vhost2.urls}> + ${vhost2.servername.directive} + ${vhost2.additional.directives} </VirtualHost> </IfModule> </IfModule> diff --git a/modules/plugins/apache/src/test/resources/full-configurations/mess/2.vhost.conf b/modules/plugins/apache/src/test/resources/full-configurations/mess/2.vhost.conf index 146cea9..37854b6 100644 --- a/modules/plugins/apache/src/test/resources/full-configurations/mess/2.vhost.conf +++ b/modules/plugins/apache/src/test/resources/full-configurations/mess/2.vhost.conf @@ -1,13 +1,13 @@ <IfModule snmpcommon_module> <IfModule mod_unknown.c> - <VirtualHost $VHOST3_URLS> - $VHOST3_SERVER_NAME_DIRECTIVE - $VHOST3_ADDITIONAL_DIRECTIVES + <VirtualHost ${vhost3.urls}> + ${vhost3.servername.directive} + ${vhost3.additional.directives} </VirtualHost> </IfModule> </IfModule>
-<VirtualHost $VHOST4_URLS> - $VHOST4_SERVER_NAME_DIRECTIVE - $VHOST4_ADDITIONAL_DIRECTIVES +<VirtualHost ${vhost4.urls}> + ${vhost4.servername.directive} + ${vhost4.additional.directives} </VirtualHost> diff --git a/modules/plugins/apache/src/test/resources/full-configurations/mess/httpd.conf b/modules/plugins/apache/src/test/resources/full-configurations/mess/httpd.conf index d0cf67c..ebc07ac 100644 --- a/modules/plugins/apache/src/test/resources/full-configurations/mess/httpd.conf +++ b/modules/plugins/apache/src/test/resources/full-configurations/mess/httpd.conf @@ -1,15 +1,15 @@ -ServerRoot $SERVER_ROOT +ServerRoot ${server.root}
-Listen $LISTEN_1 -Listen $LISTEN_2 -Listen $LISTEN_3 -Listen $LISTEN_4 +Listen ${listen1} +Listen ${listen2} +Listen ${listen3} +Listen ${listen4}
ServerAdmin root@localhost
-$SERVER_NAME_DIRECTIVE +${servername.directive}
-DocumentRoot $DOCUMENT_ROOT +DocumentRoot ${document.root}
DirectoryIndex index.html index.html.var
@@ -35,6 +35,6 @@ SNMPConf conf SNMPVar var # End of apache SNMP
-$ADDITIONAL_DIRECTIVES +${additional.directives}
Include *.vhost.conf diff --git a/modules/plugins/apache/src/test/resources/full-configurations/nested/httpd.conf b/modules/plugins/apache/src/test/resources/full-configurations/nested/httpd.conf index 3882e8f..6112bdc 100644 --- a/modules/plugins/apache/src/test/resources/full-configurations/nested/httpd.conf +++ b/modules/plugins/apache/src/test/resources/full-configurations/nested/httpd.conf @@ -1,15 +1,15 @@ -ServerRoot $SERVER_ROOT +ServerRoot ${server.root}
-Listen $LISTEN_1 -Listen $LISTEN_2 -Listen $LISTEN_3 -Listen $LISTEN_4 +Listen ${listen1} +Listen ${listen2} +Listen ${listen3} +Listen ${listen4}
ServerAdmin root@localhost
-$SERVER_NAME_DIRECTIVE +${servername.directive}
-DocumentRoot $DOCUMENT_ROOT +DocumentRoot ${document.root}
DirectoryIndex index.html index.html.var
@@ -35,12 +35,12 @@ SNMPConf conf SNMPVar var # End of apache SNMP
-$ADDITIONAL_DIRECTIVES +${additional.directives}
<IfModule not_loaded_module> - <VirtualHost $VHOST1_URLS> - $VHOST1_SERVER_NAME_DIRECTIVE - $VHOST1_ADDITIONAL_DIRECTIVES + <VirtualHost ${vhost1.urls}> + ${vhost1.servername.directive} + ${vhost1.additional.directives} </VirtualHost> </IfModule>
@@ -48,21 +48,21 @@ LoadModule proxy_module modules/mod_proxy.so
<IfModule snmpcommon_module> <IfModule mod_proxy.c> - <VirtualHost $VHOST2_URLS> - $VHOST2_SERVER_NAME_DIRECTIVE - $VHOST2_ADDITIONAL_DIRECTIVES + <VirtualHost ${vhost2.urls}> + ${vhost2.servername.directive} + ${vhost2.additional.directives} </VirtualHost> </IfModule>
<IfModule mod_unknown.c> - <VirtualHost $VHOST3_URLS> - $VHOST3_SERVER_NAME_DIRECTIVE - $VHOST3_ADDITIONAL_DIRECTIVES + <VirtualHost ${vhost3.urls}> + ${vhost3.servername.directive} + ${vhost3.additional.directives} </VirtualHost> </IfModule> </IfModule>
-<VirtualHost $VHOST4_URLS> - $VHOST4_SERVER_NAME_DIRECTIVE - $VHOST4_ADDITIONAL_DIRECTIVES +<VirtualHost ${vhost4.urls}> + ${vhost4.servername.directive} + ${vhost4.additional.directives} </VirtualHost> diff --git a/modules/plugins/apache/src/test/resources/full-configurations/simple/httpd.conf b/modules/plugins/apache/src/test/resources/full-configurations/simple/httpd.conf index 13195ef..87142b4 100644 --- a/modules/plugins/apache/src/test/resources/full-configurations/simple/httpd.conf +++ b/modules/plugins/apache/src/test/resources/full-configurations/simple/httpd.conf @@ -1,15 +1,15 @@ -ServerRoot $SERVER_ROOT +ServerRoot ${server.root}
-Listen $LISTEN_1 -Listen $LISTEN_2 -Listen $LISTEN_3 -Listen $LISTEN_4 +Listen ${listen1} +Listen ${listen2} +Listen ${listen3} +Listen ${listen4}
ServerAdmin root@localhost
-$SERVER_NAME_DIRECTIVE +${servername.directive}
-DocumentRoot $DOCUMENT_ROOT +DocumentRoot ${document.root}
DirectoryIndex index.html index.html.var
@@ -35,24 +35,24 @@ SNMPConf conf SNMPVar var # End of apache SNMP
-$ADDITIONAL_DIRECTIVES +${additional.directives}
-<VirtualHost $VHOST1_URLS> - $VHOST1_SERVER_NAME_DIRECTIVE - $VHOST1_ADDITIONAL_DIRECTIVES +<VirtualHost ${vhost1.urls}> + ${vhost1.servername.directive} + ${vhost1.additional.directives} </VirtualHost>
-<VirtualHost $VHOST2_URLS> - $VHOST2_SERVER_NAME_DIRECTIVE - $VHOST2_ADDITIONAL_DIRECTIVES +<VirtualHost ${vhost2.urls}> + ${vhost2.servername.directive} + ${vhost2.additional.directives} </VirtualHost>
-<VirtualHost $VHOST3_URLS> - $VHOST3_SERVER_NAME_DIRECTIVE - $VHOST3_ADDITIONAL_DIRECTIVES +<VirtualHost ${vhost3.urls}> + ${vhost3.servername.directive} + ${vhost3.additional.directives} </VirtualHost>
-<VirtualHost $VHOST4_URLS> - $VHOST4_SERVER_NAME_DIRECTIVE - $VHOST4_ADDITIONAL_DIRECTIVES +<VirtualHost ${vhost4.urls}> + ${vhost4.servername.directive} + ${vhost4.additional.directives} </VirtualHost> diff --git a/modules/plugins/apache/src/test/resources/mime.types b/modules/plugins/apache/src/test/resources/mime.types new file mode 100644 index 0000000..1ae0097 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mime.types @@ -0,0 +1,1351 @@ +# This file maps Internet media types to unique file extension(s). +# Although created for httpd, this file is used by many software systems +# and has been placed in the public domain for unlimited redisribution. +# +# The table below contains both registered and (common) unregistered types. +# A type that has no unique extension can be ignored -- they are listed +# here to guide configurations toward known types and to make it easier to +# identify "new" types. File extensions are also commonly used to indicate +# content languages and encodings, so choose them carefully. +# +# Internet media types should be registered as described in RFC 4288. +# The registry is at http://www.iana.org/assignments/media-types/. +# +# MIME type Extensions +# application/3gpp-ims+xml +# application/activemessage +application/andrew-inset ez +# application/applefile +application/applixware aw +application/atom+xml atom +application/atomcat+xml atomcat +# application/atomicmail +application/atomsvc+xml atomsvc +# application/auth-policy+xml +# application/batch-smtp +# application/beep+xml +# application/cals-1840 +application/ccxml+xml ccxml +# application/cea-2018+xml +# application/cellml+xml +# application/cnrp+xml +# application/commonground +# application/conference-info+xml +# application/cpl+xml +# application/csta+xml +# application/cstadata+xml +application/cu-seeme cu +# application/cybercash +application/davmount+xml davmount +# application/dca-rft +# application/dec-dx +# application/dialog-info+xml +# application/dicom +# application/dns +application/dssc+der dssc +application/dssc+xml xdssc +# application/dvcs +application/ecmascript ecma +# application/edi-consent +# application/edi-x12 +# application/edifact +application/emma+xml emma +# application/epp+xml +application/epub+zip epub +# application/eshop +# application/example +# application/fastinfoset +# application/fastsoap +# application/fits +application/font-tdpfr pfr +# application/h224 +# application/held+xml +# application/http +application/hyperstudio stk +# application/ibe-key-request+xml +# application/ibe-pkg-reply+xml +# application/ibe-pp-data +# application/iges +# application/im-iscomposing+xml +# application/index +# application/index.cmd +# application/index.obj +# application/index.response +# application/index.vnd +# application/iotp +application/ipfix ipfix +# application/ipp +# application/isup +application/java-archive jar +application/java-serialized-object ser +application/java-vm class +application/javascript js +application/json json +# application/kpml-request+xml +# application/kpml-response+xml +application/lost+xml lostxml +application/mac-binhex40 hqx +application/mac-compactpro cpt +# application/macwriteii +application/marc mrc +application/mathematica ma nb mb +application/mathml+xml mathml +# application/mbms-associated-procedure-description+xml +# application/mbms-deregister+xml +# application/mbms-envelope+xml +# application/mbms-msk+xml +# application/mbms-msk-response+xml +# application/mbms-protection-description+xml +# application/mbms-reception-report+xml +# application/mbms-register+xml +# application/mbms-register-response+xml +# application/mbms-user-service-description+xml +application/mbox mbox +# application/media_control+xml +application/mediaservercontrol+xml mscml +# application/mikey +# application/moss-keys +# application/moss-signature +# application/mosskey-data +# application/mosskey-request +application/mp4 mp4s +# application/mpeg4-generic +# application/mpeg4-iod +# application/mpeg4-iod-xmt +application/msword doc dot +application/mxf mxf +# application/nasdata +# application/news-checkgroups +# application/news-groupinfo +# application/news-transmission +# application/nss +# application/ocsp-request +# application/ocsp-response +application/octet-stream bin dms lha lrf lzh so iso dmg dist distz pkg bpk dump elc deploy +application/oda oda +application/oebps-package+xml opf +application/ogg ogx +application/onenote onetoc onetoc2 onetmp onepkg +# application/parityfec +application/patch-ops-error+xml xer +application/pdf pdf +application/pgp-encrypted pgp +# application/pgp-keys +application/pgp-signature asc sig +application/pics-rules prf +# application/pidf+xml +# application/pidf-diff+xml +application/pkcs10 p10 +application/pkcs7-mime p7m p7c +application/pkcs7-signature p7s +application/pkix-cert cer +application/pkix-crl crl +application/pkix-pkipath pkipath +application/pkixcmp pki +application/pls+xml pls +# application/poc-settings+xml +application/postscript ai eps ps +# application/prs.alvestrand.titrax-sheet +application/prs.cww cww +# application/prs.nprend +# application/prs.plucker +# application/qsig +application/rdf+xml rdf +application/reginfo+xml rif +application/relax-ng-compact-syntax rnc +# application/remote-printing +application/resource-lists+xml rl +application/resource-lists-diff+xml rld +# application/riscos +# application/rlmi+xml +application/rls-services+xml rs +application/rsd+xml rsd +application/rss+xml rss +application/rtf rtf +# application/rtx +# application/samlassertion+xml +# application/samlmetadata+xml +application/sbml+xml sbml +application/scvp-cv-request scq +application/scvp-cv-response scs +application/scvp-vp-request spq +application/scvp-vp-response spp +application/sdp sdp +# application/set-payment +application/set-payment-initiation setpay +# application/set-registration +application/set-registration-initiation setreg +# application/sgml +# application/sgml-open-catalog +application/shf+xml shf +# application/sieve +# application/simple-filter+xml +# application/simple-message-summary +# application/simplesymbolcontainer +# application/slate +# application/smil +application/smil+xml smi smil +# application/soap+fastinfoset +# application/soap+xml +application/sparql-query rq +application/sparql-results+xml srx +# application/spirits-event+xml +application/srgs gram +application/srgs+xml grxml +application/ssml+xml ssml +# application/timestamp-query +# application/timestamp-reply +# application/tve-trigger +# application/ulpfec +# application/vemmi +# application/vividence.scriptfile +# application/vnd.3gpp.bsf+xml +application/vnd.3gpp.pic-bw-large plb +application/vnd.3gpp.pic-bw-small psb +application/vnd.3gpp.pic-bw-var pvb +# application/vnd.3gpp.sms +# application/vnd.3gpp2.bcmcsinfo+xml +# application/vnd.3gpp2.sms +application/vnd.3gpp2.tcap tcap +application/vnd.3m.post-it-notes pwn +application/vnd.accpac.simply.aso aso +application/vnd.accpac.simply.imp imp +application/vnd.acucobol acu +application/vnd.acucorp atc acutc +application/vnd.adobe.air-application-installer-package+zip air +# application/vnd.adobe.partial-upload +application/vnd.adobe.xdp+xml xdp +application/vnd.adobe.xfdf xfdf +# application/vnd.aether.imp +application/vnd.airzip.filesecure.azf azf +application/vnd.airzip.filesecure.azs azs +application/vnd.amazon.ebook azw +application/vnd.americandynamics.acc acc +application/vnd.amiga.ami ami +application/vnd.android.package-archive apk +application/vnd.anser-web-certificate-issue-initiation cii +application/vnd.anser-web-funds-transfer-initiation fti +application/vnd.antix.game-component atx +application/vnd.apple.installer+xml mpkg +application/vnd.apple.mpegurl m3u8 +# application/vnd.arastra.swi +application/vnd.aristanetworks.swi swi +application/vnd.audiograph aep +# application/vnd.autopackage +# application/vnd.avistar+xml +application/vnd.blueice.multipass mpm +# application/vnd.bluetooth.ep.oob +application/vnd.bmi bmi +application/vnd.businessobjects rep +# application/vnd.cab-jscript +# application/vnd.canon-cpdl +# application/vnd.canon-lips +# application/vnd.cendio.thinlinc.clientconf +application/vnd.chemdraw+xml cdxml +application/vnd.chipnuts.karaoke-mmd mmd +application/vnd.cinderella cdy +# application/vnd.cirpack.isdn-ext +application/vnd.claymore cla +application/vnd.cloanto.rp9 rp9 +application/vnd.clonk.c4group c4g c4d c4f c4p c4u +# application/vnd.commerce-battelle +application/vnd.commonspace csp +application/vnd.contact.cmsg cdbcmsg +application/vnd.cosmocaller cmc +application/vnd.crick.clicker clkx +application/vnd.crick.clicker.keyboard clkk +application/vnd.crick.clicker.palette clkp +application/vnd.crick.clicker.template clkt +application/vnd.crick.clicker.wordbank clkw +application/vnd.criticaltools.wbs+xml wbs +application/vnd.ctc-posml pml +# application/vnd.ctct.ws+xml +# application/vnd.cups-pdf +# application/vnd.cups-postscript +application/vnd.cups-ppd ppd +# application/vnd.cups-raster +# application/vnd.cups-raw +application/vnd.curl.car car +application/vnd.curl.pcurl pcurl +# application/vnd.cybank +application/vnd.data-vision.rdz rdz +application/vnd.denovo.fcselayout-link fe_launch +# application/vnd.dir-bi.plate-dl-nosuffix +application/vnd.dna dna +application/vnd.dolby.mlp mlp +# application/vnd.dolby.mobile.1 +# application/vnd.dolby.mobile.2 +application/vnd.dpgraph dpg +application/vnd.dreamfactory dfac +# application/vnd.dvb.esgcontainer +# application/vnd.dvb.ipdcdftnotifaccess +# application/vnd.dvb.ipdcesgaccess +# application/vnd.dvb.ipdcroaming +# application/vnd.dvb.iptv.alfec-base +# application/vnd.dvb.iptv.alfec-enhancement +# application/vnd.dvb.notif-aggregate-root+xml +# application/vnd.dvb.notif-container+xml +# application/vnd.dvb.notif-generic+xml +# application/vnd.dvb.notif-ia-msglist+xml +# application/vnd.dvb.notif-ia-registration-request+xml +# application/vnd.dvb.notif-ia-registration-response+xml +# application/vnd.dvb.notif-init+xml +# application/vnd.dxr +application/vnd.dynageo geo +# application/vnd.ecdis-update +application/vnd.ecowin.chart mag +# application/vnd.ecowin.filerequest +# application/vnd.ecowin.fileupdate +# application/vnd.ecowin.series +# application/vnd.ecowin.seriesrequest +# application/vnd.ecowin.seriesupdate +# application/vnd.emclient.accessrequest+xml +application/vnd.enliven nml +application/vnd.epson.esf esf +application/vnd.epson.msf msf +application/vnd.epson.quickanime qam +application/vnd.epson.salt slt +application/vnd.epson.ssf ssf +# application/vnd.ericsson.quickcall +application/vnd.eszigno3+xml es3 et3 +# application/vnd.etsi.aoc+xml +# application/vnd.etsi.cug+xml +# application/vnd.etsi.iptvcommand+xml +# application/vnd.etsi.iptvdiscovery+xml +# application/vnd.etsi.iptvprofile+xml +# application/vnd.etsi.iptvsad-bc+xml +# application/vnd.etsi.iptvsad-cod+xml +# application/vnd.etsi.iptvsad-npvr+xml +# application/vnd.etsi.iptvueprofile+xml +# application/vnd.etsi.mcid+xml +# application/vnd.etsi.sci+xml +# application/vnd.etsi.simservs+xml +# application/vnd.etsi.tsl+xml +# application/vnd.etsi.tsl.der +# application/vnd.eudora.data +application/vnd.ezpix-album ez2 +application/vnd.ezpix-package ez3 +# application/vnd.f-secure.mobile +application/vnd.fdf fdf +application/vnd.fdsn.mseed mseed +application/vnd.fdsn.seed seed dataless +# application/vnd.ffsns +# application/vnd.fints +application/vnd.flographit gph +application/vnd.fluxtime.clip ftc +# application/vnd.font-fontforge-sfd +application/vnd.framemaker fm frame maker book +application/vnd.frogans.fnc fnc +application/vnd.frogans.ltf ltf +application/vnd.fsc.weblaunch fsc +application/vnd.fujitsu.oasys oas +application/vnd.fujitsu.oasys2 oa2 +application/vnd.fujitsu.oasys3 oa3 +application/vnd.fujitsu.oasysgp fg5 +application/vnd.fujitsu.oasysprs bh2 +# application/vnd.fujixerox.art-ex +# application/vnd.fujixerox.art4 +# application/vnd.fujixerox.hbpl +application/vnd.fujixerox.ddd ddd +application/vnd.fujixerox.docuworks xdw +application/vnd.fujixerox.docuworks.binder xbd +# application/vnd.fut-misnet +application/vnd.fuzzysheet fzs +application/vnd.genomatix.tuxedo txd +# application/vnd.geocube+xml +application/vnd.geogebra.file ggb +application/vnd.geogebra.tool ggt +application/vnd.geometry-explorer gex gre +application/vnd.geonext gxt +application/vnd.geoplan g2w +application/vnd.geospace g3w +# application/vnd.globalplatform.card-content-mgt +# application/vnd.globalplatform.card-content-mgt-response +application/vnd.gmx gmx +application/vnd.google-earth.kml+xml kml +application/vnd.google-earth.kmz kmz +application/vnd.grafeq gqf gqs +# application/vnd.gridmp +application/vnd.groove-account gac +application/vnd.groove-help ghf +application/vnd.groove-identity-message gim +application/vnd.groove-injector grv +application/vnd.groove-tool-message gtm +application/vnd.groove-tool-template tpl +application/vnd.groove-vcard vcg +application/vnd.handheld-entertainment+xml zmm +application/vnd.hbci hbci +# application/vnd.hcl-bireports +application/vnd.hhe.lesson-player les +application/vnd.hp-hpgl hpgl +application/vnd.hp-hpid hpid +application/vnd.hp-hps hps +application/vnd.hp-jlyt jlt +application/vnd.hp-pcl pcl +application/vnd.hp-pclxl pclxl +# application/vnd.httphone +application/vnd.hydrostatix.sof-data sfd-hdstx +application/vnd.hzn-3d-crossword x3d +# application/vnd.ibm.afplinedata +# application/vnd.ibm.electronic-media +application/vnd.ibm.minipay mpy +application/vnd.ibm.modcap afp listafp list3820 +application/vnd.ibm.rights-management irm +application/vnd.ibm.secure-container sc +application/vnd.iccprofile icc icm +application/vnd.igloader igl +application/vnd.immervision-ivp ivp +application/vnd.immervision-ivu ivu +# application/vnd.informedcontrol.rms+xml +# application/vnd.informix-visionary +application/vnd.intercon.formnet xpw xpx +# application/vnd.intertrust.digibox +# application/vnd.intertrust.nncp +application/vnd.intu.qbo qbo +application/vnd.intu.qfx qfx +# application/vnd.iptc.g2.conceptitem+xml +# application/vnd.iptc.g2.knowledgeitem+xml +# application/vnd.iptc.g2.newsitem+xml +# application/vnd.iptc.g2.packageitem+xml +application/vnd.ipunplugged.rcprofile rcprofile +application/vnd.irepository.package+xml irp +application/vnd.is-xpr xpr +application/vnd.jam jam +# application/vnd.japannet-directory-service +# application/vnd.japannet-jpnstore-wakeup +# application/vnd.japannet-payment-wakeup +# application/vnd.japannet-registration +# application/vnd.japannet-registration-wakeup +# application/vnd.japannet-setstore-wakeup +# application/vnd.japannet-verification +# application/vnd.japannet-verification-wakeup +application/vnd.jcp.javame.midlet-rms rms +application/vnd.jisp jisp +application/vnd.joost.joda-archive joda +application/vnd.kahootz ktz ktr +application/vnd.kde.karbon karbon +application/vnd.kde.kchart chrt +application/vnd.kde.kformula kfo +application/vnd.kde.kivio flw +application/vnd.kde.kontour kon +application/vnd.kde.kpresenter kpr kpt +application/vnd.kde.kspread ksp +application/vnd.kde.kword kwd kwt +application/vnd.kenameaapp htke +application/vnd.kidspiration kia +application/vnd.kinar kne knp +application/vnd.koan skp skd skt skm +application/vnd.kodak-descriptor sse +# application/vnd.liberty-request+xml +application/vnd.llamagraphics.life-balance.desktop lbd +application/vnd.llamagraphics.life-balance.exchange+xml lbe +application/vnd.lotus-1-2-3 123 +application/vnd.lotus-approach apr +application/vnd.lotus-freelance pre +application/vnd.lotus-notes nsf +application/vnd.lotus-organizer org +application/vnd.lotus-screencam scm +application/vnd.lotus-wordpro lwp +application/vnd.macports.portpkg portpkg +# application/vnd.marlin.drm.actiontoken+xml +# application/vnd.marlin.drm.conftoken+xml +# application/vnd.marlin.drm.license+xml +# application/vnd.marlin.drm.mdcf +application/vnd.mcd mcd +application/vnd.medcalcdata mc1 +application/vnd.mediastation.cdkey cdkey +# application/vnd.meridian-slingshot +application/vnd.mfer mwf +application/vnd.mfmp mfm +application/vnd.micrografx.flo flo +application/vnd.micrografx.igx igx +application/vnd.mif mif +# application/vnd.minisoft-hp3000-save +# application/vnd.mitsubishi.misty-guard.trustweb +application/vnd.mobius.daf daf +application/vnd.mobius.dis dis +application/vnd.mobius.mbk mbk +application/vnd.mobius.mqy mqy +application/vnd.mobius.msl msl +application/vnd.mobius.plc plc +application/vnd.mobius.txf txf +application/vnd.mophun.application mpn +application/vnd.mophun.certificate mpc +# application/vnd.motorola.flexsuite +# application/vnd.motorola.flexsuite.adsi +# application/vnd.motorola.flexsuite.fis +# application/vnd.motorola.flexsuite.gotap +# application/vnd.motorola.flexsuite.kmr +# application/vnd.motorola.flexsuite.ttc +# application/vnd.motorola.flexsuite.wem +# application/vnd.motorola.iprm +application/vnd.mozilla.xul+xml xul +application/vnd.ms-artgalry cil +# application/vnd.ms-asf +application/vnd.ms-cab-compressed cab +application/vnd.ms-excel xls xlm xla xlc xlt xlw +application/vnd.ms-excel.addin.macroenabled.12 xlam +application/vnd.ms-excel.sheet.binary.macroenabled.12 xlsb +application/vnd.ms-excel.sheet.macroenabled.12 xlsm +application/vnd.ms-excel.template.macroenabled.12 xltm +application/vnd.ms-fontobject eot +application/vnd.ms-htmlhelp chm +application/vnd.ms-ims ims +application/vnd.ms-lrm lrm +application/vnd.ms-pki.seccat cat +application/vnd.ms-pki.stl stl +# application/vnd.ms-playready.initiator+xml +application/vnd.ms-powerpoint ppt pps pot +application/vnd.ms-powerpoint.addin.macroenabled.12 ppam +application/vnd.ms-powerpoint.presentation.macroenabled.12 pptm +application/vnd.ms-powerpoint.slide.macroenabled.12 sldm +application/vnd.ms-powerpoint.slideshow.macroenabled.12 ppsm +application/vnd.ms-powerpoint.template.macroenabled.12 potm +application/vnd.ms-project mpp mpt +# application/vnd.ms-tnef +# application/vnd.ms-wmdrm.lic-chlg-req +# application/vnd.ms-wmdrm.lic-resp +# application/vnd.ms-wmdrm.meter-chlg-req +# application/vnd.ms-wmdrm.meter-resp +application/vnd.ms-word.document.macroenabled.12 docm +application/vnd.ms-word.template.macroenabled.12 dotm +application/vnd.ms-works wps wks wcm wdb +application/vnd.ms-wpl wpl +application/vnd.ms-xpsdocument xps +application/vnd.mseq mseq +# application/vnd.msign +# application/vnd.multiad.creator +# application/vnd.multiad.creator.cif +# application/vnd.music-niff +application/vnd.musician mus +application/vnd.muvee.style msty +# application/vnd.ncd.control +# application/vnd.ncd.reference +# application/vnd.nervana +# application/vnd.netfpx +application/vnd.neurolanguage.nlu nlu +application/vnd.noblenet-directory nnd +application/vnd.noblenet-sealer nns +application/vnd.noblenet-web nnw +# application/vnd.nokia.catalogs +# application/vnd.nokia.conml+wbxml +# application/vnd.nokia.conml+xml +# application/vnd.nokia.isds-radio-presets +# application/vnd.nokia.iptv.config+xml +# application/vnd.nokia.landmark+wbxml +# application/vnd.nokia.landmark+xml +# application/vnd.nokia.landmarkcollection+xml +# application/vnd.nokia.n-gage.ac+xml +application/vnd.nokia.n-gage.data ngdat +application/vnd.nokia.n-gage.symbian.install n-gage +# application/vnd.nokia.ncd +# application/vnd.nokia.pcd+wbxml +# application/vnd.nokia.pcd+xml +application/vnd.nokia.radio-preset rpst +application/vnd.nokia.radio-presets rpss +application/vnd.novadigm.edm edm +application/vnd.novadigm.edx edx +application/vnd.novadigm.ext ext +# application/vnd.ntt-local.file-transfer +application/vnd.oasis.opendocument.chart odc +application/vnd.oasis.opendocument.chart-template otc +application/vnd.oasis.opendocument.database odb +application/vnd.oasis.opendocument.formula odf +application/vnd.oasis.opendocument.formula-template odft +application/vnd.oasis.opendocument.graphics odg +application/vnd.oasis.opendocument.graphics-template otg +application/vnd.oasis.opendocument.image odi +application/vnd.oasis.opendocument.image-template oti +application/vnd.oasis.opendocument.presentation odp +application/vnd.oasis.opendocument.presentation-template otp +application/vnd.oasis.opendocument.spreadsheet ods +application/vnd.oasis.opendocument.spreadsheet-template ots +application/vnd.oasis.opendocument.text odt +application/vnd.oasis.opendocument.text-master otm +application/vnd.oasis.opendocument.text-template ott +application/vnd.oasis.opendocument.text-web oth +# application/vnd.obn +application/vnd.olpc-sugar xo +# application/vnd.oma-scws-config +# application/vnd.oma-scws-http-request +# application/vnd.oma-scws-http-response +# application/vnd.oma.bcast.associated-procedure-parameter+xml +# application/vnd.oma.bcast.drm-trigger+xml +# application/vnd.oma.bcast.imd+xml +# application/vnd.oma.bcast.ltkm +# application/vnd.oma.bcast.notification+xml +# application/vnd.oma.bcast.provisioningtrigger +# application/vnd.oma.bcast.sgboot +# application/vnd.oma.bcast.sgdd+xml +# application/vnd.oma.bcast.sgdu +# application/vnd.oma.bcast.simple-symbol-container +# application/vnd.oma.bcast.smartcard-trigger+xml +# application/vnd.oma.bcast.sprov+xml +# application/vnd.oma.bcast.stkm +# application/vnd.oma.dcd +# application/vnd.oma.dcdc +application/vnd.oma.dd2+xml dd2 +# application/vnd.oma.drm.risd+xml +# application/vnd.oma.group-usage-list+xml +# application/vnd.oma.poc.detailed-progress-report+xml +# application/vnd.oma.poc.final-report+xml +# application/vnd.oma.poc.groups+xml +# application/vnd.oma.poc.invocation-descriptor+xml +# application/vnd.oma.poc.optimized-progress-report+xml +# application/vnd.oma.push +# application/vnd.oma.scidm.messages+xml +# application/vnd.oma.xcap-directory+xml +# application/vnd.omads-email+xml +# application/vnd.omads-file+xml +# application/vnd.omads-folder+xml +# application/vnd.omaloc-supl-init +application/vnd.openofficeorg.extension oxt +# application/vnd.openxmlformats-officedocument.custom-properties+xml +# application/vnd.openxmlformats-officedocument.customxmlproperties+xml +# application/vnd.openxmlformats-officedocument.drawing+xml +# application/vnd.openxmlformats-officedocument.drawingml.chart+xml +# application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml +# application/vnd.openxmlformats-officedocument.drawingml.diagramcolors+xml +# application/vnd.openxmlformats-officedocument.drawingml.diagramdata+xml +# application/vnd.openxmlformats-officedocument.drawingml.diagramlayout+xml +# application/vnd.openxmlformats-officedocument.drawingml.diagramstyle+xml +# application/vnd.openxmlformats-officedocument.extended-properties+xml +# application/vnd.openxmlformats-officedocument.presentationml.commentauthors+xml +# application/vnd.openxmlformats-officedocument.presentationml.comments+xml +# application/vnd.openxmlformats-officedocument.presentationml.handoutmaster+xml +# application/vnd.openxmlformats-officedocument.presentationml.notesmaster+xml +# application/vnd.openxmlformats-officedocument.presentationml.notesslide+xml +application/vnd.openxmlformats-officedocument.presentationml.presentation pptx +# application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml +# application/vnd.openxmlformats-officedocument.presentationml.presprops+xml +application/vnd.openxmlformats-officedocument.presentationml.slide sldx +# application/vnd.openxmlformats-officedocument.presentationml.slide+xml +# application/vnd.openxmlformats-officedocument.presentationml.slidelayout+xml +# application/vnd.openxmlformats-officedocument.presentationml.slidemaster+xml +application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx +# application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml +# application/vnd.openxmlformats-officedocument.presentationml.slideupdateinfo+xml +# application/vnd.openxmlformats-officedocument.presentationml.tablestyles+xml +# application/vnd.openxmlformats-officedocument.presentationml.tags+xml +application/vnd.openxmlformats-officedocument.presentationml.template potx +# application/vnd.openxmlformats-officedocument.presentationml.template.main+xml +# application/vnd.openxmlformats-officedocument.presentationml.viewprops+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.calcchain+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.externallink+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcachedefinition+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcacherecords+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.pivottable+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.querytable+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.revisionheaders+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.revisionlog+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.sharedstrings+xml +application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx +# application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.sheetmetadata+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.tablesinglecells+xml +application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx +# application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.usernames+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.volatiledependencies+xml +# application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml +# application/vnd.openxmlformats-officedocument.theme+xml +# application/vnd.openxmlformats-officedocument.themeoverride+xml +# application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml +application/vnd.openxmlformats-officedocument.wordprocessingml.document docx +# application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml +# application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml +# application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml +# application/vnd.openxmlformats-officedocument.wordprocessingml.fonttable+xml +# application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml +# application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml +# application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml +# application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml +# application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml +application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx +# application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml +# application/vnd.openxmlformats-officedocument.wordprocessingml.websettings+xml +# application/vnd.openxmlformats-package.core-properties+xml +# application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml +# application/vnd.osa.netdeploy +# application/vnd.osgi.bundle +application/vnd.osgi.dp dp +# application/vnd.otps.ct-kip+xml +application/vnd.palm pdb pqa oprc +# application/vnd.paos.xml +application/vnd.pawaafile paw +application/vnd.pg.format str +application/vnd.pg.osasli ei6 +# application/vnd.piaccess.application-licence +application/vnd.picsel efif +application/vnd.pmi.widget wg +# application/vnd.poc.group-advertisement+xml +application/vnd.pocketlearn plf +application/vnd.powerbuilder6 pbd +# application/vnd.powerbuilder6-s +# application/vnd.powerbuilder7 +# application/vnd.powerbuilder7-s +# application/vnd.powerbuilder75 +# application/vnd.powerbuilder75-s +# application/vnd.preminet +application/vnd.previewsystems.box box +application/vnd.proteus.magazine mgz +application/vnd.publishare-delta-tree qps +application/vnd.pvi.ptid1 ptid +# application/vnd.pwg-multiplexed +# application/vnd.pwg-xhtml-print+xml +# application/vnd.qualcomm.brew-app-res +application/vnd.quark.quarkxpress qxd qxt qwd qwt qxl qxb +# application/vnd.radisys.moml+xml +# application/vnd.radisys.msml+xml +# application/vnd.radisys.msml-audit+xml +# application/vnd.radisys.msml-audit-conf+xml +# application/vnd.radisys.msml-audit-conn+xml +# application/vnd.radisys.msml-audit-dialog+xml +# application/vnd.radisys.msml-audit-stream+xml +# application/vnd.radisys.msml-conf+xml +# application/vnd.radisys.msml-dialog+xml +# application/vnd.radisys.msml-dialog-base+xml +# application/vnd.radisys.msml-dialog-fax-detect+xml +# application/vnd.radisys.msml-dialog-fax-sendrecv+xml +# application/vnd.radisys.msml-dialog-group+xml +# application/vnd.radisys.msml-dialog-speech+xml +# application/vnd.radisys.msml-dialog-transform+xml +# application/vnd.rapid +application/vnd.realvnc.bed bed +application/vnd.recordare.musicxml mxl +application/vnd.recordare.musicxml+xml musicxml +# application/vnd.renlearn.rlprint +application/vnd.rim.cod cod +application/vnd.rn-realmedia rm +application/vnd.route66.link66+xml link66 +# application/vnd.ruckus.download +# application/vnd.s3sms +application/vnd.sailingtracker.track st +# application/vnd.sbm.cid +# application/vnd.sbm.mid2 +# application/vnd.scribus +# application/vnd.sealed.3df +# application/vnd.sealed.csf +# application/vnd.sealed.doc +# application/vnd.sealed.eml +# application/vnd.sealed.mht +# application/vnd.sealed.net +# application/vnd.sealed.ppt +# application/vnd.sealed.tiff +# application/vnd.sealed.xls +# application/vnd.sealedmedia.softseal.html +# application/vnd.sealedmedia.softseal.pdf +application/vnd.seemail see +application/vnd.sema sema +application/vnd.semd semd +application/vnd.semf semf +application/vnd.shana.informed.formdata ifm +application/vnd.shana.informed.formtemplate itp +application/vnd.shana.informed.interchange iif +application/vnd.shana.informed.package ipk +application/vnd.simtech-mindmapper twd twds +application/vnd.smaf mmf +# application/vnd.smart.notebook +application/vnd.smart.teacher teacher +# application/vnd.software602.filler.form+xml +# application/vnd.software602.filler.form-xml-zip +application/vnd.solent.sdkm+xml sdkm sdkd +application/vnd.spotfire.dxp dxp +application/vnd.spotfire.sfs sfs +# application/vnd.sss-cod +# application/vnd.sss-dtf +# application/vnd.sss-ntf +application/vnd.stardivision.calc sdc +application/vnd.stardivision.draw sda +application/vnd.stardivision.impress sdd +application/vnd.stardivision.math smf +application/vnd.stardivision.writer sdw +application/vnd.stardivision.writer vor +application/vnd.stardivision.writer-global sgl +# application/vnd.street-stream +application/vnd.sun.xml.calc sxc +application/vnd.sun.xml.calc.template stc +application/vnd.sun.xml.draw sxd +application/vnd.sun.xml.draw.template std +application/vnd.sun.xml.impress sxi +application/vnd.sun.xml.impress.template sti +application/vnd.sun.xml.math sxm +application/vnd.sun.xml.writer sxw +application/vnd.sun.xml.writer.global sxg +application/vnd.sun.xml.writer.template stw +# application/vnd.sun.wadl+xml +application/vnd.sus-calendar sus susp +application/vnd.svd svd +# application/vnd.swiftview-ics +application/vnd.symbian.install sis sisx +application/vnd.syncml+xml xsm +application/vnd.syncml.dm+wbxml bdm +application/vnd.syncml.dm+xml xdm +# application/vnd.syncml.dm.notification +# application/vnd.syncml.ds.notification +application/vnd.tao.intent-module-archive tao +application/vnd.tmobile-livetv tmo +application/vnd.trid.tpt tpt +application/vnd.triscape.mxs mxs +application/vnd.trueapp tra +# application/vnd.truedoc +application/vnd.ufdl ufd ufdl +application/vnd.uiq.theme utz +application/vnd.umajin umj +application/vnd.unity unityweb +application/vnd.uoml+xml uoml +# application/vnd.uplanet.alert +# application/vnd.uplanet.alert-wbxml +# application/vnd.uplanet.bearer-choice +# application/vnd.uplanet.bearer-choice-wbxml +# application/vnd.uplanet.cacheop +# application/vnd.uplanet.cacheop-wbxml +# application/vnd.uplanet.channel +# application/vnd.uplanet.channel-wbxml +# application/vnd.uplanet.list +# application/vnd.uplanet.list-wbxml +# application/vnd.uplanet.listcmd +# application/vnd.uplanet.listcmd-wbxml +# application/vnd.uplanet.signal +application/vnd.vcx vcx +# application/vnd.vd-study +# application/vnd.vectorworks +# application/vnd.vidsoft.vidconference +application/vnd.visio vsd vst vss vsw +application/vnd.visionary vis +# application/vnd.vividence.scriptfile +application/vnd.vsf vsf +# application/vnd.wap.sic +# application/vnd.wap.slc +application/vnd.wap.wbxml wbxml +application/vnd.wap.wmlc wmlc +application/vnd.wap.wmlscriptc wmlsc +application/vnd.webturbo wtb +# application/vnd.wfa.wsc +# application/vnd.wmc +# application/vnd.wmf.bootstrap +# application/vnd.wolfram.mathematica +# application/vnd.wolfram.mathematica.package +application/vnd.wolfram.player nbp +application/vnd.wordperfect wpd +application/vnd.wqd wqd +# application/vnd.wrq-hp3000-labelled +application/vnd.wt.stf stf +# application/vnd.wv.csp+wbxml +# application/vnd.wv.csp+xml +# application/vnd.wv.ssp+xml +application/vnd.xara xar +application/vnd.xfdl xfdl +# application/vnd.xfdl.webform +# application/vnd.xmi+xml +# application/vnd.xmpie.cpkg +# application/vnd.xmpie.dpkg +# application/vnd.xmpie.plan +# application/vnd.xmpie.ppkg +# application/vnd.xmpie.xlim +application/vnd.yamaha.hv-dic hvd +application/vnd.yamaha.hv-script hvs +application/vnd.yamaha.hv-voice hvp +application/vnd.yamaha.openscoreformat osf +application/vnd.yamaha.openscoreformat.osfpvg+xml osfpvg +application/vnd.yamaha.smaf-audio saf +application/vnd.yamaha.smaf-phrase spf +application/vnd.yellowriver-custom-menu cmp +application/vnd.zul zir zirz +application/vnd.zzazz.deck+xml zaz +application/voicexml+xml vxml +# application/watcherinfo+xml +# application/whoispp-query +# application/whoispp-response +application/winhlp hlp +# application/wita +# application/wordperfect5.1 +application/wsdl+xml wsdl +application/wspolicy+xml wspolicy +application/x-abiword abw +application/x-ace-compressed ace +application/x-authorware-bin aab x32 u32 vox +application/x-authorware-map aam +application/x-authorware-seg aas +application/x-bcpio bcpio +application/x-bittorrent torrent +application/x-bzip bz +application/x-bzip2 bz2 boz +application/x-cdlink vcd +application/x-chat chat +application/x-chess-pgn pgn +# application/x-compress +application/x-cpio cpio +application/x-csh csh +application/x-debian-package deb udeb +application/x-director dir dcr dxr cst cct cxt w3d fgd swa +application/x-doom wad +application/x-dtbncx+xml ncx +application/x-dtbook+xml dtb +application/x-dtbresource+xml res +application/x-dvi dvi +application/x-font-bdf bdf +# application/x-font-dos +# application/x-font-framemaker +application/x-font-ghostscript gsf +# application/x-font-libgrx +application/x-font-linux-psf psf +application/x-font-otf otf +application/x-font-pcf pcf +application/x-font-snf snf +# application/x-font-speedo +# application/x-font-sunos-news +application/x-font-ttf ttf ttc +application/x-font-type1 pfa pfb pfm afm +# application/x-font-vfont +application/x-futuresplash spl +application/x-gnumeric gnumeric +application/x-gtar gtar +# application/x-gzip +application/x-hdf hdf +application/x-java-jnlp-file jnlp +application/x-latex latex +application/x-mobipocket-ebook prc mobi +application/x-ms-application application +application/x-ms-wmd wmd +application/x-ms-wmz wmz +application/x-ms-xbap xbap +application/x-msaccess mdb +application/x-msbinder obd +application/x-mscardfile crd +application/x-msclip clp +application/x-msdownload exe dll com bat msi +application/x-msmediaview mvb m13 m14 +application/x-msmetafile wmf +application/x-msmoney mny +application/x-mspublisher pub +application/x-msschedule scd +application/x-msterminal trm +application/x-mswrite wri +application/x-netcdf nc cdf +application/x-pkcs12 p12 pfx +application/x-pkcs7-certificates p7b spc +application/x-pkcs7-certreqresp p7r +application/x-rar-compressed rar +application/x-sh sh +application/x-shar shar +application/x-shockwave-flash swf +application/x-silverlight-app xap +application/x-stuffit sit +application/x-stuffitx sitx +application/x-sv4cpio sv4cpio +application/x-sv4crc sv4crc +application/x-tar tar +application/x-tcl tcl +application/x-tex tex +application/x-tex-tfm tfm +application/x-texinfo texinfo texi +application/x-ustar ustar +application/x-wais-source src +application/x-x509-ca-cert der crt +application/x-xfig fig +application/x-xpinstall xpi +# application/x400-bp +# application/xcap-att+xml +# application/xcap-caps+xml +# application/xcap-el+xml +# application/xcap-error+xml +# application/xcap-ns+xml +# application/xcon-conference-info-diff+xml +# application/xcon-conference-info+xml +application/xenc+xml xenc +application/xhtml+xml xhtml xht +# application/xhtml-voice+xml +application/xml xml xsl +application/xml-dtd dtd +# application/xml-external-parsed-entity +# application/xmpp+xml +application/xop+xml xop +application/xslt+xml xslt +application/xspf+xml xspf +application/xv+xml mxml xhvml xvml xvm +application/zip zip +# audio/32kadpcm +# audio/3gpp +# audio/3gpp2 +# audio/ac3 +audio/adpcm adp +# audio/amr +# audio/amr-wb +# audio/amr-wb+ +# audio/asc +# audio/atrac-advanced-lossless +# audio/atrac-x +# audio/atrac3 +audio/basic au snd +# audio/bv16 +# audio/bv32 +# audio/clearmode +# audio/cn +# audio/dat12 +# audio/dls +# audio/dsr-es201108 +# audio/dsr-es202050 +# audio/dsr-es202211 +# audio/dsr-es202212 +# audio/dvi4 +# audio/eac3 +# audio/evrc +# audio/evrc-qcp +# audio/evrc0 +# audio/evrc1 +# audio/evrcb +# audio/evrcb0 +# audio/evrcb1 +# audio/evrcwb +# audio/evrcwb0 +# audio/evrcwb1 +# audio/example +# audio/g719 +# audio/g722 +# audio/g7221 +# audio/g723 +# audio/g726-16 +# audio/g726-24 +# audio/g726-32 +# audio/g726-40 +# audio/g728 +# audio/g729 +# audio/g7291 +# audio/g729d +# audio/g729e +# audio/gsm +# audio/gsm-efr +# audio/ilbc +# audio/l16 +# audio/l20 +# audio/l24 +# audio/l8 +# audio/lpc +audio/midi mid midi kar rmi +# audio/mobile-xmf +audio/mp4 mp4a +# audio/mp4a-latm +# audio/mpa +# audio/mpa-robust +audio/mpeg mpga mp2 mp2a mp3 m2a m3a +# audio/mpeg4-generic +audio/ogg oga ogg spx +# audio/parityfec +# audio/pcma +# audio/pcma-wb +# audio/pcmu-wb +# audio/pcmu +# audio/prs.sid +# audio/qcelp +# audio/red +# audio/rtp-enc-aescm128 +# audio/rtp-midi +# audio/rtx +# audio/smv +# audio/smv0 +# audio/smv-qcp +# audio/sp-midi +# audio/speex +# audio/t140c +# audio/t38 +# audio/telephone-event +# audio/tone +# audio/uemclip +# audio/ulpfec +# audio/vdvi +# audio/vmr-wb +# audio/vnd.3gpp.iufp +# audio/vnd.4sb +# audio/vnd.audiokoz +# audio/vnd.celp +# audio/vnd.cisco.nse +# audio/vnd.cmles.radio-events +# audio/vnd.cns.anp1 +# audio/vnd.cns.inf1 +audio/vnd.digital-winds eol +# audio/vnd.dlna.adts +# audio/vnd.dolby.heaac.1 +# audio/vnd.dolby.heaac.2 +# audio/vnd.dolby.mlp +# audio/vnd.dolby.mps +# audio/vnd.dolby.pl2 +# audio/vnd.dolby.pl2x +# audio/vnd.dolby.pl2z +# audio/vnd.dolby.pulse.1 +audio/vnd.dra dra +audio/vnd.dts dts +audio/vnd.dts.hd dtshd +# audio/vnd.everad.plj +# audio/vnd.hns.audio +audio/vnd.lucent.voice lvp +audio/vnd.ms-playready.media.pya pya +# audio/vnd.nokia.mobile-xmf +# audio/vnd.nortel.vbk +audio/vnd.nuera.ecelp4800 ecelp4800 +audio/vnd.nuera.ecelp7470 ecelp7470 +audio/vnd.nuera.ecelp9600 ecelp9600 +# audio/vnd.octel.sbc +# audio/vnd.qcelp +# audio/vnd.rhetorex.32kadpcm +# audio/vnd.sealedmedia.softseal.mpeg +# audio/vnd.vmx.cvsd +# audio/vorbis +# audio/vorbis-config +audio/x-aac aac +audio/x-aiff aif aiff aifc +audio/x-mpegurl m3u +audio/x-ms-wax wax +audio/x-ms-wma wma +audio/x-pn-realaudio ram ra +audio/x-pn-realaudio-plugin rmp +audio/x-wav wav +chemical/x-cdx cdx +chemical/x-cif cif +chemical/x-cmdf cmdf +chemical/x-cml cml +chemical/x-csml csml +# chemical/x-pdb +chemical/x-xyz xyz +image/bmp bmp +image/cgm cgm +# image/example +# image/fits +image/g3fax g3 +image/gif gif +image/ief ief +# image/jp2 +image/jpeg jpeg jpg jpe +# image/jpm +# image/jpx +# image/naplps +image/png png +image/prs.btif btif +# image/prs.pti +image/svg+xml svg svgz +# image/t38 +image/tiff tiff tif +# image/tiff-fx +image/vnd.adobe.photoshop psd +# image/vnd.cns.inf2 +image/vnd.djvu djvu djv +image/vnd.dwg dwg +image/vnd.dxf dxf +image/vnd.fastbidsheet fbs +image/vnd.fpx fpx +image/vnd.fst fst +image/vnd.fujixerox.edmics-mmr mmr +image/vnd.fujixerox.edmics-rlc rlc +# image/vnd.globalgraphics.pgb +# image/vnd.microsoft.icon +# image/vnd.mix +image/vnd.ms-modi mdi +image/vnd.net-fpx npx +# image/vnd.radiance +# image/vnd.sealed.png +# image/vnd.sealedmedia.softseal.gif +# image/vnd.sealedmedia.softseal.jpg +# image/vnd.svf +image/vnd.wap.wbmp wbmp +image/vnd.xiff xif +image/x-cmu-raster ras +image/x-cmx cmx +image/x-freehand fh fhc fh4 fh5 fh7 +image/x-icon ico +image/x-pcx pcx +image/x-pict pic pct +image/x-portable-anymap pnm +image/x-portable-bitmap pbm +image/x-portable-graymap pgm +image/x-portable-pixmap ppm +image/x-rgb rgb +image/x-xbitmap xbm +image/x-xpixmap xpm +image/x-xwindowdump xwd +# message/cpim +# message/delivery-status +# message/disposition-notification +# message/example +# message/external-body +# message/global +# message/global-delivery-status +# message/global-disposition-notification +# message/global-headers +# message/http +# message/imdn+xml +# message/news +# message/partial +message/rfc822 eml mime +# message/s-http +# message/sip +# message/sipfrag +# message/tracking-status +# message/vnd.si.simp +# model/example +model/iges igs iges +model/mesh msh mesh silo +model/vnd.dwf dwf +# model/vnd.flatland.3dml +model/vnd.gdl gdl +# model/vnd.gs-gdl +# model/vnd.gs.gdl +model/vnd.gtw gtw +# model/vnd.moml+xml +model/vnd.mts mts +# model/vnd.parasolid.transmit.binary +# model/vnd.parasolid.transmit.text +model/vnd.vtu vtu +model/vrml wrl vrml +# multipart/alternative +# multipart/appledouble +# multipart/byteranges +# multipart/digest +# multipart/encrypted +# multipart/example +# multipart/form-data +# multipart/header-set +# multipart/mixed +# multipart/parallel +# multipart/related +# multipart/report +# multipart/signed +# multipart/voice-message +text/calendar ics ifb +text/css css +text/csv csv +# text/directory +# text/dns +# text/ecmascript +# text/enriched +# text/example +text/html html htm +# text/javascript +# text/parityfec +text/plain txt text conf def list log in +# text/prs.fallenstein.rst +text/prs.lines.tag dsc +# text/vnd.radisys.msml-basic-layout +# text/red +# text/rfc822-headers +text/richtext rtx +# text/rtf +# text/rtp-enc-aescm128 +# text/rtx +text/sgml sgml sgm +# text/t140 +text/tab-separated-values tsv +text/troff t tr roff man me ms +# text/ulpfec +text/uri-list uri uris urls +# text/vnd.abc +text/vnd.curl curl +text/vnd.curl.dcurl dcurl +text/vnd.curl.scurl scurl +text/vnd.curl.mcurl mcurl +# text/vnd.dmclientscript +# text/vnd.esmertec.theme-descriptor +text/vnd.fly fly +text/vnd.fmi.flexstor flx +text/vnd.graphviz gv +text/vnd.in3d.3dml 3dml +text/vnd.in3d.spot spot +# text/vnd.iptc.newsml +# text/vnd.iptc.nitf +# text/vnd.latex-z +# text/vnd.motorola.reflex +# text/vnd.ms-mediapackage +# text/vnd.net2phone.commcenter.command +# text/vnd.si.uricatalogue +text/vnd.sun.j2me.app-descriptor jad +# text/vnd.trolltech.linguist +# text/vnd.wap.si +# text/vnd.wap.sl +text/vnd.wap.wml wml +text/vnd.wap.wmlscript wmls +text/x-asm s asm +text/x-c c cc cxx cpp h hh dic +text/x-fortran f for f77 f90 +text/x-pascal p pas +text/x-java-source java +text/x-setext etx +text/x-uuencode uu +text/x-vcalendar vcs +text/x-vcard vcf +# text/xml +# text/xml-external-parsed-entity +video/3gpp 3gp +# video/3gpp-tt +video/3gpp2 3g2 +# video/bmpeg +# video/bt656 +# video/celb +# video/dv +# video/example +video/h261 h261 +video/h263 h263 +# video/h263-1998 +# video/h263-2000 +video/h264 h264 +video/jpeg jpgv +# video/jpeg2000 +video/jpm jpm jpgm +video/mj2 mj2 mjp2 +# video/mp1s +# video/mp2p +# video/mp2t +video/mp4 mp4 mp4v mpg4 +# video/mp4v-es +video/mpeg mpeg mpg mpe m1v m2v +# video/mpeg4-generic +# video/mpv +# video/nv +video/ogg ogv +# video/parityfec +# video/pointer +video/quicktime qt mov +# video/raw +# video/rtp-enc-aescm128 +# video/rtx +# video/smpte292m +# video/ulpfec +# video/vc1 +# video/vnd.cctv +# video/vnd.dlna.mpeg-tts +video/vnd.fvt fvt +# video/vnd.hns.video +# video/vnd.iptvforum.1dparityfec-1010 +# video/vnd.iptvforum.1dparityfec-2005 +# video/vnd.iptvforum.2dparityfec-1010 +# video/vnd.iptvforum.2dparityfec-2005 +# video/vnd.iptvforum.ttsavc +# video/vnd.iptvforum.ttsmpeg2 +# video/vnd.motorola.video +# video/vnd.motorola.videop +video/vnd.mpegurl mxu m4u +video/vnd.ms-playready.media.pyv pyv +# video/vnd.nokia.interleaved-multimedia +# video/vnd.nokia.videovoip +# video/vnd.objectvideo +# video/vnd.sealed.mpeg1 +# video/vnd.sealed.mpeg4 +# video/vnd.sealed.swf +# video/vnd.sealedmedia.softseal.mov +video/vnd.vivo viv +video/x-f4v f4v +video/x-fli fli +video/x-flv flv +video/x-m4v m4v +video/x-ms-asf asf asx +video/x-ms-wm wm +video/x-ms-wmv wmv +video/x-ms-wmx wmx +video/x-ms-wvx wvx +video/x-msvideo avi +video/x-sgi-movie movie +x-conference/x-cooltalk ice diff --git a/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/includes/inventory.xml b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/includes/inventory.xml new file mode 100644 index 0000000..1aabda1 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/mocked-inventories/rhq-1.3.x/includes/inventory.xml @@ -0,0 +1,544 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10004</id> + <uuid>ae8a7a3e-256e-4c0a-9a65-33d534523d92</uuid> + <resourceKey>${server.root}</resourceKey> + <name>localhost.localdomain Apache 2.2.17 (${server.root}/)</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>true</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1307353451273</ctime> + <mtime>1307353509168</mtime> + <itime>1307353509168</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10013</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10012</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10142</id> + <version>0</version> + <ctime>1307353451273</ctime> + <mtime>1307353451273</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10073</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353737118</ctime> + <mtime>1307353737118</mtime> + <propertySimple> + <id>10365</id> + <name>errorLogMinimumSeverity</name> + <override>false</override> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10366</id> + <name>errorLogIncludesPattern</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10367</id> + <name>snmpAgentCommunity</name> + <override>false</override> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10368</id> + <name>errorLogFilePath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10369</id> + <name>errorLogEventsEnabled</name> + <override>false</override> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10370</id> + <name>snmpAgentHost</name> + <override>false</override> + <stringValue>127.0.0.1</stringValue> + </propertySimple> + <propertySimple> + <id>10713</id> + <name>controlScriptPath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10714</id> + <name>url</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10364</id> + <name>configFile</name> + <override>false</override> + <stringValue>conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10711</id> + <name>executablePath</name> + <override>false</override> + <stringValue>${exe.path}</stringValue> + </propertySimple> + <propertySimple> + <id>10712</id> + <name>snmpAgentPort</name> + <override>false</override> + <stringValue>1610</stringValue> + </propertySimple> + <propertySimple> + <id>10715</id> + <name>serverRoot</name> + <override>false</override> + <stringValue>${server.root}</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10003</id> + </productVersion> +</resource> + +<resource> + <id>10021</id> + <uuid>3a20d809-7eba-422c-a3ef-baf65804498d</uuid> + <resourceKey>127.0.0.1:11676</resourceKey> + <name>Virtual Host 127.0.0.1:11676</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587648</ctime> + <mtime>1307353587648</mtime> + <itime>1307353587648</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10135</id> + <version>0</version> + <ctime>1307353587666</ctime> + <mtime>1307353587666</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10136</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587667</ctime> + <mtime>1307353587667</mtime> + <propertySimple> + <id>10685</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10684</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111676_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10687</id> + <name>url</name> + <override>false</override> + <stringValue>http://127.0.0.1:11676/</stringValue> + </propertySimple> + <propertySimple> + <id>10688</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>4</stringValue> + </propertySimple> + <propertySimple> + <id>10686</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> +</resource> + +<resource> + <id>10022</id> + <uuid>08290193-c716-4363-b841-8a1d9d83f580</uuid> + <resourceKey>localhost.localdomain:0</resourceKey> + <name>Virtual Host localhost.localdomain:0</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587727</ctime> + <mtime>1307353587727</mtime> + <itime>1307353587721</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10137</id> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10138</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + <propertySimple> + <id>10690</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10689</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/localhost.localdomain0_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10692</id> + <name>url</name> + <override>false</override> + <stringValue>http://localhost.localdomain:0/</stringValue> + </propertySimple> + <propertySimple> + <id>10693</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>1</stringValue> + </propertySimple> + <propertySimple> + <id>10691</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>DOWN</availabilityType> + </currentAvailability> +</resource> + +<resource> + <id>10023</id> + <uuid>c62c5d75-81dd-4b14-a768-2d8c1fca6c88</uuid> + <resourceKey>127.0.0.1:11677</resourceKey> + <name>Virtual Host 127.0.0.1:11677</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + <itime>1307353587737</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10139</id> + <version>0</version> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10140</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + <propertySimple> + <id>10695</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10694</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111677_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10697</id> + <name>url</name> + <override>false</override> + <stringValue>http://127.0.0.1:11677/</stringValue> + </propertySimple> + <propertySimple> + <id>10698</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>3</stringValue> + </propertySimple> + <propertySimple> + <id>10696</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> +</resource> + +<resource> + <id>10024</id> + <uuid>d1b59168-8666-4bc0-957e-171bf16eec73</uuid> + <resourceKey>127.0.0.1:11675</resourceKey> + <name>Virtual Host 127.0.0.1:11675</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + <itime>1307353587750</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10171</id> + <version>0</version> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10172</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + <propertySimple> + <id>10700</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10699</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10702</id> + <name>url</name> + <override>false</override> + <stringValue>http://127.0.0.1:11675/</stringValue> + </propertySimple> + <propertySimple> + <id>10703</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>5</stringValue> + </propertySimple> + <propertySimple> + <id>10701</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> +</resource> + +<resource> + <id>10025</id> + <uuid>310281d2-60c6-4d7d-bcdc-c51d7969c906</uuid> + <resourceKey>127.0.0.1:11678</resourceKey> + <name>Virtual Host 127.0.0.1:11678</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + <itime>1307353587760</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <pluginConfigurationDefinition> + <id>10013</id> + <propertyDefinitions/> + </pluginConfigurationDefinition> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10173</id> + <version>0</version> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10174</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + <propertySimple> + <id>10705</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10704</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>${server.root}/logs/127.0.0.111678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10707</id> + <name>url</name> + <override>false</override> + <stringValue>http://127.0.0.1:11678/</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>2</stringValue> + </propertySimple> + <propertySimple> + <id>10706</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/resources/snmpd.conf b/modules/plugins/apache/src/test/resources/snmpd.conf index 1cbc543..58853d1 100644 --- a/modules/plugins/apache/src/test/resources/snmpd.conf +++ b/modules/plugins/apache/src/test/resources/snmpd.conf @@ -31,7 +31,7 @@ # DEFAULT: # agentaddress 161
-agentaddress $SNMP_PORT@$SNMP_HOST +agentaddress ${snmp.port}@${snmp.host}
############################################################################### # View-based Access Control diff --git a/modules/test-utils/src/main/java/org/rhq/test/ObjectCollectionSerializer.java b/modules/test-utils/src/main/java/org/rhq/test/ObjectCollectionSerializer.java index d9b597f..d3a3cab 100644 --- a/modules/test-utils/src/main/java/org/rhq/test/ObjectCollectionSerializer.java +++ b/modules/test-utils/src/main/java/org/rhq/test/ObjectCollectionSerializer.java @@ -24,6 +24,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintStream; +import java.io.Reader; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -132,6 +133,16 @@ public class ObjectCollectionSerializer { out.append("</inventory-dump>\n"); }
+ public List<?> deserialize(InputStream inputStream) throws IOException, XMLStreamException, ClassNotFoundException, JAXBException { + XMLStreamReader rdr = XMLInputFactory.newFactory().createXMLStreamReader(inputStream); + return deserialize(rdr); + } + + public List<?> deserialize(Reader inputReader) throws IOException, XMLStreamException, ClassNotFoundException, JAXBException { + XMLStreamReader rdr = XMLInputFactory.newFactory().createXMLStreamReader(inputReader); + return deserialize(rdr); + } + /** * This deserializes given input stream into a list of objects. * <p> @@ -145,33 +156,31 @@ public class ObjectCollectionSerializer { * @throws ClassNotFoundException * @throws JAXBException */ - public List<Object> deserialize(InputStream inputStream) throws IOException, XMLStreamException, ClassNotFoundException, JAXBException { - XMLStreamReader rdr = XMLInputFactory.newFactory().createXMLStreamReader(inputStream); - + public List<?> deserialize(XMLStreamReader reader) throws IOException, XMLStreamException, ClassNotFoundException, JAXBException { List<Object> ret = new ArrayList<Object>();
boolean inObjects = false;
Unmarshaller unmarshaller = null;
- while (rdr.hasNext()) { - rdr.next(); + while (reader.hasNext()) { + reader.next();
- switch(rdr.getEventType()) { + switch(reader.getEventType()) { case XMLStreamReader.START_ELEMENT: - if ("classes-used".equals(rdr.getName().getLocalPart())) { - Set<Class<?>> classesUsed = deserializedClassesToUse(rdr); + if ("classes-used".equals(reader.getName().getLocalPart())) { + Set<Class<?>> classesUsed = deserializedClassesToUse(reader); JAXBContext context = JAXBContext.newInstance(classesUsed.toArray(new Class<?>[classesUsed.size()])); unmarshaller = context.createUnmarshaller(); - } else if ("objects".equals(rdr.getName().getLocalPart())) { + } else if ("objects".equals(reader.getName().getLocalPart())) { inObjects = true; } else if (inObjects) { - Object o = unmarshaller.unmarshal(rdr); + Object o = unmarshaller.unmarshal(reader); ret.add(o); } break; case XMLStreamReader.END_ELEMENT: - if ("objects".equals(rdr.getName().getLocalPart())) { + if ("objects".equals(reader.getName().getLocalPart())) { inObjects = false; } break; diff --git a/modules/test-utils/src/test/java/org/rhq/test/test/ObjectCollectionSerializerTest.java b/modules/test-utils/src/test/java/org/rhq/test/test/ObjectCollectionSerializerTest.java index 108e117..ed1aeb6 100644 --- a/modules/test-utils/src/test/java/org/rhq/test/test/ObjectCollectionSerializerTest.java +++ b/modules/test-utils/src/test/java/org/rhq/test/test/ObjectCollectionSerializerTest.java @@ -174,7 +174,7 @@ public class ObjectCollectionSerializerTest {
ByteArrayInputStream in = new ByteArrayInputStream(getSerializedTestObjectTree());
- List<Object> objects = serializer.deserialize(in); + List<?> objects = serializer.deserialize(in);
assert objects != null && objects.equals(getTestObjectTree()) : "The deserialized objects don't match the expected results"; }
commit 415b30a875f4fb3e7d41c05ee208b2a83338f366 Author: Lukas Krejci lkrejci@redhat.com Date: Wed Jun 15 10:33:12 2011 +0200
Make the configuration object deserializable using JAXB.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java index e2754eb..cf1ce4e 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java @@ -23,9 +23,11 @@ package org.rhq.core.domain.configuration;
import java.io.Serializable; +import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; @@ -45,7 +47,9 @@ import javax.persistence.PreUpdate; import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorOrder; import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlElementRefs; import javax.xml.bind.annotation.XmlRootElement; @@ -321,7 +325,11 @@ public class Configuration implements Serializable, Cloneable, AbstractPropertyM
/** * Returns all the <i>direct</i> children of this Configuration. - * + * This collection is fully modifiable and can be added to and removed from. + * <p> + * When adding a property to the collection returned from this method, its + * {@link Property#getConfiguration() configuration property} is set to this instance. + * * @return all child properties of this Configuration */ @NotNull @@ -329,7 +337,80 @@ public class Configuration implements Serializable, Cloneable, AbstractPropertyM @XmlElementRef(name = "PropertySimple", type = PropertySimple.class), @XmlElementRef(name = "PropertyMap", type = PropertyMap.class) }) public Collection<Property> getProperties() { - return getMap().values(); + return new Collection<Property>() { + + public int size() { + return properties.size(); + } + + public boolean isEmpty() { + return properties.isEmpty(); + } + + public boolean contains(Object o) { + return properties.containsValue(o); + } + + public Iterator<Property> iterator() { + return properties.values().iterator(); + } + + public Object[] toArray() { + return properties.values().toArray(); + } + + public <T> T[] toArray(T[] a) { + return properties.values().toArray(a); + } + + public boolean add(Property e) { + properties.put(e.getName(), e); + e.setConfiguration(Configuration.this); + return true; //we always allow adding an element even if it is already present + } + + public boolean remove(Object o) { + return properties.values().remove(o); + } + + public boolean containsAll(Collection<?> c) { + return false; + } + + public boolean addAll(Collection<? extends Property> c) { + boolean ret = false; + for(Property p : c) { + ret = ret || add(p); + } + + return ret; + } + + public boolean removeAll(Collection<?> c) { + boolean ret = false; + for(Object o : c) { + ret = ret || remove(o); + } + + return ret; + } + + public boolean retainAll(Collection<?> c) { + boolean ret = false; + ArrayList<Property> ps = new ArrayList<Property>(properties.values()); + for(Property p : ps) { + if (!c.contains(p)) { + ret = ret || remove(p); + } + } + + return ret; + } + + public void clear() { + properties.clear(); + } + }; }
public void setProperties(Collection<Property> properties) {
commit ce44e137767dd9d780ecb7536a0977cb614ca3a6 Author: Lukas Krejci lkrejci@redhat.com Date: Mon Jun 13 15:17:57 2011 +0200
tmp
diff --git a/modules/helpers/inventory-serializer/inventory-rhq-2.3.0.xml b/modules/helpers/inventory-serializer/inventory-rhq-2.3.0.xml new file mode 100644 index 0000000..b70f83e --- /dev/null +++ b/modules/helpers/inventory-serializer/inventory-rhq-2.3.0.xml @@ -0,0 +1,1423 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inventory-dump> +<classes-used> +<class>org.rhq.core.domain.resource.Resource</class> +</classes-used> +<objects> + +<resource> + <id>10001</id> + <uuid>7e83a3c0-2b25-4631-8a69-a15fa14b5565</uuid> + <resourceKey>localhost.localdomain</resourceKey> + <name>localhost.localdomain</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version>Linux 2.6.35.13-91.fc14.i686.PAE</version> + <description>Linux Operating System</description> + <ctime>1307353451263</ctime> + <mtime>1307353509094</mtime> + <itime>1307353509094</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>PLATFORM</category> + <createDeletePolicy>BOTH</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>Linux Operating System</description> + <id>10003</id> + <name>Linux</name> + <plugin>Platforms</plugin> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10126</id> + <version>0</version> + <ctime>1307353451263</ctime> + <mtime>1307353451263</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10127</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353451263</ctime> + <mtime>1307353451263</mtime> + <propertyList> + <id>10582</id> + <name>logs</name> + </propertyList> + <propertySimple> + <id>10581</id> + <name>metadataCacheTimeout</name> + <override>false</override> + <stringValue>1800</stringValue> + </propertySimple> + <propertySimple> + <id>10558</id> + <name>enableContentDiscovery</name> + <override>false</override> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10559</id> + <name>enableInternalYumServer</name> + <override>false</override> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10560</id> + <name>yumPort</name> + <override>false</override> + <stringValue>9080</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10001</id> + </productVersion> +</resource> + +<resource> + <id>10002</id> + <uuid>aabcc93d-29cc-48f7-bfd4-73e0c319d281</uuid> + <resourceKey>localhost.localdomain RHQ Agent</resourceKey> + <name>localhost.localdomain RHQ Agent</name> + <inventoryStatus>NEW</inventoryStatus> + <connected>false</connected> + <version>1.3.1.GA</version> + <description>RHQ Management Agent</description> + <ctime>1307353451265</ctime> + <mtime>1307353451265</mtime> + <itime>1307353451262</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>Management Agent</description> + <id>10030</id> + <name>RHQ Agent</name> + <plugin>RHQAgent</plugin> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10128</id> + <version>0</version> + <ctime>1307353451265</ctime> + <mtime>1307353451265</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10129</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353451265</ctime> + <mtime>1307353451265</mtime> + <propertySimple> + <id>10584</id> + <name>snapshotLogEnabled</name> + <override>false</override> + <stringValue>true</stringValue> + </propertySimple> + <propertyList> + <id>10586</id> + <name>logEventSources</name> + <list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="propertyMap"> + <id>10593</id> + <name>logEventSource</name> + <map> + <entry> + <key>enabled</key> + <value xsi:type="propertySimple"> + <id>10595</id> + <name>enabled</name> + <override>false</override> + <stringValue>false</stringValue> + </value> + </entry> + <entry> + <key>logFilePath</key> + <value xsi:type="propertySimple"> + <id>10594</id> + <name>logFilePath</name> + <override>false</override> + <stringValue>/home/metlos/Projects/java/jon/qa/jon/jon-server-2.3.1.GA/agent/rhq-agent/logs/command-trace.log</stringValue> + </value> + </entry> + <entry> + <key>includesPattern</key> + <value xsi:type="propertySimple"> + <id>10597</id> + <name>includesPattern</name> + <override>false</override> + </value> + </entry> + <entry> + <key>minimumSeverity</key> + <value xsi:type="propertySimple"> + <id>10598</id> + <name>minimumSeverity</name> + <override>false</override> + </value> + </entry> + <entry> + <key>dateFormat</key> + <value xsi:type="propertySimple"> + <id>10596</id> + <name>dateFormat</name> + <override>false</override> + </value> + </entry> + </map> + </list> + <list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="propertyMap"> + <id>10587</id> + <name>logEventSource</name> + <map> + <entry> + <key>enabled</key> + <value xsi:type="propertySimple"> + <id>10589</id> + <name>enabled</name> + <override>false</override> + <stringValue>false</stringValue> + </value> + </entry> + <entry> + <key>logFilePath</key> + <value xsi:type="propertySimple"> + <id>10588</id> + <name>logFilePath</name> + <override>false</override> + <stringValue>/home/metlos/Projects/java/jon/qa/jon/jon-server-2.3.1.GA/agent/rhq-agent/logs/agent.log</stringValue> + </value> + </entry> + <entry> + <key>includesPattern</key> + <value xsi:type="propertySimple"> + <id>10592</id> + <name>includesPattern</name> + <override>false</override> + </value> + </entry> + <entry> + <key>minimumSeverity</key> + <value xsi:type="propertySimple"> + <id>10590</id> + <name>minimumSeverity</name> + <override>false</override> + <stringValue>ERROR</stringValue> + </value> + </entry> + <entry> + <key>dateFormat</key> + <value xsi:type="propertySimple"> + <id>10591</id> + <name>dateFormat</name> + <override>false</override> + </value> + </entry> + </map> + </list> + </propertyList> + <propertySimple> + <id>10585</id> + <name>snapshotDataEnabled</name> + <override>false</override> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10583</id> + <name>snapshotConfigEnabled</name> + <override>false</override> + <stringValue>true</stringValue> + </propertySimple> + <propertySimple> + <id>10600</id> + <name>type</name> + <override>false</override> + <stringValue>org.mc4j.ems.connection.support.metadata.InternalVMTypeDescriptor</stringValue> + </propertySimple> + <propertySimple> + <id>10599</id> + <name>connectorAddress</name> + <override>false</override> + <stringValue>Local Connection</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability/> + <productVersion> + <id>10002</id> + </productVersion> +</resource> + +<resource> + <id>10003</id> + <uuid>76127b54-4551-48f7-9fde-5323f9ac6162</uuid> + <resourceKey>jdbc:postgresql://127.0.0.1:5432/postgres</resourceKey> + <name>Postgres [postgres]</name> + <inventoryStatus>NEW</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Postgres relational database server</description> + <ctime>1307353451270</ctime> + <mtime>1307353451270</mtime> + <itime>1307353451262</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>PostgreSQL Server</description> + <id>10031</id> + <name>Postgres Server</name> + <plugin>Postgres</plugin> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10130</id> + <version>0</version> + <ctime>1307353451270</ctime> + <mtime>1307353451270</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10141</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353451271</ctime> + <mtime>1307353451271</mtime> + <propertySimple> + <id>10602</id> + <name>port</name> + <override>false</override> + <stringValue>5432</stringValue> + </propertySimple> + <propertySimple> + <id>10603</id> + <name>db</name> + <override>false</override> + <stringValue>postgres</stringValue> + </propertySimple> + <propertySimple> + <id>10601</id> + <name>host</name> + <override>false</override> + <stringValue>127.0.0.1</stringValue> + </propertySimple> + <propertySimple> + <id>10605</id> + <name>principal</name> + <override>false</override> + <stringValue>postgres</stringValue> + </propertySimple> + <propertySimple> + <id>10608</id> + <name>configFile</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10604</id> + <name>driverClass</name> + <override>false</override> + <stringValue>org.postgresql.Driver</stringValue> + </propertySimple> + <propertySimple> + <id>10606</id> + <name>credentials</name> + <override>false</override> + <stringValue>postgres</stringValue> + </propertySimple> + <propertySimple> + <id>10607</id> + <name>pgdataDir</name> + <override>false</override> + <stringValue>/var/lib/pgsql/data</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability/> +</resource> + +<resource> + <id>10005</id> + <uuid>c83c5747-295d-4605-b24f-33aff62839ba</uuid> + <resourceKey>virbr1</resourceKey> + <name>virbr1</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>12:2F:62:56:07:92</description> + <ctime>1307353510534</ctime> + <mtime>1307353510534</mtime> + <itime>1307353510533</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10002</id> + <name>Network Adapter</name> + <plugin>Platforms</plugin> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10144</id> + <version>0</version> + <ctime>1307353510534</ctime> + <mtime>1307353510534</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10145</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353510534</ctime> + <mtime>1307353510534</mtime> + <propertySimple> + <id>10661</id> + <name>macAddress</name> + <override>false</override> + <stringValue>12:2F:62:56:07:92</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> +</resource> + +<resource> + <id>10006</id> + <uuid>98130e3c-5cf3-4ba1-b16a-8bb247f11496</uuid> + <resourceKey>wlan0</resourceKey> + <name>wlan0</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>00:22:FA:5F:D3:80</description> + <ctime>1307353510550</ctime> + <mtime>1307353510550</mtime> + <itime>1307353510550</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10002</id> + <name>Network Adapter</name> + <plugin>Platforms</plugin> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10146</id> + <version>0</version> + <ctime>1307353510550</ctime> + <mtime>1307353510550</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10147</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353510551</ctime> + <mtime>1307353510551</mtime> + <propertySimple> + <id>10662</id> + <name>macAddress</name> + <override>false</override> + <stringValue>00:22:FA:5F:D3:80</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> +</resource> + +<resource> + <id>10007</id> + <uuid>4cb96df3-cc42-4f57-94cd-73cc048db673</uuid> + <resourceKey>virbr0</resourceKey> + <name>virbr0</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>6E:8F:FF:79:B9:D6</description> + <ctime>1307353510557</ctime> + <mtime>1307353510557</mtime> + <itime>1307353510557</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10002</id> + <name>Network Adapter</name> + <plugin>Platforms</plugin> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10148</id> + <version>0</version> + <ctime>1307353510557</ctime> + <mtime>1307353510557</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10149</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353510557</ctime> + <mtime>1307353510557</mtime> + <propertySimple> + <id>10663</id> + <name>macAddress</name> + <override>false</override> + <stringValue>6E:8F:FF:79:B9:D6</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> +</resource> + +<resource> + <id>10008</id> + <uuid>4e59f9ef-fd91-4ec4-8da5-e617e4abf376</uuid> + <resourceKey>tun0</resourceKey> + <name>tun0</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>00:00:00:00:00:00</description> + <ctime>1307353510566</ctime> + <mtime>1307353510566</mtime> + <itime>1307353510565</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10002</id> + <name>Network Adapter</name> + <plugin>Platforms</plugin> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10150</id> + <version>0</version> + <ctime>1307353510566</ctime> + <mtime>1307353510566</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10151</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353510566</ctime> + <mtime>1307353510566</mtime> + <propertySimple> + <id>10664</id> + <name>macAddress</name> + <override>false</override> + <stringValue>00:00:00:00:00:00</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> +</resource> + +<resource> + <id>10009</id> + <uuid>dd39bfe4-9368-43a9-9c25-ab5e9c2cdc6a</uuid> + <resourceKey>lo</resourceKey> + <name>lo</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>00:00:00:00:00:00</description> + <ctime>1307353510572</ctime> + <mtime>1307353510572</mtime> + <itime>1307353510572</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10002</id> + <name>Network Adapter</name> + <plugin>Platforms</plugin> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10152</id> + <version>0</version> + <ctime>1307353510572</ctime> + <mtime>1307353510572</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10153</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353510573</ctime> + <mtime>1307353510573</mtime> + <propertySimple> + <id>10665</id> + <name>macAddress</name> + <override>false</override> + <stringValue>00:00:00:00:00:00</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> +</resource> + +<resource> + <id>10010</id> + <uuid>0c86b8a7-33b0-4b67-9178-2bb6cbd4fb34</uuid> + <resourceKey>eth0</resourceKey> + <name>eth0</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>00:1C:25:A1:F6:58</description> + <ctime>1307353510580</ctime> + <mtime>1307353510580</mtime> + <itime>1307353510579</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10002</id> + <name>Network Adapter</name> + <plugin>Platforms</plugin> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10154</id> + <version>0</version> + <ctime>1307353510580</ctime> + <mtime>1307353510580</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10155</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353510580</ctime> + <mtime>1307353510580</mtime> + <propertySimple> + <id>10666</id> + <name>macAddress</name> + <override>false</override> + <stringValue>00:1C:25:A1:F6:58</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> +</resource> + +<resource> + <id>10011</id> + <uuid>bf1e848c-88aa-4406-bf00-bf80a1825843</uuid> + <resourceKey>/boot</resourceKey> + <name>localhost.localdomain File System (local) /boot</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>/dev/sda1: /boot</description> + <ctime>1307353510586</ctime> + <mtime>1307353510586</mtime> + <itime>1307353510586</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10004</id> + <name>File System</name> + <plugin>Platforms</plugin> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10156</id> + <version>0</version> + <ctime>1307353510586</ctime> + <mtime>1307353510586</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10157</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353510587</ctime> + <mtime>1307353510587</mtime> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> +</resource> + +<resource> + <id>10012</id> + <uuid>6a12505a-c668-447b-b178-7993554ca093</uuid> + <resourceKey>/</resourceKey> + <name>localhost.localdomain File System (local) /</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>/dev/mapper/VolGroup-lv_root: /</description> + <ctime>1307353510594</ctime> + <mtime>1307353510594</mtime> + <itime>1307353510593</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10004</id> + <name>File System</name> + <plugin>Platforms</plugin> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10158</id> + <version>0</version> + <ctime>1307353510594</ctime> + <mtime>1307353510594</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10159</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353510594</ctime> + <mtime>1307353510594</mtime> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> +</resource> + +<resource> + <id>10013</id> + <uuid>983dff97-dfc4-4ec5-97c7-e2f9287399ef</uuid> + <resourceKey>1</resourceKey> + <name>CPU 1</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version>Core(TM)2 Duo CPU T9600 @ 2.80GHz</version> + <description>Intel Core(TM)2 Duo CPU T9600 @ 2.80GHz</description> + <ctime>1307353510600</ctime> + <mtime>1307353510600</mtime> + <itime>1307353510599</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10006</id> + <name>CPU</name> + <plugin>Platforms</plugin> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10160</id> + <version>0</version> + <ctime>1307353510600</ctime> + <mtime>1307353510600</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10161</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353510600</ctime> + <mtime>1307353510600</mtime> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> + +<resource> + <id>10014</id> + <uuid>fb1dd111-07ab-40f4-9040-263dc0324728</uuid> + <resourceKey>0</resourceKey> + <name>CPU 0</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version>Core(TM)2 Duo CPU T9600 @ 2.80GHz</version> + <description>Intel Core(TM)2 Duo CPU T9600 @ 2.80GHz</description> + <ctime>1307353510610</ctime> + <mtime>1307353510610</mtime> + <itime>1307353510610</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10006</id> + <name>CPU</name> + <plugin>Platforms</plugin> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10162</id> + <version>0</version> + <ctime>1307353510611</ctime> + <mtime>1307353510611</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10163</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353510611</ctime> + <mtime>1307353510611</mtime> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10004</id> + </productVersion> +</resource> + +<resource> + <id>10021</id> + <uuid>3a20d809-7eba-422c-a3ef-baf65804498d</uuid> + <resourceKey>127.0.0.1:11676</resourceKey> + <name>Virtual Host 127.0.0.1:11676</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587648</ctime> + <mtime>1307353587648</mtime> + <itime>1307353587648</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10135</id> + <version>0</version> + <ctime>1307353587666</ctime> + <mtime>1307353587666</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10136</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587667</ctime> + <mtime>1307353587667</mtime> + <propertySimple> + <id>10685</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10684</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/127.0.0.111676_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10687</id> + <name>url</name> + <override>false</override> + <stringValue>http://127.0.0.1:11676/</stringValue> + </propertySimple> + <propertySimple> + <id>10688</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>4</stringValue> + </propertySimple> + <propertySimple> + <id>10686</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> +</resource> + +<resource> + <id>10022</id> + <uuid>08290193-c716-4363-b841-8a1d9d83f580</uuid> + <resourceKey>localhost.localdomain:0</resourceKey> + <name>Virtual Host localhost.localdomain:0</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587727</ctime> + <mtime>1307353587727</mtime> + <itime>1307353587721</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10137</id> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10138</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587728</ctime> + <mtime>1307353587728</mtime> + <propertySimple> + <id>10690</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10689</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/localhost.localdomain0_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10692</id> + <name>url</name> + <override>false</override> + <stringValue>http://localhost.localdomain:0/</stringValue> + </propertySimple> + <propertySimple> + <id>10693</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>1</stringValue> + </propertySimple> + <propertySimple> + <id>10691</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>DOWN</availabilityType> + </currentAvailability> +</resource> + +<resource> + <id>10023</id> + <uuid>c62c5d75-81dd-4b14-a768-2d8c1fca6c88</uuid> + <resourceKey>127.0.0.1:11677</resourceKey> + <name>Virtual Host 127.0.0.1:11677</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + <itime>1307353587737</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10139</id> + <version>0</version> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10140</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587738</ctime> + <mtime>1307353587738</mtime> + <propertySimple> + <id>10695</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10694</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/127.0.0.111677_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10697</id> + <name>url</name> + <override>false</override> + <stringValue>http://127.0.0.1:11677/</stringValue> + </propertySimple> + <propertySimple> + <id>10698</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>3</stringValue> + </propertySimple> + <propertySimple> + <id>10696</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> +</resource> + +<resource> + <id>10024</id> + <uuid>d1b59168-8666-4bc0-957e-171bf16eec73</uuid> + <resourceKey>127.0.0.1:11675</resourceKey> + <name>Virtual Host 127.0.0.1:11675</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + <itime>1307353587750</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10171</id> + <version>0</version> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10172</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587751</ctime> + <mtime>1307353587751</mtime> + <propertySimple> + <id>10700</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10699</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/127.0.0.111675_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10702</id> + <name>url</name> + <override>false</override> + <stringValue>http://127.0.0.1:11675/</stringValue> + </propertySimple> + <propertySimple> + <id>10703</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>5</stringValue> + </propertySimple> + <propertySimple> + <id>10701</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> +</resource> + +<resource> + <id>10025</id> + <uuid>310281d2-60c6-4d7d-bcdc-c51d7969c906</uuid> + <resourceKey>127.0.0.1:11678</resourceKey> + <name>Virtual Host 127.0.0.1:11678</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>false</connected> + <version></version> + <description>Apache/2.2.17 (Unix) CovalentSNMP/2.3.0</description> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + <itime>1307353587760</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVICE</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <id>10014</id> + <name>Apache Virtual Host</name> + <plugin>Apache</plugin> + <singleton>false</singleton> + <supportsManualAdd>false</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10173</id> + <version>0</version> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10174</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353587761</ctime> + <mtime>1307353587761</mtime> + <propertySimple> + <id>10705</id> + <name>responseTimeUrlExcludes</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10704</id> + <name>responseTimeLogFile</name> + <override>false</override> + <stringValue>/home/metlos/Progs/apache-2.2.17/build/logs/127.0.0.111678_rt.log</stringValue> + </propertySimple> + <propertySimple> + <id>10707</id> + <name>url</name> + <override>false</override> + <stringValue>http://127.0.0.1:11678/</stringValue> + </propertySimple> + <propertySimple> + <id>10708</id> + <name>snmpWwwServiceIndex</name> + <override>false</override> + <stringValue>2</stringValue> + </propertySimple> + <propertySimple> + <id>10706</id> + <name>responseTimeUrlTransforms</name> + <override>false</override> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> +</resource> + +<resource> + <id>10004</id> + <uuid>ae8a7a3e-256e-4c0a-9a65-33d534523d92</uuid> + <resourceKey>/home/metlos/Progs/apache-2.2.17/build</resourceKey> + <name>localhost.localdomain Apache 2.2.17 (/home/metlos/Progs/apache-2.2.17/build/)</name> + <inventoryStatus>COMMITTED</inventoryStatus> + <connected>true</connected> + <version>2.2.17</version> + <description>Apache Web Server</description> + <ctime>1307353451273</ctime> + <mtime>1307353509168</mtime> + <itime>1307353509168</itime> + <modifiedBy> + <factive>false</factive> + <fsystem>false</fsystem> + <id>1</id> + </modifiedBy> + <resourceType> + <category>SERVER</category> + <createDeletePolicy>NEITHER</createDeletePolicy> + <creationDataType>CONFIGURATION</creationDataType> + <description>an Apache HTTP Server instance</description> + <id>10013</id> + <name>Apache HTTP Server</name> + <plugin>Apache</plugin> + <singleton>false</singleton> + <supportsManualAdd>true</supportsManualAdd> + </resourceType> + <resourceConfiguration> + <id>10142</id> + <version>0</version> + <ctime>1307353451273</ctime> + <mtime>1307353451273</mtime> + </resourceConfiguration> + <pluginConfiguration> + <id>10073</id> + <notes>null</notes> + <version>0</version> + <ctime>1307353737118</ctime> + <mtime>1307353737118</mtime> + <propertySimple> + <id>10365</id> + <name>errorLogMinimumSeverity</name> + <override>false</override> + <stringValue>error</stringValue> + </propertySimple> + <propertySimple> + <id>10366</id> + <name>errorLogIncludesPattern</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10367</id> + <name>snmpAgentCommunity</name> + <override>false</override> + <stringValue>public</stringValue> + </propertySimple> + <propertySimple> + <id>10368</id> + <name>errorLogFilePath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10369</id> + <name>errorLogEventsEnabled</name> + <override>false</override> + <stringValue>false</stringValue> + </propertySimple> + <propertySimple> + <id>10370</id> + <name>snmpAgentHost</name> + <override>false</override> + <stringValue>127.0.0.1</stringValue> + </propertySimple> + <propertySimple> + <id>10713</id> + <name>controlScriptPath</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10714</id> + <name>url</name> + <override>false</override> + </propertySimple> + <propertySimple> + <id>10364</id> + <name>configFile</name> + <override>false</override> + <stringValue>conf/httpd.conf</stringValue> + </propertySimple> + <propertySimple> + <id>10711</id> + <name>executablePath</name> + <override>false</override> + <stringValue>/home/metlos/Progs/apache-2.2.17/build/bin/httpd</stringValue> + </propertySimple> + <propertySimple> + <id>10712</id> + <name>snmpAgentPort</name> + <override>false</override> + <stringValue>1610</stringValue> + </propertySimple> + <propertySimple> + <id>10715</id> + <name>serverRoot</name> + <override>false</override> + <stringValue>/home/metlos/Progs/apache-2.2.17/build</stringValue> + </propertySimple> + </pluginConfiguration> + <agent> + <backFilled>false</backFilled> + <id>10001</id> + <port>0</port> + </agent> + <currentAvailability> + <availabilityType>UP</availabilityType> + </currentAvailability> + <productVersion> + <id>10003</id> + </productVersion> +</resource> +</objects> +</inventory-dump> diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/FakeInventory.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/FakeInventory.java new file mode 100644 index 0000000..a4d0193 --- /dev/null +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/FakeInventory.java @@ -0,0 +1,96 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.plugins.apache.util; + +import java.util.Collection; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; + +/** + * + * + * @author Lukas Krejci + */ +public class FakeInventory { + + HashMap<Class<?>, Set<Object>> database = new HashMap<Class<?>, Set<Object>>(); + + private static final Comparator<Object> EQUALS_COMPARATOR = new Comparator<Object>() { + @Override + public int compare(Object a, Object b) { + if (a == null ? b == null : a.equals(b)) { + return 0; + } + return 1; + } + }; + + public boolean insert(Object o) { + Class<?> c = o.getClass(); + + Set<Object> objects = database.get(c); + + if (objects == null) { + objects = new HashSet<Object>(); + } + + return objects.add(o); + } + + public void insertAll(Object... objects) { + for(Object o : objects) { + insert(o); + } + } + + public void insertAll(Collection<Object> objects) { + for(Object o : objects) { + insert(o); + } + } + + @SuppressWarnings("unchecked") + public <T> T get(T prototype) { + return get(prototype, (Class<T>) prototype.getClass()); + } + + public <T> T get(T prototype, Class<T> clazz) { + return get(prototype, clazz, EQUALS_COMPARATOR); + } + + public <T> T get(T prototype, Class<T> clazz, Comparator<? super T> comparator) { + Set<Object> objects = database.get(clazz); + + if (objects == null) { + return null; + } + + for (Object o : objects) { + T cast = clazz.cast(o); + if (comparator.compare(cast, prototype) == 0) { + return cast; + } + } + + return null; + } +}
commit 6cdc0c6dfd9bb175660f03a295afdd905c7599d7 Author: Lukas Krejci lkrejci@redhat.com Date: Mon Jun 13 15:17:48 2011 +0200
Created ObjectCollectionSerializer class in the test-utils so that tests can persist JAXB-enabled domain classes. Converted the Inventory Serializer utility to use that.
diff --git a/modules/helpers/inventory-serializer/pom.xml b/modules/helpers/inventory-serializer/pom.xml index f08c8ce..b97f9fb 100644 --- a/modules/helpers/inventory-serializer/pom.xml +++ b/modules/helpers/inventory-serializer/pom.xml @@ -84,13 +84,17 @@ <artifactId>postgresql</artifactId> <version>9.0-801.jdbc4</version> <scope>runtime</scope> - </dependency> - + </dependency> <dependency> <groupId>org.rhq</groupId> <artifactId>safe-invoker</artifactId> <version>${project.version}</version> - </dependency> + </dependency> + <dependency> + <groupId>org.rhq</groupId> + <artifactId>test-utils</artifactId> + <version>${project.version}</version> + </dependency> </dependencies> <build> <plugins> diff --git a/modules/helpers/inventory-serializer/src/main/java/org/rhq/helpers/inventoryserializer/Main.java b/modules/helpers/inventory-serializer/src/main/java/org/rhq/helpers/inventoryserializer/Main.java index d15451f..af67320 100644 --- a/modules/helpers/inventory-serializer/src/main/java/org/rhq/helpers/inventoryserializer/Main.java +++ b/modules/helpers/inventory-serializer/src/main/java/org/rhq/helpers/inventoryserializer/Main.java @@ -23,27 +23,23 @@ import gnu.getopt.Getopt; import gnu.getopt.LongOpt;
import java.io.File; -import java.io.PrintStream; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; -import java.util.HashSet; import java.util.List; -import java.util.Set;
import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence; import javax.persistence.Query; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Marshaller;
import org.apache.log4j.Logger;
import org.rhq.enterprise.server.util.HibernateDetachUtility; import org.rhq.helpers.inventoryserializer.util.ChildFirstClassLoader; +import org.rhq.test.ObjectCollectionSerializer;
/** * @@ -77,6 +73,8 @@ public class Main { * @throws Exception */ public static void main(String[] args) throws Exception { + + LongOpt[] longOptions = new LongOpt[7];
longOptions[0] = new LongOpt("driver-class", LongOpt.OPTIONAL_ARGUMENT, null, 'd'); @@ -133,16 +131,14 @@ public class Main { System.exit(1); }
- ClassLoader classLoaderToUse = Main.class.getClassLoader(); + ClassLoader classLoaderToUse = Main.class.getClassLoader();
if (jars.size() > 0) { URL[] jarUrls = getUrls(jars); classLoaderToUse = new ChildFirstClassLoader(jarUrls, Main.class.getClassLoader()); }
- //these will collect the results and classes of the results - List<Object> allResults = new ArrayList<Object>(); - Set<Class<?>> classes = new HashSet<Class<?>>(); + ObjectCollectionSerializer serializer = new ObjectCollectionSerializer();
EntityManager em = null; ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); @@ -150,6 +146,8 @@ public class Main { Thread.currentThread().setContextClassLoader(classLoaderToUse); em = getEntityManager(driverClass, dialect, connectionUrl, username, password, persistenceUnit);
+ em.getTransaction().begin(); + for (String query : queries) { log.info("Executing query: " + query);
@@ -158,50 +156,19 @@ public class Main { @SuppressWarnings("unchecked") List<Object> results = q.getResultList();
- allResults.addAll(results); - } - - em.clear(); - - for (Object result : allResults) { - classes.add(result.getClass()); - HibernateDetachUtility.nullOutUninitializedFields(result, HibernateDetachUtility.SerializationType.JAXB); + for(Object result : results) { + HibernateDetachUtility.nullOutUninitializedFields(result, HibernateDetachUtility.SerializationType.SERIALIZATION); + } + + serializer.addObjects(results); } + + em.close(); } finally { Thread.currentThread().setContextClassLoader(contextClassLoader); }
- PrintStream out = System.out; - out = new PrintStream(out, true, "UTF-8"); - - out.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"); - out.append("<inventory-dump>\n"); - - out.append("<classes-used>\n"); - - for (Class<?> cls : classes) { - out.append("<class>").append(cls.getName()).append("</class>\n"); - } - - out.append("</classes-used>\n"); - - out.append("<objects>\n"); - - JAXBContext context = JAXBContext.newInstance(classes.toArray(new Class<?>[classes.size()])); - - Marshaller marshaller = context.createMarshaller(); - - marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); - marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); - marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); - - for (Object r : allResults) { - marshaller.marshal(r, out); - } - - out.append("</objects>\n"); - - out.append("</inventory-dump>\n"); + serializer.serialize(System.out); }
/** diff --git a/modules/helpers/inventory-serializer/src/main/resources/log4j.properties b/modules/helpers/inventory-serializer/src/main/resources/log4j.properties index 82af3e5..7e6e52b 100644 --- a/modules/helpers/inventory-serializer/src/main/resources/log4j.properties +++ b/modules/helpers/inventory-serializer/src/main/resources/log4j.properties @@ -1,6 +1,8 @@ -log4j.rootCategory=FATAL, CONSOLE +log4j.rootCategory=INFO, CONSOLE +#log4j.category.org.hibernate.SQL=DEBUG, CONSOLE
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout +log4j.appender.CONSOLE.target=System.err log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c] %m%n
diff --git a/modules/test-utils/src/main/java/org/rhq/test/ObjectCollectionSerializer.java b/modules/test-utils/src/main/java/org/rhq/test/ObjectCollectionSerializer.java new file mode 100644 index 0000000..d9b597f --- /dev/null +++ b/modules/test-utils/src/main/java/org/rhq/test/ObjectCollectionSerializer.java @@ -0,0 +1,224 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.test; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import org.jetbrains.annotations.NotNull; + +/** + * This class produces a JAXB serialized collection of objects and can convert + * such serialized data back to a list of objects. + * <p> + * The objects passed to this class must therefore be JAXB serializable. + * <p> + * This class is intended to be used in tests that need to persist the state + * of some object collection. + * + * @author Lukas Krejci + */ +public class ObjectCollectionSerializer { + private List<Object> objects = new ArrayList<Object>(); + private Set<Class<?>> classes = new HashSet<Class<?>>(); + + /** + * Returns a list of objects that are added to this serializer. + * This list is NOT modifiable, use it only for inspection. + * + * @return + */ + public @NotNull List<Object> getObjects() { + return Collections.unmodifiableList(objects); + } + + public void addObject(@NotNull Object o) { + this.objects.add(o); + this.classes.add(o.getClass()); + } + + public void addObjects(@NotNull Collection<?> objects) { + for(Object o : objects) { + if (o == null) { + continue; + } + + addObject(o); + } + } + + /** + * Returns a set of classes of objects that are to be serialized. + * This set is not modifiable, use it only for informational purposes. + * @return + */ + public @NotNull Set<Class<?>> getClasses() { + return Collections.unmodifiableSet(classes); + } + + /** + * Serializes the objects added to this serialize to the given output. + * + * @param output the output stream to serialize to + * + * @throws IOException + * @throws JAXBException + */ + public void serialize(OutputStream output) throws IOException, JAXBException { + PrintStream out = new PrintStream(output); + out = new PrintStream(out, true, "UTF-8"); + + out.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"); + out.append("<inventory-dump>\n"); + + out.append("<classes-used>\n"); + + for (Class<?> cls : classes) { + out.append("<class>").append(cls.getName()).append("</class>\n"); + } + + out.append("</classes-used>\n"); + + out.append("<objects>\n"); + + JAXBContext context = JAXBContext.newInstance(classes.toArray(new Class<?>[classes.size()])); + + Marshaller marshaller = context.createMarshaller(); + + marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); + + for (Object o : objects) { + marshaller.marshal(o, out); + } + + out.append("</objects>\n"); + + out.append("</inventory-dump>\n"); + } + + /** + * This deserializes given input stream into a list of objects. + * <p> + * This method uses the current thread's context classloader to resolve + * the classes of the objects to be deserialized if such classloader is set. + * + * @param inputStream the input stream to read the data from + * + * @return the list of deserialized objects + * @throws XMLStreamException + * @throws ClassNotFoundException + * @throws JAXBException + */ + public List<Object> deserialize(InputStream inputStream) throws IOException, XMLStreamException, ClassNotFoundException, JAXBException { + XMLStreamReader rdr = XMLInputFactory.newFactory().createXMLStreamReader(inputStream); + + List<Object> ret = new ArrayList<Object>(); + + boolean inObjects = false; + + Unmarshaller unmarshaller = null; + + while (rdr.hasNext()) { + rdr.next(); + + switch(rdr.getEventType()) { + case XMLStreamReader.START_ELEMENT: + if ("classes-used".equals(rdr.getName().getLocalPart())) { + Set<Class<?>> classesUsed = deserializedClassesToUse(rdr); + JAXBContext context = JAXBContext.newInstance(classesUsed.toArray(new Class<?>[classesUsed.size()])); + unmarshaller = context.createUnmarshaller(); + } else if ("objects".equals(rdr.getName().getLocalPart())) { + inObjects = true; + } else if (inObjects) { + Object o = unmarshaller.unmarshal(rdr); + ret.add(o); + } + break; + case XMLStreamReader.END_ELEMENT: + if ("objects".equals(rdr.getName().getLocalPart())) { + inObjects = false; + } + break; + } + } + + return ret; + } + + private Set<Class<?>> deserializedClassesToUse(XMLStreamReader rdr) throws XMLStreamException, ClassNotFoundException { + HashSet<Class<?>> ret = new HashSet<Class<?>>(); + + boolean insideClass = false; + while (rdr.hasNext()) { + rdr.next(); + + switch (rdr.getEventType()) { + case XMLStreamReader.START_ELEMENT: + if ("class".equals(rdr.getName().getLocalPart())) { + insideClass = true; + } else { + insideClass = false; + } + break; + case XMLStreamReader.END_ELEMENT: + if ("class".equals(rdr.getName().getLocalPart())) { + insideClass = false; + } else if ("classes-used".equals(rdr.getName().getLocalPart())) { + return ret; + } + break; + case XMLStreamReader.CHARACTERS: + if (insideClass) { + Class<?> c = null; + if (Thread.currentThread().getContextClassLoader() == null) { + c = Class.forName(rdr.getText()); + } else { + c = Class.forName(rdr.getText(), false, Thread.currentThread().getContextClassLoader()); + } + + ret.add(c); + } + break; + } + } + + return ret; + } + +} diff --git a/modules/test-utils/src/test/java/org/rhq/test/test/ObjectCollectionSerializerTest.java b/modules/test-utils/src/test/java/org/rhq/test/test/ObjectCollectionSerializerTest.java new file mode 100644 index 0000000..108e117 --- /dev/null +++ b/modules/test-utils/src/test/java/org/rhq/test/test/ObjectCollectionSerializerTest.java @@ -0,0 +1,181 @@ +package org.rhq.test.test; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.xml.bind.JAXBException; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; + +import org.testng.annotations.Test; + +import org.rhq.test.ObjectCollectionSerializer; + +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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. + */ + +/** + * + * + * @author Lukas Krejci + */ +@Test +public class ObjectCollectionSerializerTest { + + @XmlRootElement + @XmlAccessorType(XmlAccessType.FIELD) + public static class MyClass { + public int id; + public String name; + + public List<MyChildClass> children; + + public MyClass() { + + } + + public MyClass(int id, String name) { + this.id = id; + this.name = name; + children = new ArrayList<MyChildClass>(); + } + + public int hashCode() { + return id * (name == null ? 1 : name.hashCode()); + } + + public boolean equals(Object o) { + if (o == this) { + return true; + } + + if (!(o instanceof MyClass)) { + return false; + } + + MyClass other = (MyClass) o; + + if (id != other.id) { + return false; + } + + if (name == null) { + if (other.name != null) { + return false; + } + } else { + if (!name.equals(other.name)) { + return false; + } + } + + return children.equals(other.children); + } + } + + @XmlAccessorType(XmlAccessType.FIELD) + public static class MyChildClass { + public int id; + public String name; + + public MyChildClass() { + + } + + public MyChildClass(int id, String name, MyClass parent) { + this.id = id; + this.name = name; + parent.children.add(this); + } + + public int hashCode() { + return id * (name == null ? 1 : name.hashCode()); + } + + public boolean equals(Object o) { + if (o == this) { + return true; + } + + if (!(o instanceof MyChildClass)) { + return false; + } + + MyChildClass other = (MyChildClass) o; + + if (id != other.id) { + return false; + } + + if (name == null) { + return other.name == null; + } else { + return name.equals(other.name); + } + } + } + + private List<MyClass> getTestObjectTree() { + MyClass m1 = new MyClass(1, "m1"); + new MyChildClass(1, "m1c1", m1); + new MyChildClass(2, "m1c2", m1); + new MyChildClass(3, "m1c3", m1); + + MyClass m2 = new MyClass(2, "m2"); + new MyChildClass(1, "m2c1", m2); + new MyChildClass(2, "m2c2", m2); + new MyChildClass(3, "m2c3", m2); + + return Arrays.asList(m1, m2); + } + + private byte[] getSerializedTestObjectTree() throws IOException, JAXBException { + ObjectCollectionSerializer serializer = new ObjectCollectionSerializer(); + + serializer.addObjects(getTestObjectTree()); + + ByteArrayOutputStream out = new ByteArrayOutputStream(); + + serializer.serialize(out); + + return out.toByteArray(); + } + + @Test + public void testCanSerialize() throws Exception { + byte[] out = getSerializedTestObjectTree(); + + assert out.length > 0 : "The serialization should have produced some output"; + } + + @Test + public void testCanDeserialize() throws Exception { + ObjectCollectionSerializer serializer = new ObjectCollectionSerializer(); + + ByteArrayInputStream in = new ByteArrayInputStream(getSerializedTestObjectTree()); + + List<Object> objects = serializer.deserialize(in); + + assert objects != null && objects.equals(getTestObjectTree()) : "The deserialized objects don't match the expected results"; + } +}
commit 6749b62ac9c867e302ffcd046c00992c5f6fa0e7 Author: Lukas Krejci lkrejci@redhat.com Date: Mon Jun 13 15:15:37 2011 +0200
Make HibernateDetachUtility compatible both with javassist and CGLIB based Hibernate bytecode enhancers.
diff --git a/modules/enterprise/server/safe-invoker/src/main/java/org/rhq/enterprise/server/util/HibernateDetachUtility.java b/modules/enterprise/server/safe-invoker/src/main/java/org/rhq/enterprise/server/util/HibernateDetachUtility.java index 0fdb835..a496efe 100644 --- a/modules/enterprise/server/safe-invoker/src/main/java/org/rhq/enterprise/server/util/HibernateDetachUtility.java +++ b/modules/enterprise/server/safe-invoker/src/main/java/org/rhq/enterprise/server/util/HibernateDetachUtility.java @@ -251,15 +251,17 @@ public class HibernateDetachUtility { if (fieldValue instanceof HibernateProxy) {
Object replacement = null; - if (fieldValue.getClass().getName().contains("javassist")) { + String assistClassName = fieldValue.getClass().getName(); + if (assistClassName.contains("javassist") || assistClassName.contains("EnhancerByCGLIB")) {
Class assistClass = fieldValue.getClass(); try { Method m = assistClass.getMethod("writeReplace"); replacement = m.invoke(fieldValue);
- String className = fieldValue.getClass().getName(); - className = className.substring(0, className.indexOf("_$$_")); + String assistNameDelimiter = assistClassName.contains("javassist") ? "_$$_" : "$$"; + + assistClassName = assistClassName.substring(0, assistClassName.indexOf(assistNameDelimiter)); if (!replacement.getClass().getName().contains("hibernate")) { nullOutUninitializedFields(replacement, checkedObjects, depth + 1, serializationType);
commit fbc2595877303deaa918c25637be15d6212242ef Author: Lukas Krejci lkrejci@redhat.com Date: Tue Jun 7 14:39:43 2011 +0200
tmp
diff --git a/modules/enterprise/server/safe-invoker/src/main/java/org/rhq/enterprise/server/util/HibernateDetachUtility.java b/modules/enterprise/server/safe-invoker/src/main/java/org/rhq/enterprise/server/util/HibernateDetachUtility.java index d23dd0a..0fdb835 100644 --- a/modules/enterprise/server/safe-invoker/src/main/java/org/rhq/enterprise/server/util/HibernateDetachUtility.java +++ b/modules/enterprise/server/safe-invoker/src/main/java/org/rhq/enterprise/server/util/HibernateDetachUtility.java @@ -275,7 +275,11 @@ public class HibernateDetachUtility { if (replacement == null) {
String className = ((HibernateProxy) fieldValue).getHibernateLazyInitializer().getEntityName(); - Class clazz = Class.forName(className); + + //see if there is a context classloader we should use instead of the current one. + ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); + + Class clazz = contextClassLoader == null ? Class.forName(className) : Class.forName(className, true, contextClassLoader); Class[] constArgs = { Integer.class }; Constructor construct = null;
diff --git a/modules/helpers/inventory-serializer/inventory-serializer.sh b/modules/helpers/inventory-serializer/inventory-serializer.sh new file mode 100755 index 0000000..01c4dd0 --- /dev/null +++ b/modules/helpers/inventory-serializer/inventory-serializer.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +java -cp 'target/dependency/*':target/inventory-serializer-4.1.0-SNAPSHOT.jar org.rhq.helpers.inventoryserializer.Main "$@" + diff --git a/modules/helpers/inventory-serializer/pom.xml b/modules/helpers/inventory-serializer/pom.xml new file mode 100644 index 0000000..f08c8ce --- /dev/null +++ b/modules/helpers/inventory-serializer/pom.xml @@ -0,0 +1,123 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <artifactId>rhq-helpers</artifactId> + <groupId>org.rhq.helpers</groupId> + <version>4.1.0-SNAPSHOT</version> + </parent> + <groupId>org.rhq.helpers</groupId> + <artifactId>inventory-serializer</artifactId> + <version>4.1.0-SNAPSHOT</version> + <name>Inventory Serializer</name> + <description>A helper command line app to export parts of the inventory to XML</description> + + <dependencies> + <dependency> + <groupId>hibernate-entitymanager</groupId> + <artifactId>hibernate-entitymanager</artifactId> + <version>${hibernate-entitymanager.version}</version> + </dependency> + <dependency> + <groupId>gnu-getopt</groupId> + <artifactId>getopt</artifactId> + </dependency> + <dependency> + <groupId>javax.persistence</groupId> + <artifactId>persistence-api</artifactId> + <version>1.0</version> + </dependency> + <dependency> + <groupId>hibernate</groupId> + <artifactId>hibernate3</artifactId> + <version>${hibernate3.version}</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>hibernate-annotations</groupId> + <artifactId>hibernate-annotations</artifactId> + <version>${hibernate-annotations.version}</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>jboss</groupId> + <artifactId>jboss-archive-browsing</artifactId> + <version>5.0.0alpha-200607201-119</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>dom4j</groupId> + <artifactId>dom4j</artifactId> + <version>1.6.1-jboss</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>javassist</groupId> + <artifactId>javassist</artifactId> + <version>3.12.1.GA</version> + </dependency> + <dependency> + <groupId>commons-collections</groupId> + <artifactId>commons-collections</artifactId> + <version>3.2.1</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>cglib</groupId> + <artifactId>cglib-nodep</artifactId> + <version>2.2</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>org.antlr</groupId> + <artifactId>antlr-runtime</artifactId> + <version>3.3</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>javax.transaction</groupId> + <artifactId>jta</artifactId> + <version>1.1</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>postgresql</groupId> + <artifactId>postgresql</artifactId> + <version>9.0-801.jdbc4</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.rhq</groupId> + <artifactId>safe-invoker</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <configuration> + <archive> + <manifest> + <mainClass>org.rhq.helpers.inventoryserializer.Main</mainClass> + </manifest> + </archive> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>copy-dependencies</id> + <phase>package</phase> + <goals> + <goal>copy-dependencies</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file diff --git a/modules/helpers/inventory-serializer/src/main/java/org/rhq/helpers/inventoryserializer/Main.java b/modules/helpers/inventory-serializer/src/main/java/org/rhq/helpers/inventoryserializer/Main.java new file mode 100644 index 0000000..d15451f --- /dev/null +++ b/modules/helpers/inventory-serializer/src/main/java/org/rhq/helpers/inventoryserializer/Main.java @@ -0,0 +1,254 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.helpers.inventoryserializer; + +import gnu.getopt.Getopt; +import gnu.getopt.LongOpt; + +import java.io.File; +import java.io.PrintStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; +import javax.persistence.Query; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; + +import org.apache.log4j.Logger; + +import org.rhq.enterprise.server.util.HibernateDetachUtility; +import org.rhq.helpers.inventoryserializer.util.ChildFirstClassLoader; + +/** + * + * + * @author Lukas Krejci + */ +public class Main { + + private static final Logger log = Logger.getLogger(Main.class); + + private Main() { + + } + + private static void usage() { + System.out.println("Usage: inventory-serializer.[sh|bat] -c [-diupjs] <JPQL Query> [more JPQL quries]"); + System.out.println("Required arguments:"); + System.out.println("-c --connection-url : The JDBC connection URL to the database."); + System.out.println(); + System.out.println("Optional arguments:"); + System.out.println("-d --driver-class : The class of the JDBC driver to use. The driver must be on the classpath. Defaults to org.postgresql.Driver."); + System.out.println("-i --dialect : The Hibernate dialect to use. Defaults to org.hibernate.dialect.PosgreSQLDialect."); + System.out.println("-u --username : The username to use when connecting to the database."); + System.out.println("-p --password : The database password."); + System.out.println("-j --jars : The comma-separated list of jars containing the entities. If none specified, the current classpath is used."); + System.out.println("-s --persistence-unit : The persistence unit to execute the queries with. Defaults to 'rhqpu'."); + } + + /** + * @param args + * @throws Exception + */ + public static void main(String[] args) throws Exception { + LongOpt[] longOptions = new LongOpt[7]; + + longOptions[0] = new LongOpt("driver-class", LongOpt.OPTIONAL_ARGUMENT, null, 'd'); + longOptions[1] = new LongOpt("dialect", LongOpt.OPTIONAL_ARGUMENT, null, 'i'); + longOptions[2] = new LongOpt("connection-url", LongOpt.REQUIRED_ARGUMENT, null, 'c'); + longOptions[3] = new LongOpt("username", LongOpt.OPTIONAL_ARGUMENT, null, 'u'); + longOptions[4] = new LongOpt("password", LongOpt.OPTIONAL_ARGUMENT, null, 'p'); + longOptions[5] = new LongOpt("jars", LongOpt.OPTIONAL_ARGUMENT, null, 'j'); + longOptions[6] = new LongOpt("persistence-unit", LongOpt.OPTIONAL_ARGUMENT, null, 's'); + + Getopt options = new Getopt("iventory-serializer serializer", args, "d:i:c:u:p:j:s:", longOptions); + + String driverClass = "org.postgresql.Driver"; + String dialect = "org.hibernate.dialect.PostgreSQLDialect"; + String connectionUrl = null; + String username = null; + String password = null; + String persistenceUnit = "rhqpu"; + List<String> jars = new ArrayList<String>(); + List<String> queries = new ArrayList<String>(); + + int option; + while ((option = options.getopt()) != -1) { + switch (option) { + case 'd': + driverClass = options.getOptarg(); + break; + case 'i': + dialect = options.getOptarg(); + break; + case 'c': + connectionUrl = options.getOptarg(); + break; + case 'u': + username = options.getOptarg(); + break; + case 'p': + password = options.getOptarg(); + break; + case 'j': + jars.addAll(extractCommaSeparated(options.getOptarg())); + break; + case 's': + persistenceUnit = options.getOptarg(); + } + } + + for (int i = options.getOptind(); i < args.length; i++) { + queries.add(args[i]); + } + + if (driverClass == null || dialect == null || connectionUrl == null || queries.isEmpty()) { + usage(); + System.exit(1); + } + + ClassLoader classLoaderToUse = Main.class.getClassLoader(); + + if (jars.size() > 0) { + URL[] jarUrls = getUrls(jars); + classLoaderToUse = new ChildFirstClassLoader(jarUrls, Main.class.getClassLoader()); + } + + //these will collect the results and classes of the results + List<Object> allResults = new ArrayList<Object>(); + Set<Class<?>> classes = new HashSet<Class<?>>(); + + EntityManager em = null; + ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); + try { + Thread.currentThread().setContextClassLoader(classLoaderToUse); + em = getEntityManager(driverClass, dialect, connectionUrl, username, password, persistenceUnit); + + for (String query : queries) { + log.info("Executing query: " + query); + + Query q = em.createQuery(query); + + @SuppressWarnings("unchecked") + List<Object> results = q.getResultList(); + + allResults.addAll(results); + } + + em.clear(); + + for (Object result : allResults) { + classes.add(result.getClass()); + HibernateDetachUtility.nullOutUninitializedFields(result, HibernateDetachUtility.SerializationType.JAXB); + } + } finally { + Thread.currentThread().setContextClassLoader(contextClassLoader); + } + + PrintStream out = System.out; + out = new PrintStream(out, true, "UTF-8"); + + out.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"); + out.append("<inventory-dump>\n"); + + out.append("<classes-used>\n"); + + for (Class<?> cls : classes) { + out.append("<class>").append(cls.getName()).append("</class>\n"); + } + + out.append("</classes-used>\n"); + + out.append("<objects>\n"); + + JAXBContext context = JAXBContext.newInstance(classes.toArray(new Class<?>[classes.size()])); + + Marshaller marshaller = context.createMarshaller(); + + marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); + + for (Object r : allResults) { + marshaller.marshal(r, out); + } + + out.append("</objects>\n"); + + out.append("</inventory-dump>\n"); + } + + /** + * @param jars + * @return + */ + private static URL[] getUrls(List<String> jars) { + URL[] ret = new URL[jars.size()]; + + int idx = 0; + for (String jar : jars) { + File f = new File(jar); + if (!f.exists()) { + throw new IllegalArgumentException("Could not find the jar '" + jar + "'."); + } + + try { + ret[idx++] = f.toURI().toURL(); + } catch (MalformedURLException e) { + //doesn't happen + } + } + + return ret; + } + + private static EntityManager getEntityManager(String driverClass, String dialect, String connectionUrl, + String username, String password, String persistenceUnit) { + + HashMap<String, String> overrides = new HashMap<String, String>(); + + overrides.put("javax.persistence.jtaDataSource", null); + overrides.put("javax.persistence.nonJtaDataSource", null); + overrides.put("hibernate.dialect", dialect); + overrides.put("hibernate.connection.driver_class", driverClass); + overrides.put("hibernate.connection.url", connectionUrl); + overrides.put("hibernate.connection.user", username); + overrides.put("hibernate.connection.password", password); + + EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, overrides); + + return emf.createEntityManager(overrides); + } + + private static List<String> extractCommaSeparated(String arg) { + String[] vals = arg.split("\s*,\s*"); + + return Arrays.asList(vals); + } +} diff --git a/modules/helpers/inventory-serializer/src/main/java/org/rhq/helpers/inventoryserializer/util/ChildFirstClassLoader.java b/modules/helpers/inventory-serializer/src/main/java/org/rhq/helpers/inventoryserializer/util/ChildFirstClassLoader.java new file mode 100644 index 0000000..33ccf8b --- /dev/null +++ b/modules/helpers/inventory-serializer/src/main/java/org/rhq/helpers/inventoryserializer/util/ChildFirstClassLoader.java @@ -0,0 +1,125 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.helpers.inventoryserializer.util; + +import java.io.IOException; +import java.net.URL; +import java.net.URLClassLoader; +import java.net.URLStreamHandlerFactory; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; + +/** + * + * + * @author Lukas Krejci + */ +public class ChildFirstClassLoader extends URLClassLoader { + + /** + * @param urls + * @param parent + * @param factory + */ + public ChildFirstClassLoader(URL[] urls, ClassLoader parent, URLStreamHandlerFactory factory) { + super(urls, parent, factory); + } + + /** + * @param urls + * @param parent + */ + public ChildFirstClassLoader(URL[] urls, ClassLoader parent) { + super(urls, parent); + } + + /** + * @param urls + */ + public ChildFirstClassLoader(URL[] urls) { + super(urls); + } + + @Override + protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { + + Class<?> c = findLoadedClass(name); + + //try to find the class among the child classloaders + if (c == null) { + try { + c = findClass(name); + } catch (ClassNotFoundException e) { + //ignore + } + } + + if (c == null) { + //ok, delegate to parent now + try { + if (getParent() != null) { + c = getParent().loadClass(name); + } else { + c = getSystemClassLoader().loadClass(name); + } + } catch (ClassNotFoundException e) { + throw e; + } + } + + if (resolve) { + resolveClass(c); + } + + return c; + } + + @Override + public URL getResource(String name) { + URL ret = findResource(name); + + if (ret == null) { + if (getParent() != null) { + ret = getParent().getResource(name); + } else { + ret = getSystemClassLoader().getResource(name); + } + } + + return ret; + } + + @Override + public Enumeration<URL> getResources(String name) throws IOException { + Enumeration<URL> ret = findResources(name); + + if (ret == null || !ret.hasMoreElements()) { + if (getParent() != null) { + ret = getParent().getResources(name); + } else { + ret = getSystemClassLoader().getResources(name); + } + } + + return ret; + } + +} diff --git a/modules/helpers/inventory-serializer/src/main/resources/log4j.properties b/modules/helpers/inventory-serializer/src/main/resources/log4j.properties new file mode 100644 index 0000000..82af3e5 --- /dev/null +++ b/modules/helpers/inventory-serializer/src/main/resources/log4j.properties @@ -0,0 +1,6 @@ +log4j.rootCategory=FATAL, CONSOLE + +log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender +log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout +log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c] %m%n + diff --git a/modules/helpers/pom.xml b/modules/helpers/pom.xml index 8b4892a..0c73fd3 100644 --- a/modules/helpers/pom.xml +++ b/modules/helpers/pom.xml @@ -47,6 +47,8 @@ <module>bundleGen</module> <module>perftest-support</module>
+ <!-- Not built by default because people will need this only rarely when developing tests. --> + <!-- <module>inventory-serializer</module> --> </modules>
diff --git a/modules/plugins/apache/pom.xml b/modules/plugins/apache/pom.xml index a352ae4..a7a6bf5 100644 --- a/modules/plugins/apache/pom.xml +++ b/modules/plugins/apache/pom.xml @@ -153,6 +153,12 @@ <include name="${project.artifactId}-${project.version}.jar" /> </fileset> </copy> + <!-- We need deterministic names (i.e. that would not change with the project version) + so that we can statically reference them in the test classes --> + <move todir="target/itest/plugins"> + <fileset dir="target/itest/plugins" /> + <mapper type="regexp" from="^(.*)-${project.version}\.jar$$" to="\1-for-apache-test.jar" /> + </move> <unzip dest="target/itest/lib"> <fileset dir="${settings.localRepository}/org/hyperic/sigar-dist/${sigar.version}" includes="*.zip" /> <patternset> @@ -229,11 +235,39 @@ <!--<argLine>-Dorg.hyperic.sigar.path=${basedir}/target/itest/lib -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</argLine>--> <environmentVariables> <LD_LIBRARY_PATH>${basedir}/target/itest/lib:${env.LD_LIBRARY_PATH}</LD_LIBRARY_PATH> - </environmentVariables> + </environmentVariables> <systemPropertyVariables> <org.hyperic.sigar.path>${basedir}/target/itest/lib</org.hyperic.sigar.path> <project.artifactId>${project.artifactId}</project.artifactId> <project.version>${project.version}</project.version> + + <apache2.install.dir>PASS THIS IN FROM THE COMMAND LINE</apache2.install.dir> + <apache2.exe.path>bin/httpd</apache2.exe.path> + <apache1.install.dir>PASS THIS IN FROM THE COMMAND LINE</apache1.install.dir> + <apache1.exe.path>bin/httpd</apache1.exe.path> + + <!-- configuration of individual upgrade tests --> + <simpleWithResolvableServerNames.server.root>${apache2.install.dir}</simpleWithResolvableServerNames.server.root> + <!-- this is defaulted to "htdocs" --> + <simpleWithResolvableServerNames.document.root></simpleWithResolvableServerNames.document.root> + <simpleWithResolvableServerNames.listen1>11675</simpleWithResolvableServerNames.listen1> + <simpleWithResolvableServerNames.listen2>11676</simpleWithResolvableServerNames.listen2> + <simpleWithResolvableServerNames.listen3>11677</simpleWithResolvableServerNames.listen3> + <simpleWithResolvableServerNames.listen4>11678</simpleWithResolvableServerNames.listen4> + <simpleWithResolvableServerNames.servername.directive></simpleWithResolvableServerNames.servername.directive> + <simpleWithResolvableServerNames.additional.directives></simpleWithResolvableServerNames.additional.directives> + <simpleWithResolvableServerNames.vhost1.urls>127.0.0.1:11675</simpleWithResolvableServerNames.vhost1.urls> + <simpleWithResolvableServerNames.vhost1.servername.directive>ServerName 127.0.0.1:11675</simpleWithResolvableServerNames.vhost1.servername.directive> + <simpleWithResolvableServerNames.vhost1.additional.directives></simpleWithResolvableServerNames.vhost1.additional.directives> + <simpleWithResolvableServerNames.vhost2.urls>127.0.0.1:11676</simpleWithResolvableServerNames.vhost2.urls> + <simpleWithResolvableServerNames.vhost2.servername.directive>ServerName 127.0.0.1:11676</simpleWithResolvableServerNames.vhost2.servername.directive> + <simpleWithResolvableServerNames.vhost2.additional.directives></simpleWithResolvableServerNames.vhost2.additional.directives> + <simpleWithResolvableServerNames.vhost3.urls>127.0.0.1:11677</simpleWithResolvableServerNames.vhost3.urls> + <simpleWithResolvableServerNames.vhost3.servername.directive>ServerName 127.0.0.1:11677</simpleWithResolvableServerNames.vhost3.servername.directive> + <simpleWithResolvableServerNames.vhost3.additional.directives></simpleWithResolvableServerNames.vhost3.additional.directives> + <simpleWithResolvableServerNames.vhost4.urls>127.0.0.1:11678</simpleWithResolvableServerNames.vhost4.urls> + <simpleWithResolvableServerNames.vhost4.servername.directive>ServerName 127.0.0.1:11678</simpleWithResolvableServerNames.vhost4.servername.directive> + <simpleWithResolvableServerNames.vhost4.additional.directives></simpleWithResolvableServerNames.vhost4.additional.directives> </systemPropertyVariables> </configuration> </execution> diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java index 130acee..08ff372 100644 --- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java +++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java @@ -636,10 +636,14 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen return null; }
- private static String formatResourceKey(Configuration pluginConfiguration) { + public static String formatResourceKey(Configuration pluginConfiguration) { String serverRoot = pluginConfiguration.getSimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_SERVER_ROOT).getStringValue(); String httpdConf = pluginConfiguration.getSimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_HTTPD_CONF).getStringValue();
+ return formatResourceKey(serverRoot, httpdConf); + } + + public static String formatResourceKey(String serverRoot, String httpdConf) { serverRoot = FileUtils.getCanonicalPath(serverRoot); httpdConf = FileUtils.getCanonicalPath(httpdConf);
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java index abd6dd9..45f883d 100644 --- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java +++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java @@ -149,12 +149,27 @@ public enum HttpdAddressUtility { /** * A simple parser of the provided address into host and port * sections. + * <p> + * This is equivalent to calling {@link #parse(String, String)} with + * the default scheme "http". * * @param address the address to parse * @return an instance of Address with host and port set accordingly */ public static Address parse(String address) { - String scheme = "http"; + return parse(address, "http"); + } + + /** + * Parses given address into an Address object and assigns a default scheme if none + * is present in the address itself. + * + * @param address the address to parse + * @param defaultScheme the default scheme to apply or null if no scheme is required by default + * @return the parsed address + */ + public static Address parse(String address, String defaultScheme) { + String scheme = defaultScheme; int schemeSpecIdx = address.indexOf("://"); if (schemeSpecIdx >= 0) { scheme = address.substring(0, schemeSpecIdx); @@ -163,7 +178,7 @@ public enum HttpdAddressUtility {
int lastColonIdx = address.lastIndexOf(':'); if (lastColonIdx == -1) { - return new Address(address, NO_PORT_SPECIFIED_VALUE); + return new Address(scheme, address, NO_PORT_SPECIFIED_VALUE); } else { int lastRightBracketPos = address.lastIndexOf(']'); if (lastColonIdx > lastRightBracketPos) { @@ -184,7 +199,7 @@ public enum HttpdAddressUtility { } } } - + public boolean isPortWildcard() { return port == PORT_WILDCARD_VALUE; } @@ -257,15 +272,19 @@ public enum HttpdAddressUtility { public String toString(boolean includeScheme, boolean interpretWildcardPort) { StringBuilder bld = new StringBuilder();
- if (includeScheme) { + if (includeScheme && scheme != null) { bld.append(scheme).append("://"); }
- bld.append(host); + if (host != null) { + bld.append(host); + + if (port != NO_PORT_SPECIFIED_VALUE) { + bld.append(":"); + } + }
if (port != NO_PORT_SPECIFIED_VALUE) { - bld.append(":"); - if (port == PORT_WILDCARD_VALUE && interpretWildcardPort) { bld.append(WILDCARD); } else { @@ -428,8 +447,8 @@ public enum HttpdAddressUtility { return ret; }
- private static Address parseListen(String listenValue) { - Address ret = Address.parse(listenValue); + public static Address parseListen(String listenValue) { + Address ret = Address.parse(listenValue, null); if (!ret.isPortDefined()) { try { ret.port = Integer.parseInt(ret.host); diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java new file mode 100644 index 0000000..0e798b8 --- /dev/null +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTest.java @@ -0,0 +1,236 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.plugins.apache; + +import static org.testng.Assert.assertTrue; + +import java.io.File; +import java.net.URI; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.jmock.Expectations; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +import org.rhq.core.clientapi.agent.metadata.PluginMetadataParser; +import org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil; +import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor; +import org.rhq.core.clientapi.server.discovery.InventoryReport; +import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.domain.configuration.PropertySimple; +import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.resource.ResourceType; +import org.rhq.core.pc.ServerServices; +import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; +import org.rhq.core.pluginapi.inventory.PluginContainerDeployment; +import org.rhq.core.pluginapi.inventory.ResourceContext; +import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; +import org.rhq.core.system.SystemInfo; +import org.rhq.core.system.SystemInfoFactory; +import org.rhq.plugins.apache.util.ApacheDeploymentUtil; +import org.rhq.plugins.apache.util.ApacheDeploymentUtil.DeploymentConfig; +import org.rhq.plugins.apache.util.HttpdAddressUtility; +import org.rhq.plugins.platform.PlatformComponent; +import org.rhq.test.pc.PluginContainerSetup; +import org.rhq.test.pc.PluginContainerTest; + +/** + * + * + * @author Lukas Krejci + */ +@Test +public class UpgradeTest extends PluginContainerTest { + + private static final String PLATFORM_PLUGIN = "file:target/itest/plugins/rhq-platform-plugin-for-apache-test.jar"; + private static final String AUGEAS_PLUGIN = "file:target/itest/plugins/rhq-augeas-plugin-for-apache-test.jar"; + private static final String APACHE_PLUGIN = "file:target/itest/plugins/rhq-apache-plugin-for-apache-test.jar"; + + private static final String DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES = "simpleWithResolvableServerNames"; + + private List<ResourceType> resourceTypesInApachePlugin; + + private static class DiscoveryInput { + public String serverRootPath; + public String exePath; + public String httpdConfPath; + public String snmpHost; + public int snmpPort; + public String pingUrl; + } + + @BeforeClass + public void parseResourceTypesFromApachePlugin() throws Exception { + PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(new URI(APACHE_PLUGIN) + .toURL()); + PluginMetadataParser parser = new PluginMetadataParser(descriptor, + Collections.<String, PluginMetadataParser> emptyMap()); + + resourceTypesInApachePlugin = parser.getAllTypes(); + } + + @AfterClass + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void shutdownApache(String apacheInstallationDirectory, + String exePath) throws Exception { + + File apacheInstallationDir = new File(apacheInstallationDirectory); + File confDir = new File(apacheInstallationDir, "conf"); + + //it really doesn't matter which configuration i use here + DeploymentConfig deploymentConfig = ApacheDeploymentUtil + .getDeploymentConfigurationFromSystemProperties(DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES); + + DiscoveryInput discoveryInput = new DiscoveryInput(); + discoveryInput.serverRootPath = apacheInstallationDirectory; + discoveryInput.exePath = exePath; + discoveryInput.httpdConfPath = confDir.getAbsolutePath() + File.separatorChar + "httpd.conf"; + discoveryInput.snmpHost = deploymentConfig.snmpHost; + discoveryInput.snmpPort = deploymentConfig.snmpPort; + + HttpdAddressUtility.Address addr = deploymentConfig.mainServer.address1; + HttpdAddressUtility.Address addrToUse = new HttpdAddressUtility.Address(null, null, + HttpdAddressUtility.Address.NO_PORT_SPECIFIED_VALUE); + addrToUse.scheme = addr.scheme == null ? "http" : addr.scheme; + addrToUse.host = addr.host == null ? "localhost" : addr.host; + addrToUse.port = addr.port; + + discoveryInput.pingUrl = addrToUse.toString(); + + ApacheServerComponent serverComponent = findAndStartServerComponent(discoveryInput); + + serverComponent.invokeOperation("stop", null); + } + + @PluginContainerSetup(plugins = { PLATFORM_PLUGIN, AUGEAS_PLUGIN, APACHE_PLUGIN }) + @Parameters({ "apache2.install.dir", "apache2.exe.path" }) + public void testSimpleConfigurationWithResolvableServerNames_Apache2_upgradeFromRHQ1_3(String apacheInstallationDirectory, + String exePath) throws Exception { + + final ServerServices ss = getCurrentPluginContainerConfiguration().getServerServices(); + + context.checking(new Expectations() { + { + allowing(ss.getDiscoveryServerService().mergeInventoryReport(with(any(InventoryReport.class)))); + //will(/* push the mocked inventory down to the agent */); + } + }); + + prepareApacheForTest(DEPLOYMENT_SIMPLE_WITH_RESOLVABLE_SERVERNAMES, apacheInstallationDirectory, exePath, + Arrays.asList("/full-configurations/simple/httpd.conf", "/snmpd.conf")); + + startConfiguredPluginContainer(); + + //TODO check the results of the upgrade + } + + private void prepareApacheForTest(String configurationName, String apacheInstallationDirectory, + String apacheExePath, List<String> configurationFiles) throws Exception { + File apacheInstallationDir = new File(apacheInstallationDirectory); + + assertTrue(apacheInstallationDir.exists(), + "The 'apache2.install.dir' system property denotes a non-existant directory: '" + + apacheInstallationDirectory + "'."); + + File confDir = new File(apacheInstallationDir, "conf"); + + assertTrue( + confDir.exists(), + "The 'apache2.install.dir' system property denotes a directory that doesn't have a 'conf' subdirectory. This is unexpected."); + + DeploymentConfig deploymentConfig = ApacheDeploymentUtil + .getDeploymentConfigurationFromSystemProperties(configurationName); + + ApacheDeploymentUtil.deployConfiguration(confDir, configurationFiles, deploymentConfig); + + DiscoveryInput discoveryInput = new DiscoveryInput(); + discoveryInput.serverRootPath = apacheInstallationDirectory; + discoveryInput.exePath = apacheExePath; + discoveryInput.httpdConfPath = confDir.getAbsolutePath() + File.separatorChar + "httpd.conf"; + discoveryInput.snmpHost = deploymentConfig.snmpHost; + discoveryInput.snmpPort = deploymentConfig.snmpPort; + + HttpdAddressUtility.Address addr = deploymentConfig.mainServer.address1; + HttpdAddressUtility.Address addrToUse = new HttpdAddressUtility.Address(null, null, + HttpdAddressUtility.Address.NO_PORT_SPECIFIED_VALUE); + addrToUse.scheme = addr.scheme == null ? "http" : addr.scheme; + addrToUse.host = addr.host == null ? "localhost" : addr.host; + addrToUse.port = addr.port; + + discoveryInput.pingUrl = addrToUse.toString(); + + restartApache(discoveryInput); + } + + private void restartApache(DiscoveryInput discoveryInput) throws Exception { + ApacheServerComponent serverComponent = findAndStartServerComponent(discoveryInput); + + serverComponent.invokeOperation("restart", null); + } + + private ApacheServerComponent findAndStartServerComponent(DiscoveryInput discoveryInput) throws Exception { + ApacheServerDiscoveryComponent discoveryComponent = new ApacheServerDiscoveryComponent(); + + ResourceType resourceType = findApachePluginResourceTypeByName("Apache HTTP Server"); + SystemInfo systemInfo = SystemInfoFactory.createSystemInfo(); + + ResourceDiscoveryContext<PlatformComponent> discoveryContext = new ResourceDiscoveryContext<PlatformComponent>( + resourceType, null, null, systemInfo, null, null, PluginContainerDeployment.AGENT); + + Configuration config = discoveryContext.getDefaultPluginConfiguration(); + config.put(new PropertySimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_SERVER_ROOT, + discoveryInput.serverRootPath)); + config + .put(new PropertySimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_EXECUTABLE_PATH, discoveryInput.exePath)); + config + .put(new PropertySimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_HTTPD_CONF, discoveryInput.httpdConfPath)); + config + .put(new PropertySimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_SNMP_AGENT_HOST, discoveryInput.snmpHost)); + config + .put(new PropertySimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_SNMP_AGENT_PORT, discoveryInput.snmpPort)); + config.put(new PropertySimple(ApacheServerComponent.PLUGIN_CONFIG_PROP_URL, discoveryInput.pingUrl)); + + DiscoveredResourceDetails result = discoveryComponent.discoverResource(config, discoveryContext); + + ApacheServerComponent serverComponent = new ApacheServerComponent(); + + Resource resource = new Resource(result.getResourceKey(), null, resourceType); + resource.setPluginConfiguration(config); + ResourceContext<PlatformComponent> resourceContext = new ResourceContext<PlatformComponent>(resource, null, + null, systemInfo, null, null, null, null, null, null, null, null); + + serverComponent.start(resourceContext); + return serverComponent; + } + + private ResourceType findApachePluginResourceTypeByName(String resourceTypeName) { + for (ResourceType rt : resourceTypesInApachePlugin) { + if (resourceTypeName.equals(rt.getName())) { + return rt; + } + } + + return null; + } +} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java new file mode 100644 index 0000000..0e22cd4 --- /dev/null +++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/ApacheDeploymentUtil.java @@ -0,0 +1,271 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 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.plugins.apache.util; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Writer; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.unitils.thirdparty.org.apache.commons.io.FileUtils; + +import org.rhq.plugins.apache.util.HttpdAddressUtility.Address; + +/** + * + * + * @author Lukas Krejci + */ +public class ApacheDeploymentUtil { + + private static final Log LOG = LogFactory.getLog(ApacheDeploymentUtil.class); + + private ApacheDeploymentUtil() { + + } + + public static class DeploymentConfig { + public static class VHost { + public Address address1 = new Address(null, null, Address.NO_PORT_SPECIFIED_VALUE); + public Address address2 = null; + public Address address3 = null; + public Address address4 = null; + public String serverNameDirective = null; + public final List<String> additionalDirectives = new ArrayList<String>(); + } + + public String serverRoot = null; + public String documentRoot = "hdocs"; + public String snmpHost = "localhost"; + public int snmpPort = 1610; + public final VHost mainServer = new VHost(); + public final VHost vhost1 = new VHost(); + public final VHost vhost2 = new VHost(); + public final VHost vhost3 = new VHost(); + public final VHost vhost4 = new VHost(); + + { + mainServer.address2 = new Address(null, null, Address.NO_PORT_SPECIFIED_VALUE); + mainServer.address3 = new Address(null, null, Address.NO_PORT_SPECIFIED_VALUE); + mainServer.address4 = new Address(null, null, Address.NO_PORT_SPECIFIED_VALUE); + } + } + + public static DeploymentConfig getDeploymentConfigurationFromSystemProperties(String variablesPrefix) { + DeploymentConfig ret = new DeploymentConfig(); + + ret.serverRoot = System.getProperty(variablesPrefix + ".server.root"); + ret.documentRoot = System.getProperty(variablesPrefix + ".document.root", "htdocs"); + ret.snmpHost = System.getProperty(variablesPrefix + ".snmp.host", "localhost"); + ret.snmpPort = Integer.parseInt(System.getProperty(variablesPrefix + ".snmp.port", "1610")); + ret.mainServer.address1 = HttpdAddressUtility.parseListen(System.getProperty(variablesPrefix + ".listen1")); + ret.mainServer.address2 = HttpdAddressUtility.parseListen(System.getProperty(variablesPrefix + ".listen2")); + ret.mainServer.address3 = HttpdAddressUtility.parseListen(System.getProperty(variablesPrefix + ".listen3")); + ret.mainServer.address4 = HttpdAddressUtility.parseListen(System.getProperty(variablesPrefix + ".listen4")); + ret.mainServer.serverNameDirective = System.getProperty(variablesPrefix + ".servername.directive"); + + String additionalDirectives = System.getProperty(variablesPrefix + ".additional.directives"); + fillAdditionalDirectives(additionalDirectives, ret.mainServer.additionalDirectives); + + readVHostConfigFromSystemProperties(ret.vhost1, variablesPrefix + ".vhost1"); + readVHostConfigFromSystemProperties(ret.vhost2, variablesPrefix + ".vhost2"); + readVHostConfigFromSystemProperties(ret.vhost3, variablesPrefix + ".vhost3"); + readVHostConfigFromSystemProperties(ret.vhost4, variablesPrefix + ".vhost4"); + + return ret; + } + + public static void deployConfiguration(File targetConfDirectory, List<String> configFilesOnClasspath, DeploymentConfig config) throws IOException { + List<File> targetFiles = new ArrayList<File>(); + for(String fileOnClassPath : configFilesOnClasspath) { + String fileName = new File(fileOnClassPath).getName(); + + File targetFile = new File(targetConfDirectory, fileName); + + URL fileUrl = ApacheDeploymentUtil.class.getResource(fileOnClassPath); + + FileUtils.copyURLToFile(fileUrl, targetFile); + + targetFiles.add(targetFile); + } + + replaceTokensInConfigFiles(targetFiles, config); + } + + private static void replaceTokensInConfigFiles(List<File> configFiles, DeploymentConfig config) { + char[] buffer = new char[8192]; + StringBuilder wholeFile = new StringBuilder(); + for(File file : configFiles) { + BufferedReader rdr = null; + boolean errorOccured = false; + try { + rdr = new BufferedReader(new FileReader(file)); + + int cnt = -1; + + while ((cnt = rdr.read(buffer)) != -1) { + wholeFile.append(buffer, 0, cnt); + } + } catch (FileNotFoundException e) { + LOG.error("File '" + file + "' not found.", e); + errorOccured = true; + } catch (IOException e) { + LOG.error("Error while reading file '" + file + "'.", e); + errorOccured = true; + } + + if (rdr != null) { + try { + rdr.close(); + } catch (IOException e) { + LOG.error("Failed to close the file '" + file + "'."); + } + } + + if (errorOccured) { + continue; + } + + String newFileContents = replaceTokens(wholeFile, config); + + Writer wrt = null; + try { + wrt = new FileWriter(file); + + wrt.write(newFileContents); + } catch (IOException e) { + LOG.error("Error while writing to the configuration file '" + file + "'.", e); + } finally { + try { + wrt.close(); + } catch (IOException e) { + LOG.error("Failed to close the file '" + file + "'.", e); + } + } + } + } + + private static String replaceTokens(CharSequence input, DeploymentConfig config) { + String s = input.toString(); + + s = s.replaceAll("\$SERVER_ROOT", config.serverRoot); + s = s.replaceAll("\$DOCUMENT_ROOT", config.documentRoot); + s = s.replaceAll("\$SNMP_HOST", config.snmpHost); + s = s.replaceAll("\$SNMP_PORT", Integer.toString(config.snmpPort)); + s = s.replaceAll("\$LISTEN_1", config.mainServer.address1.toString()); + s = s.replaceAll("\$LISTEN_2", config.mainServer.address2.toString()); + s = s.replaceAll("\$LISTEN_3", config.mainServer.address3.toString()); + s = s.replaceAll("\$LISTEN_4", config.mainServer.address4.toString()); + s = s.replaceAll("\$SNMP_HOST", config.snmpHost); + + s = replaceVHostTokens(s, 0, config.mainServer); + s = replaceVHostTokens(s, 1, config.vhost1); + s = replaceVHostTokens(s, 2, config.vhost2); + s = replaceVHostTokens(s, 3, config.vhost3); + s = replaceVHostTokens(s, 4, config.vhost4); + + return s; + } + + private static String replaceVHostTokens(String input, int vhostNumber, DeploymentConfig.VHost vhost) { + String serverNameToken = getVhostOrMainServerToken(vhostNumber, "SERVER_NAME_DIRECTIVE"); + String urlsToken = getVhostOrMainServerToken(vhostNumber, "URLS"); + String additionalDirectivesToken = getVhostOrMainServerToken(vhostNumber, "ADDITIONAL_DIRECTIVES"); + + input = input.replaceAll(serverNameToken, vhost.serverNameDirective == null ? "" : vhost.serverNameDirective); + + if (vhostNumber > 0) { + String urls = vhost.address1.toString(false, false); + if (vhost.address2 != null) { + urls += " " + vhost.address2.toString(false, false); + } + if (vhost.address3 != null) { + urls += " " + vhost.address3.toString(false, false); + } + if (vhost.address4 != null) { + urls += " " + vhost.address4.toString(false, false); + } + + input = input.replaceAll(urlsToken, urls); + } + + String additionalDirectives = ""; + if (!vhost.additionalDirectives.isEmpty()) { + String newline = System.getProperty("line.separator"); + for(String dir : vhost.additionalDirectives) { + additionalDirectives += dir + newline; + } + } + + input = input.replaceAll(additionalDirectivesToken, additionalDirectives); + + return input; + } + + private static String getVhostOrMainServerToken(int vhostNumber, String tokenBody) { + return "\$" + (vhostNumber == 0 ? "" : ("VHOST" + vhostNumber + "_")) + tokenBody; + } + + private static void readVHostConfigFromSystemProperties(DeploymentConfig.VHost vhost, String prefix) { + String addrsString = System.getProperty(prefix + ".urls"); + + if (addrsString == null) { + throw new IllegalStateException("The system property '" + prefix + ".urls' doesn't exist. It is needed to define the vhost."); + } + + String[] addrs = addrsString.split("[ \t]+"); + + //the fallthroughs below are intentional + switch(addrs.length) { + case 4: + vhost.address4 = Address.parse(addrs[3], null); + case 3: + vhost.address3 = Address.parse(addrs[2], null); + case 2: + vhost.address2 = Address.parse(addrs[1], null); + case 1: + vhost.address1 = Address.parse(addrs[0], null); + break; + default: + throw new IllegalStateException("The system property '" + prefix + ".urls' specified " + addrs.length + " addresses. Only 1-4 addresses are supported."); + } + + vhost.serverNameDirective = System.getProperty(prefix + ".servername.directive"); + + String additionalDirectives = System.getProperty(prefix + ".additional.directives"); + fillAdditionalDirectives(additionalDirectives, vhost.additionalDirectives); + } + + private static void fillAdditionalDirectives(String additionalDirectivesString, List<String> additionalDirectives) { + if (additionalDirectivesString != null) { + for(String dir : additionalDirectivesString.split("\n")) { + additionalDirectives.add(dir); + } + } + } +} diff --git a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/StandAloneContainer.java b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/StandAloneContainer.java deleted file mode 100644 index 0047faf..0000000 --- a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/util/StandAloneContainer.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.rhq.plugins.apache.util; - -import java.io.File; - -import org.rhq.augeas.tree.AugeasTree; -import org.rhq.core.clientapi.agent.PluginContainerException; -import org.rhq.core.domain.resource.Resource; -import org.rhq.core.pc.PluginContainer; -import org.rhq.core.pc.PluginContainerConfiguration; -import org.rhq.core.pc.inventory.InventoryManager; -import org.rhq.core.pc.inventory.ResourceContainer; -import org.rhq.core.pc.plugin.FileSystemPluginFinder; -import org.rhq.core.pc.util.ComponentUtil; -import org.rhq.core.pc.util.FacetLockType; - -public class StandAloneContainer { - - public PluginContainer getContainer(AugeasTree tree,String pluginPath){ - PluginContainer container=null; - try { - container = PluginContainer.getInstance(); - File pluginDir = new File(pluginPath); - PluginContainerConfiguration config = new PluginContainerConfiguration(); - config.setPluginFinder(new FileSystemPluginFinder(pluginDir)); - config.setPluginDirectory(pluginDir); - - container.setConfiguration(config); - container.initialize(); - container.getInventoryManager().executeServerScanImmediately(); - container.getInventoryManager().executeServiceScanImmediately(); - - return container; - - }catch(Exception e){ - e.printStackTrace(); - if (container!=null) - container.shutdown(); - } - return null; - } - - - - public static <T> T getComponent(int resourceId, Class<T> facetInterface, FacetLockType lockType, - long timeout, boolean daemonThread, boolean onlyIfStarted) throws PluginContainerException { - InventoryManager inventoryManager = PluginContainer.getInstance().getInventoryManager(); - ResourceContainer resourceContainer = inventoryManager.getResourceContainer(resourceId); - if (resourceContainer == null) { - throw new PluginContainerException("Resource component container could not be retrieved for resource: " - + resourceId); - } - return resourceContainer.createResourceComponentProxy(facetInterface, lockType, timeout, daemonThread, onlyIfStarted); - } - - public static <T> Object getComponentProxy(Resource res,Class<T> facetInterface) throws Exception { - ClassLoader currenContextClassLoader = Thread.currentThread() - .getContextClassLoader(); - try { - Resource asResource = res; - ClassLoader cl = PluginContainer.getInstance().getPluginComponentFactory(). - getResourceClassloader(asResource); - - Class<?> resourceSpecificFacetInterface = Class.forName( - facetInterface.getName(), true, cl); - - Thread.currentThread().setContextClassLoader(cl); - - return ComponentUtil.getComponent(asResource.getId(),resourceSpecificFacetInterface, - FacetLockType.WRITE, 30000, true, true); - } finally { - Thread.currentThread().setContextClassLoader( - currenContextClassLoader); - } - } -} diff --git a/modules/plugins/apache/src/test/resources/full-configurations/includes/1.vhost.conf b/modules/plugins/apache/src/test/resources/full-configurations/includes/1.vhost.conf new file mode 100644 index 0000000..3d0cbb8 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/full-configurations/includes/1.vhost.conf @@ -0,0 +1,9 @@ +<VirtualHost $VHOST1_URLS> + $VHOST1_SERVER_NAME_DIRECTIVE + $VHOST1_ADDITIONAL_DIRECTIVES +</VirtualHost> + +<VirtualHost $VHOST2_URLS> + $VHOST2_SERVER_NAME_DIRECTIVE + $VHOST2_ADDITIONAL_DIRECTIVES +</VirtualHost> diff --git a/modules/plugins/apache/src/test/resources/full-configurations/includes/2.vhost.conf b/modules/plugins/apache/src/test/resources/full-configurations/includes/2.vhost.conf new file mode 100644 index 0000000..5a5025e --- /dev/null +++ b/modules/plugins/apache/src/test/resources/full-configurations/includes/2.vhost.conf @@ -0,0 +1,9 @@ +<VirtualHost $VHOST3_URLS> + $VHOST3_SERVER_NAME_DIRECTIVE + $VHOST3_ADDITIONAL_DIRECTIVES +</VirtualHost> + +<VirtualHost $VHOST4_URLS> + $VHOST4_SERVER_NAME_DIRECTIVE + $VHOST4_ADDITIONAL_DIRECTIVES +</VirtualHost> diff --git a/modules/plugins/apache/src/test/resources/full-configurations/includes/httpd.conf b/modules/plugins/apache/src/test/resources/full-configurations/includes/httpd.conf new file mode 100644 index 0000000..d0cf67c --- /dev/null +++ b/modules/plugins/apache/src/test/resources/full-configurations/includes/httpd.conf @@ -0,0 +1,40 @@ +ServerRoot $SERVER_ROOT + +Listen $LISTEN_1 +Listen $LISTEN_2 +Listen $LISTEN_3 +Listen $LISTEN_4 + +ServerAdmin root@localhost + +$SERVER_NAME_DIRECTIVE + +DocumentRoot $DOCUMENT_ROOT + +DirectoryIndex index.html index.html.var + +TypesConfig conf/mime.types + +DefaultType text/plain + +ErrorLog logs/error_log + +LogLevel debug + +LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined +LogFormat "%h %l %u %t "%r" %>s %b" common +LogFormat "%{Referer}i -> %U" referer +LogFormat "%{User-agent}i" agent + +CustomLog logs/access_log combined + +# Apache SNMP +LoadModule snmpcommon_module modules/libsnmpcommon.so +LoadModule snmpagt_module modules/libsnmpmonagt.so +SNMPConf conf +SNMPVar var +# End of apache SNMP + +$ADDITIONAL_DIRECTIVES + +Include *.vhost.conf diff --git a/modules/plugins/apache/src/test/resources/full-configurations/mess/1.vhost.conf b/modules/plugins/apache/src/test/resources/full-configurations/mess/1.vhost.conf new file mode 100644 index 0000000..1898969 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/full-configurations/mess/1.vhost.conf @@ -0,0 +1,17 @@ +<IfModule not_loaded_module> + <VirtualHost $VHOST1_URLS> + $VHOST1_SERVER_NAME_DIRECTIVE + $VHOST1_ADDITIONAL_DIRECTIVES + </VirtualHost> +</IfModule> + +LoadModule proxy_module modules/mod_proxy.so + +<IfModule snmpcommon_module> +<IfModule mod_proxy.c> + <VirtualHost $VHOST2_URLS> + $VHOST2_SERVER_NAME_DIRECTIVE + $VHOST2_ADDITIONAL_DIRECTIVES + </VirtualHost> +</IfModule> +</IfModule> diff --git a/modules/plugins/apache/src/test/resources/full-configurations/mess/2.vhost.conf b/modules/plugins/apache/src/test/resources/full-configurations/mess/2.vhost.conf new file mode 100644 index 0000000..146cea9 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/full-configurations/mess/2.vhost.conf @@ -0,0 +1,13 @@ +<IfModule snmpcommon_module> +<IfModule mod_unknown.c> + <VirtualHost $VHOST3_URLS> + $VHOST3_SERVER_NAME_DIRECTIVE + $VHOST3_ADDITIONAL_DIRECTIVES + </VirtualHost> +</IfModule> +</IfModule> + +<VirtualHost $VHOST4_URLS> + $VHOST4_SERVER_NAME_DIRECTIVE + $VHOST4_ADDITIONAL_DIRECTIVES +</VirtualHost> diff --git a/modules/plugins/apache/src/test/resources/full-configurations/mess/httpd.conf b/modules/plugins/apache/src/test/resources/full-configurations/mess/httpd.conf new file mode 100644 index 0000000..d0cf67c --- /dev/null +++ b/modules/plugins/apache/src/test/resources/full-configurations/mess/httpd.conf @@ -0,0 +1,40 @@ +ServerRoot $SERVER_ROOT + +Listen $LISTEN_1 +Listen $LISTEN_2 +Listen $LISTEN_3 +Listen $LISTEN_4 + +ServerAdmin root@localhost + +$SERVER_NAME_DIRECTIVE + +DocumentRoot $DOCUMENT_ROOT + +DirectoryIndex index.html index.html.var + +TypesConfig conf/mime.types + +DefaultType text/plain + +ErrorLog logs/error_log + +LogLevel debug + +LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined +LogFormat "%h %l %u %t "%r" %>s %b" common +LogFormat "%{Referer}i -> %U" referer +LogFormat "%{User-agent}i" agent + +CustomLog logs/access_log combined + +# Apache SNMP +LoadModule snmpcommon_module modules/libsnmpcommon.so +LoadModule snmpagt_module modules/libsnmpmonagt.so +SNMPConf conf +SNMPVar var +# End of apache SNMP + +$ADDITIONAL_DIRECTIVES + +Include *.vhost.conf diff --git a/modules/plugins/apache/src/test/resources/full-configurations/nested/httpd.conf b/modules/plugins/apache/src/test/resources/full-configurations/nested/httpd.conf new file mode 100644 index 0000000..3882e8f --- /dev/null +++ b/modules/plugins/apache/src/test/resources/full-configurations/nested/httpd.conf @@ -0,0 +1,68 @@ +ServerRoot $SERVER_ROOT + +Listen $LISTEN_1 +Listen $LISTEN_2 +Listen $LISTEN_3 +Listen $LISTEN_4 + +ServerAdmin root@localhost + +$SERVER_NAME_DIRECTIVE + +DocumentRoot $DOCUMENT_ROOT + +DirectoryIndex index.html index.html.var + +TypesConfig conf/mime.types + +DefaultType text/plain + +ErrorLog logs/error_log + +LogLevel debug + +LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined +LogFormat "%h %l %u %t "%r" %>s %b" common +LogFormat "%{Referer}i -> %U" referer +LogFormat "%{User-agent}i" agent + +CustomLog logs/access_log combined + +# Apache SNMP +LoadModule snmpcommon_module modules/libsnmpcommon.so +LoadModule snmpagt_module modules/libsnmpmonagt.so +SNMPConf conf +SNMPVar var +# End of apache SNMP + +$ADDITIONAL_DIRECTIVES + +<IfModule not_loaded_module> + <VirtualHost $VHOST1_URLS> + $VHOST1_SERVER_NAME_DIRECTIVE + $VHOST1_ADDITIONAL_DIRECTIVES + </VirtualHost> +</IfModule> + +LoadModule proxy_module modules/mod_proxy.so + +<IfModule snmpcommon_module> +<IfModule mod_proxy.c> + <VirtualHost $VHOST2_URLS> + $VHOST2_SERVER_NAME_DIRECTIVE + $VHOST2_ADDITIONAL_DIRECTIVES + </VirtualHost> +</IfModule> + +<IfModule mod_unknown.c> + <VirtualHost $VHOST3_URLS> + $VHOST3_SERVER_NAME_DIRECTIVE + $VHOST3_ADDITIONAL_DIRECTIVES + </VirtualHost> +</IfModule> +</IfModule> + +<VirtualHost $VHOST4_URLS> + $VHOST4_SERVER_NAME_DIRECTIVE + $VHOST4_ADDITIONAL_DIRECTIVES +</VirtualHost> diff --git a/modules/plugins/apache/src/test/resources/full-configurations/simple/httpd.conf b/modules/plugins/apache/src/test/resources/full-configurations/simple/httpd.conf new file mode 100644 index 0000000..13195ef --- /dev/null +++ b/modules/plugins/apache/src/test/resources/full-configurations/simple/httpd.conf @@ -0,0 +1,58 @@ +ServerRoot $SERVER_ROOT + +Listen $LISTEN_1 +Listen $LISTEN_2 +Listen $LISTEN_3 +Listen $LISTEN_4 + +ServerAdmin root@localhost + +$SERVER_NAME_DIRECTIVE + +DocumentRoot $DOCUMENT_ROOT + +DirectoryIndex index.html index.html.var + +TypesConfig conf/mime.types + +DefaultType text/plain + +ErrorLog logs/error_log + +LogLevel debug + +LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined +LogFormat "%h %l %u %t "%r" %>s %b" common +LogFormat "%{Referer}i -> %U" referer +LogFormat "%{User-agent}i" agent + +CustomLog logs/access_log combined + +# Apache SNMP +LoadModule snmpcommon_module modules/libsnmpcommon.so +LoadModule snmpagt_module modules/libsnmpmonagt.so +SNMPConf conf +SNMPVar var +# End of apache SNMP + +$ADDITIONAL_DIRECTIVES + +<VirtualHost $VHOST1_URLS> + $VHOST1_SERVER_NAME_DIRECTIVE + $VHOST1_ADDITIONAL_DIRECTIVES +</VirtualHost> + +<VirtualHost $VHOST2_URLS> + $VHOST2_SERVER_NAME_DIRECTIVE + $VHOST2_ADDITIONAL_DIRECTIVES +</VirtualHost> + +<VirtualHost $VHOST3_URLS> + $VHOST3_SERVER_NAME_DIRECTIVE + $VHOST3_ADDITIONAL_DIRECTIVES +</VirtualHost> + +<VirtualHost $VHOST4_URLS> + $VHOST4_SERVER_NAME_DIRECTIVE + $VHOST4_ADDITIONAL_DIRECTIVES +</VirtualHost> diff --git a/modules/plugins/apache/src/test/resources/snmpd.conf b/modules/plugins/apache/src/test/resources/snmpd.conf new file mode 100644 index 0000000..1cbc543 --- /dev/null +++ b/modules/plugins/apache/src/test/resources/snmpd.conf @@ -0,0 +1,141 @@ +############################################################################### +# +# Conductor SNMP configuration file. +# +# This file is used to configure the Covalent SNMP Conductor agent. +# +# All lines beginning with a '#' are comments and are intended for you +# to read. All other lines are configuration commands for the agent. +# +# For more information, please refer to: +# http://www.covalent.net/resource/documentation/ers/2.2.0/HTML/ProductGuide/s... +# +############################################################################### +# Network Setup +############################################################################### +# agentaddress +# +# SYNTAX: +# agentaddress [(udp|tcp):]port[@address][,...] +# DESCRIPTION: +# This directive specifies the port(s) and optional address the SNMP agent +# will listen on. Multiple ports can be separated by commas. Transports can +# be specified by prepending the port number with the transport name ("udp" +# or "tcp") followed by a colon. To bind to a particular interface, you can +# specify the address (@address) you want it to bind with. +# EXAMPLE: +# agentaddress 8161,tcp:8161,9161@localhost +# Directs the agent to listen on udp port 8161 for any address, tcp port +# 8161 for any address, and udp port 9161 on only the interface associated +# with the localhost address. +# DEFAULT: +# agentaddress 161 + +agentaddress $SNMP_PORT@$SNMP_HOST + +############################################################################### +# View-based Access Control +############################################################################### +# This section explains on how to configure the View Based Access Control. +# +# If you want SNMPv1 and/or SNMPv2c access, you need to map +# the community name into a security name. +# SYNTAX: +# com2sec <SECNAME> <NETWORK> <COMMUNITY> +# <SECNAME> is used as user within the SNMP agent. +# <NETWORK> is used to defined from which hosts or networks +# the SNMP agent can be accessed by using the associated +# community string. +# <COMMUNITY> is the community string as used in SNMPv1 and SNMPv2c +# for authentication. + +com2sec local localhost public +#@@ENABLESNMPV12@@com2sec mynetwork @@SNMPNETWORK@@ public + +#### +# You need to map the <SECNAME>'s into one or muliple groups +# and assicate a security model to it. +# SYNTAX: +# group <GROUPNAME> <SECMODEL> <SECNAME> +# <GROUPNAME> is the idenitfication of the group. +# <SECMODEL> is the security model used. The agent +# uses: 'v1', 'v2c', 'usm' or 'any' +# <SECNAME> is the name via which SNMPv1 and SNMPv2c +# have access or the 'username' of SNMPv3 + +group MyRWGroup v1 local +group MyRWGroup v2c local +#@@ENABLESNMPV12@@group MyROGroup v1 mynetwork +#@@ENABLESNMPV12@@group MyROGroup v2c mynetwork + +#### +# You need to create a view of the MIB that can either be a +# complete or partial view. +# SYNTAX: +# view <VIEWNAME> <TYPE> <SUBTREE> <MASK> +# <VIEWNAME> identification for a MIB view. +# <TYPE> is either 'included' or 'excluded' and perform +# the associated action on the <SUBTREE> +# <SUBTREE> the MIB subtree to which the view applies. +# <MASK> is on the places in the OID-string for the accessed objects that +# must be match to included in this view. + +view all included .1 80 + +#### +# Grant each group access and define its permissions. +# SYNTAX: access <GROUPNAME> <CONTEXT> <SECMODEL> <SECLEVEL> <MATCH> <READ> <WRITE> <NOTIFY> +# <GROUPNAME> the group identification as defined with 'group'. +# <CONTEXT> the context in which access is granted. Default "" +# <SECMODEL> the security model required to be used for access +# The agent uses: 'v1', 'v2c', 'usm' or 'any' +# <SECLEVEL> The security level used for access to the MIB. The agent +# uses: 'noauth', 'auth' or 'priv' +# <MATCH> specifies how CONTEXT should be matched against the +# context of the incoming pdu, either exact or prefix. +# <READ> specificies the view for corresponding access. +# <WRITE> specificies the view for corresponding access. +# <NOTIFY> specificies the view for corresponding access. +access MyROGroup "" any noauth exact all none none +access MyRWGroup "" any noauth exact all all none + +############################################################################### +# User-based Security +############################################################################### +# For SNMPv3 you need to create users. However, after starting and stopping +# you would like to delete the 'createuser' line. The SNMP agent will store +# this information encrypted, in a persistent configuration file. +# +# We first want to create or map the SNMPv3 user into a group and provide +# access with the above view-based access control. +# Forinstance, group MyRWGroup usm covalent + +#group MyRWGroup usm covalent + +# For SNMPv3 (User-based Security) we need create a user. +# SYNTAX: CreateUser <USERNAME> <MD5/SHA> <MD5PASSPHRASE> [DES] <PASSPHRASE> +# <USERNAME> the SNMPv3 user name. Maps in to view-based access +# control on the <SECNAME> +# <MD5/SHA> type of authentication +# <MD5PASSPHRASE> the MD5 or SHA passphrase. +# <DES> the privacy protocol +# <DESPASSPHRASE> the privacy passphrase. +# Your passphrases must be at least 8 characters long! + +#@@ENABLESNMPV3@@createUser covalent MD5 @@SNMPV3PASSWORD@@ DES @@SNMPV3PASSWORD@@ + +# NOTE: If you have used the installer that was provided with Conductor +# You probably have already created the user 'covalent'. +# This was done if you were asked for an SNMPv3 password. +############################################################################### +# System information +# +# One can define some values to be returned for the system group. +# 'sysLocation' where the system is located. +# SYNTAX: syslocation <STRING> +# 'sysContact' for this system. +# SYNTAX: syscontact <STRING> + +syscontact Covalent SNMP Conductor webmaster@your.domain +syslocation Apache Server with Covalent SNMP Conductor + diff --git a/pom.xml b/pom.xml index 98dfb0c..1ccfc93 100644 --- a/pom.xml +++ b/pom.xml @@ -509,6 +509,12 @@ <artifactId>cobertura</artifactId> <version>${cobertura.version}</version> </dependency> + <!-- Just to have more tasks available --> + <dependency> + <groupId>ant</groupId> + <artifactId>ant-nodeps</artifactId> + <version>1.6.5</version> + </dependency> </dependencies> </plugin> <plugin>
commit ce1acd9e6cb798a29aa6d68a6cdb51ff7b119909 Author: Lukas Krejci lkrejci@redhat.com Date: Tue May 31 14:19:19 2011 +0200
Fix the NPE if the plugin URL specified in the PluginContainerSetup was defined using the schema-specific part as with the relative paths to the current directory:
file:relative/path
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/test/pc/PluginContainerSetup.java b/modules/core/plugin-container/src/test/java/org/rhq/test/pc/PluginContainerSetup.java index a6baff0..df4ca05 100644 --- a/modules/core/plugin-container/src/test/java/org/rhq/test/pc/PluginContainerSetup.java +++ b/modules/core/plugin-container/src/test/java/org/rhq/test/pc/PluginContainerSetup.java @@ -44,7 +44,8 @@ public @interface PluginContainerSetup { * Examples of URIs: * <ul> * <li> classpath:///test-plugin.jar - * <li> file:///some/location/on/the/filesystem.jar + * <li> file:///some/absolute/location/on/the/filesystem.jar + * <li> file:relative/path/to/current/directory/blah.jar * <li> http://www.rhq-project.org/tests/test-plugin.jar */ String[] plugins(); diff --git a/modules/core/plugin-container/src/test/java/org/rhq/test/pc/PluginContainerTest.java b/modules/core/plugin-container/src/test/java/org/rhq/test/pc/PluginContainerTest.java index 7e91ede..07a8ea3 100644 --- a/modules/core/plugin-container/src/test/java/org/rhq/test/pc/PluginContainerTest.java +++ b/modules/core/plugin-container/src/test/java/org/rhq/test/pc/PluginContainerTest.java @@ -387,7 +387,7 @@ public class PluginContainerTest extends JMockTest { }
- String pluginFileName = pluginUri.getPath().substring(pluginUri.getPath().lastIndexOf('/') + 1); + String pluginFileName = pluginUrl.getPath().substring(pluginUrl.getPath().lastIndexOf('/') + 1);
File pluginJar = new File(destination, pluginFileName); FileUtils.copyURLToFile(pluginUrl, pluginJar);
commit 80dc1b2ae792d617a8b7e8aac200f63bef038fed Author: Lukas Krejci lkrejci@redhat.com Date: Tue May 31 11:41:14 2011 +0200
Set up the main server vhost URL and response time log file location even if the parent apache server component doesn't have the URL property set. In that case, the main server sample address is detected and used.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java index 28f68da..8efac1d 100644 --- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java +++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java @@ -86,7 +86,7 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco tree = RuntimeApacheConfiguration.extract(tree, serverComponent.getCurrentProcessInfo(), serverComponent.getCurrentBinaryInfo(), serverComponent.getModuleNames(), false);
//first define the root server as one virtual host - discoverMainServer(context, discoveredResources); + discoverMainServer(context, tree, discoveredResources);
ResourceType resourceType = context.getResourceType();
@@ -273,7 +273,7 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco }
private void discoverMainServer(ResourceDiscoveryContext<ApacheServerComponent> context, - Set<DiscoveredResourceDetails> discoveredResources) throws Exception { + ApacheDirectiveTree runtimeConfig, Set<DiscoveredResourceDetails> discoveredResources) throws Exception {
ResourceType resourceType = context.getResourceType(); Configuration mainServerPluginConfig = context.getDefaultPluginConfiguration(); @@ -284,25 +284,28 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco String mainServerUrl = context.getParentResourceContext().getPluginConfiguration().getSimple( ApacheServerComponent.PLUGIN_CONFIG_PROP_URL).getStringValue();
- if (mainServerUrl != null && !"null".equals(mainServerUrl)) { - PropertySimple mainServerUrlProp = new PropertySimple(ApacheVirtualHostServiceComponent.URL_CONFIG_PROP, - mainServerUrl); + if (mainServerUrl == null || mainServerUrl.trim().isEmpty()) { + HttpdAddressUtility.Address addr = context.getParentResourceComponent().getAddressUtility().getMainServerSampleAddress(runtimeConfig, null, 0); + mainServerUrl = addr.toString(); + } + + PropertySimple mainServerUrlProp = new PropertySimple(ApacheVirtualHostServiceComponent.URL_CONFIG_PROP, + mainServerUrl);
- mainServerPluginConfig.put(mainServerUrlProp); + mainServerPluginConfig.put(mainServerUrlProp);
- URI mainServerUri = new URI(mainServerUrl); - String host = mainServerUri.getHost(); - int port = mainServerUri.getPort(); - if (port == -1) { - port = 80; - } + URI mainServerUri = new URI(mainServerUrl); + String host = mainServerUri.getHost(); + int port = mainServerUri.getPort(); + if (port == -1) { + port = 80; + }
- File rtLogFile = new File(logsDir, host + port + RT_LOG_FILE_NAME_SUFFIX); + File rtLogFile = new File(logsDir, host + port + RT_LOG_FILE_NAME_SUFFIX);
- PropertySimple rtLogProp = new PropertySimple( - ApacheVirtualHostServiceComponent.RESPONSE_TIME_LOG_FILE_CONFIG_PROP, rtLogFile.toString()); - mainServerPluginConfig.put(rtLogProp); - } + PropertySimple rtLogProp = new PropertySimple( + ApacheVirtualHostServiceComponent.RESPONSE_TIME_LOG_FILE_CONFIG_PROP, rtLogFile.toString()); + mainServerPluginConfig.put(rtLogProp);
String key = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
rhq-commits@lists.fedorahosted.org