mengw15 commented on code in PR #7744:
URL: https://github.com/apache/texera/pull/7744#discussion_r3816572738
##########
amber/src/test/scala/org/apache/texera/web/service/LakekeeperClientSpec.scala:
##########
@@ -65,13 +71,44 @@ class LakekeeperClientSpec
exchange.close()
}
+ // Lakekeeper purges dropped tables asynchronously (queue `tabular_purge`),
and
+ // answers a warehouse delete with 409 WarehouseHasUnfinishedTasks while any
+ // purge task is pending (#7742). These stub warehouses model that queue:
+ // `racing` drains after two attempts, `alwaysBusy` never drains, and
+ // `otherConflict` 409s for an unrelated reason (which must NOT be retried).
+ private val racingWarehouseId = UUID.randomUUID()
+ private val alwaysBusyWarehouseId = UUID.randomUUID()
+ private val otherConflictWarehouseId = UUID.randomUUID()
+ private val malformedConflictWarehouseId = UUID.randomUUID()
+ private val unfinishedTasksBody =
+ """{"error":{"message":"Warehouse has unfinished tasks. Cannot delete
warehouse until all tasks are
finished.","type":"WarehouseHasUnfinishedTasks","code":409}}"""
+
server.createContext(
"/management/v1/warehouse",
(exchange: HttpExchange) => {
record(exchange)
if (exchange.getRequestMethod == "POST") {
lastCreateBody = new String(exchange.getRequestBody.readAllBytes(),
StandardCharsets.UTF_8)
respond(exchange, 201, s"""{"warehouse-id": "$warehouseId"}""")
+ } else if (exchange.getRequestMethod == "DELETE") {
+ val path = exchange.getRequestURI.getPath
+ if (path.endsWith(racingWarehouseId.toString)) {
+ if (deleteAttempts(racingWarehouseId) <= 2) respond(exchange, 409,
unfinishedTasksBody)
+ else respond(exchange, 204, "")
+ } else if (path.endsWith(alwaysBusyWarehouseId.toString)) {
+ respond(exchange, 409, unfinishedTasksBody)
+ } else if (path.endsWith(malformedConflictWarehouseId.toString)) {
+ // A 409 whose body isn't the JSON envelope the type check reads.
+ respond(exchange, 409, "<html>gateway conflict</html>")
+ } else if (path.endsWith(otherConflictWarehouseId.toString)) {
+ respond(
+ exchange,
+ 409,
+ """{"error":{"message":"warehouse is in
use","type":"Conflict","code":409}}"""
+ )
+ } else {
+ respond(exchange, 200, "{}")
+ }
} else {
respond(exchange, 200, "{}")
}
Review Comment:
Done — flattened to a single match on (method, path).
--
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]