diff --git a/installers/charm/bundles/osm-ha/bundle.yaml b/installers/charm/bundles/osm-ha/bundle.yaml index d3a586a8bc7ace5f7868ba13ea4d7f8373d447b5..9ee719541a22d1ad1cd5715e10e4af039593150b 100644 --- a/installers/charm/bundles/osm-ha/bundle.yaml +++ b/installers/charm/bundles/osm-ha/bundle.yaml @@ -83,7 +83,7 @@ applications: gui-x: 0 gui-y: 0 nbi: - charm: "cs:~charmed-osm/nbi-5" + charm: "cs:~charmed-osm/nbi-6" scale: 3 series: kubernetes options: @@ -94,7 +94,7 @@ applications: gui-x: 0 gui-y: -250 ro: - charm: "cs:~charmed-osm/ro-0" + charm: "cs:~charmed-osm/ro-1" scale: 3 series: kubernetes options: @@ -103,14 +103,14 @@ applications: gui-x: -300 gui-y: 250 ng-ui: - charm: "cs:~charmed-osm/ng-ui-16" + charm: "cs:~charmed-osm/ng-ui-17" scale: 3 series: kubernetes annotations: gui-x: 600 gui-y: 0 lcm: - charm: "cs:~charmed-osm/lcm-0" + charm: "cs:~charmed-osm/lcm-2" scale: 3 series: kubernetes options: @@ -120,7 +120,7 @@ applications: gui-x: -300 gui-y: 0 mon: - charm: "cs:~charmed-osm/mon-1" + charm: "cs:~charmed-osm/mon-2" scale: 1 series: kubernetes options: @@ -131,7 +131,7 @@ applications: gui-x: 300 gui-y: 0 pol: - charm: "cs:~charmed-osm/pol-0" + charm: "cs:~charmed-osm/pol-1" scale: 3 series: kubernetes options: @@ -140,7 +140,7 @@ applications: gui-x: -300 gui-y: 500 pla: - charm: "cs:~charmed-osm/pla-6" + charm: "cs:~charmed-osm/pla-7" scale: 3 series: kubernetes options: @@ -149,7 +149,7 @@ applications: gui-x: 600 gui-y: -250 prometheus: - charm: "cs:~charmed-osm/prometheus-0" + charm: "cs:~charmed-osm/prometheus-1" scale: 1 series: kubernetes storage: @@ -160,14 +160,14 @@ applications: gui-x: 300 gui-y: 250 grafana: - charm: "cs:~charmed-osm/grafana-0" + charm: "cs:~charmed-osm/grafana-1" scale: 3 series: kubernetes annotations: gui-x: 300 gui-y: 500 keystone: - charm: "cs:~charmed-osm/keystone-4" + charm: "cs:~charmed-osm/keystone-5" scale: 1 series: kubernetes annotations: diff --git a/installers/charm/bundles/osm/bundle.yaml b/installers/charm/bundles/osm/bundle.yaml index b210a40d94901b84437ccb99813a29f9d01d9500..404ed56657929572b1ae5868d0c0769e5e0204ba 100644 --- a/installers/charm/bundles/osm/bundle.yaml +++ b/installers/charm/bundles/osm/bundle.yaml @@ -76,7 +76,7 @@ applications: gui-x: 0 gui-y: 0 nbi: - charm: "cs:~charmed-osm/nbi-5" + charm: "cs:~charmed-osm/nbi-6" scale: 1 series: kubernetes options: @@ -87,7 +87,7 @@ applications: gui-x: 0 gui-y: -250 ro: - charm: "cs:~charmed-osm/ro-0" + charm: "cs:~charmed-osm/ro-1" scale: 1 series: kubernetes options: @@ -96,14 +96,14 @@ applications: gui-x: -300 gui-y: 250 ng-ui: - charm: "cs:~charmed-osm/ng-ui-16" + charm: "cs:~charmed-osm/ng-ui-17" scale: 1 series: kubernetes annotations: gui-x: 600 gui-y: 0 lcm: - charm: "cs:~charmed-osm/lcm-0" + charm: "cs:~charmed-osm/lcm-2" scale: 1 series: kubernetes options: @@ -113,7 +113,7 @@ applications: gui-x: -300 gui-y: 0 mon: - charm: "cs:~charmed-osm/mon-1" + charm: "cs:~charmed-osm/mon-2" scale: 1 series: kubernetes options: @@ -124,7 +124,7 @@ applications: gui-x: 300 gui-y: 0 pol: - charm: "cs:~charmed-osm/pol-0" + charm: "cs:~charmed-osm/pol-1" scale: 1 series: kubernetes options: @@ -133,7 +133,7 @@ applications: gui-x: -300 gui-y: 500 pla: - charm: "cs:~charmed-osm/pla-6" + charm: "cs:~charmed-osm/pla-7" scale: 1 series: kubernetes options: @@ -142,7 +142,7 @@ applications: gui-x: 600 gui-y: -250 prometheus: - charm: "cs:~charmed-osm/prometheus-0" + charm: "cs:~charmed-osm/prometheus-1" scale: 1 series: kubernetes storage: @@ -153,14 +153,14 @@ applications: gui-x: 300 gui-y: 250 grafana: - charm: "cs:~charmed-osm/grafana-0" + charm: "cs:~charmed-osm/grafana-1" scale: 1 series: kubernetes annotations: gui-x: 300 gui-y: 500 keystone: - charm: "cs:~charmed-osm/keystone-4" + charm: "cs:~charmed-osm/keystone-5" scale: 1 series: kubernetes annotations: diff --git a/installers/charm/grafana/.jujuignore b/installers/charm/grafana/.jujuignore index bf04eb4787e6df5fd324a95b451e20c45ee9c0e5..3ae3e7dcbaabc72ec7f40ebc13192774df7f4a52 100644 --- a/installers/charm/grafana/.jujuignore +++ b/installers/charm/grafana/.jujuignore @@ -22,7 +22,13 @@ venv .vscode build -prometheus.charm +*.charm .coverage +coverage.xml +.gitignore .stestr cover +release +tests/ +requirements* +tox.ini diff --git a/installers/charm/grafana/requirements-test.txt b/installers/charm/grafana/requirements-test.txt index d7585f3e724a8c6258c4e9d960853d84e40ffe55..cf61dd4e12aa3e3834919feba9149f980468c28b 100644 --- a/installers/charm/grafana/requirements-test.txt +++ b/installers/charm/grafana/requirements-test.txt @@ -17,15 +17,4 @@ # # To get in touch with the maintainers, please contact: # osm-charmers@lists.launchpad.net -## --r requirements.txt -coverage -stestr -mock -black -yamllint -flake8 -safety -requests-mock -asynctest -nose2 \ No newline at end of file +mock==4.0.3 diff --git a/installers/charm/grafana/src/charm.py b/installers/charm/grafana/src/charm.py index d61873c79a2f83da73fbb5cc42c15eebd9e6ffdd..d10ccf23335081c0da81b167a37b0ae1422c5cf1 100755 --- a/installers/charm/grafana/src/charm.py +++ b/installers/charm/grafana/src/charm.py @@ -22,33 +22,25 @@ # pylint: disable=E0213 -import logging -from typing import Optional, NoReturn from ipaddress import ip_network +import logging +from pathlib import Path +from string import Template +from typing import NoReturn, Optional +from urllib.parse import urlparse from ops.main import main - from opslib.osm.charm import CharmedOsmBase, RelationsMissing - +from opslib.osm.interfaces.prometheus import PrometheusClient from opslib.osm.pod import ( - IngressResourceV3Builder, - FilesV3Builder, ContainerV3Builder, + FilesV3Builder, + IngressResourceV3Builder, PodSpecV3Builder, ) +from opslib.osm.validator import ModelValidator, validator -from opslib.osm.validator import ( - ModelValidator, - validator, -) - -from opslib.osm.interfaces.prometheus import PrometheusClient - -from urllib.parse import urlparse -from string import Template -from pathlib import Path - logger = logging.getLogger(__name__) PORT = 3000 @@ -90,8 +82,12 @@ class GrafanaCharm(CharmedOsmBase): super().__init__(*args, oci_image="image") self.prometheus_client = PrometheusClient(self, "prometheus") - self.framework.observe(self.on["prometheus"].relation_changed, self.configure_pod) - self.framework.observe(self.on["prometheus"].relation_broken, self.configure_pod) + self.framework.observe( + self.on["prometheus"].relation_changed, self.configure_pod + ) + self.framework.observe( + self.on["prometheus"].relation_broken, self.configure_pod + ) def _build_dashboard_files(self, config: ConfigModel): files_builder = FilesV3Builder() diff --git a/installers/charm/grafana/tests/__init__.py b/installers/charm/grafana/tests/__init__.py index 4fd849a5245f3f35f6fc392416062360d94a99f4..0967ea68109fb929e76d101e375c8432cec94795 100644 --- a/installers/charm/grafana/tests/__init__.py +++ b/installers/charm/grafana/tests/__init__.py @@ -23,6 +23,8 @@ """Init mocking for unit tests.""" import sys + + import mock sys.path.append("src") diff --git a/installers/charm/grafana/tests/test_charm.py b/installers/charm/grafana/tests/test_charm.py index 07beb4aa91fc3f2b13c524a07e0a7f882ecab02c..4e269df9dfcfde269e0d725e68edba6f42a6e659 100644 --- a/installers/charm/grafana/tests/test_charm.py +++ b/installers/charm/grafana/tests/test_charm.py @@ -23,10 +23,10 @@ import sys from typing import NoReturn import unittest -from ops.model import ActiveStatus, BlockedStatus -from ops.testing import Harness from charm import GrafanaCharm +from ops.model import ActiveStatus, BlockedStatus +from ops.testing import Harness class TestCharm(unittest.TestCase): diff --git a/installers/charm/grafana/tox.ini b/installers/charm/grafana/tox.ini index 1f9442e3716ae0dbdc8ad1888162d1c9f5872f4b..dc4074f2efa5a0f6b5b8c15c5cd9211289be08c5 100644 --- a/installers/charm/grafana/tox.ini +++ b/installers/charm/grafana/tox.ini @@ -21,21 +21,32 @@ ####################################################################################### [tox] -envlist = flake8, cover, pylint, safety, yamllint -skipsdist = True +envlist = black, cover, flake8, pylint, yamllint, safety +skipsdist = true + +[tox:jenkins] +toxworkdir = /tmp/.tox [testenv] basepython = python3.8 -setenv = - VIRTUAL_ENV={envdir} - PYTHONHASHSEED=0 - PYTHONPATH = {toxinidir}/src +setenv = VIRTUAL_ENV={envdir} + PYTHONDONTWRITEBYTECODE = 1 deps = -r{toxinidir}/requirements.txt + +####################################################################################### +[testenv:black] +deps = black +commands = + black --check --diff src/ tests/ + + ####################################################################################### [testenv:cover] deps = {[testenv]deps} -r{toxinidir}/requirements-test.txt + coverage + nose2 commands = sh -c 'rm -f nosetests.xml' coverage erase @@ -45,21 +56,14 @@ commands = coverage xml -o coverage.xml --omit=*tests* whitelist_externals = sh -####################################################################################### -[testenv:safety] -setenv = - LC_ALL=C.UTF-8 - LANG=C.UTF-8 -deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt -commands = - - safety check --full-report ####################################################################################### [testenv:flake8] -deps = flake8 +deps = flake8 + flake8-import-order commands = - flake8 src/ tests/ + flake8 src/ tests/ --exclude=*pod_spec* + ####################################################################################### [testenv:pylint] @@ -67,14 +71,19 @@ deps = {[testenv]deps} -r{toxinidir}/requirements-test.txt pylint commands = - pylint -E src + pylint -E src/ tests/ + ####################################################################################### -[testenv:black] +[testenv:safety] +setenv = + LC_ALL=C.UTF-8 + LANG=C.UTF-8 deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt - black -commands = black --check --diff . --exclude "build/|.tox/|mod/|lib/" + safety +commands = + - safety check --full-report + ####################################################################################### [testenv:yamllint] @@ -86,9 +95,7 @@ commands = yamllint . ####################################################################################### [testenv:build] passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY -deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt - charmcraft +deps = charmcraft whitelist_externals = charmcraft cp @@ -112,4 +119,5 @@ exclude = max-line-length = 120 show-source = True builtins = _ - +max-complexity = 10 +import-order-style = google diff --git a/installers/charm/keystone/.jujuignore b/installers/charm/keystone/.jujuignore index bf04eb4787e6df5fd324a95b451e20c45ee9c0e5..3ae3e7dcbaabc72ec7f40ebc13192774df7f4a52 100644 --- a/installers/charm/keystone/.jujuignore +++ b/installers/charm/keystone/.jujuignore @@ -22,7 +22,13 @@ venv .vscode build -prometheus.charm +*.charm .coverage +coverage.xml +.gitignore .stestr cover +release +tests/ +requirements* +tox.ini diff --git a/installers/charm/keystone/requirements-test.txt b/installers/charm/keystone/requirements-test.txt index d7585f3e724a8c6258c4e9d960853d84e40ffe55..cf61dd4e12aa3e3834919feba9149f980468c28b 100644 --- a/installers/charm/keystone/requirements-test.txt +++ b/installers/charm/keystone/requirements-test.txt @@ -17,15 +17,4 @@ # # To get in touch with the maintainers, please contact: # osm-charmers@lists.launchpad.net -## --r requirements.txt -coverage -stestr -mock -black -yamllint -flake8 -safety -requests-mock -asynctest -nose2 \ No newline at end of file +mock==4.0.3 diff --git a/installers/charm/keystone/src/charm.py b/installers/charm/keystone/src/charm.py index 72d70906328c95d19240b5436cb29eeca070b527..a8c69fe65ca6d2b60ac60327ea3ca009626ef9b9 100755 --- a/installers/charm/keystone/src/charm.py +++ b/installers/charm/keystone/src/charm.py @@ -23,33 +23,25 @@ # pylint: disable=E0213 -import json -import logging -from cryptography.fernet import Fernet from datetime import datetime -from typing import Optional, NoReturn, List, Tuple from ipaddress import ip_network +import json +import logging +from typing import List, NoReturn, Optional, Tuple from urllib.parse import urlparse +from cryptography.fernet import Fernet from ops.main import main - from opslib.osm.charm import CharmedOsmBase, RelationsMissing - +from opslib.osm.interfaces.keystone import KeystoneServer +from opslib.osm.interfaces.mysql import MysqlClient from opslib.osm.pod import ( ContainerV3Builder, - PodSpecV3Builder, FilesV3Builder, IngressResourceV3Builder, + PodSpecV3Builder, ) - - -from opslib.osm.validator import ( - ModelValidator, - validator, -) - -from opslib.osm.interfaces.mysql import MysqlClient -from opslib.osm.interfaces.keystone import KeystoneServer +from opslib.osm.validator import ModelValidator, validator logger = logging.getLogger(__name__) diff --git a/installers/charm/keystone/tests/__init__.py b/installers/charm/keystone/tests/__init__.py index d0d973ae18111167581b5a2173a6998e9c2cb1cb..ca37e3b9e83699ffa5ac06f6c7003747272618b4 100644 --- a/installers/charm/keystone/tests/__init__.py +++ b/installers/charm/keystone/tests/__init__.py @@ -23,6 +23,8 @@ """Init mocking for unit tests.""" import sys + + import mock sys.path.append("src") diff --git a/installers/charm/keystone/tests/test_charm.py b/installers/charm/keystone/tests/test_charm.py index 756a5e4213c3b199d093a9ee1878d696e7e92714..d16e75d7dbeeadf695d0a763200d5641e90418c5 100644 --- a/installers/charm/keystone/tests/test_charm.py +++ b/installers/charm/keystone/tests/test_charm.py @@ -23,10 +23,11 @@ import sys from typing import NoReturn import unittest -from ops.model import ActiveStatus, BlockedStatus -from ops.testing import Harness + from charm import KeystoneCharm +from ops.model import ActiveStatus, BlockedStatus +from ops.testing import Harness class TestCharm(unittest.TestCase): diff --git a/installers/charm/keystone/tox.ini b/installers/charm/keystone/tox.ini index 1f9442e3716ae0dbdc8ad1888162d1c9f5872f4b..d0d25709621904ab48d87903dde0a6a333f8e33a 100644 --- a/installers/charm/keystone/tox.ini +++ b/installers/charm/keystone/tox.ini @@ -21,21 +21,32 @@ ####################################################################################### [tox] -envlist = flake8, cover, pylint, safety, yamllint -skipsdist = True +envlist = black, cover, flake8, pylint, yamllint, safety +skipsdist = true + +[tox:jenkins] +toxworkdir = /tmp/.tox [testenv] basepython = python3.8 -setenv = - VIRTUAL_ENV={envdir} - PYTHONHASHSEED=0 - PYTHONPATH = {toxinidir}/src +setenv = VIRTUAL_ENV={envdir} + PYTHONDONTWRITEBYTECODE = 1 deps = -r{toxinidir}/requirements.txt + +####################################################################################### +[testenv:black] +deps = black +commands = + black --check --diff src/ tests/ + + ####################################################################################### [testenv:cover] deps = {[testenv]deps} -r{toxinidir}/requirements-test.txt + coverage + nose2 commands = sh -c 'rm -f nosetests.xml' coverage erase @@ -45,36 +56,34 @@ commands = coverage xml -o coverage.xml --omit=*tests* whitelist_externals = sh -####################################################################################### -[testenv:safety] -setenv = - LC_ALL=C.UTF-8 - LANG=C.UTF-8 -deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt -commands = - - safety check --full-report ####################################################################################### [testenv:flake8] -deps = flake8 +deps = flake8 + flake8-import-order commands = flake8 src/ tests/ + ####################################################################################### [testenv:pylint] deps = {[testenv]deps} -r{toxinidir}/requirements-test.txt pylint commands = - pylint -E src + pylint -E src/ tests/ + ####################################################################################### -[testenv:black] +[testenv:safety] +setenv = + LC_ALL=C.UTF-8 + LANG=C.UTF-8 deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt - black -commands = black --check --diff . --exclude "build/|.tox/|mod/|lib/" + safety +commands = + - safety check --full-report + ####################################################################################### [testenv:yamllint] @@ -86,9 +95,7 @@ commands = yamllint . ####################################################################################### [testenv:build] passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY -deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt - charmcraft +deps = charmcraft whitelist_externals = charmcraft cp @@ -112,4 +119,5 @@ exclude = max-line-length = 120 show-source = True builtins = _ - +; max-complexity = 10 +import-order-style = google diff --git a/installers/charm/lcm/.jujuignore b/installers/charm/lcm/.jujuignore index bf04eb4787e6df5fd324a95b451e20c45ee9c0e5..3ae3e7dcbaabc72ec7f40ebc13192774df7f4a52 100644 --- a/installers/charm/lcm/.jujuignore +++ b/installers/charm/lcm/.jujuignore @@ -22,7 +22,13 @@ venv .vscode build -prometheus.charm +*.charm .coverage +coverage.xml +.gitignore .stestr cover +release +tests/ +requirements* +tox.ini diff --git a/installers/charm/lcm/config.yaml b/installers/charm/lcm/config.yaml index 4c823d165f13ae179fb4bee07b14522ed1482bd5..6301622e064e63346413962e2bdc61c4115bf8f6 100644 --- a/installers/charm/lcm/config.yaml +++ b/installers/charm/lcm/config.yaml @@ -32,9 +32,9 @@ options: type: string description: "The VCA user name." default: "admin" - vca_password: + vca_secret: type: string - description: "The VCA user password." + description: "The VCA user secret." default: "secret" vca_pubkey: type: string @@ -63,3 +63,211 @@ options: description: "Log Level" type: string default: "INFO" + vca_model_config_agent_metadata_url: + description: The URL of the private stream. + type: string + vca_model_config_agent_stream: + description: | + The stream to use for deploy/upgrades of agents. + See additional info below. + type: string + vca_model_config_apt_ftp_proxy: + description: The APT FTP proxy for the model. + type: string + vca_model_config_apt_http_proxy: + description: The APT HTTP proxy for the model. + type: string + vca_model_config_apt_https_proxy: + description: The APT HTTPS proxy for the model. + type: string + vca_model_config_apt_mirror: + description: The APT mirror for the model. + type: string + vca_model_config_apt_no_proxy: + description: The APT no proxy for the model. + type: string + vca_model_config_automatically_retry_hooks: + description: Set the policy on retying failed hooks. + type: boolean + vca_model_config_backup_dir: + description: Backup directory + type: string + vca_model_config_cloudinit_userdata: + description: Cloudinit userdata + type: string + vca_model_config_container_image_metadata_url: + description: | + Corresponds to 'image-metadata-url' (see below) for cloud-hosted + KVM guests or LXD containers. Not needed for the localhost cloud. + type: string + vca_model_config_container_image_stream: + description: | + Corresponds to 'image-stream' (see below) for cloud-hosted KVM + guests or LXD containers. Not needed for the localhost cloud. + type: string + vca_model_config_container_inherit_properties: + description: | + Set parameters to be inherited from a machine toits hosted + containers (KVM or LXD). + type: string + vca_model_config_container_networking_method: + description: | + The FAN networking mode to use. Default values can be provider-specific. + type: string + vca_model_config_default_series: + description: The default series of Ubuntu to use for deploying charms. + type: string + vca_model_config_default_space: + description: | + The space used as the default binding when deploying charms. + Will be "alpha" by default. + type: string + vca_model_config_development: + description: Set whether the model is in development mode. + type: boolean + vca_model_config_disable_network_management: + description: | + Set whether to give network control to the provider instead + of Juju controlling configuration. + type: boolean + vca_model_config_egress_subnets: + description: Egress subnets + type: string + vca_model_config_enable_os_refresh_update: + description: | + Set whether newly provisioned instances should run their + respective OS's update capability. + type: boolean + vca_model_config_enable_os_upgrade: + description: | + Set whether newly provisioned instances should run their + respective OS's upgrade capability. + type: boolean + vca_model_config_fan_config: + description: | + The FAN overlay and underlay networks in + CIDR notation (space-separated). + type: string + vca_model_config_firewall_mode: + description: The mode to use for network firewalling. + type: string + vca_model_config_ftp_proxy: + description: | + The FTP proxy value to configure on instances, + in the FTP_PROXY environment variable. + type: string + vca_model_config_http_proxy: + description: | + The HTTP proxy value to configure on instances, + in the HTTP_PROXY environment variable. + type: string + vca_model_config_https_proxy: + description: | + The HTTPS proxy value to configure on instances, + in the HTTPS_PROXY environment variable. + type: string + vca_model_config_ignore_machine_addresses: + description: | + When true, the machine worker will not look up + or discover any machine addresses. + type: boolean + vca_model_config_image_metadata_url: + description: | + The URL at which the metadata used to locate + OS image ids is located. + type: string + vca_model_config_image_stream: + description: | + The simplestreams stream used to identify which image + ids to search when starting an instance. + type: string + vca_model_config_juju_ftp_proxy: + description: The charm-centric FTP proxy value. + type: string + vca_model_config_juju_http_proxy: + description: The charm-centric HTTP proxy value. + type: string + vca_model_config_juju_https_proxy: + description: The charm-centric HTTPS proxy value. + type: string + vca_model_config_juju_no_proxy: + description: The charm-centric no-proxy value. + type: string + vca_model_config_logforward_enabled: + description: Set whether the log forward function is enabled. + type: boolean + vca_model_config_logging_config: + description: | + The configuration string to use when configuring Juju agent logging + type: string + vca_model_config_lxd_snap_channel: + description: LXD snap channel + type: string + vca_model_config_max_action_results_age: + description: The maximum aget for status action results entries + type: string + vca_model_config_max_action_results_size: + description: The maximum size for status action results entries + type: string + vca_model_config_max_status_history_age: + description: | + The maximum age for status history entries before they are pruned, + in a human-readable time format. + type: string + vca_model_config_max_status_history_size: + description: | + The maximum size for the status history collection, + in human-readable memory format. + type: string + vca_model_config_net_bond_reconfigure_delay: + description: Net bond reconfigure delay + type: int + vca_model_config_no_proxy: + description: List of domain addresses not to be proxied (comma-separated). + type: string + vca_model_config_provisioner_harvest_mode: + description: Set what to do with unknown machines. + type: string + vca_model_config_proxy_ssh: + description: | + Set whether SSH commands should be proxied through the API server. + type: boolean + vca_model_config_snap_http_proxy: + description: The snap-centric HTTP proxy value. + type: string + vca_model_config_snap_https_proxy: + description: The snap-centric HTTPS proxy value. + type: string + vca_model_config_snap_store_assertions: + description: | + The collection of snap store assertions. + Each entry should contain the snap store ID. + type: string + vca_model_config_snap_store_proxy: + description: The snap store ID. + type: string + vca_model_config_snap_store_proxy_url: + description: The snap store proxy url + type: string + vca_model_config_ssl_hostname_verification: + description: Set whether SSL hostname verification is enabled. + type: boolean + vca_model_config_test_mode: + description: | + Set whether the model is intended for testing. + If true, accessing the charm store does not affect + statistical data of the store. + type: boolean + vca_model_config_transmit_vendor_metrics: + description: | + Set whether the controller will send metrics collected from + this model for use in anonymized aggregate analytics. + type: boolean + vca_model_config_update_status_hook_interval: + description: | + The run frequency of the update-status hook. + The value has a random +/- 20% offset applied to avoid hooks + for all units firing at once. Value change only honoured + during controller and model creation + (bootstrap --config and add-model --config). + type: string diff --git a/installers/charm/lcm/requirements-test.txt b/installers/charm/lcm/requirements-test.txt index d7585f3e724a8c6258c4e9d960853d84e40ffe55..cf61dd4e12aa3e3834919feba9149f980468c28b 100644 --- a/installers/charm/lcm/requirements-test.txt +++ b/installers/charm/lcm/requirements-test.txt @@ -17,15 +17,4 @@ # # To get in touch with the maintainers, please contact: # osm-charmers@lists.launchpad.net -## --r requirements.txt -coverage -stestr -mock -black -yamllint -flake8 -safety -requests-mock -asynctest -nose2 \ No newline at end of file +mock==4.0.3 diff --git a/installers/charm/lcm/src/charm.py b/installers/charm/lcm/src/charm.py index 270a5479a837a791859d2f2143eb5e71c5afb030..e9552fd194f887085f9d7c3c87c0d6484ea7875f 100755 --- a/installers/charm/lcm/src/charm.py +++ b/installers/charm/lcm/src/charm.py @@ -24,25 +24,16 @@ import logging -from typing import Optional, NoReturn +from typing import NoReturn, Optional -from ops.main import main +from ops.main import main from opslib.osm.charm import CharmedOsmBase, RelationsMissing - -from opslib.osm.pod import ( - ContainerV3Builder, - PodSpecV3Builder, -) - -from opslib.osm.validator import ( - ModelValidator, - validator, -) - +from opslib.osm.interfaces.http import HttpClient from opslib.osm.interfaces.kafka import KafkaClient from opslib.osm.interfaces.mongo import MongoClient -from opslib.osm.interfaces.http import HttpClient +from opslib.osm.pod import ContainerV3Builder, PodSpecV3Builder +from opslib.osm.validator import ModelValidator, validator logger = logging.getLogger(__name__) @@ -54,7 +45,7 @@ class ConfigModel(ModelValidator): vca_host: str vca_port: int vca_user: str - vca_password: str + vca_secret: str vca_pubkey: str vca_cacert: str vca_cloud: str @@ -62,6 +53,60 @@ class ConfigModel(ModelValidator): database_commonkey: str log_level: str vca_apiproxy: Optional[str] + # Model-config options + vca_model_config_agent_metadata_url: Optional[str] + vca_model_config_agent_stream: Optional[str] + vca_model_config_apt_ftp_proxy: Optional[str] + vca_model_config_apt_http_proxy: Optional[str] + vca_model_config_apt_https_proxy: Optional[str] + vca_model_config_apt_mirror: Optional[str] + vca_model_config_apt_no_proxy: Optional[str] + vca_model_config_automatically_retry_hooks: Optional[bool] + vca_model_config_backup_dir: Optional[str] + vca_model_config_cloudinit_userdata: Optional[str] + vca_model_config_container_image_metadata_url: Optional[str] + vca_model_config_container_image_stream: Optional[str] + vca_model_config_container_inherit_properties: Optional[str] + vca_model_config_container_networking_method: Optional[str] + vca_model_config_default_series: Optional[str] + vca_model_config_default_space: Optional[str] + vca_model_config_development: Optional[bool] + vca_model_config_disable_network_management: Optional[bool] + vca_model_config_egress_subnets: Optional[str] + vca_model_config_enable_os_refresh_update: Optional[bool] + vca_model_config_enable_os_upgrade: Optional[bool] + vca_model_config_fan_config: Optional[str] + vca_model_config_firewall_mode: Optional[str] + vca_model_config_ftp_proxy: Optional[str] + vca_model_config_http_proxy: Optional[str] + vca_model_config_https_proxy: Optional[str] + vca_model_config_ignore_machine_addresses: Optional[bool] + vca_model_config_image_metadata_url: Optional[str] + vca_model_config_image_stream: Optional[str] + vca_model_config_juju_ftp_proxy: Optional[str] + vca_model_config_juju_http_proxy: Optional[str] + vca_model_config_juju_https_proxy: Optional[str] + vca_model_config_juju_no_proxy: Optional[str] + vca_model_config_logforward_enabled: Optional[bool] + vca_model_config_logging_config: Optional[str] + vca_model_config_lxd_snap_channel: Optional[str] + vca_model_config_max_action_results_age: Optional[str] + vca_model_config_max_action_results_size: Optional[str] + vca_model_config_max_status_history_age: Optional[str] + vca_model_config_max_status_history_size: Optional[str] + vca_model_config_net_bond_reconfigure_delay: Optional[str] + vca_model_config_no_proxy: Optional[str] + vca_model_config_provisioner_harvest_mode: Optional[str] + vca_model_config_proxy_ssh: Optional[bool] + vca_model_config_snap_http_proxy: Optional[str] + vca_model_config_snap_https_proxy: Optional[str] + vca_model_config_snap_store_assertions: Optional[str] + vca_model_config_snap_store_proxy: Optional[str] + vca_model_config_snap_store_proxy_url: Optional[str] + vca_model_config_ssl_hostname_verification: Optional[bool] + vca_model_config_test_mode: Optional[bool] + vca_model_config_transmit_vendor_metrics: Optional[bool] + vca_model_config_update_status_hook_interval: Optional[str] @validator("log_level") def validate_log_level(cls, v): @@ -136,7 +181,7 @@ class LcmCharm(CharmedOsmBase): "OSMLCM_VCA_PORT": config.vca_port, "OSMLCM_VCA_USER": config.vca_user, "OSMLCM_VCA_PUBKEY": config.vca_pubkey, - "OSMLCM_VCA_SECRET": config.vca_password, + "OSMLCM_VCA_SECRET": config.vca_secret, "OSMLCM_VCA_CACERT": config.vca_cacert, "OSMLCM_VCA_CLOUD": config.vca_cloud, "OSMLCM_VCA_K8S_CLOUD": config.vca_k8s_cloud, @@ -145,6 +190,13 @@ class LcmCharm(CharmedOsmBase): if config.vca_apiproxy: container_builder.add_env("OSMLCM_VCA_APIPROXY", config.vca_apiproxy) + model_config_envs = { + f"OSMLCM_{k.upper()}": v + for k, v in self.config.items() + if k.startswith("vca_model_config") + } + if model_config_envs: + container_builder.add_envs(model_config_envs) container = container_builder.build() # Add container to pod spec pod_spec_builder.add_container(container) diff --git a/installers/charm/lcm/tests/__init__.py b/installers/charm/lcm/tests/__init__.py index d0d973ae18111167581b5a2173a6998e9c2cb1cb..ee5553b017a09b3e46c233e04714afdb4a703b09 100644 --- a/installers/charm/lcm/tests/__init__.py +++ b/installers/charm/lcm/tests/__init__.py @@ -23,6 +23,7 @@ """Init mocking for unit tests.""" import sys + import mock sys.path.append("src") diff --git a/installers/charm/lcm/tests/test_charm.py b/installers/charm/lcm/tests/test_charm.py index bff3cee2c00446cba6533c41c7781171350f79fd..831e1762a0eda634827d35c9587924bee6da20b3 100644 --- a/installers/charm/lcm/tests/test_charm.py +++ b/installers/charm/lcm/tests/test_charm.py @@ -23,10 +23,11 @@ import sys from typing import NoReturn import unittest -from ops.model import ActiveStatus, BlockedStatus -from ops.testing import Harness from charm import LcmCharm +import mock +from ops.model import ActiveStatus, BlockedStatus +from ops.testing import Harness class TestCharm(unittest.TestCase): @@ -42,7 +43,7 @@ class TestCharm(unittest.TestCase): "vca_host": "192.168.0.13", "vca_port": 17070, "vca_user": "admin", - "vca_password": "admin", + "vca_secret": "admin", "vca_pubkey": "key", "vca_cacert": "cacert", "vca_cloud": "cloud", @@ -88,6 +89,110 @@ class TestCharm(unittest.TestCase): # Verifying status self.assertNotIsInstance(self.harness.charm.unit.status, BlockedStatus) + def test_build_pod_spec( + self, + ) -> NoReturn: + expected_config = { + "OSMLCM_GLOBAL_LOGLEVEL": self.config["log_level"], + "OSMLCM_DATABASE_COMMONKEY": self.config["database_commonkey"], + } + expected_config.update( + { + f"OSMLCM_{k.upper()}": v + for k, v in self.config.items() + if k.startswith("vca_") + } + ) + self.harness.charm._check_missing_dependencies = mock.Mock() + pod_spec = self.harness.charm.build_pod_spec( + {"imageDetails": {"imagePath": "lcm-image"}} + ) + actual_config = pod_spec["containers"][0]["envConfig"] + + self.assertDictContainsSubset( + expected_config, + actual_config, + ) + for config_key in actual_config: + self.assertNotIn("VCA_MODEL_CONFIG", config_key) + + def test_build_pod_spec_with_model_config( + self, + ) -> NoReturn: + self.harness.update_config( + { + "vca_model_config_agent_metadata_url": "string", + "vca_model_config_agent_stream": "string", + "vca_model_config_apt_ftp_proxy": "string", + "vca_model_config_apt_http_proxy": "string", + "vca_model_config_apt_https_proxy": "string", + "vca_model_config_apt_mirror": "string", + "vca_model_config_apt_no_proxy": "string", + "vca_model_config_automatically_retry_hooks": False, + "vca_model_config_backup_dir": "string", + "vca_model_config_cloudinit_userdata": "string", + "vca_model_config_container_image_metadata_url": "string", + "vca_model_config_container_image_stream": "string", + "vca_model_config_container_inherit_properties": "string", + "vca_model_config_container_networking_method": "string", + "vca_model_config_default_series": "string", + "vca_model_config_default_space": "string", + "vca_model_config_development": False, + "vca_model_config_disable_network_management": False, + "vca_model_config_egress_subnets": "string", + "vca_model_config_enable_os_refresh_update": False, + "vca_model_config_enable_os_upgrade": False, + "vca_model_config_fan_config": "string", + "vca_model_config_firewall_mode": "string", + "vca_model_config_ftp_proxy": "string", + "vca_model_config_http_proxy": "string", + "vca_model_config_https_proxy": "string", + "vca_model_config_ignore_machine_addresses": False, + "vca_model_config_image_metadata_url": "string", + "vca_model_config_image_stream": "string", + "vca_model_config_juju_ftp_proxy": "string", + "vca_model_config_juju_http_proxy": "string", + "vca_model_config_juju_https_proxy": "string", + "vca_model_config_juju_no_proxy": "string", + "vca_model_config_logforward_enabled": False, + "vca_model_config_logging_config": "string", + "vca_model_config_lxd_snap_channel": "string", + "vca_model_config_max_action_results_age": "string", + "vca_model_config_max_action_results_size": "string", + "vca_model_config_max_status_history_age": "string", + "vca_model_config_max_status_history_size": "string", + "vca_model_config_net_bond_reconfigure_delay": "string", + "vca_model_config_no_proxy": "string", + "vca_model_config_provisioner_harvest_mode": "string", + "vca_model_config_proxy_ssh": False, + "vca_model_config_snap_http_proxy": "string", + "vca_model_config_snap_https_proxy": "string", + "vca_model_config_snap_store_assertions": "string", + "vca_model_config_snap_store_proxy": "string", + "vca_model_config_snap_store_proxy_url": "string", + "vca_model_config_ssl_hostname_verification": False, + "vca_model_config_test_mode": False, + "vca_model_config_transmit_vendor_metrics": False, + "vca_model_config_update_status_hook_interval": "string", + } + ) + expected_config = { + f"OSMLCM_{k.upper()}": v + for k, v in self.config.items() + if k.startswith("vca_model_config_") + } + + self.harness.charm._check_missing_dependencies = mock.Mock() + pod_spec = self.harness.charm.build_pod_spec( + {"imageDetails": {"imagePath": "lcm-image"}} + ) + actual_config = pod_spec["containers"][0]["envConfig"] + + self.assertDictContainsSubset( + expected_config, + actual_config, + ) + def initialize_kafka_relation(self): kafka_relation_id = self.harness.add_relation("kafka", "kafka") self.harness.add_relation_unit(kafka_relation_id, "kafka/0") diff --git a/installers/charm/lcm/tox.ini b/installers/charm/lcm/tox.ini index 1f9442e3716ae0dbdc8ad1888162d1c9f5872f4b..30e0ea8c7f5f1d2c3125b366626f7427b4f4199e 100644 --- a/installers/charm/lcm/tox.ini +++ b/installers/charm/lcm/tox.ini @@ -21,21 +21,32 @@ ####################################################################################### [tox] -envlist = flake8, cover, pylint, safety, yamllint -skipsdist = True +envlist = black, cover, flake8, pylint, yamllint, safety +skipsdist = true + +[tox:jenkins] +toxworkdir = /tmp/.tox [testenv] basepython = python3.8 -setenv = - VIRTUAL_ENV={envdir} - PYTHONHASHSEED=0 - PYTHONPATH = {toxinidir}/src +setenv = VIRTUAL_ENV={envdir} + PYTHONDONTWRITEBYTECODE = 1 deps = -r{toxinidir}/requirements.txt + +####################################################################################### +[testenv:black] +deps = black +commands = + black --check --diff src/ tests/ + + ####################################################################################### [testenv:cover] deps = {[testenv]deps} -r{toxinidir}/requirements-test.txt + coverage + nose2 commands = sh -c 'rm -f nosetests.xml' coverage erase @@ -45,36 +56,34 @@ commands = coverage xml -o coverage.xml --omit=*tests* whitelist_externals = sh -####################################################################################### -[testenv:safety] -setenv = - LC_ALL=C.UTF-8 - LANG=C.UTF-8 -deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt -commands = - - safety check --full-report ####################################################################################### [testenv:flake8] -deps = flake8 +deps = flake8 + flake8-import-order commands = flake8 src/ tests/ + ####################################################################################### [testenv:pylint] deps = {[testenv]deps} -r{toxinidir}/requirements-test.txt pylint commands = - pylint -E src + pylint -E src/ tests/ + ####################################################################################### -[testenv:black] +[testenv:safety] +setenv = + LC_ALL=C.UTF-8 + LANG=C.UTF-8 deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt - black -commands = black --check --diff . --exclude "build/|.tox/|mod/|lib/" + safety +commands = + - safety check --full-report + ####################################################################################### [testenv:yamllint] @@ -86,9 +95,7 @@ commands = yamllint . ####################################################################################### [testenv:build] passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY -deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt - charmcraft +deps = charmcraft whitelist_externals = charmcraft cp @@ -112,4 +119,5 @@ exclude = max-line-length = 120 show-source = True builtins = _ - +max-complexity = 10 +import-order-style = google diff --git a/installers/charm/local_osm_bundle_proxy.yaml b/installers/charm/local_osm_bundle_proxy.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d3285224806ff89ee931b86b78115de030a6024e --- /dev/null +++ b/installers/charm/local_osm_bundle_proxy.yaml @@ -0,0 +1,200 @@ +# Copyright 2020 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. +description: Single instance OSM bundle +bundle: kubernetes +variables: + proxy: &proxy http://91.189.89.11:3128 + no-proxy: &no_proxy 127.0.0.1,localhost,::1,10.131.15.1/24,10.152.183.0/24,10.1.0.0/16 +applications: + zookeeper-k8s: + charm: "cs:~charmed-osm/zookeeper-k8s" + channel: "stable" + scale: 1 + series: kubernetes + storage: + database: 100M + annotations: + gui-x: 0 + gui-y: 550 + mariadb-k8s: + charm: "cs:~charmed-osm/mariadb-k8s" + channel: "stable" + scale: 1 + series: kubernetes + storage: + database: 50M + options: + password: manopw + root_password: osm4u + user: mano + annotations: + gui-x: -250 + gui-y: -200 + kafka-k8s: + charm: "cs:~charmed-osm/kafka-k8s" + channel: "stable" + scale: 1 + series: kubernetes + storage: + database: 100M + annotations: + gui-x: 0 + gui-y: 300 + mongodb-k8s: + charm: "cs:~charmed-osm/mongodb-k8s" + channel: "stable" + scale: 1 + series: kubernetes + storage: + database: 50M + options: + replica-set: rs0 + namespace: osm + enable-sidecar: true + annotations: + gui-x: 0 + gui-y: 50 + nbi: + charm: "./nbi/build" + scale: 1 + series: kubernetes + options: + database_commonkey: osm + auth_backend: keystone + annotations: + gui-x: 0 + gui-y: -200 + ro: + charm: "./ro/build" + scale: 1 + series: kubernetes + annotations: + gui-x: -250 + gui-y: 300 + ng-ui: + charm: "./ng-ui/build" + scale: 1 + series: kubernetes + annotations: + gui-x: 500 + gui-y: 100 + lcm: + charm: "./lcm/build" + scale: 1 + series: kubernetes + options: + database_commonkey: osm + vca_model_config_no_proxy: *no_proxy + vca_model_config_juju_no_proxy: *no_proxy + vca_model_config_apt_no_proxy: *no_proxy + vca_model_config_juju_http_proxy: *proxy + vca_model_config_juju_https_proxy: *proxy + vca_model_config_apt_http_proxy: *proxy + vca_model_config_apt_https_proxy: *proxy + vca_model_config_snap_http_proxy: *proxy + vca_model_config_snap_https_proxy: *proxy + annotations: + gui-x: -250 + gui-y: 50 + mon: + charm: "./mon/build" + scale: 1 + series: kubernetes + options: + database_commonkey: osm + annotations: + gui-x: 250 + gui-y: 50 + pol: + charm: "./pol/build" + scale: 1 + series: kubernetes + annotations: + gui-x: -250 + gui-y: 550 + pla: + charm: "./pla/build" + scale: 1 + series: kubernetes + annotations: + gui-x: 500 + gui-y: -200 + prometheus: + charm: "./prometheus/build" + channel: "stable" + scale: 1 + series: kubernetes + storage: + data: 50M + options: + default-target: "mon:8000" + annotations: + gui-x: 250 + gui-y: 300 + grafana: + charm: "./grafana/build" + channel: "stable" + scale: 1 + series: kubernetes + annotations: + gui-x: 250 + gui-y: 550 + keystone: + charm: "./keystone/build" + scale: 1 + series: kubernetes + annotations: + gui-x: -250 + gui-y: 550 +relations: + - - grafana:prometheus + - prometheus:prometheus + - - kafka-k8s:zookeeper + - zookeeper-k8s:zookeeper + - - keystone:db + - mariadb-k8s:mysql + - - lcm:kafka + - kafka-k8s:kafka + - - lcm:mongodb + - mongodb-k8s:mongo + - - ro:ro + - lcm:ro + - - ro:kafka + - kafka-k8s:kafka + - - ro:mongodb + - mongodb-k8s:mongo + - - pol:kafka + - kafka-k8s:kafka + - - pol:mongodb + - mongodb-k8s:mongo + - - mon:mongodb + - mongodb-k8s:mongo + - - mon:kafka + - kafka-k8s:kafka + - - pla:kafka + - kafka-k8s:kafka + - - pla:mongodb + - mongodb-k8s:mongo + - - nbi:mongodb + - mongodb-k8s:mongo + - - nbi:kafka + - kafka-k8s:kafka + - - nbi:prometheus + - prometheus:prometheus + - - nbi:keystone + - keystone:keystone + - - mon:prometheus + - prometheus:prometheus + - - ng-ui:nbi + - nbi:nbi diff --git a/installers/charm/mon/.jujuignore b/installers/charm/mon/.jujuignore index bf04eb4787e6df5fd324a95b451e20c45ee9c0e5..3ae3e7dcbaabc72ec7f40ebc13192774df7f4a52 100644 --- a/installers/charm/mon/.jujuignore +++ b/installers/charm/mon/.jujuignore @@ -22,7 +22,13 @@ venv .vscode build -prometheus.charm +*.charm .coverage +coverage.xml +.gitignore .stestr cover +release +tests/ +requirements* +tox.ini diff --git a/installers/charm/mon/config.yaml b/installers/charm/mon/config.yaml index 2fffbc5f9329fc3a6ea0ecd96cc0ac6a03739d6b..539149748b3e9b0151f354ae5750960eeba293ba 100644 --- a/installers/charm/mon/config.yaml +++ b/installers/charm/mon/config.yaml @@ -52,7 +52,7 @@ options: type: string description: "The VCA user name." default: "admin" - vca_password: + vca_secret: type: string description: "The VCA user password." default: "secret" diff --git a/installers/charm/mon/requirements-test.txt b/installers/charm/mon/requirements-test.txt index d7585f3e724a8c6258c4e9d960853d84e40ffe55..cf61dd4e12aa3e3834919feba9149f980468c28b 100644 --- a/installers/charm/mon/requirements-test.txt +++ b/installers/charm/mon/requirements-test.txt @@ -17,15 +17,4 @@ # # To get in touch with the maintainers, please contact: # osm-charmers@lists.launchpad.net -## --r requirements.txt -coverage -stestr -mock -black -yamllint -flake8 -safety -requests-mock -asynctest -nose2 \ No newline at end of file +mock==4.0.3 diff --git a/installers/charm/mon/src/charm.py b/installers/charm/mon/src/charm.py index 26dee3ff1824da5f2609afeb57dd13694021b0f4..d0145d4f57c80abd2db552286b5610e4945a27e2 100755 --- a/installers/charm/mon/src/charm.py +++ b/installers/charm/mon/src/charm.py @@ -26,24 +26,15 @@ import logging from typing import NoReturn -from ops.main import main +from ops.main import main from opslib.osm.charm import CharmedOsmBase, RelationsMissing - -from opslib.osm.pod import ( - ContainerV3Builder, - PodSpecV3Builder, -) - -from opslib.osm.validator import ( - ModelValidator, - validator, -) - from opslib.osm.interfaces.kafka import KafkaClient +from opslib.osm.interfaces.keystone import KeystoneClient from opslib.osm.interfaces.mongo import MongoClient from opslib.osm.interfaces.prometheus import PrometheusClient -from opslib.osm.interfaces.keystone import KeystoneClient +from opslib.osm.pod import ContainerV3Builder, PodSpecV3Builder +from opslib.osm.validator import ModelValidator, validator logger = logging.getLogger(__name__) @@ -55,7 +46,7 @@ class ConfigModel(ModelValidator): keystone_enabled: bool vca_host: str vca_user: str - vca_password: str + vca_secret: str vca_cacert: str database_commonkey: str log_level: str @@ -146,7 +137,7 @@ class MonCharm(CharmedOsmBase): # VCA configuration "OSMMON_VCA_HOST": config.vca_host, "OSMMON_VCA_USER": config.vca_user, - "OSMMON_VCA_SECRET": config.vca_password, + "OSMMON_VCA_SECRET": config.vca_secret, "OSMMON_VCA_CACERT": config.vca_cacert, "OSMMON_GRAFANA_URL": config.grafana_url, "OSMMON_GRAFANA_USER": config.grafana_user, diff --git a/installers/charm/mon/tests/__init__.py b/installers/charm/mon/tests/__init__.py index d0d973ae18111167581b5a2173a6998e9c2cb1cb..ee5553b017a09b3e46c233e04714afdb4a703b09 100644 --- a/installers/charm/mon/tests/__init__.py +++ b/installers/charm/mon/tests/__init__.py @@ -23,6 +23,7 @@ """Init mocking for unit tests.""" import sys + import mock sys.path.append("src") diff --git a/installers/charm/mon/tests/test_charm.py b/installers/charm/mon/tests/test_charm.py index 5d6f1a06c16d3646e2efbd091ede134e3733c916..858ff7cb90832cb396c5d736a2f496fadf8cfef1 100644 --- a/installers/charm/mon/tests/test_charm.py +++ b/installers/charm/mon/tests/test_charm.py @@ -23,10 +23,10 @@ import sys from typing import NoReturn import unittest -from ops.model import ActiveStatus, BlockedStatus -from ops.testing import Harness from charm import MonCharm +from ops.model import ActiveStatus, BlockedStatus +from ops.testing import Harness class TestCharm(unittest.TestCase): @@ -41,7 +41,7 @@ class TestCharm(unittest.TestCase): self.config = { "vca_host": "192.168.0.13", "vca_user": "admin", - "vca_password": "admin", + "vca_secret": "admin", "vca_cacert": "cacert", "database_commonkey": "commonkey", "log_level": "INFO", diff --git a/installers/charm/mon/tests/test_pod_spec.py b/installers/charm/mon/tests/test_pod_spec.py index 6f61916ff527b209cc1bd4fd4032b6be7f575969..86a3d1699dd756f6390fbcf5959bbae753303021 100644 --- a/installers/charm/mon/tests/test_pod_spec.py +++ b/installers/charm/mon/tests/test_pod_spec.py @@ -199,8 +199,9 @@ class TestPodSpec(unittest.TestCase): "OSMMON_DATABASE_DRIVER": "mongo", "OSMMON_DATABASE_URI": relation_state["database_uri"], "OSMMON_DATABASE_COMMONKEY": config["database_commonkey"], - "OSMMON_PROMETHEUS_URL": - f"http://{relation_state['prometheus_host']}:{relation_state['prometheus_port']}", + "OSMMON_PROMETHEUS_URL": ( + f"http://{relation_state['prometheus_host']}:{relation_state['prometheus_port']}" + ), "OSMMON_VCA_HOST": config["vca_host"], "OSMMON_VCA_USER": config["vca_user"], "OSMMON_VCA_SECRET": config["vca_password"], diff --git a/installers/charm/mon/tox.ini b/installers/charm/mon/tox.ini index 1f9442e3716ae0dbdc8ad1888162d1c9f5872f4b..30e0ea8c7f5f1d2c3125b366626f7427b4f4199e 100644 --- a/installers/charm/mon/tox.ini +++ b/installers/charm/mon/tox.ini @@ -21,21 +21,32 @@ ####################################################################################### [tox] -envlist = flake8, cover, pylint, safety, yamllint -skipsdist = True +envlist = black, cover, flake8, pylint, yamllint, safety +skipsdist = true + +[tox:jenkins] +toxworkdir = /tmp/.tox [testenv] basepython = python3.8 -setenv = - VIRTUAL_ENV={envdir} - PYTHONHASHSEED=0 - PYTHONPATH = {toxinidir}/src +setenv = VIRTUAL_ENV={envdir} + PYTHONDONTWRITEBYTECODE = 1 deps = -r{toxinidir}/requirements.txt + +####################################################################################### +[testenv:black] +deps = black +commands = + black --check --diff src/ tests/ + + ####################################################################################### [testenv:cover] deps = {[testenv]deps} -r{toxinidir}/requirements-test.txt + coverage + nose2 commands = sh -c 'rm -f nosetests.xml' coverage erase @@ -45,36 +56,34 @@ commands = coverage xml -o coverage.xml --omit=*tests* whitelist_externals = sh -####################################################################################### -[testenv:safety] -setenv = - LC_ALL=C.UTF-8 - LANG=C.UTF-8 -deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt -commands = - - safety check --full-report ####################################################################################### [testenv:flake8] -deps = flake8 +deps = flake8 + flake8-import-order commands = flake8 src/ tests/ + ####################################################################################### [testenv:pylint] deps = {[testenv]deps} -r{toxinidir}/requirements-test.txt pylint commands = - pylint -E src + pylint -E src/ tests/ + ####################################################################################### -[testenv:black] +[testenv:safety] +setenv = + LC_ALL=C.UTF-8 + LANG=C.UTF-8 deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt - black -commands = black --check --diff . --exclude "build/|.tox/|mod/|lib/" + safety +commands = + - safety check --full-report + ####################################################################################### [testenv:yamllint] @@ -86,9 +95,7 @@ commands = yamllint . ####################################################################################### [testenv:build] passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY -deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt - charmcraft +deps = charmcraft whitelist_externals = charmcraft cp @@ -112,4 +119,5 @@ exclude = max-line-length = 120 show-source = True builtins = _ - +max-complexity = 10 +import-order-style = google diff --git a/installers/charm/nbi/.gitignore b/installers/charm/nbi/.gitignore index 21a2062e8bf9e783d82f5939ab4e6d6b271084a9..2885df273aad15007d0d44a57c83983822887b9c 100644 --- a/installers/charm/nbi/.gitignore +++ b/installers/charm/nbi/.gitignore @@ -22,14 +22,9 @@ venv .vscode build -<<<<<<< HEAD -nbi.charm -.coverage* -======= *.charm .coverage coverage.xml ->>>>>>> WIP: Improve osm charms .stestr cover release \ No newline at end of file diff --git a/installers/charm/nbi/.jujuignore b/installers/charm/nbi/.jujuignore index bf04eb4787e6df5fd324a95b451e20c45ee9c0e5..3ae3e7dcbaabc72ec7f40ebc13192774df7f4a52 100644 --- a/installers/charm/nbi/.jujuignore +++ b/installers/charm/nbi/.jujuignore @@ -22,7 +22,13 @@ venv .vscode build -prometheus.charm +*.charm .coverage +coverage.xml +.gitignore .stestr cover +release +tests/ +requirements* +tox.ini diff --git a/installers/charm/nbi/requirements-test.txt b/installers/charm/nbi/requirements-test.txt index d7585f3e724a8c6258c4e9d960853d84e40ffe55..cf61dd4e12aa3e3834919feba9149f980468c28b 100644 --- a/installers/charm/nbi/requirements-test.txt +++ b/installers/charm/nbi/requirements-test.txt @@ -17,15 +17,4 @@ # # To get in touch with the maintainers, please contact: # osm-charmers@lists.launchpad.net -## --r requirements.txt -coverage -stestr -mock -black -yamllint -flake8 -safety -requests-mock -asynctest -nose2 \ No newline at end of file +mock==4.0.3 diff --git a/installers/charm/nbi/src/charm.py b/installers/charm/nbi/src/charm.py index 9d62fe2fcbc4082430bb1d37658b5c72f92eaece..7efc5b0de549358414c9beaea524dd6251639b18 100755 --- a/installers/charm/nbi/src/charm.py +++ b/installers/charm/nbi/src/charm.py @@ -23,32 +23,25 @@ # pylint: disable=E0213 -import logging -from typing import Optional, NoReturn from ipaddress import ip_network +import logging +from typing import NoReturn, Optional from urllib.parse import urlparse -from ops.main import main +from ops.main import main from opslib.osm.charm import CharmedOsmBase, RelationsMissing - +from opslib.osm.interfaces.http import HttpServer +from opslib.osm.interfaces.kafka import KafkaClient +from opslib.osm.interfaces.keystone import KeystoneClient +from opslib.osm.interfaces.mongo import MongoClient +from opslib.osm.interfaces.prometheus import PrometheusClient from opslib.osm.pod import ( ContainerV3Builder, - PodSpecV3Builder, IngressResourceV3Builder, + PodSpecV3Builder, ) - - -from opslib.osm.validator import ( - ModelValidator, - validator, -) - -from opslib.osm.interfaces.kafka import KafkaClient -from opslib.osm.interfaces.mongo import MongoClient -from opslib.osm.interfaces.prometheus import PrometheusClient -from opslib.osm.interfaces.keystone import KeystoneClient -from opslib.osm.interfaces.http import HttpServer +from opslib.osm.validator import ModelValidator, validator logger = logging.getLogger(__name__) diff --git a/installers/charm/nbi/tests/__init__.py b/installers/charm/nbi/tests/__init__.py index d0d973ae18111167581b5a2173a6998e9c2cb1cb..ee5553b017a09b3e46c233e04714afdb4a703b09 100644 --- a/installers/charm/nbi/tests/__init__.py +++ b/installers/charm/nbi/tests/__init__.py @@ -23,6 +23,7 @@ """Init mocking for unit tests.""" import sys + import mock sys.path.append("src") diff --git a/installers/charm/nbi/tests/test_charm.py b/installers/charm/nbi/tests/test_charm.py index be24aa6d80205ea209afe3de818934e39d4f7bcc..c4e857feba13e981f7057e4b50513d52226dce41 100644 --- a/installers/charm/nbi/tests/test_charm.py +++ b/installers/charm/nbi/tests/test_charm.py @@ -23,10 +23,11 @@ import sys from typing import NoReturn import unittest -from ops.model import ActiveStatus, BlockedStatus -from ops.testing import Harness + from charm import NbiCharm +from ops.model import ActiveStatus, BlockedStatus +from ops.testing import Harness class TestCharm(unittest.TestCase): diff --git a/installers/charm/nbi/tox.ini b/installers/charm/nbi/tox.ini index 1f9442e3716ae0dbdc8ad1888162d1c9f5872f4b..30e0ea8c7f5f1d2c3125b366626f7427b4f4199e 100644 --- a/installers/charm/nbi/tox.ini +++ b/installers/charm/nbi/tox.ini @@ -21,21 +21,32 @@ ####################################################################################### [tox] -envlist = flake8, cover, pylint, safety, yamllint -skipsdist = True +envlist = black, cover, flake8, pylint, yamllint, safety +skipsdist = true + +[tox:jenkins] +toxworkdir = /tmp/.tox [testenv] basepython = python3.8 -setenv = - VIRTUAL_ENV={envdir} - PYTHONHASHSEED=0 - PYTHONPATH = {toxinidir}/src +setenv = VIRTUAL_ENV={envdir} + PYTHONDONTWRITEBYTECODE = 1 deps = -r{toxinidir}/requirements.txt + +####################################################################################### +[testenv:black] +deps = black +commands = + black --check --diff src/ tests/ + + ####################################################################################### [testenv:cover] deps = {[testenv]deps} -r{toxinidir}/requirements-test.txt + coverage + nose2 commands = sh -c 'rm -f nosetests.xml' coverage erase @@ -45,36 +56,34 @@ commands = coverage xml -o coverage.xml --omit=*tests* whitelist_externals = sh -####################################################################################### -[testenv:safety] -setenv = - LC_ALL=C.UTF-8 - LANG=C.UTF-8 -deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt -commands = - - safety check --full-report ####################################################################################### [testenv:flake8] -deps = flake8 +deps = flake8 + flake8-import-order commands = flake8 src/ tests/ + ####################################################################################### [testenv:pylint] deps = {[testenv]deps} -r{toxinidir}/requirements-test.txt pylint commands = - pylint -E src + pylint -E src/ tests/ + ####################################################################################### -[testenv:black] +[testenv:safety] +setenv = + LC_ALL=C.UTF-8 + LANG=C.UTF-8 deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt - black -commands = black --check --diff . --exclude "build/|.tox/|mod/|lib/" + safety +commands = + - safety check --full-report + ####################################################################################### [testenv:yamllint] @@ -86,9 +95,7 @@ commands = yamllint . ####################################################################################### [testenv:build] passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY -deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt - charmcraft +deps = charmcraft whitelist_externals = charmcraft cp @@ -112,4 +119,5 @@ exclude = max-line-length = 120 show-source = True builtins = _ - +max-complexity = 10 +import-order-style = google diff --git a/installers/charm/ng-ui/.gitignore b/installers/charm/ng-ui/.gitignore index ecfb4dc1be54fcc3f75789dff14c1972e82c782a..493739efb54d83d7a04116db3404a2b6042f4516 100644 --- a/installers/charm/ng-ui/.gitignore +++ b/installers/charm/ng-ui/.gitignore @@ -22,16 +22,9 @@ venv .vscode build -<<<<<<< HEAD -ng-ui.charm -.stestr -.coverage* -cover/ -======= *.charm .coverage coverage.xml .stestr cover release ->>>>>>> WIP: Improve osm charms diff --git a/installers/charm/ng-ui/.jujuignore b/installers/charm/ng-ui/.jujuignore index bf04eb4787e6df5fd324a95b451e20c45ee9c0e5..3ae3e7dcbaabc72ec7f40ebc13192774df7f4a52 100644 --- a/installers/charm/ng-ui/.jujuignore +++ b/installers/charm/ng-ui/.jujuignore @@ -22,7 +22,13 @@ venv .vscode build -prometheus.charm +*.charm .coverage +coverage.xml +.gitignore .stestr cover +release +tests/ +requirements* +tox.ini diff --git a/installers/charm/ng-ui/requirements-test.txt b/installers/charm/ng-ui/requirements-test.txt index d7585f3e724a8c6258c4e9d960853d84e40ffe55..cf61dd4e12aa3e3834919feba9149f980468c28b 100644 --- a/installers/charm/ng-ui/requirements-test.txt +++ b/installers/charm/ng-ui/requirements-test.txt @@ -17,15 +17,4 @@ # # To get in touch with the maintainers, please contact: # osm-charmers@lists.launchpad.net -## --r requirements.txt -coverage -stestr -mock -black -yamllint -flake8 -safety -requests-mock -asynctest -nose2 \ No newline at end of file +mock==4.0.3 diff --git a/installers/charm/ng-ui/src/charm.py b/installers/charm/ng-ui/src/charm.py index 4d2bb85d6b6043319cdaea26a359989fcd5db14e..bf301f32c74507856fb55ea83ffe83c0af4be457 100755 --- a/installers/charm/ng-ui/src/charm.py +++ b/installers/charm/ng-ui/src/charm.py @@ -23,32 +23,25 @@ # pylint: disable=E0213 -import logging -from typing import Optional, NoReturn from ipaddress import ip_network +import logging +from pathlib import Path +from string import Template +from typing import NoReturn, Optional from urllib.parse import urlparse from ops.main import main - from opslib.osm.charm import CharmedOsmBase, RelationsMissing - +from opslib.osm.interfaces.http import HttpClient from opslib.osm.pod import ( ContainerV3Builder, - PodSpecV3Builder, FilesV3Builder, IngressResourceV3Builder, + PodSpecV3Builder, ) +from opslib.osm.validator import ModelValidator, validator -from opslib.osm.validator import ( - ModelValidator, - validator, -) - -from opslib.osm.interfaces.http import HttpClient -from string import Template -from pathlib import Path - logger = logging.getLogger(__name__) diff --git a/installers/charm/ng-ui/tests/__init__.py b/installers/charm/ng-ui/tests/__init__.py index d0d973ae18111167581b5a2173a6998e9c2cb1cb..ca37e3b9e83699ffa5ac06f6c7003747272618b4 100644 --- a/installers/charm/ng-ui/tests/__init__.py +++ b/installers/charm/ng-ui/tests/__init__.py @@ -23,6 +23,8 @@ """Init mocking for unit tests.""" import sys + + import mock sys.path.append("src") diff --git a/installers/charm/ng-ui/tests/test_charm.py b/installers/charm/ng-ui/tests/test_charm.py index d9a4d3e6e65ee5d10a3366ba5ba692e9bcf37aeb..5b5327bc8ff04c4d9d677df19a50e658988b9513 100644 --- a/installers/charm/ng-ui/tests/test_charm.py +++ b/installers/charm/ng-ui/tests/test_charm.py @@ -23,10 +23,10 @@ import sys from typing import NoReturn import unittest -from ops.model import ActiveStatus, BlockedStatus -from ops.testing import Harness from charm import NgUiCharm +from ops.model import ActiveStatus, BlockedStatus +from ops.testing import Harness class TestCharm(unittest.TestCase): diff --git a/installers/charm/ng-ui/tox.ini b/installers/charm/ng-ui/tox.ini index 1f9442e3716ae0dbdc8ad1888162d1c9f5872f4b..dc4074f2efa5a0f6b5b8c15c5cd9211289be08c5 100644 --- a/installers/charm/ng-ui/tox.ini +++ b/installers/charm/ng-ui/tox.ini @@ -21,21 +21,32 @@ ####################################################################################### [tox] -envlist = flake8, cover, pylint, safety, yamllint -skipsdist = True +envlist = black, cover, flake8, pylint, yamllint, safety +skipsdist = true + +[tox:jenkins] +toxworkdir = /tmp/.tox [testenv] basepython = python3.8 -setenv = - VIRTUAL_ENV={envdir} - PYTHONHASHSEED=0 - PYTHONPATH = {toxinidir}/src +setenv = VIRTUAL_ENV={envdir} + PYTHONDONTWRITEBYTECODE = 1 deps = -r{toxinidir}/requirements.txt + +####################################################################################### +[testenv:black] +deps = black +commands = + black --check --diff src/ tests/ + + ####################################################################################### [testenv:cover] deps = {[testenv]deps} -r{toxinidir}/requirements-test.txt + coverage + nose2 commands = sh -c 'rm -f nosetests.xml' coverage erase @@ -45,21 +56,14 @@ commands = coverage xml -o coverage.xml --omit=*tests* whitelist_externals = sh -####################################################################################### -[testenv:safety] -setenv = - LC_ALL=C.UTF-8 - LANG=C.UTF-8 -deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt -commands = - - safety check --full-report ####################################################################################### [testenv:flake8] -deps = flake8 +deps = flake8 + flake8-import-order commands = - flake8 src/ tests/ + flake8 src/ tests/ --exclude=*pod_spec* + ####################################################################################### [testenv:pylint] @@ -67,14 +71,19 @@ deps = {[testenv]deps} -r{toxinidir}/requirements-test.txt pylint commands = - pylint -E src + pylint -E src/ tests/ + ####################################################################################### -[testenv:black] +[testenv:safety] +setenv = + LC_ALL=C.UTF-8 + LANG=C.UTF-8 deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt - black -commands = black --check --diff . --exclude "build/|.tox/|mod/|lib/" + safety +commands = + - safety check --full-report + ####################################################################################### [testenv:yamllint] @@ -86,9 +95,7 @@ commands = yamllint . ####################################################################################### [testenv:build] passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY -deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt - charmcraft +deps = charmcraft whitelist_externals = charmcraft cp @@ -112,4 +119,5 @@ exclude = max-line-length = 120 show-source = True builtins = _ - +max-complexity = 10 +import-order-style = google diff --git a/installers/charm/pla/.jujuignore b/installers/charm/pla/.jujuignore index bf04eb4787e6df5fd324a95b451e20c45ee9c0e5..3ae3e7dcbaabc72ec7f40ebc13192774df7f4a52 100644 --- a/installers/charm/pla/.jujuignore +++ b/installers/charm/pla/.jujuignore @@ -22,7 +22,13 @@ venv .vscode build -prometheus.charm +*.charm .coverage +coverage.xml +.gitignore .stestr cover +release +tests/ +requirements* +tox.ini diff --git a/installers/charm/pla/requirements-test.txt b/installers/charm/pla/requirements-test.txt index d7585f3e724a8c6258c4e9d960853d84e40ffe55..cf61dd4e12aa3e3834919feba9149f980468c28b 100644 --- a/installers/charm/pla/requirements-test.txt +++ b/installers/charm/pla/requirements-test.txt @@ -17,15 +17,4 @@ # # To get in touch with the maintainers, please contact: # osm-charmers@lists.launchpad.net -## --r requirements.txt -coverage -stestr -mock -black -yamllint -flake8 -safety -requests-mock -asynctest -nose2 \ No newline at end of file +mock==4.0.3 diff --git a/installers/charm/pla/src/charm.py b/installers/charm/pla/src/charm.py index 4f463bf65cecca2dc5af449063a76a1f1231f2e0..15ae0958fa70b863049dfd5c0ccf66d8023ce3a3 100755 --- a/installers/charm/pla/src/charm.py +++ b/installers/charm/pla/src/charm.py @@ -27,21 +27,14 @@ import logging from typing import NoReturn from ops.main import main - from opslib.osm.charm import CharmedOsmBase, RelationsMissing - +from opslib.osm.interfaces.kafka import KafkaClient +from opslib.osm.interfaces.mongo import MongoClient from opslib.osm.pod import ( ContainerV3Builder, PodSpecV3Builder, ) - -from opslib.osm.validator import ( - ModelValidator, - validator, -) - -from opslib.osm.interfaces.kafka import KafkaClient -from opslib.osm.interfaces.mongo import MongoClient +from opslib.osm.validator import ModelValidator, validator logger = logging.getLogger(__name__) diff --git a/installers/charm/pla/tests/__init__.py b/installers/charm/pla/tests/__init__.py index d0d973ae18111167581b5a2173a6998e9c2cb1cb..ca37e3b9e83699ffa5ac06f6c7003747272618b4 100644 --- a/installers/charm/pla/tests/__init__.py +++ b/installers/charm/pla/tests/__init__.py @@ -23,6 +23,8 @@ """Init mocking for unit tests.""" import sys + + import mock sys.path.append("src") diff --git a/installers/charm/pla/tests/test_charm.py b/installers/charm/pla/tests/test_charm.py index b1a782032d57d2d6c95faf8e46c9580cdea92061..80cb3158bf84dcd4b8b0c6e97b086b733a202fa1 100644 --- a/installers/charm/pla/tests/test_charm.py +++ b/installers/charm/pla/tests/test_charm.py @@ -23,10 +23,11 @@ import sys from typing import NoReturn import unittest -from ops.model import ActiveStatus, BlockedStatus -from ops.testing import Harness + from charm import PlaCharm +from ops.model import ActiveStatus, BlockedStatus +from ops.testing import Harness class TestCharm(unittest.TestCase): diff --git a/installers/charm/pla/tox.ini b/installers/charm/pla/tox.ini index 1f9442e3716ae0dbdc8ad1888162d1c9f5872f4b..30e0ea8c7f5f1d2c3125b366626f7427b4f4199e 100644 --- a/installers/charm/pla/tox.ini +++ b/installers/charm/pla/tox.ini @@ -21,21 +21,32 @@ ####################################################################################### [tox] -envlist = flake8, cover, pylint, safety, yamllint -skipsdist = True +envlist = black, cover, flake8, pylint, yamllint, safety +skipsdist = true + +[tox:jenkins] +toxworkdir = /tmp/.tox [testenv] basepython = python3.8 -setenv = - VIRTUAL_ENV={envdir} - PYTHONHASHSEED=0 - PYTHONPATH = {toxinidir}/src +setenv = VIRTUAL_ENV={envdir} + PYTHONDONTWRITEBYTECODE = 1 deps = -r{toxinidir}/requirements.txt + +####################################################################################### +[testenv:black] +deps = black +commands = + black --check --diff src/ tests/ + + ####################################################################################### [testenv:cover] deps = {[testenv]deps} -r{toxinidir}/requirements-test.txt + coverage + nose2 commands = sh -c 'rm -f nosetests.xml' coverage erase @@ -45,36 +56,34 @@ commands = coverage xml -o coverage.xml --omit=*tests* whitelist_externals = sh -####################################################################################### -[testenv:safety] -setenv = - LC_ALL=C.UTF-8 - LANG=C.UTF-8 -deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt -commands = - - safety check --full-report ####################################################################################### [testenv:flake8] -deps = flake8 +deps = flake8 + flake8-import-order commands = flake8 src/ tests/ + ####################################################################################### [testenv:pylint] deps = {[testenv]deps} -r{toxinidir}/requirements-test.txt pylint commands = - pylint -E src + pylint -E src/ tests/ + ####################################################################################### -[testenv:black] +[testenv:safety] +setenv = + LC_ALL=C.UTF-8 + LANG=C.UTF-8 deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt - black -commands = black --check --diff . --exclude "build/|.tox/|mod/|lib/" + safety +commands = + - safety check --full-report + ####################################################################################### [testenv:yamllint] @@ -86,9 +95,7 @@ commands = yamllint . ####################################################################################### [testenv:build] passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY -deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt - charmcraft +deps = charmcraft whitelist_externals = charmcraft cp @@ -112,4 +119,5 @@ exclude = max-line-length = 120 show-source = True builtins = _ - +max-complexity = 10 +import-order-style = google diff --git a/installers/charm/pol/.jujuignore b/installers/charm/pol/.jujuignore index bf04eb4787e6df5fd324a95b451e20c45ee9c0e5..3ae3e7dcbaabc72ec7f40ebc13192774df7f4a52 100644 --- a/installers/charm/pol/.jujuignore +++ b/installers/charm/pol/.jujuignore @@ -22,7 +22,13 @@ venv .vscode build -prometheus.charm +*.charm .coverage +coverage.xml +.gitignore .stestr cover +release +tests/ +requirements* +tox.ini diff --git a/installers/charm/pol/requirements-test.txt b/installers/charm/pol/requirements-test.txt index d7585f3e724a8c6258c4e9d960853d84e40ffe55..cf61dd4e12aa3e3834919feba9149f980468c28b 100644 --- a/installers/charm/pol/requirements-test.txt +++ b/installers/charm/pol/requirements-test.txt @@ -17,15 +17,4 @@ # # To get in touch with the maintainers, please contact: # osm-charmers@lists.launchpad.net -## --r requirements.txt -coverage -stestr -mock -black -yamllint -flake8 -safety -requests-mock -asynctest -nose2 \ No newline at end of file +mock==4.0.3 diff --git a/installers/charm/pol/src/charm.py b/installers/charm/pol/src/charm.py index ce1a25e54995dd43c13c981e2814fbe38713e027..d339e1ce0f679f55e40e7a85f53a8e8ffeb3ba70 100755 --- a/installers/charm/pol/src/charm.py +++ b/installers/charm/pol/src/charm.py @@ -27,21 +27,14 @@ import logging from typing import NoReturn from ops.main import main - from opslib.osm.charm import CharmedOsmBase, RelationsMissing - +from opslib.osm.interfaces.kafka import KafkaClient +from opslib.osm.interfaces.mongo import MongoClient from opslib.osm.pod import ( ContainerV3Builder, PodSpecV3Builder, ) - -from opslib.osm.validator import ( - ModelValidator, - validator, -) - -from opslib.osm.interfaces.kafka import KafkaClient -from opslib.osm.interfaces.mongo import MongoClient +from opslib.osm.validator import ModelValidator, validator logger = logging.getLogger(__name__) diff --git a/installers/charm/pol/tests/__init__.py b/installers/charm/pol/tests/__init__.py index d0d973ae18111167581b5a2173a6998e9c2cb1cb..ca37e3b9e83699ffa5ac06f6c7003747272618b4 100644 --- a/installers/charm/pol/tests/__init__.py +++ b/installers/charm/pol/tests/__init__.py @@ -23,6 +23,8 @@ """Init mocking for unit tests.""" import sys + + import mock sys.path.append("src") diff --git a/installers/charm/pol/tests/test_charm.py b/installers/charm/pol/tests/test_charm.py index 22143978110658edd988bd53b3e3cc64fefd3fe2..32b1acd651eb8dc14b8ed52495681062f4b11d49 100644 --- a/installers/charm/pol/tests/test_charm.py +++ b/installers/charm/pol/tests/test_charm.py @@ -23,10 +23,10 @@ import sys from typing import NoReturn import unittest -from ops.model import ActiveStatus, BlockedStatus -from ops.testing import Harness from charm import PolCharm +from ops.model import ActiveStatus, BlockedStatus +from ops.testing import Harness class TestCharm(unittest.TestCase): diff --git a/installers/charm/pol/tox.ini b/installers/charm/pol/tox.ini index 1f9442e3716ae0dbdc8ad1888162d1c9f5872f4b..30e0ea8c7f5f1d2c3125b366626f7427b4f4199e 100644 --- a/installers/charm/pol/tox.ini +++ b/installers/charm/pol/tox.ini @@ -21,21 +21,32 @@ ####################################################################################### [tox] -envlist = flake8, cover, pylint, safety, yamllint -skipsdist = True +envlist = black, cover, flake8, pylint, yamllint, safety +skipsdist = true + +[tox:jenkins] +toxworkdir = /tmp/.tox [testenv] basepython = python3.8 -setenv = - VIRTUAL_ENV={envdir} - PYTHONHASHSEED=0 - PYTHONPATH = {toxinidir}/src +setenv = VIRTUAL_ENV={envdir} + PYTHONDONTWRITEBYTECODE = 1 deps = -r{toxinidir}/requirements.txt + +####################################################################################### +[testenv:black] +deps = black +commands = + black --check --diff src/ tests/ + + ####################################################################################### [testenv:cover] deps = {[testenv]deps} -r{toxinidir}/requirements-test.txt + coverage + nose2 commands = sh -c 'rm -f nosetests.xml' coverage erase @@ -45,36 +56,34 @@ commands = coverage xml -o coverage.xml --omit=*tests* whitelist_externals = sh -####################################################################################### -[testenv:safety] -setenv = - LC_ALL=C.UTF-8 - LANG=C.UTF-8 -deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt -commands = - - safety check --full-report ####################################################################################### [testenv:flake8] -deps = flake8 +deps = flake8 + flake8-import-order commands = flake8 src/ tests/ + ####################################################################################### [testenv:pylint] deps = {[testenv]deps} -r{toxinidir}/requirements-test.txt pylint commands = - pylint -E src + pylint -E src/ tests/ + ####################################################################################### -[testenv:black] +[testenv:safety] +setenv = + LC_ALL=C.UTF-8 + LANG=C.UTF-8 deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt - black -commands = black --check --diff . --exclude "build/|.tox/|mod/|lib/" + safety +commands = + - safety check --full-report + ####################################################################################### [testenv:yamllint] @@ -86,9 +95,7 @@ commands = yamllint . ####################################################################################### [testenv:build] passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY -deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt - charmcraft +deps = charmcraft whitelist_externals = charmcraft cp @@ -112,4 +119,5 @@ exclude = max-line-length = 120 show-source = True builtins = _ - +max-complexity = 10 +import-order-style = google diff --git a/installers/charm/prometheus/.jujuignore b/installers/charm/prometheus/.jujuignore index bf04eb4787e6df5fd324a95b451e20c45ee9c0e5..3ae3e7dcbaabc72ec7f40ebc13192774df7f4a52 100644 --- a/installers/charm/prometheus/.jujuignore +++ b/installers/charm/prometheus/.jujuignore @@ -22,7 +22,13 @@ venv .vscode build -prometheus.charm +*.charm .coverage +coverage.xml +.gitignore .stestr cover +release +tests/ +requirements* +tox.ini diff --git a/installers/charm/prometheus/requirements-test.txt b/installers/charm/prometheus/requirements-test.txt index d7585f3e724a8c6258c4e9d960853d84e40ffe55..cf61dd4e12aa3e3834919feba9149f980468c28b 100644 --- a/installers/charm/prometheus/requirements-test.txt +++ b/installers/charm/prometheus/requirements-test.txt @@ -17,15 +17,4 @@ # # To get in touch with the maintainers, please contact: # osm-charmers@lists.launchpad.net -## --r requirements.txt -coverage -stestr -mock -black -yamllint -flake8 -safety -requests-mock -asynctest -nose2 \ No newline at end of file +mock==4.0.3 diff --git a/installers/charm/prometheus/src/charm.py b/installers/charm/prometheus/src/charm.py index 3d72cace76d0ebed42174c5cffc222205d82739c..47533ddf6e346409beb340c2dc225e29d393c42b 100755 --- a/installers/charm/prometheus/src/charm.py +++ b/installers/charm/prometheus/src/charm.py @@ -22,30 +22,26 @@ # pylint: disable=E0213 -import logging -from typing import Optional, NoReturn from ipaddress import ip_network +import logging +from typing import NoReturn, Optional +from urllib.parse import urlparse from ops.framework import EventBase from ops.main import main - from opslib.osm.charm import CharmedOsmBase - +from opslib.osm.interfaces.prometheus import PrometheusServer from opslib.osm.pod import ( - IngressResourceV3Builder, - FilesV3Builder, ContainerV3Builder, + FilesV3Builder, + IngressResourceV3Builder, PodSpecV3Builder, ) - - from opslib.osm.validator import ( ModelValidator, validator, ) -from opslib.osm.interfaces.prometheus import PrometheusServer -from urllib.parse import urlparse logger = logging.getLogger(__name__) diff --git a/installers/charm/prometheus/tests/__init__.py b/installers/charm/prometheus/tests/__init__.py index d0d973ae18111167581b5a2173a6998e9c2cb1cb..ca37e3b9e83699ffa5ac06f6c7003747272618b4 100644 --- a/installers/charm/prometheus/tests/__init__.py +++ b/installers/charm/prometheus/tests/__init__.py @@ -23,6 +23,8 @@ """Init mocking for unit tests.""" import sys + + import mock sys.path.append("src") diff --git a/installers/charm/prometheus/tests/test_charm.py b/installers/charm/prometheus/tests/test_charm.py index b1848bdd98245b1d5797ce84636f3b067580dccd..dd8b732cb90a6af4cfa2fbc3d261545eb2276742 100644 --- a/installers/charm/prometheus/tests/test_charm.py +++ b/installers/charm/prometheus/tests/test_charm.py @@ -23,10 +23,10 @@ import sys from typing import NoReturn import unittest -from ops.model import ActiveStatus -from ops.testing import Harness from charm import PrometheusCharm +from ops.model import ActiveStatus +from ops.testing import Harness class TestCharm(unittest.TestCase): diff --git a/installers/charm/prometheus/tox.ini b/installers/charm/prometheus/tox.ini index 1f9442e3716ae0dbdc8ad1888162d1c9f5872f4b..30e0ea8c7f5f1d2c3125b366626f7427b4f4199e 100644 --- a/installers/charm/prometheus/tox.ini +++ b/installers/charm/prometheus/tox.ini @@ -21,21 +21,32 @@ ####################################################################################### [tox] -envlist = flake8, cover, pylint, safety, yamllint -skipsdist = True +envlist = black, cover, flake8, pylint, yamllint, safety +skipsdist = true + +[tox:jenkins] +toxworkdir = /tmp/.tox [testenv] basepython = python3.8 -setenv = - VIRTUAL_ENV={envdir} - PYTHONHASHSEED=0 - PYTHONPATH = {toxinidir}/src +setenv = VIRTUAL_ENV={envdir} + PYTHONDONTWRITEBYTECODE = 1 deps = -r{toxinidir}/requirements.txt + +####################################################################################### +[testenv:black] +deps = black +commands = + black --check --diff src/ tests/ + + ####################################################################################### [testenv:cover] deps = {[testenv]deps} -r{toxinidir}/requirements-test.txt + coverage + nose2 commands = sh -c 'rm -f nosetests.xml' coverage erase @@ -45,36 +56,34 @@ commands = coverage xml -o coverage.xml --omit=*tests* whitelist_externals = sh -####################################################################################### -[testenv:safety] -setenv = - LC_ALL=C.UTF-8 - LANG=C.UTF-8 -deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt -commands = - - safety check --full-report ####################################################################################### [testenv:flake8] -deps = flake8 +deps = flake8 + flake8-import-order commands = flake8 src/ tests/ + ####################################################################################### [testenv:pylint] deps = {[testenv]deps} -r{toxinidir}/requirements-test.txt pylint commands = - pylint -E src + pylint -E src/ tests/ + ####################################################################################### -[testenv:black] +[testenv:safety] +setenv = + LC_ALL=C.UTF-8 + LANG=C.UTF-8 deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt - black -commands = black --check --diff . --exclude "build/|.tox/|mod/|lib/" + safety +commands = + - safety check --full-report + ####################################################################################### [testenv:yamllint] @@ -86,9 +95,7 @@ commands = yamllint . ####################################################################################### [testenv:build] passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY -deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt - charmcraft +deps = charmcraft whitelist_externals = charmcraft cp @@ -112,4 +119,5 @@ exclude = max-line-length = 120 show-source = True builtins = _ - +max-complexity = 10 +import-order-style = google diff --git a/installers/charm/ro/.jujuignore b/installers/charm/ro/.jujuignore index bf04eb4787e6df5fd324a95b451e20c45ee9c0e5..3ae3e7dcbaabc72ec7f40ebc13192774df7f4a52 100644 --- a/installers/charm/ro/.jujuignore +++ b/installers/charm/ro/.jujuignore @@ -22,7 +22,13 @@ venv .vscode build -prometheus.charm +*.charm .coverage +coverage.xml +.gitignore .stestr cover +release +tests/ +requirements* +tox.ini diff --git a/installers/charm/ro/requirements-test.txt b/installers/charm/ro/requirements-test.txt index 1da01c85a7cb629cc6269d936b7f9bb07f856a9c..cf61dd4e12aa3e3834919feba9149f980468c28b 100644 --- a/installers/charm/ro/requirements-test.txt +++ b/installers/charm/ro/requirements-test.txt @@ -17,14 +17,4 @@ # # To get in touch with the maintainers, please contact: # osm-charmers@lists.launchpad.net --r requirements.txt -coverage -stestr -mock -black -yamllint -flake8 -safety -requests-mock -asynctest -nose2 \ No newline at end of file +mock==4.0.3 diff --git a/installers/charm/ro/src/charm.py b/installers/charm/ro/src/charm.py index ae92d9835b09f92969a74029cd6721e23bb54689..6851600c6fe5ac225da53ca5b05a144ee3de5ed6 100755 --- a/installers/charm/ro/src/charm.py +++ b/installers/charm/ro/src/charm.py @@ -26,23 +26,15 @@ import logging from typing import NoReturn from ops.main import main - from opslib.osm.charm import CharmedOsmBase, RelationsMissing - +from opslib.osm.interfaces.kafka import KafkaClient +from opslib.osm.interfaces.mongo import MongoClient +from opslib.osm.interfaces.mysql import MysqlClient from opslib.osm.pod import ( ContainerV3Builder, PodSpecV3Builder, ) - - -from opslib.osm.validator import ( - ModelValidator, - validator, -) - -from opslib.osm.interfaces.kafka import KafkaClient -from opslib.osm.interfaces.mysql import MysqlClient -from opslib.osm.interfaces.mongo import MongoClient +from opslib.osm.validator import ModelValidator, validator logger = logging.getLogger(__name__) diff --git a/installers/charm/ro/tests/__init__.py b/installers/charm/ro/tests/__init__.py index d0d973ae18111167581b5a2173a6998e9c2cb1cb..ca37e3b9e83699ffa5ac06f6c7003747272618b4 100644 --- a/installers/charm/ro/tests/__init__.py +++ b/installers/charm/ro/tests/__init__.py @@ -23,6 +23,8 @@ """Init mocking for unit tests.""" import sys + + import mock sys.path.append("src") diff --git a/installers/charm/ro/tests/test_charm.py b/installers/charm/ro/tests/test_charm.py index 4f14aff82664a340dd8f76b9249f634a50306ab4..4610b2594d67c8b2e296857285489a736d566a91 100644 --- a/installers/charm/ro/tests/test_charm.py +++ b/installers/charm/ro/tests/test_charm.py @@ -23,10 +23,10 @@ import sys from typing import NoReturn import unittest -from ops.model import ActiveStatus, BlockedStatus -from ops.testing import Harness from charm import RoCharm +from ops.model import ActiveStatus, BlockedStatus +from ops.testing import Harness class TestCharm(unittest.TestCase): diff --git a/installers/charm/ro/tox.ini b/installers/charm/ro/tox.ini index 1f9442e3716ae0dbdc8ad1888162d1c9f5872f4b..30e0ea8c7f5f1d2c3125b366626f7427b4f4199e 100644 --- a/installers/charm/ro/tox.ini +++ b/installers/charm/ro/tox.ini @@ -21,21 +21,32 @@ ####################################################################################### [tox] -envlist = flake8, cover, pylint, safety, yamllint -skipsdist = True +envlist = black, cover, flake8, pylint, yamllint, safety +skipsdist = true + +[tox:jenkins] +toxworkdir = /tmp/.tox [testenv] basepython = python3.8 -setenv = - VIRTUAL_ENV={envdir} - PYTHONHASHSEED=0 - PYTHONPATH = {toxinidir}/src +setenv = VIRTUAL_ENV={envdir} + PYTHONDONTWRITEBYTECODE = 1 deps = -r{toxinidir}/requirements.txt + +####################################################################################### +[testenv:black] +deps = black +commands = + black --check --diff src/ tests/ + + ####################################################################################### [testenv:cover] deps = {[testenv]deps} -r{toxinidir}/requirements-test.txt + coverage + nose2 commands = sh -c 'rm -f nosetests.xml' coverage erase @@ -45,36 +56,34 @@ commands = coverage xml -o coverage.xml --omit=*tests* whitelist_externals = sh -####################################################################################### -[testenv:safety] -setenv = - LC_ALL=C.UTF-8 - LANG=C.UTF-8 -deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt -commands = - - safety check --full-report ####################################################################################### [testenv:flake8] -deps = flake8 +deps = flake8 + flake8-import-order commands = flake8 src/ tests/ + ####################################################################################### [testenv:pylint] deps = {[testenv]deps} -r{toxinidir}/requirements-test.txt pylint commands = - pylint -E src + pylint -E src/ tests/ + ####################################################################################### -[testenv:black] +[testenv:safety] +setenv = + LC_ALL=C.UTF-8 + LANG=C.UTF-8 deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt - black -commands = black --check --diff . --exclude "build/|.tox/|mod/|lib/" + safety +commands = + - safety check --full-report + ####################################################################################### [testenv:yamllint] @@ -86,9 +95,7 @@ commands = yamllint . ####################################################################################### [testenv:build] passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY -deps = {[testenv]deps} - -r{toxinidir}/requirements-test.txt - charmcraft +deps = charmcraft whitelist_externals = charmcraft cp @@ -112,4 +119,5 @@ exclude = max-line-length = 120 show-source = True builtins = _ - +max-complexity = 10 +import-order-style = google diff --git a/installers/charmed_install.sh b/installers/charmed_install.sh index e196706137eaa29a334f8674a4531cfb2f14e673..b36d582dacf83f0abe06fdada6f8fa9a32a99c9b 100755 --- a/installers/charmed_install.sh +++ b/installers/charmed_install.sh @@ -25,8 +25,8 @@ PATH=/snap/bin:${PATH} MODEL_NAME=osm -OSM_BUNDLE=cs:osm-58 -OSM_HA_BUNDLE=cs:osm-ha-43 +OSM_BUNDLE=cs:osm-60 +OSM_HA_BUNDLE=cs:osm-ha-45 TAG=testing-daily function check_arguments(){ @@ -306,7 +306,7 @@ function create_overlay() { sudo snap install yq local HOME=/home/$USER local vca_user=$(cat $HOME/.local/share/juju/accounts.yaml | yq e .controllers.$CONTROLLER_NAME.user - ) - local vca_password=$(cat $HOME/.local/share/juju/accounts.yaml | yq e .controllers.$CONTROLLER_NAME.password - ) + local vca_secret=$(cat $HOME/.local/share/juju/accounts.yaml | yq e .controllers.$CONTROLLER_NAME.password - ) local vca_host=$(cat $HOME/.local/share/juju/controllers.yaml | yq e .controllers.$CONTROLLER_NAME.api-endpoints[0] - | cut -d ":" -f 1) local vca_port=$(cat $HOME/.local/share/juju/controllers.yaml | yq e .controllers.$CONTROLLER_NAME.api-endpoints[0] - | cut -d ":" -f 2) local vca_pubkey=\"$(cat $HOME/.local/share/juju/ssh/juju_id_rsa.pub)\" @@ -323,7 +323,7 @@ applications: lcm: options: vca_user: $vca_user - vca_password: $vca_password + vca_secret: $vca_secret vca_host: $vca_host vca_port: $vca_port vca_pubkey: $vca_pubkey @@ -333,7 +333,7 @@ applications: mon: options: vca_user: $vca_user - vca_password: $vca_password + vca_secret: $vca_secret vca_host: $vca_host vca_cacert: $vca_cacert EOF