Browse Source

Merge pull request #804 from tamird/deflake-xdp

integration/xdp: increase timeout to 60 seconds
Tamir Duberstein 1 year ago
parent
commit
0cd620a9da
1 changed files with 9 additions and 6 deletions
  1. 9 6
      test/integration-test/src/tests/xdp.rs

+ 9 - 6
test/integration-test/src/tests/xdp.rs

@@ -82,17 +82,20 @@ fn cpumap_chain() {
     xdp.load().unwrap();
     xdp.attach("lo", XdpFlags::default()).unwrap();
 
-    let sock = UdpSocket::bind("127.0.0.1:1777").unwrap();
-    sock.set_read_timeout(Some(Duration::from_millis(1)))
+    const PAYLOAD: &str = "hello cpumap";
+
+    let sock = UdpSocket::bind("127.0.0.1:0").unwrap();
+    let addr = sock.local_addr().unwrap();
+    sock.set_read_timeout(Some(Duration::from_secs(60)))
         .unwrap();
-    sock.send_to(b"hello cpumap", "127.0.0.1:1777").unwrap();
+    sock.send_to(PAYLOAD.as_bytes(), addr).unwrap();
 
-    // Read back the packet to ensure it wenth through the entire network stack, including our two
+    // Read back the packet to ensure it went through the entire network stack, including our two
     // probes.
-    let mut buf = vec![0u8; 1000];
+    let mut buf = [0u8; PAYLOAD.len() + 1];
     let n = sock.recv(&mut buf).unwrap();
 
-    assert_eq!(&buf[..n], b"hello cpumap");
+    assert_eq!(&buf[..n], PAYLOAD.as_bytes());
     assert_eq!(hits.get(&0, 0).unwrap(), 1);
     assert_eq!(hits.get(&1, 0).unwrap(), 1);
 }