Commit d65efabf authored by Eduard Štefan Mlynárik's avatar Eduard Štefan Mlynárik
Browse files

scenario finalised, fix seed, add to readme

parent 2c295ecd
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ Afterward you gain a bearer token, which you can use to access other services.
Go to main project directory and run`python scenario.py`
Scenario will run correctly only in linux systems or in wsl, databases and services need to be started via docker-compose.
Before running the scenario, you need to change the token in the scenario.py file to your token you got from the security server.
In the scenario, you can see how the services work together and how the basic usage of the system might look like.


### Metrics and monitoring
+3 −3
Original line number Diff line number Diff line
@@ -40,10 +40,10 @@ insert into purchase_history (purchase_id, customer_id, purchased_at, wine_ext_i
values (4, 11, '2023-04-04', 444, 100, 10);

insert into feedback(id, rating, created_at, wine_ext_id, customer_id)
values (2, 4, '2023-02-02', 222, 22);
values (50, 4, '2023-02-02', 222, 22);

insert into feedback(id, rating, created_at, wine_ext_id, customer_id)
values (3, 3, '2023-03-03', 333, 33);
values (51, 3, '2023-03-03', 333, 33);

insert into feedback(id, rating, created_at, wine_ext_id, customer_id)
values (4, 2, '2023-04-04', 444, 33);
values (52, 2, '2023-04-04', 444, 33);
+11 −6
Original line number Diff line number Diff line
import subprocess
import time
import requests

print("!!!WELCOME TO THE WINE MANAGERY SYSTEM SCENARIO!!!" + "\n")
# this is something that simply had to be added to make the scenario work on first time run
subprocess.run(["bash", "./database-management/seed-all.sh"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)

print("Lets start with clear database")
print("Cleaning the database..." + "\n")
subprocess.run(["bash", "./database-management/clean-all.sh"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
time.sleep(2)

headers = {
    'Authorization': 'Bearer eyJraWQiOiJyc2ExIiwidHlwIjoiYXQrand0IiwiYWxnIjoiUlMyNTYifQ.eyJhdWQiOiI3ZTAyYTBhOS00NDZhLTQxMmQtYWQyYi05MGFkZDQ3YjBmZGQiLCJzdWIiOiI1MTQxNDhAbXVuaS5jeiIsImFjciI6Imh0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zIgdGVzdF8xIHRlc3RfcmVhZCBvcGVuaWQgcHJvZmlsZSBlZHVwZXJzb25fc2NvcGVkX2FmZmlsaWF0aW9uIHRlc3Rfd3JpdGUgZW1haWwgdGVzdF81IiwiYXV0aF90aW1lIjoxNzE1NzA4MDk3LCJpc3MiOiJodHRwczovL29pZGMubXVuaS5jei9vaWRjLyIsImV4cCI6MTcxNjM5MzczOCwiaWF0IjoxNzE2MzkwMTM4LCJjbGllbnRfaWQiOiI3ZTAyYTBhOS00NDZhLTQxMmQtYWQyYi05MGFkZDQ3YjBmZGQiLCJqdGkiOiI2YjhkYzA1OC0zMzMwLTQwNGQtYjk2Mi1jZTQxMDFmZmM1M2UifQ.XEKCDplat0dPS-GO3tNZHql-b4KzC0FvK3QUDCSs3LCdCj1hLYac6ABHqQsFX4URCQRzH0PnDkFhnNjLrTQ6qdo8MhX0Wpt_8ByZBK0Z1X9vuDGuLdKeiu6H7bdhDJ9Ydc0uHDHAuF-sG5MZeTKefkJ_gLHbK2IdTjFSCfBSwFqXO9v8IgrC3R5rUVrugK4L66JL-NaZIsqaiOCSmY7jlGd5qokmDBiSgiYj3K1OcLlmBc8banAo59__N3cngy_k38IcK30fMhBCmtWd3jAg2bho4ssHXG_HZR2HtcNk06kDVvXMCwHnkOCXbaN_DQDfh17El39psxLRlQwcnrFBNQ'
}

print("As we can see, new grape has grown at our vineyard!")
@@ -44,7 +45,7 @@ print(create_harvest.text + "\n")
print("Lets now put some more data into the system!")
print("Seeding the database..." + "\n")
res = subprocess.run(["bash", "./database-management/seed-all.sh"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
time.sleep(3)

print("For new wine creation we need to know recipe a.k.a production process. Which production processes are present in the system?")
print("[WINE PRODUCTION] Production processes available:")
available_processes = requests.get("http://localhost:8083/productionProcess", headers=headers)
@@ -84,11 +85,13 @@ grape_list = requests.get('http://localhost:8082/grape/list', headers=headers)
for item in grape_list.json():
    print(item)
print("\n")

print("[INVENTORY MANAGER] Ingredients in stock:")
ingredient_list = requests.get('http://localhost:8082/ingredient/list', headers=headers)
for item in ingredient_list.json():
    print(item)
print("\n")

print("[INVENTORY MANAGER] Wine in stock:")
product_list = requests.get('http://localhost:8082/wine/list', headers=headers)
for item in product_list.json():
@@ -97,7 +100,7 @@ for item in product_list.json():
print("Buying wine...")
buy_wine = requests.post(
    'http://localhost:8084/purchase/single',
    json={'id': 123, 'customerId': 11, 'purchasedAt': '2021-01-01T17:52:07.994459792Z', 'wineBottleExtId': '111',
    json={'customerId': 11, 'purchasedAt': '2021-01-01T17:52:07.994459792Z', 'wineBottleExtId': '111',
          'quantity': 1, 'price': 10},
    headers=headers
)
@@ -129,6 +132,7 @@ create_invoice = requests.post(
    },
    headers=headers
)

print("[CUSTOMER SERVICE] Invoice created:")
print(create_invoice.text + "\n")

@@ -145,6 +149,7 @@ leave_feedback = requests.post(
    headers=headers
)
print(leave_feedback.text + "\n")

print("Now let's see all the feedbacks our customer posted!")
print("[CUSTOMER SERVICE] Feedbacks for our customer:")
feedbacks = requests.get('http://localhost:8084/feedback/customer?customerId=11', headers=headers)