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

Wip tests #1259

Closed
wants to merge 6 commits into from
Closed

Wip tests #1259

wants to merge 6 commits into from

Conversation

jtnord
Copy link
Member

@jtnord jtnord commented Jul 18, 2017

just a PR for @vivek

Copy link
Collaborator

@vivek vivek left a comment

Choose a reason for hiding this comment

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

Thanks for making these tests org aware and improving tests in general, specially with authz it should work now.

Changes look fine, there is commented code in one of the test, please remove that.

}
}

// private static class DummyOrganisationAutorizationStrategy extends AuthorizationStrategy {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove the commented code

@@ -599,7 +601,7 @@ protected User login(String userId, String fullName, String email) throws IOExce

UserDetails d = Jenkins.getInstance().getSecurityRealm().loadUserByUsername(bob.getId());

SecurityContextHolder.getContext().setAuthentication(new PrincipalAcegiUserToken(bob.getId(),bob.getId(),bob.getId(), d.getAuthorities(), bob.getId()));
SecurityContextHolder.getContext().setAuthentication(new PrincipalAcegiUserToken(bob.getId(),bob.getId(),bob.getId(), d.getAuthorities(), new PrincipalSid(bob.getId())));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, so this was it. Thanks:)

Copy link
Member Author

Choose a reason for hiding this comment

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

nope - just pushing what I have been trying to get this to work....

@@ -31,7 +31,7 @@
<jacoco.line.coverage>0.70</jacoco.line.coverage>
<jacoco.missedclass.coverage>0.00</jacoco.missedclass.coverage>
<hpi.dependencyResolution>runtime</hpi.dependencyResolution>
<jenkins-test-harness.version>2.15</jenkins-test-harness.version>
<jenkins-test-harness.version>2.23</jenkins-test-harness.version>
Copy link
Collaborator

Choose a reason for hiding this comment

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

We had trouble upgrading to latest test harness. Lets see if CI is happy.

Copy link
Member Author

Choose a reason for hiding this comment

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

2.16 is needed for MockAuthorizationStrategy

@michaelneale
Copy link
Member

michaelneale commented Jul 18, 2017

@vivek often times James has noted that unit tests fail (I have seen it in the past, mostly it is a 403 error returned instead of a 200 in a unit test) - and a few others. Subsequent runs pass. Is this possibly related? A lot of these tests are failing due to 403 @vivek - which is what I see from time to time (CredentialsApiTests also fail) - is there some loading/race problem?

@jtnord
Copy link
Member Author

jtnord commented Jul 18, 2017

the wiremock setup is completely broken. If you look at the test output The Github Folder fails

Jul 18, 2017 11:01:39 PM jenkins.scm.api.SCMSourceEvent$DispatcherImpl log
WARNING: SCMEventListener.onSCMSourceEvent(SCMSourceEvent) jenkins.branch.MultiBranchProject$SCMEventListenerImpl@67b9d6f3 propagated an exception
java.lang.NoClassDefFoundError: org/apache/commons/io/Charsets
        at jenkins.branch.MultiBranchProject$SCMEventListenerImpl.globalEventsListener(MultiBranchProject.java:1098)
        at jenkins.branch.MultiBranchProject$SCMEventListenerImpl.onSCMSourceEvent(MultiBranchProject.java:1661)
        at jenkins.scm.api.SCMSourceEvent$DispatcherImpl.fire(SCMSourceEvent.java:179)
        at jenkins.scm.api.SCMSourceEvent$DispatcherImpl.fire(SCMSourceEvent.java:162)
        at jenkins.scm.api.SCMEvent$Dispatcher.run(SCMEvent.java:481)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.Charsets
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 12 more

Fixing this issue (you are using 1.34of commons io rather than the 2.something that is required causes loads of the tests to fail as wiremock no longer sees the expected calls .

public void canCreateWhenHavePermissionsOnDefaultOrg() throws Exception {
MockAuthorizationStrategy authz = new MockAuthorizationStrategy();
authz.grant(Jenkins.ADMINISTER).everywhere().to(user.getId());
j.jenkins.setAuthorizationStrategy(authz);
Copy link
Member Author

Choose a reason for hiding this comment

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

the jwt token becomes invalid.
a call to jwtToken = getJwtToken(j.jenkins, "vivek", "vivek"); seems to fix the issue.
`

@jtnord
Copy link
Member Author

jtnord commented Jul 18, 2017

I'm not expecting a review of this - its just so I can trigger builds on the CI.
@michaelneale I may have fixed the intermittent 403/201 issue (I thought I had pushed it here but it seems not). will ping you when it lands.

@@ -54,12 +56,18 @@
public abstract class PipelineBaseTest{
private static final Logger LOGGER = LoggerFactory.getLogger(PipelineBaseTest.class);

public PipelineBaseTest() {
@BeforeClass
public static void enableJWT() {
Copy link
Member Author

Choose a reason for hiding this comment

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

@michaelneale FYI this could have been the cause of some of the 403 vs 200 failures (although I have not verified this at all)

Improve the test coverage and demonstrate the issue with MBP and custom
organizations.
shouldFailOnValidation4 is the test that fails in this case.
@vivek
Copy link
Collaborator

vivek commented Jul 19, 2017

@jtnord

the wiremock setup is completely broken. If you look at the test output The Github Folder fails
Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.Charsets
...
Fixing this issue (you are using 1.34of commons io rather than the 2.something that is required causes loads of the tests to fail as wiremock no longer sees the expected calls .

Hmm, don't see such error in blueocean build log or when I build it locally. I wonder this is due to windows env? I am afraid if we are fixing issues that is specific to windows env and might make things worse otherwise.

@jtnord
Copy link
Member Author

jtnord commented Jul 19, 2017

the wiremock setup is completely broken. If you look at the test output The Github Folder fails
Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.Charsets

Fixing this issue (you are using 1.34of commons io rather than the 2.something that is required causes loads of the tests to fail as wiremock no longer sees the expected calls .

Hmm, don't see such error in blueocean build log or when I build it locally. I wonder this is due to windows env? I am afraid if we are fixing issues that is specific to windows env and might make things worse otherwise.

it is not in the build log - it is in the unit test output.
You will see it if you only run the one test with -Dtest=GithubOrgFolderTest.java

This is not windows specific - you can see the cause of the issue with mvn dependency:tree (or update to the latest parent pom where the enforcer will fail the build)

@vivek
Copy link
Collaborator

vivek commented Jul 19, 2017

@jtnord Ah, right. its indexing where its failing. These tests do not check result of indexing that is why they went unnoticed. Thanks for the fix:)

@jtnord
Copy link
Member Author

jtnord commented Jul 19, 2017

Ah, right. its indexing where its failing. These tests do not check result of indexing that is why they went unnoticed. Thanks for the fix:)

@vivek I have not fixed that - I did but then with the amount of wiremock failures I decided not to, and just add tests to cover the issues I am fixing :)

@vivek
Copy link
Collaborator

vivek commented Jul 19, 2017

@jtnord no problem. I will take care of it, I have opened https://issues.jenkins-ci.org/browse/JENKINS-45662. Thanks.

@jtnord jtnord closed this Jul 20, 2017
@jtnord
Copy link
Member Author

jtnord commented Jul 20, 2017

all rebased into #1252

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants