Skip to content

Commit 36d9888

Browse files
committed
add simulator to mimic tasks usage
1 parent daa427e commit 36d9888

File tree

4 files changed

+690
-1
lines changed

4 files changed

+690
-1
lines changed

shell.nix

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pkgs.mkShell {
3131
python
3232
python.pkgs.pip
3333
python.pkgs.virtualenv
34+
python.pkgs.requests
3435
nodejs
3536
pkgs.docker
3637
dockerCompose
@@ -80,6 +81,11 @@ pkgs.mkShell {
8081
fi
8182
fi
8283
84+
run-simulator() {
85+
echo ">>> Running simulator"
86+
(cd "$PROJECT_ROOT/simulator" && ${pkgs.python313}/bin/python3 main.py)
87+
}
88+
8389
start-docker() {
8490
echo ">>> Starting PostgreSQL, Redis and Keycloak via Docker..."
8591
(cd "$PROJECT_ROOT" && ${dockerCompose}/bin/docker-compose -f $DOCKER_COMPOSE_FILE up -d postgres redis keycloak)
@@ -153,6 +159,6 @@ pkgs.mkShell {
153159
}
154160
155161
echo ">>> Environment ready."
156-
echo "Commands: run-dev-backend, run-dev-web, run-dev-all, run-alembic, psql-dev, redis-cli-dev, clean-dev"
162+
echo "Commands: run-dev-backend, run-dev-web, run-dev-all, run-alembic, psql-dev, redis-cli-dev, clean-dev, start-docker, stop-docker, run-simulator"
157163
'';
158164
}

simulator/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Simulator
2+
3+
This tool simulates clinic traffic for the helpwave tasks application. It authenticates with Keycloak using the `tasks-web` client and performs random actions on the GraphQL API.
4+
5+
**⚠️ DEVELOPMENT USE ONLY**
6+
This script is designed solely for development and testing environments to mimic user behavior on the tasks application. Do not run this against production environments.
7+
8+
## Features
9+
10+
- **Authentication**: Implements OpenID Connect Authorization Code flow with a local callback server.
11+
- **Initial Population**: Automatically creates a hospital structure (Clinic, Wards, Rooms, Beds) and patients if the database is empty.
12+
- **Traffic Simulation**:
13+
- Creates new patients.
14+
- Creates tasks with random due dates assigned to patients.
15+
- Randomly assigns tasks to the logged-in user.
16+
- Updates task statuses (Done/Reopened).
17+
- Moves patients between locations.
18+
- Discharges (deletes) patients.
19+
20+
## Prerequisites
21+
22+
- Python 3.10+
23+
- The `helpwave tasks` stack (Backend, Keycloak, Postgres) must be running.

0 commit comments

Comments
 (0)