Repository navigation
Commit 9bfc3dd
authored
Phase 5b: logging facade and redaction — tests and doubles (#70)
* test: logging facade and redaction suites (phase 5b)
Add fourteen suites under test/dexpace/instrumentation/ -- twelve
mirrors of the phase-5b files plus the floor-straddling matrix facts as
a standing test and the four downstream wirings -- and rewrite 5c's
diagnostics mirror as this phase's, asserting the fold, the snapshot
bridge across a real thread boundary, and what the 3.2 floor makes of a
restored key, floor-aware through FiberStorageFacts. The two steps are
driven through the real Pipeline and AsyncPipeline over phase 2's
transport fakes and Completer, with 5c's recording tracer factory and
meter and 5a's FakeClock, and every configuration a suite consults is
built over FakeConfigSource seams so the process environment is never
read.
Add two top-level doubles under test/support/: RecordingSink, a real
in-memory sink with per-severity enablement, and DiagnosticContext, the
save-and-restore block for Fiber storage.
Every "never throws" claim is asserted on the substituted value; the
inert event is measured at zero allocations per chained call; and the
four tests the guard pass found missing are here: a sink that re-enters
the logger from inside its own write, the async path's header
redaction, a recording cursor whose fork raises, and the headers level
with a cap supplied. Forty-eight single-edit mutations of lib/ are
caught by these suites on 4.0.6 and 3.2.11.
* test: cover the header userinfo routes, the event name gate, fact 3
Review round 0's findings, each with the suite that now runs red on
its revert. The redactor suite gains the three inputs that leaked
through Redactor#header_value -- a network-path reference on the
relative route, an authority the parser rejects on the surgery route,
and a userinfo on the exploding-policy fallback -- plus the `%zz`
parameter name that used to sentinel the whole URL and the opaque
URI's query-shaped tail (P5-100, P5-101). The step suite drives four
hostile Location values through a real pipeline at HEADERS and asserts
the credential in no payload. The event suite gains a HeaderGateTest
class: a credential header written straight into Event#field is
REDACTED, dropped in omit mode, and the name gate runs before the
URL-value redactor (P5-102).
Fact 3 of logging_matrix_facts_test.rb was order-dependent on the 3.2
floor: every teardown's `Fiber[OTHER] = nil` is retained there, so
`storage == prior` held for any test but the first and the assertion
"exact iff = nil deletes" failed on 12 of 13 orders. The expected map
is now stated for the row -- `prior` where `= nil` deletes,
`prior.merge(OTHER => nil)` on the floor -- which is the same map
whether or not the residue was already present. Green on 3.2.11 with
seeds 9818, 1 and 42 and standalone; the old spelling reproduces the
failure on seed 9818.
* test: cover round 1's four repairs and the two surviving mutations
Twelve cases for review round 1 of phase 5b. The proxy resolver's
warning and its config diagnostic are driven with nine
credential-bearing malformed HTTPS_PROXY values -- the no-port,
out-of-range, non-numeric, space-in-host, no-host, double-@,
scheme-less, network-path and query-carrying spellings -- asserting the
placeholder in both channels and the credential in neither, and the
not-a-URI message named once without the parser's text (R1-1,
P5-103). The two ambient sources meet the reserved-key table: a
url.full, an Authorization and a Location in the logger's global
context are redacted once at build and the caller's Hash is untouched;
the unfiltered and the listed fold redact the same keys; omit mode
drops a non-allow-listed header from either source (R1-2, P5-104). A
Location with a leading SP, HTAB, VT, NUL or a trailing high byte
loses its userinfo through the redactor and through the step at
HEADERS over an inbound Headers built with the space, while the four
non-authority spellings are written back as given (R1-3, P5-105).
charset=utf-7 and iso-2022-jp-2 decode as UTF-8 at Preview.render and
the step at BODY still emits the http.response event (R1-4, P5-106).
The two mutations that survived round 1 now fail: a settlement failed
from a Thread whose own Fiber storage differs emits the failure event
under the caller's captured trace.id and span.id and restores the
settler's keys (R1-5); a chunked request and response body of declared
length -1 put no size field on either event at HEADERS (R1-6).
Three suites are split under Metrics/ClassLength: the redactor's
surgery-route cases move to SurgeryRouteTest, the step's header cases
to HeaderRedactionTest, and WritingTransport moves into the step
suite's shared Fixtures.
* test: cover round 2's three repairs and steady the allocation helper
The surgery route: every prefix review round 2 named before a real
authority -- RFC 3986 Appendix C's delimiters, quotes, parentheses, a
word, an encoded space, `+`, `@`, a backslash, an NBSP, a line
separator, the BINARY obs-text spellings -- and a doubled proxy URL,
through Redactor#header_value, through a real pipeline at HEADERS over
inbound Headers, and through Proxy.resolve with a quoted, bracketed or
doubled HTTPS_PROXY (P5-107). The P5-105 assertion that a non-whitespace
prefix is written back verbatim is gone; the not-an-authority list is
now what the parser accepts without one and the backslash spellings, and
a path that spells a second authority is asserted as OBS-14's path.
Per-value redaction: two Locations through the step and an Array through
Event#field, each value redacted before the ", " join (P5-108).
The async step under a throwing meter at every level: a later settlement
raises into the settler while the caller still receives the response,
an inline settlement fails the request, and the counter and the span
finish are counted at exactly one each way (P5-109).
AllocationDelta#allocations_per_call returns the figure two consecutive
measurements agree on: on the 3.2.11 floor a one-time cost of 7 or 28
objects can land inside a measured block after the warm-up, once per
process and test-order dependent, so a single measurement came back
negative in roughly one whole-file run in fifteen and the exact zero
assertion failed it (R2-4). A change to 5c's support file; its five
allocation suites re-run green and the M02 guard still runs red.
* test: name two more parsed-path spellings the surgery never sees
The redactor suite's not-an-authority list gains a path-absolute
reference (`/http://user:secret@h/p`, which the parser accepts as a
path and the relative route writes back) and a `/ /` that is not a
`//` (P5-100, P5-107): both surfaced by re-running review round 2's
battery against the repaired redactor, and both are what RFC 3986
decides rather than what the surgery pattern reaches.1 parent 5f3c75f commit 9bfc3dd
18 files changed
Lines changed: 3887 additions & 17 deletions
File tree
- gems/dexpace-core/test
- dexpace/instrumentation
- support
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
6 | 9 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
12 | 21 | | |
13 | | - | |
| 22 | + | |
14 | 23 | | |
| 24 | + | |
15 | 25 | | |
16 | 26 | | |
17 | 27 | | |
| |||
26 | 36 | | |
27 | 37 | | |
28 | 38 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
33 | 50 | | |
34 | 51 | | |
35 | 52 | | |
36 | 53 | | |
37 | 54 | | |
38 | 55 | | |
39 | 56 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | 57 | | |
44 | 58 | | |
45 | 59 | | |
| |||
48 | 62 | | |
49 | 63 | | |
50 | 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 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
51 | 268 | | |
0 commit comments