Add unit and integration tests for VexCandidateEmitter and SmartDiff repositories
- Implemented comprehensive unit tests for VexCandidateEmitter to validate candidate emission logic based on various scenarios including absent and present APIs, confidence thresholds, and rate limiting. - Added integration tests for SmartDiff PostgreSQL repositories, covering snapshot storage and retrieval, candidate storage, and material risk change handling. - Ensured tests validate correct behavior for storing, retrieving, and querying snapshots and candidates, including edge cases and expected outcomes.
This commit is contained in:
@@ -16,7 +16,7 @@ contributors who need to extend coverage or diagnose failures.
|
||||
| **1. Unit** | `xUnit` (<code>dotnet test</code>) | `*.Tests.csproj` | per PR / push |
|
||||
| **2. Property‑based** | `FsCheck` | `SbomPropertyTests` | per PR |
|
||||
| **3. Integration (API)** | `Testcontainers` suite | `test/Api.Integration` | per PR + nightly |
|
||||
| **4. Integration (DB-merge)** | in-memory Mongo + Redis | `Concelier.Integration` (vulnerability ingest/merge/export service) | per PR |
|
||||
| **4. Integration (DB-merge)** | Testcontainers PostgreSQL + Redis | `Concelier.Integration` (vulnerability ingest/merge/export service) | per PR |
|
||||
| **5. Contract (gRPC)** | `Buf breaking` | `buf.yaml` files | per PR |
|
||||
| **6. Front‑end unit** | `Jest` | `ui/src/**/*.spec.ts` | per PR |
|
||||
| **7. Front‑end E2E** | `Playwright` | `ui/e2e/**` | nightly |
|
||||
@@ -52,67 +52,36 @@ contributors who need to extend coverage or diagnose failures.
|
||||
./scripts/dev-test.sh --full
|
||||
````
|
||||
|
||||
The script spins up MongoDB/Redis via Testcontainers and requires:
|
||||
The script spins up PostgreSQL/Redis via Testcontainers and requires:
|
||||
|
||||
* Docker ≥ 25
|
||||
* Node 20 (for Jest/Playwright)
|
||||
* Docker ≥ 25
|
||||
* Node 20 (for Jest/Playwright)
|
||||
|
||||
#### Mongo2Go / OpenSSL shim
|
||||
#### PostgreSQL Testcontainers
|
||||
|
||||
Multiple suites (Concelier connectors, Excititor worker/WebService, Scheduler)
|
||||
fall back to [Mongo2Go](https://github.com/Mongo2Go/Mongo2Go) when a developer
|
||||
does not have a local `mongod` listening on `127.0.0.1:27017`. **This is a
|
||||
test-only dependency**: production/dev runtime MongoDB always runs inside the
|
||||
compose/k8s network using the standard StellaOps cryptography stack. Modern
|
||||
distros ship OpenSSL 3 by default, so when Mongo2Go starts its embedded
|
||||
`mongod` you **must** expose the legacy OpenSSL 1.1 libraries that binary
|
||||
expects:
|
||||
use Testcontainers with PostgreSQL for integration tests. If you don't have
|
||||
Docker available, tests can also run against a local PostgreSQL instance
|
||||
listening on `127.0.0.1:5432`.
|
||||
|
||||
1. From the repo root, export the provided binaries before running any tests:
|
||||
|
||||
```bash
|
||||
export LD_LIBRARY_PATH="$(pwd)/tests/native/openssl-1.1/linux-x64:${LD_LIBRARY_PATH:-}"
|
||||
```
|
||||
|
||||
2. (Optional) If you only need the shim for a single command, prefix it:
|
||||
|
||||
```bash
|
||||
LD_LIBRARY_PATH="$(pwd)/tests/native/openssl-1.1/linux-x64" \
|
||||
dotnet test src/Concelier/StellaOps.Concelier.sln --nologo
|
||||
```
|
||||
|
||||
3. CI runners or dev containers should either copy
|
||||
`tests/native/openssl-1.1/linux-x64/libcrypto.so.1.1` and `libssl.so.1.1`
|
||||
into a directory that is already on the default library path, or export the
|
||||
`LD_LIBRARY_PATH` value shown above before invoking `dotnet test`.
|
||||
|
||||
The shim lives under `tests/native/openssl-1.1/README.md` with upstream source
|
||||
and licensing details. When the system already has OpenSSL 1.1 installed you
|
||||
can skip this step.
|
||||
|
||||
#### Local Mongo helper
|
||||
#### Local PostgreSQL helper
|
||||
|
||||
Some suites (Concelier WebService/Core, Exporter JSON) need a full
|
||||
`mongod` instance when you want to debug outside of Mongo2Go (for example to
|
||||
inspect data with `mongosh` or pin a specific server version). A thin wrapper
|
||||
is available under `tools/mongodb/local-mongo.sh`:
|
||||
PostgreSQL instance when you want to debug or inspect data with `psql`.
|
||||
A helper script is available under `tools/postgres/local-postgres.sh`:
|
||||
|
||||
```bash
|
||||
# download (cached under .cache/mongodb-local) and start a local replica set
|
||||
tools/mongodb/local-mongo.sh start
|
||||
|
||||
# reuse an existing data set
|
||||
tools/mongodb/local-mongo.sh restart
|
||||
# start a local PostgreSQL instance
|
||||
tools/postgres/local-postgres.sh start
|
||||
|
||||
# stop / clean
|
||||
tools/mongodb/local-mongo.sh stop
|
||||
tools/mongodb/local-mongo.sh clean
|
||||
tools/postgres/local-postgres.sh stop
|
||||
tools/postgres/local-postgres.sh clean
|
||||
```
|
||||
|
||||
By default the script downloads MongoDB 6.0.16 for Ubuntu 22.04, binds to
|
||||
`127.0.0.1:27017`, and initialises a single-node replica set called `rs0`. The
|
||||
current URI is printed on start, e.g.
|
||||
`mongodb://127.0.0.1:27017/?replicaSet=rs0`, and you can export it before
|
||||
By default the script uses Docker to run PostgreSQL 16, binds to
|
||||
`127.0.0.1:5432`, and creates a database called `stellaops`. The
|
||||
connection string is printed on start and you can export it before
|
||||
running `dotnet test` if a suite supports overriding its connection string.
|
||||
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user