diff --git a/README.md b/README.md index 79643bb..ff7b24e 100644 --- a/README.md +++ b/README.md @@ -27,3 +27,7 @@ The OpenStack Charms project maintains two documentation guides: [cg]: https://docs.openstack.org/charm-guide [cdg]: https://docs.openstack.org/project-deploy-guide/charm-deployment-guide + +# Bugs + +Please report bugs on [Launchpad](https://bugs.launchpad.net/charm-cinder-nimblestorage/+filebug). diff --git a/build-requirements.txt b/build-requirements.txt index 271d895..0eb4905 100644 --- a/build-requirements.txt +++ b/build-requirements.txt @@ -1 +1,7 @@ -git+https://github.com/canonical/charmcraft.git@0.10.2#egg=charmcraft +# NOTES(lourot): +# * We don't install charmcraft via pip anymore because it anyway spins up a +# container and scp the system's charmcraft snap inside it. So the charmcraft +# snap is necessary on the system anyway. +# * `tox -e build` successfully validated with charmcraft 1.2.1 + +cffi==1.14.6; python_version < '3.6' # diff --git a/charmcraft.yaml b/charmcraft.yaml new file mode 100644 index 0000000..ff59b02 --- /dev/null +++ b/charmcraft.yaml @@ -0,0 +1,35 @@ +type: charm + +parts: + charm: + after: + - update-certificates + charm-python-packages: + # NOTE(lourot): see + # * https://github.com/canonical/charmcraft/issues/551 + - setuptools + build-packages: + - git + + update-certificates: + plugin: nil + # See https://github.com/canonical/charmcraft/issues/658 + override-build: | + apt update + apt install -y ca-certificates + update-ca-certificates + +bases: + - build-on: + - name: ubuntu + channel: "20.04" + architectures: + - amd64 + - s390x + - ppc64el + - arm64 + run-on: + - name: ubuntu + channel: "20.04" + - name: ubuntu + channel: "21.10" diff --git a/osci.yaml b/osci.yaml new file mode 100644 index 0000000..9e78cc6 --- /dev/null +++ b/osci.yaml @@ -0,0 +1,8 @@ +- project: + templates: + - charm-unit-jobs-py38 + - charm-unit-jobs-py39 + vars: + needs_charm_build: true + charm_build_name: cinder-nimblestorage + build_type: charmcraft diff --git a/rename.sh b/rename.sh new file mode 100755 index 0000000..d0c35c9 --- /dev/null +++ b/rename.sh @@ -0,0 +1,13 @@ +#!/bin/bash +charm=$(grep "charm_build_name" osci.yaml | awk '{print $2}') +echo "renaming ${charm}_*.charm to ${charm}.charm" +echo -n "pwd: " +pwd +ls -al +echo "Removing bad downloaded charm maybe?" +if [[ -e "${charm}.charm" ]]; +then + rm "${charm}.charm" +fi +echo "Renaming charm here." +mv ${charm}_*.charm ${charm}.charm diff --git a/src/test-requirements.txt b/src/test-requirements.txt deleted file mode 100644 index e771023..0000000 --- a/src/test-requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -# This file is managed centrally by release-tools and should not be modified -# within individual charm repos. See the 'global' dir contents for available -# choices of *requirements.txt files for OpenStack Charms: -# https://github.com/openstack-charmers/release-tools -# - -# Functional Test Requirements (let Zaza's dependencies solve all dependencies here!) -git+https://github.com/openstack-charmers/zaza.git#egg=zaza -git+https://github.com/openstack-charmers/zaza-openstack-tests.git#egg=zaza.openstack diff --git a/src/tox.ini b/src/tox.ini deleted file mode 100644 index b40d295..0000000 --- a/src/tox.ini +++ /dev/null @@ -1,61 +0,0 @@ -# Source charm (with zaza): ./src/tox.ini -# This file is managed centrally by release-tools and should not be modified -# within individual charm repos. See the 'global' dir contents for available -# choices of tox.ini for OpenStack Charms: -# https://github.com/openstack-charmers/release-tools - -[tox] -envlist = pep8 -skipsdist = True -# NOTE: Avoid build/test env pollution by not enabling sitepackages. -sitepackages = False -# NOTE: Avoid false positives by not skipping missing interpreters. -skip_missing_interpreters = False -# NOTES: -# * We avoid the new dependency resolver by pinning pip < 20.3, see -# https://github.com/pypa/pip/issues/9187 -# * Pinning dependencies requires tox >= 3.2.0, see -# https://tox.readthedocs.io/en/latest/config.html#conf-requires -# * It is also necessary to pin virtualenv as a newer virtualenv would still -# lead to fetching the latest pip in the func* tox targets, see -# https://stackoverflow.com/a/38133283 -requires = pip < 20.3 - virtualenv < 20.0 -# NOTE: https://wiki.canonical.com/engineering/OpenStack/InstallLatestToxOnOsci -minversion = 3.18.0 - -[testenv] -setenv = VIRTUAL_ENV={envdir} - PYTHONHASHSEED=0 -allowlist_externals = juju -passenv = HOME TERM CS_* OS_* TEST_* -deps = -r{toxinidir}/test-requirements.txt -install_command = - pip install {opts} {packages} - -[testenv:pep8] -basepython = python3 -commands = charm-proof - -[testenv:func-noop] -basepython = python3 -commands = - functest-run-suite --help - -[testenv:func] -basepython = python3 -commands = - functest-run-suite --keep-model - -[testenv:func-smoke] -basepython = python3 -commands = - functest-run-suite --keep-model --smoke - -[testenv:func-target] -basepython = python3 -commands = - functest-run-suite --keep-model --bundle {posargs} - -[testenv:venv] -commands = {posargs} diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..d002a1e --- /dev/null +++ b/tests/README.md @@ -0,0 +1,18 @@ +# Overview + +This directory provides Zaza test definitions and bundles to verify basic +deployment functionality from the perspective of this charm, its requirements +and its features, as exercised in a subset of the full OpenStack deployment +test bundle topology. + +Run the smoke tests with: + +```bash +cd ../ +tox -e build +tox -e func-smoke +``` + +For full details on functional testing of OpenStack charms please refer to +the [functional testing](https://docs.openstack.org/charm-guide/latest/reference/testing.html#functional-testing) +section of the OpenStack Charm Guide. diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/bundles/bionic-rocky.yaml b/tests/bundles/bionic-rocky.yaml deleted file mode 100644 index 2187318..0000000 --- a/tests/bundles/bionic-rocky.yaml +++ /dev/null @@ -1,61 +0,0 @@ -series: bionic -variables: - openstack-origin: &openstack-origin cloud:bionic-rocky -comment: -- 'machines section to decide order of deployment. database sooner = faster' -machines: - '0': - constraints: mem=3072M - '1': - '2': - '3': - -applications: - mysql: - charm: cs:~openstack-charmers-next/percona-cluster - num_units: 1 - to: - - '0' - keystone: - charm: cs:~openstack-charmers-next/keystone - num_units: 1 - options: - openstack-origin: *openstack-origin - to: - - '1' - cinder: - charm: cs:~openstack-charmers-next/cinder - num_units: 1 - options: - openstack-origin: *openstack-origin - to: - - '2' - cinder-nimblestorage: - charm: ../../cinder-nimblestorage - options: - volume-driver: 'iscsi' - volume-backend-name: 'nimble-storage-iscsi' - san-ip: '10.11.12.13' - san-login: 'admin' - san-password: 'admin' - use-multipath-for-image-xfer: True - encryption: 'yes' - performance-policy-name: 'test-performance-policy' - multi-initiator: True - pool-name: 'default' - subnet-label: '*' - verify-cert-path: 'None' - verify-cert: 'False' - - rabbitmq-server: - charm: cs:~openstack-charmers-next/rabbitmq-server - num_units: 1 - to: - - '3' - -relations: - - [ keystone:shared-db, mysql:shared-db ] - - [ cinder:shared-db, mysql:shared-db ] - - [ cinder:identity-service, keystone:identity-service ] - - [ cinder:amqp, rabbitmq-server:amqp ] - - [ cinder:storage-backend, cinder-nimblestorage:storage-backend ] diff --git a/tests/bundles/focal-ussuri.yaml b/tests/bundles/focal-ussuri.yaml index 45c586a..2887da7 100644 --- a/tests/bundles/focal-ussuri.yaml +++ b/tests/bundles/focal-ussuri.yaml @@ -18,7 +18,8 @@ machines: applications: mysql-innodb-cluster: - charm: cs:~openstack-charmers-next/mysql-innodb-cluster + charm: ch:mysql-innodb-cluster + channel: latest/edge num_units: 3 options: source: *openstack-origin @@ -27,23 +28,27 @@ applications: - '1' - '2' rabbitmq-server: - charm: cs:~openstack-charmers-next/rabbitmq-server + charm: ch:rabbitmq-server + channel: latest/edge num_units: 1 options: source: *openstack-origin to: - '3' keystone: - charm: cs:~openstack-charmers/keystone + charm: ch:keystone + channel: yoga/edge options: openstack-origin: *openstack-origin num_units: 1 to: - '4' keystone-mysql-router: - charm: cs:~openstack-charmers-next/mysql-router + charm: ch:mysql-router + channel: latest/edge cinder: - charm: cs:~openstack-charmers-next/cinder + charm: ch:cinder + channel: yoga/edge num_units: 1 storage: block-devices: '40G' @@ -53,18 +58,16 @@ applications: overwrite: "true" to: - '5' - + cinder-mysql-router: - charm: cs:~openstack-charmers-next/mysql-router - + charm: ch:mysql-router + channel: latest/edge + cinder-nimblestorage: - charm: ../../cinder-nimblestorage + charm: ../../cinder-nimblestorage.charm options: volume-driver: 'iscsi' - volume-backend-name: 'nimble-storage-iscsi' - san-ip: '10.11.12.13' - san-login: 'admin' - san-password: 'admin' + volume-backend-name: 'cinder-nimblestorage' use-multipath-for-image-xfer: True encryption: 'yes' performance-policy-name: 'test-performance-policy' diff --git a/tests/bundles/xenial-ocata.yaml b/tests/bundles/xenial-ocata.yaml deleted file mode 100644 index 9d907ab..0000000 --- a/tests/bundles/xenial-ocata.yaml +++ /dev/null @@ -1,62 +0,0 @@ -series: xenial -variables: - openstack-origin: &openstack-origin cloud:xenial-ocata -comment: -- 'machines section to decide order of deployment. database sooner = faster' -machines: - '0': - constraints: mem=3072M - '1': - '2': - '3': - -applications: - mysql: - charm: cs:~openstack-charmers-next/percona-cluster - num_units: 1 - to: - - '0' - keystone: - charm: cs:~openstack-charmers-next/keystone - num_units: 1 - options: - openstack-origin: *openstack-origin - to: - - '1' - cinder: - charm: cs:~openstack-charmers-next/cinder - num_units: 1 - options: - openstack-origin: *openstack-origin - to: - - '2' - cinder-nimblestorage: - series: xenial - charm: ../../cinder-nimblestorage - options: - volume-driver: 'iscsi' - volume-backend-name: 'nimble-storage-iscsi' - san-ip: '10.11.12.13' - san-login: 'admin' - san-password: 'admin' - use-multipath-for-image-xfer: True - encryption: 'yes' - performance-policy-name: 'test-performance-policy' - multi-initiator: True - pool-name: 'default' - subnet-label: '*' - verify-cert-path: 'None' - verify-cert: 'False' - - rabbitmq-server: - charm: cs:~openstack-charmers-next/rabbitmq-server - num_units: 1 - to: - - '3' - -relations: - - [ keystone:shared-db, mysql:shared-db ] - - [ cinder:shared-db, mysql:shared-db ] - - [ cinder:identity-service, keystone:identity-service ] - - [ cinder:amqp, rabbitmq-server:amqp ] - - [ cinder:storage-backend, cinder-nimblestorage:storage-backend ] diff --git a/tests/tests.py b/tests/tests.py new file mode 100644 index 0000000..e87f7a7 --- /dev/null +++ b/tests/tests.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 + +# Copyright 2019 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. + +"""Encapsulate cinder-nimblestorage testing.""" + +from zaza.openstack.charm_tests.cinder_backend.tests import CinderBackendTest +from os import environ + + +class CinderNimblestorageTest(CinderBackendTest): + """Encapsulate cinder-nimblestorage tests.""" + + backend_name = 'cinder-nimblestorage' + + expected_config_content = { + 'cinder-nimblestorage': { + 'volume_driver': + ['cinder.volume.drivers.nimble.NimbleISCSIDriver'], + 'san_ip': environ['TEST_NIMBLESTORAGE_SAN_IP'], + 'san_login': environ['TEST_NIMBLESTORAGE_SAN_USERNAME'], + 'san_password': environ['TEST_NIMBLESTORAGE_SAN_PASSWORD'] + }} diff --git a/tests/tests.yaml b/tests/tests.yaml index bc02c59..0348658 100644 --- a/tests/tests.yaml +++ b/tests/tests.yaml @@ -1,11 +1,9 @@ charm_name: cinder-nimblestorage tests: - - tests.tests_cinder_nimblestorage.CinderNimblestorageTest + - tests.tests.CinderNimblestorageTest configure: - zaza.openstack.charm_tests.keystone.setup.add_demo_user gate_bundles: - - xenial-ocata - - bionic-rocky - focal-ussuri smoke_bundles: - focal-ussuri diff --git a/tests/tests_cinder_nimblestorage.py b/tests/tests_cinder_nimblestorage.py deleted file mode 100644 index 543e696..0000000 --- a/tests/tests_cinder_nimblestorage.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env python3 - -# Copyright 2019 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. - -"""Encapsulate cinder-nimblestorage testing.""" - -import logging -import uuid - -import zaza.model -import zaza.openstack.charm_tests.test_utils as test_utils -import zaza.openstack.utilities.openstack as openstack_utils - - -class CinderNimblestorageTest(test_utils.OpenStackBaseTest): - """Encapsulate NimbleStorage tests.""" - - @classmethod - def setUpClass(cls): - """Run class setup for running tests.""" - super(CinderNimblestorageTest, cls).setUpClass() - cls.keystone_session = openstack_utils.get_overcloud_keystone_session() - cls.model_name = zaza.model.get_juju_model() - cls.cinder_client = openstack_utils.get_cinder_session_client( - cls.keystone_session) - - def test_cinder_config(self): - logging.info('nimblestorage') - expected_contents = { - 'cinder-nimblestorage': { - 'volume_driver': - ['cinder.volume.drivers.nimble.NimbleISCSIDriver'], - 'volume_backend_name': ['cinder_nimblestorage'], - 'san_ip': ['10.11.12.13'], - 'san_login': ['admin'], - 'san_password': ['admin'], - 'use_multipath_for_image_xfer': [True], - 'nimble:encryption': ['yes'], - 'nimble:perfpol-name': ['test-performance-policy'], - 'nimble:multi-initiator': [True], - 'nimble_pool_name': ['default'], - 'nimble_subnet_label': ['*'], - 'nimble_verify_cert_path': ['None'], - 'nimble_verify_certificate': ['False']}} - - zaza.model.run_on_leader( - 'cinder', - 'sudo cp /etc/cinder/cinder.conf /tmp/', - model_name=self.model_name) - zaza.model.block_until_oslo_config_entries_match( - 'cinder', - '/tmp/cinder.conf', - expected_contents, - model_name=self.model_name, - timeout=2) - - # Disabled while there is no hardware Nimblestorage appliance - def _disabled_test_create_volume(self): - test_vol_name = "zaza{}".format(uuid.uuid1().fields[0]) - vol_new = self.cinder_client.volumes.create( - name=test_vol_name, - size=2) - openstack_utils.resource_reaches_status( - self.cinder_client.volumes, - vol_new.id, - expected_status='available') - test_vol = self.cinder_client.volumes.find(name=test_vol_name) - self.assertEqual( - getattr(test_vol, 'os-vol-host-attr:host').split('#')[0], - 'cinder@cinder-nimblestorage') - self.cinder_client.volumes.delete(vol_new) diff --git a/tox.ini b/tox.ini index 99cf840..10e5179 100644 --- a/tox.ini +++ b/tox.ini @@ -15,10 +15,12 @@ skip_missing_interpreters = False # * It is also necessary to pin virtualenv as a newer virtualenv would still # lead to fetching the latest pip in the func* tox targets, see # https://stackoverflow.com/a/38133283 +# * It is necessary to declare setuptools as a dependency otherwise tox will +# fail very early at not being able to load it. The version pinning is in +# line with `pip.sh`. requires = pip < 20.3 virtualenv < 20.0 -# NOTE: https://wiki.canonical.com/engineering/OpenStack/InstallLatestToxOnOsci -minversion = 3.2.0 + setuptools < 50.0.0 [testenv] setenv = VIRTUAL_ENV={envdir} @@ -29,8 +31,9 @@ install_command = commands = stestr run --slowest {posargs} whitelist_externals = git - add-to-archive.py bash + charmcraft + rename.sh passenv = HOME TERM CS_* OS_* TEST_* deps = -r{toxinidir}/test-requirements.txt @@ -54,6 +57,11 @@ basepython = python3.8 deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt +[testenv:py39] +basepython = python3.9 +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + [testenv:py3] basepython = python3 deps = -r{toxinidir}/requirements.txt @@ -100,8 +108,15 @@ commands = {posargs} [testenv:build] basepython = python3 deps = -r{toxinidir}/build-requirements.txt +# NOTE(lourot): charmcraft 1.0.0 used to generate +# cinder-nimblestorage.charm, which is the behaviour expected by OSCI. +# However charmcraft 1.2.1 now generates +# cinder-nimblestorage_ubuntu-20.04-amd64.charm instead. In order to keep +# the old behaviour we rename the file at the en commands = - charmcraft build + charmcraft clean + charmcraft -v build + {toxinidir}/rename.sh [testenv:func-noop] basepython = python3