Skip to content

Commit a5faa59

Browse files
Shivangi Guptacoffeys
authored andcommitted
8201778: Speed up test javax/net/ssl/DTLS/PacketLossRetransmission.java
Backport-of: fc3e3e26c515ae0f9ae32aec504974fba393928d
1 parent 21e6391 commit a5faa59

File tree

2 files changed

+12
-27
lines changed

2 files changed

+12
-27
lines changed

test/jdk/javax/net/ssl/DTLS/DTLSOverDatagram.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -52,7 +52,6 @@
5252
*/
5353
public class DTLSOverDatagram {
5454

55-
private static final int SOCKET_TIMEOUT = 10 * 1000; // in millis
5655
private static final int BUFFER_SIZE = 1024;
5756
private static final int MAXIMUM_PACKET_SIZE = 1024;
5857

@@ -78,6 +77,7 @@ public class DTLSOverDatagram {
7877
private final AtomicBoolean exceptionOccurred = new AtomicBoolean(false);
7978

8079
private final CountDownLatch serverStarted = new CountDownLatch(1);
80+
private int socketTimeout = 10 * 1000; // in millis
8181
/*
8282
* =============================================================
8383
* The test case
@@ -476,6 +476,10 @@ static DatagramPacket getPacket(
476476
return null;
477477
}
478478

479+
public void setSocketTimeout(int socketTimeout) {
480+
this.socketTimeout = socketTimeout;
481+
}
482+
479483
// run delegated tasks
480484
void runDelegatedTasks(SSLEngine engine) throws Exception {
481485
Runnable runnable;
@@ -529,8 +533,8 @@ public final void runTest(DTLSOverDatagram testCase) throws Exception {
529533
try (DatagramSocket serverSocket = new DatagramSocket(serverSocketAddress);
530534
DatagramSocket clientSocket = new DatagramSocket(clientSocketAddress)) {
531535

532-
serverSocket.setSoTimeout(SOCKET_TIMEOUT);
533-
clientSocket.setSoTimeout(SOCKET_TIMEOUT);
536+
serverSocket.setSoTimeout(socketTimeout);
537+
clientSocket.setSoTimeout(socketTimeout);
534538

535539
InetSocketAddress serverSocketAddr = new InetSocketAddress(
536540
InetAddress.getLoopbackAddress(), serverSocket.getLocalPort());

test/jdk/javax/net/ssl/DTLS/PacketLossRetransmission.java

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -32,37 +32,16 @@
3232
* @library /test/lib
3333
* @build DTLSOverDatagram
3434
*
35-
* @run main/othervm PacketLossRetransmission client 0 hello_request
3635
* @run main/othervm PacketLossRetransmission client 1 client_hello
37-
* @run main/othervm PacketLossRetransmission client 2 server_hello
38-
* @run main/othervm PacketLossRetransmission client 3 hello_verify_request
39-
* @run main/othervm -Djdk.tls.client.enableSessionTicketExtension=false PacketLossRetransmission client 4 new_session_ticket
40-
* @run main/othervm PacketLossRetransmission client 11 certificate
41-
* @run main/othervm PacketLossRetransmission client 12 server_key_exchange
42-
* @run main/othervm PacketLossRetransmission client 13 certificate_request
43-
* @run main/othervm PacketLossRetransmission client 14 server_hello_done
44-
* @run main/othervm PacketLossRetransmission client 15 certificate_verify
4536
* @run main/othervm PacketLossRetransmission client 16 client_key_exchange
4637
* @run main/othervm PacketLossRetransmission client 20 finished
47-
* @run main/othervm PacketLossRetransmission client 21 certificate_url
48-
* @run main/othervm PacketLossRetransmission client 22 certificate_status
49-
* @run main/othervm PacketLossRetransmission client 23 supplemental_data
5038
* @run main/othervm PacketLossRetransmission client -1 change_cipher_spec
51-
* @run main/othervm PacketLossRetransmission server 0 hello_request
52-
* @run main/othervm PacketLossRetransmission server 1 client_hello
5339
* @run main/othervm PacketLossRetransmission server 2 server_hello
5440
* @run main/othervm PacketLossRetransmission server 3 hello_verify_request
55-
* @run main/othervm -Djdk.tls.client.enableSessionTicketExtension=false PacketLossRetransmission server 4 new_session_ticket
5641
* @run main/othervm PacketLossRetransmission server 11 certificate
5742
* @run main/othervm PacketLossRetransmission server 12 server_key_exchange
58-
* @run main/othervm PacketLossRetransmission server 13 certificate_request
5943
* @run main/othervm PacketLossRetransmission server 14 server_hello_done
60-
* @run main/othervm PacketLossRetransmission server 15 certificate_verify
61-
* @run main/othervm PacketLossRetransmission server 16 client_key_exchange
6244
* @run main/othervm PacketLossRetransmission server 20 finished
63-
* @run main/othervm PacketLossRetransmission server 21 certificate_url
64-
* @run main/othervm PacketLossRetransmission server 22 certificate_status
65-
* @run main/othervm PacketLossRetransmission server 23 supplemental_data
6645
* @run main/othervm PacketLossRetransmission server -1 change_cipher_spec
6746
*/
6847

@@ -79,6 +58,7 @@
7958
public class PacketLossRetransmission extends DTLSOverDatagram {
8059
private static boolean isClient;
8160
private static byte handshakeType;
61+
private static final int TIMEOUT = 500;
8262

8363
private boolean needPacketLoss = true;
8464

@@ -87,6 +67,7 @@ public static void main(String[] args) throws Exception {
8767
handshakeType = Byte.parseByte(args[1]);
8868

8969
PacketLossRetransmission testCase = new PacketLossRetransmission();
70+
testCase.setSocketTimeout(TIMEOUT);
9071
testCase.runTest(testCase);
9172
}
9273

@@ -102,7 +83,7 @@ boolean produceHandshakePackets(SSLEngine engine, SocketAddress socketAddr,
10283
if (packet != null) {
10384
needPacketLoss = false;
10485

105-
System.out.println("Loss a packet of handshake messahe");
86+
System.out.println("Loss a packet of handshake message");
10687
packets.remove(packet);
10788
}
10889
}

0 commit comments

Comments
 (0)