From e15346f46a4aae94265f38cd39592f96a3b53c08 Mon Sep 17 00:00:00 2001 From: David Ames Date: Wed, 16 Oct 2019 14:09:11 -0700 Subject: [PATCH] Upstream charm Bring charm into alignment with other OpenStack charms. Updates to requirements, tox, README and zuul.yaml. Change-Id: I31565983ad8ede264f69997668b194c6f320689c --- .gitreview | 4 ++ .zuul.yaml | 5 ++ requirements.txt | 7 ++- src/HACKING.md | 2 +- src/README.md | 62 +++++++++++++++++++ src/files/.gitkeep | 0 src/layer.yaml | 2 +- src/test-requirements.txt | 7 ++- src/tests/bundles/eoan.yaml | 2 +- src/tox.ini | 19 +++++- test-requirements.txt | 16 ++++- tox.ini | 27 +++++--- .../test_lib_charm_openstack_mysql_router.py | 16 ++--- 13 files changed, 140 insertions(+), 29 deletions(-) create mode 100644 .gitreview create mode 100644 .zuul.yaml create mode 100644 src/README.md create mode 100644 src/files/.gitkeep diff --git a/.gitreview b/.gitreview new file mode 100644 index 0000000..e1c8bd6 --- /dev/null +++ b/.gitreview @@ -0,0 +1,4 @@ +[gerrit] +host=review.opendev.org +port=29418 +project=openstack/charm-mysql-router.git diff --git a/.zuul.yaml b/.zuul.yaml new file mode 100644 index 0000000..7332a87 --- /dev/null +++ b/.zuul.yaml @@ -0,0 +1,5 @@ +- project: + templates: + - python35-charm-jobs + - openstack-python3-train-jobs + - openstack-cover-jobs diff --git a/requirements.txt b/requirements.txt index 20f335d..b1d4872 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ -# This file is managed centrally. If you find the need to modify this as a -# one-off, please don't. Intead, consult #openstack-charms and ask about -# requirements management in charms via bot-control. Thank you. +# 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 # # Build requirements charm-tools>=2.4.4 diff --git a/src/HACKING.md b/src/HACKING.md index 1be91a5..f34c51f 100644 --- a/src/HACKING.md +++ b/src/HACKING.md @@ -4,7 +4,7 @@ This charm is developed as part of the OpenStack Charms project, and as such you should refer to the [OpenStack Charm Development Guide](https://github.com/openstack/charm-guide) for details on how to contribute to this charm. -You can find its source code here: . +You can find its source code here: # To Do diff --git a/src/README.md b/src/README.md new file mode 100644 index 0000000..3385118 --- /dev/null +++ b/src/README.md @@ -0,0 +1,62 @@ +# Overview + +This charm provides a MySQL 8 Router. The charm proxies database requests from +the principle application charm to a MySQL 8 InnoDB Cluster. MySQL Router +handles cluster communication and understands the cluster schema. + +Ubuntu 19.10 or above is required. + +# Usage + +The charm is intended to be deployed as a subordinate charm on the +application server and related to the mysql-innodb-cluster charm. + +## Cluster deployment + +``` +juju deploy mysql-router +``` + +The charm is related to a principle application charm via the +[shared-db relation](https://github.com/openstack/charm-interface-mysql-shared): + +``` +juju add-relation keystone:shared-db mysql-router:shared-db +``` + +The charm is then related to the [MySQL 8 InnoDB cluster charm](https://github.com/openstack-charmers/charm-mysql-innodb-cluster) via the +[db-router relation](https://github.com/openstack-charmers/charm-interface-mysql-router): + +``` +juju add-relation msyql-router:db-router mysql-innodb-cluster:db-router +``` + +## Scale out Usage + +Scale out is accomplished by adding units to the principle charm: + +``` +juju add-unit keystone +``` + +## Known Limitations and Issues + +> **Warning**: This charm is in preview state. + +The charm is under active development and is not yet production ready. Its +current intended use is for validation of MySQL 8 InnoDB cluster for use with +OpenStack. + +# Contact Information + +OpenStack Charmers + +## Upstream MySQL + + - [Upstream documentation](https://dev.mysql.com/doc/mysql-router/8.0/en/) + +# Bugs + +Please report bugs on [Launchpad](https://bugs.launchpad.net/charm-mysql-router/+filebug). + +For general questions please refer to the OpenStack [Charm Guide](https://docs.openstack.org/charm-guide/latest/). diff --git a/src/files/.gitkeep b/src/files/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/layer.yaml b/src/layer.yaml index fb224f3..9d137b2 100644 --- a/src/layer.yaml +++ b/src/layer.yaml @@ -6,7 +6,7 @@ options: basic: use_venv: True packages: [ 'libmysqlclient-dev'] -repo: https://github.com/openstack-charmers/charm-mysql-router +repo: https://opendev.org/openstack/charm-mysql-router config: deletes: - verbose diff --git a/src/test-requirements.txt b/src/test-requirements.txt index f2912ba..d3c9be8 100644 --- a/src/test-requirements.txt +++ b/src/test-requirements.txt @@ -1,3 +1,8 @@ -# zaza +# 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/tests/bundles/eoan.yaml b/src/tests/bundles/eoan.yaml index 8c34114..d131fae 100644 --- a/src/tests/bundles/eoan.yaml +++ b/src/tests/bundles/eoan.yaml @@ -7,7 +7,7 @@ applications: charm: ../../../mysql-router mysql-innodb-cluster: series: eoan - charm: cs:~thedac/mysql-innodb-cluster + charm: cs:~openstack-charmers-next/mysql-innodb-cluster num_units: 3 options: source: distro-proposed diff --git a/src/tox.ini b/src/tox.ini index ce45106..07a7adc 100644 --- a/src/tox.ini +++ b/src/tox.ini @@ -1,12 +1,22 @@ +# 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 [testenv] setenv = VIRTUAL_ENV={envdir} PYTHONHASHSEED=0 whitelist_externals = juju -passenv = HOME TERM CS_API_* OS_* AMULET_* +passenv = HOME TERM CS_* OS_* TEST_* deps = -r{toxinidir}/test-requirements.txt install_command = pip install {opts} {packages} @@ -19,7 +29,7 @@ commands = charm-proof [testenv:func-noop] basepython = python3 commands = - true + functest-run-suite --help [testenv:func] basepython = python3 @@ -31,5 +41,10 @@ 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/test-requirements.txt b/test-requirements.txt index 14b380e..0ab97f6 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,6 +1,7 @@ -# This file is managed centrally. If you find the need to modify this as a -# one-off, please don't. Intead, consult #openstack-charms and ask about -# requirements management in charms via bot-control. Thank you. +# 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 # # Lint and unit test requirements flake8>=2.2.4,<=2.4.1 @@ -11,3 +12,12 @@ mock>=1.2 nose>=1.3.7 coverage>=3.6 git+https://github.com/openstack/charms.openstack.git#egg=charms.openstack +# +# Revisit for removal / mock improvement: +netifaces # vault +psycopg2-binary # vault +tenacity # vault +pbr # vault +cryptography # vault, keystone-saml-mellon +lxml # keystone-saml-mellon +hvac # vault, barbican-vault diff --git a/tox.ini b/tox.ini index b0a8454..5b41c1d 100644 --- a/tox.ini +++ b/tox.ini @@ -1,18 +1,25 @@ # Source charm: ./tox.ini # This file is managed centrally by release-tools and should not be modified -# within individual charm repos. +# 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] skipsdist = True envlist = pep8,py3 +# 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 [testenv] setenv = VIRTUAL_ENV={envdir} PYTHONHASHSEED=0 TERM=linux - CHARM_LAYER_PATH={toxinidir}/layers - CHARM_INTERFACES_DIR={toxinidir}/interfaces + LAYER_PATH={toxinidir}/layers + INTERFACE_PATH={toxinidir}/interfaces JUJU_REPOSITORY={toxinidir}/build -passenv = http_proxy https_proxy OS_* +passenv = http_proxy https_proxy INTERFACE_PATH LAYER_PATH JUJU_REPOSITORY install_command = pip install {opts} {packages} deps = @@ -26,22 +33,22 @@ commands = [testenv:py3] basepython = python3 deps = -r{toxinidir}/test-requirements.txt -commands = stestr run {posargs} +commands = stestr run --slowest {posargs} [testenv:py35] basepython = python3.5 deps = -r{toxinidir}/test-requirements.txt -commands = stestr run {posargs} +commands = stestr run --slowest {posargs} [testenv:py36] basepython = python3.6 deps = -r{toxinidir}/test-requirements.txt -commands = stestr run {posargs} +commands = stestr run --slowest {posargs} [testenv:py37] basepython = python3.7 deps = -r{toxinidir}/test-requirements.txt -commands = stestr run {posargs} +commands = stestr run --slowest {posargs} [testenv:pep8] basepython = python3 @@ -59,7 +66,7 @@ setenv = PYTHON=coverage run commands = coverage erase - stestr run {posargs} + stestr run --slowest {posargs} coverage combine coverage html -d cover coverage xml -o cover/coverage.xml @@ -82,4 +89,4 @@ commands = {posargs} [flake8] # E402 ignore necessary for path append before sys module import in actions -ignore = E402 +ignore = E402,W504 diff --git a/unit_tests/test_lib_charm_openstack_mysql_router.py b/unit_tests/test_lib_charm_openstack_mysql_router.py index 7de6fa7..84ee385 100644 --- a/unit_tests/test_lib_charm_openstack_mysql_router.py +++ b/unit_tests/test_lib_charm_openstack_mysql_router.py @@ -420,10 +420,9 @@ class TestMySQLRouterCharm(test_utils.PatchHelper): def test_proxy_db_and_user_requests_no_prefix(self): mrc = mysql_router.MySQLRouterCharm() mrc.proxy_db_and_user_requests(self.keystone_shared_db, self.db_router) - _calls = [mock.call('keystone', 'keystone', - self.keystone_unit_ip, - prefix=mrc._unprefixed)] - self.db_router.configure_proxy_db.assert_has_calls(_calls) + self.db_router.configure_proxy_db.assert_called_once_with( + 'keystone', 'keystone', self.keystone_unit_ip, + prefix=mrc._unprefixed) def test_proxy_db_and_user_requests_prefixed(self): mrc = mysql_router.MySQLRouterCharm() @@ -434,7 +433,8 @@ class TestMySQLRouterCharm(test_utils.PatchHelper): prefix="novaapi"), mock.call('nova_cell0', 'nova', self.nova_unit_ip, prefix="novacell0")] - self.db_router.configure_proxy_db.assert_has_calls(_calls) + self.db_router.configure_proxy_db.assert_has_calls( + _calls, any_order=True) def test_proxy_db_and_user_responses_unprefixed(self): _json_pass = '"pass"' @@ -499,7 +499,8 @@ class TestMySQLRouterCharm(test_utils.PatchHelper): self.nova_shared_db.relation_id, mrc.shared_db_address, _pass, None, prefix=_novacell0), ] - self.nova_shared_db.set_db_connection_info.assert_has_calls(_calls) + self.nova_shared_db.set_db_connection_info.assert_has_calls( + _calls, any_order=True) # Allowed Units set correctly self.nova_shared_db.set_db_connection_info.reset_mock() @@ -518,7 +519,8 @@ class TestMySQLRouterCharm(test_utils.PatchHelper): self.nova_shared_db.relation_id, mrc.shared_db_address, _pass, self.nova_unit_name, prefix=_novacell0), ] - self.nova_shared_db.set_db_connection_info.assert_has_calls(_calls) + self.nova_shared_db.set_db_connection_info.assert_has_calls( + _calls, any_order=True) # Confirm msyqlrouter credentials are not sent over the shared-db # relation