Merge "Fix reloading under PY3" into stable/train
This commit is contained in:
commit
cf2fc1c144
|
@ -1,2 +1 @@
|
||||||
^glance\.tests\.functional\.test_reload\.TestReload\.test_reload$
|
|
||||||
^glance\.tests\.functional\.test_ssl\.TestSSL\.test_ssl_ok$
|
^glance\.tests\.functional\.test_ssl\.TestSSL\.test_ssl_ok$
|
||||||
|
|
|
@ -613,12 +613,17 @@ def stash_conf_values():
|
||||||
conf = {
|
conf = {
|
||||||
'bind_host': CONF.bind_host,
|
'bind_host': CONF.bind_host,
|
||||||
'bind_port': CONF.bind_port,
|
'bind_port': CONF.bind_port,
|
||||||
'tcp_keepidle': CONF.cert_file,
|
|
||||||
'backlog': CONF.backlog,
|
'backlog': CONF.backlog,
|
||||||
'key_file': CONF.key_file,
|
|
||||||
'cert_file': CONF.cert_file
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Note(jokke): As we can still support termination with PY27 we
|
||||||
|
# need to add the possible certs in that specific case. This is
|
||||||
|
# only needed prior Ussuri which doesn't support PY27 anymore.
|
||||||
|
if six.PY2:
|
||||||
|
conf['key_file'] = CONF.key_file,
|
||||||
|
conf['cert_file'] = CONF.cert_file
|
||||||
|
conf['tcp_keepidle'] = CONF.cert_file,
|
||||||
|
|
||||||
return conf
|
return conf
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import time
|
||||||
|
|
||||||
import psutil
|
import psutil
|
||||||
import requests
|
import requests
|
||||||
|
import six
|
||||||
from six.moves import http_client as http
|
from six.moves import http_client as http
|
||||||
|
|
||||||
from glance.tests import functional
|
from glance.tests import functional
|
||||||
|
@ -145,87 +146,88 @@ class TestReload(functional.FunctionalTest):
|
||||||
if check_pids(pre_pids['api'], post_pids['api']):
|
if check_pids(pre_pids['api'], post_pids['api']):
|
||||||
break
|
break
|
||||||
|
|
||||||
# Test changing from http to https
|
if six.PY2:
|
||||||
# This recycles the existing socket
|
# Test changing from http to https
|
||||||
path = self._url('http', '/')
|
# This recycles the existing socket
|
||||||
response = requests.get(path)
|
path = self._url('http', '/')
|
||||||
self.assertEqual(http.MULTIPLE_CHOICES, response.status_code)
|
response = requests.get(path)
|
||||||
del response # close socket so that process audit is reliable
|
self.assertEqual(http.MULTIPLE_CHOICES, response.status_code)
|
||||||
|
del response # close socket so that process audit is reliable
|
||||||
|
|
||||||
pre_pids['api'] = self._get_children('api')
|
pre_pids['api'] = self._get_children('api')
|
||||||
key_file = os.path.join(TEST_VAR_DIR, 'privatekey.key')
|
key_file = os.path.join(TEST_VAR_DIR, 'privatekey.key')
|
||||||
set_config_value(self._conffile('api'), 'key_file', key_file)
|
set_config_value(self._conffile('api'), 'key_file', key_file)
|
||||||
cert_file = os.path.join(TEST_VAR_DIR, 'certificate.crt')
|
cert_file = os.path.join(TEST_VAR_DIR, 'certificate.crt')
|
||||||
set_config_value(self._conffile('api'), 'cert_file', cert_file)
|
set_config_value(self._conffile('api'), 'cert_file', cert_file)
|
||||||
cmd = "kill -HUP %s" % self._get_parent('api')
|
cmd = "kill -HUP %s" % self._get_parent('api')
|
||||||
execute(cmd, raise_error=True)
|
execute(cmd, raise_error=True)
|
||||||
|
|
||||||
msg = 'http to https timeout'
|
msg = 'http to https timeout'
|
||||||
for _ in self.ticker(msg):
|
for _ in self.ticker(msg):
|
||||||
post_pids['api'] = self._get_children('api')
|
post_pids['api'] = self._get_children('api')
|
||||||
if check_pids(pre_pids['api'], post_pids['api']):
|
if check_pids(pre_pids['api'], post_pids['api']):
|
||||||
break
|
break
|
||||||
|
|
||||||
ca_file = os.path.join(TEST_VAR_DIR, 'ca.crt')
|
ca_file = os.path.join(TEST_VAR_DIR, 'ca.crt')
|
||||||
path = self._url('https', '/')
|
path = self._url('https', '/')
|
||||||
response = requests.get(path, verify=ca_file)
|
response = requests.get(path, verify=ca_file)
|
||||||
self.assertEqual(http.MULTIPLE_CHOICES, response.status_code)
|
self.assertEqual(http.MULTIPLE_CHOICES, response.status_code)
|
||||||
del response
|
del response
|
||||||
|
|
||||||
# Test https restart
|
# Test https restart
|
||||||
# This recycles the existing socket
|
# This recycles the existing socket
|
||||||
pre_pids['api'] = self._get_children('api')
|
pre_pids['api'] = self._get_children('api')
|
||||||
cmd = "kill -HUP %s" % self._get_parent('api')
|
cmd = "kill -HUP %s" % self._get_parent('api')
|
||||||
execute(cmd, raise_error=True)
|
execute(cmd, raise_error=True)
|
||||||
|
|
||||||
msg = 'https restart timeout'
|
msg = 'https restart timeout'
|
||||||
for _ in self.ticker(msg):
|
for _ in self.ticker(msg):
|
||||||
post_pids['api'] = self._get_children('api')
|
post_pids['api'] = self._get_children('api')
|
||||||
if check_pids(pre_pids['api'], post_pids['api']):
|
if check_pids(pre_pids['api'], post_pids['api']):
|
||||||
break
|
break
|
||||||
|
|
||||||
ca_file = os.path.join(TEST_VAR_DIR, 'ca.crt')
|
ca_file = os.path.join(TEST_VAR_DIR, 'ca.crt')
|
||||||
path = self._url('https', '/')
|
path = self._url('https', '/')
|
||||||
response = requests.get(path, verify=ca_file)
|
response = requests.get(path, verify=ca_file)
|
||||||
self.assertEqual(http.MULTIPLE_CHOICES, response.status_code)
|
self.assertEqual(http.MULTIPLE_CHOICES, response.status_code)
|
||||||
del response
|
del response
|
||||||
|
|
||||||
# Test changing the https bind_host
|
# Test changing the https bind_host
|
||||||
# This requires a new socket
|
# This requires a new socket
|
||||||
pre_pids['api'] = self._get_children('api')
|
pre_pids['api'] = self._get_children('api')
|
||||||
set_config_value(self._conffile('api'), 'bind_host', '127.0.0.1')
|
set_config_value(self._conffile('api'), 'bind_host', '127.0.0.1')
|
||||||
cmd = "kill -HUP %s" % self._get_parent('api')
|
cmd = "kill -HUP %s" % self._get_parent('api')
|
||||||
execute(cmd, raise_error=True)
|
execute(cmd, raise_error=True)
|
||||||
|
|
||||||
msg = 'https bind_host timeout'
|
msg = 'https bind_host timeout'
|
||||||
for _ in self.ticker(msg):
|
for _ in self.ticker(msg):
|
||||||
post_pids['api'] = self._get_children('api')
|
post_pids['api'] = self._get_children('api')
|
||||||
if check_pids(pre_pids['api'], post_pids['api']):
|
if check_pids(pre_pids['api'], post_pids['api']):
|
||||||
break
|
break
|
||||||
|
|
||||||
path = self._url('https', '/')
|
path = self._url('https', '/')
|
||||||
response = requests.get(path, verify=ca_file)
|
response = requests.get(path, verify=ca_file)
|
||||||
self.assertEqual(http.MULTIPLE_CHOICES, response.status_code)
|
self.assertEqual(http.MULTIPLE_CHOICES, response.status_code)
|
||||||
del response
|
del response
|
||||||
|
|
||||||
# Test https -> http
|
# Test https -> http
|
||||||
# This recycles the existing socket
|
# This recycles the existing socket
|
||||||
pre_pids['api'] = self._get_children('api')
|
pre_pids['api'] = self._get_children('api')
|
||||||
set_config_value(self._conffile('api'), 'key_file', '')
|
set_config_value(self._conffile('api'), 'key_file', '')
|
||||||
set_config_value(self._conffile('api'), 'cert_file', '')
|
set_config_value(self._conffile('api'), 'cert_file', '')
|
||||||
cmd = "kill -HUP %s" % self._get_parent('api')
|
cmd = "kill -HUP %s" % self._get_parent('api')
|
||||||
execute(cmd, raise_error=True)
|
execute(cmd, raise_error=True)
|
||||||
|
|
||||||
msg = 'https to http timeout'
|
msg = 'https to http timeout'
|
||||||
for _ in self.ticker(msg):
|
for _ in self.ticker(msg):
|
||||||
post_pids['api'] = self._get_children('api')
|
post_pids['api'] = self._get_children('api')
|
||||||
if check_pids(pre_pids['api'], post_pids['api']):
|
if check_pids(pre_pids['api'], post_pids['api']):
|
||||||
break
|
break
|
||||||
|
|
||||||
path = self._url('http', '/')
|
path = self._url('http', '/')
|
||||||
response = requests.get(path)
|
response = requests.get(path)
|
||||||
self.assertEqual(http.MULTIPLE_CHOICES, response.status_code)
|
self.assertEqual(http.MULTIPLE_CHOICES, response.status_code)
|
||||||
del response
|
del response
|
||||||
|
|
||||||
# Test changing the http bind_host
|
# Test changing the http bind_host
|
||||||
# This requires a new socket
|
# This requires a new socket
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
* Bug 1855708_: Reload broken in PY3
|
||||||
|
|
||||||
|
.. _1855708: https://bugs.launchpad.net/glance/+bug/1855708
|
Loading…
Reference in New Issue