Skip to content

Update parent pom, update jenkins core, use bom #238

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

Merged
merged 7 commits into from
Oct 23, 2019
Merged

Update parent pom, update jenkins core, use bom #238

merged 7 commits into from
Oct 23, 2019

Conversation

jetersen
Copy link
Member

Your checklist for this pull request

  • Make sure you are requesting to pull a topic/feature/bugfix branch (right side) and not your master branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or in Jenkins JIRA
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Did you provide a test-case? That demonstrates feature works or fixes the issue.

@jetersen
Copy link
Member Author

@amuniz @stephenc I would appreciate if you could have a look at the test failures.

I am not even sure why this is failing but it seems to be related to the mocking/spying.
https://ci.jenkins.io/blue/organizations/jenkins/Plugins%2Fbitbucket-branch-source-plugin/detail/PR-238/1/tests

In a live instance everything is working.

@amuniz
Copy link
Member

amuniz commented Oct 23, 2019

Failure in indexing logs is:

ERROR: [Wed Oct 23 09:58:28 CEST 2019] Could not fetch branches from source b4e9d6d4-23e5-438a-968f-4904bea3ed07
org.mockito.exceptions.misusing.WrongTypeOfReturnValue: 
Default answer returned a result with the wrong type:
MultiBranchProjectImpl cannot be returned by getParent()
getParent() should return Jenkins

The default answer of freeStyleProject that was configured on the mock is probably incorrectly implemented.

	at com.cloudbees.hudson.plugins.folder.FolderJobQueueDecisionHandler.shouldSchedule(FolderJobQueueDecisionHandler.java:52)
	at hudson.model.Queue.schedule2(Queue.java:591)
	at jenkins.model.ParameterizedJobMixIn.scheduleBuild2(ParameterizedJobMixIn.java:156)
	at jenkins.model.ParameterizedJobMixIn.scheduleBuild(ParameterizedJobMixIn.java:116)
	at jenkins.model.ParameterizedJobMixIn.scheduleBuild(ParameterizedJobMixIn.java:105)
	at jenkins.model.ParameterizedJobMixIn$ParameterizedJob.scheduleBuild(ParameterizedJobMixIn.java:383)
	at hudson.model.BuildableItem.scheduleBuild(BuildableItem.java:44)
	at com.cloudbees.jenkins.plugins.bitbucket.BranchScanningIntegrationTest$MultiBranchProjectImpl$BranchProjectFactoryImpl.newInstance(BranchScanningIntegrationTest.java:205)
	at com.cloudbees.jenkins.plugins.bitbucket.BranchScanningIntegrationTest$MultiBranchProjectImpl$BranchProjectFactoryImpl.newInstance(BranchScanningIntegrationTest.java:197)
	at jenkins.branch.MultiBranchProject$SCMHeadObserverImpl.observeNew(MultiBranchProject.java:2054)
	at jenkins.branch.MultiBranchProject$SCMHeadObserverImpl.observe(MultiBranchProject.java:1985)
	at jenkins.scm.api.trait.SCMSourceRequest.process(SCMSourceRequest.java:357)
	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.retrieveBranches(BitbucketSCMSource.java:748)
	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.retrieve(BitbucketSCMSource.java:589)
	at jenkins.scm.api.SCMSource._retrieve(SCMSource.java:373)
	at jenkins.scm.api.SCMSource.fetch(SCMSource.java:283)
	at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:635)
	at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:277)
	at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:164)
	at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:1026)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:429)

It's weird, because the only mocking around those tests is the BB API mock, which has nothing to do with Jenkins jobs (even less with freestyle jobs...)

@stephenc
Copy link
Member

I have given up on mocks for testing these kinds of things

@amuniz
Copy link
Member

amuniz commented Oct 23, 2019

I think I found the problem.
This is fixing the issue:

a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BranchScanningIntegrationTest.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BranchScanningIntegrationTest.java
index b365a78..95afab8 100644
--- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BranchScanningIntegrationTest.java
+++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BranchScanningIntegrationTest.java
@@ -191,13 +191,9 @@ public class BranchScanningIntegrationTest {
 
             @Override
             public FreeStyleProject newInstance(Branch branch) {
-                FreeStyleProject job = new FreeStyleProject(getOwner(), branch.getName());
-                job.onCreatedFromScratch();
-                FreeStyleProject spied = spy(job);
-                // Do nothing.. Running the actual build is not desired/required (and not possible) in this tests.
-                when(spied.scheduleBuild()).thenReturn(false);
-                setBranch(spied, branch);
-                return spied;
+                FreeStyleProject job = new FreeStyleProject(getOwner(), branch.getEncodedName());
+                setBranch(job, branch);
+                return job;
             }
 
             @Override

That spying on the job was causing problems, and is not needed anymore, I believe.

@jetersen
Copy link
Member Author

fixed two of them. Down to one test which is also doing some odd mocking 😓

Seems like mockito cannot mock a super method being called on a sub class
@jetersen
Copy link
Member Author

Not sure what changed in mocktio 3 that does not allow calling real method on a subclass when call is done on super

@jetersen jetersen changed the title Update deps Update parent pom, update jenkins core, use bom Oct 23, 2019
@jetersen jetersen merged commit b5e197d into jenkinsci:master Oct 23, 2019
@jetersen jetersen deleted the updateDeps branch October 23, 2019 20:47
@jetersen jetersen added the chore label Oct 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants