1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
//! Deterministic simulation testing helpers.
//!
//! The goal of the DST harness is to validate the engine's
//! concurrency-sensitive behavior using real production components under
//! deterministic time and deterministic interleavings. Rather than
//! reimplementing shutdown, timers, or Ack/Nack unwinding in a separate
//! simulator, the harness runs the real
//! [`crate::message::ProcessorInbox`],
//! [`crate::message::ExporterInbox`],
//! [`RuntimeCtrlMsgManager`], and [`PipelineCompletionMsgDispatcher`] on the
//! same kind of single-threaded runtime used by local engine components.
//!
//! The harness combines three ingredients:
//!
//! - [`SimClock`], which gives tests explicit control over deadlines and timer
//! wakeups
//! - [`DstRng`], a tiny deterministic RNG used to vary scenario timing and
//! control bursts while remaining replayable from a seed
//! - [`dst_seeds`], which combines fixed regression seeds with optional
//! environment-driven random-seed sweeps via `DST_SEED` and `DST_SEEDS`
//!
//! The current engine DST scenarios cover:
//!
//! - `dst_inbox_seeded`: bounded-fair progress between control and
//! `pdata`, processor shutdown draining after admission reopens, exporter
//! shutdown draining of buffered `pdata` without reopening admission, and
//! deadline-forced shutdown when a processor keeps admission closed
//! - `dst_runtime_control_plane_seeded`: timer progress under runtime-control
//! pressure, Ack/Nack unwind correctness, `RETURN_DATA` retention/drop
//! behavior, and `DrainIngress` before downstream `Shutdown`
//! - `dst_heavy_ingress_backpressure_seeded`: sustained ingress, bounded
//! `pdata` channels, processor admission gating and reopen, mixed Ack/Nack
//! completions, runtime-control noise, and clean shutdown ordering
//! - `dst_closed_admission_deadline_abandons_buffered_pdata_seeded`: the
//! current known limitation where buffered `pdata` is abandoned if admission
//! stays closed until the shutdown deadline
//!
//! Receiver-side `wait_for_result` behavior is covered separately in
//! `otlp_receiver.rs`, where the DST suite exercises four terminal paths for an
//! admitted request: Ack before drain completes, temporary Nack during drain,
//! permanent Nack during drain, and shutdown/unavailable completion at the
//! deadline.
/// Re-exported simulated clock used by engine and receiver DST suites.
pub use crateSimClock;
use HashSet;
/// Small deterministic RNG for DST scenarios.
///
/// The harness does not need statistically sophisticated randomness; it needs a
/// tiny, dependency-free generator that can vary action ordering and remain
/// perfectly replayable from a seed printed in a failing test.
/// Returns the DST seeds selected from the environment.
///
/// `DST_SEED` replays one seed. Otherwise `DST_SEEDS` controls the number of
/// generated seeds appended after the regression seeds. This keeps a stable set
/// of known-sensitive interleavings while still allowing larger sweeps in CI or
/// during local debugging.