etc/agentspawn/src/scripts/agentcopy.properties | 4
modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/avail/AvailTest.java | 8
modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/LateMeasurementRescheduleTest.java | 4
modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/ReadOnlyScheduleSetTest.java | 4
modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java | 133 ++-
modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientProxy.java | 39 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java | 14
modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/Installer.java | 9
modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerConfiguration.java | 9
modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java | 77 +-
modules/enterprise/server/installer/src/main/resources/logging.properties | 3
modules/enterprise/server/itests-2/pom.xml | 356 +++++-----
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java | 20
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/test/ResourceStorageTest.java | 101 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java | 13
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentManagerBean.java | 19
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerBean.java | 9
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerLocal.java | 7
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerBean.java | 17
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java | 150 ++--
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 43 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/AlertMetadataManagerBean.java | 26
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/EventHandlerBean.java | 15
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/GroupHandlerBean.java | 24
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/OperationsHandlerBean.java | 13
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ResourceHandlerBean.java | 2
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/augeas/AugeasReferenceLeakingTest.java | 33
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestSetup.java | 88 +-
modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java | 115 +--
modules/integration-tests/jndi-access/jndi-access-test/pom.xml | 10
modules/plugins/jmx/src/test/java/org/rhq/plugins/jmx/test/JMXPluginTest.java | 10
31 files changed, 763 insertions(+), 612 deletions(-)
New commits:
commit b22eeffcdaf0f5f37033705bd697faa0327d5076
Author: Simeon Pinder <spinder(a)fulliautomatix.conchfritter.com>
Date: Mon Feb 18 06:05:15 2013 -0500
Removing earlier paging/CriteriaQuery changes as REST will be handling this differently.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/GroupHandlerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/GroupHandlerBean.java
index 6b4c4ba..032bf97 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/GroupHandlerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/GroupHandlerBean.java
@@ -83,8 +83,6 @@ import org.rhq.enterprise.server.rest.domain.GroupRest;
import org.rhq.enterprise.server.rest.domain.Link;
import org.rhq.enterprise.server.rest.domain.MetricSchedule;
import org.rhq.enterprise.server.rest.domain.ResourceWithType;
-import org.rhq.enterprise.server.util.CriteriaQuery;
-import org.rhq.enterprise.server.util.CriteriaQueryExecutor;
/**
* Deal with group related things.
@@ -124,16 +122,7 @@ public class GroupHandlerBean extends AbstractRestBean {
criteria.addFilterName(q);
}
- //Use CriteriaQuery to automatically chunk/page through criteria query results
- CriteriaQueryExecutor<ResourceGroup, ResourceGroupCriteria> queryExecutor = new CriteriaQueryExecutor<ResourceGroup, ResourceGroupCriteria>() {
- @Override
- public PageList<ResourceGroup> execute(ResourceGroupCriteria criteria) {
- return resourceGroupManager.findResourceGroupsByCriteria(caller, criteria);
- }
- };
-
- CriteriaQuery<ResourceGroup, ResourceGroupCriteria> groups = new CriteriaQuery<ResourceGroup, ResourceGroupCriteria>(
- criteria, queryExecutor);
+ PageList<ResourceGroup> groups = resourceGroupManager.findResourceGroupsByCriteria(caller, criteria);
List<GroupRest> list = new ArrayList<GroupRest>();
for (ResourceGroup group : groups) {
@@ -415,16 +404,7 @@ public class GroupHandlerBean extends AbstractRestBean {
criteria.addFilterName(q);
}
- //Use CriteriaQuery to automatically chunk/page through criteria query results
- CriteriaQueryExecutor<GroupDefinition, ResourceGroupDefinitionCriteria> queryExecutor = new CriteriaQueryExecutor<GroupDefinition, ResourceGroupDefinitionCriteria>() {
- @Override
- public PageList<GroupDefinition> execute(ResourceGroupDefinitionCriteria criteria) {
- return definitionManager.findGroupDefinitionsByCriteria(caller, criteria);
- }
- };
-
- CriteriaQuery<GroupDefinition, ResourceGroupDefinitionCriteria> gdlist = new CriteriaQuery<GroupDefinition, ResourceGroupDefinitionCriteria>(
- criteria, queryExecutor);
+ PageList<GroupDefinition> gdlist = definitionManager.findGroupDefinitionsByCriteria(caller, criteria);
List<GroupDefinitionRest> list = new ArrayList<GroupDefinitionRest>();
for (GroupDefinition def: gdlist) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/OperationsHandlerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/OperationsHandlerBean.java
index 2e8f99c..a94b81c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/OperationsHandlerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/OperationsHandlerBean.java
@@ -76,8 +76,6 @@ import org.rhq.enterprise.server.rest.domain.OperationDefinitionRest;
import org.rhq.enterprise.server.rest.domain.OperationHistoryRest;
import org.rhq.enterprise.server.rest.domain.OperationRest;
import org.rhq.enterprise.server.rest.domain.SimplePropDef;
-import org.rhq.enterprise.server.util.CriteriaQuery;
-import org.rhq.enterprise.server.util.CriteriaQueryExecutor;
/**
* Deal with operations
@@ -390,16 +388,7 @@ public class OperationsHandlerBean extends AbstractRestBean {
criteria.addSortEndTime(PageOrdering.DESC);
- //Use CriteriaQuery to automatically chunk/page through criteria query results
- CriteriaQueryExecutor<ResourceOperationHistory, ResourceOperationHistoryCriteria> queryExecutor = new CriteriaQueryExecutor<ResourceOperationHistory, ResourceOperationHistoryCriteria>() {
- @Override
- public PageList<ResourceOperationHistory> execute(ResourceOperationHistoryCriteria criteria) {
- return opsManager.findResourceOperationHistoriesByCriteria(caller, criteria);
- }
- };
-
- CriteriaQuery<ResourceOperationHistory, ResourceOperationHistoryCriteria> list = new CriteriaQuery<ResourceOperationHistory, ResourceOperationHistoryCriteria>(
- criteria, queryExecutor);
+ PageList<ResourceOperationHistory> list = opsManager.findResourceOperationHistoriesByCriteria(caller, criteria);
List<OperationHistoryRest> result = new ArrayList<OperationHistoryRest>();
for (ResourceOperationHistory roh : list) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ResourceHandlerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ResourceHandlerBean.java
index b748833..f518952 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ResourceHandlerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ResourceHandlerBean.java
@@ -329,7 +329,6 @@ public class ResourceHandlerBean extends AbstractRestBean {
criteria.addFilterInterval(start,end);
criteria.addFilterResourceId(resourceId);
criteria.addSortStartTime(PageOrdering.DESC);
- criteria.clearPaging();//disable paging as the code assumes all the results will be returned.
List<Availability> points = availMgr.findAvailabilityByCriteria(caller,criteria);
List<AvailabilityRest> ret = new ArrayList<AvailabilityRest>(points.size());
@@ -524,7 +523,6 @@ public class ResourceHandlerBean extends AbstractRestBean {
public List<Link> getAlertsForResource(@ApiParam("Id of the resource to query") @PathParam("id") int resourceId) {
AlertCriteria criteria = new AlertCriteria();
criteria.addFilterResourceIds(resourceId);
- criteria.clearPaging();//disable paging as the code assumes all the results will be returned.
List<Alert> alerts = alertManager.findAlertsByCriteria(caller, criteria);
List<Link> links = new ArrayList<Link>(alerts.size());
commit 9ba9f80aaa95d4f5ee3e209d26315d1cb70e12b8
Author: Simeon Pinder <spinder(a)fulliautomatix.conchfritter.com>
Date: Mon Feb 18 05:43:55 2013 -0500
Remove any paging changes as REST will handle paging differently.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/EventHandlerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/EventHandlerBean.java
index e550bd2..becb680 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/EventHandlerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/EventHandlerBean.java
@@ -61,14 +61,11 @@ import org.rhq.core.domain.event.EventSource;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageControl;
-import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.event.EventManagerLocal;
import org.rhq.enterprise.server.rest.domain.EventDefinitionRest;
import org.rhq.enterprise.server.rest.domain.EventRest;
import org.rhq.enterprise.server.rest.domain.EventSourceRest;
-import org.rhq.enterprise.server.util.CriteriaQuery;
-import org.rhq.enterprise.server.util.CriteriaQueryExecutor;
/**
* Handle event related things
@@ -308,16 +305,8 @@ public class EventHandlerBean extends AbstractRestBean {
private Response.ResponseBuilder getEventsAsBuilderForCriteria(HttpHeaders headers, EventCriteria criteria) {
- //Use CriteriaQuery to automatically chunk/page through criteria query results
- CriteriaQueryExecutor<Event, EventCriteria> queryExecutor = new CriteriaQueryExecutor<Event, EventCriteria>() {
- @Override
- public PageList<Event> execute(EventCriteria criteria) {
- return eventManager.findEventsByCriteria(caller, criteria);
- }
- };
-
- CriteriaQuery<Event, EventCriteria> eventList = new CriteriaQuery<Event, EventCriteria>(criteria, queryExecutor);
- List<EventRest> restEvents = new ArrayList<EventRest>();
+ List<Event> eventList = eventManager.findEventsByCriteria(caller, criteria);
+ List<EventRest> restEvents = new ArrayList<EventRest>(eventList.size());
for (Event event : eventList) {
restEvents.add(convertEvent(event));
}
commit 2cb4c49448eeb7730ba064a2692929ddc45aa9c1
Author: Simeon Pinder <spinder(a)fulliautomatix.conchfritter.com>
Date: Mon Feb 18 05:37:31 2013 -0500
Commenting out unused code. No need to execute the query if we don't process the results.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
index 6521730..a1ff092 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
@@ -83,7 +83,6 @@ import org.rhq.core.domain.criteria.GroupResourceConfigurationUpdateCriteria;
import org.rhq.core.domain.criteria.PluginConfigurationUpdateCriteria;
import org.rhq.core.domain.criteria.ResourceConfigurationUpdateCriteria;
import org.rhq.core.domain.criteria.ResourceCriteria;
-import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceError;
@@ -2625,12 +2624,12 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf
}
}
} else if (tt == PropertyOptionsSource.TargetType.GROUP) {
- // for groups we need to talk to the group manager
- ResourceGroupCriteria criteria = new ResourceGroupCriteria();
- criteria.setSearchExpression(expression);
-
- //?? spinder 2-12-13: We don't do anything with the composite results here?
- resourceGroupManager.findResourceGroupCompositesByCriteria(subject, criteria);
+ // spinder 2-15-13: commenting out this code below as we don't appear to be using any of it. Half done.
+ // // for groups we need to talk to the group manager
+ // ResourceGroupCriteria criteria = new ResourceGroupCriteria();
+ // criteria.setSearchExpression(expression);
+ //
+ // resourceGroupManager.findResourceGroupCompositesByCriteria(subject, criteria);
}
// TODO plugin and resourceType
}
commit bacb200a03eb9ac474a61bf10c9121fd56e4e13e
Author: Simeon Pinder <spinder(a)fulliautomatix.conchfritter.com>
Date: Mon Feb 18 05:32:12 2013 -0500
Removing criteriaQuery usage here as paging needs to be handled by caller instead.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerBean.java
index 239cf35..5d149a1 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerBean.java
@@ -82,8 +82,6 @@ import org.rhq.enterprise.server.agentclient.AgentClient;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.core.AgentManagerLocal;
import org.rhq.enterprise.server.plugin.pc.drift.DriftChangeSetSummary;
-import org.rhq.enterprise.server.util.CriteriaQuery;
-import org.rhq.enterprise.server.util.CriteriaQueryExecutor;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
import org.rhq.enterprise.server.util.CriteriaQueryRunner;
@@ -180,24 +178,13 @@ public class JPADriftServerBean implements JPADriftServerLocal {
}
@Override
- public PageList<DriftComposite> findDriftCompositesByCriteria(final Subject subject, DriftCriteria criteria) {
+ public PageList<DriftComposite> findDriftCompositesByCriteria(Subject subject, DriftCriteria criteria) {
JPADriftCriteria jpaCriteria = (criteria instanceof JPADriftCriteria) ? (JPADriftCriteria) criteria
: new JPADriftCriteria(criteria);
jpaCriteria.fetchChangeSet(true);
-
- //Use CriteriaQuery to automatically chunk/page through criteria query results
- CriteriaQueryExecutor<JPADrift, JPADriftCriteria> queryExecutor = new CriteriaQueryExecutor<JPADrift, JPADriftCriteria>() {
- @Override
- public PageList<JPADrift> execute(JPADriftCriteria jpaCriteria) {
- return findDriftsByCriteria(subject, jpaCriteria);
- }
- };
-
- CriteriaQuery<JPADrift, JPADriftCriteria> drifts = new CriteriaQuery<JPADrift, JPADriftCriteria>(jpaCriteria,
- queryExecutor);
-
+ PageList<JPADrift> drifts = findDriftsByCriteria(subject, jpaCriteria);
PageList<DriftComposite> result = new PageList<DriftComposite>();
for (JPADrift drift : drifts) {
JPADriftChangeSet changeSet = drift.getChangeSet();
commit 835f4a546bfdd626c9519e3a4c2b9245e2cfee1a
Author: Simeon Pinder <spinder(a)fulliautomatix.conchfritter.com>
Date: Mon Feb 18 05:25:30 2013 -0500
Remove this occurrence of CriteriaQuery usage.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentManagerBean.java
index 68af1e7..f749c9c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentManagerBean.java
@@ -111,8 +111,6 @@ import org.rhq.enterprise.server.plugin.pc.content.PackageTypeBehavior;
import org.rhq.enterprise.server.resource.ResourceManagerLocal;
import org.rhq.enterprise.server.resource.ResourceTypeManagerLocal;
import org.rhq.enterprise.server.resource.ResourceTypeNotFoundException;
-import org.rhq.enterprise.server.util.CriteriaQuery;
-import org.rhq.enterprise.server.util.CriteriaQueryExecutor;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
import org.rhq.enterprise.server.util.CriteriaQueryRunner;
@@ -1595,26 +1593,17 @@ public class ContentManagerBean implements ContentManagerLocal, ContentManagerRe
return runner.execute();
}
- public PageList<PackageAndLatestVersionComposite> findPackagesWithLatestVersion(final Subject subject,
+ public PageList<PackageAndLatestVersionComposite> findPackagesWithLatestVersion(Subject subject,
PackageCriteria criteria) {
if (criteria.getFilterRepoId() == null) {
throw new IllegalArgumentException("The criteria query has to have a filter for a specific repo.");
}
criteria.fetchVersions(true);
+ PageList<Package> packages = findPackagesByCriteria(subject, criteria);
- //Use CriteriaQuery to automatically chunk/page through criteria query results
- CriteriaQueryExecutor<Package, PackageCriteria> queryExecutor = new CriteriaQueryExecutor<Package, PackageCriteria>() {
- @Override
- public PageList<Package> execute(PackageCriteria criteria) {
- return findPackagesByCriteria(subject, criteria);
- }
- };
-
- CriteriaQuery<Package, PackageCriteria> packages = new CriteriaQuery<Package, PackageCriteria>(criteria,
- queryExecutor);
-
- PageList<PackageAndLatestVersionComposite> ret = new PageList<PackageAndLatestVersionComposite>();
+ PageList<PackageAndLatestVersionComposite> ret = new PageList<PackageAndLatestVersionComposite>(
+ packages.getTotalSize(), packages.getPageControl());
for(Package p : packages) {
PackageVersion latest = repoManager.getLatestPackageVersion(subject, p.getId(), criteria.getFilterRepoId());
commit f7146a6313337bfe23b9e0a52edb817b5df4e222
Author: Simeon Pinder <spinder(a)fulliautomatix.conchfritter.com>
Date: Mon Feb 18 05:17:00 2013 -0500
Revert to just use clearPaging as CriteriaQuery usage not needed.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/AlertMetadataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/AlertMetadataManagerBean.java
index 711a653..a52c4c2 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/AlertMetadataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/AlertMetadataManagerBean.java
@@ -1,6 +1,6 @@
package org.rhq.enterprise.server.resource.metadata;
-import java.util.ArrayList;
+import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
@@ -12,11 +12,8 @@ import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.alert.AlertDefinitionManagerLocal;
import org.rhq.enterprise.server.alert.AlertTemplateManagerLocal;
-import org.rhq.enterprise.server.util.CriteriaQuery;
-import org.rhq.enterprise.server.util.CriteriaQueryExecutor;
@Stateless
public class AlertMetadataManagerBean implements AlertMetadataManagerLocal {
@@ -30,32 +27,21 @@ public class AlertMetadataManagerBean implements AlertMetadataManagerLocal {
private AlertTemplateManagerLocal alertTemplateMgr;
@Override
- public void deleteAlertTemplates(final Subject subject, ResourceType resourceType) {
+ public void deleteAlertTemplates(Subject subject, ResourceType resourceType) {
log.debug("Deleting alert templates for " + resourceType);
AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
criteria.addFilterAlertTemplateResourceTypeId(resourceType.getId());
+ criteria.clearPaging();//disable paging as the code assumes all the results will be returned.
- //Use CriteriaQuery to automatically chunk/page through criteria query results
- CriteriaQueryExecutor<AlertDefinition, AlertDefinitionCriteria> queryExecutor = new CriteriaQueryExecutor<AlertDefinition, AlertDefinitionCriteria>() {
- @Override
- public PageList<AlertDefinition> execute(AlertDefinitionCriteria criteria) {
- return alertDefinitionMgr.findAlertDefinitionsByCriteria(subject, criteria);
- }
- };
+ List<AlertDefinition> templates = alertDefinitionMgr.findAlertDefinitionsByCriteria(subject, criteria);
- CriteriaQuery<AlertDefinition, AlertDefinitionCriteria> templates = new CriteriaQuery<AlertDefinition, AlertDefinitionCriteria>(
- criteria, queryExecutor);
-
- ArrayList<Integer> templateIdList = new ArrayList<Integer>();
+ Integer[] templateIds = new Integer[templates.size()];
int i = 0;
for (AlertDefinition template : templates) {
- templateIdList.add(template.getId());
+ templateIds[i++] = template.getId();
}
- Integer[] templateIds = new Integer[templateIdList.size()];
- templateIds = templateIdList.toArray(templateIds);
-
// Alert definitions associated with individual resources and with groups
// are deleted as part of resource deletion. This commit adds support for
// templates which are alert definitions associated with the resource
commit 3f33214af914fb3411f0d297020347f275cfc95b
Author: Simeon Pinder <spinder(a)fulliautomatix.conchfritter.com>
Date: Mon Feb 18 05:10:37 2013 -0500
Revert to only clearpaging updates here as CriteriaQuery usage is unnecessary.
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientProxy.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientProxy.java
index 773176b..9b20aef 100644
--- a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientProxy.java
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/ResourceClientProxy.java
@@ -74,8 +74,6 @@ import org.rhq.enterprise.server.measurement.MeasurementDefinitionManagerRemote;
import org.rhq.enterprise.server.operation.OperationManagerRemote;
import org.rhq.enterprise.server.resource.ResourceManagerRemote;
import org.rhq.enterprise.server.resource.ResourceTypeNotFoundException;
-import org.rhq.enterprise.server.util.CriteriaQuery;
-import org.rhq.enterprise.server.util.CriteriaQueryExecutor;
/**
* Implements a local object that exposes resource related data as
@@ -237,18 +235,9 @@ public class ResourceClientProxy {
private void initChildren() {
ResourceCriteria criteria = new ResourceCriteria();
criteria.addFilterParentResourceId(resourceId);
-
- //Use CriteriaQuery to automatically chunk/page through criteria query results
- CriteriaQueryExecutor<Resource, ResourceCriteria> queryExecutor = new CriteriaQueryExecutor<Resource, ResourceCriteria>() {
- @Override
- public PageList<Resource> execute(ResourceCriteria criteria) {
- return remoteClient.getProxy(ResourceManagerRemote.class).findResourcesByCriteria(
- remoteClient.getSubject(), criteria);
- }
- };
-
- CriteriaQuery<Resource, ResourceCriteria> childResources = new CriteriaQuery<Resource, ResourceCriteria>(
- criteria, queryExecutor);
+ criteria.clearPaging();//disable paging as the code assumes all the results will be returned.
+ PageList<Resource> childResources = remoteClient.getProxy(ResourceManagerRemote.class).findResourcesByCriteria(
+ remoteClient.getSubject(), criteria);
for (Resource child : childResources) {
this.children.add(proxyFactory.getResource(child.getId()));
@@ -258,26 +247,14 @@ public class ResourceClientProxy {
private void initMeasurements() {
MeasurementDefinitionCriteria criteria = new MeasurementDefinitionCriteria();
criteria.addFilterResourceTypeId(resource.getResourceType().getId());
- // criteria.addFilterResourceTypeName(resource.getResourceType().getName());
- // criteria.setStrict(true);
-
- //Use CriteriaQuery to automatically chunk/page through criteria query results
- CriteriaQueryExecutor<MeasurementDefinition, MeasurementDefinitionCriteria> queryExecutor = new CriteriaQueryExecutor<MeasurementDefinition, MeasurementDefinitionCriteria>() {
- @Override
- public PageList<MeasurementDefinition> execute(MeasurementDefinitionCriteria criteria) {
- return remoteClient.getProxy(MeasurementDefinitionManagerRemote.class)
- .findMeasurementDefinitionsByCriteria(remoteClient.getSubject(), criteria);
- }
- };
-
- CriteriaQuery<MeasurementDefinition, MeasurementDefinitionCriteria> measurementDefIterator = new CriteriaQuery<MeasurementDefinition, MeasurementDefinitionCriteria>(
- criteria, queryExecutor);
+ // criteria.addFilterResourceTypeName(resource.getResourceType().getName());
+ // criteria.setStrict(true);
- this.measurementDefinitions = new PageList<MeasurementDefinition>();
+ this.measurementDefinitions = remoteClient.getProxy(MeasurementDefinitionManagerRemote.class)
+ .findMeasurementDefinitionsByCriteria(remoteClient.getSubject(), criteria);
this.measurementMap = new HashMap<String, Measurement>();
- for (MeasurementDefinition def : measurementDefIterator) {
- this.measurementDefinitions.add(def);
+ for (MeasurementDefinition def : measurementDefinitions) {
Measurement m = new Measurement(def);
String name = def.getDisplayName().replaceAll("\\W", "");
commit 8d55baaac5f93f222dd14383884fe8538d752cc5
Author: Simeon Pinder <spinder(a)fulliautomatix.conchfritter.com>
Date: Mon Feb 18 04:52:36 2013 -0500
Remove CriteriaQuery usage as unnecessary here.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index e005121..13baa3c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -126,8 +126,6 @@ import org.rhq.enterprise.server.resource.disambiguation.DisambiguationUpdateStr
import org.rhq.enterprise.server.resource.disambiguation.Disambiguator;
import org.rhq.enterprise.server.resource.group.ResourceGroupDeleteException;
import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal;
-import org.rhq.enterprise.server.util.CriteriaQuery;
-import org.rhq.enterprise.server.util.CriteriaQueryExecutor;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
import org.rhq.enterprise.server.util.CriteriaQueryRunner;
import org.rhq.enterprise.server.util.QueryUtility;
@@ -882,7 +880,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
return resourceLineage;
}
- public Map<Integer, String> getResourcesAncestry(final Subject subject, Integer[] resourceIds,
+ public Map<Integer, String> getResourcesAncestry(Subject subject, Integer[] resourceIds,
ResourceAncestryFormat format) {
Map<Integer, String> result = new HashMap<Integer, String>(resourceIds.length);
@@ -890,20 +888,10 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
return result;
}
- final ResourceCriteria resourceCriteria = new ResourceCriteria();
+ ResourceCriteria resourceCriteria = new ResourceCriteria();
resourceCriteria.addFilterIds(resourceIds);
resourceCriteria.fetchResourceType(true);
-
- //Use CriteriaQuery to automatically chunk/page through criteria query results
- CriteriaQueryExecutor<Resource, ResourceCriteria> queryExecutor = new CriteriaQueryExecutor<Resource, ResourceCriteria>() {
- @Override
- public PageList<Resource> execute(ResourceCriteria criteria) {
- return findResourcesByCriteria(subject, resourceCriteria);
- }
- };
-
- CriteriaQuery<Resource, ResourceCriteria> resources = new CriteriaQuery<Resource, ResourceCriteria>(
- resourceCriteria, queryExecutor);
+ List<Resource> resources = findResourcesByCriteria(subject, resourceCriteria);
if (ResourceAncestryFormat.RAW == format) {
for (Resource resource : resources) {
@@ -925,36 +913,17 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
// In addition to the types of the result resources, get the types of their ancestry
typesSet.addAll(getAncestryTypeIds(ancestries));
- final ResourceTypeCriteria resourceTypeCriteria = new ResourceTypeCriteria();
+ ResourceTypeCriteria resourceTypeCriteria = new ResourceTypeCriteria();
resourceTypeCriteria.addFilterIds(typesSet.toArray(new Integer[typesSet.size()]));
-
- //Use CriteriaQuery to automatically chunk/page through criteria query results
- CriteriaQueryExecutor<ResourceType, ResourceTypeCriteria> rtQueryExecutor =
- new CriteriaQueryExecutor<ResourceType, ResourceTypeCriteria>() {
- @Override
- public PageList<ResourceType> execute(ResourceTypeCriteria criteria) {
- return typeManager.findResourceTypesByCriteria(subject, resourceTypeCriteria);
- }
- };
-
- CriteriaQuery<ResourceType, ResourceTypeCriteria> types =
- new CriteriaQuery<ResourceType, ResourceTypeCriteria>(resourceTypeCriteria, rtQueryExecutor);
+ List<ResourceType> types = typeManager.findResourceTypesByCriteria(subject, resourceTypeCriteria);
for (Resource resource : resources) {
- String decodedAncestry = getDecodedAncestry(resource, loadAsList(types.iterator()), format);
+ String decodedAncestry = getDecodedAncestry(resource, types, format);
result.put(resource.getId(), decodedAncestry);
}
return result;
}
- private List<ResourceType> loadAsList(Iterator<ResourceType> iterator) {
- PageList<ResourceType> list = new PageList<ResourceType>();
- while(iterator.hasNext()){
- list.add(iterator.next());
- }
- return list;
- }
-
/**
* Get the complete set of resource type Ids in the ancestries provided. This is useful for
* being able to load all the types in advance of generating decoded values.
commit 1d2618a3e388ad46f390732bc5101fef67c94e8c
Merge: db38ce2 f7409c5
Author: Simeon Pinder <spinder(a)fulliautomatix.conchfritter.com>
Date: Sun Feb 17 22:19:02 2013 -0500
Merge branch 'track_master' into spinder/criteriaUsage
Conflicts:
modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java
commit db38ce2e7137d4507194ee296fbc51358b6719ed
Author: Simeon Pinder <spinder(a)fulliautomatix.conchfritter.com>
Date: Sun Feb 17 22:10:41 2013 -0500
Add test to exercise CriteriaQuery iteration for large result sets.
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/test/ResourceStorageTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/test/ResourceStorageTest.java
index d748109..6b93f7a 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/test/ResourceStorageTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/test/ResourceStorageTest.java
@@ -18,9 +18,13 @@
*/
package org.rhq.enterprise.server.resource.test;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Random;
+import javax.persistence.EntityManager;
import javax.persistence.Query;
import org.apache.commons.logging.Log;
@@ -28,11 +32,15 @@ import org.apache.commons.logging.LogFactory;
import org.testng.annotations.Test;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.domain.authz.Role;
+import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.core.domain.resource.group.GroupCategory;
+import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
import org.rhq.core.domain.util.OrderingField;
import org.rhq.core.domain.util.PageControl;
@@ -44,7 +52,10 @@ import org.rhq.enterprise.server.discovery.DiscoveryBossLocal;
import org.rhq.enterprise.server.resource.ResourceManagerLocal;
import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
+import org.rhq.enterprise.server.util.CriteriaQuery;
+import org.rhq.enterprise.server.util.CriteriaQueryExecutor;
import org.rhq.enterprise.server.util.LookupUtil;
+import org.rhq.enterprise.server.util.SessionTestHelper;
public class ResourceStorageTest extends AbstractEJB3Test {
private Log log = LogFactory.getLog(ResourceStorageTest.class);
@@ -208,4 +219,94 @@ public class ResourceStorageTest extends AbstractEJB3Test {
Subject rhqadmin = subjectManager.loginUnauthenticated("rhqadmin");
System.out.println(rhqadmin);
}
+
+ /** Test creates a large number of resources and pages through them using CriteriaQuery.
+ * NOTE: CriteriaQuery uses PageList instances underneath and are susceptible to dirty
+ * read issues if the total number of resources being parsed is i)very large or ii)processing
+ * each instance takes a significant amount of time. Ex. Begin parsing all resource types,
+ * while plugin update is removing some of those same types.
+ *
+ * @throws Exception
+ */
+ @SuppressWarnings("unused")
+ @Test(groups = "integration.ejb3")
+ public void testParsingCriteriaQueryResults() throws Exception {
+ getTransactionManager().begin();
+ EntityManager entityMgr = getEntityManager();
+ final ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
+
+ //verify that all resource objects are actually parsed.
+ Map<String, Object> resourceNames = new HashMap<String, Object>();
+
+ ArrayList<Resource> allResources = new ArrayList<Resource>();
+
+ int resourceCount = 700; //assuming 200 per page at least 4 pages of results.
+
+ try {
+ final Subject subject = SessionTestHelper.createNewSubject(entityMgr, "testSubject");
+
+ Role roleWithSubject = SessionTestHelper.createNewRoleForSubject(entityMgr, subject, "role with subject");
+ roleWithSubject.addPermission(Permission.VIEW_RESOURCE);
+
+ ResourceGroup group = SessionTestHelper.createNewCompatibleGroupForRole(entityMgr, roleWithSubject,
+ "accessible group");
+
+ String tuid = "" + new Random().nextInt();
+ //create large number of resources
+ String prefix = "largeResultSet-" + tuid + "-";
+ System.out.println("-------- Creating " + resourceCount
+ + " resource(s). This may take a while ....");
+
+ long start = System.currentTimeMillis();
+ for (int i = 0; i < resourceCount; i++) {
+ String name = prefix + i;
+ Resource r = SessionTestHelper.createNewResourceForGroup(entityMgr, group, name);
+ //store away each resource name/key
+ resourceNames.put(String.valueOf(r.getId()), name);
+ }
+ entityMgr.flush();
+
+ System.out.println("----------- Created " + resourceCount + " resource(s) in "
+ + (System.currentTimeMillis() - start)
+ + " ms.");
+
+ assert resourceNames.size() == resourceCount;//assert all resources loaded/created
+
+ //query the results and delete the resources
+ ResourceCriteria criteria = new ResourceCriteria();
+ criteria.addFilterName(prefix);
+ criteria.setPaging(0, 47);
+ // PageList<Resource> resources = resourceManager.findResourcesByCriteria(subject, criteria);
+
+ //iterate over the results with CriteriaQuery
+ CriteriaQueryExecutor<Resource, ResourceCriteria> queryExecutor = new CriteriaQueryExecutor<Resource, ResourceCriteria>() {
+ @Override
+ public PageList<Resource> execute(ResourceCriteria criteria) {
+ return resourceManager.findResourcesByCriteria(subject, criteria);
+ }
+ };
+
+ //initiate first/(total depending on page size) request.
+ CriteriaQuery<Resource, ResourceCriteria> resources = new CriteriaQuery<Resource, ResourceCriteria>(
+ criteria, queryExecutor);
+
+ start = System.currentTimeMillis();
+ //iterate over the entire result set efficiently
+ for (Resource r : resources) {
+ allResources.add(r);
+ resourceNames.remove(String.valueOf(r.getId()));
+ }
+
+ System.out.println("----------- Parsed " + resourceCount + " resource(s) in "
+ + (System.currentTimeMillis() - start)
+ + " ms.");
+
+ //test that entire list parsed spanning multiple pages
+ assert resourceNames.size() == 0 : "Expected resourceNames to be empty. Still " + resourceNames.size()
+ + " name(s).";
+
+ } finally {
+ getTransactionManager().rollback();
+ }
+ }
}
\ No newline at end of file
commit 42593fc93ee5fffe4c270b60fedcce0101a25e66
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Thu Feb 14 18:23:36 2013 +0100
Fix JMX plugin test failure
diff --git a/modules/plugins/jmx/src/test/java/org/rhq/plugins/jmx/test/JMXPluginTest.java b/modules/plugins/jmx/src/test/java/org/rhq/plugins/jmx/test/JMXPluginTest.java
index b841a38..9757c7a 100644
--- a/modules/plugins/jmx/src/test/java/org/rhq/plugins/jmx/test/JMXPluginTest.java
+++ b/modules/plugins/jmx/src/test/java/org/rhq/plugins/jmx/test/JMXPluginTest.java
@@ -72,8 +72,6 @@ import org.rhq.plugins.jmx.util.JvmResourceKey;
* @author Greg Hinkle
* @author Ian Springer
*/
-// Disabled until we find a fix for Sigar getProcCredName issue
-@Test(enabled = false)
public class JMXPluginTest {
private static final int JMX_REMOTING_PORT1 = 9921;
@@ -95,8 +93,9 @@ public class JMXPluginTest {
this.testServerJvms.add(startTestServerJvm("-Dcom.sun.management.jmxremote.port=" + JMX_REMOTING_PORT1,
"-Dcom.sun.management.jmxremote.ssl=false", "-Dcom.sun.management.jmxremote.authenticate=false"));
- this.testServerJvms.add(startTestServerJvm("-D" + JMXDiscoveryComponent.SYSPROP_RHQ_RESOURCE_KEY + "="
- + EXPLICIT_RESOURCE_KEY1));
+ // FIXME: Disabled until we find a fix for Sigar getProcCredName issue
+ // this.testServerJvms.add(startTestServerJvm("-D" + JMXDiscoveryComponent.SYSPROP_RHQ_RESOURCE_KEY + "="
+ // + EXPLICIT_RESOURCE_KEY1));
this.testServerJvms.add(startTestServerJvm("-Dcom.sun.management.jmxremote.port=" + JMX_REMOTING_PORT2,
"-Dcom.sun.management.jmxremote.ssl=false", "-Dcom.sun.management.jmxremote.authenticate=false",
@@ -206,7 +205,8 @@ public class JMXPluginTest {
}
}
assert foundJmxRemotingServer : "JMX Remoting server not found.";
- assert foundExplicitKey1Server : "Explicit key server not found.";
+ // FIXME: Disabled until we find a fix for Sigar getProcCredName issue
+ //assert foundExplicitKey1Server : "Explicit key server not found.";
assert foundExplicitKey2Server : "JMX Remoting + explicit key server not found.";
}
commit e7311690dd0c28a9d75b6b7a481291bcd13634db
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Feb 13 20:09:02 2013 +0100
Fix the expectations of the JMock-based apache plugin integration tests
after the fixes in the inventory report processing that changed the workflow
slightly.
This should make the apache integration tests pass again.
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 a7f6697..37d8433 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
@@ -117,7 +117,7 @@ public class FakeServerInventory {
InventoryReport inventoryReport = (InventoryReport) invocation.getParameter(0);
for (Resource res : inventoryReport.getAddedRoots()) {
- Resource persisted = fakePersist(res, judge, new HashSet<String>());
+ Resource persisted = fakePersist(res, requiredInventoryStatus, new HashSet<String>());
if (res.getParentResource() == Resource.ROOT) {
platform = persisted;
@@ -333,7 +333,7 @@ public class FakeServerInventory {
}
}
- private Resource fakePersist(Resource agentSideResource, InventoryStatusJudge statusJudge,
+ private Resource fakePersist(Resource agentSideResource, InventoryStatus requiredInventoryStatus,
Set<String> inProgressUUIds) {
Resource persisted = resourceStore.get(agentSideResource.getUuid());
if (!inProgressUUIds.add(agentSideResource.getUuid())) {
commit 5c5706794ad060158ca832fcbd876dedb811d716
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Thu Feb 14 15:28:02 2013 +0100
[BZ 909157 - Operation parameters are not shown in schedule operation details.] If the method refreshOperationParametersItem() is called when scheduling a new operation, the existent parameters are not forget.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
index 0f54af0..8436c2ab 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
@@ -355,7 +355,6 @@ public abstract class AbstractOperationScheduleDetailsView extends
this.operationParameters = (Configuration) record
.getAttributeAsObject(AbstractOperationScheduleDataSource.Field.PARAMETERS);
-
super.editExistingRecord(record);
}
@@ -426,11 +425,14 @@ public abstract class AbstractOperationScheduleDetailsView extends
private void refreshOperationParametersItem() {
String operationName = getSelectedOperationName();
String value;
- operationParameters = null; // reset params between dropdown selects
- // make sure we wipe out anything left by the previous op def
- for (Canvas child : this.operationParametersConfigurationHolder.getChildren()) {
- child.destroy();
+ if (isNewRecord()) { // BZ 909157: do it only for new schedule
+ operationParameters = null; // reset params between dropdown selects
+ // make sure we wipe out anything left by the previous op def
+ for (Canvas child : this.operationParametersConfigurationHolder.getChildren()) {
+ child.destroy();
+ }
}
+
if (operationName == null) {
value = "<i>" + MSG.view_operationScheduleDetails_fieldDefault_parameters() + "</i>";
this.operationParametersConfigurationHolder.hide();
@@ -453,8 +455,6 @@ public abstract class AbstractOperationScheduleDetailsView extends
ConfigurationTemplate defaultTemplate = parametersDefinition.getDefaultTemplate();
this.operationParameters = (defaultTemplate != null) ? defaultTemplate.createConfiguration()
: new Configuration();
- } else {
- this.operationParameters = new Configuration();
}
ConfigurationGWTServiceAsync configurationService = GWTServiceLookup.getConfigurationService();
commit 56f8cf4ff1a4ef2c3aa7959d25487e57897778bb
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Feb 14 09:22:47 2013 -0500
installer now provides a "--force" option - this lets you re-run the installer even if you didn't set autoinstall.enabled=true
and it also lets you attempt another installation if a previous one failed in the middle of its prior attempt.
diff --git a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/Installer.java b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/Installer.java
index 48defbc..b8a83fc 100644
--- a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/Installer.java
+++ b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/Installer.java
@@ -157,6 +157,7 @@ public class Installer {
usage.append("\t--host=<hostname>, -h: hostname where the app server is running").append("\n");
usage.append("\t--port=<port>, -p: talk to the app server over this management port").append("\n");
usage.append("\t--test, -t: test the validity of the server properties (install not performed)").append("\n");
+ usage.append("\t--force, -f: force the installer to try to install everything").append("\n");
usage.append("\t--listservers, -l: show list of known installed servers (install not performed)").append("\n");
usage.append("\t--setupdb, -b: only perform database schema creation or update").append("\n");
usage.append("\t--reconfig, -r: resets some configuration settings in an installed server").append("\n");
@@ -166,7 +167,7 @@ public class Installer {
}
private WhatToDo[] processArguments(String[] args) throws Exception {
- String sopts = "-:HD:h:p:d:blrt";
+ String sopts = "-:HD:h:p:d:bflrt";
LongOpt[] lopts = { new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'H'),
new LongOpt("host", LongOpt.REQUIRED_ARGUMENT, null, 'h'),
new LongOpt("port", LongOpt.REQUIRED_ARGUMENT, null, 'p'),
@@ -174,6 +175,7 @@ public class Installer {
new LongOpt("setupdb", LongOpt.NO_ARGUMENT, null, 'b'),
new LongOpt("listservers", LongOpt.NO_ARGUMENT, null, 'l'),
new LongOpt("reconfig", LongOpt.NO_ARGUMENT, null, 'r'),
+ new LongOpt("force", LongOpt.NO_ARGUMENT, null, 'f'),
new LongOpt("test", LongOpt.NO_ARGUMENT, null, 't') };
boolean test = false;
@@ -255,6 +257,11 @@ public class Installer {
break; // don't return, in case we need to allow more args
}
+ case 'f': {
+ this.installerConfig.setForceInstall(true);
+ break; // don't return, in case we need to allow more args
+ }
+
case 'l': {
listservers = true;
break; // don't return, we need to allow more args to be processed, like -p or -h
diff --git a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerConfiguration.java b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerConfiguration.java
index 0852b78..3adecbe 100644
--- a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerConfiguration.java
+++ b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerConfiguration.java
@@ -28,6 +28,7 @@ package org.rhq.enterprise.server.installer;
public class InstallerConfiguration {
private String managementHost = "127.0.0.1";
private int managementPort = 9999; // this is the default AS port
+ private boolean forceInstall = false;
public InstallerConfiguration() {
}
@@ -59,4 +60,12 @@ public class InstallerConfiguration {
}
this.managementPort = port;
}
+
+ public boolean isForceInstall() {
+ return this.forceInstall;
+ }
+
+ public void setForceInstall(boolean flag) {
+ this.forceInstall = flag;
+ }
}
diff --git a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
index 3ece569..e72f133 100644
--- a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
+++ b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
@@ -86,7 +86,7 @@ public class InstallerServiceImpl implements InstallerService {
return;
}
if (allServerDetails.size() == 0) {
- log.info("There are no known servers currently registered");
+ log("There are no known servers currently registered");
return;
}
@@ -108,7 +108,7 @@ public class InstallerServiceImpl implements InstallerService {
info.append(serverDetails.getEndpointSecurePortString());
info.append("\n");
}
- log.info(info.toString());
+ log(info.toString());
return;
}
@@ -136,15 +136,21 @@ public class InstallerServiceImpl implements InstallerService {
ServerDetails detailsFromProps = getServerDetailsFromPropertiesOnly(serverProperties);
ServerDetails detailsFromDb = getServerDetails(dbUrl, dbUsername, clearTextDbPassword,
detailsFromProps.getName());
+ ExistingSchemaOption existingSchemaOption = getAutoinstallExistingSchemaOption(serverProperties);
+
if (detailsFromDb == null) {
- log.info("This will be considered a new server: " + detailsFromProps);
+ log("This will be considered a new server: " + detailsFromProps);
} else {
- log.info("This [" + detailsFromProps + "] will be considered a reinstallation of an existing server ["
- + detailsFromDb + "]");
+ if (existingSchemaOption == ExistingSchemaOption.OVERWRITE) {
+ log("This [" + detailsFromProps + "] will OVERWRITE the existing server [" + detailsFromDb
+ + "] that already exists in the database.");
+ } else {
+ log("This [" + detailsFromProps + "] will be considered a reinstallation of an existing server ["
+ + detailsFromDb + "]");
+ }
}
// just warns if the schema will be overwritten
- ExistingSchemaOption existingSchemaOption = getAutoinstallExistingSchemaOption(serverProperties);
if (existingSchemaOption == ExistingSchemaOption.OVERWRITE) {
log.warn("The installer has been configured to OVERWRITE any existing data in the database. "
+ "If you do install with this configuration, realize that all existing data in the database "
@@ -153,10 +159,10 @@ public class InstallerServiceImpl implements InstallerService {
// just logs the location of the AS instance where RHQ will be installed
String appServerHomeDir = getAppServerHomeDir();
- log.info("The app server where the installation will go is found at: " + appServerHomeDir);
+ log("The app server where the installation will go is found at: " + appServerHomeDir);
// give some message to indicate everything looks OK and the user can start the real install
- log.info("It looks like everything is OK and you can start the installation.");
+ log("It looks like everything is OK and you can start the installation.");
}
@Override
@@ -177,8 +183,12 @@ public class InstallerServiceImpl implements InstallerService {
if (autoInstallMode) {
log("The server is preconfigured and ready for auto-install.");
} else {
- throw new AutoInstallDisabledException(
- "Auto-installation is disabled. Please fully configure rhq-server.properties");
+ if (this.installerConfiguration.isForceInstall()) {
+ log("Auto-installation would have been disabled, but installer was asked to force the install... continuing.");
+ } else {
+ throw new AutoInstallDisabledException(
+ "Auto-installation is disabled. Please fully configure rhq-server.properties");
+ }
}
// make an attempt to connect to the app server - we must make sure its running and we can connect to it
@@ -189,11 +199,21 @@ public class InstallerServiceImpl implements InstallerService {
final String installationResults = getInstallationResults();
if (installationResults != null) {
if (installationResults.length() == 0) {
- throw new AlreadyInstalledException(
- "The installer has already been told to perform its work. The server should be ready soon.");
+ if (this.installerConfiguration.isForceInstall()) {
+ log("The installer appears to have already been told to perform its work, but the installer was asked for force the install... continuing.");
+ } else {
+ throw new AlreadyInstalledException(
+ "The installer has already been told to perform its work. The server should be ready soon.");
+ }
} else {
- throw new Exception("The installer has already attempted to install the server but errors occurred:\n"
- + installationResults);
+ if (this.installerConfiguration.isForceInstall()) {
+ log("The installer is going to force another installation attempt, even though a previous attempt encountered errors:\n"
+ + installationResults);
+ } else {
+ throw new Exception(
+ "The installer has already attempted to install the server but errors occurred:\n"
+ + installationResults);
+ }
}
}
@@ -225,8 +245,12 @@ public class InstallerServiceImpl implements InstallerService {
String existingSchemaOption) throws AutoInstallDisabledException, AlreadyInstalledException, Exception {
if (isEarDeployed()) {
- throw new AlreadyInstalledException(
- "It looks like the installation has already been completed - there is nothing for the installer to do.");
+ if (this.installerConfiguration.isForceInstall()) {
+ log("It looks like the installation has already been completed, but the installer was asked for force the install... continuing.");
+ } else {
+ throw new AlreadyInstalledException(
+ "It looks like the installation has already been completed - there is nothing for the installer to do.");
+ }
}
prepareDatabase(serverProperties, serverDetails, existingSchemaOption);
@@ -930,7 +954,8 @@ public class InstallerServiceImpl implements InstallerService {
// Not only do we want to make sure we can connect, but we also want to wait for the subsystems to initialize.
// Let's wait for one of the subsystems to exist; once we know this is up, the rest are probably ready too.
if (!(new WebJBossASClient(getModelControllerClient()).isWebSubsystem())) {
- throw new IllegalStateException("The server does not appear to be fully started yet");
+ throw new IllegalStateException(
+ "The server does not appear to be fully started yet (the web subsystem did not start)");
}
return retVal;
@@ -1096,8 +1121,13 @@ public class InstallerServiceImpl implements InstallerService {
try {
mcc = getModelControllerClient();
CoreJBossASClient client = new CoreJBossASClient(mcc);
- log("Installing RHQ EAR startup subsystem extension");
- client.addExtension(RHQ_EXTENSION_NAME);
+ boolean isDeployed = client.isExtension(RHQ_EXTENSION_NAME);
+ if (!isDeployed) {
+ log("Installing RHQ EAR startup subsystem extension");
+ client.addExtension(RHQ_EXTENSION_NAME);
+ } else {
+ log("RHQ EAR startup subsystem extension is already deployed");
+ }
} finally {
safeClose(mcc);
}
@@ -1108,8 +1138,13 @@ public class InstallerServiceImpl implements InstallerService {
try {
mcc = getModelControllerClient();
CoreJBossASClient client = new CoreJBossASClient(mcc);
- log("Installing RHQ EAR subsystem");
- client.addSubsystem(RHQ_SUBSYSTEM_NAME);
+ boolean isDeployed = client.isSubsystem(RHQ_SUBSYSTEM_NAME);
+ if (!isDeployed) {
+ log("Installing RHQ EAR subsystem");
+ client.addSubsystem(RHQ_SUBSYSTEM_NAME);
+ } else {
+ log("RHQ EAR subsystem is already deployed");
+ }
} finally {
safeClose(mcc);
}
commit 36316a5917684ae2bfe811c682a553e7b7149772
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Feb 14 15:04:35 2013 +0100
The apache integration tests are now resilient against apache servers running on the target machine out of the test control. These will no longer affect the test results.
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 8bc25ca..a7f6697 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
@@ -59,6 +59,10 @@ import org.rhq.core.domain.resource.ResourceType;
*/
public class FakeServerInventory {
+ public interface InventoryStatusJudge {
+ InventoryStatus judge(Resource resource);
+ }
+
private Resource platform;
private Map<String, Resource> resourceStore = new HashMap<String, Resource>();
private int counter;
@@ -77,6 +81,13 @@ public class FakeServerInventory {
}
};
+ private static final Comparator<Resource> RESOURCE_TYPE_AND_STATUS_COMPARATOR = new Comparator<Resource>() {
+ public int compare(Resource o1, Resource o2) {
+ return o1.getResourceType().equals(o2.getResourceType())
+ && o1.getInventoryStatus() == o2.getInventoryStatus() ? 0 : o1.getId() - o2.getId();
+ }
+ };
+
public FakeServerInventory() {
this(false);
}
@@ -86,14 +97,18 @@ public class FakeServerInventory {
}
public synchronized void prepopulateInventory(Resource platform, Collection<Resource> topLevelServers) {
- this.platform = fakePersist(platform, InventoryStatus.COMMITTED, new HashSet<String>());
+ this.platform = fakePersist(platform, getSimpleJudge(InventoryStatus.COMMITTED), new HashSet<String>());
for (Resource res : topLevelServers) {
res.setParentResource(this.platform);
- fakePersist(res, InventoryStatus.COMMITTED, new HashSet<String>());
+ fakePersist(res, getSimpleJudge(InventoryStatus.COMMITTED), new HashSet<String>());
}
}
public synchronized CustomAction mergeInventoryReport(final InventoryStatus requiredInventoryStatus) {
+ return mergeInventoryReport(getSimpleJudge(requiredInventoryStatus));
+ }
+
+ public synchronized CustomAction mergeInventoryReport(final InventoryStatusJudge judge) {
return new CustomAction("updateServerSideInventory") {
public Object invoke(Invocation invocation) throws Throwable {
synchronized (FakeServerInventory.this) {
@@ -102,7 +117,7 @@ public class FakeServerInventory {
InventoryReport inventoryReport = (InventoryReport) invocation.getParameter(0);
for (Resource res : inventoryReport.getAddedRoots()) {
- Resource persisted = fakePersist(res, requiredInventoryStatus, new HashSet<String>());
+ Resource persisted = fakePersist(res, judge, new HashSet<String>());
if (res.getParentResource() == Resource.ROOT) {
platform = persisted;
@@ -265,6 +280,23 @@ public class FakeServerInventory {
}
@SuppressWarnings("serial")
+ public synchronized Set<Resource> findResourcesByTypeAndStatus(final ResourceType type, final InventoryStatus status) {
+ Set<Resource> result = new HashSet<Resource>();
+ if (platform != null) {
+ findResources(platform, new Resource() {
+ public ResourceType getResourceType() {
+ return type;
+ }
+
+ public InventoryStatus getInventoryStatus() {
+ return status;
+ }
+ }, result, RESOURCE_TYPE_AND_STATUS_COMPARATOR);
+ }
+ return result;
+ }
+
+ @SuppressWarnings("serial")
private Set<Resource> getResources(Set<Integer> resourceIds, boolean includeDescendants) {
//it is important to keep the hierarchical order of the resource in the returned set
//so that plugin container can merge the resources from top to bottom.
@@ -301,7 +333,7 @@ public class FakeServerInventory {
}
}
- private Resource fakePersist(Resource agentSideResource, InventoryStatus requiredInventoryStatus,
+ private Resource fakePersist(Resource agentSideResource, InventoryStatusJudge statusJudge,
Set<String> inProgressUUIds) {
Resource persisted = resourceStore.get(agentSideResource.getUuid());
if (!inProgressUUIds.add(agentSideResource.getUuid())) {
@@ -316,6 +348,7 @@ public class FakeServerInventory {
persisted.setUuid(agentSideResource.getUuid());
resourceStore.put(persisted.getUuid(), persisted);
}
+
persisted.setAgent(agentSideResource.getAgent());
persisted.setCurrentAvailability(agentSideResource.getCurrentAvailability());
persisted.setDescription(agentSideResource.getDescription());
@@ -323,13 +356,15 @@ public class FakeServerInventory {
persisted.setPluginConfiguration(agentSideResource.getPluginConfiguration().clone());
persisted.setResourceConfiguration(agentSideResource.getResourceConfiguration().clone());
persisted.setVersion(agentSideResource.getVersion());
- persisted.setInventoryStatus(requiredInventoryStatus);
persisted.setResourceKey(agentSideResource.getResourceKey());
persisted.setResourceType(agentSideResource.getResourceType());
+ InventoryStatus status = statusJudge.judge(persisted);
+ persisted.setInventoryStatus(status);
+
Resource parent = agentSideResource.getParentResource();
if (parent != null && parent != Resource.ROOT) {
- parent = fakePersist(agentSideResource.getParentResource(), requiredInventoryStatus,
+ parent = fakePersist(agentSideResource.getParentResource(), statusJudge,
inProgressUUIds);
persisted.setParentResource(parent);
parent.getChildResources().add(persisted);
@@ -340,7 +375,7 @@ public class FakeServerInventory {
//persist the children
Set<Resource> childResources = new LinkedHashSet<Resource>();
for (Resource child : agentSideResource.getChildResources()) {
- childResources.add(fakePersist(child, requiredInventoryStatus, inProgressUUIds));
+ childResources.add(fakePersist(child, statusJudge, inProgressUUIds));
}
//now update the list with whatever the persisted resource contained in the past
//i.e. we prefer the current results from the agent but keep the children we used to
@@ -398,6 +433,7 @@ public class FakeServerInventory {
children.add(syncChild);
}
+
getPrivateField(clazz, "childSyncInfos").set(ret, children);
return ret;
@@ -444,4 +480,14 @@ public class FakeServerInventory {
}
}
}
+
+ private InventoryStatusJudge getSimpleJudge(final InventoryStatus requiredStatus) {
+ return new InventoryStatusJudge() {
+
+ @Override
+ public InventoryStatus judge(Resource resource) {
+ return requiredStatus;
+ }
+ };
+ }
}
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/augeas/AugeasReferenceLeakingTest.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/augeas/AugeasReferenceLeakingTest.java
index b1c8a24..85d5f52 100644
--- a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/augeas/AugeasReferenceLeakingTest.java
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/augeas/AugeasReferenceLeakingTest.java
@@ -49,6 +49,7 @@ import org.rhq.core.pc.configuration.ConfigurationManager;
import org.rhq.core.pc.inventory.InventoryManager;
import org.rhq.core.pc.inventory.ResourceContainer;
import org.rhq.core.pc.upgrade.FakeServerInventory;
+import org.rhq.plugins.apache.ApacheServerComponent;
import org.rhq.plugins.apache.PluginLocation;
import org.rhq.plugins.apache.setup.ApacheTestConfiguration;
import org.rhq.plugins.apache.setup.ApacheTestSetup;
@@ -58,7 +59,7 @@ import org.rhq.test.pc.PluginContainerSetup;
import org.rhq.test.pc.PluginContainerTest;
/**
- *
+ *
*
* @author Lukas Krejci
*/
@@ -126,13 +127,13 @@ public class AugeasReferenceLeakingTest extends BMNGRunner {
configureApacheServerToUseAugeas();
PluginContainer pc = PluginContainer.getInstance();
- Resource platform = pc.getInventoryManager().getPlatform();
+ Resource apacheServer = findApacheServerResource().getResource();
for (int i = 0; i < configurationReadingInvocationCount; ++i) {
- checkConfigurationRecursively(platform, pc.getConfigurationManager());
+ checkApacheServerConfigurationRecursively(apacheServer, pc.getConfigurationManager());
Thread.sleep(10000);
}
-
+
//wait a couple of seconds for the loadConfig calls to finish
Thread.sleep(60000);
} finally {
@@ -192,14 +193,14 @@ public class AugeasReferenceLeakingTest extends BMNGRunner {
}
}
- private void checkConfigurationRecursively(Resource resource, ConfigurationManager cm)
+ private void checkApacheServerConfigurationRecursively(Resource resource, ConfigurationManager cm)
throws PluginContainerException {
if (resource.getResourceType().getResourceConfigurationDefinition() != null) {
cm.loadResourceConfiguration(resource.getId());
}
for (Resource child : resource.getChildResources()) {
- checkConfigurationRecursively(child, cm);
+ checkApacheServerConfigurationRecursively(child, cm);
}
}
@@ -208,32 +209,36 @@ public class AugeasReferenceLeakingTest extends BMNGRunner {
InventoryManager im = PluginContainer.getInstance().getInventoryManager();
- ResourceContainer apacheServer = findResource(resourceTypes.findByName("Apache HTTP Server"));
+ ResourceContainer apacheServer = findApacheServerResource();
Configuration config = apacheServer.getResourceContext().getPluginConfiguration();
config.getSimple("augeasEnabled").setValue("yes");
im.updatePluginConfiguration(apacheServer.getResource().getId(), config);
-
+
//and run discovery so that the new resources can go into inventory
-
+
im.executeServiceScanImmediately();
}
- private ResourceContainer findResource(ResourceType resourceType) {
+ private ResourceContainer findApacheServerResource() throws Exception {
InventoryManager im = PluginContainer.getInstance().getInventoryManager();
+ ResourceTypes resourceTypes = new ResourceTypes(PluginLocation.APACHE_PLUGIN);
+ ResourceType apacheServerResourceType = resourceTypes.findByName("Apache HTTP Server");
- return findResource(im, resourceType, im.getPlatform());
+ return findApacheServerResource(im, apacheServerResourceType, im.getPlatform());
}
- private ResourceContainer findResource(InventoryManager im, ResourceType rt, Resource root) {
- if (root.getResourceType().equals(rt)) {
+ private ResourceContainer findApacheServerResource(InventoryManager im, ResourceType rt, Resource root) {
+ if (root.getResourceType().equals(rt)
+ && root.getPluginConfiguration().getSimpleValue(ApacheServerComponent.PLUGIN_CONFIG_PROP_SERVER_ROOT)
+ .equals(setup.getDeploymentConfig().serverRoot)) {
return im.getResourceContainer(root);
}
for (Resource child : root.getChildResources()) {
- ResourceContainer rc = findResource(im, rt, child);
+ ResourceContainer rc = findApacheServerResource(im, rt, child);
if (rc != null) {
return rc;
}
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestSetup.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestSetup.java
index 37e74d9..e0363af 100644
--- a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestSetup.java
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestSetup.java
@@ -41,6 +41,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.ResourceType;
import org.rhq.core.pc.ServerServices;
import org.rhq.core.pc.upgrade.FakeServerInventory;
import org.rhq.core.system.SystemInfoFactory;
@@ -257,9 +258,23 @@ public class ApacheTestSetup {
public void addDefaultExceptations(Expectations expectations) throws Exception {
ServerServices ss = PluginContainerTest.getCurrentPluginContainerConfiguration().getServerServices();
+ //only import the apache servers we actually care about - we can't assume another apache won't be present
+ //on the machine running the test...
+ final ResourceType serverResourceType = apacheResourceTypes.findByName("Apache HTTP Server");
expectations.allowing(ss.getDiscoveryServerService()).mergeInventoryReport(
expectations.with(Expectations.any(InventoryReport.class)));
- expectations.will(fakeInventory.mergeInventoryReport(InventoryStatus.COMMITTED));
+ expectations.will(fakeInventory.mergeInventoryReport(new FakeServerInventory.InventoryStatusJudge() {
+ @Override
+ public InventoryStatus judge(Resource resource) {
+ if (serverResourceType.equals(resource.getResourceType())) {
+ return deploymentConfig.serverRoot.equals(resource.getPluginConfiguration().getSimpleValue(
+ ApacheServerComponent.PLUGIN_CONFIG_PROP_SERVER_ROOT)) ? InventoryStatus.COMMITTED
+ : InventoryStatus.IGNORED;
+ } else {
+ return InventoryStatus.COMMITTED;
+ }
+ }
+ }));
expectations.allowing(ss.getDiscoveryServerService()).upgradeResources(
expectations.with(Expectations.any(Set.class)));
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java
index aebea53..719a3dd 100644
--- a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java
@@ -42,6 +42,7 @@ 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.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceError;
@@ -77,15 +78,15 @@ import org.rhq.test.pc.PluginContainerTest;
public class UpgradeTestBase extends PluginContainerTest {
private static final Log LOG = LogFactory.getLog(UpgradeTestBase.class);
-
+
public enum ResourceKeyFormat {
SNMP, RHQ3, RHQ4
};
-
+
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 ResourceTypes apacheResourceTypes;
protected Resource platform;
@@ -101,15 +102,15 @@ public class UpgradeTestBase extends PluginContainerTest {
apacheResourceTypes);
boolean testFailed = false;
try {
-
+
String[] configFiles = Arrays.copyOf(testConfiguration.apacheConfigurationFiles, testConfiguration.apacheConfigurationFiles.length + 1);
configFiles[testConfiguration.apacheConfigurationFiles.length] = "/snmpd.conf";
-
+
setup.withInventoryFrom(testConfiguration.inventoryFile)
.withPlatformResource(platform).withDefaultExpectations().withDefaultOverrides(testConfiguration.defaultOverrides)
.withApacheSetup().withConfigurationFiles(configFiles)
.withServerRoot(testConfiguration.serverRoot).withExePath(testConfiguration.binPath);
-
+
testConfiguration.beforeTestSetup(setup);
LOG.debug("---------------------------------------------------------- Starting the upgrade test for: "
@@ -117,46 +118,46 @@ public class UpgradeTestBase extends PluginContainerTest {
LOG.debug("Deployment configuration: " + setup.getDeploymentConfig());
setup.setup();
-
+
testConfiguration.beforePluginContainerStart(setup);
-
+
startConfiguredPluginContainer();
-
+
testConfiguration.beforeTests(setup);
-
+
//ok, now we should see the resources upgraded in the fake server inventory.
ResourceType serverResourceType = apacheResourceTypes.findByName("Apache HTTP Server");
ResourceType vhostResourceType = apacheResourceTypes.findByName("Apache Virtual Host");
-
- Set<Resource> servers = setup.getFakeInventory().findResourcesByType(serverResourceType);
+
+ Set<Resource> servers = setup.getFakeInventory().findResourcesByTypeAndStatus(serverResourceType, InventoryStatus.COMMITTED);
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);
-
+
+ Set<Resource> vhosts = setup.getFakeInventory().findResourcesByTypeAndStatus(vhostResourceType, InventoryStatus.COMMITTED);
+
String[] expectedRKs = testConfiguration.getExpectedResourceKeysAfterUpgrade(setup);
-
+
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())) {
@@ -165,21 +166,21 @@ public class UpgradeTestBase extends PluginContainerTest {
}
}
}
-
+
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 {
@@ -213,31 +214,31 @@ public class UpgradeTestBase extends PluginContainerTest {
setup.withApacheSetup().init();
ApacheServerComponent component = setup.withApacheSetup().getServerComponent();
ApacheDirectiveTree config = component.parseRuntimeConfiguration(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) {
+
+ 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);
}
@@ -248,13 +249,13 @@ public class UpgradeTestBase extends PluginContainerTest {
protected static String[] getVHostRKs(ApacheTestSetup 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) {
@@ -264,7 +265,7 @@ public class UpgradeTestBase extends PluginContainerTest {
ret[retIdx] = ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(vhost.serverName, vhost.hosts);
}
}
-
+
for(int i = 0; i < failLen; ++i, ++retIdx) {
String variableName = null;
if (failedUpgrades[i] == 0) {
@@ -280,7 +281,7 @@ public class UpgradeTestBase extends PluginContainerTest {
variableName = "vhost" + failedUpgrades[i] + ".rhq";
}
}
-
+
switch (rkFormat) {
case RHQ3:
variableName += "3.resource.key";
@@ -292,10 +293,10 @@ public class UpgradeTestBase extends PluginContainerTest {
variableName += "snmp.identifier";
break;
}
-
+
ret[retIdx] = replacements.get(variableName);
}
-
+
return ret;
}
@@ -305,7 +306,7 @@ public class UpgradeTestBase extends PluginContainerTest {
.toURL());
PluginMetadataParser parser = new PluginMetadataParser(descriptor,
Collections.<String, PluginMetadataParser> emptyMap());
-
+
List<ResourceType> platformTypes = parser.getAllTypes();
//this is the default container name in case of no plugin explicit plugin configuration, which we don't have.
@@ -317,20 +318,20 @@ public class UpgradeTestBase extends PluginContainerTest {
}
Class discoveryClass = Class.forName(parser.getDiscoveryComponentClass(rt));
-
+
ResourceDiscoveryComponent discoveryComponent = (ResourceDiscoveryComponent) discoveryClass.newInstance();
-
+
ResourceDiscoveryContext context = new ResourceDiscoveryContext(rt, null, null,
SystemInfoFactory.createSystemInfo(), Collections.emptyList(), Collections.emptyList(), containerName,
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());
@@ -339,11 +340,11 @@ public class UpgradeTestBase extends PluginContainerTest {
platform.setResourceType(rt);
platform.setUuid(UUID.randomUUID().toString());
platform.setId(1);
-
+
return platform;
}
}
-
+
return null;
}
@@ -352,12 +353,12 @@ public class UpgradeTestBase extends PluginContainerTest {
if (prefix != null && !prefix.isEmpty()) {
bld.append(prefix).append(".");
}
-
+
bld.append(name);
-
+
return bld.toString();
}
-
+
protected static InetAddress determineLocalhost() {
try {
return InetAddress.getLocalHost();
commit 9b30d84de016542bad1f9490a9b24e93dce9c162
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Feb 13 16:11:34 2013 -0500
append to the installer log so we don't lose any installer log messages when rhq-installer.sh is run multiple times
diff --git a/modules/enterprise/server/installer/src/main/resources/logging.properties b/modules/enterprise/server/installer/src/main/resources/logging.properties
index 6a48b2b..0affd97 100644
--- a/modules/enterprise/server/installer/src/main/resources/logging.properties
+++ b/modules/enterprise/server/installer/src/main/resources/logging.properties
@@ -16,8 +16,9 @@ handler.CONSOLE.formatter=PATTERN
# File handler configuration
handler.FILE=org.jboss.logmanager.handlers.FileHandler
handler.FILE.level=${rhq.server.installer.loglevel:DEBUG}
-handler.FILE.properties=autoFlush,fileName
+handler.FILE.properties=autoFlush,append,fileName
handler.FILE.autoFlush=true
+handler.FILE.append=true
handler.FILE.fileName=${rhq.server.installer.logdir:.}/rhq-installer.log
handler.FILE.formatter=PATTERN
commit d3465f9300f95680fda57fab996401870a39ffa6
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Feb 13 20:09:02 2013 +0100
Fix the expectations of the JMock-based apache plugin integration tests
after the fixes in the inventory report processing that changed the workflow
slightly.
This should make the apache integration tests pass again.
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 17beb1e..8bc25ca 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java
@@ -26,6 +26,8 @@ package org.rhq.core.pc.upgrade;
import static org.testng.Assert.fail;
import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
@@ -52,7 +54,7 @@ import org.rhq.core.domain.resource.ResourceType;
/**
* This class represents a server side database store of the inventory for the purposes
* of the ResourceUpgradeTest unit test.
- *
+ *
* @author Lukas Krejci
*/
public class FakeServerInventory {
@@ -62,7 +64,7 @@ public class FakeServerInventory {
private int counter;
private boolean failing;
private boolean failUpgrade;
-
+
private static final Comparator<Resource> ID_COMPARATOR = new Comparator<Resource>() {
public int compare(Resource o1, Resource o2) {
return o1.getId() - o2.getId();
@@ -90,18 +92,18 @@ public class FakeServerInventory {
fakePersist(res, InventoryStatus.COMMITTED, new HashSet<String>());
}
}
-
+
public synchronized CustomAction mergeInventoryReport(final InventoryStatus requiredInventoryStatus) {
return new CustomAction("updateServerSideInventory") {
public Object invoke(Invocation invocation) throws Throwable {
synchronized (FakeServerInventory.this) {
throwIfFailing();
-
+
InventoryReport inventoryReport = (InventoryReport) invocation.getParameter(0);
-
+
for (Resource res : inventoryReport.getAddedRoots()) {
Resource persisted = fakePersist(res, requiredInventoryStatus, new HashSet<String>());
-
+
if (res.getParentResource() == Resource.ROOT) {
platform = persisted;
}
@@ -117,9 +119,9 @@ public class FakeServerInventory {
public Object invoke(Invocation invocation) throws Throwable {
synchronized (FakeServerInventory.this) {
throwIfFailing();
-
+
platform = null;
-
+
return getSyncInfo();
}
}
@@ -131,36 +133,36 @@ public class FakeServerInventory {
public Object invoke(Invocation invocation) throws Throwable {
synchronized(FakeServerInventory.this) {
throwIfFailing();
-
+
ResourceError error = (ResourceError) invocation.getParameter(0);
-
+
Resource serverSideResource = resourceStore.get(error.getResource().getUuid());
-
+
if (serverSideResource != null) {
List<ResourceError> currentErrors = serverSideResource.getResourceErrors();
currentErrors.add(error);
}
-
+
return null;
}
}
};
}
-
+
public synchronized CustomAction upgradeResources() {
return new CustomAction("upgradeServerSideInventory") {
@SuppressWarnings({ "serial", "unchecked" })
public Object invoke(Invocation invocation) throws Throwable {
synchronized(FakeServerInventory.this) {
throwIfFailing();
-
+
if (failUpgrade) {
- throw new RuntimeException("Failing the upgrade purposefully.");
+ throw new RuntimeException("Failing the upgrade purposefully.");
}
-
+
Set<ResourceUpgradeRequest> requests = (Set<ResourceUpgradeRequest>) invocation.getParameter(0);
Set<ResourceUpgradeResponse> responses = new HashSet<ResourceUpgradeResponse>();
-
+
for (final ResourceUpgradeRequest request : requests) {
Resource resource = findResource(platform, new Resource() {
public int getId() {
@@ -174,18 +176,18 @@ public class FakeServerInventory {
if (request.getNewName() != null) {
resource.setName(request.getNewName());
}
-
+
if (request.getNewResourceKey() != null) {
resource.setResourceKey(request.getNewResourceKey());
}
-
+
if (request.getUpgradeErrorMessage() != null) {
ResourceError error = new ResourceError(resource, ResourceErrorType.UPGRADE,
request.getUpgradeErrorMessage(), request.getUpgradeErrorStackTrace(),
request.getTimestamp());
resource.getResourceErrors().add(error);
}
-
+
ResourceUpgradeResponse resp = new ResourceUpgradeResponse();
resp.setResourceId(resource.getId());
resp.setUpgradedResourceName(resource.getName());
@@ -206,16 +208,33 @@ public class FakeServerInventory {
public Object invoke(Invocation invocation) throws Throwable {
synchronized (FakeServerInventory.this) {
throwIfFailing();
-
+
Set<Integer> resourceIds = (Set<Integer>) invocation.getParameter(0);
boolean includeDescendants = (Boolean) invocation.getParameter(1);
-
+
return getResources(resourceIds, includeDescendants);
}
}
};
}
+ public synchronized CustomAction getResourcesAsList() {
+ return new CustomAction("getResourcesAsList") {
+ @Override
+ public Object invoke(Invocation invocation) throws Throwable {
+ synchronized(FakeServerInventory.this) {
+ throwIfFailing();
+
+ Integer[] resourceIds = (Integer[]) invocation.getParameter(0);
+
+ Set<Resource> resources = getResources(new LinkedHashSet<Integer>(Arrays.asList(resourceIds)), false);
+
+ return new ArrayList<Resource>(resources);
+ }
+ }
+ };
+ }
+
public synchronized boolean isFailing() {
return failing;
}
@@ -227,11 +246,11 @@ public class FakeServerInventory {
public synchronized boolean isFailUpgrade() {
return failUpgrade;
}
-
+
public synchronized void setFailUpgrade(boolean failUpgrade) {
this.failUpgrade = failUpgrade;
}
-
+
@SuppressWarnings("serial")
public synchronized Set<Resource> findResourcesByType(final ResourceType type) {
Set<Resource> result = new HashSet<Resource>();
@@ -281,7 +300,7 @@ public class FakeServerInventory {
removeResource(child);
}
}
-
+
private Resource fakePersist(Resource agentSideResource, InventoryStatus requiredInventoryStatus,
Set<String> inProgressUUIds) {
Resource persisted = resourceStore.get(agentSideResource.getUuid());
@@ -327,9 +346,9 @@ public class FakeServerInventory {
//i.e. we prefer the current results from the agent but keep the children we used to
//have in the past. This is the same behavior as the actual RHQ server has.
childResources.addAll(persisted.getChildResources());
-
+
persisted.setChildResources(childResources);
-
+
inProgressUUIds.remove(agentSideResource.getUuid());
return persisted;
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestSetup.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestSetup.java
index 9f12166..37e74d9 100644
--- a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestSetup.java
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestSetup.java
@@ -74,14 +74,14 @@ public class ApacheTestSetup {
private Mockery context;
private ResourceTypes apacheResourceTypes;
private String testId;
-
+
public class ApacheSetup {
private String serverRoot;
private String exePath;
private Collection<String> configurationFiles;
private ApacheExecutionUtil execution;
private boolean deploy = true;
-
+
private ApacheSetup() {
}
@@ -162,16 +162,16 @@ public class ApacheTestSetup {
+ serverRootDir + "'.");
File logsDir = new File(serverRootDir, "logs");
-
+
assertTrue(logsDir.exists(), "The configured server root denotes a directory that doesn't have a 'logs' subdirectory. This is unexpected.");
-
+
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;
@@ -185,11 +185,11 @@ public class ApacheTestSetup {
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
- //the same code the apache server discovery does.
+ //the same code the apache server discovery does.
ApacheDirectiveTree tree = ApacheServerDiscoveryComponent.parseRuntimeConfiguration(confFilePath, null, ApacheBinaryInfo.getInfo(exePath, SystemInfoFactory.createSystemInfo()));
-
+
//XXX this hardcodes apache2 as the only option we have...
HttpdAddressUtility.Address addrToUse = HttpdAddressUtility.APACHE_2_x.getMainServerSampleAddress(tree, null, -1);
pingUrl = addrToUse.toString();
@@ -205,7 +205,7 @@ public class ApacheTestSetup {
}
private void doSetup() throws Exception {
- init();
+ init();
startApache();
}
@@ -228,12 +228,12 @@ public class ApacheTestSetup {
return this;
}
- public ApacheTestSetup withDefaultOverrides(Map<String, String> defaultOverrides) {
+ public ApacheTestSetup withDefaultOverrides(Map<String, String> defaultOverrides) {
this.defaultOverrides = defaultOverrides == null ? new HashMap<String, String>() : defaultOverrides;
deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName, this.defaultOverrides);
return this;
}
-
+
public ApacheTestSetup withPlatformResource(Resource platform) {
this.platform = platform;
return this;
@@ -271,7 +271,7 @@ public class ApacheTestSetup {
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)));
@@ -280,7 +280,7 @@ public class ApacheTestSetup {
expectations.allowing(ss.getDiscoveryServerService()).clearResourceConfigError(
expectations.with(Expectations.any(int.class)));
-
+
expectations.allowing(ss.getDiscoveryServerService()).setResourceEnablement(
expectations.with(Expectations.any(int.class)), expectations.with(Expectations.any(boolean.class)));
@@ -289,7 +289,10 @@ public class ApacheTestSetup {
expectations.allowing(ss.getDriftServerService()).getDriftDefinitions(expectations.with(Expectations.any(Set.class)));
expectations.will(Expectations.returnValue(Collections.emptyMap()));
-
+
+ expectations.allowing(ss.getDiscoveryServerService()).getResourcesAsList(expectations.with(Expectations.any(Integer[].class)));
+ expectations.will(fakeInventory.getResourcesAsList());
+
expectations.ignoring(ss.getBundleServerService());
expectations.ignoring(ss.getConfigurationServerService());
expectations.ignoring(ss.getContentServerService());
@@ -307,14 +310,14 @@ public class ApacheTestSetup {
public DeploymentConfig getDeploymentConfig() {
return deploymentConfig;
}
-
+
public ApacheTestSetup setup() throws Exception {
apacheSetup.doSetup();
- Map<String, String> replacements = deploymentConfig.getTokenReplacements();
+ Map<String, String> replacements = deploymentConfig.getTokenReplacements();
replacements.put("server.root", apacheSetup.serverRoot);
replacements.put("exe.path", apacheSetup.exePath);
-
+
ApacheDeploymentUtil.addDefaultVariables(replacements, null);
HttpdAddressUtility addressUtility = apacheSetup.getServerComponent()
@@ -325,18 +328,18 @@ public class ApacheTestSetup {
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(
@@ -348,7 +351,7 @@ public class ApacheTestSetup {
"vhost2.snmp.identifier",
addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost2.hosts.get(0),
vhost2.serverName).toString(false, false));
-
+
replacements.put(
"vhost2.rhq4.resource.key",
ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(
@@ -360,7 +363,7 @@ public class ApacheTestSetup {
"vhost3.snmp.identifier",
addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost3.hosts.get(0),
vhost3.serverName).toString(false, false));
-
+
replacements.put(
"vhost3.rhq4.resource.key",
ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(
@@ -372,7 +375,7 @@ public class ApacheTestSetup {
"vhost4.snmp.identifier",
addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost4.hosts.get(0),
vhost4.serverName).toString(false, false));
-
+
replacements.put(
"vhost4.rhq4.resource.key",
ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(
@@ -381,35 +384,35 @@ public class ApacheTestSetup {
//let the user override everything we just did
replacements.putAll(defaultOverrides);
-
+
inventoryFileReplacements = replacements;
-
+
if (inventoryFile != null) {
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
+
+ //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.
- *
+ * 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);
commit a23490d9053904f0e78cb5b0ce7c43a92b7c4f36
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Feb 13 11:51:45 2013 -0500
Fix issues in mergeAvailabilityReport "repair code". This is code that
attempts to fix problems in the Availability records, if they somehow get
corrupted. In general, it doesn't execute. But if and when it did, it
wasn't repairing things as well as it could. This makes improvements.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java
index 2946d40..0181d7a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java
@@ -591,52 +591,13 @@ public class AvailabilityManagerBean implements AvailabilityManagerLocal, Availa
// availability reports only tell us the current state at the start time; end time is ignored/must be null
reported.setEndTime(null);
- try {
- q.setParameter("resourceId", reported.getResource().getId());
- Availability latest = (Availability) q.getSingleResult();
- AvailabilityType latestType = latest.getAvailabilityType();
- AvailabilityType reportedType = reported.getAvailabilityType();
-
- // If the current avail is DISABLED, and this report is not trying to re-enable the resource,
- // Then ignore the reported avail.
- if (AvailabilityType.DISABLED == latestType) {
- if (!(mergeInfo.isEnablementReport() && (AvailabilityType.UNKNOWN == reportedType))) {
- disabledAvailabilities.add(reported);
- continue;
- }
- }
-
- if (reported.getStartTime() >= latest.getStartTime()) {
- //log.info( "new avail (latest/reported)-->" + latest + "/" + reported );
-
- // the new availability data is for a time after our last known state change
- // we are run-length encoded, so only persist data if the availability changed
- if (latest.getAvailabilityType() != reported.getAvailabilityType()) {
- entityManager.persist(reported);
- mergeInfo.incrementNumInserted();
-
- latest.setEndTime(reported.getStartTime());
- latest = entityManager.merge(latest);
-
- updateResourceAvailability(reported);
- }
-
- // our last known state was unknown, ask for a full report to ensure we are in sync with agent
- if (latest.getAvailabilityType() == AvailabilityType.UNKNOWN) {
- mergeInfo.setAskForFullReport(true);
- }
- } else {
- //log.info( "past avail (latest/reported)==>" + latest + "/" + reported );
+ // get the latest avail for the reported resource
+ q.setParameter("resourceId", reported.getResource().getId());
+ Availability latest = null;
- // The new data is for a time in the past, probably an agent sending a report after
- // a network outage has been corrected but after we have already backfilled.
- // We need to insert it into our past timeline.
- insertAvailability(reported);
- mergeInfo.incrementNumInserted();
+ try {
+ latest = (Availability) q.getSingleResult();
- // this is an unusual report - ask the agent for a full report so as to ensure we are in sync with agent
- mergeInfo.setAskForFullReport(true);
- }
} catch (NoResultException nre) {
// This should not happen unless the Resource in the report is stale, which can happen in certain
// sync scenarios. A Resource is given its initial Availability/ResourceAvailability when it is
@@ -644,37 +605,47 @@ public class AvailabilityManagerBean implements AvailabilityManagerLocal, Availa
// it must not exist in my utopian view of the world. Let's just make sure...
Resource attachedResource = (Resource) entityManager.find(Resource.class, reported.getResource()
.getId());
- if (null == attachedResource) {
+
+ if ((null == attachedResource) || (InventoryStatus.COMMITTED != attachedResource.getInventoryStatus())) {
// expected case
log.info("Skipping mergeAvailabilityReport() for stale resource [" + reported.getResource()
+ "]. These messages should go away after the next agent synchronization with the server.");
- } else if (InventoryStatus.COMMITTED == attachedResource.getInventoryStatus()) {
- // this should not happen, it means the resource exists but has no latest Availability
- // record (i.e. sendTime == null). Try to correct the situation.
+ continue;
+
+ } else {
+ // this should not really happen but is possible in rare failure situations, it means the resource
+ // exists but has no latest Availability record (i.e. sendTime == null). Correct the situation and
+ // then process the reported avail.
log.warn("Resource [" + reported.getResource()
+ "] has no latest availability record (i.e. no endtime) - will attempt to repair.\n"
+ mergeInfo.toString(false));
+
try {
List<Availability> attachedAvails = attachedResource.getAvailability();
+ Availability attachedLastAvail = null;
+
if (attachedAvails.isEmpty()) {
- attachedResource.initCurrentAvailability();
- entityManager.merge(attachedResource);
+ latest = new Availability(attachedResource, 0L, AvailabilityType.UNKNOWN);
+ entityManager.persist(latest);
} else {
- Availability attachedLastAvail = attachedAvails.get(attachedAvails.size() - 1);
- attachedLastAvail.setEndTime(null);
- entityManager.merge(attachedLastAvail);
+ latest = attachedAvails.get(attachedAvails.size() - 1);
+ latest.setEndTime(null);
+ latest = entityManager.merge(latest);
}
+ updateResourceAvailability(latest);
+
// ask the agent for a full report so as to ensure we are in sync with agent
mergeInfo.setAskForFullReport(true);
} catch (Throwable t) {
- log.warn("Unable to repair latest availablity for Resource [" + reported.getResource() + "]", t);
+ log.warn("Unable to repair NoResult latest availablity for Resource [" + reported.getResource()
+ + "]", t);
+ continue;
}
}
-
} catch (NonUniqueResultException nure) {
// This condition should never happen. In my world of la-la land, I've done everything
// correctly so this never happens. But, due to the asynchronous nature of things,
@@ -686,15 +657,69 @@ public class AvailabilityManagerBean implements AvailabilityManagerLocal, Availa
log.warn("Resource [" + reported.getResource() + "] has multiple availabilities without an endtime ["
+ nure.getMessage() + "] - will attempt to remove the extra ones\n" + mergeInfo.toString(false));
- q.setParameter("resourceId", reported.getResource().getId());
- List<Availability> latest = q.getResultList();
+ try {
+
+ List<Availability> latestList = q.getResultList();
+
+ // delete all but the last one (our query sorts in ASC start time order)
+ int latestCount = latestList.size();
+ for (int i = 0; i < (latestCount - 1); i++) {
+ entityManager.remove(latestList.get(i));
+ }
+
+ latest = latestList.get(latestCount - 1);
+ updateResourceAvailability(latest);
+
+ // this is an unusual report - ask the agent for a full report so as to ensure we are in sync with agent
+ mergeInfo.setAskForFullReport(true);
+
+ } catch (Throwable t) {
+ log.warn(
+ "Unable to repair NonUnique Result latest availablity for Resource [" + reported.getResource()
+ + "]", t);
+ continue;
+ }
+ }
+
+ AvailabilityType latestType = latest.getAvailabilityType();
+ AvailabilityType reportedType = reported.getAvailabilityType();
- // delete all but the last one (our query sorts in ASC start time order)
- int latestCount = latest.size();
- for (int i = 0; i < (latestCount - 1); i++) {
- entityManager.remove(latest.get(i));
+ // If the current avail is DISABLED, and this report is not trying to re-enable the resource,
+ // Then ignore the reported avail.
+ if (AvailabilityType.DISABLED == latestType) {
+ if (!(mergeInfo.isEnablementReport() && (AvailabilityType.UNKNOWN == reportedType))) {
+ disabledAvailabilities.add(reported);
+ continue;
}
- updateResourceAvailability(latest.get(latestCount - 1));
+ }
+
+ if (reported.getStartTime() >= latest.getStartTime()) {
+ //log.info( "new avail (latest/reported)-->" + latest + "/" + reported );
+
+ // the new availability data is for a time after our last known state change
+ // we are run-length encoded, so only persist data if the availability changed
+ if (latest.getAvailabilityType() != reported.getAvailabilityType()) {
+ entityManager.persist(reported);
+ mergeInfo.incrementNumInserted();
+
+ latest.setEndTime(reported.getStartTime());
+ latest = entityManager.merge(latest);
+
+ updateResourceAvailability(reported);
+ }
+
+ // our last known state was unknown, ask for a full report to ensure we are in sync with agent
+ if (latest.getAvailabilityType() == AvailabilityType.UNKNOWN) {
+ mergeInfo.setAskForFullReport(true);
+ }
+ } else {
+ //log.info( "past avail (latest/reported)==>" + latest + "/" + reported );
+
+ // The new data is for a time in the past, probably an agent sending a report after
+ // a network outage has been corrected but after we have already backfilled.
+ // We need to insert it into our past timeline.
+ insertAvailability(reported);
+ mergeInfo.incrementNumInserted();
// this is an unusual report - ask the agent for a full report so as to ensure we are in sync with agent
mergeInfo.setAskForFullReport(true);
commit 9c6886bf1be548b195ac14e81c76805b988c149a
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Feb 13 09:22:40 2013 -0500
Fix test given slight change in avail behavior. In commit c516ad09fcebcedfd1a505d6bfd434997ac6642d
we stopped kicking off an immediate avail scan when new resources were discovered,
simplifying the code, and approach, to just wait for the next scheduled scan,
which likely occurs nearly as fast. From the test's perspective this meant one
resource, the platform, had its avail change at a slightly different time.
diff --git a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/avail/AvailTest.java b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/avail/AvailTest.java
index 005e900..956fb97 100644
--- a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/avail/AvailTest.java
+++ b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/avail/AvailTest.java
@@ -24,13 +24,13 @@ import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.pc.PluginContainer;
-import org.rhq.plugins.test.avail.AvailDiscoveryComponent;
-import org.rhq.plugins.test.avail.AvailResourceComponent;
import org.rhq.core.pc.inventory.AvailabilityExecutor;
import org.rhq.core.pc.inventory.AvailabilityExecutor.Scan;
import org.rhq.core.pc.inventory.ForceAvailabilityExecutor;
import org.rhq.core.pc.inventory.ResourceContainer;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.plugins.test.avail.AvailDiscoveryComponent;
+import org.rhq.plugins.test.avail.AvailResourceComponent;
import org.rhq.test.arquillian.AfterDiscovery;
import org.rhq.test.arquillian.BeforeDiscovery;
import org.rhq.test.arquillian.FakeServerInventory;
@@ -184,7 +184,7 @@ public class AvailTest extends Arquillian {
Assert.assertEquals(datum.getAvailabilityType(), AvailabilityType.UP, "should be UP at the start");
}
AvailabilityExecutor.Scan scan = executor.getMostRecentScanHistory();
- assertScan(scan, true, true, 29, 28, 29, 28, 0, 0);
+ assertScan(scan, true, true, 29, 29, 29, 28, 0, 0);
// do a forced avail check again - nothing changed, so we should have an empty report
report = executor.call();
@@ -514,7 +514,7 @@ public class AvailTest extends Arquillian {
Assert.assertEquals(scan.getNumResources(), numResources,
"Unexpected numResources, remember to include the implied platform?");
Assert.assertEquals(scan.getNumAvailabilityChanges(), numChanges,
- "Unexpected numChanges, remember to omit the implied platform");
+ "Unexpected numChanges, remember to include the implied platform");
Assert.assertEquals(scan.getNumGetAvailabilityCalls(), numCalls,
"Unexpected numGetAvailCalls, remember to include the implied platform");
Assert.assertEquals(scan.getNumScheduledRandomly(), numSched,
commit 1b1e78f7a8c6a364d563a9bae4ea73116e5381c1
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Feb 12 17:20:00 2013 -0500
To maintain the test dep ordering, which is sometimes important, and definitel
is important here, move all of the test deps to the new test.dependencies profile.
diff --git a/modules/enterprise/server/itests-2/pom.xml b/modules/enterprise/server/itests-2/pom.xml
index d5daa17..5961627 100644
--- a/modules/enterprise/server/itests-2/pom.xml
+++ b/modules/enterprise/server/itests-2/pom.xml
@@ -35,144 +35,7 @@
</properties>
<dependencies>
- <!--================ Test Deps ================ -->
-
- <!-- Note, the test dep ordering can be important. Maven orders the [test] classpath in the order listed in the pom. -->
- <dependency>
- <groupId>org.jboss.as</groupId>
- <artifactId>jboss-as-dist</artifactId>
- <type>zip</type>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.spec</groupId>
- <artifactId>jboss-javaee-6.0</artifactId>
- <version>${jboss.javaee6.spec.version}</version>
- <scope>provided</scope>
- <type>pom</type>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.arquillian.testng</groupId>
- <artifactId>arquillian-testng-container</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.shrinkwrap.resolver</groupId>
- <artifactId>shrinkwrap-resolver-depchain</artifactId>
- <type>pom</type>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.arquillian.protocol</groupId>
- <artifactId>arquillian-protocol-servlet</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-arquillian-suite-extension</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-domain</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-enterprise-server</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-script-bindings</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-server-client-api</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>rhq-serverplugin-drift</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>test-utils</artifactId>
- <version>${project.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- </exclusion>
- </exclusions>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.rhq.helpers</groupId>
- <artifactId>perftest-support</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-entitymanager</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-testng</artifactId>
- <version>${powermock.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito</artifactId>
- <version>${powermock.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.opensymphony.quartz</groupId>
- <artifactId>quartz</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.liquibase</groupId>
- <artifactId>liquibase-core</artifactId>
- <version>${liquibase.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>joda-time</groupId>
- <artifactId>joda-time</artifactId>
- <version>2.1</version>
- <scope>test</scope>
- </dependency>
+ <!-- see the test.dependencies profile below -->
</dependencies>
<build>
@@ -669,46 +532,183 @@
<profiles>
- <profile>
- <!--
- This profile has been created to avoid unnecessary resolution of test dependencies during a build that
- does not run, compile or need tests.
- More test dependencies are to be moved here if the set of sub-dependencies is complex, references project
- test jars, or conflicts with changing the container version.
- -->
- <id>test.dependencies</id>
- <activation>
- <property>
- <name>maven.test.skip</name>
- <value>!true</value>
- </property>
- </activation>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>rhq-core-client-api</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.as</groupId>
- <artifactId>jboss-as-arquillian-container-managed</artifactId>
- <version>${jboss.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>rhq-core-domain</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- </dependencies>
- </profile>
+ <profile>
+ <!-- This profile has been created to avoid unnecessary resolution of test dependencies during a build that does not
+ run, compile or need tests. There are product build dependencies on this profile, don't remove. -->
+
+ <id>test.dependencies</id>
+ <activation>
+ <property>
+ <name>maven.test.skip</name>
+ <value>!true</value>
+ </property>
+ </activation>
+
+
+ <dependencies>
+ <!-- Note, the test dep ordering can be important. Maven orders the [test] classpath in the order listed in the pom. -->
+
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-dist</artifactId>
+ <type>zip</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.spec</groupId>
+ <artifactId>jboss-javaee-6.0</artifactId>
+ <version>${jboss.javaee6.spec.version}</version>
+ <scope>provided</scope>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-arquillian-container-managed</artifactId>
+ <version>${jboss.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian.testng</groupId>
+ <artifactId>arquillian-testng-container</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-depchain</artifactId>
+ <type>pom</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian.protocol</groupId>
+ <artifactId>arquillian-protocol-servlet</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-arquillian-suite-extension</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-domain</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-core-domain</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-enterprise-server</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-script-bindings</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-server-client-api</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-serverplugin-drift</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-core-client-api</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>test-utils</artifactId>
+ <version>${project.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ </exclusion>
+ </exclusions>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq.helpers</groupId>
+ <artifactId>perftest-support</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-testng</artifactId>
+ <version>${powermock.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ <version>${powermock.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.opensymphony.quartz</groupId>
+ <artifactId>quartz</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.liquibase</groupId>
+ <artifactId>liquibase-core</artifactId>
+ <version>${liquibase.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>joda-time</groupId>
+ <artifactId>joda-time</artifactId>
+ <version>2.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+ </profile>
<!-- If testing against oracle, override the default property settings -->
<profile>
commit 1c247adee91e2d82a2dd28905345067efa546a85
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Feb 12 15:48:32 2013 -0500
Fix a transactioning issue with agent backfill. It was possible for the Agent to
be marked backfilled in one transaction yet have the actual avail changes fail
in a second transaction, leaving the dead agent and its children with UP avail
and no longer eligible for backfill due to the flag being set.
Additionally, avoid large transactions if many agents need to be backfilled
sumultaneously.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerBean.java
index 29c3ad3..d01dbd0 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerBean.java
@@ -192,7 +192,7 @@ public class AgentManagerBean implements AgentManagerLocal {
server_bootstrap.removeDownedAgent(downedAgent.getRemoteEndpoint());
log.info("Agent with name [" + agentName + "] just went down");
- agentManager.backfillAgent(subjectManager.getOverlord(), agentName, downedAgent.getId());
+ agentManager.backfillAgentInNewTransaction(subjectManager.getOverlord(), agentName, downedAgent.getId());
return;
}
@@ -272,7 +272,8 @@ public class AgentManagerBean implements AgentManagerLocal {
log.info("Have not heard from agent [" + record.getAgentName() + "] since ["
+ new Date(record.getLastAvailabilityPing()) + "]. Will be backfilled since we suspect it is down");
- agentManager.backfillAgent(subjectManager.getOverlord(), record.getAgentName(), record.getAgentId());
+ agentManager.backfillAgentInNewTransaction(subjectManager.getOverlord(), record.getAgentName(),
+ record.getAgentId());
}
}
@@ -281,7 +282,8 @@ public class AgentManagerBean implements AgentManagerLocal {
return;
}
- public void backfillAgent(Subject subject, String agentName, int agentId) {
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public void backfillAgentInNewTransaction(Subject subject, String agentName, int agentId) {
// make sure we lock out all processing of any availability reports that might come our way to avoid concurrency
// problems
AvailabilityReportSerializer.getSingleton().lock(agentName);
@@ -299,7 +301,6 @@ public class AgentManagerBean implements AgentManagerLocal {
}
}
- @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void setAgentBackfilled(int agentId, boolean backfilled) {
Query query = entityManager.createNamedQuery(Agent.QUERY_SET_AGENT_BACKFILLED);
query.setParameter("agentId", agentId);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerLocal.java
index 6cb50f2..842d5d8 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerLocal.java
@@ -45,15 +45,16 @@ import org.rhq.enterprise.server.agentclient.AgentClient;
public interface AgentManagerLocal {
/**
- * Call this method to set the agent down and mark it 'backfilled'. Also, sets all of its monitored resources
- * to an UNKNOWN avail state since the agent is no longer reporting availability.
+ * Call this method to set the agent DOWN and mark it 'backfilled'. Also, sets all of its monitored resources
+ * to an UNKNOWN avail state since the agent is no longer reporting availability. Done in its own transaction to
+ * avoid large transactions if many agents are simultaneously backfilled.
*
* @param subject
* @param agentName
* @param agentId
*/
// This method should not be remoted.
- void backfillAgent(Subject subject, String agentName, int agentId);
+ void backfillAgentInNewTransaction(Subject subject, String agentName, int agentId);
/**
* Persists a new agent.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java
index d92cbc4..2946d40 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java
@@ -749,7 +749,6 @@ public class AvailabilityManagerBean implements AvailabilityManagerLocal, Availa
}
@SuppressWarnings("unchecked")
- @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void updateAgentResourceAvailabilities(int agentId, AvailabilityType platformAvailType,
AvailabilityType childAvailType) {
commit f7409c5649029ba91d1d25ced972196b677ab14d
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Feb 15 21:29:54 2013 -0500
Inventory sync no longer schedules avail check runs in response to
unknown/modified resources, instead just waiting for the next scheduled
run, which is soon given only 30s intervals.
These test classes, perhaps unwittingly, depended on that behavior, so now
run the avail checker as a post-discovery task, to fully initialize the
resource containers.
diff --git a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/LateMeasurementRescheduleTest.java b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/LateMeasurementRescheduleTest.java
index c79988b..301d613 100644
--- a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/LateMeasurementRescheduleTest.java
+++ b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/LateMeasurementRescheduleTest.java
@@ -18,6 +18,7 @@ import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.rhq.core.clientapi.server.discovery.InventoryReport;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.pc.PluginContainer;
+import org.rhq.core.pc.inventory.ForceAvailabilityExecutor;
import org.rhq.core.pc.inventory.ResourceContainer;
import org.rhq.plugins.test.SingleResourceDiscoveryComponent;
import org.rhq.plugins.test.measurement.BZ834019ResourceComponent;
@@ -85,6 +86,9 @@ public class LateMeasurementRescheduleTest extends Arquillian {
public void waitForAsyncDiscoveries() throws Exception {
if (discoveryCompleteChecker != null) {
discoveryCompleteChecker.waitForDiscoveryComplete(10000);
+
+ // Since the avail job is not running, make sure our discovered resources get their initial UP avail
+ new ForceAvailabilityExecutor(pluginContainer.getInventoryManager()).call();
}
}
diff --git a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/ReadOnlyScheduleSetTest.java b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/ReadOnlyScheduleSetTest.java
index dedf968..4747851 100644
--- a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/ReadOnlyScheduleSetTest.java
+++ b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/ReadOnlyScheduleSetTest.java
@@ -19,6 +19,7 @@ import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.rhq.core.clientapi.server.discovery.InventoryReport;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.pc.PluginContainer;
+import org.rhq.core.pc.inventory.ForceAvailabilityExecutor;
import org.rhq.core.pc.inventory.ResourceContainer;
import org.rhq.plugins.test.SingleResourceDiscoveryComponent;
import org.rhq.plugins.test.measurement.BZ821058ResourceComponent;
@@ -84,6 +85,9 @@ public class ReadOnlyScheduleSetTest extends Arquillian {
public void waitForAsyncDiscoveries() throws Exception {
if (discoveryCompleteChecker != null) {
discoveryCompleteChecker.waitForDiscoveryComplete(10000);
+
+ // Since the avail job is not running, make sure our discovered resources get their initial UP avail
+ new ForceAvailabilityExecutor(pluginContainer.getInventoryManager()).call();
}
}
commit f7da6afeb80a4a3a18906d7ae3f8318e2d3640a9
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Feb 15 15:43:50 2013 -0500
the name of the perftest sysprops are different now
diff --git a/etc/agentspawn/src/scripts/agentcopy.properties b/etc/agentspawn/src/scripts/agentcopy.properties
index 52f3cba..8e15c26 100644
--- a/etc/agentspawn/src/scripts/agentcopy.properties
+++ b/etc/agentspawn/src/scripts/agentcopy.properties
@@ -32,8 +32,8 @@ agentcopy.agent.javaopts-default=-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=tru
# you do not specify -D options for a specific agent index, the
# sysprops-default will be used for that agent.
agentcopy.agent.sysprops-default=
-#agentcopy.agent.sysprops-default=-Don.perftest.scenario=configurable-alphaomega -Don.perftest.server-omega-count=10 -Don.perftest.service-alpha-count=25 -Don.perftest.service-beta-count=50
-#agentcopy.agent.sysprops.#####=-Don.perftest.scenario=configurable-3 -Don.perftest.server-b-count=10 -Don.perftest.service-b-count=50
+#agentcopy.agent.sysprops-default=-Drhq.perftest.scenario=configurable-alphaomega -Drhq.perftest.server-omega-count=10 -Drhq.perftest.service-alpha-count=25 -Drhq.perftest.service-beta-count=50
+#agentcopy.agent.sysprops.#####=-Drhq.perftest.scenario=configurable-3 -Drhq.perftest.server-b-count=10 -Drhq.perftest.service-b-count=50
# These are additional agent command line options that you can pass to an
# agent. These are added to the normal command line options that are always
commit 93a79d386873d8ecf9261fa7dee1d11772c9d591
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Feb 15 14:33:14 2013 -0500
Fix test to reflect the improved behavior when mergeAvailabilityReport
performs Availability "repair".
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java
index d6ac8b2..1fcda30 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java
@@ -1242,26 +1242,32 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
Thread.sleep(1000);
availabilityManager.mergeAvailabilityReport(report);
+ // the end time of avail 4 should have been reset to the start time of avail 5. Avail 5 should have been
+ // added and should be DOWN
avails = getResourceAvailabilities(theResource);
- assertEquals(avails.toString(), 4, avails.size());
+ assertEquals(avails.toString(), 5, avails.size());
- // avail start times should now be 0, 1:00 (UP), 1:10(DOWN), 1:40(UP)
+ // avail start times should now be 0, 1:00 (UP), 1:20(DOWN), 1:40(UP), 1:45(DOWN)
avail = avails.get(0); // 0..1:00
assertTrue(avail.toString(), Math.abs(avail.getStartTime() - 0L) < 1000L);
assertEquals(avail.toString(), AvailabilityType.UNKNOWN, avail.getAvailabilityType());
assertTrue(avail.toString(), Math.abs(avail.getEndTime() - avails.get(1).getStartTime()) < 1000L);
avail = avails.get(1); // 1:00..1:20
- assertTrue(avail.toString(), Math.abs(currentStartTime - (avail.getStartTime() + (40 * 60 * 1000))) < 1000L);
+ assertTrue(avail.toString(), Math.abs(newStartTime - (avail.getStartTime() + (45 * 60 * 1000))) < 1000L);
assertEquals(avail.toString(), AvailabilityType.UP, avail.getAvailabilityType());
assertTrue(avail.toString(), Math.abs(avail.getEndTime() - avails.get(2).getStartTime()) < 1000L);
avail = avails.get(2); // 1:20..1:40
- assertTrue(avail.toString(), Math.abs(currentStartTime - (avail.getStartTime() + (20 * 60 * 1000))) < 1000L);
+ assertTrue(avail.toString(), Math.abs(newStartTime - (avail.getStartTime() + (25 * 60 * 1000))) < 1000L);
assertEquals(avail.toString(), AvailabilityType.DOWN, avail.getAvailabilityType());
assertTrue(avail.toString(), Math.abs(avail.getEndTime() - avails.get(3).getStartTime()) < 1000L);
- avail = avails.get(3); // 1:40
- assertTrue(avail.toString(), Math.abs(currentStartTime - avail.getStartTime()) < 1000L);
+ avail = avails.get(3); // 1:40..1:45
+ assertTrue(avail.toString(), Math.abs(newStartTime - (avail.getStartTime() + (5 * 60 * 1000))) < 1000L);
assertEquals(avail.toString(), AvailabilityType.UP, avail.getAvailabilityType());
- assertEquals(avail.toString(), null, avail.getEndTime()); // THIS IS THE CHANGE
+ assertTrue(avail.toString(), Math.abs(avail.getEndTime() - avails.get(4).getStartTime()) < 1000L); // THE FIX
+ avail = avails.get(4); // 1:45..null
+ assertTrue(avail.toString(), Math.abs(newStartTime - avail.getStartTime()) < 1000L);
+ assertEquals(avail.toString(), AvailabilityType.DOWN, avail.getAvailabilityType());
+ assertEquals(avail.toString(), null, avail.getEndTime());
} catch (Exception e) {
e.printStackTrace();
commit 0ec2c91347728df8462b2587f7ecc01e9245b73d
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Feb 15 16:14:38 2013 +0100
Fix the JNDI access integration test. Default activation of profiles in Maven
just doesn't work the way I expected it to ;)
diff --git a/modules/integration-tests/jndi-access/jndi-access-test/pom.xml b/modules/integration-tests/jndi-access/jndi-access-test/pom.xml
index 74e563c..b20dfa0 100644
--- a/modules/integration-tests/jndi-access/jndi-access-test/pom.xml
+++ b/modules/integration-tests/jndi-access/jndi-access-test/pom.xml
@@ -155,14 +155,15 @@
<profile>
<id>managed-test-server</id>
<activation>
- <activeByDefault>true</activeByDefault>
+ <property>
+ <name>!remote-test-server</name>
+ </property>
</activation>
<dependencies>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-arquillian-container-managed</artifactId>
- <version>${jboss.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
@@ -170,6 +171,11 @@
<profile>
<id>remote-test-server</id>
+ <activation>
+ <property>
+ <name>remote-test-server</name>
+ </property>
+ </activation>
<dependencies>
<dependency>
commit d124641fbb254087544f8f6dda17ae0dc8b3d967
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Thu Feb 14 18:23:36 2013 +0100
Fix JMX plugin test failure
diff --git a/modules/plugins/jmx/src/test/java/org/rhq/plugins/jmx/test/JMXPluginTest.java b/modules/plugins/jmx/src/test/java/org/rhq/plugins/jmx/test/JMXPluginTest.java
index b841a38..9757c7a 100644
--- a/modules/plugins/jmx/src/test/java/org/rhq/plugins/jmx/test/JMXPluginTest.java
+++ b/modules/plugins/jmx/src/test/java/org/rhq/plugins/jmx/test/JMXPluginTest.java
@@ -72,8 +72,6 @@ import org.rhq.plugins.jmx.util.JvmResourceKey;
* @author Greg Hinkle
* @author Ian Springer
*/
-// Disabled until we find a fix for Sigar getProcCredName issue
-@Test(enabled = false)
public class JMXPluginTest {
private static final int JMX_REMOTING_PORT1 = 9921;
@@ -95,8 +93,9 @@ public class JMXPluginTest {
this.testServerJvms.add(startTestServerJvm("-Dcom.sun.management.jmxremote.port=" + JMX_REMOTING_PORT1,
"-Dcom.sun.management.jmxremote.ssl=false", "-Dcom.sun.management.jmxremote.authenticate=false"));
- this.testServerJvms.add(startTestServerJvm("-D" + JMXDiscoveryComponent.SYSPROP_RHQ_RESOURCE_KEY + "="
- + EXPLICIT_RESOURCE_KEY1));
+ // FIXME: Disabled until we find a fix for Sigar getProcCredName issue
+ // this.testServerJvms.add(startTestServerJvm("-D" + JMXDiscoveryComponent.SYSPROP_RHQ_RESOURCE_KEY + "="
+ // + EXPLICIT_RESOURCE_KEY1));
this.testServerJvms.add(startTestServerJvm("-Dcom.sun.management.jmxremote.port=" + JMX_REMOTING_PORT2,
"-Dcom.sun.management.jmxremote.ssl=false", "-Dcom.sun.management.jmxremote.authenticate=false",
@@ -206,7 +205,8 @@ public class JMXPluginTest {
}
}
assert foundJmxRemotingServer : "JMX Remoting server not found.";
- assert foundExplicitKey1Server : "Explicit key server not found.";
+ // FIXME: Disabled until we find a fix for Sigar getProcCredName issue
+ //assert foundExplicitKey1Server : "Explicit key server not found.";
assert foundExplicitKey2Server : "JMX Remoting + explicit key server not found.";
}
commit f5104b4e3523c481a768a6411e87122371c002ec
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Thu Feb 14 15:28:02 2013 +0100
[BZ 909157 - Operation parameters are not shown in schedule operation details.] If the method refreshOperationParametersItem() is called when scheduling a new operation, the existent parameters are not forget.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
index 0f54af0..8436c2ab 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
@@ -355,7 +355,6 @@ public abstract class AbstractOperationScheduleDetailsView extends
this.operationParameters = (Configuration) record
.getAttributeAsObject(AbstractOperationScheduleDataSource.Field.PARAMETERS);
-
super.editExistingRecord(record);
}
@@ -426,11 +425,14 @@ public abstract class AbstractOperationScheduleDetailsView extends
private void refreshOperationParametersItem() {
String operationName = getSelectedOperationName();
String value;
- operationParameters = null; // reset params between dropdown selects
- // make sure we wipe out anything left by the previous op def
- for (Canvas child : this.operationParametersConfigurationHolder.getChildren()) {
- child.destroy();
+ if (isNewRecord()) { // BZ 909157: do it only for new schedule
+ operationParameters = null; // reset params between dropdown selects
+ // make sure we wipe out anything left by the previous op def
+ for (Canvas child : this.operationParametersConfigurationHolder.getChildren()) {
+ child.destroy();
+ }
}
+
if (operationName == null) {
value = "<i>" + MSG.view_operationScheduleDetails_fieldDefault_parameters() + "</i>";
this.operationParametersConfigurationHolder.hide();
@@ -453,8 +455,6 @@ public abstract class AbstractOperationScheduleDetailsView extends
ConfigurationTemplate defaultTemplate = parametersDefinition.getDefaultTemplate();
this.operationParameters = (defaultTemplate != null) ? defaultTemplate.createConfiguration()
: new Configuration();
- } else {
- this.operationParameters = new Configuration();
}
ConfigurationGWTServiceAsync configurationService = GWTServiceLookup.getConfigurationService();
commit 75938dac1e630e1f71a6a31e59f7b6124084a2c3
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Feb 14 09:22:47 2013 -0500
installer now provides a "--force" option - this lets you re-run the installer even if you didn't set autoinstall.enabled=true
and it also lets you attempt another installation if a previous one failed in the middle of its prior attempt.
diff --git a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/Installer.java b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/Installer.java
index 48defbc..b8a83fc 100644
--- a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/Installer.java
+++ b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/Installer.java
@@ -157,6 +157,7 @@ public class Installer {
usage.append("\t--host=<hostname>, -h: hostname where the app server is running").append("\n");
usage.append("\t--port=<port>, -p: talk to the app server over this management port").append("\n");
usage.append("\t--test, -t: test the validity of the server properties (install not performed)").append("\n");
+ usage.append("\t--force, -f: force the installer to try to install everything").append("\n");
usage.append("\t--listservers, -l: show list of known installed servers (install not performed)").append("\n");
usage.append("\t--setupdb, -b: only perform database schema creation or update").append("\n");
usage.append("\t--reconfig, -r: resets some configuration settings in an installed server").append("\n");
@@ -166,7 +167,7 @@ public class Installer {
}
private WhatToDo[] processArguments(String[] args) throws Exception {
- String sopts = "-:HD:h:p:d:blrt";
+ String sopts = "-:HD:h:p:d:bflrt";
LongOpt[] lopts = { new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'H'),
new LongOpt("host", LongOpt.REQUIRED_ARGUMENT, null, 'h'),
new LongOpt("port", LongOpt.REQUIRED_ARGUMENT, null, 'p'),
@@ -174,6 +175,7 @@ public class Installer {
new LongOpt("setupdb", LongOpt.NO_ARGUMENT, null, 'b'),
new LongOpt("listservers", LongOpt.NO_ARGUMENT, null, 'l'),
new LongOpt("reconfig", LongOpt.NO_ARGUMENT, null, 'r'),
+ new LongOpt("force", LongOpt.NO_ARGUMENT, null, 'f'),
new LongOpt("test", LongOpt.NO_ARGUMENT, null, 't') };
boolean test = false;
@@ -255,6 +257,11 @@ public class Installer {
break; // don't return, in case we need to allow more args
}
+ case 'f': {
+ this.installerConfig.setForceInstall(true);
+ break; // don't return, in case we need to allow more args
+ }
+
case 'l': {
listservers = true;
break; // don't return, we need to allow more args to be processed, like -p or -h
diff --git a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerConfiguration.java b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerConfiguration.java
index 0852b78..3adecbe 100644
--- a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerConfiguration.java
+++ b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerConfiguration.java
@@ -28,6 +28,7 @@ package org.rhq.enterprise.server.installer;
public class InstallerConfiguration {
private String managementHost = "127.0.0.1";
private int managementPort = 9999; // this is the default AS port
+ private boolean forceInstall = false;
public InstallerConfiguration() {
}
@@ -59,4 +60,12 @@ public class InstallerConfiguration {
}
this.managementPort = port;
}
+
+ public boolean isForceInstall() {
+ return this.forceInstall;
+ }
+
+ public void setForceInstall(boolean flag) {
+ this.forceInstall = flag;
+ }
}
diff --git a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
index 3ece569..e72f133 100644
--- a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
+++ b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
@@ -86,7 +86,7 @@ public class InstallerServiceImpl implements InstallerService {
return;
}
if (allServerDetails.size() == 0) {
- log.info("There are no known servers currently registered");
+ log("There are no known servers currently registered");
return;
}
@@ -108,7 +108,7 @@ public class InstallerServiceImpl implements InstallerService {
info.append(serverDetails.getEndpointSecurePortString());
info.append("\n");
}
- log.info(info.toString());
+ log(info.toString());
return;
}
@@ -136,15 +136,21 @@ public class InstallerServiceImpl implements InstallerService {
ServerDetails detailsFromProps = getServerDetailsFromPropertiesOnly(serverProperties);
ServerDetails detailsFromDb = getServerDetails(dbUrl, dbUsername, clearTextDbPassword,
detailsFromProps.getName());
+ ExistingSchemaOption existingSchemaOption = getAutoinstallExistingSchemaOption(serverProperties);
+
if (detailsFromDb == null) {
- log.info("This will be considered a new server: " + detailsFromProps);
+ log("This will be considered a new server: " + detailsFromProps);
} else {
- log.info("This [" + detailsFromProps + "] will be considered a reinstallation of an existing server ["
- + detailsFromDb + "]");
+ if (existingSchemaOption == ExistingSchemaOption.OVERWRITE) {
+ log("This [" + detailsFromProps + "] will OVERWRITE the existing server [" + detailsFromDb
+ + "] that already exists in the database.");
+ } else {
+ log("This [" + detailsFromProps + "] will be considered a reinstallation of an existing server ["
+ + detailsFromDb + "]");
+ }
}
// just warns if the schema will be overwritten
- ExistingSchemaOption existingSchemaOption = getAutoinstallExistingSchemaOption(serverProperties);
if (existingSchemaOption == ExistingSchemaOption.OVERWRITE) {
log.warn("The installer has been configured to OVERWRITE any existing data in the database. "
+ "If you do install with this configuration, realize that all existing data in the database "
@@ -153,10 +159,10 @@ public class InstallerServiceImpl implements InstallerService {
// just logs the location of the AS instance where RHQ will be installed
String appServerHomeDir = getAppServerHomeDir();
- log.info("The app server where the installation will go is found at: " + appServerHomeDir);
+ log("The app server where the installation will go is found at: " + appServerHomeDir);
// give some message to indicate everything looks OK and the user can start the real install
- log.info("It looks like everything is OK and you can start the installation.");
+ log("It looks like everything is OK and you can start the installation.");
}
@Override
@@ -177,8 +183,12 @@ public class InstallerServiceImpl implements InstallerService {
if (autoInstallMode) {
log("The server is preconfigured and ready for auto-install.");
} else {
- throw new AutoInstallDisabledException(
- "Auto-installation is disabled. Please fully configure rhq-server.properties");
+ if (this.installerConfiguration.isForceInstall()) {
+ log("Auto-installation would have been disabled, but installer was asked to force the install... continuing.");
+ } else {
+ throw new AutoInstallDisabledException(
+ "Auto-installation is disabled. Please fully configure rhq-server.properties");
+ }
}
// make an attempt to connect to the app server - we must make sure its running and we can connect to it
@@ -189,11 +199,21 @@ public class InstallerServiceImpl implements InstallerService {
final String installationResults = getInstallationResults();
if (installationResults != null) {
if (installationResults.length() == 0) {
- throw new AlreadyInstalledException(
- "The installer has already been told to perform its work. The server should be ready soon.");
+ if (this.installerConfiguration.isForceInstall()) {
+ log("The installer appears to have already been told to perform its work, but the installer was asked for force the install... continuing.");
+ } else {
+ throw new AlreadyInstalledException(
+ "The installer has already been told to perform its work. The server should be ready soon.");
+ }
} else {
- throw new Exception("The installer has already attempted to install the server but errors occurred:\n"
- + installationResults);
+ if (this.installerConfiguration.isForceInstall()) {
+ log("The installer is going to force another installation attempt, even though a previous attempt encountered errors:\n"
+ + installationResults);
+ } else {
+ throw new Exception(
+ "The installer has already attempted to install the server but errors occurred:\n"
+ + installationResults);
+ }
}
}
@@ -225,8 +245,12 @@ public class InstallerServiceImpl implements InstallerService {
String existingSchemaOption) throws AutoInstallDisabledException, AlreadyInstalledException, Exception {
if (isEarDeployed()) {
- throw new AlreadyInstalledException(
- "It looks like the installation has already been completed - there is nothing for the installer to do.");
+ if (this.installerConfiguration.isForceInstall()) {
+ log("It looks like the installation has already been completed, but the installer was asked for force the install... continuing.");
+ } else {
+ throw new AlreadyInstalledException(
+ "It looks like the installation has already been completed - there is nothing for the installer to do.");
+ }
}
prepareDatabase(serverProperties, serverDetails, existingSchemaOption);
@@ -930,7 +954,8 @@ public class InstallerServiceImpl implements InstallerService {
// Not only do we want to make sure we can connect, but we also want to wait for the subsystems to initialize.
// Let's wait for one of the subsystems to exist; once we know this is up, the rest are probably ready too.
if (!(new WebJBossASClient(getModelControllerClient()).isWebSubsystem())) {
- throw new IllegalStateException("The server does not appear to be fully started yet");
+ throw new IllegalStateException(
+ "The server does not appear to be fully started yet (the web subsystem did not start)");
}
return retVal;
@@ -1096,8 +1121,13 @@ public class InstallerServiceImpl implements InstallerService {
try {
mcc = getModelControllerClient();
CoreJBossASClient client = new CoreJBossASClient(mcc);
- log("Installing RHQ EAR startup subsystem extension");
- client.addExtension(RHQ_EXTENSION_NAME);
+ boolean isDeployed = client.isExtension(RHQ_EXTENSION_NAME);
+ if (!isDeployed) {
+ log("Installing RHQ EAR startup subsystem extension");
+ client.addExtension(RHQ_EXTENSION_NAME);
+ } else {
+ log("RHQ EAR startup subsystem extension is already deployed");
+ }
} finally {
safeClose(mcc);
}
@@ -1108,8 +1138,13 @@ public class InstallerServiceImpl implements InstallerService {
try {
mcc = getModelControllerClient();
CoreJBossASClient client = new CoreJBossASClient(mcc);
- log("Installing RHQ EAR subsystem");
- client.addSubsystem(RHQ_SUBSYSTEM_NAME);
+ boolean isDeployed = client.isSubsystem(RHQ_SUBSYSTEM_NAME);
+ if (!isDeployed) {
+ log("Installing RHQ EAR subsystem");
+ client.addSubsystem(RHQ_SUBSYSTEM_NAME);
+ } else {
+ log("RHQ EAR subsystem is already deployed");
+ }
} finally {
safeClose(mcc);
}
commit a7172ed168f77a6de4c6eb020666fa142aaa5569
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Feb 14 15:04:35 2013 +0100
The apache integration tests are now resilient against apache servers running on the target machine out of the test control. These will no longer affect the test results.
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 8bc25ca..a7f6697 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
@@ -59,6 +59,10 @@ import org.rhq.core.domain.resource.ResourceType;
*/
public class FakeServerInventory {
+ public interface InventoryStatusJudge {
+ InventoryStatus judge(Resource resource);
+ }
+
private Resource platform;
private Map<String, Resource> resourceStore = new HashMap<String, Resource>();
private int counter;
@@ -77,6 +81,13 @@ public class FakeServerInventory {
}
};
+ private static final Comparator<Resource> RESOURCE_TYPE_AND_STATUS_COMPARATOR = new Comparator<Resource>() {
+ public int compare(Resource o1, Resource o2) {
+ return o1.getResourceType().equals(o2.getResourceType())
+ && o1.getInventoryStatus() == o2.getInventoryStatus() ? 0 : o1.getId() - o2.getId();
+ }
+ };
+
public FakeServerInventory() {
this(false);
}
@@ -86,14 +97,18 @@ public class FakeServerInventory {
}
public synchronized void prepopulateInventory(Resource platform, Collection<Resource> topLevelServers) {
- this.platform = fakePersist(platform, InventoryStatus.COMMITTED, new HashSet<String>());
+ this.platform = fakePersist(platform, getSimpleJudge(InventoryStatus.COMMITTED), new HashSet<String>());
for (Resource res : topLevelServers) {
res.setParentResource(this.platform);
- fakePersist(res, InventoryStatus.COMMITTED, new HashSet<String>());
+ fakePersist(res, getSimpleJudge(InventoryStatus.COMMITTED), new HashSet<String>());
}
}
public synchronized CustomAction mergeInventoryReport(final InventoryStatus requiredInventoryStatus) {
+ return mergeInventoryReport(getSimpleJudge(requiredInventoryStatus));
+ }
+
+ public synchronized CustomAction mergeInventoryReport(final InventoryStatusJudge judge) {
return new CustomAction("updateServerSideInventory") {
public Object invoke(Invocation invocation) throws Throwable {
synchronized (FakeServerInventory.this) {
@@ -102,7 +117,7 @@ public class FakeServerInventory {
InventoryReport inventoryReport = (InventoryReport) invocation.getParameter(0);
for (Resource res : inventoryReport.getAddedRoots()) {
- Resource persisted = fakePersist(res, requiredInventoryStatus, new HashSet<String>());
+ Resource persisted = fakePersist(res, judge, new HashSet<String>());
if (res.getParentResource() == Resource.ROOT) {
platform = persisted;
@@ -265,6 +280,23 @@ public class FakeServerInventory {
}
@SuppressWarnings("serial")
+ public synchronized Set<Resource> findResourcesByTypeAndStatus(final ResourceType type, final InventoryStatus status) {
+ Set<Resource> result = new HashSet<Resource>();
+ if (platform != null) {
+ findResources(platform, new Resource() {
+ public ResourceType getResourceType() {
+ return type;
+ }
+
+ public InventoryStatus getInventoryStatus() {
+ return status;
+ }
+ }, result, RESOURCE_TYPE_AND_STATUS_COMPARATOR);
+ }
+ return result;
+ }
+
+ @SuppressWarnings("serial")
private Set<Resource> getResources(Set<Integer> resourceIds, boolean includeDescendants) {
//it is important to keep the hierarchical order of the resource in the returned set
//so that plugin container can merge the resources from top to bottom.
@@ -301,7 +333,7 @@ public class FakeServerInventory {
}
}
- private Resource fakePersist(Resource agentSideResource, InventoryStatus requiredInventoryStatus,
+ private Resource fakePersist(Resource agentSideResource, InventoryStatusJudge statusJudge,
Set<String> inProgressUUIds) {
Resource persisted = resourceStore.get(agentSideResource.getUuid());
if (!inProgressUUIds.add(agentSideResource.getUuid())) {
@@ -316,6 +348,7 @@ public class FakeServerInventory {
persisted.setUuid(agentSideResource.getUuid());
resourceStore.put(persisted.getUuid(), persisted);
}
+
persisted.setAgent(agentSideResource.getAgent());
persisted.setCurrentAvailability(agentSideResource.getCurrentAvailability());
persisted.setDescription(agentSideResource.getDescription());
@@ -323,13 +356,15 @@ public class FakeServerInventory {
persisted.setPluginConfiguration(agentSideResource.getPluginConfiguration().clone());
persisted.setResourceConfiguration(agentSideResource.getResourceConfiguration().clone());
persisted.setVersion(agentSideResource.getVersion());
- persisted.setInventoryStatus(requiredInventoryStatus);
persisted.setResourceKey(agentSideResource.getResourceKey());
persisted.setResourceType(agentSideResource.getResourceType());
+ InventoryStatus status = statusJudge.judge(persisted);
+ persisted.setInventoryStatus(status);
+
Resource parent = agentSideResource.getParentResource();
if (parent != null && parent != Resource.ROOT) {
- parent = fakePersist(agentSideResource.getParentResource(), requiredInventoryStatus,
+ parent = fakePersist(agentSideResource.getParentResource(), statusJudge,
inProgressUUIds);
persisted.setParentResource(parent);
parent.getChildResources().add(persisted);
@@ -340,7 +375,7 @@ public class FakeServerInventory {
//persist the children
Set<Resource> childResources = new LinkedHashSet<Resource>();
for (Resource child : agentSideResource.getChildResources()) {
- childResources.add(fakePersist(child, requiredInventoryStatus, inProgressUUIds));
+ childResources.add(fakePersist(child, statusJudge, inProgressUUIds));
}
//now update the list with whatever the persisted resource contained in the past
//i.e. we prefer the current results from the agent but keep the children we used to
@@ -398,6 +433,7 @@ public class FakeServerInventory {
children.add(syncChild);
}
+
getPrivateField(clazz, "childSyncInfos").set(ret, children);
return ret;
@@ -444,4 +480,14 @@ public class FakeServerInventory {
}
}
}
+
+ private InventoryStatusJudge getSimpleJudge(final InventoryStatus requiredStatus) {
+ return new InventoryStatusJudge() {
+
+ @Override
+ public InventoryStatus judge(Resource resource) {
+ return requiredStatus;
+ }
+ };
+ }
}
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/augeas/AugeasReferenceLeakingTest.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/augeas/AugeasReferenceLeakingTest.java
index b1c8a24..85d5f52 100644
--- a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/augeas/AugeasReferenceLeakingTest.java
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/augeas/AugeasReferenceLeakingTest.java
@@ -49,6 +49,7 @@ import org.rhq.core.pc.configuration.ConfigurationManager;
import org.rhq.core.pc.inventory.InventoryManager;
import org.rhq.core.pc.inventory.ResourceContainer;
import org.rhq.core.pc.upgrade.FakeServerInventory;
+import org.rhq.plugins.apache.ApacheServerComponent;
import org.rhq.plugins.apache.PluginLocation;
import org.rhq.plugins.apache.setup.ApacheTestConfiguration;
import org.rhq.plugins.apache.setup.ApacheTestSetup;
@@ -58,7 +59,7 @@ import org.rhq.test.pc.PluginContainerSetup;
import org.rhq.test.pc.PluginContainerTest;
/**
- *
+ *
*
* @author Lukas Krejci
*/
@@ -126,13 +127,13 @@ public class AugeasReferenceLeakingTest extends BMNGRunner {
configureApacheServerToUseAugeas();
PluginContainer pc = PluginContainer.getInstance();
- Resource platform = pc.getInventoryManager().getPlatform();
+ Resource apacheServer = findApacheServerResource().getResource();
for (int i = 0; i < configurationReadingInvocationCount; ++i) {
- checkConfigurationRecursively(platform, pc.getConfigurationManager());
+ checkApacheServerConfigurationRecursively(apacheServer, pc.getConfigurationManager());
Thread.sleep(10000);
}
-
+
//wait a couple of seconds for the loadConfig calls to finish
Thread.sleep(60000);
} finally {
@@ -192,14 +193,14 @@ public class AugeasReferenceLeakingTest extends BMNGRunner {
}
}
- private void checkConfigurationRecursively(Resource resource, ConfigurationManager cm)
+ private void checkApacheServerConfigurationRecursively(Resource resource, ConfigurationManager cm)
throws PluginContainerException {
if (resource.getResourceType().getResourceConfigurationDefinition() != null) {
cm.loadResourceConfiguration(resource.getId());
}
for (Resource child : resource.getChildResources()) {
- checkConfigurationRecursively(child, cm);
+ checkApacheServerConfigurationRecursively(child, cm);
}
}
@@ -208,32 +209,36 @@ public class AugeasReferenceLeakingTest extends BMNGRunner {
InventoryManager im = PluginContainer.getInstance().getInventoryManager();
- ResourceContainer apacheServer = findResource(resourceTypes.findByName("Apache HTTP Server"));
+ ResourceContainer apacheServer = findApacheServerResource();
Configuration config = apacheServer.getResourceContext().getPluginConfiguration();
config.getSimple("augeasEnabled").setValue("yes");
im.updatePluginConfiguration(apacheServer.getResource().getId(), config);
-
+
//and run discovery so that the new resources can go into inventory
-
+
im.executeServiceScanImmediately();
}
- private ResourceContainer findResource(ResourceType resourceType) {
+ private ResourceContainer findApacheServerResource() throws Exception {
InventoryManager im = PluginContainer.getInstance().getInventoryManager();
+ ResourceTypes resourceTypes = new ResourceTypes(PluginLocation.APACHE_PLUGIN);
+ ResourceType apacheServerResourceType = resourceTypes.findByName("Apache HTTP Server");
- return findResource(im, resourceType, im.getPlatform());
+ return findApacheServerResource(im, apacheServerResourceType, im.getPlatform());
}
- private ResourceContainer findResource(InventoryManager im, ResourceType rt, Resource root) {
- if (root.getResourceType().equals(rt)) {
+ private ResourceContainer findApacheServerResource(InventoryManager im, ResourceType rt, Resource root) {
+ if (root.getResourceType().equals(rt)
+ && root.getPluginConfiguration().getSimpleValue(ApacheServerComponent.PLUGIN_CONFIG_PROP_SERVER_ROOT)
+ .equals(setup.getDeploymentConfig().serverRoot)) {
return im.getResourceContainer(root);
}
for (Resource child : root.getChildResources()) {
- ResourceContainer rc = findResource(im, rt, child);
+ ResourceContainer rc = findApacheServerResource(im, rt, child);
if (rc != null) {
return rc;
}
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestSetup.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestSetup.java
index 37e74d9..e0363af 100644
--- a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestSetup.java
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestSetup.java
@@ -41,6 +41,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.ResourceType;
import org.rhq.core.pc.ServerServices;
import org.rhq.core.pc.upgrade.FakeServerInventory;
import org.rhq.core.system.SystemInfoFactory;
@@ -257,9 +258,23 @@ public class ApacheTestSetup {
public void addDefaultExceptations(Expectations expectations) throws Exception {
ServerServices ss = PluginContainerTest.getCurrentPluginContainerConfiguration().getServerServices();
+ //only import the apache servers we actually care about - we can't assume another apache won't be present
+ //on the machine running the test...
+ final ResourceType serverResourceType = apacheResourceTypes.findByName("Apache HTTP Server");
expectations.allowing(ss.getDiscoveryServerService()).mergeInventoryReport(
expectations.with(Expectations.any(InventoryReport.class)));
- expectations.will(fakeInventory.mergeInventoryReport(InventoryStatus.COMMITTED));
+ expectations.will(fakeInventory.mergeInventoryReport(new FakeServerInventory.InventoryStatusJudge() {
+ @Override
+ public InventoryStatus judge(Resource resource) {
+ if (serverResourceType.equals(resource.getResourceType())) {
+ return deploymentConfig.serverRoot.equals(resource.getPluginConfiguration().getSimpleValue(
+ ApacheServerComponent.PLUGIN_CONFIG_PROP_SERVER_ROOT)) ? InventoryStatus.COMMITTED
+ : InventoryStatus.IGNORED;
+ } else {
+ return InventoryStatus.COMMITTED;
+ }
+ }
+ }));
expectations.allowing(ss.getDiscoveryServerService()).upgradeResources(
expectations.with(Expectations.any(Set.class)));
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java
index aebea53..719a3dd 100644
--- a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/upgrade/UpgradeTestBase.java
@@ -42,6 +42,7 @@ 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.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceError;
@@ -77,15 +78,15 @@ import org.rhq.test.pc.PluginContainerTest;
public class UpgradeTestBase extends PluginContainerTest {
private static final Log LOG = LogFactory.getLog(UpgradeTestBase.class);
-
+
public enum ResourceKeyFormat {
SNMP, RHQ3, RHQ4
};
-
+
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 ResourceTypes apacheResourceTypes;
protected Resource platform;
@@ -101,15 +102,15 @@ public class UpgradeTestBase extends PluginContainerTest {
apacheResourceTypes);
boolean testFailed = false;
try {
-
+
String[] configFiles = Arrays.copyOf(testConfiguration.apacheConfigurationFiles, testConfiguration.apacheConfigurationFiles.length + 1);
configFiles[testConfiguration.apacheConfigurationFiles.length] = "/snmpd.conf";
-
+
setup.withInventoryFrom(testConfiguration.inventoryFile)
.withPlatformResource(platform).withDefaultExpectations().withDefaultOverrides(testConfiguration.defaultOverrides)
.withApacheSetup().withConfigurationFiles(configFiles)
.withServerRoot(testConfiguration.serverRoot).withExePath(testConfiguration.binPath);
-
+
testConfiguration.beforeTestSetup(setup);
LOG.debug("---------------------------------------------------------- Starting the upgrade test for: "
@@ -117,46 +118,46 @@ public class UpgradeTestBase extends PluginContainerTest {
LOG.debug("Deployment configuration: " + setup.getDeploymentConfig());
setup.setup();
-
+
testConfiguration.beforePluginContainerStart(setup);
-
+
startConfiguredPluginContainer();
-
+
testConfiguration.beforeTests(setup);
-
+
//ok, now we should see the resources upgraded in the fake server inventory.
ResourceType serverResourceType = apacheResourceTypes.findByName("Apache HTTP Server");
ResourceType vhostResourceType = apacheResourceTypes.findByName("Apache Virtual Host");
-
- Set<Resource> servers = setup.getFakeInventory().findResourcesByType(serverResourceType);
+
+ Set<Resource> servers = setup.getFakeInventory().findResourcesByTypeAndStatus(serverResourceType, InventoryStatus.COMMITTED);
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);
-
+
+ Set<Resource> vhosts = setup.getFakeInventory().findResourcesByTypeAndStatus(vhostResourceType, InventoryStatus.COMMITTED);
+
String[] expectedRKs = testConfiguration.getExpectedResourceKeysAfterUpgrade(setup);
-
+
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())) {
@@ -165,21 +166,21 @@ public class UpgradeTestBase extends PluginContainerTest {
}
}
}
-
+
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 {
@@ -213,31 +214,31 @@ public class UpgradeTestBase extends PluginContainerTest {
setup.withApacheSetup().init();
ApacheServerComponent component = setup.withApacheSetup().getServerComponent();
ApacheDirectiveTree config = component.parseRuntimeConfiguration(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) {
+
+ 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);
}
@@ -248,13 +249,13 @@ public class UpgradeTestBase extends PluginContainerTest {
protected static String[] getVHostRKs(ApacheTestSetup 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) {
@@ -264,7 +265,7 @@ public class UpgradeTestBase extends PluginContainerTest {
ret[retIdx] = ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(vhost.serverName, vhost.hosts);
}
}
-
+
for(int i = 0; i < failLen; ++i, ++retIdx) {
String variableName = null;
if (failedUpgrades[i] == 0) {
@@ -280,7 +281,7 @@ public class UpgradeTestBase extends PluginContainerTest {
variableName = "vhost" + failedUpgrades[i] + ".rhq";
}
}
-
+
switch (rkFormat) {
case RHQ3:
variableName += "3.resource.key";
@@ -292,10 +293,10 @@ public class UpgradeTestBase extends PluginContainerTest {
variableName += "snmp.identifier";
break;
}
-
+
ret[retIdx] = replacements.get(variableName);
}
-
+
return ret;
}
@@ -305,7 +306,7 @@ public class UpgradeTestBase extends PluginContainerTest {
.toURL());
PluginMetadataParser parser = new PluginMetadataParser(descriptor,
Collections.<String, PluginMetadataParser> emptyMap());
-
+
List<ResourceType> platformTypes = parser.getAllTypes();
//this is the default container name in case of no plugin explicit plugin configuration, which we don't have.
@@ -317,20 +318,20 @@ public class UpgradeTestBase extends PluginContainerTest {
}
Class discoveryClass = Class.forName(parser.getDiscoveryComponentClass(rt));
-
+
ResourceDiscoveryComponent discoveryComponent = (ResourceDiscoveryComponent) discoveryClass.newInstance();
-
+
ResourceDiscoveryContext context = new ResourceDiscoveryContext(rt, null, null,
SystemInfoFactory.createSystemInfo(), Collections.emptyList(), Collections.emptyList(), containerName,
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());
@@ -339,11 +340,11 @@ public class UpgradeTestBase extends PluginContainerTest {
platform.setResourceType(rt);
platform.setUuid(UUID.randomUUID().toString());
platform.setId(1);
-
+
return platform;
}
}
-
+
return null;
}
@@ -352,12 +353,12 @@ public class UpgradeTestBase extends PluginContainerTest {
if (prefix != null && !prefix.isEmpty()) {
bld.append(prefix).append(".");
}
-
+
bld.append(name);
-
+
return bld.toString();
}
-
+
protected static InetAddress determineLocalhost() {
try {
return InetAddress.getLocalHost();
commit 21a5d14f5577f71245d62456ffabab7e4c647698
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Feb 13 16:11:34 2013 -0500
append to the installer log so we don't lose any installer log messages when rhq-installer.sh is run multiple times
diff --git a/modules/enterprise/server/installer/src/main/resources/logging.properties b/modules/enterprise/server/installer/src/main/resources/logging.properties
index 6a48b2b..0affd97 100644
--- a/modules/enterprise/server/installer/src/main/resources/logging.properties
+++ b/modules/enterprise/server/installer/src/main/resources/logging.properties
@@ -16,8 +16,9 @@ handler.CONSOLE.formatter=PATTERN
# File handler configuration
handler.FILE=org.jboss.logmanager.handlers.FileHandler
handler.FILE.level=${rhq.server.installer.loglevel:DEBUG}
-handler.FILE.properties=autoFlush,fileName
+handler.FILE.properties=autoFlush,append,fileName
handler.FILE.autoFlush=true
+handler.FILE.append=true
handler.FILE.fileName=${rhq.server.installer.logdir:.}/rhq-installer.log
handler.FILE.formatter=PATTERN
commit 842814143212160f2a88f3a83b5ae71eb3a6d506
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Feb 13 20:09:02 2013 +0100
Fix the expectations of the JMock-based apache plugin integration tests
after the fixes in the inventory report processing that changed the workflow
slightly.
This should make the apache integration tests pass again.
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 17beb1e..8bc25ca 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java
@@ -26,6 +26,8 @@ package org.rhq.core.pc.upgrade;
import static org.testng.Assert.fail;
import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
@@ -52,7 +54,7 @@ import org.rhq.core.domain.resource.ResourceType;
/**
* This class represents a server side database store of the inventory for the purposes
* of the ResourceUpgradeTest unit test.
- *
+ *
* @author Lukas Krejci
*/
public class FakeServerInventory {
@@ -62,7 +64,7 @@ public class FakeServerInventory {
private int counter;
private boolean failing;
private boolean failUpgrade;
-
+
private static final Comparator<Resource> ID_COMPARATOR = new Comparator<Resource>() {
public int compare(Resource o1, Resource o2) {
return o1.getId() - o2.getId();
@@ -90,18 +92,18 @@ public class FakeServerInventory {
fakePersist(res, InventoryStatus.COMMITTED, new HashSet<String>());
}
}
-
+
public synchronized CustomAction mergeInventoryReport(final InventoryStatus requiredInventoryStatus) {
return new CustomAction("updateServerSideInventory") {
public Object invoke(Invocation invocation) throws Throwable {
synchronized (FakeServerInventory.this) {
throwIfFailing();
-
+
InventoryReport inventoryReport = (InventoryReport) invocation.getParameter(0);
-
+
for (Resource res : inventoryReport.getAddedRoots()) {
Resource persisted = fakePersist(res, requiredInventoryStatus, new HashSet<String>());
-
+
if (res.getParentResource() == Resource.ROOT) {
platform = persisted;
}
@@ -117,9 +119,9 @@ public class FakeServerInventory {
public Object invoke(Invocation invocation) throws Throwable {
synchronized (FakeServerInventory.this) {
throwIfFailing();
-
+
platform = null;
-
+
return getSyncInfo();
}
}
@@ -131,36 +133,36 @@ public class FakeServerInventory {
public Object invoke(Invocation invocation) throws Throwable {
synchronized(FakeServerInventory.this) {
throwIfFailing();
-
+
ResourceError error = (ResourceError) invocation.getParameter(0);
-
+
Resource serverSideResource = resourceStore.get(error.getResource().getUuid());
-
+
if (serverSideResource != null) {
List<ResourceError> currentErrors = serverSideResource.getResourceErrors();
currentErrors.add(error);
}
-
+
return null;
}
}
};
}
-
+
public synchronized CustomAction upgradeResources() {
return new CustomAction("upgradeServerSideInventory") {
@SuppressWarnings({ "serial", "unchecked" })
public Object invoke(Invocation invocation) throws Throwable {
synchronized(FakeServerInventory.this) {
throwIfFailing();
-
+
if (failUpgrade) {
- throw new RuntimeException("Failing the upgrade purposefully.");
+ throw new RuntimeException("Failing the upgrade purposefully.");
}
-
+
Set<ResourceUpgradeRequest> requests = (Set<ResourceUpgradeRequest>) invocation.getParameter(0);
Set<ResourceUpgradeResponse> responses = new HashSet<ResourceUpgradeResponse>();
-
+
for (final ResourceUpgradeRequest request : requests) {
Resource resource = findResource(platform, new Resource() {
public int getId() {
@@ -174,18 +176,18 @@ public class FakeServerInventory {
if (request.getNewName() != null) {
resource.setName(request.getNewName());
}
-
+
if (request.getNewResourceKey() != null) {
resource.setResourceKey(request.getNewResourceKey());
}
-
+
if (request.getUpgradeErrorMessage() != null) {
ResourceError error = new ResourceError(resource, ResourceErrorType.UPGRADE,
request.getUpgradeErrorMessage(), request.getUpgradeErrorStackTrace(),
request.getTimestamp());
resource.getResourceErrors().add(error);
}
-
+
ResourceUpgradeResponse resp = new ResourceUpgradeResponse();
resp.setResourceId(resource.getId());
resp.setUpgradedResourceName(resource.getName());
@@ -206,16 +208,33 @@ public class FakeServerInventory {
public Object invoke(Invocation invocation) throws Throwable {
synchronized (FakeServerInventory.this) {
throwIfFailing();
-
+
Set<Integer> resourceIds = (Set<Integer>) invocation.getParameter(0);
boolean includeDescendants = (Boolean) invocation.getParameter(1);
-
+
return getResources(resourceIds, includeDescendants);
}
}
};
}
+ public synchronized CustomAction getResourcesAsList() {
+ return new CustomAction("getResourcesAsList") {
+ @Override
+ public Object invoke(Invocation invocation) throws Throwable {
+ synchronized(FakeServerInventory.this) {
+ throwIfFailing();
+
+ Integer[] resourceIds = (Integer[]) invocation.getParameter(0);
+
+ Set<Resource> resources = getResources(new LinkedHashSet<Integer>(Arrays.asList(resourceIds)), false);
+
+ return new ArrayList<Resource>(resources);
+ }
+ }
+ };
+ }
+
public synchronized boolean isFailing() {
return failing;
}
@@ -227,11 +246,11 @@ public class FakeServerInventory {
public synchronized boolean isFailUpgrade() {
return failUpgrade;
}
-
+
public synchronized void setFailUpgrade(boolean failUpgrade) {
this.failUpgrade = failUpgrade;
}
-
+
@SuppressWarnings("serial")
public synchronized Set<Resource> findResourcesByType(final ResourceType type) {
Set<Resource> result = new HashSet<Resource>();
@@ -281,7 +300,7 @@ public class FakeServerInventory {
removeResource(child);
}
}
-
+
private Resource fakePersist(Resource agentSideResource, InventoryStatus requiredInventoryStatus,
Set<String> inProgressUUIds) {
Resource persisted = resourceStore.get(agentSideResource.getUuid());
@@ -327,9 +346,9 @@ public class FakeServerInventory {
//i.e. we prefer the current results from the agent but keep the children we used to
//have in the past. This is the same behavior as the actual RHQ server has.
childResources.addAll(persisted.getChildResources());
-
+
persisted.setChildResources(childResources);
-
+
inProgressUUIds.remove(agentSideResource.getUuid());
return persisted;
diff --git a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestSetup.java b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestSetup.java
index 9f12166..37e74d9 100644
--- a/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestSetup.java
+++ b/modules/integration-tests/apache-plugin-test/src/test/java/org/rhq/plugins/apache/setup/ApacheTestSetup.java
@@ -74,14 +74,14 @@ public class ApacheTestSetup {
private Mockery context;
private ResourceTypes apacheResourceTypes;
private String testId;
-
+
public class ApacheSetup {
private String serverRoot;
private String exePath;
private Collection<String> configurationFiles;
private ApacheExecutionUtil execution;
private boolean deploy = true;
-
+
private ApacheSetup() {
}
@@ -162,16 +162,16 @@ public class ApacheTestSetup {
+ serverRootDir + "'.");
File logsDir = new File(serverRootDir, "logs");
-
+
assertTrue(logsDir.exists(), "The configured server root denotes a directory that doesn't have a 'logs' subdirectory. This is unexpected.");
-
+
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;
@@ -185,11 +185,11 @@ public class ApacheTestSetup {
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
- //the same code the apache server discovery does.
+ //the same code the apache server discovery does.
ApacheDirectiveTree tree = ApacheServerDiscoveryComponent.parseRuntimeConfiguration(confFilePath, null, ApacheBinaryInfo.getInfo(exePath, SystemInfoFactory.createSystemInfo()));
-
+
//XXX this hardcodes apache2 as the only option we have...
HttpdAddressUtility.Address addrToUse = HttpdAddressUtility.APACHE_2_x.getMainServerSampleAddress(tree, null, -1);
pingUrl = addrToUse.toString();
@@ -205,7 +205,7 @@ public class ApacheTestSetup {
}
private void doSetup() throws Exception {
- init();
+ init();
startApache();
}
@@ -228,12 +228,12 @@ public class ApacheTestSetup {
return this;
}
- public ApacheTestSetup withDefaultOverrides(Map<String, String> defaultOverrides) {
+ public ApacheTestSetup withDefaultOverrides(Map<String, String> defaultOverrides) {
this.defaultOverrides = defaultOverrides == null ? new HashMap<String, String>() : defaultOverrides;
deploymentConfig = ApacheDeploymentUtil.getDeploymentConfigurationFromSystemProperties(configurationName, this.defaultOverrides);
return this;
}
-
+
public ApacheTestSetup withPlatformResource(Resource platform) {
this.platform = platform;
return this;
@@ -271,7 +271,7 @@ public class ApacheTestSetup {
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)));
@@ -280,7 +280,7 @@ public class ApacheTestSetup {
expectations.allowing(ss.getDiscoveryServerService()).clearResourceConfigError(
expectations.with(Expectations.any(int.class)));
-
+
expectations.allowing(ss.getDiscoveryServerService()).setResourceEnablement(
expectations.with(Expectations.any(int.class)), expectations.with(Expectations.any(boolean.class)));
@@ -289,7 +289,10 @@ public class ApacheTestSetup {
expectations.allowing(ss.getDriftServerService()).getDriftDefinitions(expectations.with(Expectations.any(Set.class)));
expectations.will(Expectations.returnValue(Collections.emptyMap()));
-
+
+ expectations.allowing(ss.getDiscoveryServerService()).getResourcesAsList(expectations.with(Expectations.any(Integer[].class)));
+ expectations.will(fakeInventory.getResourcesAsList());
+
expectations.ignoring(ss.getBundleServerService());
expectations.ignoring(ss.getConfigurationServerService());
expectations.ignoring(ss.getContentServerService());
@@ -307,14 +310,14 @@ public class ApacheTestSetup {
public DeploymentConfig getDeploymentConfig() {
return deploymentConfig;
}
-
+
public ApacheTestSetup setup() throws Exception {
apacheSetup.doSetup();
- Map<String, String> replacements = deploymentConfig.getTokenReplacements();
+ Map<String, String> replacements = deploymentConfig.getTokenReplacements();
replacements.put("server.root", apacheSetup.serverRoot);
replacements.put("exe.path", apacheSetup.exePath);
-
+
ApacheDeploymentUtil.addDefaultVariables(replacements, null);
HttpdAddressUtility addressUtility = apacheSetup.getServerComponent()
@@ -325,18 +328,18 @@ public class ApacheTestSetup {
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(
@@ -348,7 +351,7 @@ public class ApacheTestSetup {
"vhost2.snmp.identifier",
addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost2.hosts.get(0),
vhost2.serverName).toString(false, false));
-
+
replacements.put(
"vhost2.rhq4.resource.key",
ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(
@@ -360,7 +363,7 @@ public class ApacheTestSetup {
"vhost3.snmp.identifier",
addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost3.hosts.get(0),
vhost3.serverName).toString(false, false));
-
+
replacements.put(
"vhost3.rhq4.resource.key",
ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(
@@ -372,7 +375,7 @@ public class ApacheTestSetup {
"vhost4.snmp.identifier",
addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost4.hosts.get(0),
vhost4.serverName).toString(false, false));
-
+
replacements.put(
"vhost4.rhq4.resource.key",
ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(
@@ -381,35 +384,35 @@ public class ApacheTestSetup {
//let the user override everything we just did
replacements.putAll(defaultOverrides);
-
+
inventoryFileReplacements = replacements;
-
+
if (inventoryFile != null) {
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
+
+ //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.
- *
+ * 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);
commit 955ef8974d5c8782c048704550ad8da395365e93
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Feb 13 11:51:45 2013 -0500
Fix issues in mergeAvailabilityReport "repair code". This is code that
attempts to fix problems in the Availability records, if they somehow get
corrupted. In general, it doesn't execute. But if and when it did, it
wasn't repairing things as well as it could. This makes improvements.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java
index 2946d40..0181d7a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java
@@ -591,52 +591,13 @@ public class AvailabilityManagerBean implements AvailabilityManagerLocal, Availa
// availability reports only tell us the current state at the start time; end time is ignored/must be null
reported.setEndTime(null);
- try {
- q.setParameter("resourceId", reported.getResource().getId());
- Availability latest = (Availability) q.getSingleResult();
- AvailabilityType latestType = latest.getAvailabilityType();
- AvailabilityType reportedType = reported.getAvailabilityType();
-
- // If the current avail is DISABLED, and this report is not trying to re-enable the resource,
- // Then ignore the reported avail.
- if (AvailabilityType.DISABLED == latestType) {
- if (!(mergeInfo.isEnablementReport() && (AvailabilityType.UNKNOWN == reportedType))) {
- disabledAvailabilities.add(reported);
- continue;
- }
- }
-
- if (reported.getStartTime() >= latest.getStartTime()) {
- //log.info( "new avail (latest/reported)-->" + latest + "/" + reported );
-
- // the new availability data is for a time after our last known state change
- // we are run-length encoded, so only persist data if the availability changed
- if (latest.getAvailabilityType() != reported.getAvailabilityType()) {
- entityManager.persist(reported);
- mergeInfo.incrementNumInserted();
-
- latest.setEndTime(reported.getStartTime());
- latest = entityManager.merge(latest);
-
- updateResourceAvailability(reported);
- }
-
- // our last known state was unknown, ask for a full report to ensure we are in sync with agent
- if (latest.getAvailabilityType() == AvailabilityType.UNKNOWN) {
- mergeInfo.setAskForFullReport(true);
- }
- } else {
- //log.info( "past avail (latest/reported)==>" + latest + "/" + reported );
+ // get the latest avail for the reported resource
+ q.setParameter("resourceId", reported.getResource().getId());
+ Availability latest = null;
- // The new data is for a time in the past, probably an agent sending a report after
- // a network outage has been corrected but after we have already backfilled.
- // We need to insert it into our past timeline.
- insertAvailability(reported);
- mergeInfo.incrementNumInserted();
+ try {
+ latest = (Availability) q.getSingleResult();
- // this is an unusual report - ask the agent for a full report so as to ensure we are in sync with agent
- mergeInfo.setAskForFullReport(true);
- }
} catch (NoResultException nre) {
// This should not happen unless the Resource in the report is stale, which can happen in certain
// sync scenarios. A Resource is given its initial Availability/ResourceAvailability when it is
@@ -644,37 +605,47 @@ public class AvailabilityManagerBean implements AvailabilityManagerLocal, Availa
// it must not exist in my utopian view of the world. Let's just make sure...
Resource attachedResource = (Resource) entityManager.find(Resource.class, reported.getResource()
.getId());
- if (null == attachedResource) {
+
+ if ((null == attachedResource) || (InventoryStatus.COMMITTED != attachedResource.getInventoryStatus())) {
// expected case
log.info("Skipping mergeAvailabilityReport() for stale resource [" + reported.getResource()
+ "]. These messages should go away after the next agent synchronization with the server.");
- } else if (InventoryStatus.COMMITTED == attachedResource.getInventoryStatus()) {
- // this should not happen, it means the resource exists but has no latest Availability
- // record (i.e. sendTime == null). Try to correct the situation.
+ continue;
+
+ } else {
+ // this should not really happen but is possible in rare failure situations, it means the resource
+ // exists but has no latest Availability record (i.e. sendTime == null). Correct the situation and
+ // then process the reported avail.
log.warn("Resource [" + reported.getResource()
+ "] has no latest availability record (i.e. no endtime) - will attempt to repair.\n"
+ mergeInfo.toString(false));
+
try {
List<Availability> attachedAvails = attachedResource.getAvailability();
+ Availability attachedLastAvail = null;
+
if (attachedAvails.isEmpty()) {
- attachedResource.initCurrentAvailability();
- entityManager.merge(attachedResource);
+ latest = new Availability(attachedResource, 0L, AvailabilityType.UNKNOWN);
+ entityManager.persist(latest);
} else {
- Availability attachedLastAvail = attachedAvails.get(attachedAvails.size() - 1);
- attachedLastAvail.setEndTime(null);
- entityManager.merge(attachedLastAvail);
+ latest = attachedAvails.get(attachedAvails.size() - 1);
+ latest.setEndTime(null);
+ latest = entityManager.merge(latest);
}
+ updateResourceAvailability(latest);
+
// ask the agent for a full report so as to ensure we are in sync with agent
mergeInfo.setAskForFullReport(true);
} catch (Throwable t) {
- log.warn("Unable to repair latest availablity for Resource [" + reported.getResource() + "]", t);
+ log.warn("Unable to repair NoResult latest availablity for Resource [" + reported.getResource()
+ + "]", t);
+ continue;
}
}
-
} catch (NonUniqueResultException nure) {
// This condition should never happen. In my world of la-la land, I've done everything
// correctly so this never happens. But, due to the asynchronous nature of things,
@@ -686,15 +657,69 @@ public class AvailabilityManagerBean implements AvailabilityManagerLocal, Availa
log.warn("Resource [" + reported.getResource() + "] has multiple availabilities without an endtime ["
+ nure.getMessage() + "] - will attempt to remove the extra ones\n" + mergeInfo.toString(false));
- q.setParameter("resourceId", reported.getResource().getId());
- List<Availability> latest = q.getResultList();
+ try {
+
+ List<Availability> latestList = q.getResultList();
+
+ // delete all but the last one (our query sorts in ASC start time order)
+ int latestCount = latestList.size();
+ for (int i = 0; i < (latestCount - 1); i++) {
+ entityManager.remove(latestList.get(i));
+ }
+
+ latest = latestList.get(latestCount - 1);
+ updateResourceAvailability(latest);
+
+ // this is an unusual report - ask the agent for a full report so as to ensure we are in sync with agent
+ mergeInfo.setAskForFullReport(true);
+
+ } catch (Throwable t) {
+ log.warn(
+ "Unable to repair NonUnique Result latest availablity for Resource [" + reported.getResource()
+ + "]", t);
+ continue;
+ }
+ }
+
+ AvailabilityType latestType = latest.getAvailabilityType();
+ AvailabilityType reportedType = reported.getAvailabilityType();
- // delete all but the last one (our query sorts in ASC start time order)
- int latestCount = latest.size();
- for (int i = 0; i < (latestCount - 1); i++) {
- entityManager.remove(latest.get(i));
+ // If the current avail is DISABLED, and this report is not trying to re-enable the resource,
+ // Then ignore the reported avail.
+ if (AvailabilityType.DISABLED == latestType) {
+ if (!(mergeInfo.isEnablementReport() && (AvailabilityType.UNKNOWN == reportedType))) {
+ disabledAvailabilities.add(reported);
+ continue;
}
- updateResourceAvailability(latest.get(latestCount - 1));
+ }
+
+ if (reported.getStartTime() >= latest.getStartTime()) {
+ //log.info( "new avail (latest/reported)-->" + latest + "/" + reported );
+
+ // the new availability data is for a time after our last known state change
+ // we are run-length encoded, so only persist data if the availability changed
+ if (latest.getAvailabilityType() != reported.getAvailabilityType()) {
+ entityManager.persist(reported);
+ mergeInfo.incrementNumInserted();
+
+ latest.setEndTime(reported.getStartTime());
+ latest = entityManager.merge(latest);
+
+ updateResourceAvailability(reported);
+ }
+
+ // our last known state was unknown, ask for a full report to ensure we are in sync with agent
+ if (latest.getAvailabilityType() == AvailabilityType.UNKNOWN) {
+ mergeInfo.setAskForFullReport(true);
+ }
+ } else {
+ //log.info( "past avail (latest/reported)==>" + latest + "/" + reported );
+
+ // The new data is for a time in the past, probably an agent sending a report after
+ // a network outage has been corrected but after we have already backfilled.
+ // We need to insert it into our past timeline.
+ insertAvailability(reported);
+ mergeInfo.incrementNumInserted();
// this is an unusual report - ask the agent for a full report so as to ensure we are in sync with agent
mergeInfo.setAskForFullReport(true);
commit ae56056671aba575d8b3c2c9064497bacfe00661
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Feb 13 09:22:40 2013 -0500
Fix test given slight change in avail behavior. In commit c516ad09fcebcedfd1a505d6bfd434997ac6642d
we stopped kicking off an immediate avail scan when new resources were discovered,
simplifying the code, and approach, to just wait for the next scheduled scan,
which likely occurs nearly as fast. From the test's perspective this meant one
resource, the platform, had its avail change at a slightly different time.
diff --git a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/avail/AvailTest.java b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/avail/AvailTest.java
index 005e900..956fb97 100644
--- a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/avail/AvailTest.java
+++ b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/avail/AvailTest.java
@@ -24,13 +24,13 @@ import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.pc.PluginContainer;
-import org.rhq.plugins.test.avail.AvailDiscoveryComponent;
-import org.rhq.plugins.test.avail.AvailResourceComponent;
import org.rhq.core.pc.inventory.AvailabilityExecutor;
import org.rhq.core.pc.inventory.AvailabilityExecutor.Scan;
import org.rhq.core.pc.inventory.ForceAvailabilityExecutor;
import org.rhq.core.pc.inventory.ResourceContainer;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.plugins.test.avail.AvailDiscoveryComponent;
+import org.rhq.plugins.test.avail.AvailResourceComponent;
import org.rhq.test.arquillian.AfterDiscovery;
import org.rhq.test.arquillian.BeforeDiscovery;
import org.rhq.test.arquillian.FakeServerInventory;
@@ -184,7 +184,7 @@ public class AvailTest extends Arquillian {
Assert.assertEquals(datum.getAvailabilityType(), AvailabilityType.UP, "should be UP at the start");
}
AvailabilityExecutor.Scan scan = executor.getMostRecentScanHistory();
- assertScan(scan, true, true, 29, 28, 29, 28, 0, 0);
+ assertScan(scan, true, true, 29, 29, 29, 28, 0, 0);
// do a forced avail check again - nothing changed, so we should have an empty report
report = executor.call();
@@ -514,7 +514,7 @@ public class AvailTest extends Arquillian {
Assert.assertEquals(scan.getNumResources(), numResources,
"Unexpected numResources, remember to include the implied platform?");
Assert.assertEquals(scan.getNumAvailabilityChanges(), numChanges,
- "Unexpected numChanges, remember to omit the implied platform");
+ "Unexpected numChanges, remember to include the implied platform");
Assert.assertEquals(scan.getNumGetAvailabilityCalls(), numCalls,
"Unexpected numGetAvailCalls, remember to include the implied platform");
Assert.assertEquals(scan.getNumScheduledRandomly(), numSched,
commit d5acca52875c8aabcf784bf512fc63f1ebab373a
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Feb 12 17:20:00 2013 -0500
To maintain the test dep ordering, which is sometimes important, and definitel
is important here, move all of the test deps to the new test.dependencies profile.
diff --git a/modules/enterprise/server/itests-2/pom.xml b/modules/enterprise/server/itests-2/pom.xml
index d5daa17..5961627 100644
--- a/modules/enterprise/server/itests-2/pom.xml
+++ b/modules/enterprise/server/itests-2/pom.xml
@@ -35,144 +35,7 @@
</properties>
<dependencies>
- <!--================ Test Deps ================ -->
-
- <!-- Note, the test dep ordering can be important. Maven orders the [test] classpath in the order listed in the pom. -->
- <dependency>
- <groupId>org.jboss.as</groupId>
- <artifactId>jboss-as-dist</artifactId>
- <type>zip</type>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.spec</groupId>
- <artifactId>jboss-javaee-6.0</artifactId>
- <version>${jboss.javaee6.spec.version}</version>
- <scope>provided</scope>
- <type>pom</type>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.arquillian.testng</groupId>
- <artifactId>arquillian-testng-container</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.shrinkwrap.resolver</groupId>
- <artifactId>shrinkwrap-resolver-depchain</artifactId>
- <type>pom</type>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.arquillian.protocol</groupId>
- <artifactId>arquillian-protocol-servlet</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-arquillian-suite-extension</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-domain</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-enterprise-server</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-script-bindings</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-server-client-api</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>rhq-serverplugin-drift</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>test-utils</artifactId>
- <version>${project.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- </exclusion>
- </exclusions>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.rhq.helpers</groupId>
- <artifactId>perftest-support</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-entitymanager</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-testng</artifactId>
- <version>${powermock.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito</artifactId>
- <version>${powermock.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.opensymphony.quartz</groupId>
- <artifactId>quartz</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.liquibase</groupId>
- <artifactId>liquibase-core</artifactId>
- <version>${liquibase.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>joda-time</groupId>
- <artifactId>joda-time</artifactId>
- <version>2.1</version>
- <scope>test</scope>
- </dependency>
+ <!-- see the test.dependencies profile below -->
</dependencies>
<build>
@@ -669,46 +532,183 @@
<profiles>
- <profile>
- <!--
- This profile has been created to avoid unnecessary resolution of test dependencies during a build that
- does not run, compile or need tests.
- More test dependencies are to be moved here if the set of sub-dependencies is complex, references project
- test jars, or conflicts with changing the container version.
- -->
- <id>test.dependencies</id>
- <activation>
- <property>
- <name>maven.test.skip</name>
- <value>!true</value>
- </property>
- </activation>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>rhq-core-client-api</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.as</groupId>
- <artifactId>jboss-as-arquillian-container-managed</artifactId>
- <version>${jboss.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>rhq-core-domain</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- </dependencies>
- </profile>
+ <profile>
+ <!-- This profile has been created to avoid unnecessary resolution of test dependencies during a build that does not
+ run, compile or need tests. There are product build dependencies on this profile, don't remove. -->
+
+ <id>test.dependencies</id>
+ <activation>
+ <property>
+ <name>maven.test.skip</name>
+ <value>!true</value>
+ </property>
+ </activation>
+
+
+ <dependencies>
+ <!-- Note, the test dep ordering can be important. Maven orders the [test] classpath in the order listed in the pom. -->
+
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-dist</artifactId>
+ <type>zip</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.spec</groupId>
+ <artifactId>jboss-javaee-6.0</artifactId>
+ <version>${jboss.javaee6.spec.version}</version>
+ <scope>provided</scope>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-arquillian-container-managed</artifactId>
+ <version>${jboss.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian.testng</groupId>
+ <artifactId>arquillian-testng-container</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-depchain</artifactId>
+ <type>pom</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian.protocol</groupId>
+ <artifactId>arquillian-protocol-servlet</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-arquillian-suite-extension</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-domain</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-core-domain</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-enterprise-server</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-script-bindings</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-server-client-api</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-serverplugin-drift</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-core-client-api</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>test-utils</artifactId>
+ <version>${project.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ </exclusion>
+ </exclusions>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq.helpers</groupId>
+ <artifactId>perftest-support</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-testng</artifactId>
+ <version>${powermock.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ <version>${powermock.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.opensymphony.quartz</groupId>
+ <artifactId>quartz</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.liquibase</groupId>
+ <artifactId>liquibase-core</artifactId>
+ <version>${liquibase.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>joda-time</groupId>
+ <artifactId>joda-time</artifactId>
+ <version>2.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+ </profile>
<!-- If testing against oracle, override the default property settings -->
<profile>
commit 0057e40c03683899f3cc454a9958aba188984d03
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Feb 12 15:48:32 2013 -0500
Fix a transactioning issue with agent backfill. It was possible for the Agent to
be marked backfilled in one transaction yet have the actual avail changes fail
in a second transaction, leaving the dead agent and its children with UP avail
and no longer eligible for backfill due to the flag being set.
Additionally, avoid large transactions if many agents need to be backfilled
sumultaneously.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerBean.java
index 29c3ad3..d01dbd0 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerBean.java
@@ -192,7 +192,7 @@ public class AgentManagerBean implements AgentManagerLocal {
server_bootstrap.removeDownedAgent(downedAgent.getRemoteEndpoint());
log.info("Agent with name [" + agentName + "] just went down");
- agentManager.backfillAgent(subjectManager.getOverlord(), agentName, downedAgent.getId());
+ agentManager.backfillAgentInNewTransaction(subjectManager.getOverlord(), agentName, downedAgent.getId());
return;
}
@@ -272,7 +272,8 @@ public class AgentManagerBean implements AgentManagerLocal {
log.info("Have not heard from agent [" + record.getAgentName() + "] since ["
+ new Date(record.getLastAvailabilityPing()) + "]. Will be backfilled since we suspect it is down");
- agentManager.backfillAgent(subjectManager.getOverlord(), record.getAgentName(), record.getAgentId());
+ agentManager.backfillAgentInNewTransaction(subjectManager.getOverlord(), record.getAgentName(),
+ record.getAgentId());
}
}
@@ -281,7 +282,8 @@ public class AgentManagerBean implements AgentManagerLocal {
return;
}
- public void backfillAgent(Subject subject, String agentName, int agentId) {
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public void backfillAgentInNewTransaction(Subject subject, String agentName, int agentId) {
// make sure we lock out all processing of any availability reports that might come our way to avoid concurrency
// problems
AvailabilityReportSerializer.getSingleton().lock(agentName);
@@ -299,7 +301,6 @@ public class AgentManagerBean implements AgentManagerLocal {
}
}
- @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void setAgentBackfilled(int agentId, boolean backfilled) {
Query query = entityManager.createNamedQuery(Agent.QUERY_SET_AGENT_BACKFILLED);
query.setParameter("agentId", agentId);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerLocal.java
index 6cb50f2..842d5d8 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerLocal.java
@@ -45,15 +45,16 @@ import org.rhq.enterprise.server.agentclient.AgentClient;
public interface AgentManagerLocal {
/**
- * Call this method to set the agent down and mark it 'backfilled'. Also, sets all of its monitored resources
- * to an UNKNOWN avail state since the agent is no longer reporting availability.
+ * Call this method to set the agent DOWN and mark it 'backfilled'. Also, sets all of its monitored resources
+ * to an UNKNOWN avail state since the agent is no longer reporting availability. Done in its own transaction to
+ * avoid large transactions if many agents are simultaneously backfilled.
*
* @param subject
* @param agentName
* @param agentId
*/
// This method should not be remoted.
- void backfillAgent(Subject subject, String agentName, int agentId);
+ void backfillAgentInNewTransaction(Subject subject, String agentName, int agentId);
/**
* Persists a new agent.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java
index d92cbc4..2946d40 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java
@@ -749,7 +749,6 @@ public class AvailabilityManagerBean implements AvailabilityManagerLocal, Availa
}
@SuppressWarnings("unchecked")
- @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void updateAgentResourceAvailabilities(int agentId, AvailabilityType platformAvailType,
AvailabilityType childAvailType) {