@@ -172,9 +172,6 @@ def import_reimport_performance(self, expected_num_queries1, expected_num_async_
172
172
reimporter = DefaultReImporter (** reimport_options )
173
173
test , _ , _len_new_findings , _len_closed_findings , _ , _ , _ = reimporter .process_scan (scan )
174
174
175
- # patch the we_want_async decorator to always return True so we don't depend on block_execution flag shenanigans
176
- # @patch("dojo.decorators.we_want_async", return_value=True)
177
- # def test_import_reimport_reimport_performance_async(self, mock):
178
175
@override_settings (ENABLE_AUDITLOG = True , AUDITLOG_TYPE = "django-auditlog" )
179
176
def test_import_reimport_reimport_performance_async (self ):
180
177
# Ensure django-auditlog is properly configured for this test
@@ -191,38 +188,27 @@ def test_import_reimport_reimport_performance_async(self):
191
188
expected_num_async_tasks3 = 20 ,
192
189
)
193
190
194
- # @patch("dojo.decorators.we_want_async", return_value=False)
195
- # def test_import_reimport_reimport_performance_no_async(self, mock):
196
- @override_settings (ENABLE_AUDITLOG = True , AUDITLOG_TYPE = "django-auditlog" )
197
- def test_import_reimport_reimport_performance_no_async (self ):
191
+ @override_settings (ENABLE_AUDITLOG = True , AUDITLOG_TYPE = "django-pghistory" )
192
+ def test_import_reimport_reimport_performance_pghistory_async (self ):
198
193
"""
199
- This test checks the performance of the importers when they are run in sync mode.
200
- The reason for this is that we also want to be aware of when a PR affects the number of queries
201
- or async tasks created by a background task.
202
- The impersonate context manager above does not work as expected for disabling async,
203
- so we patch the we_want_async decorator to always return False.
194
+ This test checks the performance of the importers when using django-pghistory with async enabled.
195
+ Query counts will need to be determined by running the test initially.
204
196
"""
205
- # Ensure django-auditlog is properly configured for this test
206
197
from dojo .auditlog import configure_audit_system , configure_pghistory_triggers
207
198
configure_audit_system ()
208
199
configure_pghistory_triggers ()
209
200
210
- testuser = User .objects .get (username = "admin" )
211
- testuser .usercontactinfo .block_execution = True
212
- testuser .usercontactinfo .save ()
213
201
self .import_reimport_performance (
214
- expected_num_queries1 = 682 ,
202
+ expected_num_queries1 = 648 ,
215
203
expected_num_async_tasks1 = 10 ,
216
- expected_num_queries2 = 615 ,
204
+ expected_num_queries2 = 603 ,
217
205
expected_num_async_tasks2 = 22 ,
218
- expected_num_queries3 = 297 ,
206
+ expected_num_queries3 = 287 ,
219
207
expected_num_async_tasks3 = 20 ,
220
208
)
221
209
222
- # @patch("dojo.decorators.we_want_async", return_value=False)
223
- # def test_import_reimport_reimport_performance_no_async_with_product_grading(self, mock):
224
210
@override_settings (ENABLE_AUDITLOG = True , AUDITLOG_TYPE = "django-auditlog" )
225
- def test_import_reimport_reimport_performance_no_async_with_product_grading (self ):
211
+ def test_import_reimport_reimport_performance_no_async (self ):
226
212
"""
227
213
This test checks the performance of the importers when they are run in sync mode.
228
214
The reason for this is that we also want to be aware of when a PR affects the number of queries
@@ -238,57 +224,63 @@ def test_import_reimport_reimport_performance_no_async_with_product_grading(self
238
224
testuser = User .objects .get (username = "admin" )
239
225
testuser .usercontactinfo .block_execution = True
240
226
testuser .usercontactinfo .save ()
241
- self .system_settings (enable_product_grade = True )
242
-
243
227
self .import_reimport_performance (
244
- expected_num_queries1 = 666 ,
228
+ expected_num_queries1 = 682 ,
245
229
expected_num_async_tasks1 = 10 ,
246
- expected_num_queries2 = 630 ,
230
+ expected_num_queries2 = 615 ,
247
231
expected_num_async_tasks2 = 22 ,
248
- expected_num_queries3 = 312 ,
232
+ expected_num_queries3 = 297 ,
249
233
expected_num_async_tasks3 = 20 ,
250
234
)
251
235
252
- # New pghistory performance tests
253
236
@override_settings (ENABLE_AUDITLOG = True , AUDITLOG_TYPE = "django-pghistory" )
254
- def test_import_reimport_reimport_performance_pghistory_async (self ):
237
+ def test_import_reimport_reimport_performance_pghistory_no_async (self ):
255
238
"""
256
- This test checks the performance of the importers when using django-pghistory with async enabled .
239
+ This test checks the performance of the importers when using django-pghistory with async disabled .
257
240
Query counts will need to be determined by running the test initially.
258
241
"""
259
242
from dojo .auditlog import configure_audit_system , configure_pghistory_triggers
260
243
configure_audit_system ()
261
244
configure_pghistory_triggers ()
262
245
246
+ testuser = User .objects .get (username = "admin" )
247
+ testuser .usercontactinfo .block_execution = True
248
+ testuser .usercontactinfo .save ()
249
+
263
250
self .import_reimport_performance (
264
251
expected_num_queries1 = 648 ,
265
252
expected_num_async_tasks1 = 10 ,
266
- expected_num_queries2 = 603 ,
253
+ expected_num_queries2 = 608 ,
267
254
expected_num_async_tasks2 = 22 ,
268
- expected_num_queries3 = 287 ,
255
+ expected_num_queries3 = 292 ,
269
256
expected_num_async_tasks3 = 20 ,
270
257
)
271
258
272
- @override_settings (ENABLE_AUDITLOG = True , AUDITLOG_TYPE = "django-pghistory " )
273
- def test_import_reimport_reimport_performance_pghistory_no_async (self ):
259
+ @override_settings (ENABLE_AUDITLOG = True , AUDITLOG_TYPE = "django-auditlog " )
260
+ def test_import_reimport_reimport_performance_no_async_with_product_grading (self ):
274
261
"""
275
- This test checks the performance of the importers when using django-pghistory with async disabled.
276
- Query counts will need to be determined by running the test initially.
262
+ This test checks the performance of the importers when they are run in sync mode.
263
+ The reason for this is that we also want to be aware of when a PR affects the number of queries
264
+ or async tasks created by a background task.
265
+ The impersonate context manager above does not work as expected for disabling async,
266
+ so we patch the we_want_async decorator to always return False.
277
267
"""
268
+ # Ensure django-auditlog is properly configured for this test
278
269
from dojo .auditlog import configure_audit_system , configure_pghistory_triggers
279
270
configure_audit_system ()
280
271
configure_pghistory_triggers ()
281
272
282
273
testuser = User .objects .get (username = "admin" )
283
274
testuser .usercontactinfo .block_execution = True
284
275
testuser .usercontactinfo .save ()
276
+ self .system_settings (enable_product_grade = True )
285
277
286
278
self .import_reimport_performance (
287
- expected_num_queries1 = 648 ,
279
+ expected_num_queries1 = 666 ,
288
280
expected_num_async_tasks1 = 10 ,
289
- expected_num_queries2 = 608 ,
281
+ expected_num_queries2 = 630 ,
290
282
expected_num_async_tasks2 = 22 ,
291
- expected_num_queries3 = 292 ,
283
+ expected_num_queries3 = 312 ,
292
284
expected_num_async_tasks3 = 20 ,
293
285
)
294
286
0 commit comments