Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/571#discussion_r27614109
  
    --- Diff: 
policy/src/test/java/brooklyn/policy/ha/ServiceFailureDetectorTest.java ---
    @@ -312,6 +316,54 @@ public void 
testReportsFailureWhenAlreadyOnFireOnRegisteringPolicy() throws Exce
             assertHasEventEventually(HASensors.ENTITY_FAILED, 
Predicates.<Object>equalTo(e1), null);
         }
         
    +    @Test(groups="Integration") // Has a 1.5 second wait
    +    public void testRepublishedFailure() throws Exception {
    +        Duration republishPeriod = Duration.millis(100);
    +
    +        e1.addEnricher(EnricherSpec.create(ServiceFailureDetector.class)
    +                
.configure(ServiceFailureDetector.ENTITY_FAILED_REPUBLISH_TIME, 
republishPeriod));
    +            
    +        // Set the entity to healthy
    +        e1.setAttribute(TestEntity.SERVICE_UP, true);
    +        ServiceStateLogic.setExpectedState(e1, Lifecycle.RUNNING);
    +        EntityTestUtils.assertAttributeEqualsEventually(e1, 
Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
    +        
    +        // Make the entity fail;
    +        ServiceStateLogic.ServiceProblemsLogic.updateProblemsIndicator(e1, 
"test", "foo");
    +        EntityTestUtils.assertAttributeEqualsEventually(e1, 
TestEntity.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE);
    +        assertHasEventEventually(HASensors.ENTITY_FAILED, 
Predicates.<Object>equalTo(e1), null);
    +
    +        TimeUnit.SECONDS.sleep(1);
    +        
    +        // Now recover
    +        ServiceStateLogic.ServiceProblemsLogic.clearProblemsIndicator(e1, 
"test");
    +        EntityTestUtils.assertAttributeEqualsEventually(e1, 
TestEntity.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
    +        assertHasEventEventually(HASensors.ENTITY_RECOVERED, 
Predicates.<Object>equalTo(e1), null);
    +        
    +        TimeUnit.MILLISECONDS.sleep(500);
    +
    +        //can't assert number of republish events due to jitter, warn 
below if it deviates from expectation
    +        assertTrue(events.size() > 2, "events="+events);
    --- End diff --
    
    I'm hesitant about time-sensitive tests like this. We're probably ok 
because it's integration...
    
    For those that used to run in cloudbees, we'd occassionally see failures 
that suggested the thread had been starved for several seconds. I resorted to 
30 second timeouts to be on the safe side, so we wouldn't get false negatives 
in functional tests.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to