Merge ~cjwatson/content-cache-charm:remove-functional-tests into content-cache-charm:master

Proposed by Colin Watson
Status: Merged
Approved by: Haw Loeung
Approved revision: b0d11c80bea2d04a2b5add5280c0e8129cba1fe6
Merged at revision: 789e443da21b90db33113c6dff8d9d13df4b7713
Proposed branch: ~cjwatson/content-cache-charm:remove-functional-tests
Merge into: content-cache-charm:master
Diff against target: 150 lines (+7/-73)
3 files modified
Makefile (+4/-8)
dev/null (+0/-52)
tox.ini (+3/-13)
Reviewer Review Type Date Requested Status
Haw Loeung +1 Approve
Canonical IS Reviewers Pending
Review via email: mp+434621@code.launchpad.net

Commit message

Remove functional tests

Description of the change

They didn't work properly for a couple of reasons:

 * Since commit bf9aa16221ed3fc2daf1a98343798c8d9e428aff, the `build` target that `make functional` depended on is no longer present, so you had to build the charm manually and unpack it into `builds/content-cache/` in a Juju repository somewhere, or else build it with `charmcraft pack` and hack the functional tests to point to the resulting `.charm` file.

 * The tests aren't quite compatible with the current version of `pytest-asyncio` for some reason.

Furthermore, the integration tests are completely a superset of the functional tests: they deal with building the charm to test themselves, they cover the same general ground of deploying the charm using Juju to see what happens, and they test more than the functional tests do. So it doesn't really make much sense to have both, especially considering that both functional and integration tests are quite slow.

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Haw Loeung (hloeung) wrote :

LGTM, thanks!

review: Approve (+1)
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 789e443da21b90db33113c6dff8d9d13df4b7713

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/Makefile b/Makefile
2index c7533cf..4446d25 100644
3--- a/Makefile
4+++ b/Makefile
5@@ -3,9 +3,8 @@ help:
6 @echo ""
7 @echo " make help - show this text"
8 @echo " make lint - run flake8"
9- @echo " make test - run the functional test and unittests"
10- @echo " make unittest - run the the unittest"
11- @echo " make functional - run the functional tests"
12+ @echo " make test - run the unit and integration tests"
13+ @echo " make unittest - run the unit tests"
14 @echo " make integration - run the integration tests"
15 @echo " make clean - remove unneeded files"
16 @echo ""
17@@ -18,14 +17,11 @@ lint: blacken
18 @echo "Running flake8"
19 @tox -e lint
20
21-test: lint unittest functional
22+test: lint unittest
23
24 unittest:
25 @tox -e unit
26
27-functional: build
28- @tox -e functional
29-
30 integration:
31 @tox -e integration
32
33@@ -34,4 +30,4 @@ clean:
34 @git clean -ffXd
35
36 # The targets below don't depend on a file
37-.PHONY: lint test unittest functionaltest build clean help
38+.PHONY: lint test unittest integration build clean help
39diff --git a/tests/functional/requirements.txt b/tests/functional/requirements.txt
40deleted file mode 100644
41index f76bfbb..0000000
42--- a/tests/functional/requirements.txt
43+++ /dev/null
44@@ -1,6 +0,0 @@
45-flake8
46-juju
47-mock
48-pytest
49-pytest-asyncio
50-requests
51diff --git a/tests/functional/test_content_cache.py b/tests/functional/test_content_cache.py
52deleted file mode 100644
53index 5d0ecf5..0000000
54--- a/tests/functional/test_content_cache.py
55+++ /dev/null
56@@ -1,52 +0,0 @@
57-import os
58-import pytest
59-from juju.model import Model
60-
61-# Treat tests as coroutines
62-pytestmark = pytest.mark.asyncio
63-
64-series = ['bionic']
65-juju_repository = os.getenv('JUJU_REPOSITORY', '.').rstrip('/')
66-
67-
68-@pytest.fixture
69-async def model():
70- model = Model()
71- await model.connect_current()
72- yield model
73- await model.disconnect()
74-
75-
76-@pytest.fixture
77-async def apps(model):
78- apps = []
79- for entry in series:
80- app = model.applications['content-cache-{}'.format(entry)]
81- apps.append(app)
82- return apps
83-
84-
85-@pytest.fixture
86-async def units(apps):
87- units = []
88- for app in apps:
89- units.extend(app.units)
90- return units
91-
92-
93-@pytest.mark.parametrize('series', series)
94-async def test_content_cache_deploy(model, series):
95- # Starts a deploy for each series
96- await model.deploy(
97- '{}/builds/content-cache'.format(juju_repository),
98- series=series,
99- application_name='content-cache-{}'.format(series),
100- )
101- assert True
102-
103-
104-async def test_content_cache_status(apps, model):
105- # Verifies status for all deployed series of the charm
106- for app in apps:
107- await model.block_until(lambda: app.status == 'active')
108- assert True
109diff --git a/tox.ini b/tox.ini
110index cfe4513..e339c8d 100644
111--- a/tox.ini
112+++ b/tox.ini
113@@ -1,6 +1,6 @@
114 [tox]
115 skipsdist=True
116-envlist = unit, functional
117+envlist = unit
118 skip_missing_interpreters = True
119
120 [testenv]
121@@ -10,7 +10,7 @@ setenv =
122
123 [testenv:unit]
124 commands =
125- pytest --ignore {toxinidir}/tests/functional \
126+ pytest \
127 --ignore {toxinidir}/tests/integration \
128 {posargs:-v --cov=lib --cov=reactive --cov=actions --cov-branch --cov-report=term-missing --cov-report=html}
129 deps = -r{toxinidir}/tests/unit/requirements.txt
130@@ -19,19 +19,9 @@ setenv =
131 PYTHONPATH={toxinidir}/lib
132 TZ=UTC
133
134-[testenv:functional]
135-passenv =
136- HOME
137- JUJU_REPOSITORY
138- PATH
139-commands =
140- pytest -v --ignore {toxinidir}/tests/unit --ignore {toxinidir}/tests/integration {posargs}
141-deps = -r{toxinidir}/tests/functional/requirements.txt
142- -r{toxinidir}/requirements.txt
143-
144 [testenv:integration]
145 commands = pytest -v --ignore {toxinidir}/tests/unit \
146- --ignore {toxinidir}/tests/functional --log-cli-level=INFO {posargs}
147+ --log-cli-level=INFO {posargs}
148 deps = pytest
149 pytest-operator
150 pytest-asyncio

Subscribers

People subscribed via source and target branches