Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-54424] - Remove Jenkins Test Harness Dependency & replace by local code #36

Merged
merged 4 commits into from
Nov 20, 2018

Conversation

oleg-nenashev
Copy link
Member

This change removes dependency on the Jenkins Test Harness framework. JUnit is still used, but there is a separate ticket for that.

  • Many classes were copied from JTH, but it can be optimized later
  • Irrelevant code in JenkinsRule and other classes was removed

There is still a lot of optimizations/refactorings to be done (e.g. prevent WAR exploder from running at all, remove interfaces), but at least we keep the engine separate from JTH going forward

https://issues.jenkins-ci.org/browse/JENKINS-54424

… local code

This change removes dependency on the Jenkins Test Harness framework. JUnit is still used, but there is a separate ticket for that.

* Many classes were copied from JTH, but it can be optimized later
* Irrelevant code in JenkinsRule and other classes was removed

There is still a lot of optimizations/refactorings to be done (e.g. prevent WAR exploder from running at all, remove interfaces), but at least we keep the engine separate from JTH going forward
return t;
}
})));
QueuedThreadPool queuedThreadPool = new QueuedThreadPool(10);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed custom Thread Pool like @olamy did for Winstone in jenkinsci/winstone#54 . Likely we need to upstream the fix to Jenkins Test Harness so that it runs reliably on 50+ core machines. I wish we had them on our infra :P

FYI @jglick

Copy link
Member

@jvz jvz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming you just copied most of this code, the only real fixes I would need are the copyright headers.

/**
* Allocates a new empty directory, meaning this will emulate the fresh Hudson installation.
*/
HudsonHomeLoader NEW = new HudsonHomeLoader() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this be a lambda function?

File src = new File(source.toURI());
if(src.isDirectory())
new FilePath(src).copyRecursiveTo("**/*",new FilePath(target));
else
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to add some curly braces here for clarity.

* @param <T>
* The recipe annotation associated with this runner.
*/
abstract class Runner<T extends Annotation> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about compatibility, but would it be possible to refactor this into an interface with default methods?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer to create a follow-up task for now

@@ -0,0 +1,57 @@
package io.jenkins.jenkinsfile.runner.util;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a license header.

@@ -0,0 +1,16 @@
package io.jenkins.jenkinsfile.runner.util;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a license header.

* Allocates temporary directories and cleans it up at the end.
* @author Kohsuke Kawaguchi
*/
public class TemporaryDirectoryAllocator {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be too late at this point, but doesn't the JUnit TemporaryFolder rule do this, too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My plan is to get rid of JUnit... and this implementation as well. We really need a really simple mapper to a fixed directory, no magic required for Jenkinsfile Runner

Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a ton of stuff here that does not look necessary at all. I do not understand why we would bother to remove the JTH binary dependency, only to copy & paste all this stuff which only exists for tests and has no relevance to the purpose.

Would it not be simpler to throw out this repo and start with @ndeloof’s, which seems to have a cleaner design?

@oleg-nenashev
Copy link
Member Author

There is a ton of stuff here that does not look necessary at all. I do not understand why we would bother to remove the JTH binary dependency, only to copy & paste all this stuff which only exists for tests and has no relevance to the purpose.

The code will change late to improve performance. By moving the code here, we have no risk of breaking the JTH use-cases

Would it not be simpler to throw out this repo and start with @ndeloof’s, which seems to have a cleaner design?

Performance, again. This repo, even it has a non-production design (powered by JUnit, yey!), gave me much better startup time than the one from @ndeloof . Assuming I find enough time, I want to gradually integrate Nicolas' codebase and to move performance tweaks to the Jenkins core directly where possible

@oleg-nenashev oleg-nenashev merged commit 66626ef into jenkinsci:master Nov 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants