Problem
test_live_full_cycle in test/test_baza_live.rb:36-62 periodically fails with:
BazaRb::ServerFailure: Invalid response code #400 at PUT https://api.zerocracy.com/push/fakeea9e3b3fea801116
(Flash: An existing job named "fakeea9e3b3fea801116" is running now)
This happens in CI of every open PR: #350, #351, #352, #310, #317, #314, #308, and others.
Root cause
The job name is generated at line 133-134:
def fake_name
"fake#{SecureRandom.hex(8)}"
end
SecureRandom.hex(8) produces 16 hex chars — 2^64 possible values. When CI runs in parallel (macOS + ubuntu create jobs simultaneously) or when a previous run left a job with the same name still running, the zerocracy server returns 400.
The test fails not because the code is broken, but because randomness does not guarantee uniqueness. "Re-run CI and hope it passes" is the only workaround — a luck-based technique, not determinism.
Proposed fixes
Option A (recommended): add timestamp
def fake_name
"fake-#{Time.now.to_i}-#{SecureRandom.hex(4)}"
end
The name now contains the creation timestamp + 8 hex chars. Even if two CI jobs start at the same second, hex(4) still gives 4 billion variants. Collision becomes practically impossible.
Additionally: extract the push call from test_live_full_cycle into a separate setup method that runs once before all live tests, to reduce server-side garbage.
Option B: UUID
def fake_name
"fake-#{SecureRandom.uuid}"
end
UUID provides 122 bits of entropy. Collision within a single CI run is impossible.
Option C: retry on 400
def fake_name
loop do
n = "fake#{SecureRandom.hex(8)}"
return n unless LIVE.name_exists?(n)
end
end
But this adds an extra HTTP request and does not fix the case when the job exists but has not been created yet.
Expected outcome
After the fix, test_live_full_cycle should pass 100% of runs without requiring re-runs.
Problem
test_live_full_cycleintest/test_baza_live.rb:36-62periodically fails with:This happens in CI of every open PR: #350, #351, #352, #310, #317, #314, #308, and others.
Root cause
The job name is generated at line 133-134:
SecureRandom.hex(8)produces 16 hex chars — 2^64 possible values. When CI runs in parallel (macOS + ubuntu create jobs simultaneously) or when a previous run left a job with the same name still running, the zerocracy server returns 400.The test fails not because the code is broken, but because randomness does not guarantee uniqueness. "Re-run CI and hope it passes" is the only workaround — a luck-based technique, not determinism.
Proposed fixes
Option A (recommended): add timestamp
The name now contains the creation timestamp + 8 hex chars. Even if two CI jobs start at the same second, hex(4) still gives 4 billion variants. Collision becomes practically impossible.
Additionally: extract the push call from test_live_full_cycle into a separate setup method that runs once before all live tests, to reduce server-side garbage.
Option B: UUID
UUID provides 122 bits of entropy. Collision within a single CI run is impossible.
Option C: retry on 400
But this adds an extra HTTP request and does not fix the case when the job exists but has not been created yet.
Expected outcome
After the fix, test_live_full_cycle should pass 100% of runs without requiring re-runs.