From 75694acecc191ef01b5ea3a1a1fced464f0d4528 Mon Sep 17 00:00:00 2001 From: Charles Short Date: Thu, 2 Sep 2021 13:54:14 -0400 Subject: [PATCH] Enable py39 tox gate/test for app plugins Add support for tox testing under Debian Bullseye by enabling a python 3.9 gate and tox target for exercising plugin unit tests. Story: 2009101 Task: 43188 Signed-off-by: Charles Short Change-Id: Ie7f0f4efd809fafb95a14274c400e7cb2f8458b9 --- .zuul.yaml | 21 ++++++++++++++++++- bindep.txt | 10 +++++++++ python-k8sapp-snmp/k8sapp_snmp/.stestr.conf | 4 ++-- .../k8sapp_snmp/tests/test_plugins.py | 8 +++++++ python-k8sapp-snmp/k8sapp_snmp/tox.ini | 20 ++++++++++++++---- 5 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 bindep.txt diff --git a/.zuul.yaml b/.zuul.yaml index b34b5b2..0eda3c9 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -3,13 +3,32 @@ check: jobs: - openstack-tox-linters + - k8app-snmp-armada-tox-py39 gate: jobs: - openstack-tox-linters + - k8app-snmp-armada-tox-py39 post: jobs: - stx-snmp-armada-app-upload-git-mirror +- job: + name: k8app-snmp-armada-tox-py39 + parent: tox-py39 + description: | + Run py39 test for k8app-snmp-armada-app + nodeset: debian-bullseye + required-projects: + - starlingx/config + - starlingx/fault + - starlingx/update + - starlingx/utilities + files: + - python-k8sapp-snmp/k8sapp_snmp/* + vars: + tox_envlist: py39 + python_version: 3.9 + tox_extra_args: python-k8sapp-snmp/k8sapp_snmp/tox.ini - job: name: stx-snmp-armada-app-upload-git-mirror parent: upload-git-mirror @@ -100,4 +119,4 @@ Zbi+hbm/Cfzd8/hCnIQbG7LSi0kAiNSgM9pcU2J3qcivIL7ArpjOrYR+qTa4BraGcqumM oCrQPmkGGbtEjqD1r7GUHUaUUU2EnCv+qfXF2+GqV3VruRP0X/WWbLmfKYjLgDn3tY5nM PFo3bmC7D9aU2vHRefTIu0XPpg7VqGTaPIPngkpp71rwlc8s+Kskt/it3o6ZtQNsSna5+ - YrbCChy6nCnzWhPeNtAGlRzfSkMYJig98fgEC6wgOexmN6cUYGR7Q0pt/o0Ct0= \ No newline at end of file + YrbCChy6nCnzWhPeNtAGlRzfSkMYJig98fgEC6wgOexmN6cUYGR7Q0pt/o0Ct0= diff --git a/bindep.txt b/bindep.txt new file mode 100644 index 0000000..3ffe69f --- /dev/null +++ b/bindep.txt @@ -0,0 +1,10 @@ +# This is a cross-platform list tracking distribution packages needed for install and tests; +# see https://docs.openstack.org/infra/bindep/ for additional information. + +libffi-dev [platform:dpkg] +libldap2-dev [platform:dpkg] +libxml2-dev [platform:dpkg] +libxslt1-dev [platform:dpkg] +libsasl2-dev [platform:dpkg] +libffi-devel [platform:rpm] +python3-all-dev [platform:dpkg] diff --git a/python-k8sapp-snmp/k8sapp_snmp/.stestr.conf b/python-k8sapp-snmp/k8sapp_snmp/.stestr.conf index 1a33049..bef93da 100644 --- a/python-k8sapp-snmp/k8sapp_snmp/.stestr.conf +++ b/python-k8sapp-snmp/k8sapp_snmp/.stestr.conf @@ -1,4 +1,4 @@ [DEFAULT] -test_path=./k8sapp_cert_manager/tests -top_dir=./k8sapp_cert_manager +test_path=./k8sapp_snmp/tests +top_dir=./k8sapp_snmp #parallel_class=True diff --git a/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/tests/test_plugins.py b/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/tests/test_plugins.py index 97fe5bf..97e5a9a 100644 --- a/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/tests/test_plugins.py +++ b/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/tests/test_plugins.py @@ -4,6 +4,10 @@ # SPDX-License-Identifier: Apache-2.0 # +import mock + +from k8sapp_snmp.helm.snmp import SnmpHelm + from sysinv.common import constants from sysinv.tests.db import base as dbbase from sysinv.tests.helm.test_helm import HelmOperatorTestSuiteMixin @@ -15,6 +19,10 @@ class K8SAppSnmpAppMixin(object): def setUp(self): super(K8SAppSnmpAppMixin, self).setUp() + get_db_connection = mock.patch.object(SnmpHelm, + '_get_database_connection') + self.mock_save_overrides = get_db_connection.start() + self.addCleanup(get_db_connection.stop) # Test Configuration: diff --git a/python-k8sapp-snmp/k8sapp_snmp/tox.ini b/python-k8sapp-snmp/k8sapp_snmp/tox.ini index fa07dae..3b70e0e 100644 --- a/python-k8sapp-snmp/k8sapp_snmp/tox.ini +++ b/python-k8sapp-snmp/k8sapp_snmp/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = flake8,py27,py36,pylint,bandit +envlist = flake8,py27,py36,py39,pylint,bandit minversion = 1.6 # skipsdist = True #,pip-missing-reqs @@ -14,15 +14,15 @@ distshare={toxworkdir}/.tox/distshare # enabling usedevelop results in py27 develop-inst: # Exception: Versioning for this project requires either an sdist tarball, # or access to an upstream git repository. -# Note. site-packages is true and rpm-python must be yum installed on your dev machine. -sitepackages = True +# Note. site-packages is false and rpm-python must be yum installed on your dev machine. +sitepackages = False # tox is silly... these need to be separated by a newline.... whitelist_externals = bash find install_command = pip install \ - -v -v -v \ + -v -v -v --use-deprecated legacy-resolver \ -c{toxinidir}/upper-constraints.txt \ -c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/openstack/requirements/raw/branch/stable/stein/upper-constraints.txt} \ {opts} {packages} @@ -79,6 +79,18 @@ commands = stestr run {posargs} stestr slowest +[testenv:py39] +basepython = python3.9 +install_command = pip install \ + -v -v -v --use-deprecated legacy-resolver \ + -c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/starlingx/root/raw/branch/master/build-tools/requirements/debian/upper-constraints.txt} \ + {opts} {packages} +commands = + {[testenv]commands} + stestr run {posargs} + stestr slowest + + [testenv:pep8] # testenv:flake8 clone basepython = {[testenv:flake8]basepython}