mirror of
https://github.com/s-frick/effigenix.git
synced 2026-03-28 10:19: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("mvStockBatchId", stockBatchIds.get(rnd.nextInt(stockBatchIds.size())))
|
||||||
.set("mvBatchRef", "LT-CHARGE-%06d".formatted(rnd.nextInt(999999)))
|
.set("mvBatchRef", "LT-CHARGE-%06d".formatted(rnd.nextInt(999999)))
|
||||||
.set("mvQty", "%d.0".formatted(rnd.nextInt(1, 30)));
|
.set("mvQty", "%d.0".formatted(rnd.nextInt(1, 30)));
|
||||||
}).exec(
|
}).doIf(session -> session.contains("mvStockId")).then(
|
||||||
|
exec(
|
||||||
http("Bestandsbewegung erfassen")
|
http("Bestandsbewegung erfassen")
|
||||||
.post("/api/inventory/stock-movements")
|
.post("/api/inventory/stock-movements")
|
||||||
.header("Authorization", "Bearer #{accessToken}")
|
.header("Authorization", "Bearer #{accessToken}")
|
||||||
.body(StringBody("""
|
.body(StringBody("""
|
||||||
{"stockId":"#{mvStockId}","articleId":"#{mvArticleId}","stockBatchId":"#{mvStockBatchId}","batchId":"#{mvBatchRef}","batchType":"PRODUCED","movementType":"GOODS_RECEIPT","quantityAmount":"#{mvQty}","quantityUnit":"KILOGRAM"}"""))
|
{"stockId":"#{mvStockId}","articleId":"#{mvArticleId}","stockBatchId":"#{mvStockBatchId}","batchId":"#{mvBatchRef}","batchType":"PRODUCED","movementType":"GOODS_RECEIPT","quantityAmount":"#{mvQty}","quantityUnit":"KILOGRAM"}"""))
|
||||||
.check(status().is(201))
|
.check(status().is(201))
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -142,9 +142,29 @@ public final class ProductionScenario {
|
||||||
// Charge planen für Order-Start (separate Batch, wird nicht direkt gestartet)
|
// Charge planen für Order-Start (separate Batch, wird nicht direkt gestartet)
|
||||||
.exec(planBatch())
|
.exec(planBatch())
|
||||||
.pause(1, 2)
|
.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
|
// Produktionsauftrag anlegen, freigeben und mit Charge starten
|
||||||
.exec(createProductionOrder())
|
.exec(createProductionOrder())
|
||||||
.pause(1, 2)
|
.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(
|
.doIf(session -> session.contains("productionOrderId") && session.contains("batchId")).then(
|
||||||
exec(releaseProductionOrder())
|
exec(releaseProductionOrder())
|
||||||
.pause(1, 2)
|
.pause(1, 2)
|
||||||
|
|
@ -155,6 +175,16 @@ public final class ProductionScenario {
|
||||||
// Separate Charge planen → starten → abschließen (unabhängiger Workflow)
|
// Separate Charge planen → starten → abschließen (unabhängiger Workflow)
|
||||||
.exec(planBatch())
|
.exec(planBatch())
|
||||||
.pause(1, 2)
|
.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(
|
.doIf(session -> session.contains("batchId")).then(
|
||||||
exec(startBatch())
|
exec(startBatch())
|
||||||
.pause(2, 5)
|
.pause(2, 5)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue