From d3ad9c8c078d96c323205f1c300a33e298a3d006 Mon Sep 17 00:00:00 2001 From: Alex Kavanagh Date: Mon, 7 Aug 2023 12:39:30 +0100 Subject: [PATCH 1/6] Add explicit .readthedocs.yaml Due to [1] this patch adds an explicit .readthedocs.yaml file for the readthedocs.org sphinx build. It also fixes some more recent linting failures in the actual docs that sphinx seems to care about more now. Finally, it experimentally uses pip-compile (manually) to generate a doc-requirements.txt from a doc-requirements.in just for the docs. This has been added to the tox.ini and the rest adjusted accordingly. [1] https://blog.readthedocs.com/doctool-without-configuration-file/ --- .readthedocs.yaml | 15 +++ doc-requirements.in | 5 + doc-requirements.txt | 168 +++++++++++++++++++++++++++++++++ doc/source/api.rst | 2 - doc/source/openstack-utils.rst | 5 - doc/source/test-utils.rst | 5 - tox.ini | 5 +- zaza/model.py | 14 ++- zaza/utilities/juju.py | 5 + 9 files changed, 204 insertions(+), 20 deletions(-) create mode 100644 .readthedocs.yaml create mode 100644 doc-requirements.in create mode 100644 doc-requirements.txt delete mode 100644 doc/source/openstack-utils.rst delete mode 100644 doc/source/test-utils.rst diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 000000000..6a78245db --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,15 @@ +version: 2 + +build: + os: "ubuntu-22.04" + tools: + python: "3.10" + +# Build from the docs/ directory with Sphinx +sphinx: + configuration: doc/source/conf.py + +# Explicitly set the version of Python and its requirements +python: + install: + - requirements: docs-requirements.txt diff --git a/doc-requirements.in b/doc-requirements.in new file mode 100644 index 000000000..07b4356b1 --- /dev/null +++ b/doc-requirements.in @@ -0,0 +1,5 @@ +oslo.config +async_generator +juju<3.0 +sphinx +sphinxcontrib-asyncio diff --git a/doc-requirements.txt b/doc-requirements.txt new file mode 100644 index 000000000..237bc0185 --- /dev/null +++ b/doc-requirements.txt @@ -0,0 +1,168 @@ +# +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: +# +# pip-compile doc-requirements.in +# +alabaster==0.7.13 + # via sphinx +async-generator==1.10 + # via -r doc-requirements.in +babel==2.12.1 + # via sphinx +bcrypt==4.0.1 + # via paramiko +cachetools==5.3.1 + # via google-auth +certifi==2023.7.22 + # via + # kubernetes + # requests +cffi==1.15.1 + # via + # cryptography + # pynacl +charset-normalizer==3.2.0 + # via requests +cryptography==41.0.3 + # via paramiko +debtcollector==2.5.0 + # via oslo-config +docutils==0.20.1 + # via sphinx +google-auth==2.17.3 + # via kubernetes +idna==3.4 + # via requests +imagesize==1.4.1 + # via sphinx +jinja2==3.1.2 + # via sphinx +juju==2.9.44.0 + # via -r doc-requirements.in +jujubundlelib==0.5.7 + # via theblues +kubernetes==27.2.0 + # via juju +macaroonbakery==1.3.1 + # via + # juju + # theblues +markupsafe==2.1.3 + # via jinja2 +mypy-extensions==1.0.0 + # via typing-inspect +netaddr==0.8.0 + # via oslo-config +oauthlib==3.2.2 + # via + # kubernetes + # requests-oauthlib +oslo-config==9.1.1 + # via -r doc-requirements.in +oslo-i18n==6.0.0 + # via oslo-config +packaging==23.1 + # via sphinx +paramiko==2.12.0 + # via juju +pbr==5.11.1 + # via + # oslo-i18n + # stevedore +protobuf==3.20.3 + # via macaroonbakery +pyasn1==0.5.0 + # via + # juju + # pyasn1-modules + # rsa +pyasn1-modules==0.3.0 + # via google-auth +pycparser==2.21 + # via cffi +pygments==2.16.1 + # via sphinx +pymacaroons==0.13.0 + # via macaroonbakery +pynacl==1.5.0 + # via + # macaroonbakery + # paramiko + # pymacaroons +pyrfc3339==1.1 + # via + # juju + # macaroonbakery +python-dateutil==2.8.2 + # via kubernetes +pytz==2023.3 + # via pyrfc3339 +pyyaml==6.0.1 + # via + # juju + # jujubundlelib + # kubernetes + # oslo-config +requests==2.31.0 + # via + # kubernetes + # macaroonbakery + # oslo-config + # requests-oauthlib + # sphinx + # theblues +requests-oauthlib==1.3.1 + # via kubernetes +rfc3986==2.0.0 + # via oslo-config +rsa==4.9 + # via google-auth +six==1.16.0 + # via + # google-auth + # kubernetes + # macaroonbakery + # paramiko + # pymacaroons + # python-dateutil +snowballstemmer==2.2.0 + # via sphinx +sphinx==7.1.2 + # via + # -r doc-requirements.in + # sphinxcontrib-asyncio +sphinxcontrib-applehelp==1.0.4 + # via sphinx +sphinxcontrib-asyncio==0.3.0 + # via -r doc-requirements.in +sphinxcontrib-devhelp==1.0.2 + # via sphinx +sphinxcontrib-htmlhelp==2.0.1 + # via sphinx +sphinxcontrib-jsmath==1.0.1 + # via sphinx +sphinxcontrib-qthelp==1.0.3 + # via sphinx +sphinxcontrib-serializinghtml==1.1.5 + # via sphinx +stevedore==5.1.0 + # via oslo-config +theblues==0.5.2 + # via juju +toposort==1.10 + # via juju +typing-extensions==4.7.1 + # via typing-inspect +typing-inspect==0.9.0 + # via juju +urllib3==2.0.4 + # via + # kubernetes + # requests +websocket-client==1.6.1 + # via kubernetes +websockets==11.0.3 + # via juju +wrapt==1.15.0 + # via debtcollector diff --git a/doc/source/api.rst b/doc/source/api.rst index b872e7689..3edf80364 100644 --- a/doc/source/api.rst +++ b/doc/source/api.rst @@ -6,10 +6,8 @@ Utilities API documentation controller-api model-api - openstack-utils tls-cert-utils cli-utils exception-utils generic-utils juju-utils - test-utils diff --git a/doc/source/openstack-utils.rst b/doc/source/openstack-utils.rst deleted file mode 100644 index 8ba9d3b6e..000000000 --- a/doc/source/openstack-utils.rst +++ /dev/null @@ -1,5 +0,0 @@ -OpenStack Utilities -------------------- - -.. automodule:: zaza.openstack.utilities.openstack - :members: diff --git a/doc/source/test-utils.rst b/doc/source/test-utils.rst deleted file mode 100644 index 20ad2e5ab..000000000 --- a/doc/source/test-utils.rst +++ /dev/null @@ -1,5 +0,0 @@ -Test Utils ----------- - -.. automodule:: zaza.charm_tests.test_utils - :members: diff --git a/tox.ini b/tox.ini index 1a7963a2d..3830b9a1d 100644 --- a/tox.ini +++ b/tox.ini @@ -17,8 +17,6 @@ passenv = CS_* OS_* TEST_* -deps = - -r{toxinidir}/test-requirements.txt commands = pytest --cov=./zaza/ {posargs} {toxinidir}/unit_tests [testenv:py3] @@ -37,6 +35,7 @@ commands = /bin/true [flake8] ignore = E402,E226,W504 +deps = -r{toxinidir}/test-requirements.txt per-file-ignores = unit_tests/**: D @@ -44,7 +43,7 @@ per-file-ignores = basepython = python3 changedir = doc/source deps = - -r{toxinidir}/test-requirements.txt + -r{toxinidir}/doc-requirements.txt commands = sphinx-build -W -b html -d {toxinidir}/doc/build/doctrees . {toxinidir}/doc/build/html [testenv:func] diff --git a/zaza/model.py b/zaza/model.py index 77e5e2ce6..f4bd3d5df 100644 --- a/zaza/model.py +++ b/zaza/model.py @@ -234,7 +234,7 @@ async def get_model_memo(model_name): async def get_model(model_name=None): - """Get (or create) the current model for :param:`model_name`. + """Get (or create) the current model for `model_name`. If None is passed, or there is no model_name param, then the current model is fetched. @@ -1503,7 +1503,9 @@ async def async_wait_for_application_states(model_name=None, states=None, message that starts with one of the approved_message_prefixes. Bespoke statuses and messages can be passed in with states. states takes - the form:: + the form: + + .. code-block:: python states = { 'app': { @@ -1515,6 +1517,7 @@ async def async_wait_for_application_states(model_name=None, states=None, 'workload-status-message-prefix': 'Unit is super ready'}} wait_for_application_states('modelname', states=states) + The keys that can be used are: - "workload-status" - an exact match of the workload-status @@ -1523,11 +1526,12 @@ async def async_wait_for_application_states(model_name=None, states=None, - "workload-status-message-regex" - the entire string matches if the regex matches. - "workloaed-status-message" - DEPRECATED; use - "workload-status-message-prefix" instead. - - "num-expected-units' - the number of units to be 'ready'. + "workload-status-message-prefix" instead. + - "num-expected-units' - the number of units to be 'ready'. To match an empty string, use: - "workload-status-message-regex": "^$" + + - `"workload-status-message-regex": "^$"` NOTE: all applications that are being waited on are expected to have at least one unit for that application to be ready. Any subordinate charms diff --git a/zaza/utilities/juju.py b/zaza/utilities/juju.py index d0ef1c54d..fea84c980 100644 --- a/zaza/utilities/juju.py +++ b/zaza/utilities/juju.py @@ -454,11 +454,16 @@ def get_subordinate_units(unit_list, charm_name=None, status=None, Subordinate can be filtered by using 'charm_name' which will only return subordinate units which have 'charm_name' in the name of the charm e.g. + .. code-block:: python + get_subordinate_units( ['cinder/1']) would return ['cinder-hacluster/1', 'cinder-ceph/2']) + where as + .. code-block:: python + get_subordinate_units( ['cinder/1'], charm_name='hac') would return ['cinder-hacluster/1'] From 4ea41320341af30a0fde78219622ff737b938ba4 Mon Sep 17 00:00:00 2001 From: Alex Kavanagh Date: Mon, 7 Aug 2023 12:51:50 +0100 Subject: [PATCH 2/6] Update gh tox.yaml to use py3 rather than py --- .github/workflows/tox.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tox.yaml b/.github/workflows/tox.yaml index 1d506b2a9..ca2b9b634 100644 --- a/.github/workflows/tox.yaml +++ b/.github/workflows/tox.yaml @@ -24,7 +24,7 @@ jobs: - name: Lint with tox run: tox -e pep8 - name: Test with tox - run: tox -e py + run: tox -e py3 - name: Codecov run: | set -euxo pipefail From d414dee6fcec94e1844e534c9f987476f4dc8608 Mon Sep 17 00:00:00 2001 From: Corey Bryant Date: Wed, 23 Aug 2023 18:46:31 +0000 Subject: [PATCH 3/6] Set pin-priority for proposed pocket to 500 As of lunar, a lower pin priority is set by default for the proposed pocket [1]. The lower pin-priority prevents installation of proposed packages, unless they are selectively installed per package [2]. This is the case even if the proposed package version is greater than any other available versions. This change restores the previous behavior. By creating an apt preferences file that sets the pin-priority of the proposed pocket to 500, all proposed packages will be installed when proposed is enabled, assuming the proposed package version is greater than any other available versions. [1] https://lists.ubuntu.com/archives/ubuntu-devel/2022-November/042338.html [2] sudo apt-get install packagename/lunar-proposed --- .github/workflows/tox.yaml | 3 +++ unit_tests/utilities/test_deployment_env.py | 26 ++++++++++++++++++++- zaza/utilities/deployment_env.py | 12 +++++++--- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tox.yaml b/.github/workflows/tox.yaml index ca2b9b634..92da89ed6 100644 --- a/.github/workflows/tox.yaml +++ b/.github/workflows/tox.yaml @@ -84,3 +84,6 @@ jobs: with: name: test-run-logs-and-crashdump path: logs/ + - name: consider debugging + uses: lhotari/action-upterm@v1 + if: failure() diff --git a/unit_tests/utilities/test_deployment_env.py b/unit_tests/utilities/test_deployment_env.py index 69c987d7b..58340a235 100644 --- a/unit_tests/utilities/test_deployment_env.py +++ b/unit_tests/utilities/test_deployment_env.py @@ -67,8 +67,27 @@ def test_get_overlay_ppas(self): self.assertEqual(deployment_env.get_overlay_ppas(), None) def test_get_cloudinit_userdata(self): + with mock.patch.object(deployment_env, 'get_overlay_ppas', + return_value=None): + preferences_file = "/etc/apt/preferences.d/proposed-updates" + cloud_config = { + 'apt': { + 'sources': {} + }, + 'preruncmd': [ + f"echo 'Package: *' >> {preferences_file}", + f"echo 'Pin: release a=*-proposed' >> {preferences_file}", + f"echo 'Pin-Priority: 500' >> {preferences_file}", + ] + } + cloudinit_userdata = "#cloud-config\n{}".format( + yaml.safe_dump(cloud_config)) + self.assertEqual( + deployment_env.get_cloudinit_userdata(), + cloudinit_userdata) with mock.patch.object(deployment_env, 'get_overlay_ppas', return_value=['ppa:ppa0', 'ppa:ppa1']): + preferences_file = "/etc/apt/preferences.d/proposed-updates" cloud_config = { 'apt': { 'sources': { @@ -79,7 +98,12 @@ def test_get_cloudinit_userdata(self): 'source': 'ppa:ppa1' } } - } + }, + 'preruncmd': [ + f"echo 'Package: *' >> {preferences_file}", + f"echo 'Pin: release a=*-proposed' >> {preferences_file}", + f"echo 'Pin-Priority: 500' >> {preferences_file}", + ] } cloudinit_userdata = "#cloud-config\n{}".format( yaml.safe_dump(cloud_config)) diff --git a/zaza/utilities/deployment_env.py b/zaza/utilities/deployment_env.py index f90e67258..b3faff6ac 100644 --- a/zaza/utilities/deployment_env.py +++ b/zaza/utilities/deployment_env.py @@ -116,11 +116,17 @@ def get_cloudinit_userdata(): :rtype: str """ cloudinit_userdata = None + preferences_file = "/etc/apt/preferences.d/proposed-updates" cloud_config = { 'apt': { 'sources': { } - } + }, + 'preruncmd': [ + f"echo 'Package: *' >> {preferences_file}", + f"echo 'Pin: release a=*-proposed' >> {preferences_file}", + f"echo 'Pin-Priority: 500' >> {preferences_file}", + ] } overlay_ppas = get_overlay_ppas() if overlay_ppas: @@ -128,8 +134,8 @@ def get_cloudinit_userdata(): cloud_config['apt']['sources']["overlay-ppa-{}".format(index)] = { 'source': overlay_ppa } - cloudinit_userdata = "#cloud-config\n{}".format( - yaml.safe_dump(cloud_config)) + cloudinit_userdata = "#cloud-config\n{}".format( + yaml.safe_dump(cloud_config)) return cloudinit_userdata From abbb76b558cc9527f66cbdc33a50f8a004c85ad9 Mon Sep 17 00:00:00 2001 From: Corey Bryant Date: Mon, 28 Aug 2023 22:01:12 +0000 Subject: [PATCH 4/6] Add model alias support to overlay_ppas There currently isn't model alias support for the overlay_ppas tests option: tests_options: overlay_ppas: - ppa:ubuntu-security-proposed/ppa This results in a lack of flexibility where a single tests.yaml will use the overlay_ppas for every deployment that it defines. Adding model alias support allows more flexibility by only setting up the overlay_ppas for a specified model alias: tests_options: model_alias_name: overlay_ppas: - ppa:ubuntu-security-proposed/ppa --- ...t_zaza_charm_lifecycle_func_test_runner.py | 16 +++++----- .../test_zaza_charm_lifecycle_prepare.py | 29 +++++++++++++++++++ unit_tests/utilities/test_deployment_env.py | 6 ++++ zaza/charm_lifecycle/func_test_runner.py | 1 + zaza/charm_lifecycle/prepare.py | 15 +++++++--- zaza/utilities/deployment_env.py | 20 +++++++++---- 6 files changed, 70 insertions(+), 17 deletions(-) diff --git a/unit_tests/test_zaza_charm_lifecycle_func_test_runner.py b/unit_tests/test_zaza_charm_lifecycle_func_test_runner.py index b1d83e355..088ee48d7 100644 --- a/unit_tests/test_zaza_charm_lifecycle_func_test_runner.py +++ b/unit_tests/test_zaza_charm_lifecycle_func_test_runner.py @@ -79,8 +79,8 @@ def test_func_test_runner(self): lc_func_test_runner.func_test_runner( force=True) prepare_calls = [ - mock.call('newmodel', test_directory=None), - mock.call('newmodel', test_directory=None)] + mock.call('newmodel', 'default_alias', test_directory=None), + mock.call('newmodel', 'default_alias', test_directory=None)] cwd = os.getcwd() deploy_calls = [ mock.call(cwd + '/tests/bundles/bundle1.yaml', 'newmodel', @@ -157,10 +157,10 @@ def test_func_test_runner_cmr(self): 'zaza.charm_tests.ks.test.project_create2']}]} lc_func_test_runner.func_test_runner() prepare_calls = [ - mock.call('m1', test_directory=None), - mock.call('m2', test_directory=None), - mock.call('m3', test_directory=None), - mock.call('m4', test_directory=None)] + mock.call('m1', 'default_alias', test_directory=None), + mock.call('m2', 'default_alias', test_directory=None), + mock.call('m3', 'model_alias_5', test_directory=None), + mock.call('m4', 'model_alias_6', test_directory=None)] cwd = os.getcwd() deploy_calls = [ mock.call(cwd + '/tests/bundles/bundle1.yaml', 'm1', @@ -252,8 +252,8 @@ def test_func_test_runner_with_before_script(self): lc_func_test_runner.func_test_runner() cwd = os.getcwd() prepare_calls = [ - mock.call('newmodel', test_directory=None), - mock.call('newmodel', test_directory=None)] + mock.call('newmodel', 'default_alias', test_directory=None), + mock.call('newmodel', 'default_alias', test_directory=None)] deploy_calls = [ mock.call(cwd + '/tests/bundles/bundle1.yaml', 'newmodel', model_ctxt={'default_alias': 'newmodel'}, force=False, diff --git a/unit_tests/test_zaza_charm_lifecycle_prepare.py b/unit_tests/test_zaza_charm_lifecycle_prepare.py index 6b3efd53d..c46b85670 100644 --- a/unit_tests/test_zaza_charm_lifecycle_prepare.py +++ b/unit_tests/test_zaza_charm_lifecycle_prepare.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import mock + import zaza.charm_lifecycle.prepare as lc_prepare import unit_tests.utils as ut_utils @@ -53,3 +55,30 @@ def test_parser_logging(self): # Using args args = lc_prepare.parse_args(['-m', 'model', '--log', 'DEBUG']) self.assertEqual(args.loglevel, 'DEBUG') + + def test_main(self): + self.patch_object(lc_prepare.sys, "argv") + self.patch_object(lc_prepare, "cli_utils") + mock_args = mock.MagicMock() + self.patch_object(lc_prepare, "parse_args", return_value=mock_args) + self.patch_object(lc_prepare, "prepare") + + # model + mock_args.model_name = "test_model" + mock_args.test_directory = None + + lc_prepare.main() + self.prepare.assert_called_once_with("test_model", "default_alias", + test_directory=None) + mock_args.reset_mock() + self.prepare.reset_mock() + + # alias:model + mock_args.model_name = "test_alias:test_model" + mock_args.test_directory = None + + lc_prepare.main() + self.prepare.assert_called_once_with("test_model", "test_alias", + test_directory=None) + mock_args.reset_mock() + self.prepare.reset_mock() diff --git a/unit_tests/utilities/test_deployment_env.py b/unit_tests/utilities/test_deployment_env.py index 58340a235..58d916c29 100644 --- a/unit_tests/utilities/test_deployment_env.py +++ b/unit_tests/utilities/test_deployment_env.py @@ -62,6 +62,12 @@ def test_get_overlay_ppas(self): self.assertEqual(deployment_env.get_overlay_ppas(), ro_types.ReadOnlyList(['ppa:ppa1', 'ppa:ppa2'])) + config = collections.OrderedDict({'model_alias': {'overlay_ppas': + ['ppa:ppa1', 'ppa:ppa2']}}) + get_options_mock.return_value = ro_types.resolve_immutable(config) + self.assertEqual(deployment_env.get_overlay_ppas('model_alias'), + ro_types.ReadOnlyList(['ppa:ppa1', 'ppa:ppa2'])) + config = collections.OrderedDict({'force_deploy': 'x-y'}) get_options_mock.return_value = ro_types.resolve_immutable(config) self.assertEqual(deployment_env.get_overlay_ppas(), None) diff --git a/zaza/charm_lifecycle/func_test_runner.py b/zaza/charm_lifecycle/func_test_runner.py index 814357132..325000b24 100644 --- a/zaza/charm_lifecycle/func_test_runner.py +++ b/zaza/charm_lifecycle/func_test_runner.py @@ -124,6 +124,7 @@ def run_env_deployment(env_deployment, keep_model=DESTROY_MODEL, force=False, for deployment in env_deployment.model_deploys: prepare.prepare( deployment.model_name, + deployment.model_alias, test_directory=test_directory) for deployment in env_deployment.model_deploys: diff --git a/zaza/charm_lifecycle/prepare.py b/zaza/charm_lifecycle/prepare.py index 8c731e232..6b75e23d9 100644 --- a/zaza/charm_lifecycle/prepare.py +++ b/zaza/charm_lifecycle/prepare.py @@ -29,11 +29,13 @@ @run_report.register_event_wrapper('Prepare Environment') -def prepare(model_name, test_directory=None): +def prepare(model_name, model_alias='default_alias', test_directory=None): """Run all steps to prepare the environment before a functional test run. :param model: Name of model to add :type bundle: str + :param model: Name of model alias + :type bundle: str :param test_directory: Set the directory containing tests.yaml and bundles. :type test_directory: str """ @@ -41,7 +43,7 @@ def prepare(model_name, test_directory=None): utils.set_base_test_dir(test_dir=test_directory) zaza.controller.add_model( model_name, - config=deployment_env.get_model_settings(), + config=deployment_env.get_model_settings(model_alias), cloud_name=deployment_env.get_cloud_name(), region=deployment_env.get_cloud_region()) zaza.model.set_model_constraints( @@ -70,10 +72,15 @@ def parse_args(args): def main(): """Add a new model.""" args = parse_args(sys.argv[1:]) + model_alias = 'default_alias' + model_name = args.model_name + if ':' in model_name: + model_alias, model_name = args.model_name.split(':') cli_utils.setup_logging(log_level=args.loglevel.upper()) - logging.info('model_name: {}'.format(args.model_name)) + logging.info('model_name: {}'.format(model_name)) + logging.info('model_alias: {}'.format(model_alias)) try: - prepare(args.model_name, test_directory=args.test_directory) + prepare(model_name, model_alias, test_directory=args.test_directory) run_report.output_event_report() finally: zaza.clean_up_libjuju_thread() diff --git a/zaza/utilities/deployment_env.py b/zaza/utilities/deployment_env.py index b3faff6ac..986cd006f 100644 --- a/zaza/utilities/deployment_env.py +++ b/zaza/utilities/deployment_env.py @@ -85,7 +85,7 @@ def parse_option_list_string(option_list, delimiter=None): return settings -def get_overlay_ppas(): +def get_overlay_ppas(model_alias='default_alias'): """Get overlay_ppas from global_config. In the config file for the tests, the tests_options.overlay_ppa option @@ -98,6 +98,8 @@ def get_overlay_ppas(): overlay_ppas: - ppa:ubuntu-security-proposed/ppa + :param model: Name of model alias + :type bundle: str :returns: List of overlay PPAs :rtype: list[str] """ @@ -106,12 +108,18 @@ def get_overlay_ppas(): return config.overlay_ppas except KeyError: pass + try: + return config[model_alias].overlay_ppas + except KeyError: + pass return None -def get_cloudinit_userdata(): +def get_cloudinit_userdata(model_alias='default_alias'): """Return cloudinit_userdata based on tests_options config. + :param model: Name of model alias + :type bundle: str :returns: YAML-formatted string of cloudinit_userdata :rtype: str """ @@ -128,7 +136,7 @@ def get_cloudinit_userdata(): f"echo 'Pin-Priority: 500' >> {preferences_file}", ] } - overlay_ppas = get_overlay_ppas() + overlay_ppas = get_overlay_ppas(model_alias) if overlay_ppas: for index, overlay_ppa in enumerate(overlay_ppas): cloud_config['apt']['sources']["overlay-ppa-{}".format(index)] = { @@ -139,9 +147,11 @@ def get_cloudinit_userdata(): return cloudinit_userdata -def get_model_settings(): +def get_model_settings(model_alias='default_alias'): """Return model settings from defaults, config file and env variables. + :param model: Name of model alias + :type bundle: str :returns: Settings to use for model :rtype: Dict """ @@ -149,7 +159,7 @@ def get_model_settings(): model_settings.update(get_setup_file_section(MODEL_SETTINGS_SECTION)) env_settings = os.environ.get('MODEL_SETTINGS', '') test_env_settings = os.environ.get('TEST_MODEL_SETTINGS', '') - cloudinit_userdata = get_cloudinit_userdata() + cloudinit_userdata = get_cloudinit_userdata(model_alias) if cloudinit_userdata: if 'cloudinit-userdata' in test_env_settings: logging.warn('TEST_MODEL_SETTINGS contains cloudinit-userdata ' From 95afecf56e9c3b8f22e217deefe947e683ce6e7c Mon Sep 17 00:00:00 2001 From: Corey Bryant Date: Thu, 31 Aug 2023 14:46:50 -0400 Subject: [PATCH 5/6] Check for model alias overlay_ppas first --- zaza/utilities/deployment_env.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/zaza/utilities/deployment_env.py b/zaza/utilities/deployment_env.py index 986cd006f..81799e99f 100644 --- a/zaza/utilities/deployment_env.py +++ b/zaza/utilities/deployment_env.py @@ -98,20 +98,26 @@ def get_overlay_ppas(model_alias='default_alias'): overlay_ppas: - ppa:ubuntu-security-proposed/ppa + or: + + tests_options: + model_alias: + overlay_ppas: + - ppa:ubuntu-security-proposed/ppa + :param model: Name of model alias :type bundle: str :returns: List of overlay PPAs :rtype: list[str] """ config = zaza.global_options.get_options() - try: - return config.overlay_ppas - except KeyError: - pass try: return config[model_alias].overlay_ppas except KeyError: - pass + try: + return config.overlay_ppas + except KeyError: + pass return None From 547d803ba51d45aa55e9b43f42ffd46e2b9eabd2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Oct 2023 00:24:44 +0000 Subject: [PATCH 6/6] Bump urllib3 from 2.0.4 to 2.0.6 Bumps [urllib3](https://github.com/urllib3/urllib3) from 2.0.4 to 2.0.6. - [Release notes](https://github.com/urllib3/urllib3/releases) - [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst) - [Commits](https://github.com/urllib3/urllib3/compare/2.0.4...2.0.6) --- updated-dependencies: - dependency-name: urllib3 dependency-type: indirect ... Signed-off-by: dependabot[bot] --- doc-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc-requirements.txt b/doc-requirements.txt index 237bc0185..791083c88 100644 --- a/doc-requirements.txt +++ b/doc-requirements.txt @@ -156,7 +156,7 @@ typing-extensions==4.7.1 # via typing-inspect typing-inspect==0.9.0 # via juju -urllib3==2.0.4 +urllib3==2.0.6 # via # kubernetes # requests