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

@TestExtension works only when the enclosing class is exactly the test case class

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Original design:

      • HudsonTestCase.ComputerListenerImpl and JenkinsRule.ComputerListenerImpl register channels of launched slaves in order to close at the tearDown phase.
      • They are registered to Jenkins with @TestExtension

      Current status:

      • They does not work.
      • @TestExtension can be used for classes enclosed by test case classes.
      • JenkinsRule.ComputerListenerImpl does not work at all.
      • HudsonTestCase.ComputerListenerImpl worked in Jenkins < 1.482 for HudsonTestCase is a super class of enclosing classes. But in Jenkins 1.482, @TestExtension works only when the encolosing class is exactly the test case class.

      Problems caused by this:

      • Log files of slaves are left open, and fail to delete temporary directories in Windows: JENKINS-18259

        Attachments

          Issue Links

            Activity

            Hide
            jglick Jesse Glick added a comment -

            How about registering ComputerListener not with @TestExtension, but with @Extension?

            That is another possible workaround, but I would rather focus on the root issue first. Does following the suggestion in https://github.com/jenkinsci/jenkins/commit/5dd905f2a2c5316f170034c9026f6ff0eb0e2a2c#commitcomment-3437503 work?

            Show
            jglick Jesse Glick added a comment - How about registering ComputerListener not with @TestExtension , but with @Extension ? That is another possible workaround, but I would rather focus on the root issue first. Does following the suggestion in https://github.com/jenkinsci/jenkins/commit/5dd905f2a2c5316f170034c9026f6ff0eb0e2a2c#commitcomment-3437503 work?
            Hide
            ikedam ikedam added a comment -

            I verified it works for HudsonTestCase.
            Also for JenkinsRule, it must be

            if (outer.isAssignableFrom(description.getTestClass())
                || JenkinsRule.class.isAssignableFrom(outer)) {
            
            Show
            ikedam ikedam added a comment - I verified it works for HudsonTestCase . Also for JenkinsRule , it must be if ( outer .isAssignableFrom(description.getTestClass()) || JenkinsRule. class. isAssignableFrom( outer )) {
            Hide
            jglick Jesse Glick added a comment -

            Adjusting summary since JENKINS-18259 was solved differently anyway.

            Show
            jglick Jesse Glick added a comment - Adjusting summary since JENKINS-18259 was solved differently anyway.
            Hide
            jglick Jesse Glick added a comment -

            Not sure if this is worth fixing. HudsonTestCase is deprecated, and JenkinsRule is not normally subclassed. Would however be expected for a JUnit 4 test which subclasses another test with a @TestExtension to load the extension. Either way, need a direct test case not related to the now-deleted computer listener.

            Show
            jglick Jesse Glick added a comment - Not sure if this is worth fixing. HudsonTestCase is deprecated, and JenkinsRule is not normally subclassed. Would however be expected for a JUnit 4 test which subclasses another test with a @TestExtension to load the extension. Either way, need a direct test case not related to the now-deleted computer listener.
            Hide
            ikedam ikedam added a comment -

            Fixed in 1.520, 80cf490.

            Show
            ikedam ikedam added a comment - Fixed in 1.520, 80cf490 .

              People

              Assignee:
              jglick Jesse Glick
              Reporter:
              ikedam ikedam
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: