This project is a TypeScript-based application that includes various tests for user pool management using Playwright. The project uses different testing strategies to ensure the proper functioning of user acquisition and release mechanisms.
centralized
: Centralized Locking Mechanism (Working solution if no horizontal scaling is required)express
: REST API for managing a user pool using Express.js, async-mutex (For horizontal scaling need to start Server before running tests)
file
: File-based user pool manager (No synchronization mechanism is implemented)mutex
: Custom Mutex implementation (Each worker creates its own mutex)
To install the project dependencies, run:
npm install
API server stars at `http://localhost:3002 automatically thanks to the playwright webServer configuration.
webServer: {
command: 'npx ts-node express/express.up.ts',
port: 3002,
reuseExistingServer: !process.env.CI,
timeout: 5 * 1000,
}
- acquire:
POST /acquire
curl -X POST http://localhost:3002/acquire \
-H "Content-Type: application/json" \
-d '{"role": "roleName", "workerId": "worker1"}'
- release:
POST /release
curl -X POST http://localhost:3002/release \
-H "Content-Type: application/json" \
-d '{"role": "roleName", "workerId": "worker1"}'
- get all:
GET /pool
curl -X GET http://localhost:3002/pool
- release all:
POST /release-all
curl -X POST http://localhost:3002/release-all
npx ts-node express/express.up.ts