diff --git a/.travis.yml b/.travis.yml index ca3237cd..777b002e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,11 +17,6 @@ script: - tox after_success: - codecov -branches: - only: - - master - - develop - - /^(\d+)\.(\d+)\.(\d+)$/ jobs: include: - stage: release @@ -38,5 +33,6 @@ jobs: - AUTHORS skip_cleanup: true on: + branch: master repo: pycontribs/jenkinsapi tags: true diff --git a/jenkinsapi_tests/systests/conftest.py b/jenkinsapi_tests/systests/conftest.py index 3f3c461f..379e5719 100644 --- a/jenkinsapi_tests/systests/conftest.py +++ b/jenkinsapi_tests/systests/conftest.py @@ -26,7 +26,8 @@ "https://updates.jenkins-ci.org/latest/ssh-slaves.hpi", "https://updates.jenkins-ci.org/latest/structs.hpi", "http://updates.jenkins-ci.org/latest/plain-credentials.hpi", - "http://updates.jenkins-ci.org/latest/envinject.hpi" + "http://updates.jenkins-ci.org/latest/envinject.hpi", + "http://updates.jenkins-ci.org/latest/envinject-api.hpi" ] diff --git a/jenkinsapi_tests/systests/test_restart.py b/jenkinsapi_tests/systests/test_restart.py index 4a2cc0dd..f3149021 100644 --- a/jenkinsapi_tests/systests/test_restart.py +++ b/jenkinsapi_tests/systests/test_restart.py @@ -12,38 +12,49 @@ log = logging.getLogger(__name__) -def wait_for_reboot(jenkins): - wait = 5 +def wait_for_restart(jenkins): + wait = 15 count = 0 max_count = 30 success = False - while count < max_count: + msg = ( + 'Jenkins has not restarted yet! (This is try %s of %s, ' + 'waited %s seconds so far) ' + 'Sleeping %s seconds and trying again...' + ) + + while count < max_count or not success: time.sleep(wait) try: jenkins.poll() + log.info('Jenkins restarted successfully.') success = True - except (HTTPError, ConnectionError): - msg = ("Jenkins has not restarted yet! (This is" - " try {0} of {1}, waited {2} seconds so far)" - " Sleeping and trying again..") - msg = msg.format(count, max_count, count*wait) - log.debug(msg) + break + except HTTPError as ex: + log.info(ex) + except ConnectionError as ex: + log.info(ex) + + log.info(msg, count + 1, max_count, count * wait, wait) count += 1 + if not success: - msg = ("Jenkins did not come back from safe restart! " - "Waited {0} seconds altogether. This " - "failure may cause other failures.") + msg = ('Jenkins did not come back from safe restart! ' + 'Waited {0} seconds altogether. This ' + 'failure may cause other failures.') log.critical(msg.format(count*wait)) - pytest.fail("msg") + pytest.fail(msg) def test_safe_restart(jenkins): jenkins.poll() # jenkins should be alive jenkins.safe_restart() - with pytest.raises(HTTPError): + # Jenkins sleeps for 10 seconds before actually restarting + time.sleep(11) + with pytest.raises((HTTPError, ConnectionError)): # this is a 503: jenkins is still restarting jenkins.poll() # the test is now complete, but other tests cannot run until # jenkins has finished restarted. to avoid cascading failure # we have to wait for reboot to finish. - wait_for_reboot(jenkins) + wait_for_restart(jenkins) diff --git a/jenkinsapi_utils/jenkins_launcher.py b/jenkinsapi_utils/jenkins_launcher.py index b35bc90f..f6e9d5b2 100644 --- a/jenkinsapi_utils/jenkins_launcher.py +++ b/jenkinsapi_utils/jenkins_launcher.py @@ -209,7 +209,7 @@ def start(self, timeout=60): if isinstance(line, bytes): line = line.decode('UTF-8') except queue.Empty: - log.warn("Input ended unexpectedly") + log.warning("Input ended unexpectedly") break else: if line: