Skip to content

Commit

Permalink
Merge pull request #804 from tamird/deflake-xdp
Browse files Browse the repository at this point in the history
integration/xdp: increase timeout to 60 seconds
  • Loading branch information
tamird authored Oct 2, 2023
2 parents c547dd7 + 81268b7 commit 0cd620a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions test/integration-test/src/tests/xdp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 0cd620a

Please sign in to comment.