python-jenkins/tests/jobs
Tomas Janousek b5a8b7035e Request multiple folder levels at once in get_all_jobs
On our Jenkins instance with almost a hundred folders, JJB update
stalls for quite a while because it calls get_all_jobs. When invoked
locally at the Jenkins master, it's a matter of seconds, on a fast
broadband link and VPN, it's 2 minutes, and on a train it's easily 10
minutes.

But there's trick!

    curl \
        --show-error --silent --fail \
        --user : --negotiate \
        --get \
        --data-urlencode \
            tree=jobs\[url\,name\,jobs\[url\,name\,jobs\[url\,name\,\
            jobs\[url\,name\,jobs\[url\,name\,jobs\[url\,name\,\
            jobs\[url\,name\,jobs\[url\,name\,jobs\[url\,name\,\
            jobs\[url\,name\,jobs\]\]\]\]\]\]\]\]\]\]
        https://jenkins.example.com/api/json

This returns almost instantly.

And it gets better: if we fail to correctly guess the nesting level
necessary, Jenkins returns

    …, "jobs": [{}, {}, …], …

so we can easily detect that we need to recurse deeper.

Change-Id: I7268259149e4bc8939c512a112c7e6ec1908224f
2018-10-17 18:06:56 +02:00
..
__init__.py Separate tests in separate files and classes 2015-08-25 01:11:47 +01:00
base.py Request multiple folder levels at once in get_all_jobs 2018-10-17 18:06:56 +02:00
test_assert.py Adds Cloudbees folder plugin support 2015-09-21 18:25:35 +01:00
test_build.py Check for 'Location' header in the response 2018-06-25 12:59:38 +03:00
test_config.py Migration to using requests 2018-02-12 11:16:54 +00:00
test_copy.py Migration to using requests 2018-02-12 11:16:54 +00:00
test_count.py Separate tests in separate files and classes 2015-08-25 01:11:47 +01:00
test_create.py Migration to using requests 2018-02-12 11:16:54 +00:00
test_debug.py Migration to using requests 2018-02-12 11:16:54 +00:00
test_delete.py Migration to using requests 2018-02-12 11:16:54 +00:00
test_disable.py Migration to using requests 2018-02-12 11:16:54 +00:00
test_enable.py Migration to using requests 2018-02-12 11:16:54 +00:00
test_get.py Request multiple folder levels at once in get_all_jobs 2018-10-17 18:06:56 +02:00
test_getall.py Request multiple folder levels at once in get_all_jobs 2018-10-17 18:06:56 +02:00
test_info.py Migration to using requests 2018-02-12 11:16:54 +00:00
test_name.py Migration to using requests 2018-02-12 11:16:54 +00:00
test_reconfig.py Migration to using requests 2018-02-12 11:16:54 +00:00
test_rename.py Migration to using requests 2018-02-12 11:16:54 +00:00
test_set_next_build_number.py Migration to using requests 2018-02-12 11:16:54 +00:00