End to end tests
This commit is contained in:
parent
c71e4b4cd0
commit
fed82d1ae8
26 changed files with 1016 additions and 37 deletions
|
|
@ -77,8 +77,26 @@ The local stack also mounts:
|
|||
|
||||
- `../bin/Face_Recognition_Unix` into the processor container as the matcher binary source
|
||||
- `../test_pkl` into both the public FaceAI container and the processor container as the shared read-only PKL dataset root
|
||||
- `./logs` into both the public FaceAI container and the processor container as the persistent diagnostics directory
|
||||
- `../www` into the PHP container so the real bridge files are used
|
||||
|
||||
The `processor` service is built from `docker/processor.Dockerfile`, which uses a Debian Trixie-based Node 22 image, applies the current package upgrades available during build, and installs `libxcb1` so the bundled Linux `face_matcher` binary can run locally.
|
||||
|
||||
### Persistent Logs
|
||||
|
||||
The checked-in local Compose stack now redirects the relevant Node service logs into `faceai/logs` on the host.
|
||||
|
||||
After `docker compose up --build`, inspect:
|
||||
|
||||
- `faceai/logs/backend.log` for backend startup and API-side failures
|
||||
- `faceai/logs/processor.log` for worker startup, queue processing, and uncaught processor errors
|
||||
- `faceai/logs/searches/<searchId>/worker.log` for the per-search processor trace
|
||||
- `faceai/logs/searches/<searchId>/matcher.log` for the native `face_matcher` output
|
||||
|
||||
This keeps the useful processor diagnostics outside the Docker-managed runtime volume so they survive container rebuilds and can be inspected directly from the workspace.
|
||||
|
||||
The current bundled Linux `face_matcher` binary is a PyInstaller build that requires `GLIBC_2.38` or newer and the `libxcb.so.1` runtime library. The checked-in local processor image satisfies that requirement.
|
||||
|
||||
### Run The Browser Test
|
||||
|
||||
Open:
|
||||
|
|
@ -115,6 +133,43 @@ If you want to stop and remove the local containers afterward, run:
|
|||
docker compose down
|
||||
```
|
||||
|
||||
### Automated End-To-End Test
|
||||
|
||||
The workspace now includes a Playwright suite that drives the PHP simulator, the FaceAI app, and the processor end to end.
|
||||
|
||||
From this folder, run:
|
||||
|
||||
```bash
|
||||
npm install
|
||||
npm run test:e2e:install
|
||||
npm run test:e2e
|
||||
```
|
||||
|
||||
The suite will:
|
||||
|
||||
- build the frontend bundle
|
||||
- start `docker compose up --build -d`
|
||||
- open `http://localhost:8080/faceai_simulator.php?raceId=202&lang=it`
|
||||
- click the `Face ID` launch button injected by `www/_js/rus-ecom-240621.js`
|
||||
- upload `test_pkl/test_images/DSC_1960.JPG`
|
||||
- wait for the processor to complete and for FaceAI to redirect to `faceai_return.php`
|
||||
- assert the filtered legacy result contains the expected `6` matches and includes `DSC_1960.JPG`
|
||||
- validate `faceai/logs/backend.log`, `faceai/logs/processor.log`, and the per-search `worker.log` and `matcher.log` for the run
|
||||
- stop the Compose stack automatically when the suite finishes
|
||||
|
||||
The default deterministic fixture can be overridden with environment variables if the dataset changes:
|
||||
|
||||
```bash
|
||||
FACEAI_E2E_SELFIE=DSC_1960.JPG
|
||||
FACEAI_E2E_EXPECTED_MATCH_COUNT=6
|
||||
```
|
||||
|
||||
If you want to keep the local containers running after the test for manual inspection, set:
|
||||
|
||||
```bash
|
||||
FACEAI_E2E_KEEP_STACK=1
|
||||
```
|
||||
|
||||
## Optional Backend And Frontend Dev Loop
|
||||
|
||||
If you only want to iterate on the app without the PHP simulator, you can still run the public site and the processor separately. The queue-backed flow now requires Redis and the processor, so `npm run dev` alone is no longer the full stack.
|
||||
|
|
@ -138,6 +193,8 @@ The public FaceAI site and the matcher runner can both use the same application
|
|||
- `npm run start` for the public site
|
||||
- `npm run start:processor` for the matcher runner
|
||||
|
||||
If that shared image also embeds or mounts the current Linux `face_matcher` build, make sure the base OS provides `GLIBC_2.38` or newer and includes `libxcb1`. A Debian Trixie-based image with that package installed satisfies the requirement; a Bookworm-based image does not.
|
||||
|
||||
### Production Compose Example
|
||||
|
||||
Replace the registry path, secrets, and host paths with the real deployment values.
|
||||
|
|
@ -148,6 +205,7 @@ services:
|
|||
image: registry.example.com/my-namespace/faceai:latest
|
||||
container_name: regalami-faceai
|
||||
restart: unless-stopped
|
||||
command: sh -c "mkdir -p /data/logs && npm run start >> /data/logs/backend.log 2>&1"
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
PORT: 3001
|
||||
|
|
@ -160,10 +218,12 @@ services:
|
|||
FACEAI_QUEUE_NAME: faceai-searches
|
||||
FACEAI_RUNTIME_ROOT: /data/runtime
|
||||
FACEAI_UPLOAD_ROOT: /data/runtime/uploads
|
||||
FACEAI_LOG_ROOT: /data/logs
|
||||
FACEAI_PKL_ROOT: /data/pkl
|
||||
FACEAI_ENABLE_LOCAL_LEGACY_STATIC: 0
|
||||
volumes:
|
||||
- faceai-runtime:/data/runtime
|
||||
- /srv/faceai/logs:/data/logs
|
||||
- /srv/faceai/pkl:/data/pkl:ro
|
||||
ports:
|
||||
- "127.0.0.1:3001:3001"
|
||||
|
|
@ -174,18 +234,20 @@ services:
|
|||
image: registry.example.com/my-namespace/faceai:latest
|
||||
container_name: regalami-faceai-processor
|
||||
restart: unless-stopped
|
||||
command: npm run start:processor
|
||||
command: sh -c "mkdir -p /data/logs && npm run start:processor >> /data/logs/processor.log 2>&1"
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
FACEAI_REDIS_URL: redis://redis:6379
|
||||
FACEAI_QUEUE_NAME: faceai-searches
|
||||
FACEAI_RUNTIME_ROOT: /data/runtime
|
||||
FACEAI_LOG_ROOT: /data/logs
|
||||
FACEAI_PKL_ROOT: /data/pkl
|
||||
FACEAI_MATCHER_BINARY: /opt/face-recognition/face_matcher
|
||||
FACEAI_WORKER_CONCURRENCY: 2
|
||||
FACEAI_WORKER_TIMEOUT_MS: 300000
|
||||
volumes:
|
||||
- faceai-runtime:/data/runtime
|
||||
- /srv/faceai/logs:/data/logs
|
||||
- /srv/faceai/pkl:/data/pkl:ro
|
||||
- /srv/faceai/bin/Face_Recognition_Unix:/opt/face-recognition:ro
|
||||
depends_on:
|
||||
|
|
@ -213,6 +275,7 @@ Shared application settings:
|
|||
| `FACEAI_REDIS_URL` | yes | `redis://redis:6379` | queue and search-state backend |
|
||||
| `FACEAI_QUEUE_NAME` | optional | `faceai-searches` | BullMQ queue name |
|
||||
| `FACEAI_RUNTIME_ROOT` | yes | `/data/runtime` | shared writable runtime root between site and processor |
|
||||
| `FACEAI_LOG_ROOT` | recommended | `/data/logs` | persistent host-mounted diagnostics root for backend, processor, and per-search logs |
|
||||
| `FACEAI_SHARED_SECRET` | yes | long random secret | trust boundary between FaceAI and the legacy bridge |
|
||||
|
||||
Public site settings:
|
||||
|
|
@ -311,6 +374,7 @@ FACEAI_REDIS_URL=redis://redis:6379
|
|||
FACEAI_QUEUE_NAME=faceai-searches
|
||||
FACEAI_RUNTIME_ROOT=/data/runtime
|
||||
FACEAI_UPLOAD_ROOT=/data/runtime/uploads
|
||||
FACEAI_LOG_ROOT=/data/logs
|
||||
FACEAI_PKL_ROOT=/data/pkl
|
||||
FACEAI_MATCHER_BINARY=/opt/face-recognition/face_matcher
|
||||
```
|
||||
|
|
@ -323,6 +387,8 @@ In the provided Docker Compose stack, that wiring is already done with:
|
|||
FACEAI_LEGACY_RETURN_URL=http://localhost:8080/faceai_return.php
|
||||
```
|
||||
|
||||
The log wiring is also already done in the checked-in Compose file with a host bind mount for `./logs:/data/logs`, so both the backend and the processor write persistent diagnostics into the workspace.
|
||||
|
||||
The local PHP simulator also needs the legacy bridge feature flag enabled:
|
||||
|
||||
```text
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue