# Features — test_harness

Evidence date: 2026-10-01.

Source: `git@bitbucket.org:overdrive/test_harness.git`, `main` at `9f2f006` (2025-03-17).

Status words: **Current** means the file is on `main` and something in the tree calls it, or it is itself an entry point. **Partial** means the file is present and does not line up with the path, variable, or README that is supposed to use it. **Standalone** means implemented and not referenced by the server, the pipeline test script, or the shell wrappers. **Documented** means the README states it. **Removed** means a later commit deleted it.

## Current

### Express health check

- **Status:** Current.
- **What:** `GET /health` returns `{ "status": "healthy" }`.
- **Where:** `src/server.js`. Also the success check in `scripts/validate_service.sh`.
- **Provenance:** **Implemented**. **Documented** in `README.md`.

### HTTP trigger for one k6 script

- **Status:** Current.
- **What:** `POST /trigger-test` with `{ "lambdaUrl" }` runs `k6 run src/k6-script.js` and returns stdout/stderr when the process exits. Missing `lambdaUrl` returns 400.
- **Where:** `src/server.js`.
- **Provenance:** **Implemented**. **Documented** request shape in `README.md`.

### Original k6 scenario file

- **Status:** Current as the only script the server and `npm test` run. The load shape in the README is not the active options.
- **What:** 600 VUs for 7.2 seconds. Each iteration POSTs one JSON fix. Course coordinates are inline (53 rows). Several fields are random. Checks status 200 and duration under 500 ms.
- **Where:** `src/k6-script.js`. `package.json` script `test`. Pipeline step "Build and Test".
- **Provenance:** **Implemented**. Ramp stages are comments. Added in `d05f843`, rewritten in `e16fe88`.

### Course coordinate list

- **Status:** Current.
- **What:** 53 points named like `Hole 1 Fairway` through `Hole 18 Green`, plus `Halfway` (`hole` null, `number` 28). `number` 29 is absent. The same sequence is inlined twice and exported once.
- **Where:** `src/fixData.js` (export used by the memory-oriented script), inline arrays in `src/k6-script.js` and `src/k6-script-updated.js`.
- **Provenance:** **Implemented** since `e16fe88` / `e89320a`. The course name is not in the data.

### Constant-arrival-rate k6 script with CSV summary

- **Status:** Standalone.
- **What:** Arrival rate from `BATCH_SIZE` and `WAIT_TIME_MS`, duration from day/hour/minute env vars, default URL on the `lt19abpplb` API Gateway host, `handleSummary` writes `results.csv`.
- **Where:** `src/k6-script-updated.js`.
- **Provenance:** **Implemented** in `e16fe88` (small edit in `e89320a`). No caller in the repo.

### Memory-oriented k6 script

- **Status:** Current relative to the shell wrapper, which names this file. The wrapper's loop variable does not start it (see Partial).
- **What:** Constant arrival rate, default batch 121, wait 400 ms, duration 7 days. Custom metrics `response_time` and `error_rate`. Reuses one payload object. Imports `./fixData.js`. `http.post` receives the object rather than a JSON string.
- **Where:** `src/K6-Updated-MemEfficientS3Archive.js`.
- **Provenance:** **Implemented** in `e89320a`.

### SQS Lambda handler

- **Status:** Standalone source. Not deployed by the pipeline.
- **What:** Parse `event.body`, require `fixes` array, validate each fix, send one SQS message or batches of 10, return 200, 400, or 500.
- **Where:** `lambda-sqs-handler/index.js`, `lambda-sqs-handler/package.json`, `lambda-sqs-handler/README.md`.
- **Provenance:** **Implemented** and **Documented** in that README. Commit `3448466`.

### Bitbucket pipeline and CodeDeploy hooks

- **Status:** Current as YAML and shell. Live account state was not checked.
- **What:** `npm install` and `npm test` on the default pipeline and on `main`. `main` then uploads a zip and creates a CodeDeploy deployment. Hooks install Node, k6, and PM2, write `.env`, start `src/server.js`, and curl `/health`.
- **Where:** `bitbucket-pipelines.yml`, `appspec.yml`, `scripts/before_install.sh`, `scripts/after_install.sh`, `scripts/start_application.sh`, `scripts/validate_service.sh`.
- **Provenance:** **Implemented** since `d05f843`. **Documented** in `README.md`.

### SSM Automation template and IAM role template

- **Status:** Current as files. Application to an AWS account was not verified.
- **What:** Document `TestHarnessConfiguration` installs packages and unpacks `s3://k6testharnessrepo/test_harness.zip` onto instances tagged `tagmarshal-test-harness-test-instance`. Role `SSM-Automation-TestHarness-ConfigRole` allows SSM, EC2 describe, and `iam:PassRole` to `ssm.amazonaws.com`.
- **Where:** `scripts/TagmarshalTestHarnessSSMDocument V1.yaml`, `scripts/TagmarshalTestHarnessSSMDocumentExecRole V1.yaml`.
- **Provenance:** **Implemented** as templates in `9f2f006`. The role description still says "MongoDB Config Servers".

### Docker image definition

- **Status:** Standalone.
- **What:** `node:18-slim`, install k6 from the k6 apt repo, `npm install`, expose 3000, `npm start`.
- **Where:** `Dockerfile`.
- **Provenance:** **Implemented** since `d05f843`. **Documented** as a feature bullet in `README.md`. The pipeline and `appspec.yml` do not build it.

### Committed sample results

- **Status:** Current file, historical content.
- **What:** `results.csv` with the six metrics produced by `handleSummary` in `src/k6-script-updated.js`. Counts: 169702 HTTP requests, the same number stored under "Failed Requests", average response about 267 ms, p95 about 277 ms, 339012 successful checks, 392 failed checks.
- **Where:** `results.csv`, added in `e16fe88`.
- **Provenance:** **Implemented** output stored in git. Not regenerated for this document.

## Partial

### Multi-process launcher

- **Status:** Partial.
- **What:** Starts N wrapper processes, waits for pid files, concatenates CSV metrics from disk and from S3, uploads `aggregated_metrics.csv`.
- **Where:** `src/start_k6_processes.sh`, `src/run_k6_wrapper.sh`. README manual steps.
- **Gap:** Both the README and the starter look for `src/newversion/run_k6_wrapper.sh` and `src/newversion/start_k6_processes.sh`. Git has those scripts in `src/` only. The wrapper assigns `totalSeconds` and reads `total_seconds`. The k6 binary path inside the wrapper is absolute under `/home/ssm-user/test_harness/src/K6-Updated-MemEfficientS3Archive.js`, which matches the source file name but not the `newversion` layout used everywhere else in the same script.
- **Provenance:** **Implemented** in `e89320a`. **Documented** in the README block added in the same commit.

### CodeDeploy k6 install

- **Status:** Partial.
- **What:** `scripts/before_install.sh` is written for `yum` and also appends a Debian `deb` line for `dl.k6.io` before `yum install k6`.
- **Where:** `scripts/before_install.sh`.
- **Provenance:** **Implemented**. Whether this succeeds on the real AMI is **Unknown**.

### Pipeline test step

- **Status:** Partial.
- **What:** `npm test` runs k6. The pipeline image is `atlassian/default-image:3` and the step does not install k6. The script under test POSTs to the hard-coded default URL when `LAMBDA_URL` is unset.
- **Where:** `bitbucket-pipelines.yml`, `package.json`, `src/k6-script.js`.
- **Provenance:** **Implemented**. Outcome of a real pipeline run is **Unknown**.

### README ramp-up and "up to 1000 concurrent users"

- **Status:** Documented, not the active options.
- **Where:** `README.md` "Features" and "Load Test Configuration". The matching `options` block in `src/k6-script.js` is commented out.
- **Provenance:** **Documented**. The active options are **Implemented** as 600 VUs and 7.2 seconds.

## Removed

### `results.json`

- **Status:** Removed.
- **What:** A one-line file added in `e16fe88` and deleted in `e89320a`.
- **Provenance:** Git history. The file is not on `main`.

## Not in this repository

- SonarQube project file and `sonarqube_scan.bat`. The onboarding scan listed both names. They are not in `9f2f006`.
- A consumer for the SQS queue.
- The API implementation behind `/Stage/device/fix/<id>`.
- Authentication, a UI, or a database.
- Automated unit tests for the Lambda or the Express routes.

## Recently changed (last commits on `main`)

| Date | Commit | Change |
|---|---|---|
| 2025-03-17 | `9f2f006` | SSM document and IAM role YAML |
| 2025-03-17 | `e89320a` | Memory-oriented k6 script, `fixData.js`, shell wrappers, README install block; `results.json` removed |
| 2025-03-05 | `e16fe88` | Course list, `k6-script-updated.js`, `results.csv` |
| 2025-02-13 | `3448466` | `lambda-sqs-handler/` |
| 2025-02-13 | `d05f843` | Server, first k6 script, Docker, CodeDeploy, pipeline, README |

No commit on `main` is newer than 2025-03-17.
