Merge "Add configurable payload size to sendPing() in ApfIntegrationTest" into main

This commit is contained in:
Treehugger Robot 2024-05-30 03:15:42 +00:00 • committed by Gerrit Code Review
commit 6f0898e41b

View file

@ -192,8 +192,8 @@ class ApfIntegrationTest {
futureReply!!.complete(recvbuf.sliceArray(8..<length))
}
fun sendPing(data: ByteArray) {
require(data.size == 56)
fun sendPing(data: ByteArray, payloadSize: Int) {
require(data.size == payloadSize)
// rfc4443#section-4.1: Echo Request Message
// 0 1 2 3
@ -415,8 +415,9 @@ class ApfIntegrationTest {
readProgram() // wait for install completion
// Assert that initial ping does not get filtered.
val data = ByteArray(56).also { Random.nextBytes(it) }
packetReader.sendPing(data)
val payloadSize = 56
val data = ByteArray(payloadSize).also { Random.nextBytes(it) }
packetReader.sendPing(data, payloadSize)
assertThat(packetReader.expectPingReply()).isEqualTo(data)
// Generate an APF program that drops the next ping
@ -436,7 +437,7 @@ class ApfIntegrationTest {
installProgram(program)
readProgram() // wait for install completion
packetReader.sendPing(data)
packetReader.sendPing(data, payloadSize)
packetReader.expectPingDropped()
}
@ -478,8 +479,9 @@ class ApfIntegrationTest {
readProgram() // wait for install completion
// Trigger the program by sending a ping and waiting on the reply.
val data = ByteArray(56).also { Random.nextBytes(it) }
packetReader.sendPing(data)
val payloadSize = 56
val data = ByteArray(payloadSize).also { Random.nextBytes(it) }
packetReader.sendPing(data, payloadSize)
packetReader.expectPingReply()
val readResult = readProgram()
@ -512,8 +514,9 @@ class ApfIntegrationTest {
installProgram(gen.generate())
readProgram() // wait for install completion
val data = ByteArray(56).also { Random.nextBytes(it) }
packetReader.sendPing(data)
val payloadSize = 56
val data = ByteArray(payloadSize).also { Random.nextBytes(it) }
packetReader.sendPing(data, payloadSize)
packetReader.expectPingReply()
var buffer = ByteBuffer.wrap(readProgram(), counterRegion, 4 /* length */)
@ -521,7 +524,7 @@ class ApfIntegrationTest {
Thread.sleep(5100)
packetReader.sendPing(data)
packetReader.sendPing(data, payloadSize)
packetReader.expectPingReply()
buffer = ByteBuffer.wrap(readProgram(), counterRegion, 4 /* length */)