(self)
| 2125 | mixed_users = weighted_user_classes[:25] + fixed_user_classes_10k[25:] |
| 2126 | |
| 2127 | def test_distribute_users(self): |
| 2128 | for user_classes in [self.weighted_user_classes, self.fixed_user_classes_1M, self.mixed_users]: |
| 2129 | workers = [WorkerNode(str(i)) for i in range(10_000)] |
| 2130 | |
| 2131 | target_user_count = 1_000_000 |
| 2132 | |
| 2133 | users_dispatcher = UsersDispatcher(worker_nodes=workers, user_classes=user_classes) |
| 2134 | |
| 2135 | ts = time.perf_counter() |
| 2136 | users_on_workers, user_gen, worker_gen, active_users = users_dispatcher._distribute_users( |
| 2137 | target_user_count=target_user_count |
| 2138 | ) |
| 2139 | delta = time.perf_counter() - ts |
| 2140 | |
| 2141 | # Because tests are run with coverage, the code will be slower. |
| 2142 | # We set the pass criterion to 7000ms, but in real life, the |
| 2143 | # `_distribute_users` method runs faster than this. |
| 2144 | self.assertLessEqual(1000 * delta, 7000) |
| 2145 | |
| 2146 | self.assertEqual(_user_count(users_on_workers), target_user_count) |
| 2147 | |
| 2148 | def test_ramp_up_from_0_to_100_000_users_with_50_user_classes_and_1000_workers_and_5000_spawn_rate(self): |
| 2149 | for user_classes in [ |
nothing calls this directly
no test coverage detected