Skip to content

Conversation

@Jagrutiti
Copy link
Contributor

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@Jagrutiti
Copy link
Contributor Author

Hey @MarkEWaite

I intend to complete the getParameter test case. I read about AbstractBuild and TaskListener.

My best guess is I have to assert the labelExpanded variable.

But I was not sure how to initialize AbstractBuild and TaskListener in this method.

@MarkEWaite
Copy link
Contributor

MarkEWaite commented Oct 23, 2022

I think there are at least two alternatives.

The most typical technique will test more deeply, but runs slower. It involves using a JenkinsRule to define a job with a node parameter then run the job and get the resulting run as a build. That path will let you explore Jenkins objects as they are used in Jenkins core. See AllNodesForLabelBuildParameterFactoryTest.java for an example of that technique.

The less typical technique tests less deeply but runs faster. It involves using mock objects to create the desired Java objects. Refer to https://github.com/jenkinsci/embeddable-build-status-plugin/pull/117/files for an example of that technique that arrived during Hacktoberfest.

I have a personal preference for the first technique because it is more widely used and tests more of the components, but it is only usable in the Jenkins code base. However, the second technique is valid and is a good technique to use in many different code bases, not just the Jenkins code base. I've had bad experiences with mocking in tests in the past and those bad experiences tend to lead me away from mock objects. Mock objects applied with skill and care can be a great help. Mock objects applied too broadly or poorly can create a "mess" for later maintainers.

@Jagrutiti
Copy link
Contributor Author

Hey @MarkEWaite

Thanks for sharing the link to the test case. It helped me understand how to proceed.

I found the class I am testing and the one you shared as a reference quite similar (feel free to correct me). Though their function is different.

From the if condition I understand that I have to check for a blank and non-blank string.

The JenkinsRule documentation is huge. I made sure not to skip the methods invoked by JenkinsRules in AllNodesForLabelBuildParameterFactoryTest.

In testLabelFactoryNonBlocking, createFreeStyleProject() and createSlaves() methods are used.

I was confused about how do I decide which method I should use from JenkinsRule.


Though the following line in getParameters() in AllNodesForLabelBuildParameterFactory class:

labelExpanded = TokenMacro.expandAll(build, listener, labelExpanded);

and the below in getParameters() in NodeListBuildParameterFactory class:

nodeListStringExpanded = TokenMacro.expandAll(build, listener, nodeListStringExpanded);

is common.

I did not understand how to test it.

@Jagrutiti
Copy link
Contributor Author

Also,

I forgot to mention I am using the first technique.

I do not have the expertise to mock.

And would like to try JenkinsRule.

@MarkEWaite
Copy link
Contributor

Also,

I forgot to mention I am using the first technique.

I do not have the expertise to mock.

And would like to try JenkinsRule.

I won't be able to help until the end of this week at the earliest. I'm traveling with family and visiting friends.

@Jagrutiti
Copy link
Contributor Author

Hey @MarkEWaite

Happy Holidays.

I would await your guidance when you're back.

@MarkEWaite
Copy link
Contributor

Thanks. I'm afraid that there are other reviews and improvements that are much higher on my list than this one. It will likely be several more weeks before I'm able to look at this. Sorry about that.

@Jagrutiti
Copy link
Contributor Author

Hey @MarkEWaite

Thank you for replying.

I hope you will remember that I am waiting for your guidance when you are free from your priority work.

Or if you give me an estimation of when I can text you, I will ping you again.

@MarkEWaite
Copy link
Contributor

Ping me again in two weeks

@Jagrutiti
Copy link
Contributor Author

Hey @MarkEWaite

Is this a good time to ping you again?

@MarkEWaite
Copy link
Contributor

Thanks for the reminder. It will be another week before I can help here. There is a pull request on the git plugin that I need to test, merge, and release before I can help here. See jenkinsci/git-plugin#1305 for details

@Jagrutiti
Copy link
Contributor Author

Hey @MarkEWaite

Do you think I can lend you a hand with this release?

@MarkEWaite
Copy link
Contributor

Do you think I can lend you a hand with this release?

That's a great idea! I need to test

by duplicating JENKINS-42971 while running the most recent release of the git plugin, then confirm that the issue is resolved after installing the most recent plugin build (hpi file) from that pull request. Once that is confirmed, I need some exploratory testing to confirm that the change did not harm any other functionality of the plugin.

Once I've completed that testing, I'll merge that pull request and release a new version of the git plugin.

Any help that you can give to those efforts would be greatly appreciated.

If you need a Docker container to help with that setup and want to experiment with docker, you could use my docker-lfs branch lts-with-plugins that already includes that git plugin version in its definition.

I also understand if you're not available to help with that. Testing and releasing that plugin is my responsibility, but I'd love to have any help that you can offer. Even if that help is "I installed the pre-release of the plugin and found no issues in my interactive testing".

@Jagrutiti
Copy link
Contributor Author

Hey @MarkEWaite

I am available to help you with this :)

@Jagrutiti
Copy link
Contributor Author

Hey @MarkEWaite

Where would I get the docker command to install the plugin?

I mean I went through the command in docker-lfs read.me file but did not find the instructions to install it.

You have shared this line of code but I am not sure how to use it.

@MarkEWaite
Copy link
Contributor

If you checkout the lts-with-plugins branch locally, you should be able to run the command docker_build.py to build the container image that includes the plugins.

If the container image has problems building (since I've not checked with others that it works outside my environment), then you can place that plugins.txt in a directory and run the following bash script:

#!/bin/bash
JENKINS_WAR_VERSION=2.361.4
JENKINS_WAR=jenkins-${JENKINS_WAR_VERSION}.war
PLUGIN_MANAGER_VERSION=2.12.9
PLUGIN_MANAGER_JAR=jenkins-plugin-manager-${PLUGIN_MANAGER_VERSION}.jar

if [ ! -f ../$PLUGIN_MANAGER_JAR ]; then
  wget https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/${PLUGIN_MANAGER_VERSION}/$PLUGIN_MANAGER_JAR
  mv $PLUGIN_MANAGER_JAR ..
fi
if [ ! -d plugins ]; then
  mkdir plugins
fi
java -jar ../$PLUGIN_MANAGER_JAR --jenkins-version $JENKINS_WAR_VERSION \
  --latest false --plugin-download-directory plugins --plugin-file plugins.txt

if [ ! -f ../$JENKINS_WAR ]; then
  wget https://get.jenkins.io/war-stable/${JENKINS_WAR_VERSION}/jenkins.war
  mv jenkins.war ../$JENKINS_WAR
fi

JENKINS_HOME=. java -jar ../$JENKINS_WAR

@Jagrutiti
Copy link
Contributor Author

Hey @MarkEWaite

From the instructions and reading the issue, I understand that it is manual testing and I have to install the plugin (before and after release).

If you could share with me what I have to install from where,
and a documentation with steps to install on Windows, it would be quite helpful.

I hope I am not increasing your task by asking for help. I am here to take some workload off you.

If I am taking too much of your time I would understand if you do not want to guide me on this issue.

@Jagrutiti
Copy link
Contributor Author

If you checkout the lts-with-plugins branch locally, you should be able to run the command docker_build.py to build the container image that includes the plugins.

This helps. I will try it. Thanks.

@MarkEWaite
Copy link
Contributor

That python script is unlikely to work on Windows. I've wanted to develop the instructions for Windows anyway, so this is a good excuse to create instructions for Windows. Will need some time so that I can finish current Jenkins and work meetings

@MarkEWaite
Copy link
Contributor

MarkEWaite commented Nov 17, 2022

Here is the batch file that does most of the same things that bash script does:

SET JENKINS_VERSION=2.361.4
SET JENKINS_WAR=..\jenkins-%JENKINS_VERSION%.war
IF NOT EXIST %JENKINS_WAR% (
   curl --location --output %JENKINS_WAR% https://get.jenkins.io/war-stable/%JENKINS_VERSION%/jenkins.war
)

IF NOT EXIST plugins (
    mkdir plugins
)

SET PLUGIN_MANAGER_VERSION=2.12.9
SET PLUGIN_MANAGER_FILE_NAME=jenkins-plugin-manager-%PLUGIN_MANAGER_VERSION%.jar
SET PLUGIN_MANAGER_JAR=..\%PLUGIN_MANAGER_FILE_NAME%

IF NOT EXIST %PLUGIN_MANAGER_JAR% (
   curl --location --output %PLUGIN_MANAGER_JAR% https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/%PLUGIN_MANAGER_VERSION%/%PLUGIN_MANAGER_FILE_NAME%
)

java -jar %PLUGIN_MANAGER_JAR% --war %JENKINS_WAR% --latest false --plugin-download-directory plugins --plugin-file plugins.txt

set JENKINS_HOME=.
java -jar %JENKINS_WAR%

@Jagrutiti
Copy link
Contributor Author

Here is the batch file that does most of the same things that bash script does:

Hey @MarkEWaite

Here are the steps I followed:

  1. Clone docker-ltfs

  2. Created account at https://hub.docker.com/.

Use these credentials below to login in command prompt:

  1. $ docker login

  2. $ docker build -t <username>/opens .

  3. Next, I pasted the above code the in a .bat file and ran it as Windows Administrator.

Step no.5 is still in progress. The download speed of my internet speed is 30 Mbps. It has been almost an hour since the command is executed.

Keeping you posted.

Let me know the next steps after this.

@Jagrutiti
Copy link
Contributor Author

Hey @MarkEWaite

Step no.5 from above fails:

$ java -jar %PLUGIN_MANAGER_JAR% --war %JENKINS_WAR% --latest false --plugin-download-directory plugins --plugin-file plugins.txt
Provider "jar" not found

This command throws the error: Provider "jar" not found

When I run it individually this way:

$ java -jar jenkins-plugin-manager-2.12.9.jar --war jenkins-2.361.4.war --latest false --plugin-download-directory plugins --plugin-file plugins.txt

I get:

Unable to open jenkins-2.361.4.war

Unable to get Jenkins version from the WAR file jenkins-2.361.4.war

Provider "jar" not found

@Jagrutiti
Copy link
Contributor Author

Hey @MarkEWaite

The good news is I tried again and it worked.

It is stuck asking me to paste the password. I do not know where to paste the password. I know what the password is.

Here are the logs:

D:\open-source>java -jar ..\jenkins-2.361.4.war
Running from: D:\jenkins-2.361.4.war
webroot: EnvVars.masterEnvVars.get("JENKINS_HOME")
2022-11-18 15:16:10.837+0000 [id=1]     INFO    winstone.Logger#logInternal: Beginning extraction from war file
2022-11-18 15:16:10.880+0000 [id=1]     WARNING o.e.j.s.handler.ContextHandler#setContextPath: Empty contextPath
2022-11-18 15:16:10.954+0000 [id=1]     INFO    org.eclipse.jetty.server.Server#doStart: jetty-10.0.11; built: 2022-06-21T21:12:44.640Z; git: d988aa016e0bb2de6fba84c1659049c72eae3e32; jvm 11.0.17+10-LTS-269
2022-11-18 15:16:12.540+0000 [id=1]     INFO    o.e.j.w.StandardDescriptorProcessor#visitServlet: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
2022-11-18 15:16:12.604+0000 [id=1]     INFO    o.e.j.s.s.DefaultSessionIdManager#doStart: Session workerName=node0
2022-11-18 15:16:13.086+0000 [id=1]     INFO    hudson.WebAppMain#contextInitialized: Jenkins home directory: D:\open-source\. found at: EnvVars.masterEnvVars.get("JENKINS_HOME")
2022-11-18 15:16:13.218+0000 [id=1]     INFO    o.e.j.s.handler.ContextHandler#doStart: Started w.@15723761{Jenkins v2.361.4,/,file:///D:/open-source/war/,AVAILABLE}{D:\open-source\.\war}
2022-11-18 15:16:13.238+0000 [id=1]     INFO    o.e.j.server.AbstractConnector#doStart: Started ServerConnector@6f45df59{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
2022-11-18 15:16:13.260+0000 [id=1]     INFO    org.eclipse.jetty.server.Server#doStart: Started Server@1356d4d4{STARTING}[10.0.11,sto=0] @3408ms
2022-11-18 15:16:13.262+0000 [id=26]    INFO    winstone.Logger#logInternal: Winstone Servlet Engine running: controlPort=disabled
2022-11-18 15:16:13.542+0000 [id=33]    INFO    jenkins.InitReactorRunner$1#onAttained: Started initialization
2022-11-18 15:16:15.324+0000 [id=40]    INFO    jenkins.InitReactorRunner$1#onAttained: Listed all plugins
2022-11-18 15:16:16.956+0000 [id=37]    INFO    jenkins.InitReactorRunner$1#onAttained: Prepared all plugins
2022-11-18 15:16:16.970+0000 [id=46]    INFO    jenkins.InitReactorRunner$1#onAttained: Started all plugins
2022-11-18 15:16:16.972+0000 [id=38]    INFO    jenkins.InitReactorRunner$1#onAttained: Augmented all extensions
2022-11-18 15:16:17.306+0000 [id=37]    INFO    jenkins.InitReactorRunner$1#onAttained: System config loaded
2022-11-18 15:16:17.307+0000 [id=43]    INFO    jenkins.InitReactorRunner$1#onAttained: System config adapted
2022-11-18 15:16:17.308+0000 [id=43]    INFO    jenkins.InitReactorRunner$1#onAttained: Loaded all jobs
2022-11-18 15:16:17.319+0000 [id=38]    INFO    jenkins.InitReactorRunner$1#onAttained: Configuration for all jobs updated
2022-11-18 15:16:17.337+0000 [id=59]    INFO    hudson.model.AsyncPeriodicWork#lambda$doRun$1: Started Download metadata
2022-11-18 15:16:17.344+0000 [id=59]    INFO    hudson.model.AsyncPeriodicWork#lambda$doRun$1: Finished Download metadata. 5 ms
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v7.Java7$1 (file:/D:/open-source/war/WEB-INF/lib/groovy-all-2.4.21.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.vmplugin.v7.Java7$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2022-11-18 15:16:17.458+0000 [id=39]    INFO    jenkins.install.SetupWizard#init:

*************************************************************
*************************************************************
*************************************************************

Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:

7343d87409b146e39224753de975b611

This may also be found at: D:\open-source\secrets\initialAdminPassword

*************************************************************
*************************************************************
*************************************************************

2022-11-18 15:16:28.998+0000 [id=34]    INFO    jenkins.InitReactorRunner$1#onAttained: Completed initialization
2022-11-18 15:16:29.028+0000 [id=25]    INFO    hudson.lifecycle.Lifecycle#onReady: Jenkins is fully up and running

The cursor just blinks with no prompt to paste the password.

Something like in the screenshot.

image

@MarkEWaite
Copy link
Contributor

It is stuck asking me to paste the password. I do not know where to paste the password. I know what the password is.

I'm glad it worked. Open your web browser to http://localhost:8080 and then you can configure Jenkins from inside your web browser. https://www.jenkins.io/doc/tutorials/#tools provides tutorials that can guide your experimenting as well

@Jagrutiti
Copy link
Contributor Author

Hey @MarkEWaite

It worked. I am installing the recommended plugins.

What is the next step?

@MarkEWaite
Copy link
Contributor

What is the next step?

Follow the instructions in JENKINS-42971 to duplicate the problem, then install the new build of the plugin and confirm that the problem is resolved by the git plugin pull request build:

@Jagrutiti
Copy link
Contributor Author

Hey @MarkEWaite

Step 3 to recreate the issue is: Enter the repository URL.

Which URL does it mean? And where shall I add it?

I have completed the first two steps. Attaching a screenshot.

image

@MarkEWaite
Copy link
Contributor

In my case, I entered the URL of a repository that I use for bug verification

  • Repository URL: https://github.com/MarkEWaite/JENKINS-26197.git
  • Branch to build: ${PIPELINE_BRANCH}

The surprising thing is that even with the patched git plugin, I still see the error that is noted in the bug report.

@Jagrutiti
Copy link
Contributor Author

Hey @MarkEWaite

You are right. It fails for me too.

Does this mean the issue is not resolved yet?

The testing stops here?

@MarkEWaite
Copy link
Contributor

Hey @MarkEWaite

You are right. It fails for me too.

Does this mean the issue is not resolved yet?

The testing stops here?

Thanks for confirming it! Yes, the testing is done. I'll need to switch into a debugger to understand why the case that we're testing still fails. The code changes seem reasonable to me, but there may be something missing in order to complete the fix of the issue.

@Jagrutiti
Copy link
Contributor Author

The code changes seem reasonable to me, but there may be something missing in order to complete the fix of the issue.

I cannot help you with anything as of now?

@Jagrutiti
Copy link
Contributor Author

Do you think I can document the steps? The Windows script you shared with me? If it isn't documented yet?

@MarkEWaite
Copy link
Contributor

Do you think I can document the steps? The Windows script you shared with me? If it isn't documented yet?

That would be a nice addition to add as a comment in

@Jagrutiti
Copy link
Contributor Author

Hey @MarkEWaite

Let me know anything else I can assist you with :)

To sum up what I did,

The script that you shared was to install Jenkins on my local machine?

Then I recreated the issue. Right?

@MarkEWaite
Copy link
Contributor

The script that you shared was to install Jenkins on my local machine?

Then I recreated the issue. Right?

Yes, though I'd describe it a little differently. You helped me evaluate a pull request by performing interactive testing of the original issue that the pull request is trying to resolve. In order to help me evaluate that pull request, you installed Jenkins, configured a test job, and observed the results of the test job. You compared behavior with lightweight checkout with the behavior without lightweight checkout. That provided some insights into a portion of the many different ways that Jenkins is used.

@Jagrutiti
Copy link
Contributor Author

You compared behavior with lightweight checkout with the behavior without lightweight checkout

I did not stand the meaning of the jargon lightweight checkout.

Thank you for giving me an opportunity to assist you.

I created a build a pipeline myself for the first time last night. I see Jenkins at work every day but never got this clarity until yesterday.

@MartinKosicky
Copy link

MartinKosicky commented Nov 22, 2022

Just to clarify, the lightweight checkout is "testable" only if you can use jenkinsci/workflow-cps-plugin#577 . It was currently drafted because it was waiting for the git plugin (there seems to be some cyclic dependency between the plugins mainly in tests). If you want to test the entire flow, I can undraft that PR jenkinsci/workflow-cps-plugin#577 and can use incremental build to test the lightweight checkout. (Actually that is how we use it in production)

@MarkEWaite
Copy link
Contributor

@Jagrutiti I am sincerely sorry, but I don't expect to have time to implement these tests in the next 1-2 months. I'm closing this pull request. We can decide to reopen it or create it anew in the future.

@MarkEWaite MarkEWaite closed this Apr 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants