# RFC 9946 §9: Stopping a Test

The 12 Requirements of RFC 9946 §9, each quoted from the RFC with its state and the tests that prove it. [Conformance](index.md) explains the states.

| State | Requirements |
|---|--:|
| Tested | 12 |

## RFC9946-9-1 {#RFC9946-9-1}

**Tested**

> When the test duration timer (testIntTime) on the server expires, it SHALL set the local connection test action to TEST_ACT_STOP1 (phase 1 of graceful termination).

Conformance Records: [server-test-interval-timer-runs-half-a-second-over](../conformance/interpretations.md#server-test-interval-timer-runs-half-a-second-over).

Proving tests:

- [`crates/udpstp-core/tests/stop_exchange.rs::the_test_stops_gracefully_when_the_servers_test_interval_ends`](https://github.com/pederbe/udpstp/blob/c88fe32e0973594682a069c58de24fd703714277/crates/udpstp-core/tests/stop_exchange.rs)

## RFC9946-9-2 {#RFC9946-9-2}

**Tested**

> Upon transmission of the next Load or Status PDUs, the server SHALL set the local connection test action to TEST_ACT_STOP2 (phase 2 of graceful termination) and mark any outgoing PDUs with a testAction value of TEST_ACT_STOP2.

Conformance Records: [stop-confirmation-waits](../conformance/interpretations.md#stop-confirmation-waits).

Proving tests:

- [`crates/udpstp-core/tests/stop_exchange.rs::the_test_stops_gracefully_when_the_servers_test_interval_ends`](https://github.com/pederbe/udpstp/blob/c88fe32e0973594682a069c58de24fd703714277/crates/udpstp-core/tests/stop_exchange.rs)
- [`crates/udpstp-core/tests/upstream.rs::an_upstream_test_stops_gracefully`](https://github.com/pederbe/udpstp/blob/c88fe32e0973594682a069c58de24fd703714277/crates/udpstp-core/tests/upstream.rs)

## RFC9946-9-3 {#RFC9946-9-3}

**Tested**

> While in this state, the server MAY reduce any Load PDU bursts to a size of one.

Conformance Records: [stop-bursts-of-one-without-add-on](../conformance/interpretations.md#stop-bursts-of-one-without-add-on).

Proving tests:

- [`crates/udpstp-core/tests/stop_exchange.rs::the_test_stops_gracefully_when_the_servers_test_interval_ends`](https://github.com/pederbe/udpstp/blob/c88fe32e0973594682a069c58de24fd703714277/crates/udpstp-core/tests/stop_exchange.rs)

## RFC9946-9-4 {#RFC9946-9-4}

**Tested**

> When the client receives a Load or Status PDU with the TEST_ACT_STOP2 indication, it SHALL finalize testing, display the test results, and mark its local connection with a test action of TEST_ACT_STOP2 (so that any PDUs subsequently received can be ignored).

Conformance Records: [stop-test-action-per-role](../conformance/interpretations.md#stop-test-action-per-role), [stop-ends-counting](../conformance/interpretations.md#stop-ends-counting).

Proving tests:

- [`crates/udpstp-core/tests/stop_exchange.rs::the_test_stops_gracefully_when_the_servers_test_interval_ends`](https://github.com/pederbe/udpstp/blob/c88fe32e0973594682a069c58de24fd703714277/crates/udpstp-core/tests/stop_exchange.rs)
- [`crates/udpstp-core/tests/stop_exchange.rs::only_stop2_stops_the_client_and_later_load_pdus_are_ignored`](https://github.com/pederbe/udpstp/blob/c88fe32e0973594682a069c58de24fd703714277/crates/udpstp-core/tests/stop_exchange.rs)
- [`crates/udpstp-core/tests/upstream.rs::an_upstream_test_stops_gracefully`](https://github.com/pederbe/udpstp/blob/c88fe32e0973594682a069c58de24fd703714277/crates/udpstp-core/tests/upstream.rs)

## RFC9946-9-5 {#RFC9946-9-5}

**Tested**

> With the test action of the client's connection set to TEST_ACT_STOP2, the very next expiry of a send timer, for either a Load or a Status PDU, SHALL result in it and any subsequent PDUs being sent with a testAction value of TEST_ACT_STOP2 (as confirmation to the server).

Proving tests:

- [`crates/udpstp-core/tests/stop_exchange.rs::the_test_stops_gracefully_when_the_servers_test_interval_ends`](https://github.com/pederbe/udpstp/blob/c88fe32e0973594682a069c58de24fd703714277/crates/udpstp-core/tests/stop_exchange.rs)
- [`crates/udpstp-core/tests/stop_exchange.rs::only_stop2_stops_the_client_and_later_load_pdus_are_ignored`](https://github.com/pederbe/udpstp/blob/c88fe32e0973594682a069c58de24fd703714277/crates/udpstp-core/tests/stop_exchange.rs)
- [`crates/udpstp-core/tests/upstream.rs::an_upstream_test_stops_gracefully`](https://github.com/pederbe/udpstp/blob/c88fe32e0973594682a069c58de24fd703714277/crates/udpstp-core/tests/upstream.rs)
- [`crates/udpstp-core/tests/upstream.rs::a_stop_status_pdu_does_not_change_the_rate`](https://github.com/pederbe/udpstp/blob/c88fe32e0973594682a069c58de24fd703714277/crates/udpstp-core/tests/upstream.rs)
- [`crates/udpstp-core/tests/upstream.rs::a_client_with_nothing_to_send_still_confirms_a_stop`](https://github.com/pederbe/udpstp/blob/c88fe32e0973594682a069c58de24fd703714277/crates/udpstp-core/tests/upstream.rs)

## RFC9946-9-6 {#RFC9946-9-6}

**Tested**

> While in this state, the client MAY reduce any Load PDU bursts to a size of one.

Conformance Records: [stop-bursts-of-one-without-add-on](../conformance/interpretations.md#stop-bursts-of-one-without-add-on).

Proving tests:

- [`crates/udpstp-core/tests/stop_exchange.rs::the_test_stops_gracefully_when_the_servers_test_interval_ends`](https://github.com/pederbe/udpstp/blob/c88fe32e0973594682a069c58de24fd703714277/crates/udpstp-core/tests/stop_exchange.rs)

## RFC9946-9-7 {#RFC9946-9-7}

**Tested**

> The client SHALL then schedule an immediate end time for the connection.

Proving tests:

- [`crates/udpstp-core/tests/stop_exchange.rs::the_test_stops_gracefully_when_the_servers_test_interval_ends`](https://github.com/pederbe/udpstp/blob/c88fe32e0973594682a069c58de24fd703714277/crates/udpstp-core/tests/stop_exchange.rs)

## RFC9946-9-8 {#RFC9946-9-8}

**Tested**

> When the server receives the TEST_ACT_STOP2 confirmation in the Load or Status PDU, the server SHALL schedule an immediate end time for the connection that closes the socket and deallocates the associated resources.

Conformance Records: [stop-test-action-per-role](../conformance/interpretations.md#stop-test-action-per-role).

Proving tests:

- [`crates/udpstp-core/tests/stop_exchange.rs::the_test_stops_gracefully_when_the_servers_test_interval_ends`](https://github.com/pederbe/udpstp/blob/c88fe32e0973594682a069c58de24fd703714277/crates/udpstp-core/tests/stop_exchange.rs)
- [`crates/udpstp-core/tests/upstream.rs::an_upstream_test_stops_gracefully`](https://github.com/pederbe/udpstp/blob/c88fe32e0973594682a069c58de24fd703714277/crates/udpstp-core/tests/upstream.rs)

## RFC9946-9-9 {#RFC9946-9-9}

**Tested**

> In a non-graceful test stop due to path failure, the watchdog timeouts at each endpoint will expire (sometimes at one endpoint first); notifications in logs, STDOUT, and/or formatted output SHALL be made; and the endpoint SHALL schedule an immediate end time for the connection.

Note: Timeouts per ADR 0002.

Proving tests:

- [`crates/udpstp-core/tests/timeouts.rs::a_downstream_path_that_breaks_stops_within_1_s_and_ends_at_3_s`](https://github.com/pederbe/udpstp/blob/c88fe32e0973594682a069c58de24fd703714277/crates/udpstp-core/tests/timeouts.rs)
- [`crates/udpstp-core/tests/timeouts.rs::an_upstream_client_stops_when_status_pdus_stop`](https://github.com/pederbe/udpstp/blob/c88fe32e0973594682a069c58de24fd703714277/crates/udpstp-core/tests/timeouts.rs)

## RFC9946-9-10 {#RFC9946-9-10}

**Tested**

> If an attacker clears the TEST_ACT_STOP2 indication, then the configured test duration timer (testIntTime) at the server and client SHALL take precedence and the endpoint SHALL schedule an immediate end time for the connection.

Proving tests:

- [`crates/udpstp-core/tests/stop_exchange.rs::a_cleared_stop_cannot_extend_the_test`](https://github.com/pederbe/udpstp/blob/c88fe32e0973594682a069c58de24fd703714277/crates/udpstp-core/tests/stop_exchange.rs)

## RFC9946-9-L1 {#RFC9946-9-L1}

**Tested**

> This is simply a non-reversible state awaiting the next message(s) to be sent from the server.

Note: TEST_ACT_STOP1.

Proving tests:

- [`crates/udpstp-core/tests/stop_exchange.rs::a_cleared_stop_cannot_extend_the_test`](https://github.com/pederbe/udpstp/blob/c88fe32e0973594682a069c58de24fd703714277/crates/udpstp-core/tests/stop_exchange.rs)

## RFC9946-9-L2 {#RFC9946-9-L2}

**Tested**

> During this time, any received Load or Status PDUs are processed normally.

Note: TEST_ACT_STOP1.

Conformance Records: [stop-status-pdus-are-not-classified](../conformance/interpretations.md#stop-status-pdus-are-not-classified).

Proving tests:

- [`crates/udpstp-core/tests/stop_exchange.rs::load_pdus_arriving_after_stop1_still_count`](https://github.com/pederbe/udpstp/blob/c88fe32e0973594682a069c58de24fd703714277/crates/udpstp-core/tests/stop_exchange.rs)

