Heat integration tests failing against https endpoints

Provide ca_file option to pass the ca certificate to verify https
connection. Also pass verify parameter to the test cases which
directly call requests library methods.

Change-Id: I4a81047136d6a64b151180e95c254edea8165349
Closes-Bug: #1553898
This commit is contained in:
tyagi 2016-03-07 04:47:00 -08:00 committed by Ishant Tyagi
parent e37e73e63d
commit 96ef3fc4ca
6 changed files with 31 additions and 17 deletions

View File

@ -79,6 +79,8 @@ class ClientManager(object):
raise ValueError(_('Incorrectly specified auth_url config: no ' raise ValueError(_('Incorrectly specified auth_url config: no '
'version found.')) 'version found.'))
self.insecure = self.conf.disable_ssl_certificate_validation
self.ca_file = self.conf.ca_file
self.identity_client = self._get_identity_client() self.identity_client = self._get_identity_client()
self.orchestration_client = self._get_orchestration_client() self.orchestration_client = self._get_orchestration_client()
self.compute_client = self._get_compute_client() self.compute_client = self._get_compute_client()
@ -121,13 +123,15 @@ class ClientManager(object):
'project_domain_name': domain, 'project_domain_name': domain,
'user_domain_name': domain}) 'user_domain_name': domain})
auth = password.Password(**kwargs) auth = password.Password(**kwargs)
return KeystoneWrapperClient( if self.insecure:
auth, verify_cert = False
not self.conf.disable_ssl_certificate_validation) else:
verify_cert = self.ca_file or True
return KeystoneWrapperClient(auth, verify_cert)
def _get_compute_client(self): def _get_compute_client(self):
dscv = self.conf.disable_ssl_certificate_validation
region = self.conf.region region = self.conf.region
client_args = ( client_args = (
@ -146,11 +150,11 @@ class ClientManager(object):
endpoint_type='publicURL', endpoint_type='publicURL',
region_name=region, region_name=region,
no_cache=True, no_cache=True,
insecure=dscv, insecure=self.insecure,
cacert=self.ca_file,
http_log_debug=True) http_log_debug=True)
def _get_network_client(self): def _get_network_client(self):
dscv = self.conf.disable_ssl_certificate_validation
return neutron_client.Client( return neutron_client.Client(
username=self.conf.username, username=self.conf.username,
@ -159,12 +163,12 @@ class ClientManager(object):
endpoint_type='publicURL', endpoint_type='publicURL',
# neutronclient can not use v3 url # neutronclient can not use v3 url
auth_url=self.v2_auth_url, auth_url=self.v2_auth_url,
insecure=dscv) insecure=self.insecure,
ca_cert=self.ca_file)
def _get_volume_client(self): def _get_volume_client(self):
region = self.conf.region region = self.conf.region
endpoint_type = 'publicURL' endpoint_type = 'publicURL'
dscv = self.conf.disable_ssl_certificate_validation
return cinder_client.Client( return cinder_client.Client(
self.CINDERCLIENT_VERSION, self.CINDERCLIENT_VERSION,
self.conf.username, self.conf.username,
@ -174,11 +178,11 @@ class ClientManager(object):
self.v2_auth_url, self.v2_auth_url,
region_name=region, region_name=region,
endpoint_type=endpoint_type, endpoint_type=endpoint_type,
insecure=dscv, insecure=self.insecure,
cacert=self.ca_file,
http_log_debug=True) http_log_debug=True)
def _get_object_client(self): def _get_object_client(self):
dscv = self.conf.disable_ssl_certificate_validation
args = { args = {
'auth_version': self.auth_version, 'auth_version': self.auth_version,
'tenant_name': self.conf.tenant_name, 'tenant_name': self.conf.tenant_name,
@ -186,12 +190,12 @@ class ClientManager(object):
'key': self.conf.password, 'key': self.conf.password,
'authurl': self.conf.auth_url, 'authurl': self.conf.auth_url,
'os_options': {'endpoint_type': 'publicURL'}, 'os_options': {'endpoint_type': 'publicURL'},
'insecure': dscv, 'insecure': self.insecure,
'cacert': self.ca_file,
} }
return swift_client.Connection(**args) return swift_client.Connection(**args)
def _get_metering_client(self): def _get_metering_client(self):
dscv = self.conf.disable_ssl_certificate_validation
domain = self.conf.domain_name domain = self.conf.domain_name
try: try:
endpoint = self.identity_client.get_endpoint_url('metering', endpoint = self.identity_client.get_endpoint_url('metering',
@ -204,7 +208,8 @@ class ClientManager(object):
'password': self.conf.password, 'password': self.conf.password,
'tenant_name': self.conf.tenant_name, 'tenant_name': self.conf.tenant_name,
'auth_url': self.conf.auth_url, 'auth_url': self.conf.auth_url,
'insecure': dscv, 'insecure': self.insecure,
'cacert': self.ca_file,
'region_name': self.conf.region, 'region_name': self.conf.region,
'endpoint_type': 'publicURL', 'endpoint_type': 'publicURL',
'service_type': 'metering', 'service_type': 'metering',

View File

@ -60,6 +60,10 @@ IntegrationTestGroup = [
cfg.BoolOpt('disable_ssl_certificate_validation', cfg.BoolOpt('disable_ssl_certificate_validation',
default=False, default=False,
help="Set to True if using self-signed SSL certificates."), help="Set to True if using self-signed SSL certificates."),
cfg.StrOpt('ca_file',
default=None,
help="CA certificate to pass for servers that have "
"https endpoint."),
cfg.IntOpt('build_interval', cfg.IntOpt('build_interval',
default=4, default=4,
help="Time in seconds between build status checks."), help="Time in seconds between build status checks."),

View File

@ -92,6 +92,10 @@ class HeatIntegrationTest(testscenarios.WithScenarios,
self.metering_client = self.manager.metering_client self.metering_client = self.manager.metering_client
self.useFixture(fixtures.FakeLogger(format=_LOG_FORMAT)) self.useFixture(fixtures.FakeLogger(format=_LOG_FORMAT))
self.updated_time = {} self.updated_time = {}
if self.conf.disable_ssl_certificate_validation:
self.verify_cert = False
else:
self.verify_cert = self.conf.ca_file or True
def get_remote_client(self, server_or_ip, username, private_key=None): def get_remote_client(self, server_or_ip, username, private_key=None):
if isinstance(server_or_ip, six.string_types): if isinstance(server_or_ip, six.string_types):

View File

@ -179,12 +179,12 @@ outputs:
callbacks=[handler.process_message], callbacks=[handler.process_message],
auto_declare=False): auto_declare=False):
requests.post(scale_up_url) requests.post(scale_up_url, verify=self.verify_cert)
test.call_until_true(20, 0, self.consume_events, handler, 2) test.call_until_true(20, 0, self.consume_events, handler, 2)
notifications += handler.notifications notifications += handler.notifications
handler.clear() handler.clear()
requests.post(scale_down_url) requests.post(scale_down_url, verify=self.verify_cert)
test.call_until_true(20, 0, self.consume_events, handler, 2) test.call_until_true(20, 0, self.consume_events, handler, 2)
notifications += handler.notifications notifications += handler.notifications

View File

@ -149,7 +149,8 @@ properties:
iv = dict((i['name'], i['value']) for i in dep['inputs']) iv = dict((i['name'], i['value']) for i in dep['inputs'])
sigurl = iv.get('deploy_signal_id') sigurl = iv.get('deploy_signal_id')
requests.post(sigurl, data='{}', requests.post(sigurl, data='{}',
headers={'content-type': None}) headers={'content-type': None},
verify=self.verify_cert)
class ZaqarSignalTransportTest(functional_base.FunctionalTestsBase): class ZaqarSignalTransportTest(functional_base.FunctionalTestsBase):

View File

@ -39,7 +39,7 @@ class AutoscalingLoadBalancerTest(scenario_base.ScenarioTestsBase):
for count in range(retries): for count in range(retries):
time.sleep(1) time.sleep(1)
try: try:
r = requests.get(url) r = requests.get(url, verify=self.verify_cert)
except requests.exceptions.ConnectionError: except requests.exceptions.ConnectionError:
# The LB may not be up yet, let's retry # The LB may not be up yet, let's retry
continue continue