Permalink
Browse files

More timing fixes - specifically to avoid intermittent "Empty long re…

…ason" messages on alert validation (caused by asynchronous creation of AlertConditionLogs)
  • Loading branch information...
1 parent 2e55be8 commit 815029da9ba0f20ef25cc3a699ee499f753a62a7 Jennifer Hickey committed Oct 28, 2009
@@ -44,6 +44,12 @@ protected void validateAlert(Alert a) throws Exception {
assertTrue("Alert id is incorrect", a.getId() > 0);
assertTrue("Empty long reason", a.getReason().length() > 0);
}
+
+ protected boolean validateAlertAttributes(Alert a) throws Exception {
+ return a.getCtime() > 0 && a.getResourceId() > 0 &&
+ a.getAlertDefinitionId() > 0 && a.getName() != null && a.getId() >0 &&
+ a.getReason().length() > 0;
+ }
protected Escalation createEscalation() throws Exception {
EscalationApi escalationApi = getApi().getEscalationApi();
@@ -136,12 +142,21 @@ protected Alert generateAlerts(final Resource resource,
dataPoints.add(dp);
StatusResponse dataResponse = dataApi.addData(availMetric, dataPoints);
hqAssertSuccess(dataResponse);
- SpinBarrier alertsGenerated = new SpinBarrier(100000l,100l,new SpinBarrierCondition() {
+ SpinBarrier alertsGenerated = new SpinBarrier(new SpinBarrierCondition() {
public boolean evaluate() {
try {
- return getGeneratedAlert(resource,start,e,def) != null;
- } catch (IOException e) {
- fail("Error obtaining alerts: " + e.getMessage());
+ Alert a = getGeneratedAlert(resource,start,e,def);
+ if(a == null) {
+ return false;
+ }
+ //We found an alert, but all fields may not be populated yet. Specifically reason may still be blank.
+ boolean alertValid = validateAlertAttributes(a);
+ if(alertValid == false) {
+ System.out.println("WARN: Found an alert, but it is missing required attributes");
+ }
+ return alertValid;
+ } catch (Exception e) {
+ fail("Error obtaining or validating alerts: " + e.getMessage());
return false;
}
}
@@ -14,7 +14,7 @@
*
*/
public class SpinBarrier {
- private long timeout = 5000l;
+ private long timeout = 120000l;
private long retryInterval = 250l;
private final SpinBarrierCondition condition;

0 comments on commit 815029d

Please sign in to comment.