modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/AbstractBundleType.java
| 4
modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/type/AbstractBundleTypeTest.java
| 26 -
modules/common/jboss-as/src/test/java/com/jboss/jbossnetwork/product/jbpm/handlers/test/CompareDigestActionHandlerTest.java
| 52 +--
modules/core/dbutils/src/main/scripts/dbsetup/measurement-schema.xml
| 4
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
| 17
modules/core/domain/src/main/java/org/rhq/core/domain/measurement/Availability.java
| 12
modules/core/domain/src/main/java/org/rhq/core/domain/measurement/ResourceAvailability.java
| 14
modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
| 3
modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/AgentTest.java
| 86 ++---
modules/core/plugin-container/src/test/java/org/rhq/core/pc/bundle/BundleManagerTest.java
| 21 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java
| 27 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
| 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerRemote.java
| 3
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java
| 172 +++++-----
14 files changed, 241 insertions(+), 202 deletions(-)
New commits:
commit 554e32cbb896e21d17501104e6c84390e1353dd6
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Feb 27 10:39:23 2012 -0500
Fix issues in Availability and AvailabilityPoint handing and
generation by working in full support for UNKNOWN and DISABLED avail types.
- Handle perPointMillis "division remainder" issue in avail point
calculation.
- Make Availability.availabilityPoint not nullable. The UNKNOWN enum
should now be used/persisted.
- Make ResourceAvailability.availabilityPoint not nullable. The UNKNOWN enum
should now be used/persisted.
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/measurement-schema.xml
b/modules/core/dbutils/src/main/scripts/dbsetup/measurement-schema.xml
index bb57378..fecb046 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/measurement-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/measurement-schema.xml
@@ -187,7 +187,7 @@
<column name="RESOURCE_ID" type="INTEGER"
required="true" references="RHQ_RESOURCE(ID)"/>
<column name="START_TIME" type="LONG"
required="true" />
<column name="END_TIME" type="LONG"
required="false" />
- <column name="AVAILABILITY_TYPE" type="SMALLINT"
required="false" />
+ <column name="AVAILABILITY_TYPE" type="SMALLINT"
required="true" />
<index name="RHQ_AVAIL_RESOURCE_START_IDX">
<field ref="RESOURCE_ID"/>
<field ref="START_TIME"/>
@@ -202,7 +202,7 @@
<table name="RHQ_RESOURCE_AVAIL">
<column name="ID" type="INTEGER"
default="sequence-only" initial="10001" primarykey="true"
required="true"/>
<column name="RESOURCE_ID" type="INTEGER"
required="true" references="RHQ_RESOURCE(ID)"
ondelete="cascade"/>
- <column name="AVAILABILITY_TYPE" type="SMALLINT"
required="false" />
+ <column name="AVAILABILITY_TYPE" type="SMALLINT"
required="true" />
<index name="RHQ_RESOURCE_AVAIL_IDX">
<field ref="RESOURCE_ID" />
</index>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index b7229c2..82befc8 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3983,6 +3983,23 @@
WHERE PROPERTY_KEY = 'AGENT_MAX_QUIET_TIME_ALLOWED'
</statement>
</schema-directSQL>
+
+ <!-- set null availabilities to UNKNOWN -->
+ <schema-directSQL>
+ <statement desc="Changing NULL
RHQ_AVAILABILITY.AVAILABILITY_TYPE to UNKNOWN">
+ UPDATE RHQ_AVAILABILITY
+ SET AVAILABILITY_TYPE = 2
+ WHERE AVAILABILITY_TYPE IS NULL
+ </statement>
+ <statement desc="Changing NULL
RHQ_RESOURCE_AVAIL.AVAILABILITY_TYPE to UNKNOWN">
+ UPDATE RHQ_RESOURCE_AVAIL
+ SET AVAILABILITY_TYPE = 2
+ WHERE AVAILABILITY_TYPE IS NULL
+ </statement>
+ <schema-alterColumn table="RHQ_AVAILABILITY"
column="AVAILABILITY_TYPE" nullable="FALSE"/>
+ <schema-alterColumn table="RHQ_RESOURCE_AVAIL"
column="AVAILABILITY_TYPE" nullable="FALSE"/>
+ </schema-directSQL>
+
</schemaSpec>
</dbupgrade>
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/measurement/Availability.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/measurement/Availability.java
index cc4fb1a..ec45e77 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/measurement/Availability.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/measurement/Availability.java
@@ -170,7 +170,7 @@ public class Availability implements Serializable {
/**
* Availability state for this time period
*/
- @Column(name = "AVAILABILITY_TYPE", nullable = true)
+ @Column(name = "AVAILABILITY_TYPE", nullable = false)
@Enumerated(EnumType.ORDINAL)
private AvailabilityType availabilityType;
@@ -230,20 +230,10 @@ public class Availability implements Serializable {
this.endTime = (endTime != null) ? endTime.getTime() : null;
}
- /**
- * Indicates the availability status as either UP or DOWN; if
<code>null</code> is returned, the status is unknown.
- *
- * @return availability status
- */
public AvailabilityType getAvailabilityType() {
return availabilityType;
}
- /**
- * Sets the availability status. This can be <code>null</code> to
indicate an "unknown" availability status.
- *
- * @param availabilityType
- */
public void setAvailabilityType(AvailabilityType availabilityType) {
this.availabilityType = availabilityType;
}
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/measurement/ResourceAvailability.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/measurement/ResourceAvailability.java
index efc00e5..e541b18 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/measurement/ResourceAvailability.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/measurement/ResourceAvailability.java
@@ -107,7 +107,7 @@ public class ResourceAvailability implements Serializable {
/**
* Availability state for this time period
*/
- @Column(name = "AVAILABILITY_TYPE", nullable = true)
+ @Column(name = "AVAILABILITY_TYPE", nullable = false)
@Enumerated(EnumType.ORDINAL)
private AvailabilityType availabilityType;
@@ -116,8 +116,7 @@ public class ResourceAvailability implements Serializable {
}
/**
- * Constructor for {@link ResourceAvailability}. If <code>type</code> is
<code>null</code>, it will be
- * considered unknown.
+ * Constructor for {@link ResourceAvailability}.
*
* @param resource
* @param type
@@ -137,19 +136,12 @@ public class ResourceAvailability implements Serializable {
}
/**
- * Indicates the availability status as either UP or DOWN; if
<code>null</code> is returned, the status is unknown.
- *
- * @return availability status
+ * @return availability type
*/
public AvailabilityType getAvailabilityType() {
return availabilityType;
}
- /**
- * Sets the availability status. This can be <code>null</code> to
indicate an "unknown" availability status.
- *
- * @param availabilityType
- */
public void setAvailabilityType(AvailabilityType availabilityType) {
this.availabilityType = availabilityType;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
index e920c51..e0de35a 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
@@ -72,6 +72,7 @@ import org.rhq.core.domain.dashboard.Dashboard;
import org.rhq.core.domain.drift.DriftDefinition;
import org.rhq.core.domain.event.EventSource;
import org.rhq.core.domain.measurement.Availability;
+import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.MeasurementSchedule;
import org.rhq.core.domain.measurement.ResourceAvailability;
import org.rhq.core.domain.operation.ResourceOperationHistory;
@@ -1867,7 +1868,7 @@ public class Resource implements Comparable<Resource>,
Serializable {
// this should only ever be called once, during initial persistence
public void initCurrentAvailability() {
if (this.currentAvailability == null) {
- this.currentAvailability = new ResourceAvailability(this, null);
+ this.currentAvailability = new ResourceAvailability(this,
AvailabilityType.UNKNOWN);
}
}
}
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 782cd6c..6857aef 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
@@ -132,7 +132,7 @@ public class AvailabilityManagerBean implements
AvailabilityManagerLocal, Availa
log.warn("Could not query for latest avail but found one - missing
null end time (this should never happen)");
retAvailability = availList.get(availList.size() - 1);
} else {
- retAvailability = new Availability(resource, new Date(), null);
+ retAvailability = new Availability(resource, new Date(),
AvailabilityType.UNKNOWN);
}
}
@@ -281,7 +281,7 @@ public class AvailabilityManagerBean implements
AvailabilityManagerLocal, Availa
// end the data point
if (currentAvailability.getAvailabilityType() == null) {
- // we are on the edge of the range, the null avail type means we have
an unknown period for
+ // we are on the edge of the range, the null avail type indicates a
surrogate for
// this data point. Be pessimistic, if we have had any down time,
set to down, then disabled,
// then up, and finally unknown.
if (hasDownPeriods) {
@@ -343,13 +343,28 @@ public class AvailabilityManagerBean implements
AvailabilityManagerLocal, Availa
currentTime = dataPointStartBarrier;
dataPointStartBarrier -= perPointMillis;
+ // the division determing perPointMillis drops the remainder, which may
leave us slightly short.
+ // if we go negative, we're done.
+ if (dataPointStartBarrier < 0) {
+ break;
+ }
+
} else { // the end of the availability record comes first, in the middle of
a data point
- // if the resource has been up in the current time frame, bump up the
counter
- if (currentAvailability.getAvailabilityType() == AvailabilityType.UP) {
+ switch (currentAvailability.getAvailabilityType()) {
+ case UP:
+ // if the resource has been up in the current time frame, bump up the
counter
timeUpInDataPoint += currentTime - availabilityStartBarrier;
- } else if (currentAvailability.getAvailabilityType() ==
AvailabilityType.DOWN) {
+ break;
+ case DOWN:
hasDownPeriods = true;
+ break;
+ case DISABLED:
+ hasDisabledPeriods = true;
+ break;
+ case UNKNOWN:
+ default:
+ hasUnknownPeriods = true;
}
// move to the previous availability record
@@ -492,7 +507,7 @@ public class AvailabilityManagerBean implements
AvailabilityManagerLocal, Availa
}
// our last known state was unknown, ask for a full report to
ensure we are in sync with agent
- if (latest.getAvailabilityType() == null) {
+ if (latest.getAvailabilityType() == AvailabilityType.UNKNOWN) {
askForFullReport = true;
}
} else {
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 90cc92a..d7ad462 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
@@ -2328,7 +2328,7 @@ public class ResourceManagerBean implements ResourceManagerLocal,
ResourceManage
public ResourceAvailability getLiveResourceAvailability(Subject subject, int
resourceId) {
Resource res = getResourceById(subject, resourceId);
- ResourceAvailability results = new ResourceAvailability(res, null);
+ ResourceAvailability results = new ResourceAvailability(res,
AvailabilityType.UNKNOWN);
try {
Agent agent = res.getAgent();
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerRemote.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerRemote.java
index d0c6c6d..6ced734 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerRemote.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerRemote.java
@@ -59,7 +59,8 @@ public interface ResourceManagerRemote {
* @param resourceId the id of a {@link Resource} in inventory.
*
* @return the resource availability - note that if the encapsulated availability
type is <code>null</code>,
- * the resource availability is UNKNOWN.
+ * the resource availability is UNKNOWN. As of RHQ 4.4 this does not return
null but rather
+ * {@link AvailabilityType.UNKNOWN}.
*
* @throws FetchException if the resource represented by the resourceId parameter
does not exist, or if the
* passed subject does not have permission to view this
resource.
commit 742c485f95a2f24cae46eea3e79b56c83050bc06
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Feb 27 10:36:18 2012 -0500
Fix unit tests given that:
0) backfilling is now based on ping time
1) backfilling now sets children avail to unknown
3) down is no longer used to represent unknown in avail points
Enhance unit testing with use of DISABLED and UNKNOWN states, as well as
enablement reporting.
diff --git
a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java
b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java
index f816e20..6abc6ca 100644
---
a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java
+++
b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java
@@ -56,7 +56,7 @@ import org.rhq.enterprise.server.util.LookupUtil;
* @author John Mazzitelli
*/
public class AvailabilityManagerTest extends AbstractEJB3Test {
- // private static final boolean ENABLE_TESTS = false;
+ private static final boolean ENABLE_TESTS = true;
private static final AvailabilityType UP = AvailabilityType.UP;
private static final AvailabilityType DOWN = AvailabilityType.DOWN;
@@ -147,7 +147,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
}
@SuppressWarnings("unchecked")
- @Test(enabled = true)
+ @Test(enabled = ENABLE_TESTS)
public void testInsertPastAvailabilities() throws Exception {
Date now = new Date();
Date middle = new Date(now.getTime() - 30000); // 30s ago
@@ -159,13 +159,13 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
setupResource(em);
commitAndClose(em);
- Availability aThen = new Availability(theResource, then,
AvailabilityType.UP);
+ Availability aThen = new Availability(theResource, then, UP);
aThen.setEndTime(middle);
- Availability aMiddle = new Availability(theResource, middle,
AvailabilityType.DOWN);
+ Availability aMiddle = new Availability(theResource, middle, DOWN);
aMiddle.setEndTime(now);
- Availability aNow = new Availability(theResource, now, AvailabilityType.UP);
+ Availability aNow = new Availability(theResource, now, UP);
/*
* Simulate a report (aMiddle) that came in late (e.g. because of sorting
@@ -195,7 +195,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
}
@SuppressWarnings("unchecked")
- @Test(enabled = true)
+ @Test(enabled = ENABLE_TESTS)
public void testPurgeAvailabilities() throws Exception {
Date now = new Date();
Date middle = new Date(now.getTime() - 30000); // 30s ago
@@ -207,13 +207,12 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
setupResource(em);
commitAndClose(em);
- Availability aThen = new Availability(theResource, then,
AvailabilityType.UP);
- aThen.setEndTime(middle);
+ Availability aThen = new Availability(theResource, then, UP);
- Availability aMiddle = new Availability(theResource, middle,
AvailabilityType.DOWN);
+ Availability aMiddle = new Availability(theResource, middle, DOWN);
aMiddle.setEndTime(now);
- Availability aNow = new Availability(theResource, now, AvailabilityType.UP);
+ Availability aNow = new Availability(theResource, now, UP);
persistAvailability(aThen);
persistAvailability(aMiddle);
@@ -229,10 +228,10 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
List<Availability> avails = q.getResultList();
assert avails.size() == 2;
- assert avails.get(0).getAvailabilityType() == AvailabilityType.DOWN;
+ assert avails.get(0).getAvailabilityType() == DOWN;
assert avails.get(0).getStartTime().equals(middle);
assert avails.get(0).getEndTime().equals(now);
- assert avails.get(1).getAvailabilityType() == AvailabilityType.UP;
+ assert avails.get(1).getAvailabilityType() == UP;
assert avails.get(1).getStartTime().equals(now);
assert avails.get(1).getEndTime() == null;
@@ -247,7 +246,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
avails = q.getResultList();
assert avails.size() == 1;
- assert avails.get(0).getAvailabilityType() == AvailabilityType.UP;
+ assert avails.get(0).getAvailabilityType() == UP;
assert avails.get(0).getStartTime().equals(now);
assert avails.get(0).getEndTime() == null;
} catch (Exception e) {
@@ -261,7 +260,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
}
}
- @Test(enabled = true)
+ @Test(enabled = ENABLE_TESTS)
public void testGetAvailabilities() throws Exception {
EntityManager em = beginTx();
@@ -300,11 +299,11 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
availPoints = availabilityManager.findAvailabilitiesForResource(overlord,
theResource.getId(),
startMillis - 3, startMillis, 3, false);
assert availPoints.size() == 3 : "There is 1 avail data, but should
still get 3 availability points";
- assert availPoints.get(0).getAvailabilityType() == DOWN; // aka unknown
+ assert availPoints.get(0).getAvailabilityType() == UNKNOWN;
assert !availPoints.get(0).isKnown() : availPoints;
- assert availPoints.get(1).getAvailabilityType() == DOWN; // aka unknown
+ assert availPoints.get(1).getAvailabilityType() == UNKNOWN;
assert !availPoints.get(1).isKnown() : availPoints;
- assert availPoints.get(2).getAvailabilityType() == DOWN; // aka unknown
+ assert availPoints.get(2).getAvailabilityType() == UNKNOWN;
assert !availPoints.get(2).isKnown() : availPoints;
availPoints = availabilityManager.findAvailabilitiesForResource(overlord,
theResource.getId(),
@@ -330,13 +329,13 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
assert availPoints.size() == 10 : "There is 1 avail data, but should
still get 10 availability points";
assert availPoints.get(0).getAvailabilityType() == UNKNOWN : availPoints;
assert !availPoints.get(0).isKnown() : availPoints;
- assert availPoints.get(1).getAvailabilityType() == DOWN : availPoints;
+ assert availPoints.get(1).getAvailabilityType() == UNKNOWN : availPoints;
assert !availPoints.get(1).isKnown() : availPoints;
- assert availPoints.get(2).getAvailabilityType() == DOWN : availPoints;
+ assert availPoints.get(2).getAvailabilityType() == UNKNOWN : availPoints;
assert !availPoints.get(2).isKnown() : availPoints;
- assert availPoints.get(3).getAvailabilityType() == DOWN : availPoints;
+ assert availPoints.get(3).getAvailabilityType() == UNKNOWN : availPoints;
assert !availPoints.get(3).isKnown() : availPoints;
- assert availPoints.get(4).getAvailabilityType() == DOWN : availPoints;
+ assert availPoints.get(4).getAvailabilityType() == UNKNOWN : availPoints;
assert !availPoints.get(4).isKnown() : availPoints;
assert availPoints.get(5).getAvailabilityType() == UP : availPoints;
assert availPoints.get(5).isKnown() : availPoints;
@@ -345,46 +344,55 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
assert availPoints.get(8).getAvailabilityType() == UP : availPoints;
assert availPoints.get(9).getAvailabilityType() == UP : availPoints;
- report = new AvailabilityReport(false, theAgent.getName());
- report.addAvailability(new Availability(theResource, new
Date(startDate.getTime() + 10000), DOWN));
+ report = new AvailabilityReport(false, theAgent.getName()); // 70000
+ report.setEnablementReport(true); // simulate a real disable
+ report.addAvailability(new Availability(theResource, new
Date(startDate.getTime() + 10000), DISABLED));
availabilityManager.mergeAvailabilityReport(report);
- report = new AvailabilityReport(false, theAgent.getName());
+ // before setting other avails, must end disable with enablement report to
unknown
+ report = new AvailabilityReport(false, theAgent.getName()); // 75000
+ report.setEnablementReport(true);
+ report.addAvailability(new Availability(theResource, new
Date(startDate.getTime() + 15000), UNKNOWN));
+ availabilityManager.mergeAvailabilityReport(report);
+
+ report = new AvailabilityReport(false, theAgent.getName()); // 80000
report.addAvailability(new Availability(theResource, new
Date(startDate.getTime() + 20000), UP));
availabilityManager.mergeAvailabilityReport(report);
- report = new AvailabilityReport(false, theAgent.getName());
+ report = new AvailabilityReport(false, theAgent.getName()); // 90000
report.addAvailability(new Availability(theResource, new
Date(startDate.getTime() + 30000), DOWN));
availabilityManager.mergeAvailabilityReport(report);
availPoints = availabilityManager.findAvailabilitiesForResource(overlord,
theResource.getId(),
- startMillis - 15000, startMillis + 35000, 5, false);
+ startMillis - 15000, startMillis + 35000, 5, false); // 45000 - 95000
+
assert availPoints.size() == 5 : "There is 1 avail data, but should
still get 5 availability points";
- assert availPoints.get(0).getAvailabilityType() == UNKNOWN : availPoints; //
45000-55000 == unknown
+ assert availPoints.get(0).getAvailabilityType() == UNKNOWN : availPoints; //
45-55 == unknown
assert !availPoints.get(0).isKnown() : availPoints;
// this next point is on the edge - part was unknown, part was up - because
its on the edge, and part of it
// was UP, we consider the data point UP
- assert availPoints.get(1).getAvailabilityType() == UP : availPoints; //
55000-65000 == 55-60=unknown=down, 60-70=up
+ assert availPoints.get(1).getAvailabilityType() == UP : availPoints; // 55-65
== 55-60=unknown, 60-65=up
assert availPoints.get(1).isKnown() : availPoints;
- assert availPoints.get(2).getAvailabilityType() == DOWN : availPoints; //
65000-75000 == 60-70=up, 70-80=down (0.5==down)
- assert availPoints.get(3).getAvailabilityType() == DOWN : availPoints; //
75000-85000, 0.5 == down
- assert availPoints.get(4).getAvailabilityType() == DOWN : availPoints; //
85000-95000, 0.5 == down
+ assert availPoints.get(2).getAvailabilityType() == DISABLED : availPoints; //
65-75 == 65-70=up, 70-75=disabled
+ assert availPoints.get(3).getAvailabilityType() == UNKNOWN : availPoints; //
75-85 == 75-80=unknown, 80-85=up
+ assert availPoints.get(4).getAvailabilityType() == DOWN : availPoints; //
85-95, == 85-90=up, 90-95=down
availPoints = availabilityManager.findAvailabilitiesForResource(overlord,
theResource.getId(),
- startMillis - 30000, startMillis + 30000, 10, false);
+ startMillis - 30000, startMillis + 30000, 10, false); // 30000 - 90000
+
assert availPoints.size() == 10 : "There is 1 avail data, but should
still get 10 availability points";
- assert availPoints.get(0).getAvailabilityType() == DOWN : availPoints;
- assert availPoints.get(1).getAvailabilityType() == DOWN : availPoints;
- assert availPoints.get(2).getAvailabilityType() == DOWN : availPoints;
- assert availPoints.get(3).getAvailabilityType() == DOWN : availPoints;
- assert availPoints.get(4).getAvailabilityType() == DOWN : availPoints;
- assert availPoints.get(5).getAvailabilityType() == UP : availPoints;
- assert availPoints.get(6).getAvailabilityType() == DOWN : availPoints; //
0.5
- assert availPoints.get(7).getAvailabilityType() == DOWN : availPoints;
- assert availPoints.get(8).getAvailabilityType() == DOWN : availPoints; //
0.5
- assert availPoints.get(9).getAvailabilityType() == UP : availPoints;
+ assert availPoints.get(0).getAvailabilityType() == UNKNOWN : availPoints; //
30-36
+ assert availPoints.get(1).getAvailabilityType() == UNKNOWN : availPoints; //
36-42
+ assert availPoints.get(2).getAvailabilityType() == UNKNOWN : availPoints; //
42-48
+ assert availPoints.get(3).getAvailabilityType() == UNKNOWN : availPoints; //
58-54
+ assert availPoints.get(4).getAvailabilityType() == UNKNOWN : availPoints; //
54-60
+ assert availPoints.get(5).getAvailabilityType() == UP : availPoints; //
60-66
+ assert availPoints.get(6).getAvailabilityType() == DISABLED : availPoints; //
66-72
+ assert availPoints.get(7).getAvailabilityType() == DISABLED : availPoints; //
72-78
+ assert availPoints.get(8).getAvailabilityType() == UNKNOWN : availPoints; //
78-84
+ assert availPoints.get(9).getAvailabilityType() == UP : availPoints; //
84-90
} catch (Exception e) {
e.printStackTrace();
throw e;
@@ -396,7 +404,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
}
}
- @Test(enabled = true)
+ @Test(enabled = ENABLE_TESTS)
public void testSetAllAgentResourceAvailabilities() throws Exception {
EntityManager em = beginTx();
@@ -406,10 +414,10 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
em = null;
// setAllAgentResourceAvails will only operate on those that have at least 1
avail row
- Availability avail = new Availability(theResource, new Date(), null);
+ Availability avail = new Availability(theResource, new Date(), UNKNOWN);
persistAvailability(avail);
- assert availabilityManager.getCurrentAvailabilityTypeForResource(overlord,
theResource.getId()) == null;
+ assert availabilityManager.getCurrentAvailabilityTypeForResource(overlord,
theResource.getId()) == UNKNOWN;
availabilityManager.updateAgentResourceAvailabilities(theAgent.getId(), UP,
UP);
assert availabilityManager.getCurrentAvailabilityTypeForResource(overlord,
theResource.getId()) == UP;
availabilityManager.updateAgentResourceAvailabilities(theAgent.getId(), DOWN,
DOWN);
@@ -427,7 +435,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
}
}
- @Test(enabled = true)
+ @Test(enabled = ENABLE_TESTS)
public void testAgentBackfillNewResource() throws Exception {
EntityManager em = beginTx();
@@ -438,7 +446,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
// have never heard from the new agent yet - we do not backfill anything in
this case
LookupUtil.getAgentManager().checkForSuspectAgents();
- assert availabilityManager.getCurrentAvailabilityTypeForResource(overlord,
theResource.getId()) == null; // unknown
+ assert availabilityManager.getCurrentAvailabilityTypeForResource(overlord,
theResource.getId()) == UNKNOWN;
em = beginTx();
Resource resource = em.find(Resource.class, theResource.getId());
@@ -456,7 +464,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
}
}
- @Test(enabled = true)
+ @Test(enabled = ENABLE_TESTS)
public void testAgentBackfill() throws Exception {
EntityManager em = beginTx();
@@ -477,15 +485,16 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
// let's pretend we haven't heard from the agent in a few minutes
em = beginTx();
Agent agent = em.find(Agent.class, theAgent.getId());
- agent.setLastAvailabilityReport(System.currentTimeMillis() - (1000 * 60 *
18)); // 18 mins
+ agent.setLastAvailabilityPing(System.currentTimeMillis() - (1000 * 60 * 18));
// 18 mins
commitAndClose(em);
em = null;
- // the agent should be suspect and will be considered down
- LookupUtil.getAgentManager().checkForSuspectAgents(); // checks for 15 mins
!!
+ // the agent should be suspect and will be considered down, the platform
resource should be down
+ // (although children should be UNKNOWN)
+ LookupUtil.getAgentManager().checkForSuspectAgents(); // checks for 5 mins
!!
AvailabilityType curAvail;
curAvail =
availabilityManager.getCurrentAvailabilityTypeForResource(overlord, theResource.getId());
- assert curAvail == AvailabilityType.DOWN : curAvail; // backfilled with
"null" to mean "unknown"
+ assert curAvail == DOWN : curAvail;
// make sure our resource's new availabilities are consistent (first (UP)
is before second (unknown))
em = beginTx();
@@ -497,8 +506,8 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
Availability first = allAvails.get(0);
Availability second = allAvails.get(1);
- assert first.getAvailabilityType() == AvailabilityType.UP;
- assert second.getAvailabilityType() == AvailabilityType.DOWN :
second.getAvailabilityType();
+ assert first.getAvailabilityType() == UP;
+ assert second.getAvailabilityType() == DOWN : second.getAvailabilityType();
assert first.getEndTime() != null;
assert second.getEndTime() == null;
assert first.getEndTime().getTime() > first.getStartTime().getTime();
@@ -516,7 +525,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
}
}
- @Test(enabled = true)
+ @Test(enabled = ENABLE_TESTS)
public void testAgentBackfillPerformance() throws Exception {
EntityManager em = beginTx();
List<Resource> allResources = new ArrayList<Resource>();
@@ -542,7 +551,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
Availability currentAvailability =
availabilityManager.getCurrentAvailabilityForResource(overlord,
resId);
assert currentAvailability != null : "Current Availability was null
for " + resId;
- assert currentAvailability.getAvailabilityType() == null : "Current
AvailabilityType should have been null for "
+ assert currentAvailability.getAvailabilityType() == UNKNOWN :
"Current AvailabilityType should have been UNKNOWN for "
+ resId;
List<Availability> allData =
availabilityManager.findAvailabilityWithinInterval(resId, new Date(0),
@@ -552,14 +561,14 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
ResourceAvailability currentResAvail =
resourceAvailabilityManager.getLatestAvailability(resId);
assert currentResAvail != null : "Current ResourceAvailability was
null for " + resId;
- assert currentResAvail.getAvailabilityType() == null : "Current
ResourceAvailabilityType should have been null for "
+ assert currentResAvail.getAvailabilityType() == UNKNOWN : "Current
ResourceAvailabilityType should have been UNKNOWN for "
+ resId;
}
// let's pretend we haven't heard from the agent in a few minutes
em = beginTx();
Agent agent = em.find(Agent.class, theAgent.getId());
- agent.setLastAvailabilityReport(System.currentTimeMillis() - (1000 * 60 *
18)); // 18 mins
+ agent.setLastAvailabilityPing(System.currentTimeMillis() - (1000 * 60 * 18));
// 18 mins
commitAndClose(em);
em = null;
@@ -591,7 +600,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
// let's again pretend we haven't heard from the agent in a few
minutes
em = beginTx();
agent = em.find(Agent.class, theAgent.getId());
- agent.setLastAvailabilityReport(System.currentTimeMillis() - (1000 * 60 *
18));
+ agent.setLastAvailabilityPing(System.currentTimeMillis() - (1000 * 60 *
18));
commitAndClose(em);
em = null;
@@ -608,7 +617,8 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
for (Resource resource : allResources) {
curAvail =
availabilityManager.getCurrentAvailabilityTypeForResource(overlord, resource.getId());
- assert curAvail == AvailabilityType.DOWN : curAvail; // backfilled with
"null" to mean "unknown"
+ AvailabilityType expected = (null == resource.getParentResource()) ? DOWN
: UNKNOWN;
+ assert curAvail == expected : curAvail;
// make sure our resources' new availabilities are consistent
// the first time we suspected the agent and backfilled with unknown,
there was no rows
@@ -622,8 +632,8 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
Availability a0 = allAvails.get(0);
Availability a1 = allAvails.get(1);
- assert a0.getAvailabilityType() == AvailabilityType.UP : allAvails;
- assert a1.getAvailabilityType() == AvailabilityType.DOWN : allAvails;
+ assert a0.getAvailabilityType() == UP : allAvails;
+ assert a1.getAvailabilityType() == expected : allAvails;
assert a0.getEndTime() != null : allAvails;
assert a1.getEndTime() == null : allAvails;
assert a0.getEndTime().getTime() > a0.getStartTime().getTime() :
allAvails;
@@ -647,7 +657,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
}
}
- @Test(enabled = true)
+ @Test(enabled = ENABLE_TESTS)
public void testAgentOldReport() throws Exception {
EntityManager em = beginTx();
@@ -670,11 +680,11 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
report = new AvailabilityReport(false, theAgent.getName());
report.addAvailability(avail);
availabilityManager.mergeAvailabilityReport(report);
- assert getPointInTime(new Date(avail.getStartTime().getTime() - 1)) == DOWN;
// should be unknown
+ assert getPointInTime(new Date(avail.getStartTime().getTime() - 1)) ==
UNKNOWN;
assert getPointInTime(avail.getStartTime()) == UP;
assert getPointInTime(new Date(avail.getStartTime().getTime() + 1)) == UP;
- // its still down though - since we've received a more recent report
saying it was down
+ // it's still down though - since we've received a more recent report
saying it was down
assert availabilityManager.getCurrentAvailabilityTypeForResource(overlord,
theResource.getId()) == DOWN;
// now pretend the agent sent us reports from inbetween our existing time
periods
@@ -721,7 +731,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
report = new AvailabilityReport(false, theAgent.getName());
report.addAvailability(avail);
availabilityManager.mergeAvailabilityReport(report);
- assert getPointInTime(new Date(avail.getStartTime().getTime() - 1)) == DOWN;
// should be unknown
+ assert getPointInTime(new Date(avail.getStartTime().getTime() - 1)) ==
UNKNOWN;
assert getPointInTime(avail.getStartTime()) == UP;
assert getPointInTime(new Date(avail.getStartTime().getTime() + 1)) == UP;
} catch (Exception e) {
@@ -735,7 +745,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
}
}
- @Test(enabled = true)
+ @Test(enabled = ENABLE_TESTS)
public void testAgentOldReport2() throws Exception {
EntityManager em = beginTx();
@@ -795,7 +805,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
}
}
- @Test(enabled = true)
+ @Test(enabled = ENABLE_TESTS)
public void testGetAvailabilities2() throws Exception {
EntityManager em = beginTx();
@@ -836,27 +846,27 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
cal.set(Calendar.MINUTE, 30);
Date date6 = cal.getTime();
- avail = new Availability(theResource, date1, AvailabilityType.UP);
+ avail = new Availability(theResource, date1, UP);
avail.setEndTime(date2);
persistAvailability(avail);
- avail = new Availability(theResource, date2, AvailabilityType.DOWN);
+ avail = new Availability(theResource, date2, DOWN);
avail.setEndTime(date3);
persistAvailability(avail);
- avail = new Availability(theResource, date3, AvailabilityType.UP);
+ avail = new Availability(theResource, date3, UP);
avail.setEndTime(date4);
persistAvailability(avail);
- avail = new Availability(theResource, date4, AvailabilityType.DOWN);
+ avail = new Availability(theResource, date4, DOWN);
avail.setEndTime(date5);
persistAvailability(avail);
- avail = new Availability(theResource, date5, AvailabilityType.UP);
+ avail = new Availability(theResource, date5, UP);
avail.setEndTime(date6);
persistAvailability(avail);
- avail = new Availability(theResource, date6, AvailabilityType.DOWN);
+ avail = new Availability(theResource, date6, DOWN);
persistAvailability(avail);
List<AvailabilityPoint> points =
availabilityManager.findAvailabilitiesForResource(overlord,
@@ -883,7 +893,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
*
* @throws Exception in case of error
*/
- @Test(enabled = true)
+ @Test(enabled = ENABLE_TESTS)
public void testMergeReport() throws Exception {
EntityManager em = beginTx();
@@ -957,7 +967,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
}
}
- @Test(enabled = true)
+ @Test(enabled = ENABLE_TESTS)
public void testMergeReportPerformance() throws Exception {
EntityManager em = beginTx();
List<Resource> allResources = new ArrayList<Resource>();
@@ -1029,7 +1039,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
// at this point, the resources have 2 rows in availability - after the merge
they will have 3
report = new AvailabilityReport(false, theAgent.getName());
for (Resource resource : allResources) {
- Availability avail = new Availability(resource, new Date(), null);
+ Availability avail = new Availability(resource, new Date(), UNKNOWN);
report.addAvailability(avail);
}
@@ -1043,7 +1053,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
for (Resource resource : allResources) {
curAvail =
availabilityManager.getCurrentAvailabilityTypeForResource(overlord, resource.getId());
- assert curAvail == null : curAvail;
+ assert curAvail == UNKNOWN : curAvail;
}
System.out.println("testMergeReportPerformance: checking validity of
data 3 took "
@@ -1197,15 +1207,15 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
long count = countAvailabilitiesInDB(em);
- availability1 = new Availability(theResource, start, AvailabilityType.UP);
+ availability1 = new Availability(theResource, start, UP);
availability1.setEndTime(splitStart);
persistAvailability(availability1);
- availability2 = new Availability(theResource, splitStart,
AvailabilityType.DOWN);
+ availability2 = new Availability(theResource, splitStart, DOWN);
availability2.setEndTime(splitEnd);
persistAvailability(availability2);
- availability3 = new Availability(theResource, splitEnd, AvailabilityType.UP);
+ availability3 = new Availability(theResource, splitEnd, UP);
persistAvailability(availability3);
long countNow = countAvailabilitiesInDB(em);
commit 09a765a1d355403723772375fd349390d81892c1
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Feb 24 16:01:20 2012 -0500
Unit tests failed on windows. This seems to be a real problem
in AbstractBundleType, which assumed unix-style separators.
Modified unit tests to test a windows path and updated AbstractBundleType
to force unix style separators for the file paths.
diff --git
a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/AbstractBundleType.java
b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/AbstractBundleType.java
index 44daf4c..6544f10 100644
---
a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/AbstractBundleType.java
+++
b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/AbstractBundleType.java
@@ -7,6 +7,7 @@ import java.util.regex.Pattern;
import org.apache.tools.ant.types.DataType;
import org.rhq.bundle.ant.BundleAntProject;
+import org.rhq.core.util.file.FileUtil;
/**
*
@@ -32,7 +33,8 @@ public abstract class AbstractBundleType extends DataType {
regex.append("(");
File dir = fileSet.getDir();
if (dir != null) {
- regex.append(dir);
+ String path = FileUtil.useForwardSlash(dir.getPath());
+ regex.append(path);
regex.append('/');
}
if (fileSet.getIncludePatterns().length == 0) {
diff --git
a/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/type/AbstractBundleTypeTest.java
b/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/type/AbstractBundleTypeTest.java
index fc27760..ec8fd53 100644
---
a/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/type/AbstractBundleTypeTest.java
+++
b/modules/common/ant-bundle/src/test/java/org/rhq/bundle/ant/type/AbstractBundleTypeTest.java
@@ -23,6 +23,7 @@
package org.rhq.bundle.ant.type;
+import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
@@ -31,19 +32,24 @@ import org.testng.annotations.Test;
@Test
public class AbstractBundleTypeTest {
+ private static final String realBasedir = (File.separatorChar == '/') ?
"/basedir" : "c:\\basedir";
+ // normalized basedir
+ private static final String basedir = (File.separatorChar == '/') ?
"/basedir" : "c:/basedir";
+
public void testGetPattern() {
Pattern regex;
- regex = assertPatternsRegex("/basedir",
"(/basedir/(easy\\.txt))|(/basedir/(test\\.txt))", "easy.txt",
- "test.txt");
- assert regex.matcher("/basedir/easy.txt").matches();
- assert regex.matcher("/basedir/test.txt").matches();
- assert !regex.matcher("/basedir/easyXtxt").matches();
- assert !regex.matcher("/basedir/testXtxt").matches();
- assert !regex.matcher("/basedir/easy.txtX").matches();
- assert !regex.matcher("/basedir/test.txtX").matches();
- assert !regex.matcher("/basedirX/easy.txt").matches();
- assert !regex.matcher("/basedirX/test.txt").matches();
+ String expectedPattern = "(" + basedir + "/(easy\\.txt))|(" +
basedir + "/(test\\.txt))";
+
+ regex = assertPatternsRegex(realBasedir, expectedPattern, "easy.txt",
"test.txt");
+ assert regex.matcher(basedir + "/easy.txt").matches() : regex.pattern()
+ " vs. " + basedir + "/easy.txt";
+ assert regex.matcher(basedir + "/test.txt").matches();
+ assert !regex.matcher(basedir + "/easyXtxt").matches();
+ assert !regex.matcher(basedir + "/testXtxt").matches();
+ assert !regex.matcher(basedir + "/easy.txtX").matches();
+ assert !regex.matcher(basedir + "/test.txtX").matches();
+ assert !regex.matcher(basedir + "X/easy.txt").matches();
+ assert !regex.matcher(basedir + "X/test.txt").matches();
assert !regex.matcher("easy.txt").matches() : "missing
basedir";
assert !regex.matcher("test.txt").matches() : "missing
basedir";
commit 477e05916b851d99dac7b3e64a32d12ad37a39e0
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Feb 24 13:59:49 2012 -0500
Fix unit tests to run properly on windows.
diff --git
a/modules/common/jboss-as/src/test/java/com/jboss/jbossnetwork/product/jbpm/handlers/test/CompareDigestActionHandlerTest.java
b/modules/common/jboss-as/src/test/java/com/jboss/jbossnetwork/product/jbpm/handlers/test/CompareDigestActionHandlerTest.java
index f5c306f..a2d2ecb 100644
---
a/modules/common/jboss-as/src/test/java/com/jboss/jbossnetwork/product/jbpm/handlers/test/CompareDigestActionHandlerTest.java
+++
b/modules/common/jboss-as/src/test/java/com/jboss/jbossnetwork/product/jbpm/handlers/test/CompareDigestActionHandlerTest.java
@@ -1,34 +1,38 @@
- /*
- * Jopr Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
+/*
+ * Jopr Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
package com.jboss.jbossnetwork.product.jbpm.handlers.test;
+import java.io.File;
import java.net.URL;
import java.util.Iterator;
import java.util.List;
+
import com.jboss.jbossnetwork.product.jbpm.handlers.ActionHandlerMessageLog;
+
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
import org.testng.annotations.Test;
+
import org.rhq.core.domain.content.transfer.ContentResponseResult;
import org.rhq.core.domain.content.transfer.DeployPackageStep;
@@ -44,7 +48,9 @@ public class CompareDigestActionHandlerTest {
sampleDigestFile = url.getFile();
}
- private String sampleDigestFileMD5 = "c58587b872b8ed47b3fdba4734729c65";
+ // different line terminators give different md5s for different OS.
+ private String sampleDigestFileMD5 = (File.separatorChar == '/') ?
"c58587b872b8ed47b3fdba4734729c65"
+ : "e04d8968410a3edc683ed461626456bd";
@Test
public void matchingDigest() throws Exception {
diff --git
a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/bundle/BundleManagerTest.java
b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/bundle/BundleManagerTest.java
index c8e9f10..536f137 100644
---
a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/bundle/BundleManagerTest.java
+++
b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/bundle/BundleManagerTest.java
@@ -106,7 +106,7 @@ public class BundleManagerTest {
Bundle bundle = new Bundle("bundleName", bundleType, null, null);
BundleVersion bundleVersion = new BundleVersion("bundleVersionName",
"1.0", bundle, "");
BundleDestination destination = new BundleDestination(bundle,
"destName", null,
- MockInventoryManager.BUNDLE_CONFIG_NAME_FS, "/tmp/dest"); //
ABSOLUTE PATH
+ MockInventoryManager.BUNDLE_CONFIG_NAME_FS, getPath("/tmp/dest"));
// ABSOLUTE PATH
BundleDeployment bundleDeployment = new BundleDeployment(bundleVersion,
destination, "deploymentName");
BundleResourceDeployment resourceDeployment = new
BundleResourceDeployment(bundleDeployment, im.serverFS);
BundleScheduleRequest request = new BundleScheduleRequest(resourceDeployment);
@@ -114,11 +114,14 @@ public class BundleManagerTest {
// No matter what the CONTEXT_VALUE_FS is (i.e. the default context value in the
plugin descriptor),
// if the user specifies an absolute path for the destination, that will be used
explicitly. So here in this test,
// the destination was specified with a destDir that had an absolute path of
/tmp/dest and it will be used as-is
- mockBundleManager.absolutePathToAssert = "/tmp/dest";
+ mockBundleManager.absolutePathToAssert = getPath("/tmp/dest");
BundleScheduleResponse response = mockBundleManager.schedule(request);
assertSuccess(response);
assertBundleDeploymentStatus(BundleDeploymentStatus.SUCCESS);
+ }
+ private static String getPath(String path) {
+ return ((File.separatorChar == '\\') &&
path.startsWith("/")) ? ("C:" + path) : path;
}
public void testNonPlatformBundleDeploy_FileSystem_RelativePath() throws Exception {
@@ -208,7 +211,7 @@ public class BundleManagerTest {
Bundle bundle = new Bundle("bundleName", bundleType, null, null);
BundleVersion bundleVersion = new BundleVersion("bundleVersionName",
"1.0", bundle, "");
BundleDestination destination = new BundleDestination(bundle,
"destName", null,
- MockInventoryManager.BUNDLE_CONFIG_NAME_FS, "/tmp/dest"); //
ABSOLUTE PATH
+ MockInventoryManager.BUNDLE_CONFIG_NAME_FS, getPath("/tmp/dest"));
// ABSOLUTE PATH
BundleDeployment bundleDeployment = new BundleDeployment(bundleVersion,
destination, "deploymentName");
BundleResourceDeployment resourceDeployment = new
BundleResourceDeployment(bundleDeployment, im.serverFS);
BundleScheduleRequest request = new BundleScheduleRequest(resourceDeployment);
@@ -307,21 +310,21 @@ public class BundleManagerTest {
}
}
- private class MockInventoryManager extends InventoryManager {
+ private static class MockInventoryManager extends InventoryManager {
private static final String BUNDLE_CONFIG_NAME_FS =
"fsBaseDirLocation";
- private static final String BUNDLE_CONFIG_CONTEXT_VALUE_FS = "/blah";
+ private static final String BUNDLE_CONFIG_CONTEXT_VALUE_FS =
getPath("/blah");
private static final String BUNDLE_CONFIG_NAME_PC =
"pcBaseDirLocation";
private static final String BUNDLE_CONFIG_CONTEXT_VALUE_PC =
"pcPropBundle";
- private static final String BUNDLE_CONFIG_LOCATION_PC =
"/pluginconfig/base/dir";
+ private static final String BUNDLE_CONFIG_LOCATION_PC =
getPath("/pluginconfig/base/dir");
private static final String BUNDLE_CONFIG_NAME_RC =
"rcBaseDirLocation";
private static final String BUNDLE_CONFIG_CONTEXT_VALUE_RC =
"rcPropBundle";
- private static final String BUNDLE_CONFIG_LOCATION_RC =
"/resourceconfig/base/dir";
+ private static final String BUNDLE_CONFIG_LOCATION_RC =
getPath("/resourceconfig/base/dir");
private static final String BUNDLE_CONFIG_NAME_MT =
"mtBaseDirLocation";
private static final String BUNDLE_CONFIG_CONTEXT_VALUE_MT =
"traitBundle";
- private static final String BUNDLE_CONFIG_LOCATION_MT =
"/trait/base/dir";
+ private static final String BUNDLE_CONFIG_LOCATION_MT =
getPath("/trait/base/dir");
// mocking the following:
// - one platform type and a platform resource to be used as the root parent
@@ -475,7 +478,7 @@ public class BundleManagerTest {
}
@SuppressWarnings("unchecked")
- private class MockResourceContext extends ResourceContext {
+ private static class MockResourceContext extends ResourceContext {
public MockResourceContext(Resource resource) {
super(resource, null, null, null, null, null, null, null, null, null, null,
null, null);
}
commit f6996bc7d6f2425ac02ce0e2c7b7a59203877aaa
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Feb 24 10:25:01 2012 -0500
Fix Suspect Job unit test to properly use ping times as opposed to
avail report times.
diff --git
a/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/AgentTest.java
b/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/AgentTest.java
index e7b5be5..b631289 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/AgentTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/AgentTest.java
@@ -38,7 +38,7 @@ public class AgentTest extends AbstractEJB3Test {
private long now = System.currentTimeMillis();
public void testSuspectAgentQuery() throws Exception {
- List<AgentLastAvailabilityPingComposite> reports;
+ List<AgentLastAvailabilityPingComposite> pings;
int i;
getTransactionManager().begin();
@@ -64,58 +64,54 @@ public class AgentTest extends AbstractEJB3Test {
q = em.createNamedQuery(Agent.QUERY_FIND_ALL_SUSPECT_AGENTS);
q.setParameter("dateThreshold", now - 2500);
- reports = q.getResultList();
- assert reports.size() == 2 + baselineSize : reports;
-
- i = reports.indexOf(new AgentLastAvailabilityPingComposite(agent3.getId(),
null, null, null, false));
- assert reports.get(i).getAgentId() == agent3.getId();
- assert reports.get(i).getAgentName().equals(agent3.getName());
- assert
reports.get(i).getRemoteEndpoint().equals(agent3.getRemoteEndpoint());
- assert
reports.get(i).getLastAvailabilityPing().equals(agent3.getLastAvailabilityPing());
-
- i = reports.indexOf(new AgentLastAvailabilityPingComposite(agent4.getId(),
null, null, null, false));
- assert reports.get(i).getAgentId() == agent4.getId();
- assert reports.get(i).getAgentName().equals(agent4.getName());
- assert
reports.get(i).getRemoteEndpoint().equals(agent4.getRemoteEndpoint());
- assert
reports.get(i).getLastAvailabilityPing().equals(agent4.getLastAvailabilityPing());
-
- assert -1 == reports
- .indexOf(new AgentLastAvailabilityPingComposite(agent2.getId(), null,
null, null, false));
- assert -1 == reports
- .indexOf(new AgentLastAvailabilityPingComposite(agent1.getId(), null,
null, null, false));
+ pings = q.getResultList();
+ assert pings.size() == 2 + baselineSize : pings;
+
+ i = pings.indexOf(new AgentLastAvailabilityPingComposite(agent3.getId(),
null, null, null, false));
+ assert pings.get(i).getAgentId() == agent3.getId();
+ assert pings.get(i).getAgentName().equals(agent3.getName());
+ assert pings.get(i).getRemoteEndpoint().equals(agent3.getRemoteEndpoint());
+ assert
pings.get(i).getLastAvailabilityPing().equals(agent3.getLastAvailabilityPing());
+
+ i = pings.indexOf(new AgentLastAvailabilityPingComposite(agent4.getId(),
null, null, null, false));
+ assert pings.get(i).getAgentId() == agent4.getId();
+ assert pings.get(i).getAgentName().equals(agent4.getName());
+ assert pings.get(i).getRemoteEndpoint().equals(agent4.getRemoteEndpoint());
+ assert
pings.get(i).getLastAvailabilityPing().equals(agent4.getLastAvailabilityPing());
+
+ assert -1 == pings.indexOf(new
AgentLastAvailabilityPingComposite(agent2.getId(), null, null, null, false));
+ assert -1 == pings.indexOf(new
AgentLastAvailabilityPingComposite(agent1.getId(), null, null, null, false));
// add an agent with a null in the date column
Agent agent0 = createAgent(em, 0, -1);
assert em.find(Agent.class, agent0.getId()) != null;
- reports = q.getResultList();
- assert reports.size() == 2 + baselineSize : reports;
-
- i = reports.indexOf(new AgentLastAvailabilityPingComposite(agent3.getId(),
null, null, null, false));
- assert reports.get(i).getAgentId() == agent3.getId();
- assert reports.get(i).getAgentName().equals(agent3.getName());
- assert
reports.get(i).getRemoteEndpoint().equals(agent3.getRemoteEndpoint());
- assert
reports.get(i).getLastAvailabilityPing().equals(agent3.getLastAvailabilityPing());
-
- i = reports.indexOf(new AgentLastAvailabilityPingComposite(agent4.getId(),
null, null, null, false));
- assert reports.get(i).getAgentId() == agent4.getId();
- assert reports.get(i).getAgentName().equals(agent4.getName());
- assert
reports.get(i).getRemoteEndpoint().equals(agent4.getRemoteEndpoint());
- assert
reports.get(i).getLastAvailabilityPing().equals(agent4.getLastAvailabilityPing());
-
- assert -1 == reports
- .indexOf(new AgentLastAvailabilityPingComposite(agent2.getId(), null,
null, null, false));
- assert -1 == reports
- .indexOf(new AgentLastAvailabilityPingComposite(agent1.getId(), null,
null, null, false));
+ pings = q.getResultList();
+ assert pings.size() == 2 + baselineSize : pings;
+
+ i = pings.indexOf(new AgentLastAvailabilityPingComposite(agent3.getId(),
null, null, null, false));
+ assert pings.get(i).getAgentId() == agent3.getId();
+ assert pings.get(i).getAgentName().equals(agent3.getName());
+ assert pings.get(i).getRemoteEndpoint().equals(agent3.getRemoteEndpoint());
+ assert
pings.get(i).getLastAvailabilityPing().equals(agent3.getLastAvailabilityPing());
+
+ i = pings.indexOf(new AgentLastAvailabilityPingComposite(agent4.getId(),
null, null, null, false));
+ assert pings.get(i).getAgentId() == agent4.getId();
+ assert pings.get(i).getAgentName().equals(agent4.getName());
+ assert pings.get(i).getRemoteEndpoint().equals(agent4.getRemoteEndpoint());
+ assert
pings.get(i).getLastAvailabilityPing().equals(agent4.getLastAvailabilityPing());
+
+ assert -1 == pings.indexOf(new
AgentLastAvailabilityPingComposite(agent2.getId(), null, null, null, false));
+ assert -1 == pings.indexOf(new
AgentLastAvailabilityPingComposite(agent1.getId(), null, null, null, false));
// get all of them, except the one with the null
q.setParameter("dateThreshold", now - 1);
- reports = q.getResultList();
- assert reports.size() == 4 + baselineSize : reports;
+ pings = q.getResultList();
+ assert pings.size() == 4 + baselineSize : pings;
// get none of them
q.setParameter("dateThreshold", now - 10000);
- reports = q.getResultList();
- assert reports.size() == 0 + baselineSize : reports;
+ pings = q.getResultList();
+ assert pings.size() == 0 + baselineSize : pings;
} finally {
getTransactionManager().rollback();
}
@@ -124,9 +120,9 @@ public class AgentTest extends AbstractEJB3Test {
private Agent createAgent(EntityManager em, int num, long availDateOffsetFromNow) {
Agent agent = new Agent("agent" + num, "address" + num, num,
"remoteaddr" + num, "token" + num);
if (availDateOffsetFromNow > 0) {
- agent.setLastAvailabilityReport(now - availDateOffsetFromNow);
+ agent.setLastAvailabilityPing(now - availDateOffsetFromNow);
} else {
- agent.setLastAvailabilityReport(null);
+ agent.setLastAvailabilityPing(null);
}
em.persist(agent);