From 7c7bd4524ed81275b582aa116a670a6063ada462 Mon Sep 17 00:00:00 2001
From: "Embruch, Gerd" <gerd.embruch@uni-hamburg.de>
Date: Tue, 16 Jul 2024 14:35:37 +0200
Subject: [PATCH] added .env usage

---
 .env.template            |  3 +++
 README.md                |  1 -
 __tests__/prompting.yaml | 19 +++++++++++--------
 package.json             |  2 +-
 4 files changed, 15 insertions(+), 10 deletions(-)
 create mode 100644 .env.template

diff --git a/.env.template b/.env.template
new file mode 100644
index 0000000..805c8c0
--- /dev/null
+++ b/.env.template
@@ -0,0 +1,3 @@
+TARGET=https://localhost:8080
+EMAIL=valid@user.mail
+PASSWORD=superSecret123!
diff --git a/README.md b/README.md
index 25ee7fc..8f0bba9 100644
--- a/README.md
+++ b/README.md
@@ -24,7 +24,6 @@ cp ./.env.template ./.env
 - [PM2](https://pm2.keymetrics.io/)
 
 # Roadmap
-- [ ] write a starting nodeJS server
 - [ ] fetch existing api account from .env
 - [ ] create a artillery script to test login & fetch jwt
 - [ ] extend script to use JWT to send a prompt
diff --git a/__tests__/prompting.yaml b/__tests__/prompting.yaml
index 9b5f167..1bc74bf 100644
--- a/__tests__/prompting.yaml
+++ b/__tests__/prompting.yaml
@@ -1,17 +1,17 @@
 config:
   # This is a test server run by team Artillery
   # It's designed to be highly scalable
-  target: https://localhost:8080
+  target: "{{ $processEnvironment.TARGET}}"
   phases:
-    - duration: 10
+    - duration: 1
       arrivalRate: 1
       rampTo: 2
       name: Warm up phase
-    - duration: 20
+    - duration: 2
       arrivalRate: 2
       rampTo: 3
       name: Ramp up load
-    - duration: 10
+    - duration: 1
       arrivalRate: 3
       rampTo: 4
       name: Spike phase
@@ -30,10 +30,13 @@ config:
 scenarios:
   - flow:
       - loop:
+          - post:
+              url: '/users/login'
+              json:
+                email: "{{$processEnvironment.EMAIL}}"
+                password: "{{$processEnvironment.PASSWORD}}"
           - get:
-              url: '/ai/status'
-          # - get:
-          #     url: '/pony'
+              url: '/users/logout'
           # - get:
           #     url: '/armadillo'
-        count: 100
\ No newline at end of file
+        count: 1
\ No newline at end of file
diff --git a/package.json b/package.json
index cf70b94..0ffa300 100644
--- a/package.json
+++ b/package.json
@@ -4,7 +4,7 @@
   "description": "performance tests for RAGChat API",
   "main": "server.js",
   "scripts": {
-    "start": "artillery run -k ./__tests__/prompting.yaml --output ./reports/prompting.json ; artillery report --output ./reports/prompting.html ./reports/prompting.json"
+    "start": "artillery run -k --dotenv ./.env ./__tests__/prompting.yaml --output ./reports/prompting.json ; artillery report --output ./reports/prompting.html ./reports/prompting.json"
   },
   "author": "",
   "license": "ISC",
-- 
GitLab