Debugging HtmlUnit: FailingHttpStatusCodeException 500 Server Error

315 views
Skip to first unread message

Alexandra Goultiaeva

unread,
Sep 27, 2017, 4:53:46 PM9/27/17
to Jenkins Developers
I am working on Jenkins Unit tests, and am trying to add a round trip test.
Unfortunately, I keep getting errors.


I've added the roundtrip test ClassicUploadStepTest
When I run the test, I get the following error:
com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException: 500 Server Error for http://localhost:33657/jenkins/job/test0/configure

I've played with the test a bit, and found that if I comment out my setUp, the test works. It seems that the test breaks as soon as I add the following line:
SystemCredentialsProvider.getInstance().getCredentials().add(credentials);
I'm somewhat at a loss as to how to debug this further.
Stack traces seem to point to where the exception is thrown (throwFailingHttpStatusCodeExceptionIfNecessary), and not where the error occurred. The error itself is quite generic.

Any hints on how to approach this?
How can I try to get at the root cause for the 500?

Thanks!


PS. This is the stack trace I'm getting:
testRoundtrip(com.google.jenkins.plugins.storage.ClassicUploadStepTest)  Time elapsed: 6.1 sec  <<< ERROR!
com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException: 500 Server Error for http://localhost:37367/jenkins/job/test0/configure
at com.gargoylesoftware.htmlunit.WebClient.throwFailingHttpStatusCodeExceptionIfNecessary(WebClient.java:535)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:360)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:415)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:400)
at org.jvnet.hudson.test.JenkinsRule$WebClient.goTo(JenkinsRule.java:2148)
at org.jvnet.hudson.test.JenkinsRule$WebClient.goTo(JenkinsRule.java:2128)
at org.jvnet.hudson.test.JenkinsRule$WebClient.getPage(JenkinsRule.java:2084)
at org.jvnet.hudson.test.JenkinsRule.configRoundtrip(JenkinsRule.java:1077)
at org.jvnet.hudson.test.JenkinsRule.configRoundtrip(JenkinsRule.java:1087)
at com.google.jenkins.plugins.storage.ClassicUploadStepTest.ConfigurationRoundTripTest(ClassicUploadStepTest.java:82)
at com.google.jenkins.plugins.storage.ClassicUploadStepTest.testRoundtrip(ClassicUploadStepTest.java:89)

Robert Sandell

unread,
Sep 28, 2017, 5:11:36 AM9/28/17
to jenkin...@googlegroups.com
A 500 server error is an indication that an exception was thrown in the backend when the http request was made.
You should see another stacktrace in the log just before the FailingHttpstatusCodeException.

/B

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/587d5c60-f702-4621-942c-6688b6a8d58b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Robert Sandell
Software Engineer
CloudBees Inc.

Alexandra Goultiaeva

unread,
Sep 28, 2017, 11:29:00 AM9/28/17
to Jenkins Developers
Ooh, right, thanks!

In case there will be another newbie reading this:
The output from "mvn package" contains the last exception thrown, but it's not the whole log!

Running the individual test gave the full log:
mvn test -Dtest=com.google.jenkins.plugins.storage.ClassicUploadStepTest

In my case I haven't mocked out getDescriptor(), so it returns nullptr and the server dies with NullPointerException

Thanks for getting me on track again!


To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages