From 395d23cee901279a7cb95b9b3e9bd40bfdb8462a Mon Sep 17 00:00:00 2001
From: Philipp Theyssen
Date: Sun, 26 Feb 2023 20:02:27 +0100
Subject: [PATCH] Start working on scenario files for workload generation
---
scenario-definition/README.md | 41 +++++++++++++
.../operations/op_basket_add_item.json | 39 ++++++++++++
.../operations/op_basket_checkout.json | 0
.../operations/op_catalog_add_item.json | 61 +++++++++++++++++++
.../operations/op_catalog_get_items.json | 12 ++++
.../operations/op_catalog_update_price.json | 0
.../transactions/add_items_to_basket.json | 18 ++++++
7 files changed, 171 insertions(+)
create mode 100644 scenario-definition/README.md
create mode 100644 scenario-definition/operations/op_basket_add_item.json
create mode 100644 scenario-definition/operations/op_basket_checkout.json
create mode 100644 scenario-definition/operations/op_catalog_add_item.json
create mode 100644 scenario-definition/operations/op_catalog_get_items.json
create mode 100644 scenario-definition/operations/op_catalog_update_price.json
create mode 100644 scenario-definition/transactions/add_items_to_basket.json
diff --git a/scenario-definition/README.md b/scenario-definition/README.md
new file mode 100644
index 000000000..e53938362
--- /dev/null
+++ b/scenario-definition/README.md
@@ -0,0 +1,41 @@
+# Scenario Definition for EshopOnContainers
+
+To use the simulation framework for microservices you have
+to specify a scenario/workload using json (configuration) files.
+
+The configuration files consist of:
+
+- operations: a HTTP request
+- transactions: multiple operations sequentially chained together
+- scenario: specifies which transactions are run and other workload
+ configuration like distribution, arguments the transaction should use etc.
+
+
+The scenario should simulate a workload the microservice application would
+experience during a given timespan in production.
+
+
+
+## Scenario for eshopOnContainers
+
+Arguments and Dynamic Variables for Transactions:
+- userId
+- productId
+
+
+Transactions:
+- Customer reads items, adds item to basket, checkouts basket
+- Customer adds item to basket, removes again, logs out
+- Price update transaction
+- Stock replenished for catalog item
+- Catalog item is removed
+- create Order draft
+- Order cancel
+
+
+
+Workload configuration:
+- dataskew on catalog items (distribution of which items are accessed/bought)
+- distribution between different transactions
+- how many concurrent transactions
+- how many total transactions to be executed
diff --git a/scenario-definition/operations/op_basket_add_item.json b/scenario-definition/operations/op_basket_add_item.json
new file mode 100644
index 000000000..f314d5d20
--- /dev/null
+++ b/scenario-definition/operations/op_basket_add_item.json
@@ -0,0 +1,39 @@
+{
+ "id": "basket-add-item",
+ "type": "http",
+ "httpMethod": "post",
+ "arguments": [
+ {
+ "name": "items",
+ "required": true,
+ "type": "object"
+ },
+ {
+ "name": "buyerId",
+ "required": true,
+ "type": "guid"
+ },
+ ],
+ "dynamicVariables": [
+ {
+ "name": "basket-item-id",
+ "type": "unsignedInt"
+ }
+ ]
+ "payload": {
+ "type": "json",
+ "content": {
+ "buyerId": "{{buyerId}}",
+ "items": [
+ "id": "1",
+ "productId": "{{items}}",
+ "productName": "string",
+ "unitPrice": 0,
+ "oldUnitPrice": 0,
+ "quantity": 0,
+ "pictureUrl": ""
+ ]
+ }
+ },
+ "url": "http://localhost:5101/catalog-api/api/v1/Basket"
+}
diff --git a/scenario-definition/operations/op_basket_checkout.json b/scenario-definition/operations/op_basket_checkout.json
new file mode 100644
index 000000000..e69de29bb
diff --git a/scenario-definition/operations/op_catalog_add_item.json b/scenario-definition/operations/op_catalog_add_item.json
new file mode 100644
index 000000000..e2c1155fe
--- /dev/null
+++ b/scenario-definition/operations/op_catalog_add_item.json
@@ -0,0 +1,61 @@
+{
+ "id": "catalog-add-item",
+ "type": "http",
+ "httpMethod": "post",
+ "dynamicVariables": [
+ {
+ "name": "item-name",
+ "type": "string"
+ },
+ {
+ "name": "item-description",
+ "type": "string"
+ },
+ {
+ "name": "price",
+ "type": "unsignedInt"
+ },
+ {
+ "name": "brand-name",
+ "type": "string"
+ },
+ {
+ "name": "available-stock",
+ "type": "unsignedInt"
+ },
+ {
+ "name": "restock-threshold",
+ "type": "unsignedInt"
+ },
+ {
+ "name": "max-stock-threshold",
+ "type": "unsignedInt"
+ }
+ ]
+ "payload": {
+ "type": "json",
+ "content": {
+ "id": 0,
+ "name": "{{item-name}}",
+ "description": "{{item-description}}",
+ "price": "{{price}}",
+ "pictureFileName": "",
+ "pictureUri": "",
+ "catalogTypeId": 1,
+ "catalogType": {
+ "id": 0,
+ "type": ""
+ },
+ "catalogBrandId": 1,
+ "catalogBrand": {
+ "id": 1,
+ "brand": "{{brand-name}}"
+ },
+ "availableStock": "{{available-stock}}",
+ "restockThreshold": "{{restock-threshold}}",
+ "maxStockThreshold": "{{max-stock-threshold}}",
+ "onReorder": true
+ }
+ },
+ "url": "http://localhost:5101/catalog-api/api/v1/Catalog/items"
+}
diff --git a/scenario-definition/operations/op_catalog_get_items.json b/scenario-definition/operations/op_catalog_get_items.json
new file mode 100644
index 000000000..c7527c4e7
--- /dev/null
+++ b/scenario-definition/operations/op_catalog_get_items.json
@@ -0,0 +1,12 @@
+{
+ "id": "catalog-get-items",
+ "type": "http",
+ "httpMethod": "get",
+ "queryParameters": [
+ {
+ "key": "pageSize",
+ "value": 3
+ }
+ ],
+ "url": "http://localhost:5101/catalog-api/api/v1/Catalog/items"
+}
diff --git a/scenario-definition/operations/op_catalog_update_price.json b/scenario-definition/operations/op_catalog_update_price.json
new file mode 100644
index 000000000..e69de29bb
diff --git a/scenario-definition/transactions/add_items_to_basket.json b/scenario-definition/transactions/add_items_to_basket.json
new file mode 100644
index 000000000..72618a0f8
--- /dev/null
+++ b/scenario-definition/transactions/add_items_to_basket.json
@@ -0,0 +1,18 @@
+transaction:
+{
+ "id": "add-items-to-basket",
+ "operations": [
+ {
+ operationRefId: "catalog-get-items",
+ id: "op-1",
+ },
+ {
+ operationRefId: "op-id-2",
+ id: "second-op-in-this-transaction",
+ arguments: [
+ userId,
+ @first-op-in-this-transaction.response.id
+ ]
+ }
+ ]
+}