Fix ci issues

* Fix pep8 issues - unpin the package versions
* Change unit tests bases on latest
changes in ops harness.

Change-Id: I62017d1ed5a225c479f64ce6a73bc5274bfc747b
This commit is contained in:
Hemanth Nakkina
2025-03-07 07:45:56 +05:30
parent c0950a23a5
commit c50638a7e4
3 changed files with 19 additions and 21 deletions

View File

@@ -149,5 +149,6 @@ class OpenstackLoadbalancerCharm(ops_openstack.core.OSBaseCharm):
self._configure_haproxy()
self._send_loadbalancer_response()
if __name__ == "__main__":
main(OpenstackLoadbalancerCharm)

27
tox.ini
View File

@@ -7,22 +7,6 @@ skipsdist = True
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
# * 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
setuptools < 50.0.0
# NOTE: https://wiki.canonical.com/engineering/OpenStack/InstallLatestToxOnOsci
minversion = 3.2.0
[testenv]
setenv = VIRTUAL_ENV={envdir}
@@ -37,7 +21,12 @@ allowlist_externals =
bash
charmcraft
rename.sh
passenv = HOME TERM CS_* OS_* TEST_*
passenv =
HOME
TERM
CS_*
OS_*
TEST_*
deps = -r{toxinidir}/test-requirements.txt
[testenv:py35]
@@ -77,8 +66,8 @@ deps = -r{toxinidir}/requirements.txt
[testenv:pep8]
basepython = python3
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
deps = flake8==7.1.1
git+https://github.com/juju/charm-tools.git
commands = flake8 {posargs} src unit_tests tests
[testenv:cover]

View File

@@ -16,6 +16,7 @@
import ipaddress
import json
import os
import re
import sys
import unittest
@@ -25,7 +26,9 @@ sys.path.append('src') # noqa
from mock import patch
from ops.testing import Harness, _TestingModelBackend
from ops._private.harness import _TestingModelBackend
from ops.jujucontext import _JujuContext
from ops.testing import Harness
from ops import framework, model
import charm
from unit_tests.manage_test_relations import (
@@ -72,6 +75,8 @@ class TestOpenstackLoadbalancerCharmBase(CharmTestCase):
def get_harness(self):
initial_config = {}
# dummy juju version
os.environ["JUJU_VERSION"] = "0.0.0"
_harness = Harness(
_OpenstackLoadbalancerCharm,
meta='''
@@ -122,7 +127,10 @@ requires:
return network_data[endpoint_name]
_harness._backend = _TestingOPSModelBackend(
_harness._unit_name, _harness._meta)
_harness._unit_name,
_harness._meta,
_harness._get_config(None),
_JujuContext.from_dict(os.environ),)
_harness._model = model.Model(
_harness._meta,
_harness._backend)