Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-44467

Matrix project CombinationFilterUsingBuildParamsTest is failling on the PCT

    Details

    • Similar Issues:

      Description

      Description

      matrix-project is failing when executing on the PCT against cores >= 1.653, the failling test is CombinationFilterUsingBuildParamsTest

      CombinationFilterUsingBuildParamsTest fails due to the need to adapt the mocking strategy to the new Jenkins#getInstanceOrNull method

       
      testCombinationFilterV01(hudson.matrix.CombinationFilterUsingBuildParamsTest) Time elapsed: 0.006 sec <<< ERROR! 
      org.mockito.exceptions.misusing.WrongTypeOfReturnValue: 
      
      ExtensionList$$EnhancerByMockitoWithCGLIB$$91270d55 cannot be returned by getInstanceOrNull() 
      getInstanceOrNull() should return Jenkins 
      *** 
      If you're unsure why you're getting above error read on. 
      Due to the nature of the syntax above problem might occur because: 
      1. This exception *might* occur in wrongly written multi-threaded tests. 
      Please refer to Mockito FAQ on limitations of concurrency testing. 
      2. A spy is stubbed using when(spy.foo()).then() syntax. It is safer to stub spies - 
      - with doReturn|Throw() family of methods. More in javadocs for Mockito.spy() method. 
      
      at hudson.matrix.CombinationFilterUsingBuildParamsTest.usingNoListeners(CombinationFilterUsingBuildParamsTest.java:252) 
      at hudson.matrix.CombinationFilterUsingBuildParamsTest.setUp(CombinationFilterUsingBuildParamsTest.java:122) 
      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.internal.runners.MethodRoadie.runBefores(MethodRoadie.java:133) 
      at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:96) 
      at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:294) 
      at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTestInSuper(PowerMockJUnit47RunnerDelegateImpl.java:127) 
      at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTest(PowerMockJUnit47RunnerDelegateImpl.java:82) 
      at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:282)
      at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:87) 
      at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:50) 
      at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:207) 
      at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:146) 
      at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:120) 
      at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34) 
      at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44) 
      at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:122) 
      at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:106) 
      at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53) 
      at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:59) 
      at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:367) 
      at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:274) 
      at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238) 
      at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:161) 
      at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:290) 
      at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:242) 
      at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121) 
      
      

      The issue is that the existing attempt to mock MatrixBuildListener#all was not working, hence the real method is invoked and as a result of that on core >= 1.653 it results (eventually) on a call to Jenkins#getInstanceOrNull which is not stubbed and results in returning the wrong type.

      On core <= 1.652 it worked because Jenkins#getInstance is stubbed.

      To reproduce

      mvn clean compile test-compile && mvn surefire:test -Djenkins.version=2.46.2 -Dtest=CombinationFilter* -Djava.level=7
      

      The jenkins.version property can be any higher or equal to 1.653

      Extra comments

      Note that in order to retain compatibility with the existing baseline Jenkins#getInstanceOrNull can not be stubbed as it does not exists in the baseline, hence the proposal is to properly mock MatrixBuildListener#all

        Attachments

          Issue Links

            Activity

            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Raul Arabaolaza
            Path:
            src/test/java/hudson/matrix/CombinationFilterUsingBuildParamsTest.java
            http://jenkins-ci.org/commit/matrix-project-plugin/1f56acccb7c9e7347412e4b1cefa64406dd6d507
            Log:
            JENKINS-44467 Properly mock MatrixBuildListener#all

            As a result Jenkins class does not need to be mocked

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Raul Arabaolaza Path: src/test/java/hudson/matrix/CombinationFilterUsingBuildParamsTest.java http://jenkins-ci.org/commit/matrix-project-plugin/1f56acccb7c9e7347412e4b1cefa64406dd6d507 Log: JENKINS-44467 Properly mock MatrixBuildListener#all As a result Jenkins class does not need to be mocked
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Oliver Gondža
            Path:
            src/test/java/hudson/matrix/CombinationFilterUsingBuildParamsTest.java
            http://jenkins-ci.org/commit/matrix-project-plugin/7a675c361f41308751b8a38aa7a475dc80d41e16
            Log:
            Merge pull request #51 from raul-arabaolaza/JENKINS-44467

            JENKINS-44467 Matrix project CombinationFilterUsingBuildParamsTest is failling on the PCT

            Compare: https://github.com/jenkinsci/matrix-project-plugin/compare/f96421a4aa65...7a675c361f41

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oliver Gondža Path: src/test/java/hudson/matrix/CombinationFilterUsingBuildParamsTest.java http://jenkins-ci.org/commit/matrix-project-plugin/7a675c361f41308751b8a38aa7a475dc80d41e16 Log: Merge pull request #51 from raul-arabaolaza/ JENKINS-44467 JENKINS-44467 Matrix project CombinationFilterUsingBuildParamsTest is failling on the PCT Compare: https://github.com/jenkinsci/matrix-project-plugin/compare/f96421a4aa65...7a675c361f41

              People

              • Assignee:
                rarabaolaza Raul Arabaolaza
                Reporter:
                rarabaolaza Raul Arabaolaza
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: