diff options
author | Alvaro Uria <alvaro.uria@canonical.com> | 2020-05-21 23:54:53 +0200 |
---|---|---|
committer | Alvaro Uria <alvaro.uria@canonical.com> | 2020-05-21 23:54:53 +0200 |
commit | a47d77a2eea582277ad47e0f245b1d6fed204640 (patch) | |
tree | a407395173d65185c0bc7c38da2a26a77f0b1dec | |
parent | 21a9befa06d4c6e63b7b157274b4828c992d24dd (diff) |
Fix func tests (except bionic-shard)
-rw-r--r-- | Makefile | 6 | ||||
-rwxr-xr-x | hooks/hooks.py | 12 | ||||
-rw-r--r-- | tests/bundles/bionic-shard.yaml | 4 | ||||
-rw-r--r-- | tests/bundles/bionic.yaml | 1 | ||||
-rw-r--r-- | tests/bundles/overlays/bionic-shard.yaml.j2 | 7 | ||||
-rw-r--r-- | tests/bundles/overlays/local-charm-overlay.yaml.j2 | 3 | ||||
-rw-r--r-- | tests/bundles/xenial.yaml | 1 | ||||
-rw-r--r-- | tests/tests.yaml | 2 |
8 files changed, 21 insertions, 15 deletions
@@ -19,11 +19,7 @@ PROJECTPATH := $(realpath $(dir $(realpath $(firstword $(MAKEFILE_LIST))))) clean: - rm -f .coverage - find . -name '*.pyc' -delete - rm -rf .venv - rm -rf .tox - (which dh_clean && dh_clean) || true + git clean -fXd lint: @echo Starting flake8... diff --git a/hooks/hooks.py b/hooks/hooks.py index cc8fd85..e18d064 100755 --- a/hooks/hooks.py +++ b/hooks/hooks.py @@ -9,7 +9,7 @@ import collections import distutils import json import os -import distro +import pip import pprint import re import signal @@ -19,6 +19,12 @@ import sys import time try: + import distro # flake8: noqa +except ImportError: + pip.main(['install', "distro"]) + import distro # flake8: noqa + +try: import yaml # flake8: noqa except ImportError: if sys.version_info.major == 2: @@ -496,7 +502,7 @@ def mongo_client_smart(host='localhost', command=None): for i in range(MONGO_CLIENT_RETRIES): try: - cmd_output = subprocess.check_output(cmd_line) + cmd_output = subprocess.check_output(cmd_line).decode("utf8") juju_log('mongo_client_smart executed, output: %s' % cmd_output) if json.loads(cmd_output)['ok'] == 1: @@ -970,7 +976,7 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # We can remove this quirk when charm no longer supports trusty def arm64_trusty_quirk(): - arch = subprocess.check_output(['dpkg', '--print-architecture']).strip() + arch = subprocess.check_output(['dpkg', '--print-architecture']).decode("utf8").strip() if arch != 'arm64': return if lsb_release()['DISTRIB_CODENAME'] != 'trusty': diff --git a/tests/bundles/bionic-shard.yaml b/tests/bundles/bionic-shard.yaml index b7ee354..9b0e209 100644 --- a/tests/bundles/bionic-shard.yaml +++ b/tests/bundles/bionic-shard.yaml @@ -2,22 +2,18 @@ series: bionic description: "mongodb-charm test bundle" applications: configsvr: - charm: "../../." num_units: 1 options: replicaset: configsvr mongodb: - charm: "../../." num_units: 1 options: replicaset: testset shard1: - charm: "../../." num_units: 1 options: replicaset: shard1 shard2: - charm: "../../." num_units: 1 options: replicaset: shard2 diff --git a/tests/bundles/bionic.yaml b/tests/bundles/bionic.yaml index ebfb98e..cef11a1 100644 --- a/tests/bundles/bionic.yaml +++ b/tests/bundles/bionic.yaml @@ -2,7 +2,6 @@ series: bionic description: "mongodb-charm test bundle" applications: mongodb: - charm: "../../." num_units: 3 options: replicaset: testset diff --git a/tests/bundles/overlays/bionic-shard.yaml.j2 b/tests/bundles/overlays/bionic-shard.yaml.j2 new file mode 100644 index 0000000..91c7d6c --- /dev/null +++ b/tests/bundles/overlays/bionic-shard.yaml.j2 @@ -0,0 +1,7 @@ +applications: + configsvr: + charm: "{{ CHARM_BUILD_DIR }}" + shard1: + charm: "{{ CHARM_BUILD_DIR }}" + shard2: + charm: "{{ CHARM_BUILD_DIR }}" diff --git a/tests/bundles/overlays/local-charm-overlay.yaml.j2 b/tests/bundles/overlays/local-charm-overlay.yaml.j2 new file mode 100644 index 0000000..0a63173 --- /dev/null +++ b/tests/bundles/overlays/local-charm-overlay.yaml.j2 @@ -0,0 +1,3 @@ +applications: + {{ charm_name }}: + charm: "{{ CHARM_BUILD_DIR }}" diff --git a/tests/bundles/xenial.yaml b/tests/bundles/xenial.yaml index 9d29342..a17f8b7 100644 --- a/tests/bundles/xenial.yaml +++ b/tests/bundles/xenial.yaml @@ -2,7 +2,6 @@ series: xenial description: "mongodb-charm test bundle" applications: mongodb: - charm: "../../." num_units: 3 options: replicaset: testset diff --git a/tests/tests.yaml b/tests/tests.yaml index dcbd01c..2f157ec 100644 --- a/tests/tests.yaml +++ b/tests/tests.yaml @@ -1,4 +1,4 @@ -charm_name: mongodb-charm +charm_name: mongodb tests: - model_alias_xenial: - tests.tests_mongodb.BasicMongodbCharmTest |