Files
openstack-armada-app/python-k8sapp-openstack/k8sapp_openstack/k8sapp_openstack/tests/helm/test_cinder.py
Thiago Brito dceba41943 Add flake8 check and flake8-import-order
Improving the code quality of the plugins by adding the flake8 check on
zuul and addint the flake8-import-order plugin to standardize imports.
Also, defaults testenv to python3.9 configuration that should be used
for now on with the debian migration.

Story: 2010100
Task: 45656
Signed-off-by: Thiago Brito <thiago.brito@windriver.com>
Change-Id: I6566d5b99f4e7b19feeffe3b35674222eabe1cca
2022-06-22 13:46:16 -03:00

166 lines
5.6 KiB
Python

#
# Copyright (c) 2020 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
import mock
from oslo_utils import uuidutils
from sysinv.common import constants
from sysinv.helm import common
from sysinv.tests.db import base as dbbase
from sysinv.tests.db import utils as dbutils
from sysinv.tests.helm import base
import tsconfig.tsconfig as tsc
from k8sapp_openstack.common import constants as app_constants
from k8sapp_openstack.helm import cinder
from k8sapp_openstack.tests import test_plugins
class CinderConversionTestCase(test_plugins.K8SAppOpenstackAppMixin,
base.HelmTestCaseMixin):
def setUp(self):
super(CinderConversionTestCase, self).setUp()
self.app = dbutils.create_test_app(name=self.app_name)
class CinderGetOverrideTest(CinderConversionTestCase,
dbbase.ControllerHostTestCase):
def test_cinder_overrides(self):
dbutils.create_test_host_fs(name='image-conversion',
forihostid=self.host.id)
overrides = self.operator.get_helm_chart_overrides(
app_constants.HELM_CHART_CINDER,
cnamespace=common.HELM_NS_OPENSTACK)
self.assertOverridesParameters(overrides, {
'conf': {
'cinder': {
'DEFAULT': {
'image_conversion_dir': tsc.IMAGE_CONVERSION_PATH}}},
'endpoints': {
'volume': {
'host_fqdn_override': {
'public': {},
},
},
'volumev2': {
'host_fqdn_override': {
'public': {},
},
},
'volumev3': {
'host_fqdn_override': {
'public': {},
},
},
}
})
@mock.patch('os.path.exists', return_value=True)
@mock.patch('six.moves.builtins.open', mock.mock_open(read_data="fake"))
@mock.patch('k8sapp_openstack.utils.https_enabled', return_value=True)
def test_cinder_overrides_https_enabled(self, *_):
dbutils.create_test_host_fs(name='image-conversion',
forihostid=self.host.id)
self.dbapi.certificate_create(
{
"id": 1,
"uuid": uuidutils.generate_uuid(),
"certtype": constants.CERT_MODE_OPENSTACK,
"signature": "abcdef",
}
)
self.dbapi.certificate_create(
{
"id": 2,
"uuid": uuidutils.generate_uuid(),
"certtype": constants.CERT_MODE_OPENSTACK_CA,
"signature": "abcdef",
}
)
self.dbapi.certificate_create(
{
"id": 3,
"uuid": uuidutils.generate_uuid(),
"certtype": constants.CERT_MODE_SSL_CA,
"signature": "abcdef",
}
)
overrides = self.operator.get_helm_chart_overrides(
app_constants.HELM_CHART_CINDER,
cnamespace=common.HELM_NS_OPENSTACK)
self.assertOverridesParameters(overrides, {
'conf': {
'cinder': {
'keystone_authtoken': {
'cafile': cinder.CinderHelm.get_ca_file()
},
}
},
'endpoints': {
'identity': {
'auth': {
'admin': {
'cacert': cinder.CinderHelm.get_ca_file(),
'password': mock.ANY,
'region_name': mock.ANY,
},
'cinder': {
'cacert': cinder.CinderHelm.get_ca_file(),
'password': mock.ANY,
'region_name': mock.ANY,
},
'test': {
'cacert': cinder.CinderHelm.get_ca_file(),
'password': mock.ANY,
'region_name': mock.ANY,
},
},
},
'volume': {
'host_fqdn_override': {
'public': {
# 'host': mock.ANY,
'tls': {
'ca': 'fake',
'crt': 'fake',
'key': 'fake',
},
},
},
},
'volumev2': {
'host_fqdn_override': {
'public': {
# 'host': mock.ANY,
'tls': {
'ca': 'fake',
'crt': 'fake',
'key': 'fake',
},
},
},
},
'volumev3': {
'host_fqdn_override': {
'public': {
# 'host': mock.ANY,
'tls': {
'ca': 'fake',
'crt': 'fake',
'key': 'fake',
},
},
},
},
},
'manifests': {
'certificates': True,
},
})