brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: new policies: SshConnectionFailur...
Date Wed, 01 Apr 2015 21:36:27 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/571#discussion_r27614430
  
    --- 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);
    +
    +        SensorEvent<FailureDescriptor> prevEvent = null;
    +        for (SensorEvent<FailureDescriptor> event : events) {
    +            if (prevEvent != null) {
    +                long repeatOffset = event.getTimestamp() - prevEvent.getTimestamp();
    +                long deviation = Math.abs(repeatOffset - republishPeriod.toMilliseconds());
    +                if (deviation > republishPeriod.toMilliseconds()/10 &&
    --- End diff --
    
    Same here: very time sensitive. We might well get a 10ms starvation of the required thread
when running on a cloud test server.
    
    For this kind of time test (to avoid false negatives), I resorted to number that were
more like republishPeriod being at least 1 second (rather than 100ms), and accepting anything
up to 500ms difference.
    
    If we start running our integration tests on apache hardware, we might find that will
sometimes fail as well!


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message