Way to use api rest call with Test-Harness

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Way to use api rest call with Test-Harness

maxim.chouinard
Hey guys, 

       I'm currently writing a gradle plugin that import job/view/folder/pipeline from a job directory to a jenkins instance.

In the plugin i use httpClient, to post/get request that validate if the job exist or create it. I tried my plugin with a local and a cloud instance and it work great, But with the test harness, it looks like the JenkinsRule instance use the same thread than my test and somehow the response from the jenkins jetty instance always give 404.

Do you guys know a way to test restApi based functionality without having to spawn a jenkins docker instance?
Otherwise, a way to have a JenkinsRule Async?

Thanks

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/bef0129d-732c-44d2-bcf5-6e9673bab5d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Way to use api rest call with Test-Harness

Jesse Glick-4
On Fri, Feb 17, 2017 at 10:17 AM,  <[hidden email]> wrote:
> somehow the response from the
> jenkins jetty instance always give 404.

Well track down why. Plenty of tests using
`JenkinsRule.createWebClient` successfully.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr3m7aeBP7dvLXj36mgxoYjSvXksdh3pZ4d30O6FvgRz7g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Way to use api rest call with Test-Harness

maxim.chouinard
I will dig in there a bit. I was wondering , if someone had perform that kind of test before.

output from my test:
GET : http://localhost:60768/jenkins/crumbIssuer/api/json 404 [Authorization:Basic YWRtaW46ZDk3MTYwOTZkMzY3YTA3MzI4OWVmNGM4MTFiYjY2MmI=]

manual curl in the console:  
curl -XGET 'http://localhost:60768/jenkins/crumbIssuer/api/json' --user admin:password                                                                                                                                                                                                                 09:06:10
{"_class":"org.jvnet.hudson.test.TestCrumbIssuer","crumb":"test","crumbRequestField":"Jenkins-Crumb"}

On Fri, Feb 17, 2017 at 10:30 AM, Jesse Glick <[hidden email]> wrote:
On Fri, Feb 17, 2017 at 10:17 AM,  <[hidden email]> wrote:
> somehow the response from the
> jenkins jetty instance always give 404.

Well track down why. Plenty of tests using
`JenkinsRule.createWebClient` successfully.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/1z0SDAP4U1M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr3m7aeBP7dvLXj36mgxoYjSvXksdh3pZ4d30O6FvgRz7g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--
Maxim Chouinard
Java Developer / Ingeno
c: 1 (418) 456-6706
skype: maxim.chouinard

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAE1CGz9aVFb%2BxdsCeevEOOyXh6dtOJc%3DRsq%2BeGgJCfZrzx743Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Way to use api rest call with Test-Harness

Jesse Glick-4
On Fri, Feb 17, 2017 at 10:35 AM, Maxim Chouinard
<[hidden email]> wrote:
> output from my test:
> GET : http://localhost:60768/jenkins/crumbIssuer/api/json 404

Why is your test asking for the crumb? See the utilities in
`JenkinsRule.WebClient` to add a crumb to a request for you.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr0zMnzWwMF3Y68RbFXD9C7mSx%2BByAFJy7n3nD2LaDWqhg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Way to use api rest call with Test-Harness

maxim.chouinard
The plugin add jobs via the rest api, so in my integration test i want to use the same behaviour but against a jenkins instance, maybe i should use a dockerized jenkins instead


 
Why is your test asking for the crumb? See the utilities in
`JenkinsRule.WebClient` to add a crumb to a request for you.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAE1CGz9Wv27RraqSHiz-52zJdSEuG-Rnnembrfkxn07Rcci6pA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Way to use api rest call with Test-Harness

Jesse Glick-4
Hold on, you are writing a *Gradle* plugin? Then do not use
`jenkins-test-harness`, this is only for tests of Jenkins plugins.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr0yg5vwgVhD85hSGT1QcV%3DLqDHD2n-5HoJNdjWyNGGZ-A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.