-
Notifications
You must be signed in to change notification settings - Fork 106
/
locustfile.py
811 lines (738 loc) · 25.6 KB
/
locustfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
# -*- coding: utf-8 -*-
"""Load testing for the API and web app. Run from the root directory using the
`locust --host=https://api-stage.open.fec.gov/v1/ --logfile=locustfile.log` (stage)
`locust --host=https://api.open.fec.gov/v1/ --logfile=locustfile.log` (prod)
`locust --host=https://fec-dev-api.app.cloud.gov/v1/ --logfile=locustfile.log` (dev)
command, then open localhost:8089 to run tests.
API keys:
- Use an unlimited `FEC_WEB_API_KEY_PUBLIC`
- Borrow the `FEC_DOWNLOAD_API_KEY` from the staging space
"""
import os
import random
import resource
import json
import logging
from locust import between, task, TaskSet, user
# As of 11/2023 max time for successful queries is about 300 sec
timeout = 300
# Avoid "Too many open files" error
resource.setrlimit(resource.RLIMIT_NOFILE, (10000, 999999))
API_KEY = os.environ["FEC_WEB_API_KEY_PUBLIC"]
DOWNLOAD_KEY = os.environ["FEC_DOWNLOAD_API_KEY"]
CYCLES = range(1980, 2024, 2)
CANDIDATES = [
"bush",
"cheney",
"gore",
"lieberman",
"kerry",
"edwards",
"obama",
"biden",
"mccain",
"palin",
"clinton",
"sanders",
"omalley",
"rubio",
"graham",
"kasich",
"trump",
"haley",
]
TERMS = ["embezzle", "email", "department", "contribution", "commission"]
small_records_sched_a = [
{"contributor_name": "Teachout Zephyr"},
{"contributor_name": "Steve Danger"},
{"contributor_name": "Marvin Martian"},
{"contributor_name": "Abraham Lincoln"},
{"committee_id": "C00671339"},
{"committee_id": "C00012914"},
{"committee_id": "C00405050"},
{"committee_id": "C00309054"},
{"contributor_zip": "96910"},
{"contributor_zip": "57002"},
{"contributor_zip": "46928"},
{"contributor_zip": "34343"},
{"contributor_name": "Elspeth"},
{"contributor_name": "Han Solo"},
{"contributor_occupation": "Dad"},
{"contributor_occupation": "candle"},
{"contributor_occupation": "lumberjack"},
{"contributor_employer": "kohls"},
{"contributor_employer": "blockbuster"},
{"contributor_employer": "sephora"},
{"contributor_employer": "patreon"},
{"image_number": "96016112914"},
{"image_number": "202310159598048212"}
]
medium_records_sched_a = [
{"committee_id": "C00496067"},
{"committee_id": "C00658476"},
{"committee_id": "C00728238"},
{"committee_id": "C00091884"},
{"contributor_zip": "46038"},
{"contributor_city": "Fresno"},
{"contributor_city": "Sedona"},
{"contributor_city": "Bozeman"},
{"contributor_occupation": "podcast"},
{"contributor_occupation": "lighting"},
{"contributor_occupation": "chef"},
{"contributor_name": "mildred"},
{"contributor_employer": "google"},
{
"contributor_name": "smith",
"recipient_committee_designation": "D",
},
]
large_records_sched_a = [
{"committee_id": "C00401224"},
{
"committee_id": [
"C00401224",
"C00003418",
"C00010603",
"C00027466",
"C00005561",
"C00484642",
]
},
{"contributor_zip": "10001"},
{"contributor_zip": "20001"},
{
"committee_id": "C00744946",
"two_year_transaction_period": 2020,
"min_amount": 2,
},
{"contributor_name": "Smith"},
{"contributor_name": "Johnson"},
{"contributor_occupation": "consultant"},
# seeing this problem in production
{
"data_type": "processed",
"sort_hide_null": "true",
"committee_id": "C00401224",
"two_year_transaction_period": 2016,
"min_date": "07/01/2016",
"max_date": "07/31/2016",
"sort": "-contribution_receipt_date",
"per_page": 30,
},
]
poor_performance_a = [
{
"sort_hide_null": True,
"contributor_name": "paul+johnson",
"two_year_transaction_period": 2014,
"min_date": "01/01/2013",
"max_date": "12/31/2014",
"contributor_state": "IN",
"sort": "-contribution_receipt_date",
"per_page": 30,
"is_individual": True,
},
{
"sort_hide_null": True,
"contributor_name": "Robert+F+Pence",
"two_year_transaction_period": 2014,
"min_date": "01/01/2013",
"max_date": "12/31/2014",
"sort": "-contribution_receipt_date",
"per_page": 100,
"is_individual": True,
},
{
"sort_hide_null": True,
"contributor_name": "tom+lewis",
"two_year_transaction_period": 2016,
"min_date": "01/01/2015",
"max_date": "12/31/2016",
"sort": "-contribution_receipt_amount",
"per_page": 30,
"is_individual": True,
},
{
"sort_hide_null": True,
"contributor_name": "Becher%2C+S",
"two_year_transaction_period": 2016,
"min_date": "01/01/2015",
"max_date": "12/31/2016",
"contributor_state": "FL",
"sort": "-contribution_receipt_date",
"per_page": 30,
"is_individual": True,
},
{
"sort_hide_null": True,
"contributor_name": "Becher",
"two_year_transaction_period": 2016,
"min_date": "01/01/2015",
"max_date": "12/31/2016",
"contributor_state": "FL",
"sort": "-contribution_receipt_date",
"per_page": 30,
"is_individual": True,
},
# slow queries from this month (11/23)
{
"contributor_type": "individual",
"contributor_zip": "12588",
"per_page": 100,
},
{"committee_id": "C00496067"},
{
"two_year_transaction_period": 2016,
"contributor_name": "Paul",
"contributor_employer": "Huntington+Bank",
"per_page": 100,
},
{
"committee_id": [
"C00660555",
"C00253955"],
"two_year_transaction_period": 2022,
"is_individual": True,
"per_page": 100,
},
{
"committee_id": "C00532465",
"min_amount": "1",
"is_individual": True,
"per_page": 100,
},
{
"contributor_type": "individual",
"sort_hide_null": True,
"contributor_zip": "30325",
"per_page": 100,
},
# 502, 504's (11/23)
{"committee_id": "C00765800"},
{
"committee_id": "C00696153",
"two_year_transaction_period": 2020,
},
{
"committee_id": "C00709410",
"two_year_transaction_period": 2020
},
{
"committee_id": "C00329896",
"sort_nulls_only": False,
"sort_hide_null": False,
"min_amount": 1,
},
{
"committee_id": "C00703975",
"two_year_transaction_period": [
2018,
2020
],
"min_amount": 2,
}
]
small_records_sched_b = [
{"recipient_name": "Mooses"},
{"recipient_name": "Danger"},
{"committee_id": "C00148031"},
{"committee_id": "C00003855"},
{"recipient_city": "Fairmount"},
{"recipient_city": "Greenfield"},
{"recipient_state": "AS"},
{"disbursement_description": "unitemized"},
{
"min_amount": 653,
"max_amount": 653.50
},
{"line_number": "F3-19"},
{"line_number": "F3P-27B"},
{"image_number": "26930697364"},
{"spender_committee_org_type": "V"},
]
medium_records_sched_b = [
{"committee_id": "C00042366"},
{"committee_id": "C00005561"},
{"recipient_name": "Food"},
{"recipient_name": "Cassidy"},
{"recipient_name": "Walt"},
{"recipient_city": "Carmel"},
{"recipient_city": "Sedona"},
{"recipient_city": "Bozeman"},
{"recipient_state": "PI"},
{"disbursement_description": "COMPUTER"},
{"line_number": "F3-18"},
{"line_number": "F3X-30B"},
{"two_year_transaction_period": 1988},
{"spender_committee_org_type": "V"},
]
large_records_sched_b = [
{"committee_id": "C00401224"},
{"committee_id": "C00010603"},
{
"committee_id": [
"C00003418",
"C00027466",
"C00005561",
"C00484642",
]
},
{
"recipient_name": [
"post",
"verizon",
]
},
{"two_year_transaction_period": 2004},
{"two_year_transaction_period": 2008},
{"recipient_state": "UT"},
{"recipient_state": "WV"},
{"line_number": "F3X-21B"},
{"line_number": "F3X-29"},
{"spender_committee_org_type": "C"},
{"spender_committee_designation": "J"},
]
poor_performance_b = [
# older poor performance
{
"sort_hide_null": True,
"two_year_transaction_period": 2016,
"per_page": 100,
"sort": "disbursement_date",
"last_disbursement_date": "2016-03-03",
"last_index": 4070720161305573871,
},
{
"two_year_transaction_period": 2016,
"per_page": 100,
"sort": "disbursement_date",
"last_disbursement_date": "2016-03-03",
"last_index": 4062420161300286190,
},
{
"two_year_transaction_period": 2016,
"per_page": 100,
"sort": "disbursement_date",
"last_disbursement_date": "2016-03-03",
"last_index": 4062120161299938749,
},
{
"two_year_transaction_period": 2016,
"per_page": 100,
"sort": "disbursement_date",
"last_disbursement_date": "2016-03-03",
"last_index": 4061720161299122923,
},
{
"two_year_transaction_period": 2024,
"per_page": 100,
"sort": "disbursement_date",
"last_disbursement_date": "2023-11-30",
"last_index": 4120820231812161483,
},
# slow queries (recent 11/23)
{
"committee_id": "C00357129",
"two_year_transaction_period": 2024,
"per_page": 100,
"min_date": "2020-09-11",
},
{
"committee_id": [
"C00713404",
"C00656793"
],
"two_year_transaction_period": 2020,
"disbursement_purpose_category": "OTHER",
"per_page": 10,
},
{
"committee_id": "C00076893",
"two_year_transaction_period": 2022,
"min_date": "2020-09-11",
"per_page": 100,
},
{
"committee_id": "C00495846",
"two_year_transaction_period": 2024,
"per_page": 10,
},
{
"disbursement_description": "nsf",
"per_page": 30,
},
{
"disbursement_description": "salary",
"per_page": 30,
},
{
"recipient_name": "meidastouch",
"per_page": 30,
"data_type": "processed",
},
]
schedule_c_params = [
{"committee_id": "C00846089"},
{"loan_source_name": "phd"},
{"loan_source_name": "bank"},
{"min_amount": 50000},
{"min_amount": 70000},
{"min_incurred_date": "12/07/2020"},
]
schedule_d_params = [
{"committee_id": "C00553560"},
{"creditor_debtor_name": "florist"},
{"creditor_debtor_name": "bank"},
{"min_coverage_end_date": "11/21/2022"},
{"form_line_number": "F3-9"},
{"form_line_number": "F3X-9"},
{"form_line_number": "F3P-11"},
]
schedule_e_params = [
{"q_spender": "senate"},
{"q_spender": "speak"},
{"cycle": "2016"},
{"is_notice": "True"},
{"filing_form": "F3X"},
{"support_oppose_indicator": "O"},
{"candidate_office": "H"},
{"candidate_office_state": "CA"},
{"payee_name": "Consult"},
]
filings_params = [
{"q_filer": "senate"},
{"filer_type": "e-file"},
{"committee_type": "Q"},
{"committee_type": "S"},
{"cycle": "2016"},
{"cycle": "2020"},
{"is_amended": "True"},
{"most_recent": "True"},
{"report_type": "M3"},
{"report_type": "Q2"},
{"request_type": "1"},
{"report_type": "2"},
{"report_year": "2016"},
{"committee_id": "C00401224"},
]
schedule_f_params = [
{"payee_name": "senate"},
{"cycle": "2014"},
{"cycle": "2016"},
{"form_line_number": "F3X-25"},
]
schedule_h4_params = [
{"committee_id": "C00044776"},
{"q_payee_name": "hotel"},
{"cycle": "2020"},
{"payee_city": "new york"},
{"payee_state": "AZ"},
{"payee_state": "VA"},
{"q_disbursement_purpose": "event"},
{"spender_committee_type": "O"},
{"spender_committee_type": "Y"},
]
def get_random_date():
"""
A handy function to get a random date
e.g. '2018-01-01'
# TODO: could be updated to something like this:
https://stackoverflow.com/questions/553303/
generate-a-random-date-between-two-other-dates
"""
month = random.choice(range(1, 13))
year = random.choice(range(1979, 2024))
date = random.choice(range(1, 29))
if len(str(date)) == 1:
date = "0" + str(date)
return "{y}-{m}-{d}".format(y=str(year), m=str(month), d=str(date))
def log_response(self, endpoint_name, params, resp):
if resp.status_code == 200:
logging.info('*********fetch_{} response: {}'.format(endpoint_name, resp))
logging.info('params: %s', params)
response_json = json.loads(resp.text)
count = response_json.get('pagination', {}).get('count', None)
logging.info('Response count: %s', count)
else:
logging.error('{} error fetching {}'.format(resp.status_code, endpoint_name))
class Tasks(TaskSet):
def on_start(self):
self.candidates = self.fetch_ids("candidates", "candidate_id")
self.committees = self.fetch_ids("committees", "committee_id")
def fetch_ids(self, endpoint, key):
params = {"api_key": API_KEY}
resp = self.client.get(endpoint, name="preload_ids", params=params)
if resp.status_code == 200:
return [result[key] for result in resp.json()["results"]]
else:
logging.error('{} error fetching pre-load id'.format(resp.status_code))
@task
def load_home(self):
params = {"api_key": API_KEY}
self.client.get("", name="home", params=params)
@task
def test_download(self):
"""
a quick test on download api. this test need to generate a dynamic query
each time in order to be queued for celery processing.
the filename payload is optional(cms ajax call do pass in a filename each time.)
"""
rand_date = get_random_date()
_year = int(rand_date.split("-")[0])
_cycle = (_year + 1) if _year % 2 == 1 else _year
params = {
"api_key": DOWNLOAD_KEY,
"sort_hide_null": False,
"sort_nulls_last": False,
"two_year_transaction_period": _cycle,
"min_date": rand_date,
"max_date": rand_date,
"sort": "-contribution_receipt_date",
"is_individual": True,
}
payload = {"filename": "f_" + rand_date + ".csv"}
self.client.post(
"download/schedules/schedule_a",
name="download",
params=params,
json=payload,
)
@task
def load_candidates_search(self, term=None):
term = term or random.choice(CANDIDATES)
params = {"api_key": API_KEY, "sort": "-receipts", "q": term}
resp = self.client.get("candidates/search", name="candidate_search", params=params, timeout=timeout)
log_response(self, "candidates/search", params, resp)
@task
def load_committees_search(self, term=None):
term = term or random.choice(CANDIDATES)
params = {"api_key": API_KEY, "sort": "-receipts", "q": term}
resp = self.client.get("committees", name="committee_search", params=params, timeout=timeout)
log_response(self, "committees", params, resp)
@task
def load_candidates_table(self):
params = {
"cycle": [random.choice(CYCLES) for _ in range(3)],
"api_key": API_KEY,
}
resp = self.client.get("candidates", name="candidates_table", params=params, timeout=timeout)
log_response(self, "candidates", params, resp)
@task
def load_committees_table(self):
params = {
"cycle": [random.choice(CYCLES) for _ in range(3)],
"api_key": API_KEY,
}
resp = self.client.get("committees", name="committees_table", params=params, timeout=timeout)
log_response(self, "candidates", params, resp)
@task
def load_candidate_detail(self, candidate_id=None):
params = {"api_key": API_KEY}
candidate_id = candidate_id or random.choice(self.candidates)
resp = self.client.get(
os.path.join("candidate", candidate_id),
name="candidate_detail",
params=params,
timeout=timeout
)
log_response(self, "candidate_detail", params, resp)
@task
def load_committee_detail(self, committee_id=None):
params = {"api_key": API_KEY}
committee_id = committee_id or random.choice(self.committees)
resp = self.client.get(
os.path.join("committee", committee_id),
name="committee_detail",
params=params,
timeout=timeout,
)
log_response(self, "committee_detail", params, resp)
@task
def load_candidate_totals(self, candidate_id=None):
params = {"api_key": API_KEY}
candidate_id = candidate_id or random.choice(self.candidates)
resp = self.client.get(
os.path.join("candidate", candidate_id, "totals"),
name="candidate_totals",
params=params,
timeout=timeout
)
log_response(self, "candidate_totals", params, resp)
@task
def load_committee_totals(self, committee_id=None):
params = {"api_key": API_KEY}
committee_id = committee_id or random.choice(self.committees)
resp = self.client.get(
os.path.join("committee", committee_id, "totals"),
name="committee_totals",
params=params,
timeout=timeout
)
log_response(self, "committee_totals", params, resp)
@task(6)
def load_schedule_a_small(self):
params = random.choice(small_records_sched_a)
params["api_key"] = API_KEY
resp = self.client.get('schedules/schedule_a/', name='schedule_a_small', params=params, timeout=timeout)
log_response(self, "schedule_a_small", params, resp)
@task(3)
def load_schedule_a_medium(self):
params = random.choice(medium_records_sched_a)
params["api_key"] = API_KEY
resp = self.client.get('schedules/schedule_a/', name='schedule_a_medium', params=params, timeout=timeout)
log_response(self, "schedule_a_medium", params, resp)
@task
def load_schedule_a_large(self):
params = random.choice(large_records_sched_a)
params["api_key"] = API_KEY
resp = self.client.get('schedules/schedule_a/', name='schedule_a_large', params=params, timeout=timeout)
log_response(self, "schedule_a_large", params, resp)
@task
def load_schedule_a_problematic(self):
params = random.choice(poor_performance_a)
params["api_key"] = API_KEY
resp = self.client.get('schedules/schedule_a/', name='schedule_a_problematic', params=params, timeout=timeout)
log_response(self, "schedule_a_problematic", params, resp)
@task(3)
def load_schedule_a_rand(self):
params = {"api_key": API_KEY}
params["committee_id"] = random.choice(self.committees)
resp = self.client.get('schedules/schedule_a/', name='schedule_a_rand', params=params, timeout=timeout)
log_response(self, "schedule_a_rand", params, resp)
@task(6)
def load_schedule_b_small(self):
params = random.choice(small_records_sched_b)
params["api_key"] = API_KEY
resp = self.client.get('schedules/schedule_b/', name='schedule_b_small', params=params, timeout=timeout)
log_response(self, "schedule_b_small", params, resp)
@task(3)
def load_schedule_b_medium(self):
params = random.choice(medium_records_sched_b)
params["api_key"] = API_KEY
resp = self.client.get('schedules/schedule_b/', name='schedule_b_medium', params=params, timeout=timeout)
log_response(self, "schedule_b_medium", params, resp)
@task
def load_schedule_b_large(self):
params = random.choice(large_records_sched_b)
params["api_key"] = API_KEY
resp = self.client.get('schedules/schedule_b/', name='schedule_b_large', params=params, timeout=timeout)
log_response(self, "schedule_b_large", params, resp)
@task
def load_schedule_b_problematic(self):
params = random.choice(poor_performance_b)
params["api_key"] = API_KEY
resp = self.client.get('schedules/schedule_b/', name='schedule_b_problematic', params=params, timeout=timeout)
log_response(self, "schedule_b_problematic", params, resp)
@task(3)
def load_schedule_b_rand(self):
params = {"api_key": API_KEY}
params["committee_id"] = random.choice(self.committees)
resp = self.client.get('schedules/schedule_b/', name='schedule_b_rand', params=params, timeout=timeout)
log_response(self, "schedule_b_rand", params, resp)
@task
def load_schedule_c(self):
params = random.choice(schedule_c_params)
params["api_key"] = API_KEY
resp = self.client.get('schedules/schedule_c/', name='schedule_c', params=params, timeout=timeout)
log_response(self, "schedule_c", params, resp)
@task
def load_schedule_d(self):
params = random.choice(schedule_d_params)
params["api_key"] = API_KEY
resp = self.client.get('schedules/schedule_d/', name='schedule_d', params=params, timeout=timeout)
log_response(self, "schedule_d", params, resp)
@task
def load_schedule_e(self):
params = random.choice(schedule_e_params)
params["api_key"] = API_KEY
resp = self.client.get('schedules/schedule_e/', name='schedule_e', params=params, timeout=timeout)
log_response(self, "schedule_e", params, resp)
@task
def load_schedule_f(self):
params = random.choice(schedule_f_params)
params["api_key"] = API_KEY
resp = self.client.get('schedules/schedule_f/', name='schedule_f', params=params, timeout=timeout)
log_response(self, "schedule_f", params, resp)
@task
def load_schedule_h4(self):
params = random.choice(schedule_h4_params)
params["api_key"] = API_KEY
resp = self.client.get('schedules/schedule_h4/', name='schedule_h4', params=params, timeout=timeout)
log_response(self, "schedule_h4", params, resp)
@task
def load_audit_category(self):
params = {"api_key": API_KEY}
resp = self.client.get("audit-category/", name="load_audit_category", params=params, timeout=timeout)
log_response(self, "audit-category", params, resp)
@task(3)
def load_filings(self):
params = random.choice(filings_params)
params["api_key"] = API_KEY
resp = self.client.get('filings', name='load_filings', params=params, timeout=timeout)
log_response(self, "filings", params, resp)
@task
def load_totals(self):
params = {"api_key": API_KEY}
resp = self.client.get("totals/P/", name="load_P_totals", params=params, timeout=timeout)
log_response(self, "Ptotals", params, resp)
@task
def load_reports(self):
params = {"api_key": API_KEY}
resp = self.client.get("reports/P/", name="load_reports", params=params, timeout=timeout)
log_response(self, "Ptotals", params, resp)
@task
def load_legal_documents_search(self, term=None):
params = {"q": term, "api_key": API_KEY}
resp = self.client.get("legal/search", name="legal_search", params=params, timeout=timeout)
log_response(self, "legal_search", params, resp)
@task
def get_docs_mur(self):
params = {"api_key": API_KEY}
resp = self.client.get("legal/docs/murs/7074", name="get_docs_mur", params=params, timeout=timeout)
log_response(self, "mur7074", params, resp)
@task
def get_docs_adr(self):
params = {"api_key": API_KEY}
resp = self.client.get("legal/docs/adrs/668", name="get_docs_adr", params=params, timeout=timeout)
log_response(self, "adrs668", params, resp)
@task
def get_docs_admin_fine(self):
params = {"api_key": API_KEY}
resp = self.client.get(
"legal/docs/admin_fines/3745", name="get_docs_admin_fine", params=params, timeout=timeout
)
log_response(self, "admin_fines3745", params, resp)
# archived mur #179
@task
def get_docs_archived_mur(self):
params = {"api_key": API_KEY}
resp = self.client.get("legal/docs/murs/179", name="get_docs_archived_mur", params=params, timeout=timeout)
log_response(self, "archived_murs179", params, resp)
@task
def get_docs_advisory_opinions(self):
params = {"api_key": API_KEY}
resp = self.client.get(
"legal/docs/advisory_opinions/2023-12",
name="get_docs_advisory_opinions",
params=params,
timeout=timeout
)
log_response(self, "ao202312", params, resp)
@task
def get_mur_inner_hits(self):
params = {"q": "reason", "type": "murs", "case_no": "4530", "case_doc_category_id": "1", "api_key": API_KEY}
resp = self.client.get("legal/search", name="get_mur_inner_hits", params=params, timeout=timeout)
log_response(self, "mur_inner_hits", params, resp)
@task
def get_mur_inner_hits_all(self):
params = {"q": "reason", "type": "murs", "api_key": API_KEY}
resp = self.client.get("legal/search", name="get_mur_inner_hits_all", params=params, timeout=timeout)
log_response(self, "mur_inner_hits_all", params, resp)
@task
def get_inner_hits_all(self):
params = {"q": "committee", "api_key": API_KEY}
resp = self.client.get("legal/search", name="get_inner_hits_all", params=params, timeout=timeout)
log_response(self, "get_inner_hits_all", params, resp)
class Swarm(user.HttpUser):
tasks = [Tasks]
wait_time = between(1, 5)