From 2f2d9020cd4eaab26b4159fd87e1220211e35a63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 21 Aug 2018 12:17:54 +0200 Subject: [PATCH] Add delay in test to avoid race condition We previously observed random-looking failures from this test. I think they were caused by a race condition where the client tries to reconnect while the server is still closing the connection and has not yet returned to an accepting state. In that case, the server would fail to see and reply to the ClientHello, and the client would have to resend it. I believe logs of failing runs are compatible with this interpretation: - the proxy logs show the new ClientHello and the server's closing Alert are sent the same millisecond. - the client logs show the server's closing Alert is received after the new handshake has been started (discarding message from wrong epoch). The attempted fix is for the client to wait a bit before reconnecting, which should vastly enhance the probability of the server reaching its accepting state before the client tries to reconnect. The value of 1 second is arbitrary but should be more than enough even on loaded machines. The test was run locally 100 times in a row on a slightly loaded machine (an instance of all.sh running in parallel) without any failure after this fix. --- tests/ssl-opt.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 4a6234803..f811789e6 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -5139,6 +5139,8 @@ run_test "DTLS fragmenting: proxy MTU, simple handshake" \ # Since we don't support reading fragmented ClientHello yet, # up the MTU to 1450 (larger than ClientHello with session ticket, # but still smaller than client's Certificate to ensure fragmentation). +# reco_delay avoids races where the client reconnects before the server has +# resumed listening, which would result in a spurious resend. not_with_valgrind # spurious resend due to timeout requires_config_enabled MBEDTLS_SSL_PROTO_DTLS requires_config_enabled MBEDTLS_RSA_C @@ -5152,7 +5154,7 @@ run_test "DTLS fragmenting: proxy MTU, resumed handshake" \ "$P_CLI dtls=1 debug_level=2 \ crt_file=data_files/server8_int-ca2.crt \ key_file=data_files/server8.key \ - mtu=1450 reconnect=1" \ + mtu=1450 reconnect=1 reco_delay=1" \ 0 \ -S "resend" \ -C "resend" \