main
ply4 git calls486 ms42 KiB2 cachedprotocol v2
162 lines6.3 KiBRaw
1// ply-web#145: how a settled unjudged ramp state reaches verdict.json (rolledBack, fault, reason).
2import assert from 'node:assert/strict'
3import { test } from 'node:test'
4import type { HarnessTraffic } from '../scripts/cd/ramp.ts'
5import { rampStageResult, unjudgedFail } from '../scripts/cd/stage-ramp.ts'
6import type { RampState } from '../scripts/cd/ramp.ts'
8const traffic = (value: 'rolled_back' | 'held' | 'settle_failed') => value as HarnessTraffic
10test('a rolled-back harness_unhealthy step is a rolledBack fail with fault harness_unhealthy', () => {
11 const reason = 'harness unhealthy: client stall; rolled back to previous'
12 assert.deepEqual(unjudgedFail({ kind: 'held', reason, outcome: 'harness_unhealthy', traffic: traffic('rolled_back') }), {
13 kind: 'fail',
14 stage: 'ramp',
15 reason,
16 rolledBack: true,
17 fault: 'harness_unhealthy',
18 })
19})
21test('a held insufficient_samples step is not rolledBack and keeps its outcome as the fault', () => {
22 const reason = 'stall; held at 75%'
23 assert.deepEqual(unjudgedFail({ kind: 'held', reason, outcome: 'insufficient_samples', traffic: traffic('held') }), {
24 kind: 'fail',
25 stage: 'ramp',
26 reason,
27 rolledBack: false,
28 fault: 'insufficient_samples',
29 })
30})
32test('a failed settle is not rolledBack, and the reason is the state reason with no repeated error', () => {
33 const reason = 'harness unhealthy: x; rollback to previous failed: boom 503; still at 100%'
34 const result = unjudgedFail({ kind: 'held', reason, outcome: 'harness_unhealthy', traffic: traffic('settle_failed') })
35 assert.deepEqual(result, { kind: 'fail', stage: 'ramp', reason, rolledBack: false, fault: 'harness_unhealthy' })
36})
38test('a rolled-back harness_fault stop is a rolledBack fail with fault harness_fault', () => {
39 const reason = 'telemetry unavailable: 502; rolled back to previous'
40 assert.deepEqual(unjudgedFail({ kind: 'stopped', reason, fault: 'harness_fault', traffic: traffic('rolled_back') }), {
41 kind: 'fail',
42 stage: 'ramp',
43 reason,
44 rolledBack: true,
45 fault: 'harness_fault',
46 })
47})
49// rampStageResult: every arm of the RampLoopResult -> StageResult mapping stageRamp returns (PR #151 round 3).
50// Expected values are written out from the issue's contract, not computed from the code under test.
51const V = 'new-version'
52const P = 'prev-version'
53const loop = (state: RampState, rollbackError: string | null = null) => ({ state, lines: ['l1', 'l2'], rollbackError })
55test('rampStageResult: complete passes with version, previous and lines', () => {
56 assert.deepEqual(rampStageResult(loop({ kind: 'complete' }), V, P), {
57 kind: 'pass',
58 stage: 'ramp',
59 value: { version: V, previous: P, lines: ['l1', 'l2'] },
60 })
61})
63test('rampStageResult: a policy hold (no traffic) is a worker fail, not rolledBack', () => {
64 assert.deepEqual(rampStageResult(loop({ kind: 'held', reason: 'split mismatch; held', outcome: 'hold' }), V, P), {
65 kind: 'fail',
66 stage: 'ramp',
67 reason: 'split mismatch; held',
68 rolledBack: false,
69 fault: 'worker',
70 })
71 assert.deepEqual(rampStageResult(loop({ kind: 'held', reason: 'thin data; held', outcome: 'insufficient_data' }), V, P), {
72 kind: 'fail',
73 stage: 'ramp',
74 reason: 'thin data; held',
75 rolledBack: false,
76 fault: 'worker',
77 })
78})
80test('rampStageResult: an unjudged rolled-back harness_unhealthy hold is rolledBack with fault harness_unhealthy', () => {
81 const state: RampState = { kind: 'held', reason: 'client stall; rolled back', outcome: 'harness_unhealthy', traffic: traffic('rolled_back') }
82 assert.deepEqual(rampStageResult(loop(state), V, P), {
83 kind: 'fail',
84 stage: 'ramp',
85 reason: 'client stall; rolled back',
86 rolledBack: true,
87 fault: 'harness_unhealthy',
88 })
89})
91test('rampStageResult: an unjudged held insufficient_samples hold is not rolledBack with fault insufficient_samples', () => {
92 const state: RampState = { kind: 'held', reason: 'few samples; held at 25%', outcome: 'insufficient_samples', traffic: traffic('held') }
93 assert.deepEqual(rampStageResult(loop(state), V, P), {
94 kind: 'fail',
95 stage: 'ramp',
96 reason: 'few samples; held at 25%',
97 rolledBack: false,
98 fault: 'insufficient_samples',
99 })
100})
102test('rampStageResult: a rolled-back harness_fault stop is rolledBack with fault harness_fault', () => {
103 const state: RampState = { kind: 'stopped', reason: 'telemetry 502; rolled back', fault: 'harness_fault', traffic: traffic('rolled_back') }
104 assert.deepEqual(rampStageResult(loop(state), V, P), {
105 kind: 'fail',
106 stage: 'ramp',
107 reason: 'telemetry 502; rolled back',
108 rolledBack: true,
109 fault: 'harness_fault',
110 })
111})
113test('rampStageResult: a harness_fault stop whose settle failed is not rolledBack', () => {
114 const state: RampState = { kind: 'stopped', reason: 'telemetry 502; rollback failed', fault: 'harness_fault', traffic: traffic('settle_failed') }
115 assert.deepEqual(rampStageResult(loop(state), V, P), {
116 kind: 'fail',
117 stage: 'ramp',
118 reason: 'telemetry 502; rollback failed',
119 rolledBack: false,
120 fault: 'harness_fault',
121 })
122})
124test('rampStageResult: a state_conflict stop is not rolledBack with fault state_conflict', () => {
125 assert.deepEqual(rampStageResult(loop({ kind: 'stopped', reason: 'split changed under us', fault: 'state_conflict' }), V, P), {
126 kind: 'fail',
127 stage: 'ramp',
128 reason: 'split changed under us',
129 rolledBack: false,
130 fault: 'state_conflict',
131 })
132})
134test('rampStageResult: a rollback that landed is a rolledBack worker fail', () => {
135 assert.deepEqual(rampStageResult(loop({ kind: 'rolled-back', reason: '5xx at 10%' }), V, P), {
136 kind: 'fail',
137 stage: 'ramp',
138 reason: '5xx at 10%',
139 rolledBack: true,
140 fault: 'worker',
141 })
142})
144test('rampStageResult: a rollback whose write failed names previous and the error and is not rolledBack', () => {
145 assert.deepEqual(rampStageResult(loop({ kind: 'rolled-back', reason: '5xx at 10%' }, 'cf 503'), V, P), {
146 kind: 'fail',
147 stage: 'ramp',
148 reason: '5xx at 10%; rollback to prev-version failed: cf 503',
149 rolledBack: false,
150 fault: 'worker',
151 })
152})
154test('rampStageResult: a loop that ended still ramping reads "ramp stopped" and is rolledBack', () => {
155 assert.deepEqual(rampStageResult(loop({ kind: 'ramping', step: 1 }), V, P), {
156 kind: 'fail',
157 stage: 'ramp',
158 reason: 'ramp stopped',
159 rolledBack: true,
160 fault: 'worker',
161 })
162})
Diagnostics4 git calls · 486 ms
CallStatusSizeTime0486 ms
discover200152 B4 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=4
git.response.bytes=152
git.server.agent=gitty/1.0
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch object-format
git.server.fetch=shallow filter sideband-all
git.protocol.version=2
git.pkt.frames=8
git.pkt.data=6
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=152
git.pkt.payload.max=34
ls-refs200145 B · hit4 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=4
git.response.bytes=145
git.response.cache=HIT
git.response.duration_ms=4
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=145
git.pkt.payload.max=76
git.ls_refs.count=2
git.ls_refs.head=refs/heads/main
fetchblob:none · deepen 1020040 KiB · hit4 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
git.response.bytes=41349
git.response.cache=HIT
git.response.duration_ms=4
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=526b305930b8ef382f2d7a1f9c0238730a585921
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=6
git.pkt.data=4
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=41349
git.pkt.payload.max=41254
git.sideband.band1.bytes=41253
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=61
git.pack.bytes=41253
git.pack.ofs_delta=0
git.pack.ref_delta=0
git.pack.chain.max=0
git.pack.trailer=ab60efef4b7243678c75de64a4386986ee885c1c
git.pack.full=61
Open pack map
fetch2001.4 KiB478 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=478
git.response.bytes=1406
git.response.cache=MISS
git.response.duration_ms=478
git.fetch.wants=2767067d51110d63fbbce67f7e8815d811bb25a7
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=1406
git.pkt.payload.max=1385
git.sideband.band1.bytes=1384
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/ply-web.git
Ref
refs/heads/main
Commit
526b305930b8ef382f2d7a1f9c0238730a585921
cf-ray
a5e37859f9fb4603
Request
887822fb…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format