Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Site
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software/vole.git

Self-hosted forge that lives in your Git repo.

Test the deadline and the site guard, not the machine

e48543eec150817b20c17a8b3d4f663be1c11609 · Keenan Nemetz · 23d ago · parent c284cb2c

Test the deadline and the site guard, not the machine

verify failed twice on cli-help-table while the runner host was at 50-60% CPU
steal. Neither failing test was about the code under test.

TestWorkflowRefusesAStaleSiteDeploy started its held runner with
exec.Command(binPath, "runner", ...) instead of f.runnerCmd, so it kept the 2G
disk reserve that c284cb2 turned off for every other test-spawned runner. Inside
a CI job /tmp is the runtime's 1G tmpfs, so the nested runner stopped the build
at its first one-second disk check: the stale run failed, but for the disk rather
than for staleness, and the log never said "the site was not deployed".
TestTestRunnersComeFromRunnerCmd now fails when a test starts a runner directly,
because the mistake is invisible on a workstation where /tmp is large.

TestHandshakeDeadlineIsClearedForTheSession gave the handshake a 100 ms deadline
and then slept past it. On a loaded machine the server cut the test's own
handshake, so dial failed with EOF and the test reported a product problem it had
created. It now reads the deadlines the server set on the connection: a non-zero
bound for the handshake, then a zero one after it. That is the property, it takes
no wall-clock assumption, and deleting the clearing in serveConn fails it
immediately instead of a third of a second later.

Closes: 01M7389DZ8JY77W3AF1P10ZDRT

server/ssh/limits_test.go +26−6

@@ -261,24 +261,44 @@ func discardLogger() *slog.Logger {
261 261 return slog.New(slog.NewTextHandler(io.Discard, nil))
262 262 }
263 263
264 // The handshake is the one part of a connection with a deadline, and it has to
265 // come off when the handshake completes: an idle session that outlived the bound
266 // would be cut in the middle of its work.
267 //
268 // The test reads the deadlines the server set rather than sleeping past one. That
269 // is what makes it a test of this property and not of the machine: waiting for a
270 // short deadline fails on a loaded host for having cut the test's own handshake,
271 // which says nothing about whether the deadline was cleared. Deleting the clearing
272 // in serveConn fails this test directly.
264 273 func TestHandshakeDeadlineIsClearedForTheSession(t *testing.T) {
265 274 t.Parallel()
266 h := newHarnessWith(t, func(c *Config) { c.HandshakeTimeout = 100 * time.Millisecond })
275 h, rec := newRecordingHarness(t, func(c *Config) { c.HandshakeTimeout = 30 * time.Second })
267 276 client := h.dial(t, h.keyPath)
268 277
269 278 sess, err := client.NewSession()
270 279 if err != nil {
271 280 t.Fatalf("a session after the handshake: %v", err)
272 281 }
273 // Outlive the handshake deadline on a session that is open but idle. If the
274 // deadline survived the handshake, this channel would be cut when it ran.
275 time.Sleep(300 * time.Millisecond)
282 defer sess.Close()
283
284 seen := rec.first(t).deadlinesSeen()
285 if len(seen) < 2 {
286 t.Fatalf("the server set %d deadlines on the connection, want the handshake bound and its removal", len(seen))
287 }
288 if seen[0].IsZero() {
289 t.Fatal("the handshake ran with no deadline, so an idle client could hold it open")
290 }
291 if !seen[len(seen)-1].IsZero() {
292 t.Fatalf("the deadline was not cleared after the handshake: %v", seen)
293 }
294
295 // And the session is usable once the bound is gone, which is what an idle
296 // session depends on.
276 297 out, err := sess.Output("vole-whoami")
277 298 if err != nil {
278 t.Fatalf("the session was cut by the handshake deadline: %v", err)
299 t.Fatalf("the session did not run after the handshake: %v", err)
279 300 }
280 301 if !strings.Contains(string(out), "writer") {
281 302 t.Fatalf("vole-whoami answered %q", out)
282 303 }
283 sess.Close()
284 304 }