@@ -1366,22 +1366,32 @@ func TestReleaseHomebrewBehavior(t *testing.T) {
13661366 }
13671367}
13681368
1369+ // blockedCommandTimeoutSeconds is the AICR_NETWORK_TIMEOUT_SECONDS value the
1370+ // blocked-command subtests configure. blockedCommandBudget scales the wall-clock
1371+ // assertion off it with generous headroom: the elapsed time also covers shell
1372+ // startup and process spawning, so a tight bound only produces flakes under
1373+ // load. The assertion exists solely to catch an indefinite hang — the "script
1374+ // failed" and "artifact not mutated" assertions prove the real behavior.
1375+ const (
1376+ blockedCommandTimeoutSeconds = 1
1377+ blockedCommandBudget = 10 * blockedCommandTimeoutSeconds * time .Second
1378+ )
1379+
13691380func TestReleaseNetworkBoundsTerminateBlockedCommands (t * testing.T ) {
1370- t .Parallel ()
13711381 t .Run ("candidate resolver" , func (t * testing.T ) {
1372- t .Parallel ()
13731382 fixture := newReleaseFixture (t )
13741383 writeExecutable (t , filepath .Join (fixture .bin , "timeout" ), fakeTimeout )
13751384 writeExecutable (t , filepath .Join (fixture .bin , "crane" ), blockingCommand )
13761385 output := filepath .Join (fixture .dir , "digests.json" )
1377- environment := append (fixture .environment (), "AICR_NETWORK_TIMEOUT_SECONDS=1" )
1386+ environment := append (fixture .environment (),
1387+ fmt .Sprintf ("AICR_NETWORK_TIMEOUT_SECONDS=%d" , blockedCommandTimeoutSeconds ))
13781388 started := time .Now ()
13791389 result := runScript (t , environment , ".github/scripts/release-images.sh" , "resolve" , output )
13801390 if result .err == nil {
13811391 t .Fatal ("resolver accepted a blocked registry command" )
13821392 }
1383- if elapsed := time .Since (started ); elapsed > 4 * time . Second {
1384- t .Errorf ("resolver timeout took %s, want under 4s " , elapsed )
1393+ if elapsed := time .Since (started ); elapsed > blockedCommandBudget {
1394+ t .Errorf ("resolver timeout took %s, want under %s " , elapsed , blockedCommandBudget )
13851395 }
13861396 if _ , err := os .Stat (output ); ! os .IsNotExist (err ) {
13871397 t .Errorf ("timed-out resolver published output: %v" , err )
@@ -1392,7 +1402,6 @@ func TestReleaseNetworkBoundsTerminateBlockedCommands(t *testing.T) {
13921402 })
13931403
13941404 t .Run ("Homebrew checksum fetch" , func (t * testing.T ) {
1395- t .Parallel ()
13961405 dir := t .TempDir ()
13971406 bin := filepath .Join (dir , "bin" )
13981407 formulaDir := filepath .Join (dir , "tap" , "Formula" )
@@ -1416,15 +1425,15 @@ func TestReleaseNetworkBoundsTerminateBlockedCommands(t *testing.T) {
14161425 environment := append (os .Environ (),
14171426 "PATH=" + bin + ":" + os .Getenv ("PATH" ),
14181427 "RELEASE_TAG=v1.2.3" ,
1419- "AICR_NETWORK_TIMEOUT_SECONDS=1" ,
1428+ fmt . Sprintf ( "AICR_NETWORK_TIMEOUT_SECONDS=%d" , blockedCommandTimeoutSeconds ) ,
14201429 )
14211430 started := time .Now ()
14221431 result := runScript (t , environment , ".github/scripts/publish-homebrew.sh" , candidate , filepath .Join (dir , "tap" ))
14231432 if result .err == nil {
14241433 t .Fatal ("Homebrew publisher accepted a blocked checksum request" )
14251434 }
1426- if elapsed := time .Since (started ); elapsed > 4 * time . Second {
1427- t .Errorf ("Homebrew timeout took %s, want under 4s " , elapsed )
1435+ if elapsed := time .Since (started ); elapsed > blockedCommandBudget {
1436+ t .Errorf ("Homebrew timeout took %s, want under %s " , elapsed , blockedCommandBudget )
14281437 }
14291438 if got := readOptional (t , destination ); got != existing {
14301439 t .Error ("timed-out checksum request modified the tap" )
0 commit comments