uranusjr commented on code in PR #76269:
URL: https://github.com/apache/airflow/pull/76269#discussion_r4715324585
##########
java-sdk/sdk/src/test/kotlin/org/apache/airflow/sdk/execution/CommTest.kt:
##########
@@ -783,7 +725,7 @@ class CommsTest {
val healthy = async { comm.communicate<XComResult>(GetVariable().also
{ it.key = "b" }) }
fromClient.readOneRequest()
- toClient.writeFrame(unknownTypeFrame(0))
+ toClient.writeFrame(successFrame("SomeFutureMessage")(0))
Review Comment:
`"SomeFutureMessage"` is not a success reply, so the function should be
named something more neutral (to reuse the `[id, body, nil]` envelope).
##########
java-sdk/sdk/src/test/kotlin/org/apache/airflow/sdk/execution/CommTest.kt:
##########
@@ -108,53 +108,38 @@ class CommsTest {
Assertions.assertEquals(expected, actual)
}
+ private fun successFrame(
+ type: String,
+ vararg fields: Pair<String, Any>,
+ ): (Int) -> ByteArray =
+ { id ->
+ val out = ByteArrayOutputStream()
+ MessagePack.newDefaultPacker(out).use { packer ->
+ packer.packArrayHeader(3)
+ packer.packInt(id)
+ packer.packMapHeader(fields.size + 1)
+ packer.packString("type")
+ packer.packString(type)
+ for ((key, value) in fields) {
+ packer.packString(key)
+ when (value) {
+ is Int -> packer.packInt(value)
+ is Boolean -> packer.packBoolean(value)
+ is String -> packer.packString(value)
+ else -> error("unsupported fixture value: $value")
Review Comment:
msgpack-core helpers can remove the hand-written type switch and the runtime
`error` branch, and also support nested maps and nil if a later fixture needs
them. Fine to keep as is if you'd rather not make callers more verbose.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]