Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,13 @@ and [Semantic Versioning](https://semver.org/).
([#574](https://github.com/OpenTollGate/tollgate-module-basic-go/pull/574)).

### Changed / Internal
- **The parent tests README is a map of the test estate again.** It
documented only the hardware data-measurement harness; it now points
at every environment (cloud-lab, hardware fleet, contract, packaging,
sim, happy-path) and names the cloud-lab as the default for
logic-level work.
([#570](https://github.com/OpenTollGate/tollgate-module-basic-go/pull/570))


- **The module can report the gates it believes it holds, so the ones nothing
else examines are reachable.** `valve.TrackedGates()` returns a sorted,
Expand Down
62 changes: 48 additions & 14 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,92 @@
# TollGate Automated Testing

This directory contains automated tests for the TollGate module.

## Data Measurement Test

The `test_data_measurement.py` script is designed to validate the data allotment enforcement feature of the TollGate. It orchestrates a test between a client machine (where you run the test) and a remote server to simulate a high-volume data stream.
This directory contains the automated test estate. It splits into two
very different worlds — pick the right one for the job:

| Environment | What it is | Where |
|---|---|---|
| **cloud-lab** | Docker-compose integration lab: the real tollgate binary + self-hosted cdk-mintd FakeWallet mints, pytest driver, no routers needed. Payment/fee/rotation/failure lanes, the run-scoped `lab.sh` runner and the shared-host runbook. | [cloud-lab/](cloud-lab/), start with its [README](cloud-lab/README.md) |
| **hardware fleet** | The pytest suite in this directory, against real routers over SSH/Wi-Fi (flashing, install, e2e payment, teardown). Credentials are env-only — see [`.env.example`](.env.example). | this directory + [flash_routers.py](flash_routers.py) |
| **contract** | Offline invariants: schema lint, build purity, dependency/import checks, mirror sync. | [contract/](contract/) |
| **packaging** | Asserts over built artifacts: portal-bundle contract, artifact contents, nodogsplash dependency. | [packaging/](packaging/) |
| **sim** | Offline renewal-policy simulation with committed results. | [sim/](sim/) |
| **happy-path** | Published-artifact happy-path regression suite. | [happy-path/](happy-path/) |

The cloud-lab is the default for anything logic-level (payments, fees,
sessions, mints); the hardware fleet is the only place router-visible
behavior (portal, Wi-Fi, gate) is real. Before running anything on a
host shared with other sessions, read
[cloud-lab/RUNBOOK.md](cloud-lab/RUNBOOK.md) (on the runner branch;
until it merges, the short version: use per-checkout
`COMPOSE_PROJECT_NAME`, strip host ports, tear down with
`down -v --remove-orphans`).

## Hardware fleet: data measurement test

The `test_data_measurement.py` script is designed to validate the data
allotment enforcement feature of the TollGate. It orchestrates a test
between a client machine (where you run the test) and a remote server to
simulate a high-volume data stream.

### Prerequisites

1. A remote server with SSH access. The test is pre-configured for a server at `188.40.151.90`.
2. SSH key-based authentication should be configured for the `root` user on the server to allow the script to connect without a password.
1. A remote server with SSH access. The test is pre-configured for a
server at `188.40.151.90`.
2. SSH key-based authentication should be configured for the `root`
user on the server to allow the script to connect without a
password.
3. Python 3 and `venv` on your local machine.

### Setup and Execution

To ensure a clean and isolated environment, these tests should be run within a Python virtual environment.
To ensure a clean and isolated environment, these tests should be run
within a Python virtual environment.

**1. Create the Virtual Environment**

From the project's root directory (`tollgate-module-basic-go`), create a virtual environment named `.venv`:
From the project's root directory (`tollgate-module-basic-go`), create a
virtual environment named `.venv`:

```bash
python3 -m venv .venv
```

**2. Activate the Virtual Environment**

Activate the environment to use its isolated set of packages. Your terminal prompt will change to indicate that the environment is active.
Activate the environment to use its isolated set of packages. Your
virtual environment prompt will change to indicate that the environment
is active.

```bash
source .venv/bin/activate
```

**3. Install Dependencies**

Install the necessary Python packages (`pytest` and `paramiko`) into the virtual environment:
Install the necessary Python packages (`pytest` and `paramiko`) into the
virtual environment:

```bash
pip install -r tests/requirements.txt
```

**4. Run the Test**

Execute the test script using `pytest`. The `-s` flag ensures you can see the interactive prompts, and the `-v` flag provides verbose output.
Execute the test script using `pytest`. The `-s` flag ensures you can
see the interactive prompts, and the `-v` flag provides verbose output.

```bash
pytest -sv tests/test_data_measurement.py
```

The test will then guide you through the process of connecting to the TollGate Wi-Fi and paying the captive portal before it begins the data stream test.
The test will then guide you through the process of connecting to the
TollGate Wi-Fi and paying the captive portal before it begins the data
stream test.

**5. Deactivate the Environment (Optional)**

When you are finished testing, you can deactivate the virtual environment and return to your normal shell:
When you are finished testing, you can deactivate the virtual
environment and return to your normal shell.

```bash
deactivate
Expand Down