Browse Source

TT#14008 ICE test robustness

The order between receiving the STUN success and the triggered check is
not guaranteed, therefore resolve possible race condition by expecting
the two packets in either order.

Change-Id: Ibef9907cd4116bc5f3b7d17d936007c8efcabd3b
(cherry picked from commit 7b8fa51cc1)
mr10.5.2
Richard Fuchs 3 years ago
parent
commit
1936c50ec2
2 changed files with 57 additions and 19 deletions
  1. +2
    -2
      perl/NGCP/Rtpengine/AutoTest.pm
  2. +55
    -17
      t/auto-daemon-tests.pl

+ 2
- 2
perl/NGCP/Rtpengine/AutoTest.pm View File

@ -212,10 +212,10 @@ sub rcv {
like $p, $match, 'received packet matches';
my @matches = $p =~ $match;
for my $m (@matches) {
if (length($m) == 2) {
if (defined($m) && length($m) == 2) {
($m) = unpack('n', $m);
}
elsif (length($m) == 4) {
elsif (defined($m) && length($m) == 4) {
($m) = unpack('N', $m);
}
}


+ 55
- 17
t/auto-daemon-tests.pl View File

@ -34,7 +34,7 @@ my $pcma_5 = "\xad\xac\xa2\xa6\xbd\x9a\x06\x3f\x26\x2d\x2c\x2d\x26\x3f\x06\x9a\x
my ($sock_a, $sock_b, $sock_c, $sock_d, $port_a, $port_b, $ssrc, $ssrc_b, $resp,
$sock_ax, $sock_bx, $port_ax, $port_bx,
$srtp_ctx_a, $srtp_ctx_b, $srtp_ctx_a_rev, $srtp_ctx_b_rev, $ufrag_a, $ufrag_b,
@ret1, @ret2, @ret3, @ret4, $srtp_key_a, $srtp_key_b, $ts, $seq);
@ret1, @ret2, @ret3, @ret4, $srtp_key_a, $srtp_key_b, $ts, $seq, $has_recv);
@ -377,21 +377,40 @@ rcv($sock_b, -1, qr/^\x00\x01\x00.\x21\x12\xa4\x42/s);
my ($packet, $tid) = stun_req(1, 65527, 1, 'q27e93', $ufrag_a, $ufrag_b);
snd($sock_c, $port_a, $packet);
# receive STUN success
rcv($sock_c, $port_a, qr/^\x01\x01\x00.\x21\x12\xa4\x42\Q$tid\E/s);
$has_recv = 0;
# receive triggered STUN check
@ret1 = rcv($sock_c, $port_a, qr/^\x00\x01\x00.\x21\x12\xa4\x42(............)\x80\x22\x00.rtpengine/s);
while ($has_recv != 3) {
# receive STUN packet, either triggered check or success
@ret2 = rcv($sock_c, $port_a, qr/^\x01(\x01)\x00.\x21\x12\xa4\x42\Q$tid\E|^\x00\x01\x00.\x21\x12\xa4\x42(............)\x80\x22\x00.rtpengine/s);
if (@ret2[0]) {
# STUN success
$has_recv |= 1;
}
elsif (@ret2[1]) {
# triggered check
@ret1 = @ret2;
$has_recv |= 2;
}
}
# respond with success
snd($sock_c, $port_a, stun_succ($port_a, $ret1[0], 'bd5e8b8d6dd8e1bc6'));
snd($sock_c, $port_a, stun_succ($port_a, $ret1[1], 'bd5e8b8d6dd8e1bc6'));
# repeat for RTCP
($packet, $tid) = stun_req(1, 65527, 2, 'q27e93', $ufrag_a, $ufrag_b);
snd($sock_d, $port_ax, $packet);
rcv($sock_d, $port_ax, qr/^\x01\x01\x00.\x21\x12\xa4\x42\Q$tid\E/s);
@ret1 = rcv($sock_d, $port_ax, qr/^\x00\x01\x00.\x21\x12\xa4\x42(............)\x80\x22\x00.rtpengine/s);
snd($sock_d, $port_ax, stun_succ($port_b, $ret1[0], 'bd5e8b8d6dd8e1bc6'));
$has_recv = 0;
while ($has_recv != 3) {
@ret2 = rcv($sock_d, $port_ax, qr/^\x01(\x01)\x00.\x21\x12\xa4\x42\Q$tid\E|^\x00\x01\x00.\x21\x12\xa4\x42(............)\x80\x22\x00.rtpengine/s);
if (@ret2[0]) {
$has_recv |= 1;
}
elsif (@ret2[1]) {
@ret1 = @ret2;
$has_recv |= 2;
}
}
snd($sock_d, $port_ax, stun_succ($port_b, $ret1[1], 'bd5e8b8d6dd8e1bc6'));
@ -463,21 +482,40 @@ rcv($sock_b, -1, qr/^\x00\x01\x00.\x21\x12\xa4\x42/s);
my ($packet, $tid) = stun_req(0, 65527, 1, 'q27e93', $ufrag_a, $ufrag_b);
snd($sock_c, $port_a, $packet);
# receive STUN success
rcv($sock_c, $port_a, qr/^\x01\x01\x00.\x21\x12\xa4\x42\Q$tid\E/s);
$has_recv = 0;
# receive triggered STUN check
@ret1 = rcv($sock_c, $port_a, qr/^\x00\x01\x00.\x21\x12\xa4\x42(............)\x80\x22\x00.rtpengine/s);
while ($has_recv != 3) {
# receive STUN packet, either triggered check or success
@ret2 = rcv($sock_c, $port_a, qr/^\x01(\x01)\x00.\x21\x12\xa4\x42\Q$tid\E|^\x00\x01\x00.\x21\x12\xa4\x42(............)\x80\x22\x00.rtpengine/s);
if (@ret2[0]) {
# STUN success
$has_recv |= 1;
}
elsif (@ret2[1]) {
# triggered check
@ret1 = @ret2;
$has_recv |= 2;
}
}
# respond with success
snd($sock_c, $port_a, stun_succ($port_a, $ret1[0], 'bd5e8b8d6dd8e1bc6'));
snd($sock_c, $port_a, stun_succ($port_a, $ret1[1], 'bd5e8b8d6dd8e1bc6'));
# repeat for RTCP
($packet, $tid) = stun_req(0, 65527, 2, 'q27e93', $ufrag_a, $ufrag_b);
snd($sock_d, $port_ax, $packet);
rcv($sock_d, $port_ax, qr/^\x01\x01\x00.\x21\x12\xa4\x42\Q$tid\E/s);
@ret1 = rcv($sock_d, $port_ax, qr/^\x00\x01\x00.\x21\x12\xa4\x42(............)\x80\x22\x00.rtpengine/s);
snd($sock_d, $port_ax, stun_succ($port_b, $ret1[0], 'bd5e8b8d6dd8e1bc6'));
$has_recv = 0;
while ($has_recv != 3) {
@ret2 = rcv($sock_d, $port_ax, qr/^\x01(\x01)\x00.\x21\x12\xa4\x42\Q$tid\E|^\x00\x01\x00.\x21\x12\xa4\x42(............)\x80\x22\x00.rtpengine/s);
if (@ret2[0]) {
$has_recv |= 1;
}
elsif (@ret2[1]) {
@ret1 = @ret2;
$has_recv |= 2;
}
}
snd($sock_d, $port_ax, stun_succ($port_b, $ret1[1], 'bd5e8b8d6dd8e1bc6'));
# wait for nominations
@ret1 = rcv($sock_c, $port_a, qr/^\x00\x01\x00.\x21\x12\xa4\x42(............)\x80\x22\x00.rtpengine.*\x00\x25/s);


Loading…
Cancel
Save