Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable ssl on manila #1243

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9a722b2
Add caracal to codename maps
freyes May 8, 2024
1e0d928
Merge pull request #1207 from openstack-charmers/add-caracal-map-stab…
fnordahl May 9, 2024
680a09a
Remove designate-agent for caracal+ testing
ajkavanagh May 30, 2024
16c200d
Add squid package name
sabaini May 13, 2024
4b61fb7
Merge pull request #1216 from wolsen/backport-add-squid-package-name
lmlg May 31, 2024
9358922
Merge pull request #1214 from wolsen/backport-designate-agent-changes
freyes May 31, 2024
46409d8
Adding fixing broken configuration test for mysql-router
xtrusia Apr 9, 2024
f4ee170
Merge pull request #1219 from xtrusia/stable/caracal
ajkavanagh Jun 17, 2024
47935e2
Add class for keystone audit middleware testing
MylesJP May 24, 2024
ce1ec55
Merge pull request #1229 from MylesJP/stable/caracal
freyes Jun 21, 2024
e876fc7
Add ObjectRetrier to CinderaBackupTests
ajkavanagh Jun 24, 2024
514972e
Add additional debug for ObjectRetrier
ajkavanagh Jun 25, 2024
80c25da
Re-enable test 410 for cinder backups
ajkavanagh Jun 26, 2024
9dc5f3e
Fix ObjectRetrierWraps recursive wrapping
ajkavanagh Jun 27, 2024
ca1f644
Double Cinder backup restore time
ajkavanagh Jun 27, 2024
08fa7c0
Add more retries to allow manila backup restore to complete
ajkavanagh Jul 1, 2024
76ea216
Reduce ObjectRetrierWraps logging noise during normal use
ajkavanagh Jul 1, 2024
5b6049b
Modify test code to be less brittle
ajkavanagh Jul 1, 2024
1e2a8a1
Merge pull request #1234 from openstack-charmers/test-cinder-client-r…
wolsen Jul 1, 2024
57d227b
Enable SSL support on manila client
ajkavanagh Jul 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ python-novaclient
python-octaviaclient
python-swiftclient
python-watcherclient
tenacity
# Due to https://github.com/jd/tenacity/pull/479 the strategy for mocking out tenacity
# waits/times/etc no longer works. Pin to 8.4.1 until it is solved.
# Bug in tenacity tracking issue: https://github.com/jd/tenacity/issues/482
tenacity<8.4.2
paramiko

# Documentation requirements
Expand Down
26 changes: 23 additions & 3 deletions unit_tests/utilities/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,28 @@ def func(self):

mock_sleep.assert_not_called()

@mock.patch("time.sleep")
def test_object_wrap_multilevel_with_exception(self, mock_sleep):

class A:

def func(self):
raise SomeException()

class B:

def __init__(self):
self.a = A()

b = B()
# retry on a specific exception
wrapped_b = utilities.ObjectRetrierWraps(
b, num_retries=1, retry_exceptions=[SomeException])
with self.assertRaises(SomeException):
wrapped_b.a.func()

mock_sleep.assert_called_once_with(5)

@mock.patch("time.sleep")
def test_log_called(self, mock_sleep):

Expand All @@ -128,9 +150,7 @@ def func(self):
with self.assertRaises(SomeException):
wrapped_a.func()

# there should be two calls; one for the single retry and one for the
# failure.
self.assertEqual(mock_log.call_count, 2)
mock_log.assert_called()

@mock.patch("time.sleep")
def test_back_off_maximum(self, mock_sleep):
Expand Down
3 changes: 3 additions & 0 deletions unit_tests/utilities/test_zaza_utilities_openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ def setUp(self):
self.neutronclient.list_agents.return_value = self.agents
self.neutronclient.list_bgp_speaker_on_dragent.return_value = \
self.bgp_speakers
self.patch("zaza.openstack.utilities.ObjectRetrierWraps",
name="_object_retrier_wraps",
new=lambda x, *_, **__: x)

def test_create_port(self):
self.patch_object(openstack_utils, "get_net_uuid")
Expand Down
20 changes: 20 additions & 0 deletions zaza/openstack/charm_tests/audit/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2024 Canonical Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Keystone audit middleware.

Collection of code for setting up and testing Keystone audit middleware
functionality.
"""
119 changes: 119 additions & 0 deletions zaza/openstack/charm_tests/audit/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#!/usr/bin/env python3
#
# Copyright 2024 Canonical Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Keystone audit middleware API logging testing.

These methods test the rendering of the charm api-paste.ini file to
ensure the appropriate sections are rendered or not rendered depending
on the state of the audit-middleware configuration option.
"""

import textwrap
import logging
import zaza.model
import zaza.openstack.charm_tests.test_utils as test_utils


class KeystoneAuditMiddlewareTest(test_utils.OpenStackBaseTest):
"""Keystone audit middleware test class."""

@classmethod
def setUpClass(cls):
"""Run class setup for Keystone audit middleware tests."""
super(KeystoneAuditMiddlewareTest, cls).setUpClass()
test_config = cls.test_config['tests_options']['audit-middleware']
cls.service_name = test_config['service']

cls.application_name = test_config.get('application', cls.service_name)
logging.info('Using application name: %s', cls.application_name)

cls.initial_audit_middleware = zaza.model.get_application_config(
cls.application_name)['audit-middleware']['value']

@classmethod
def tearDownClass(cls):
"""Restore the audit-middleware configuration to its original state."""
super(KeystoneAuditMiddlewareTest, cls).tearDownClass()
logging.info("Running teardown on %s" % cls.application_name)
zaza.model.set_application_config(
cls.application_name,
{'audit-middleware': str(cls.initial_audit_middleware)},
model_name=cls.model_name
)
zaza.model.wait_for_application_states(
states={cls.application_name: {
'workload-status': 'active',
'workload-status-message': 'Unit is ready'}},
model_name=cls.model_name
)

def fetch_api_paste_content(self):
"""Fetch content of api-paste.ini file."""
api_paste_ini_path = f"/etc/{self.service_name}/api-paste.ini"
lead_unit = zaza.model.get_lead_unit_name(
self.application_name,
model_name=self.model_name
)
try:
return zaza.model.file_contents(
lead_unit,
api_paste_ini_path,
)
except zaza.model.CommandRunFailed as e:
self.fail("Error fetching api-paste.ini: %s" % e)

def test_101_apipaste_includes_audit_section(self):
"""Test api-paste.ini renders audit section when enabled."""
expected_content = textwrap.dedent(f"""\
[filter:audit]
paste.filter_factory = keystonemiddleware.audit:filter_factory
audit_map_file = /etc/{self.service_name}/api_audit_map.conf
service_name = {self.service_name}
""")

set_default = {'audit-middleware': False}
set_alternate = {'audit-middleware': True}

with self.config_change(default_config=set_default,
alternate_config=set_alternate,
application_name=self.application_name):
api_paste_content = self.fetch_api_paste_content()
self.assertIn(expected_content, api_paste_content)

def test_102_apipaste_excludes_audit_section(self):
"""Test api_paste.ini does not render audit section when disabled."""
section_heading = '[filter:audit]'
set_default = {'audit-middleware': True}
set_alternate = {'audit-middleware': False}

with self.config_change(default_config=set_default,
alternate_config=set_alternate,
application_name=self.application_name):
api_paste_content = self.fetch_api_paste_content()
self.assertNotIn(section_heading, api_paste_content)


class IronicAuditMiddlewareTest(KeystoneAuditMiddlewareTest):
"""Ironic-API audit middleware test class."""

def test_101_apipaste_includes_audit_section(self):
"""Test api-paste.ini renders audit section when enabled."""
self.skipTest('ironic-api does not use an api-paste.ini file')

def test_102_apipaste_excludes_audit_section(self):
"""Test api_paste.ini does not render audit section when disabled."""
self.skipTest('ironic-api does not use an api-paste.ini file')
10 changes: 6 additions & 4 deletions zaza/openstack/charm_tests/cinder_backup/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import zaza.model
import zaza.openstack.charm_tests.test_utils as test_utils
from zaza.openstack.utilities import retry_on_connect_failure
import zaza.openstack.utilities.ceph as ceph_utils
import zaza.openstack.utilities.openstack as openstack_utils

Expand All @@ -35,8 +36,9 @@ class CinderBackupTest(test_utils.OpenStackBaseTest):
def setUpClass(cls):
"""Run class setup for running Cinder Backup tests."""
super(CinderBackupTest, cls).setUpClass()
cls.cinder_client = openstack_utils.get_cinder_session_client(
cls.keystone_session)
cls.cinder_client = retry_on_connect_failure(
openstack_utils.get_cinder_session_client(cls.keystone_session),
log=logging.warn)

@property
def services(self):
Expand Down Expand Up @@ -101,7 +103,7 @@ def test_410_cinder_vol_create_backup_delete_restore_pool_inspect(self):
self.cinder_client.volumes,
cinder_vol.id,
wait_iteration_max_time=180,
stop_after_attempt=15,
stop_after_attempt=30,
expected_status='available',
msg='ceph-backed cinder volume')

Expand All @@ -123,7 +125,7 @@ def test_410_cinder_vol_create_backup_delete_restore_pool_inspect(self):
self.cinder_client.backups,
vol_backup.id,
wait_iteration_max_time=180,
stop_after_attempt=15,
stop_after_attempt=30,
expected_status='available',
msg='Backup volume')

Expand Down
9 changes: 8 additions & 1 deletion zaza/openstack/charm_tests/designate/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,15 @@ def setUpClass(cls, application_name=None, model_alias=None):
model_alias = model_alias or ""
super(BaseDesignateTest, cls).setUpClass(application_name, model_alias)
os_release = openstack_utils.get_os_release
current_release = os_release()

if os_release() >= os_release('bionic_rocky'):
if current_release >= os_release('jammy_caracal'):
cls.designate_svcs = [
'designate-api', 'designate-central',
'designate-mdns', 'designate-worker', 'designate-sink',
'designate-producer',
]
elif current_release >= os_release('bionic_rocky'):
cls.designate_svcs = [
'designate-agent', 'designate-api', 'designate-central',
'designate-mdns', 'designate-worker', 'designate-sink',
Expand Down
22 changes: 11 additions & 11 deletions zaza/openstack/charm_tests/manila/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
import logging
import tenacity

from manilaclient import client as manilaclient

import zaza.model
import zaza.openstack.configure.guest as guest
from zaza.openstack.utilities import retry_on_connect_failure
import zaza.openstack.utilities.generic as generic_utils
import zaza.openstack.utilities.openstack as openstack_utils
import zaza.openstack.charm_tests.test_utils as test_utils
Expand Down Expand Up @@ -67,8 +66,9 @@ class ManilaTests(test_utils.OpenStackBaseTest):
def setUpClass(cls):
"""Run class setup for running tests."""
super(ManilaTests, cls).setUpClass()
cls.manila_client = manilaclient.Client(
session=cls.keystone_session, client_version='2')
cls.manila_client = retry_on_connect_failure(
openstack_utils.get_manila_session_client(
session=cls.keystone_session))

def test_manila_api(self):
"""Test that the Manila API is working."""
Expand Down Expand Up @@ -132,8 +132,8 @@ def setUpClass(cls):
super(ManilaBaseTest, cls).setUpClass()
cls.nova_client = openstack_utils.get_nova_session_client(
session=cls.keystone_session)
cls.manila_client = manilaclient.Client(
session=cls.keystone_session, client_version='2')
cls.manila_client = openstack_utils.get_manila_session_client(
session=cls.keystone_session)
cls.share_name = 'test-manila-share'
cls.share_type_name = 'default_share_type'
cls.share_protocol = 'nfs'
Expand Down Expand Up @@ -221,7 +221,7 @@ def _mount_share_on_instance(self, instance_ip, ssh_user_name,

for attempt in tenacity.Retrying(
stop=tenacity.stop_after_attempt(5),
wait=tenacity.wait_exponential(multiplier=3, min=2, max=10)):
wait=tenacity.wait_exponential(multiplier=5, min=2, max=60)):
with attempt:
openstack_utils.ssh_command(
vm_name="instance-{}".format(instance_ip),
Expand All @@ -233,7 +233,7 @@ def _mount_share_on_instance(self, instance_ip, ssh_user_name,

@tenacity.retry(
stop=tenacity.stop_after_attempt(5),
wait=tenacity.wait_exponential(multiplier=3, min=2, max=10))
wait=tenacity.wait_exponential(multiplier=5, min=2, max=60))
def _write_testing_file_on_instance(self, instance_ip, ssh_user_name,
ssh_private_key):
"""Write a file on a Manila share mounted into a Nova instance.
Expand All @@ -260,7 +260,7 @@ def _write_testing_file_on_instance(self, instance_ip, ssh_user_name,

@tenacity.retry(
stop=tenacity.stop_after_attempt(5),
wait=tenacity.wait_exponential(multiplier=3, min=2, max=10))
wait=tenacity.wait_exponential(multiplier=5, min=2, max=60))
def _clear_testing_file_on_instance(self, instance_ip, ssh_user_name,
ssh_private_key):
"""Clear a file on a Manila share mounted into a Nova instance.
Expand All @@ -287,7 +287,7 @@ def _clear_testing_file_on_instance(self, instance_ip, ssh_user_name,

@tenacity.retry(
stop=tenacity.stop_after_attempt(5),
wait=tenacity.wait_exponential(multiplier=3, min=2, max=10))
wait=tenacity.wait_exponential(multiplier=5, min=2, max=60))
def _validate_testing_file_from_instance(self, instance_ip, ssh_user_name,
ssh_private_key):
"""Validate a file from the Manila share mounted into a Nova instance.
Expand Down Expand Up @@ -359,7 +359,7 @@ def test_manila_share(self):
self.manila_client.shares,
share.id,
wait_iteration_max_time=120,
stop_after_attempt=2,
stop_after_attempt=10,
expected_status="available",
msg="Waiting for a share to become available")

Expand Down
6 changes: 2 additions & 4 deletions zaza/openstack/charm_tests/manila_ganesha/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

import zaza.openstack.utilities.openstack as openstack_utils

from manilaclient import client as manilaclient


MANILA_GANESHA_TYPE_NAME = "cephfsnfstype"

Expand All @@ -34,8 +32,8 @@ def setup_ganesha_share_type(manila_client=None):
"""
if manila_client is None:
keystone_session = openstack_utils.get_overcloud_keystone_session()
manila_client = manilaclient.Client(
session=keystone_session, client_version='2')
manila_client = openstack_utils.get_manila_session_client(
keystone_session)

manila_client.share_types.create(
name=MANILA_GANESHA_TYPE_NAME, spec_driver_handles_share_servers=False,
Expand Down
Loading
Loading