mirror of
https://github.com/s-frick/effigenix.git
synced 2026-03-28 10:09:35 +01:00
fix(loadtest): robustere Szenarien für bedingte Requests
- InventoryScenario.recordStockMovement(): HTTP-Request mit doIf guards, verhindert 'No attribute mvStockId' Fehler - ProductionScenario.productionWorkflow(): Seeded Batch-/Order-IDs als Fallback wenn planBatch/createProductionOrder fehlschlägt, stellt sicher dass startBatch/completeBatch/releaseProductionOrder immer feuern und Gatling-Assertions Stats sammeln können
This commit is contained in:
parent
a23c5a8985
commit
14b59722f7
2 changed files with 39 additions and 7 deletions
|
|
@ -141,13 +141,15 @@ public final class InventoryScenario {
|
|||
.set("mvStockBatchId", stockBatchIds.get(rnd.nextInt(stockBatchIds.size())))
|
||||
.set("mvBatchRef", "LT-CHARGE-%06d".formatted(rnd.nextInt(999999)))
|
||||
.set("mvQty", "%d.0".formatted(rnd.nextInt(1, 30)));
|
||||
}).exec(
|
||||
http("Bestandsbewegung erfassen")
|
||||
.post("/api/inventory/stock-movements")
|
||||
.header("Authorization", "Bearer #{accessToken}")
|
||||
.body(StringBody("""
|
||||
{"stockId":"#{mvStockId}","articleId":"#{mvArticleId}","stockBatchId":"#{mvStockBatchId}","batchId":"#{mvBatchRef}","batchType":"PRODUCED","movementType":"GOODS_RECEIPT","quantityAmount":"#{mvQty}","quantityUnit":"KILOGRAM"}"""))
|
||||
.check(status().is(201))
|
||||
}).doIf(session -> session.contains("mvStockId")).then(
|
||||
exec(
|
||||
http("Bestandsbewegung erfassen")
|
||||
.post("/api/inventory/stock-movements")
|
||||
.header("Authorization", "Bearer #{accessToken}")
|
||||
.body(StringBody("""
|
||||
{"stockId":"#{mvStockId}","articleId":"#{mvArticleId}","stockBatchId":"#{mvStockBatchId}","batchId":"#{mvBatchRef}","batchType":"PRODUCED","movementType":"GOODS_RECEIPT","quantityAmount":"#{mvQty}","quantityUnit":"KILOGRAM"}"""))
|
||||
.check(status().is(201))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -142,9 +142,29 @@ public final class ProductionScenario {
|
|||
// Charge planen für Order-Start (separate Batch, wird nicht direkt gestartet)
|
||||
.exec(planBatch())
|
||||
.pause(1, 2)
|
||||
// Fallback: Seeded Batch-ID nutzen, falls planBatch fehlschlug
|
||||
.exec(session -> {
|
||||
if (!session.contains("batchId")) {
|
||||
var ids = LoadTestDataSeeder.batchIds();
|
||||
if (ids != null && !ids.isEmpty()) {
|
||||
return session.set("batchId", ids.get(ThreadLocalRandom.current().nextInt(ids.size())));
|
||||
}
|
||||
}
|
||||
return session;
|
||||
})
|
||||
// Produktionsauftrag anlegen, freigeben und mit Charge starten
|
||||
.exec(createProductionOrder())
|
||||
.pause(1, 2)
|
||||
// Fallback: Seeded ProductionOrder-ID nutzen, falls createProductionOrder fehlschlug
|
||||
.exec(session -> {
|
||||
if (!session.contains("productionOrderId")) {
|
||||
var ids = LoadTestDataSeeder.productionOrderIds();
|
||||
if (ids != null && !ids.isEmpty()) {
|
||||
return session.set("productionOrderId", ids.get(ThreadLocalRandom.current().nextInt(ids.size())));
|
||||
}
|
||||
}
|
||||
return session;
|
||||
})
|
||||
.doIf(session -> session.contains("productionOrderId") && session.contains("batchId")).then(
|
||||
exec(releaseProductionOrder())
|
||||
.pause(1, 2)
|
||||
|
|
@ -155,6 +175,16 @@ public final class ProductionScenario {
|
|||
// Separate Charge planen → starten → abschließen (unabhängiger Workflow)
|
||||
.exec(planBatch())
|
||||
.pause(1, 2)
|
||||
// Fallback: Seeded Batch-ID nutzen
|
||||
.exec(session -> {
|
||||
if (!session.contains("batchId")) {
|
||||
var ids = LoadTestDataSeeder.batchIds();
|
||||
if (ids != null && !ids.isEmpty()) {
|
||||
return session.set("batchId", ids.get(ThreadLocalRandom.current().nextInt(ids.size())));
|
||||
}
|
||||
}
|
||||
return session;
|
||||
})
|
||||
.doIf(session -> session.contains("batchId")).then(
|
||||
exec(startBatch())
|
||||
.pause(2, 5)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue