jenkinsci / jenkins-test-harness

Unit test framework for Jenkins core and its plugins
https://www.jenkins.io/doc/developer/testing/
MIT License
109 stars 126 forks source link

Dynamically create the RealJenkinsRuleInit plugin #782

Closed jtnord closed 4 months ago

jtnord commented 4 months ago

Switch to dynamically creating the plugin used by RealJenkinsRule

The plugin will have its Jenkis baseline set to the version of the war to ensure that no detached plugins are pulled in.

Previously if the version of Jenkins used by RealJenkinsRuleInit has detached plugins in the version of Jenknis used for the test then this can uncessescarily pull in detached plugins.

In most cases this is harmless, but in some cases these plugins may be prevented from running under the test (e.g. testing FIPS and one of the detached plugins like eddsa is not FIPS complaint and blocks startup).

The plugin itself has limited exposure to the Jenkins api (via hudson.plugin.Plugin and RealJenkinsRule$Init2).

Code running from the plugin tests inside RealJenkinsRule useis the uberClassloader and if the plugin was targetting a lower core (where the dependencies have been deteached, they should still be included as this change only affects the version of the RealJenkinsRuleInit plugin.

based on a suggestion by @jglick https://github.com/jenkinsci/jenkins-test-harness/pull/780#discussion_r1628438844

obsoletes: #781

Testing done

Submitter checklist

jglick commented 3 months ago

This seems to break tests which deliberately run an older Jenkins version (withWar) for purposes of testing compatibility. Maybe we can get a new method in RJR to override targetJenkinsVersion?

Edit: probably unnecessary; I found a workaround: call withWar before the test starts.