Merge ~bjornt/maas:perftest-websocket-machine-list-all into maas:master

Proposed by Björn Tillenius
Status: Merged
Approved by: Björn Tillenius
Approved revision: 346e64038f0aa3addf3fedbad472029ed11ca73e
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~bjornt/maas:perftest-websocket-machine-list-all
Merge into: maas:master
Diff against target: 43 lines (+22/-0)
1 file modified
src/maasperf/tests/maasserver/websockets/test_machines.py (+22/-0)
Reviewer Review Type Date Requested Status
Alberto Donato (community) Approve
MAAS Lander Approve
Review via email: mp+433442@code.launchpad.net

Commit message

Add a performance test for listing all machines with the websocket.

With this it's easier to track what the default page size should be.

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b perftest-websocket-machine-list-all lp:~bjornt/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 346e64038f0aa3addf3fedbad472029ed11ca73e

review: Approve
Revision history for this message
Alberto Donato (ack) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasperf/tests/maasserver/websockets/test_machines.py b/src/maasperf/tests/maasserver/websockets/test_machines.py
2index b4cd181..7fcf8b5 100644
3--- a/src/maasperf/tests/maasserver/websockets/test_machines.py
4+++ b/src/maasperf/tests/maasserver/websockets/test_machines.py
5@@ -1,12 +1,15 @@
6 # Copyright 2022 Canonical Ltd. This software is licensed under the
7 # GNU Affero General Public License version 3 (see the file LICENSE).
8
9+from maasserver.models import Machine
10 from maasserver.websockets.handlers.machine import MachineHandler
11 from maastesting.perftest import perf_test, profile
12
13
14 @perf_test(db_only=True)
15 def test_perf_list_machines_Websocket_endpoint(admin):
16+ # This should test the websocket calls that are used to load
17+ # the machine listing page on the initial page load.
18 with profile("test_perf_list_machines_Websocket_endpoint"):
19 ws_handler = MachineHandler(admin, {}, None)
20 # Extracted from a clean load of labmaas with empty local
21@@ -21,3 +24,22 @@ def test_perf_list_machines_Websocket_endpoint(admin):
22 "sort_key": "hostname",
23 }
24 ws_handler.list(params)
25+
26+
27+@perf_test(db_only=True)
28+def test_perf_list_machines_Websocket_endpoint_all(admin):
29+ # How long would it take to list all the machines using the
30+ # websocket without any pagination.
31+ machine_count = Machine.objects.all().count()
32+ with profile("test_perf_list_machines_Websocket_endpoint_all"):
33+ ws_handler = MachineHandler(admin, {}, None)
34+ # Extracted from a clean load of labmaas with empty local
35+ # storage
36+ params = {
37+ "filter": {},
38+ "page_number": 1,
39+ "page_size": machine_count + 1,
40+ "sort_direction": "descending",
41+ "sort_key": "hostname",
42+ }
43+ ws_handler.list(params)

Subscribers

People subscribed via source and target branches