Merge ~cgrabowski/maas:backport-perftests-split-to-3.2 into maas:3.2

Proposed by Christian Grabowski
Status: Merged
Approved by: Christian Grabowski
Approved revision: ee5c222dae442633edd5eaed0ce40fc2619bc375
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~cgrabowski/maas:backport-perftests-split-to-3.2
Merge into: maas:3.2
Diff against target: 258 lines (+44/-49)
8 files modified
Makefile (+2/-2)
dev/null (+0/-9)
src/maasperf/tests/conftest.py (+41/-0)
src/maasperf/tests/maasserver/models/__init__.py (+0/-0)
src/maasperf/tests/maasserver/websockets/__init__.py (+0/-0)
src/maasserver/conftest.py (+0/-30)
src/maastesting/perftest.py (+1/-2)
src/maastesting/scripts.py (+0/-6)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Alexsander de Souza Approve
Review via email: mp+424321@code.launchpad.net

Commit message

move performance tests so they're easier to select/skip for runners

    Drop the marker for performance tests and move them under src/maasperf.
    bin/pytest doesn't look there by default, while the bin/test.perf runner only runs tests under that tree.

    (cherry picked from commit fa5728e6ad5e902f01bfc2d0cd85e021c6b85bd7)

To post a comment you must log in.
Revision history for this message
Alexsander de Souza (alexsander-souza) wrote :

+1

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b backport-perftests-split-to-3.2 lp:~cgrabowski/maas/+git/maas into -b 3.2 lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas/job/branch-tester/12896/console
COMMIT: cb1204713c28325bb53a4f1be1012c22fb8394ed

review: Needs Fixing
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b backport-perftests-split-to-3.2 lp:~cgrabowski/maas/+git/maas into -b 3.2 lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: ee5c222dae442633edd5eaed0ce40fc2619bc375

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/Makefile b/Makefile
2index 8aba789..ea62f89 100644
3--- a/Makefile
4+++ b/Makefile
5@@ -139,13 +139,13 @@ test-py: bin/test.parallel bin/subunit-1to2 bin/subunit2junitxml bin/subunit2pyu
6 test-perf: bin/test.perf
7 GIT_BRANCH=$(shell git rev-parse --abbrev-ref HEAD) \
8 GIT_HASH=$(shell git rev-parse HEAD) \
9- find . -type d -name perf | xargs bin/test.perf
10+ bin/test.perf
11 .PHONY: test-perf
12
13 test-perf-quiet: bin/test.perf
14 GIT_BRANCH=$(shell git rev-parse --abbrev-ref HEAD) \
15 GIT_HASH=$(shell git rev-parse HEAD) \
16- find . -type d -name perf | xargs bin/test.perf -q --disable-warnings --show-capture=no --no-header --no-summary
17+ bin/test.perf -q --disable-warnings --show-capture=no --no-header --no-summary
18 .PHONY: test-perf-quiet
19
20 update-initial-sql: bin/database bin/maas-region cleandb
21diff --git a/conftest.py b/conftest.py
22deleted file mode 100644
23index 9029b08..0000000
24--- a/conftest.py
25+++ /dev/null
26@@ -1,20 +0,0 @@
27-import pytest
28-
29-
30-def pytest_addoption(parser):
31- parser.addoption(
32- "--perf",
33- action="store_true",
34- default=False,
35- help="run performance tests",
36- )
37-
38-
39-def pytest_collection_modifyitems(config, items):
40- if config.getoption("--perf"):
41- # We want to run the performance tests
42- return
43- skip_perf = pytest.mark.skip(reason="need --perf option to run")
44- for item in items:
45- if "perftest" in item.keywords:
46- item.add_marker(skip_perf)
47diff --git a/src/maascli/perf/__init__.py b/src/maasperf/__init__.py
48similarity index 100%
49rename from src/maascli/perf/__init__.py
50rename to src/maasperf/__init__.py
51diff --git a/src/maasserver/api/perf/__init__.py b/src/maasperf/tests/__init__.py
52similarity index 100%
53rename from src/maasserver/api/perf/__init__.py
54rename to src/maasperf/tests/__init__.py
55diff --git a/src/maasserver/models/perf/__init__.py b/src/maasperf/tests/cli/__init__.py
56similarity index 100%
57rename from src/maasserver/models/perf/__init__.py
58rename to src/maasperf/tests/cli/__init__.py
59diff --git a/src/maascli/perf/conftest.py b/src/maasperf/tests/cli/conftest.py
60similarity index 100%
61rename from src/maascli/perf/conftest.py
62rename to src/maasperf/tests/cli/conftest.py
63diff --git a/src/maascli/perf/test_machines.py b/src/maasperf/tests/cli/test_machines.py
64similarity index 100%
65rename from src/maascli/perf/test_machines.py
66rename to src/maasperf/tests/cli/test_machines.py
67diff --git a/src/maasperf/tests/conftest.py b/src/maasperf/tests/conftest.py
68new file mode 100644
69index 0000000..f44495e
70--- /dev/null
71+++ b/src/maasperf/tests/conftest.py
72@@ -0,0 +1,41 @@
73+# Copyright 2022 Canonical Ltd. This software is licensed under the
74+# GNU Affero General Public License version 3 (see the file LICENSE).
75+
76+from pytest import fixture
77+
78+from maasserver.models.user import get_auth_tokens
79+from maasserver.testing.factory import factory as maasserver_factory
80+from maasserver.testing.testclient import MAASSensibleOAuthClient
81+
82+
83+# override pytest-django's db setup
84+@fixture(scope="session")
85+def django_db_setup():
86+ pass
87+
88+
89+@fixture(scope="session")
90+def factory():
91+ return maasserver_factory
92+
93+
94+@fixture()
95+def admin(factory):
96+ return factory.make_admin()
97+
98+
99+@fixture()
100+def maas_user(factory):
101+ return factory.make_User()
102+
103+
104+@fixture()
105+def api_client(maas_user):
106+ return MAASSensibleOAuthClient(
107+ user=maas_user, token=get_auth_tokens(maas_user)[0]
108+ )
109+
110+
111+@fixture()
112+def admin_api_client(admin):
113+ return MAASSensibleOAuthClient(user=admin, token=get_auth_tokens(admin)[0])
114diff --git a/src/maasserver/websockets/handlers/perf/__init__.py b/src/maasperf/tests/maasserver/api/__init__.py
115similarity index 100%
116rename from src/maasserver/websockets/handlers/perf/__init__.py
117rename to src/maasperf/tests/maasserver/api/__init__.py
118diff --git a/src/maasserver/api/perf/test_machines.py b/src/maasperf/tests/maasserver/api/test_machines.py
119similarity index 100%
120rename from src/maasserver/api/perf/test_machines.py
121rename to src/maasperf/tests/maasserver/api/test_machines.py
122diff --git a/src/maasperf/tests/maasserver/models/__init__.py b/src/maasperf/tests/maasserver/models/__init__.py
123new file mode 100644
124index 0000000..e69de29
125--- /dev/null
126+++ b/src/maasperf/tests/maasserver/models/__init__.py
127diff --git a/src/maasserver/models/perf/conftest.py b/src/maasperf/tests/maasserver/models/conftest.py
128similarity index 100%
129rename from src/maasserver/models/perf/conftest.py
130rename to src/maasperf/tests/maasserver/models/conftest.py
131diff --git a/src/maasserver/models/perf/test_machine.py b/src/maasperf/tests/maasserver/models/test_machine.py
132similarity index 100%
133rename from src/maasserver/models/perf/test_machine.py
134rename to src/maasperf/tests/maasserver/models/test_machine.py
135diff --git a/src/maasperf/tests/maasserver/websockets/__init__.py b/src/maasperf/tests/maasserver/websockets/__init__.py
136new file mode 100644
137index 0000000..e69de29
138--- /dev/null
139+++ b/src/maasperf/tests/maasserver/websockets/__init__.py
140diff --git a/src/maasserver/websockets/handlers/perf/conftest.py b/src/maasperf/tests/maasserver/websockets/conftest.py
141similarity index 100%
142rename from src/maasserver/websockets/handlers/perf/conftest.py
143rename to src/maasperf/tests/maasserver/websockets/conftest.py
144diff --git a/src/maasserver/websockets/handlers/perf/test_machines.py b/src/maasperf/tests/maasserver/websockets/test_machines.py
145similarity index 100%
146rename from src/maasserver/websockets/handlers/perf/test_machines.py
147rename to src/maasperf/tests/maasserver/websockets/test_machines.py
148diff --git a/src/maasserver/conftest.py b/src/maasserver/conftest.py
149index f44495e..688ad7c 100644
150--- a/src/maasserver/conftest.py
151+++ b/src/maasserver/conftest.py
152@@ -3,39 +3,9 @@
153
154 from pytest import fixture
155
156-from maasserver.models.user import get_auth_tokens
157 from maasserver.testing.factory import factory as maasserver_factory
158-from maasserver.testing.testclient import MAASSensibleOAuthClient
159-
160-
161-# override pytest-django's db setup
162-@fixture(scope="session")
163-def django_db_setup():
164- pass
165
166
167 @fixture(scope="session")
168 def factory():
169 return maasserver_factory
170-
171-
172-@fixture()
173-def admin(factory):
174- return factory.make_admin()
175-
176-
177-@fixture()
178-def maas_user(factory):
179- return factory.make_User()
180-
181-
182-@fixture()
183-def api_client(maas_user):
184- return MAASSensibleOAuthClient(
185- user=maas_user, token=get_auth_tokens(maas_user)[0]
186- )
187-
188-
189-@fixture()
190-def admin_api_client(admin):
191- return MAASSensibleOAuthClient(user=admin, token=get_auth_tokens(admin)[0])
192diff --git a/src/maastesting/perftest.py b/src/maastesting/perftest.py
193index 46ddb8a..46ca79d 100644
194--- a/src/maastesting/perftest.py
195+++ b/src/maastesting/perftest.py
196@@ -64,7 +64,6 @@ class PerfTester:
197 def perf_test(commit_transaction=False, db_only=False):
198 def inner(fn):
199 @wraps(fn)
200- @mark.perftest
201 @mark.django_db
202 def wrapper(*args, **kwargs):
203 from django.db import transaction
204@@ -112,7 +111,7 @@ def run_perf_tests(env):
205 perf_tester = PerfTester(env.get("GIT_BRANCH"), env.get("GIT_HASH"))
206
207 pytest_main(
208- args=["--perf", "-m", "perftest", "--reuse-db"] + cmd_args,
209+ args=["--reuse-db", "src/maasperf"] + cmd_args,
210 )
211 finally:
212 perf_test_finish(env.get("OUTPUT_FILE"))
213diff --git a/src/maastesting/scripts.py b/src/maastesting/scripts.py
214index afdee65..18acde6 100644
215--- a/src/maastesting/scripts.py
216+++ b/src/maastesting/scripts.py
217@@ -53,8 +53,6 @@ def run_region():
218 "--cover-branches",
219 # exclude pytest tests
220 "--exclude-dir-file=src/maastesting/pytest.dirs",
221- # exclude perf tests
222- "--exclude=perf",
223 # Reduce the logging level to INFO here as
224 # DebuggingLoggerMiddleware logs the content of all the
225 # requests at DEBUG level: we don't want this in the
226@@ -99,8 +97,6 @@ def run_region_legacy():
227 "--cover-branches",
228 # exclude pytest tests
229 "--exclude-dir-file=src/maastesting/pytest.dirs",
230- # exclude perf tests
231- "--exclude=perf",
232 # Reduce the logging level to INFO here as DebuggingLoggerMiddleware
233 # logs the content of all the requests at DEBUG level: we don't want
234 # this in the tests as it's too verbose.
235@@ -129,8 +125,6 @@ def run_rack():
236 "--cover-branches",
237 # exclude pytest tests
238 "--exclude-dir-file=src/maastesting/pytest.dirs",
239- # exclude perf tests
240- "--exclude=perf",
241 ]
242 inject_test_options(options)
243 update_environ()
244diff --git a/src/maastesting/tests/conftest.py b/src/maastesting/tests/conftest.py
245deleted file mode 100644
246index 83dd6e4..0000000
247--- a/src/maastesting/tests/conftest.py
248+++ /dev/null
249@@ -1,9 +0,0 @@
250-# Copyright 2022 Canonical Ltd. This software is licensed under the
251-# GNU Affero General Public License version 3 (see the file LICENSE).
252-
253-from pytest import fixture
254-
255-
256-@fixture(scope="session")
257-def django_db_setup():
258- pass

Subscribers

People subscribed via source and target branches