Merge ~hloeung/jenkins-agent-charm:master into jenkins-agent-charm:master

Proposed by Haw Loeung
Status: Merged
Approved by: Haw Loeung
Approved revision: 5cde3e05e9abdee56ea85b18dc466134dc2ade06
Merged at revision: 5b771d15301641c7338157ac517156ad2aefe1b6
Proposed branch: ~hloeung/jenkins-agent-charm:master
Merge into: jenkins-agent-charm:master
Diff against target: 185 lines (+45/-62)
9 files modified
Makefile (+1/-1)
dev/null (+0/-50)
tests/bundles (+1/-0)
tests/functional/bundles/base-bionic.yaml (+22/-0)
tests/functional/bundles/overlays/local-charm-overlay.yaml.j2 (+3/-0)
tests/functional/requirements.txt (+1/-6)
tests/functional/tests.yaml (+14/-0)
tests/tests.yaml (+1/-0)
tox.ini (+2/-5)
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Canonical IS Reviewers Pending
Review via email: mp+369073@code.launchpad.net

Commit message

Replace functional testing using pytest with zaza

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 :

Output from 'make lint unittest functionaltest' run - https://pastebin.ubuntu.com/p/kpkcT87F3Q/

Revision history for this message
Stuart Bishop (stub) wrote :

Looks good from my end. Before landing, worth considering your opinion on if this is a step forward or backwards and discussing if you think backwards.

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

Change successfully merged at revision 5b771d15301641c7338157ac517156ad2aefe1b6

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/Makefile b/Makefile
2index e592bf7..43470ed 100644
3--- a/Makefile
4+++ b/Makefile
5@@ -13,7 +13,7 @@ lint:
6 @echo "Running flake8"
7 @tox -e lint
8
9-test: unittest functionaltest lint
10+test: lint unittest functionaltest
11
12 unittest:
13 @tox -e unit
14diff --git a/requirements.txt b/requirements.txt
15deleted file mode 100644
16index 8462291..0000000
17--- a/requirements.txt
18+++ /dev/null
19@@ -1 +0,0 @@
20-# Include python requirements here
21diff --git a/tests/bundles b/tests/bundles
22new file mode 120000
23index 0000000..dbd0feb
24--- /dev/null
25+++ b/tests/bundles
26@@ -0,0 +1 @@
27+functional/bundles
28\ No newline at end of file
29diff --git a/tests/functional/bundles/base-bionic.yaml b/tests/functional/bundles/base-bionic.yaml
30new file mode 100644
31index 0000000..cb92d23
32--- /dev/null
33+++ b/tests/functional/bundles/base-bionic.yaml
34@@ -0,0 +1,22 @@
35+series: bionic
36+
37+applications:
38+ jenkins:
39+ charm: cs:jenkins
40+ num_units: 1
41+ options:
42+ username: admin
43+ password: admin
44+ expose: true
45+
46+ jenkins-slave:
47+ num_units: 1
48+
49+ nrpe:
50+ charm: cs:nrpe
51+
52+relations:
53+ - - jenkins
54+ - jenkins-slave
55+ - - jenkins-slave
56+ - nrpe
57diff --git a/tests/functional/bundles/overlays/local-charm-overlay.yaml.j2 b/tests/functional/bundles/overlays/local-charm-overlay.yaml.j2
58new file mode 100644
59index 0000000..1adcb54
60--- /dev/null
61+++ b/tests/functional/bundles/overlays/local-charm-overlay.yaml.j2
62@@ -0,0 +1,3 @@
63+applications:
64+ jenkins-slave:
65+ charm: /tmp/charm-builds/jenkins-slave
66diff --git a/tests/functional/requirements.txt b/tests/functional/requirements.txt
67index f76bfbb..b7c9112 100644
68--- a/tests/functional/requirements.txt
69+++ b/tests/functional/requirements.txt
70@@ -1,6 +1 @@
71-flake8
72-juju
73-mock
74-pytest
75-pytest-asyncio
76-requests
77+git+https://github.com/openstack-charmers/zaza.git#egg=zaza
78diff --git a/tests/functional/test_jenkins_slave.py b/tests/functional/test_jenkins_slave.py
79deleted file mode 100644
80index e5051ac..0000000
81--- a/tests/functional/test_jenkins_slave.py
82+++ /dev/null
83@@ -1,50 +0,0 @@
84-import os
85-import pytest
86-from juju.model import Model
87-
88-# Treat tests as coroutines
89-pytestmark = pytest.mark.asyncio
90-
91-series = ['bionic']
92-juju_repository = os.getenv('JUJU_REPOSITORY', '.').rstrip('/')
93-
94-
95-@pytest.fixture
96-async def model():
97- model = Model()
98- await model.connect_current()
99- yield model
100- await model.disconnect()
101-
102-
103-@pytest.fixture
104-async def apps(model):
105- apps = []
106- for entry in series:
107- app = model.applications['jenkins-slave-{}'.format(entry)]
108- apps.append(app)
109- return apps
110-
111-
112-@pytest.fixture
113-async def units(apps):
114- units = []
115- for app in apps:
116- units.extend(app.units)
117- return units
118-
119-
120-@pytest.mark.parametrize('series', series)
121-async def test_jenkins_slave_deploy(model, series):
122- # Starts a deploy for each series
123- await model.deploy('{}/builds/jenkins-slave'.format(juju_repository),
124- series=series,
125- application_name='jenkins-slave-{}'.format(series))
126- assert True
127-
128-
129-async def test_jenkins_slave_status(apps, model):
130- # Verifies status for all deployed series of the charm
131- for app in apps:
132- await model.block_until(lambda: app.status == 'active')
133- assert True
134diff --git a/tests/functional/tests.yaml b/tests/functional/tests.yaml
135new file mode 100644
136index 0000000..757a6ea
137--- /dev/null
138+++ b/tests/functional/tests.yaml
139@@ -0,0 +1,14 @@
140+charm_name: jenkins-slave
141+tests:
142+ - zaza.charm_tests.noop.tests.NoopTest
143+configure:
144+ - zaza.charm_tests.noop.setup.basic_setup
145+gate_bundles:
146+ - base-bionic
147+dev_bundles:
148+ - base-bionic
149+smoke_bundles:
150+ - base-bionic
151+target_deploy_status:
152+ jenkins:
153+ workload-status-message: Jenkins is running
154diff --git a/tests/tests.yaml b/tests/tests.yaml
155new file mode 120000
156index 0000000..19e19a7
157--- /dev/null
158+++ b/tests/tests.yaml
159@@ -0,0 +1 @@
160+functional/tests.yaml
161\ No newline at end of file
162diff --git a/tox.ini b/tox.ini
163index d6b7675..99078b2 100644
164--- a/tox.ini
165+++ b/tox.ini
166@@ -11,17 +11,14 @@ setenv =
167 [testenv:unit]
168 commands = pytest -v --ignore {toxinidir}/tests/functional --cov=lib --cov=reactive --cov=actions --cov-report=term-missing --cov-branch
169 deps = -r{toxinidir}/tests/unit/requirements.txt
170- -r{toxinidir}/requirements.txt
171 setenv = PYTHONPATH={toxinidir}/lib
172
173 [testenv:functional]
174 passenv =
175 HOME
176- JUJU_REPOSITORY
177- PATH
178-commands = pytest -v --ignore {toxinidir}/tests/unit
179+basepython = python3
180+commands = functest-run-suite --keep-model
181 deps = -r{toxinidir}/tests/functional/requirements.txt
182- -r{toxinidir}/requirements.txt
183
184 [testenv:lint]
185 commands = flake8

Subscribers

People subscribed via source and target branches