@@ -213,28 +213,26 @@ public void testDynamicOutboundRateUpdateSharedServers() throws IOException, Int
213213 public void start (Promise <Void > startPromise ) throws Exception
214214 {
215215 HttpServer testServer = serverFactory .apply (vertx );
216- servers .add (testServer );
217216 testServer .requestHandler (HANDLERS .getFile (sampleF ))
218217 .listen (DEFAULT_HTTP_PORT , DEFAULT_HTTP_HOST ).onComplete (res -> {
219218 if (res .succeeded ()) {
219+ servers .add (testServer );
220220 // Apply traffic shaping options after the server has started
221221 TrafficShapingOptions updatedTrafficOptions = new TrafficShapingOptions ()
222222 .setInboundGlobalBandwidth (INBOUND_LIMIT )
223223 .setOutboundGlobalBandwidth (2 * OUTBOUND_LIMIT );
224224
225225 List <Promise <Void >> promises = new ArrayList <>();
226- for (int i = 0 ; i < numEventLoops ; i ++) {
227- servers .forEach (s -> {
228- Promise <Void > promise = Promise .promise ();
229- try {
230- s .updateTrafficShapingOptions (updatedTrafficOptions );
231- promise .complete ();
232- } catch (Exception e ) {
233- promise .fail (e );
234- }
235- promises .add (promise );
236- });
237- }
226+ servers .forEach (s -> {
227+ Promise <Void > promise = Promise .promise ();
228+ try {
229+ s .updateTrafficShapingOptions (updatedTrafficOptions );
230+ promise .complete ();
231+ } catch (Exception e ) {
232+ promise .fail (e );
233+ }
234+ promises .add (promise );
235+ });
238236 // Ensure all traffic shaping updates complete before resolving the startPromise
239237 Future .all (promises .stream ().map (Promise ::future ).collect (Collectors .toList ()))
240238 .onSuccess (v -> startPromise .complete ())
@@ -266,7 +264,7 @@ public void start(Promise<Void> startPromise) throws Exception
266264 }));
267265 }
268266 }));
269- awaitLatch (waitForResponse , 20 , TimeUnit .SECONDS );
267+ awaitLatch (waitForResponse , 2000 , TimeUnit .SECONDS );
270268 long elapsedMillis = TimeUnit .NANOSECONDS .toMillis (System .nanoTime () - startTime .get ());
271269 Assert .assertTrue (elapsedMillis < expectedUpperBoundTimeMillis (totalReceivedLength .get (), OUTBOUND_LIMIT ));
272270 }
0 commit comments