# Test connector conformance (https://docs.openetl.io/docs/next/build-connectors/test)

Use the conformance kit after you build a connector. The example command uses the source from [Write a source in Go](./write-source.md).

## Test it with the conformance kit [#test-it-with-the-conformance-kit]

The [conformance kit](../../sdk/go/conformance) tests connectors through the protocol. It supports connectors in any implementation language.

Source checks cover:

- Specifications and configuration schemas.
- Connection checks and their items.
- A preflight of every discovered stream.
- Discovery, reads and resumption. Reads give each stream the declared types that discovery returned.
- Reads that stop at a redo's `until` or complete at its `complete_at`.
- Continuous reads, of streams read whole and of streams in splits.

Destination checks cover:

- A preflight of the suite's streams.
- Commits, recovery at each commit step and fencing.
- Write modes, schema changes, types and type-change refusal.
- Holds and writer lanes.

For a destination with lane commits, checks commit each lane independently. They settle each committable on a writer of its lane. They also rewrite a lost lane's part.

Run it from the CLI:

```sh
openetl connector test --config config.json ./bin/source-greetings
```

```text
PASS spec
PASS check
SKIP errors
    the suite has neither BadCredentials nor Unreachable
SKIP setup
    the connector has no setup
PASS discover
PASS preflight
PASS read/full
SKIP read/resume
    no stream sent a resume point
SKIP read/until
    the suite doesn't say the source stops at until
SKIP read/incremental
    the suite reads no stream incrementally
SKIP read/complete-at
    the suite doesn't say the source completes at complete_at
SKIP read/committed
    the source doesn't acknowledge, so the platform never calls Committed
SKIP read/continuous
    the suite reads no stream with cdc or stream
SKIP read/continuous-splits
    the source doesn't split streams
source-greetings: 14 checks, 5 passed, 0 failed, 9 skipped
```

`--bad-credentials` and `--unreachable` add configs for the errors check, and `--add-records-command` lets the incremental and complete-at checks add records upstream. A destination's checks that write need `--read-command`, which prints what the destination made visible; they are skipped without it. `openetl connector test -h` has the details.

The until check runs only for a source that stops at `until`: pass `--stops-at-until`, or set `StopsAtUntil` in Go. The check reads from a resume point, with the next resume point's state as `until`. It expects the records between the two and nothing past them, then a resume point and a completion at `until`. It also reads from the last resume point with no `until`, and expects a completion at the state the first read completed at.

The complete-at check runs only for a source that completes at `complete_at`: pass `--stops-at-completion` and `--add-records-command`, or set `StopsAtCompletion` and `AddRecords` in Go. For each stream that completed with a state, the check first adds records upstream. It leaves out a stream that gets none, since a source that ignores `complete_at` would pass there. It then reads from the stream's last resume point, with the state the stream completed at as `complete_at`. It expects the records between the two and none that the first read did not return. It then expects a completion at `complete_at`, and nothing after it.

The continuous-splits check runs only for a source whose spec declares `splits` (`Splits` in `sdk.Connector`). It also needs a stream that the suite reads with `cdc` or `stream`. The check asks the source for the splits of each such stream, and keeps the streams with more than one split. It reads these streams whole in a bounded read, then in splits, continuously with one lane, as [Splits and lanes](./protocol.md#splits-and-lanes) describes. It expects every record of the bounded read, and fails if the read then ends. It then expects the records that `--add-records-command` adds upstream. In each split that gets some of them, it expects a resume point of that split after them.

The other checks read each stream whole, so the until and complete-at checks give a stream's `until` and `complete_at`, not a split's. A source that reads splits gets the same fields on each `Split`, and its own tests cover that.

In Go, a connector's own tests run the same checks with `conformance.SourceSuite` or `conformance.DestinationSuite` and `Test(t)`, as every official connector does in its `conformance_test.go`.

## Secrets in test configs [#secrets-in-test-configs]

Give each secret in the suite's configs a distinctive value. The kit fails a connector whose `Check` or preflight shows a secret's value in any text. It finds the value as a substring, so a short or common value also matches text that does not show it. For example, the secret `openetl` matches the path `_openetl/check-1`.

The kit refuses such a value before it checks for leaks. It refuses a non-empty secret in any of the suite's configs, with bad credentials and an unreachable upstream included, if one of these is true:

- The value has fewer than 12 characters.
- The value appears in a value of the same config that is not a secret.

The `spec` check fails and names the secret by its path, such as `config.password`, and not by its value. If `--run` leaves out `spec`, the first check that looks for leaks fails instead. To fix it, use a value of at least 12 characters that appears nowhere else in the config, such as `conformance-test-password`. Set your test upstream to accept the same value.
