[ 
https://issues.apache.org/jira/browse/FLINK-7773?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16240485#comment-16240485
 ] 

ASF GitHub Bot commented on FLINK-7773:
---------------------------------------

GitHub user tillrohrmann opened a pull request:

    https://github.com/apache/flink/pull/4957

    [FLINK-7773] [tests] Move all mocking before testing code in UtilsTest to 
avoid unfinished stubbing

    ## What is the purpose of the change
    
    Move all mocking code before the actual testing code in 
UtilsTest#testYarnFlinkResourceManagerJobManagerLostLeadership.
    Hopefully, this will fix the unfinished stubbing exception which still 
occurs spuriously.
    
    ## Verifying this change
    
    This change is a trivial rework / code cleanup without any test coverage.
    
    ## Does this pull request potentially affect one of the following parts:
    
      - Dependencies (does it add or upgrade a dependency): (no)
      - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)`: ( no)
      - The serializers: (no)
      - The runtime per-record code paths (performance sensitive): (no)
      - Anything that affects deployment or recovery: JobManager (and its 
components), Checkpointing, Yarn/Mesos, ZooKeeper: (no)
      - The S3 file system connector: (no)
    
    ## Documentation
    
      - Does this pull request introduce a new feature? (no)
      - If yes, how is the feature documented? (not applicable)


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

    $ git pull https://github.com/tillrohrmann/flink hardenUtilsTest

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

    https://github.com/apache/flink/pull/4957.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 #4957
    
----
commit 8c572f943dd064c8d22100ced1e1f50645f6e519
Author: Till Rohrmann <trohrm...@apache.org>
Date:   2017-11-06T16:07:38Z

    [FLINK-7773] [tests] Move all mocking before testing code in UtilsTest to 
avoid unfinished stubbing
    
    Move all mocking code before the actual testing code in 
UtilsTest#testYarnFlinkResourceManagerJobManagerLostLeadership.
    Hopefully, this will fix the unfinished stubbing exception which still 
occurs spuriously.

----


> Test instability in 
> UtilsTest#testYarnFlinkResourceManagerJobManagerLostLeadership
> ----------------------------------------------------------------------------------
>
>                 Key: FLINK-7773
>                 URL: https://issues.apache.org/jira/browse/FLINK-7773
>             Project: Flink
>          Issue Type: Bug
>          Components: Tests, YARN
>    Affects Versions: 1.4.0
>            Reporter: Nico Kruber
>            Assignee: Till Rohrmann
>            Priority: Critical
>              Labels: test-stability
>             Fix For: 1.4.0
>
>
> {{UtilsTest#testYarnFlinkResourceManagerJobManagerLostLeadership}} may result 
> in the following exception (repeated run in IntelliJ until failure, but also 
> on Travis here: https://travis-ci.org/NicoK/flink/jobs/283696974 )
> {code}
> org.apache.flink.yarn.UtilsTest "Until Failure"
> org.mockito.exceptions.misusing.UnfinishedStubbingException: 
> Unfinished stubbing detected here:
> -> at org.apache.flink.yarn.UtilsTest$1.<init>(UtilsTest.java:171)
> E.g. thenReturn() may be missing.
> Examples of correct stubbing:
>     when(mock.isOk()).thenReturn(true);
>     when(mock.isOk()).thenThrow(exception);
>     doThrow(exception).when(mock).someVoidMethod();
> Hints:
>  1. missing thenReturn()
>  2. you are trying to stub a final method, you naughty developer!
>  3: you are stubbing the behaviour of another mock inside before 'thenReturn' 
> instruction if completed
>       at org.apache.flink.yarn.UtilsTest$1.<init>(UtilsTest.java:179)
>       at 
> org.apache.flink.yarn.UtilsTest.testYarnFlinkResourceManagerJobManagerLostLeadership(UtilsTest.java:95)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:498)
>       at 
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
>       at 
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
>       at 
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
>       at 
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
>       at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
>       at org.junit.rules.RunRules.evaluate(RunRules.java:20)
>       at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
>       at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
>       at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
>       at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
>       at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
>       at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
>       at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
>       at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
>       at 
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
>       at 
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
>       at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
>       at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
>       at 
> com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
>       at 
> com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:67)
>       at 
> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
>       at 
> com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
> {code}
> The incriminating code is this:
> {code}
> doAnswer(new Answer() {
>       @Override
>       public Object answer(InvocationOnMock invocation) throws Throwable {
>               Container container = (Container) invocation.getArguments()[0];
>               resourceManagerGateway.tell(new 
> NotifyResourceStarted(YarnFlinkResourceManager.extractResourceID(container)),
>                       leader1Gateway);
>               return null;
>       }
> }).when(nodeManagerClient).startContainer(Matchers.any(Container.class), 
> Matchers.any(ContainerLaunchContext.class));
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to