modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java | 3 modules/core/plugin-container/src/test/java/org/rhq/test/pc/PluginContainerTest.java | 2 modules/core/util/src/main/java/org/rhq/core/util/stream/StreamUtil.java | 72 modules/plugins/apache/pom.xml | 82 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/UpgradeSimpleConfigurationWithResolvableServerNamesTest.java | 235 - modules/plugins/apache/src/test/java/org/rhq/plugins/apache/UpgradeTestBase.java | 431 --- 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 | 93 modules/plugins/apache/src/test/resources/full-configurations/2.2.x/includes/httpd.conf | 13 modules/plugins/apache/src/test/resources/full-configurations/2.2.x/mess/1.vhost.conf | 4 modules/plugins/apache/src/test/resources/full-configurations/2.2.x/mess/httpd.conf | 13 modules/plugins/apache/src/test/resources/full-configurations/2.2.x/nested/httpd.conf | 15 modules/plugins/apache/src/test/resources/full-configurations/2.2.x/simple/httpd.conf | 11 modules/plugins/apache/src/test/resources/log4j.xml | 2 modules/plugins/apache/src/test/resources/mime.types | 1351 ---------- 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 | 4 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/test-utils/src/main/java/org/rhq/test/TokenReplacingProperties.java | 11 modules/test-utils/src/main/java/org/rhq/test/TokenReplacingReader.java | 69 77 files changed, 20084 insertions(+), 2133 deletions(-)
New commits: 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;
rhq-commits@lists.fedorahosted.org