Skip to content

Commit

Permalink
Update control history tests so that it doesn't require a completed c…
Browse files Browse the repository at this point in the history
…ontrol history to do integration testing for HQ-2080.
  • Loading branch information
pnguyen committed Apr 20, 2010
1 parent 644cf4c commit 988fcbe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
14 changes: 10 additions & 4 deletions src/org/hyperic/hq/hqapi1/test/ControlTestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ public void cleanupControllableGroup(HQApi api, Group g)
hqAssertSuccess(response);
}

/**
*
* @param resource The resource
* @param timeout Time in seconds to wait for a completed control history
* @return ControlHistory A control history within the specified timeout
* @throws Exception
*/
protected ControlHistory findControlHistory(Object resource, int timeout)
throws Exception {

Expand All @@ -86,10 +93,9 @@ protected ControlHistory findControlHistory(Object resource, int timeout)
assertEquals("Wrong number of items in control history",
1, historyResponse.getControlHistory().size());

ControlHistory log = historyResponse.getControlHistory().get(0);
controlHistory = historyResponse.getControlHistory().get(0);

if (STATUS_COMPLETED.equals(log.getStatus())) {
controlHistory = log;
if (STATUS_COMPLETED.equals(controlHistory.getStatus())) {
break;
}

Expand All @@ -99,7 +105,7 @@ protected ControlHistory findControlHistory(Object resource, int timeout)

if (controlHistory == null) {
throw new Exception (
"Unable to find a completed control history in timeout of "
"Unable to find a control history in timeout of "
+ timeout + " seconds");
}

Expand Down
8 changes: 5 additions & 3 deletions src/org/hyperic/hq/hqapi1/test/GroupControlHistory_test.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,16 @@ public void testControlHistoryValidGroupWithHistory() throws Exception {
// validate the control history for the group and it's members
ControlHistory groupHistory = findControlHistory(controlGroup, 60);

for (Resource r : controlGroup.getResource()) {
findControlHistory(r, 1);
if (STATUS_COMPLETED.equals(groupHistory.getStatus())) {
for (Resource r : controlGroup.getResource()) {
findControlHistory(r, 1);
}
}

// verify that the group control action is started without "significant" delay
// TODO: ideally, this needs to be less than 1 second
long timeToStart = groupHistory.getStartTime() - groupHistory.getDateScheduled();
assertTrue(timeToStart < (40*SECOND));
assertTrue(timeToStart < (60*SECOND));

cleanupControllableGroup(api, controlGroup);
}
Expand Down

0 comments on commit 988fcbe

Please sign in to comment.