modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java | 8 modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/ResourcesDomainServerTest.java | 139 ++++++++++ modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/SecurityModuleOptionsTest.java | 46 +-- modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/ResourcesStandaloneServerTest.java | 2 4 files changed, 171 insertions(+), 24 deletions(-)
New commits: commit 7f0fd6111408fbe4fb6643e7646cb86d679d37ec Author: Stefan Negrea snegrea@redhat.com Date: Fri Sep 21 12:53:46 2012 -0500
[BZ 859512] Execute :read-resource if whoami fails to correctly detect the server state. :whoami exists for the majority of the resources, the only exceptions are resources that do not have the security context established by AS7.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java index a4e99b4..080c60f 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java @@ -280,6 +280,14 @@ public class BaseComponent<T extends ResourceComponent<?>> implements AS7Compone // Read server state Operation op = new Operation("whoami", getAddress()); Result res = getASConnection().execute(op); + + //:whoami might fail host controller resources, in that case use :read-resource operation + //which is slower due to larger content returned but more reliable since every resource has it. + if (!res.isSuccess()) { + op = new Operation("read-resource", getAddress()); + res = getASConnection().execute(op); + } + if (res.isReloadRequired()) { PropertySimple oobMessage = new PropertySimple("__OOB","The server needs a reload for the latest changes to come effective."); configuration.put(oobMessage);
commit 965b08b1e2f8a16f33206001d8f8ac19d0bec51b Author: Stefan Negrea snegrea@redhat.com Date: Fri Sep 21 12:20:25 2012 -0500
Update test priority to match other integration tests for host controllers.
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/SecurityModuleOptionsTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/SecurityModuleOptionsTest.java index 7be0689..99f6fa6 100644 --- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/SecurityModuleOptionsTest.java +++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/SecurityModuleOptionsTest.java @@ -64,8 +64,8 @@ import org.rhq.modules.plugins.jbossas7.json.Result; import org.rhq.test.arquillian.RunDiscovery;
/** - * Test exercising the subsystem=security/SecurityDomain/[Authentication(Classic|Jaspi), - * Authorization, Mapping, Audit, Acl, + * Test exercising the subsystem=security/SecurityDomain/[Authentication(Classic|Jaspi), + * Authorization, Mapping, Audit, Acl, * Identity-Trust] * @author Simeon Pinder */ @@ -130,7 +130,7 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest { /* This first discovery is only so that we can leverage existing code to install the management user needed * in next test. */ - @Test(priority = 10, groups = "discovery") + @Test(priority = 1040, groups = "discovery") @RunDiscovery(discoverServices = true, discoverServers = true) public void firstDiscovery() throws Exception { Resource platform = this.pluginContainer.getInventoryManager().getPlatform(); @@ -142,16 +142,16 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest { installManagementUsers(); }
- /** This method mass loads all the supported Module Option Types(Excluding authentication=jaspi, cannot co-exist with + /** This method mass loads all the supported Module Option Types(Excluding authentication=jaspi, cannot co-exist with * authentication=classic) into a single SecurityDomain. This is done as - * -i)creating all of the related hierarchy of types needed to exercise N Module Options Types and their associated + * -i)creating all of the related hierarchy of types needed to exercise N Module Options Types and their associated * Module Options instances would take too long to setup(N creates would signal N discovery runs before test could complete). - * -ii)setting the priority of this method lower than the discovery method means that we'll get all the same types in much + * -ii)setting the priority of this method lower than the discovery method means that we'll get all the same types in much * less time. - * + * * @throws Exception */ - @Test(priority = 11) + @Test(priority = 1041) public void loadStandardModuleOptionTypes() throws Exception { mapper = new ObjectMapper(); mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); @@ -226,10 +226,10 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest { }
/** Runs the second discovery run to load all the new types added. - * + * * @throws Exception */ - @Test(priority = 12, groups = "discovery") + @Test(priority = 1042, groups = "discovery") @RunDiscovery(discoverServices = true, discoverServers = true) public void secondDiscovery() throws Exception { Resource platform = this.pluginContainer.getInventoryManager().getPlatform(); @@ -243,14 +243,14 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest {
/** This test method exercises a number of things: * - that the security-domain children loaded have been created successfully - * - that all of the supported Module Option Type children(excluding 'authentication=jaspi') have been + * - that all of the supported Module Option Type children(excluding 'authentication=jaspi') have been * discovered as AS7 types successfully. * - that the correct child attribute was specified for each type //Ex. acl=classic -> acl-modules - * - - * + * - + * * @throws Exception */ - @Test(priority = 13) + @Test(priority = 1043) public void testDiscoveredSecurityNodes() throws Exception { //lazy-load configurationManager if (testConfigurationManager == null) { @@ -338,7 +338,7 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest { Configuration loadedOptionsConfiguration = testConfigurationManager .loadResourceConfiguration(moduleOptionsResource.getId()); for (String key : loadedOptionsConfiguration.getAllProperties().keySet()) { - //retrieve the open map of Module Options + //retrieve the open map of Module Options PropertyMap map = ((PropertyMap) loadedOptionsConfiguration.getAllProperties().get(key)); LinkedHashMap<String, Object> options = moduleOptionType.getOptions(); for (String optionKey : map.getMap().keySet()) { @@ -359,7 +359,7 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest { } }
- @Test(priority = 14) + @Test(priority = 1044) public void testCreateSecurityDomain() throws Exception { //get the root security resource securityResource = getResource(); @@ -387,7 +387,7 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest { + response.getErrorMessage(); }
- @Test(priority = 15) + @Test(priority = 1045) public void testAuthenticationClassic() throws Exception { //get the root security resource securityResource = getResource(); @@ -426,7 +426,7 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest { + response.getErrorMessage(); }
- @Test(priority = 16) + @Test(priority = 1046) public void testDeleteSecurityDomain() throws Exception { //get the root security resource securityResource = getResource(); @@ -477,7 +477,7 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest { }
/** Automates hierarchy creation for Module Option type resources and their parents - * + * * @param optionAttributeType * @return */ @@ -553,7 +553,7 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest { }
/** Automates hierarchy creation for Module Option type resources and their parents - * + * * @param optionAttributeType * @return */ @@ -624,10 +624,10 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest { return created; }
- /** For each operation + /** For each operation * - will write verbose json and operation details to system.out if verboseOutput = true; * - will execute the operation against running server if execute = true. - * + * * @param op * @param execute * @param verboseOutput @@ -664,7 +664,7 @@ public class SecurityModuleOptionsTest extends AbstractJBossAS7PluginTest { } } if (verboseOutput) { - //result wrapper details + //result wrapper details System.out.println("\tResult:" + result); //detailed results System.out.println("\tValue:" + result.getResult());
commit 313c627fe8e0015faf4c978c71801584bb2b3afa Author: Stefan Negrea snegrea@redhat.com Date: Fri Sep 21 12:19:52 2012 -0500
Add generic unit tests for loading and updating resource configuration and executing noarg operations for AS7 host controllers.
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/ResourcesDomainServerTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/ResourcesDomainServerTest.java new file mode 100644 index 0000000..1714b64 --- /dev/null +++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/ResourcesDomainServerTest.java @@ -0,0 +1,139 @@ +/* + * RHQ Management Platform + * Copyright 2011, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This 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.modules.plugins.jbossas7.itest.domain; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.testng.Assert; +import org.testng.annotations.Test; + +import org.rhq.core.domain.resource.InventoryStatus; +import org.rhq.core.domain.resource.Resource; +import org.rhq.core.pc.inventory.InventoryManager; +import org.rhq.core.pc.inventory.ResourceContainer; +import org.rhq.modules.plugins.jbossas7.itest.AbstractJBossAS7PluginTest; +import org.rhq.test.arquillian.RunDiscovery; + +/** + * @author Stefan Negrea + * + */ +@Test(groups = { "integration", "pc", "domain" }, singleThreaded = true) +public class ResourcesDomainServerTest extends AbstractJBossAS7PluginTest { + private Log log = LogFactory.getLog(this.getClass()); + + @Test(priority = 1030, groups = "discovery") + @RunDiscovery(discoverServices = true, discoverServers = true) + public void discoverPlatform() throws Exception { + InventoryManager inventoryManager = this.pluginContainer.getInventoryManager(); + + Resource platform = inventoryManager.getPlatform(); + assertNotNull(platform); + assertEquals(platform.getInventoryStatus(), InventoryStatus.COMMITTED); + + Thread.sleep(20 * 1000L); + + ResourceContainer platformContainer = inventoryManager.getResourceContainer(platform); + Resource server = getResourceByTypeAndKey(platform, DomainServerComponentTest.RESOURCE_TYPE, + DomainServerComponentTest.RESOURCE_KEY); + inventoryManager.activateResource(server, platformContainer, false); + + Thread.sleep(80 * 1000L); + } + + + @Test(priority = 1031) + public void loadUpdateResourceConfiguration() throws Exception { + List<String> ignoredResources = new ArrayList<String>(); + + //ignored because of differences between test plugin container and real application + //works well with real agent + ignoredResources.add("VHost (Profile)"); + ignoredResources.add("VHost (Managed Server)"); + + //created JIRA AS7-5011 + //server is started with the configuration but unable to write it back as is + //due to marshaling error + ignoredResources.add("Network Interface"); + + //created JIRA AS7-5012 + //default value for is float but the resource only accepts integers + ignoredResources.add("Domain Load Metric"); + + //will revisit after BZ 826542 is resolved + //ignoredResources.add("Authentication (Classic)"); + + //tested separately + ignoredResources.add("SocketBindingGroup"); + + //Update requirements validate separately + ignoredResources.add("Pooled Connection Factory (Profile)"); + ignoredResources.add("Connection Factory (Profile)"); + ignoredResources.add("Pooled Connection Factory (Managed Server)"); + ignoredResources.add("Connection Factory (Managed Server)"); + + ignoredResources.add("Memory Pool"); + ignoredResources.add("Periodic Rotating File Handler"); + ignoredResources.add("Console Handler"); + + Resource platform = this.pluginContainer.getInventoryManager().getPlatform(); + Resource server = getResourceByTypeAndKey(platform, DomainServerComponentTest.RESOURCE_TYPE, + DomainServerComponentTest.RESOURCE_KEY); + + int errorCount = loadUpdateConfigChildResources(server, ignoredResources); + Assert.assertEquals(errorCount, 0); + } + + @Test(priority = 1032) + public void executeNoArgOperations() throws Exception { + List<String> ignoredSubsystems = new ArrayList<String>(); + + List<String> ignoredOperations = new ArrayList<String>(); + //ignored because there is no other server to fail-over to + ignoredOperations.add("subsystem:force-failover"); + //ignored because this is not a true operation, it is handled + //internally by a configuration property change + ignoredOperations.add("enable"); + //ignored because the Osgi subsystem not configured out of box + ignoredOperations.add("subsystem:activate"); + + //ignored operations because they will stop the managed server and + //the domain controller itself + ignoredOperations.add("stop"); + ignoredOperations.add("restart"); + ignoredOperations.add("shutdown"); + ignoredOperations.add("stop-servers"); + ignoredOperations.add("restart-servers"); + + Resource platform = this.pluginContainer.getInventoryManager().getPlatform(); + Resource server = getResourceByTypeAndKey(platform, DomainServerComponentTest.RESOURCE_TYPE, + DomainServerComponentTest.RESOURCE_KEY); + + executeNoArgOperations(server, ignoredSubsystems, ignoredOperations); + } + +} diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/ResourcesStandaloneServerTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/ResourcesStandaloneServerTest.java index 824162a..8d391a1 100644 --- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/ResourcesStandaloneServerTest.java +++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/ResourcesStandaloneServerTest.java @@ -67,7 +67,7 @@ public class ResourcesStandaloneServerTest extends AbstractJBossAS7PluginTest {
@Test(priority = 12) - public void loadUpdateTemplatedResourceConfiguration() throws Exception { + public void loadUpdateResourceConfiguration() throws Exception { List<String> ignoredResources = new ArrayList<String>();
//ignored because of differences between test plugin container and real application
rhq-commits@lists.fedorahosted.org