GitHub user nickwallen opened a pull request:

    https://github.com/apache/metron/pull/1090

    METRON-1649 Intermittent Test Failure 
ProfileBuilderBoltTest#testFlushExpiredProfiles

    ```
    Tests run: 5, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.412 sec 
<<< FAILURE! - in org.apache.metron.profiler.bolt.ProfileBuilderBoltTest
    
testFlushExpiredProfiles(org.apache.metron.profiler.bolt.ProfileBuilderBoltTest)
  Time elapsed: 0.026 sec  <<< FAILURE!
    org.mockito.exceptions.verification.TooManyActualInvocations: 
    outputCollector.emit(
        "hbase",
        <Capturing argument>
    );
    Wanted 1 time:
    -> at 
org.apache.metron.profiler.bolt.ProfileBuilderBoltTest.getProfileMeasurements(ProfileBuilderBoltTest.java:265)
    But was 2 times. Undesired invocation:
    -> at 
org.apache.metron.profiler.bolt.HBaseEmitter.emit(HBaseEmitter.java:54)
    
        at 
org.apache.metron.profiler.bolt.ProfileBuilderBoltTest.getProfileMeasurements(ProfileBuilderBoltTest.java:265)
        at 
org.apache.metron.profiler.bolt.ProfileBuilderBoltTest.testFlushExpiredProfiles(ProfileBuilderBoltTest.java:205)
       ...
    ```
    
    The test case ensures that expired profiles are flushed successfully.  The 
test forces a flush of expired profiles and validates that a value was emitted 
from the expired profile.  During normal execution, any expired profiles are 
flushed regularly on a separate thread.
    
    The test case can fail intermittently because profiles are also being 
flushed in a separate thread at the same time that the test case is forcing a 
flush.  When the test fails, both the flush triggered by the test and the flush 
triggered by the background thread have occurred, which results in two values 
being emitted and the test failing.
    
    Instead of scheduling the background thread so that it executes 
immediately, execution is delayed by the profile TTL.  There is no need to run 
the flush immediately as there will never be any expired profiles to flush at 
least until after a period of time equal to the TTL has passed.  Introducing 
this initial delay also gives the test plenty of time to execute without 
interference.
    
    ## Pull Request Checklist
    
    - [ ] Is there a JIRA ticket associated with this PR? If not one needs to 
be created at [Metron 
Jira](https://issues.apache.org/jira/browse/METRON/?selectedTab=com.atlassian.jira.jira-projects-plugin:summary-panel).
    - [ ] Does your PR title start with METRON-XXXX where XXXX is the JIRA 
number you are trying to resolve? Pay particular attention to the hyphen "-" 
character.
    - [ ] Has your PR been rebased against the latest commit within the target 
branch (typically master)?
    - [ ] Have you included steps to reproduce the behavior or problem that is 
being changed or addressed?
    - [ ] Have you included steps or a guide to how the change may be verified 
and tested manually?
    - [ ] Have you ensured that the full suite of tests and checks have been 
executed in the root metron folder via:
    - [ ] Have you written or updated unit tests and or integration tests to 
verify your changes?
    - [ ] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)?
    - [ ] Have you verified the basic functionality of the build by building 
and running locally with Vagrant full-dev environment or the equivalent?


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/nickwallen/metron METRON-1649

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/metron/pull/1090.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1090
    
----
commit 23037a59ec4386f30adc0c502cf333688b7f2c5f
Author: Nick Allen <nick@...>
Date:   2018-07-02T19:34:10Z

    METRON-1649 Intermittent Test Failure 
ProfileBuilderBoltTest#testFlushExpiredProfiles

----


---

Reply via email to