Skip to content

Commit

Permalink
Fix safe exit test (#736)
Browse files Browse the repository at this point in the history
* ask Jenkins only for quietingDown
* don't wait for jenkins exit
  • Loading branch information
lechat authored Oct 21, 2019
1 parent e52a5a6 commit 713bb4f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions jenkinsapi/jenkins.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,9 @@ def credentials_by_id(self):

@property
def is_quieting_down(self):
url = '%s/api/python' % (self.baseurl,)
url = '%s/api/python?tree=quietingDown' % (self.baseurl,)
data = self.get_data(url=url)
return data['quietingDown']
return data.get('quietingDown', False)

def shutdown(self):
url = "%s/exit" % self.baseurl
Expand Down
2 changes: 1 addition & 1 deletion jenkinsapi/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def check_updates_server(self):

@property
def update_center_dict(self):
update_center = 'https://updates.jenkins-ci.org/update-center.json'
update_center = 'https://updates.jenkins.io/update-center.json'
jsonp = requests.get(update_center).content.decode('utf-8')
return json.loads(jsonp_to_json(jsonp))

Expand Down
8 changes: 5 additions & 3 deletions jenkinsapi_tests/systests/test_safe_exit.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,18 @@ def test_safe_exit(jenkins):
assert build.is_running()

# A job is now running and safe_exit should await running jobs
# Call, but wait only for 10 seconds then cancel exit
jenkins.safe_exit(max_wait=10)
# Call, but wait only for 5 seconds then cancel exit
jenkins.safe_exit(wait_for_exit=False)
time.sleep(5)

jenkins.cancel_quiet_down() # leave quietDown mode
assert jenkins.is_quieting_down is False

build.stop()
# if we call next line right away - Jenkins have no time to stop job
# so we wait a bit
time.sleep(5)
while build.is_running():
time.sleep(0.5)

console = build.get_console()
assert isinstance(console, str)
Expand Down
4 changes: 2 additions & 2 deletions jenkinsapi_utils/jenkins_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ class JenkinsLancher(object):
Launch jenkins
"""
JENKINS_WEEKLY_WAR_URL = (
"https://mirrors.jenkins-ci.org/war/latest/jenkins.war"
"https://updates.jenkins.io/latest/jenkins.war"
)
JENKINS_LTS_WAR_URL = (
"http:https://mirrors.jenkins-ci.org/war-stable/latest/jenkins.war"
"https:https://updates.jenkins.io/stable/latest/jenkins.war"
)

def __init__(self, local_orig_dir, systests_dir, war_name, plugin_urls=None,
Expand Down

0 comments on commit 713bb4f

Please sign in to comment.