1- # run with locust -f locust_files/load_testing.py
1+ # run with " locust -f locust_files/load_testing.py"
22# then set number of users and spawn rate in web interface
33# e.g. test with 100 users, and 15 users/sec
44# web interface: http://0.0.0.0:8089/
@@ -36,6 +36,10 @@ def set_up_user(self):
3636 pass
3737
3838 def create_mock_result (self , group ):
39+ """Create a result object for a build area project.
40+
41+ The result values are generated randomly.
42+ """
3943 start_time = datetime .datetime .utcnow ().isoformat ()[0 :- 3 ] + "Z"
4044 end_time = datetime .datetime .utcnow ().isoformat ()[0 :- 3 ] + "Z"
4145
@@ -59,6 +63,7 @@ def create_mock_result(self, group):
5963 return data
6064
6165 def set_firebase_db (self , path , data , token = None ):
66+ """Upload results to Firebase using REST api."""
6267 request_ref = f"{ path } .json?auth={ token } "
6368 headers = {"content-type" : "application/json; charset=UTF-8" }
6469 self .client .patch (
@@ -68,9 +73,11 @@ def set_firebase_db(self, path, data, token=None):
6873
6974 @task
7075 def map_a_group (self ):
71- """Get a group from Firebase for this user.
76+ """Get a group from Firebase for this user and "map" it .
7277
7378 Make sure that this user has not worked on this group before.
79+ Get the group and create mock results.
80+ Upload results to Firebse.
7481 """
7582
7683 # get the groups that need to be mapped
@@ -114,6 +121,7 @@ def map_a_group(self):
114121 self .set_firebase_db (path , result , self .signed_in_user ["idToken" ])
115122
116123 def on_start (self ):
124+ """Set up user and define project when user starts running."""
117125 self .project_id = "-MYg8CEf2k1-RitN62X0"
118126 random_string = uuid4 ()
119127 self .email = f"test_{ random_string } @mapswipe.org"
0 commit comments