From 7a57b1b0460601a32880cebeb2412969188baed8 Mon Sep 17 00:00:00 2001 From: Emilio Del Tessandoro Date: Fri, 27 Nov 2026 11:41:32 +0100 Subject: [PATCH 1/3] test(volumes): cut the put package's test time Run the put package's tests in parallel. Most of them send a 64 MiB part, the smallest part the format has, through a local TLS server, so the package spent about 70 s under the race detector on one core and ran past the CI timeout on a slower runner. Part sizes and timings are unchanged. The table tests with slow subtests (a lost key, a change between hashing and sending, a change before the last part, a stalled part) also run their subtests in parallel; each builds its own environment. Five tests stay sequential: two set environment variables, one swaps the package's change-time hook, one counts the process's allocations, and one relies on 300 ms pauses staying under a 1 s stall timer. --- internal/volumes/put/behavior_test.go | 34 ++++++++++++++++++++ internal/volumes/put/crc_test.go | 3 ++ internal/volumes/put/dedup_test.go | 8 +++++ internal/volumes/put/endpoint_test.go | 2 ++ internal/volumes/put/hashcache_test.go | 11 +++++++ internal/volumes/put/part_digest_test.go | 9 ++++++ internal/volumes/put/part_retry_test.go | 7 ++++ internal/volumes/put/part_stream_test.go | 3 ++ internal/volumes/put/progress_test.go | 7 ++++ internal/volumes/put/put_test.go | 17 ++++++++++ internal/volumes/put/resume_journal_test.go | 1 + internal/volumes/put/resume_recovery_test.go | 10 ++++++ internal/volumes/put/resume_test.go | 21 ++++++++++++ internal/volumes/put/retry_test.go | 10 ++++++ internal/volumes/put/transport_test.go | 18 +++++++++++ internal/volumes/put/walk_test.go | 8 +++++ internal/volumes/put/wire_test.go | 7 ++++ 17 files changed, 176 insertions(+) diff --git a/internal/volumes/put/behavior_test.go b/internal/volumes/put/behavior_test.go index 7c0b39ff..e4eebfd6 100644 --- a/internal/volumes/put/behavior_test.go +++ b/internal/volumes/put/behavior_test.go @@ -44,6 +44,7 @@ func statuses(puts []putRecord) []int { // TestPutTwoPartFile completes a two-part file with the CRC of the whole ciphertext. func TestPutTwoPartFile(t *testing.T) { + t.Parallel() e := newTestEnv(t) file := filepath.Join(e.srcDir, "big.bin") writeTwoPartFile(t, file) @@ -75,6 +76,7 @@ func TestPutTwoPartFile(t *testing.T) { // TestZeroLengthFileOnePart: an empty file is one part of a salt and a tag. func TestZeroLengthFileOnePart(t *testing.T) { + t.Parallel() e := newTestEnv(t) file := singleFile(t, e, "empty.txt", nil) vol := e.cloud.newVolume("model-weights", "") @@ -95,6 +97,7 @@ func TestZeroLengthFileOnePart(t *testing.T) { // TestRetryUsesNewSealer: a retried part is sealed again under a fresh salt from the same buffer. func TestRetryUsesNewSealer(t *testing.T) { + t.Parallel() e := newTestEnv(t) file := singleFile(t, e, "weights.bin", patterned(5000, 1)) vol := e.cloud.newVolume("model-weights", "") @@ -123,6 +126,7 @@ func TestRetryUsesNewSealer(t *testing.T) { } func TestStorageFailureKeepsSessionAfterRetries(t *testing.T) { + t.Parallel() e := newTestEnv(t) file := singleFile(t, e, "weights.bin", patterned(5000, 1)) vol := e.cloud.newVolume("model-weights", "") @@ -153,6 +157,7 @@ func TestStorageFailureKeepsSessionAfterRetries(t *testing.T) { } func TestPartRecoversAfterExtendedOutage(t *testing.T) { + t.Parallel() e := newTestEnv(t) file := singleFile(t, e, "weights.bin", patterned(5000, 1)) vol := e.cloud.newVolume("model-weights", "") @@ -192,6 +197,7 @@ func TestPartRecoversAfterExtendedOutage(t *testing.T) { } func TestPartsUploadInParallel(t *testing.T) { + t.Parallel() e := newTestEnv(t) file := filepath.Join(e.srcDir, "big.bin") writeTwoPartFile(t, file) @@ -222,6 +228,7 @@ func TestPartsUploadInParallel(t *testing.T) { } func TestParallelismBoundsPartRequestsAcrossFiles(t *testing.T) { + t.Parallel() const parallel = 2 e := newTestEnv(t) vol := e.cloud.newVolume("model-weights", "") @@ -286,6 +293,7 @@ func TestParallelismBoundsPartRequestsAcrossFiles(t *testing.T) { // TestParallelismIsBounded: zero or less runs the default number of parts at once, and no more than the most run however many are asked for. func TestParallelismIsBounded(t *testing.T) { + t.Parallel() for asked, want := range map[int]int{ -3: DefaultParallelism, 0: DefaultParallelism, @@ -320,6 +328,7 @@ func (u unverifiedCompletion) CompleteFile(ctx context.Context, up UploadRef, fi } func TestPutRefusesAnUnverifiedCompletion(t *testing.T) { + t.Parallel() e := newTestEnv(t) file := singleFile(t, e, "weights.bin", patterned(5000, 1)) vol := e.cloud.newVolume("model-weights", "") @@ -366,6 +375,7 @@ type refusedCompletionCase struct { // TestPutAbortsWhenACompletionIsRefused: a refused completion names the limit or the file, aborts the session and publishes nothing. func TestPutAbortsWhenACompletionIsRefused(t *testing.T) { + t.Parallel() cases := []refusedCompletionCase{ { name: "the Volume would hold too many files", @@ -434,6 +444,7 @@ func TestPutAbortsWhenACompletionIsRefused(t *testing.T) { } func TestFileKeyClearedWhenItsFileCompletes(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := filepath.Join(e.srcDir, "pair") writeTree(t, dir, map[string][]byte{ @@ -461,6 +472,7 @@ func TestFileKeyClearedWhenItsFileCompletes(t *testing.T) { } func TestRenewsExpiredTokenBeforeSending(t *testing.T) { + t.Parallel() e := newTestEnv(t) file := singleFile(t, e, "weights.bin", patterned(5000, 1)) vol := e.cloud.newVolume("model-weights", "") @@ -477,6 +489,7 @@ func TestRenewsExpiredTokenBeforeSending(t *testing.T) { } func TestRenewsTokenRefusedByEndpoint(t *testing.T) { + t.Parallel() e := newTestEnv(t) file := singleFile(t, e, "weights.bin", patterned(5000, 1)) vol := e.cloud.newVolume("model-weights", "") @@ -494,6 +507,7 @@ func TestRenewsTokenRefusedByEndpoint(t *testing.T) { } func TestRenewalGivesUp(t *testing.T) { + t.Parallel() e := newTestEnv(t) file := singleFile(t, e, "weights.bin", patterned(5000, 1)) vol := e.cloud.newVolume("model-weights", "") @@ -515,6 +529,7 @@ func TestRenewalGivesUp(t *testing.T) { } func TestRejectsAlreadyExpiredRenewal(t *testing.T) { + t.Parallel() e := newTestEnv(t) file := singleFile(t, e, "weights.bin", patterned(5000, 1)) vol := e.cloud.newVolume("model-weights", "") @@ -529,6 +544,7 @@ func TestRejectsAlreadyExpiredRenewal(t *testing.T) { // TestPutDeclaresInBatches: files are declared at most 100 at a time. func TestPutDeclaresInBatches(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := filepath.Join(e.srcDir, "many") files := make(map[string][]byte, 105) @@ -561,6 +577,7 @@ func TestPutDeclaresInBatches(t *testing.T) { } func TestRenewsMissingTargets(t *testing.T) { + t.Parallel() e := newTestEnv(t) file := filepath.Join(e.srcDir, "big.bin") writeTwoPartFile(t, file) @@ -628,6 +645,7 @@ func renewalRunner(t *testing.T, api API) (*runner, *fileState) { // TestRenewalAsksForAtMost128Parts: a renewal names the part that needs a target and the parts after it, 128 at the most. func TestRenewalAsksForAtMost128Parts(t *testing.T) { + t.Parallel() api := &renewalAPI{answer: func(parts []int) ([]Target, error) { return targetsFor(parts), nil }} r, f := renewalRunner(t, api) @@ -657,6 +675,7 @@ type renewalAnswerCase struct { // TestRenewalChecksTheAnswer: a short, reordered or misnumbered answer breaks the contract, and a quota refusal names the limit. func TestRenewalChecksTheAnswer(t *testing.T) { + t.Parallel() cases := []renewalAnswerCase{ { name: "one target short", @@ -715,6 +734,7 @@ func TestRenewalChecksTheAnswer(t *testing.T) { } func TestNeverRenewsPastSessionDeadline(t *testing.T) { + t.Parallel() e := newTestEnv(t) file := singleFile(t, e, "weights.bin", patterned(5000, 1)) vol := e.cloud.newVolume("model-weights", "") @@ -740,6 +760,7 @@ type fatalPartCase struct { } func TestAbortsOnFatalPartRefusal(t *testing.T) { + t.Parallel() cases := []fatalPartCase{ { name: "volume-part-token-invalid", @@ -813,6 +834,7 @@ func (a observedAbort) AbortUpload(ctx context.Context, ref UploadRef) error { // TestInterruptKeepsSession: an interrupt leaves the session open and its resume state on disk, for put to resume. func TestInterruptKeepsSession(t *testing.T) { + t.Parallel() e := newTestEnv(t) first := singleFile(t, e, "first.bin", patterned(5000, 1)) second := singleFile(t, e, "second.bin", patterned(5000, 2)) @@ -881,6 +903,7 @@ type abortCase struct { } func TestAbortFailureStillRemovesJournal(t *testing.T) { + t.Parallel() cases := []abortCase{ { name: "the API is unreachable", @@ -933,6 +956,7 @@ func TestAbortFailureStillRemovesJournal(t *testing.T) { } func TestJournalDropsReusedFileKeys(t *testing.T) { + t.Parallel() e := newTestEnv(t) reused := singleFile(t, e, "known.bin", []byte("already stored")) missing := singleFile(t, e, "missing.bin", []byte("needs transfer")) @@ -975,6 +999,7 @@ func keyForms(b []byte) []string { // TestNoSecretsInLogs: no token, ack, key or upload URL reaches progress output, summaries or errors. func TestNoSecretsInLogs(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := standardTree(t, e) var out strings.Builder @@ -1027,6 +1052,7 @@ func TestNoSecretsInLogs(t *testing.T) { } func TestDeclareLimitErrorNamesFile(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := filepath.Join(e.srcDir, "data") writeTree(t, dir, map[string][]byte{ @@ -1051,6 +1077,7 @@ func TestDeclareLimitErrorNamesFile(t *testing.T) { } func TestKeyPairNotReadyRetries(t *testing.T) { + t.Parallel() var ( mu sync.Mutex pauses []time.Duration @@ -1106,6 +1133,7 @@ func TestKeyPairNotReadyRetries(t *testing.T) { // TestVolumeNotFoundStopsEarly: a missing Volume is reported before any file is hashed. func TestVolumeNotFoundStopsEarly(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := standardTree(t, e) @@ -1121,6 +1149,7 @@ func TestVolumeNotFoundStopsEarly(t *testing.T) { } func TestPutNothingToUpload(t *testing.T) { + t.Parallel() e := newTestEnv(t) empty := filepath.Join(e.srcDir, "empty") if err := os.MkdirAll(filepath.Join(empty, "sub"), 0o700); err != nil { @@ -1139,6 +1168,7 @@ func TestPutNothingToUpload(t *testing.T) { } func TestPutReportsProgress(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := standardTree(t, e) e.mustPut(e.cloud.newVolume("model-weights", ""), dir) @@ -1176,6 +1206,7 @@ func decodeStd(t *testing.T, v any) []byte { // TestJournalSavedBeforeDeclare: the session key and each file's keys are saved before the declaration. func TestJournalSavedBeforeDeclare(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := standardTree(t, e) vol := e.cloud.newVolume("model-weights", "") @@ -1227,6 +1258,7 @@ func TestJournalSavedBeforeDeclare(t *testing.T) { // TestJournalPartDigestBeforeSeal: a part's plaintext digest is saved before the part is sealed. func TestJournalPartDigestBeforeSeal(t *testing.T) { + t.Parallel() e := newTestEnv(t) content := patterned(5000, 1) file := singleFile(t, e, "weights.bin", content) @@ -1248,6 +1280,7 @@ func TestJournalPartDigestBeforeSeal(t *testing.T) { // TestJournalHoldsAcks: a completed file's layout, acks and CRCs are in the resume state. func TestJournalHoldsAcks(t *testing.T) { + t.Parallel() e := newTestEnv(t) file := singleFile(t, e, "weights.bin", patterned(5000, 1)) vol := e.cloud.newVolume("model-weights", "") @@ -1271,6 +1304,7 @@ func TestJournalHoldsAcks(t *testing.T) { } func TestJournalFilePermissions(t *testing.T) { + t.Parallel() if runtime.GOOS == "windows" { t.Skip("Windows has no permission bits") } diff --git a/internal/volumes/put/crc_test.go b/internal/volumes/put/crc_test.go index 6f97cfe7..ff5f3709 100644 --- a/internal/volumes/put/crc_test.go +++ b/internal/volumes/put/crc_test.go @@ -15,6 +15,7 @@ func crcOf(b []byte) uint64 { } func TestCRC64NVMEPolynomial(t *testing.T) { + t.Parallel() if got := crcOf([]byte("123456789")); got != 0xae8b14860a799888 { t.Errorf("CRC-64/NVME of 123456789 = %016x, want ae8b14860a799888", got) } @@ -25,6 +26,7 @@ func TestCRC64NVMEPolynomial(t *testing.T) { } func TestCRC64Combine(t *testing.T) { + t.Parallel() for _, size := range []int{1, 2, 7, 16, 31, 32, 4096, 1<<20 + 13} { data := patterned(size, byte(size)) for _, cut := range []int{0, 1, size / 3, size / 2, size - 1, size} { @@ -40,6 +42,7 @@ func TestCRC64Combine(t *testing.T) { } func TestFileCRCFoldsParts(t *testing.T) { + t.Parallel() var object []byte var parts []partResult for i, size := range []int{32, 5000, 1 << 20, 77} { diff --git a/internal/volumes/put/dedup_test.go b/internal/volumes/put/dedup_test.go index 674b0890..f193983a 100644 --- a/internal/volumes/put/dedup_test.go +++ b/internal/volumes/put/dedup_test.go @@ -20,6 +20,7 @@ import ( ) func TestPutDeduplicatesAcrossDeclarationBatches(t *testing.T) { + t.Parallel() e := newTestEnv(t) vol := e.cloud.newVolume("weights", "") content := []byte("common") @@ -74,6 +75,7 @@ func TestPutDeduplicatesAcrossDeclarationBatches(t *testing.T) { } func TestDeduplicatedPutRefusesChangedDuplicate(t *testing.T) { + t.Parallel() e := newTestEnv(t) vol := e.cloud.newVolume("weights", "") first := singleFile(t, e, "first.txt", []byte("common")) @@ -93,6 +95,7 @@ func TestDeduplicatedPutRefusesChangedDuplicate(t *testing.T) { } func TestDeduplicatedPutDoesNotDeclareDuplicateIfRepresentativeFails(t *testing.T) { + t.Parallel() e := newTestEnv(t) vol := e.cloud.newVolume("weights", "") first := singleFile(t, e, "first.txt", []byte("common")) @@ -130,6 +133,7 @@ func (a interruptFileCompletion) CompleteFile(ctx context.Context, ref UploadRef } func TestDeduplicatedPutResumesBeforeDeclaringDuplicate(t *testing.T) { + t.Parallel() for _, drop := range []bool{false, true} { t.Run(fmt.Sprintf("drop response %v", drop), func(t *testing.T) { e := newTestEnv(t) @@ -173,6 +177,7 @@ func TestDeduplicatedPutResumesBeforeDeclaringDuplicate(t *testing.T) { } func TestDeduplicatedPutFallsBackWhenBlobBecomesIneligible(t *testing.T) { + t.Parallel() e := newTestEnv(t) vol := e.cloud.newVolume("weights", "") first := singleFile(t, e, "first.txt", []byte("common")) @@ -194,6 +199,7 @@ func TestDeduplicatedPutFallsBackWhenBlobBecomesIneligible(t *testing.T) { } func TestDeduplicatedResumeRefusesChangedUndeclaredSource(t *testing.T) { + t.Parallel() e := newTestEnv(t) vol := e.cloud.newVolume("weights", "") first := singleFile(t, e, "first.txt", []byte("common")) @@ -238,6 +244,7 @@ func (a lostDeclarations) DeclareFiles(ctx context.Context, ref UploadRef, batch } func TestDeduplicatedPutReplaysBothDeclarations(t *testing.T) { + t.Parallel() e := newTestEnv(t) vol := e.cloud.newVolume("weights", "") first := singleFile(t, e, "first.txt", []byte("common")) @@ -257,6 +264,7 @@ func TestDeduplicatedPutReplaysBothDeclarations(t *testing.T) { } func TestDeduplicatedPutPreservesLegacyDeclaredAttempts(t *testing.T) { + t.Parallel() e := newTestEnv(t) vol := e.cloud.newVolume("weights", "") first := singleFile(t, e, "first.txt", []byte("common")) diff --git a/internal/volumes/put/endpoint_test.go b/internal/volumes/put/endpoint_test.go index d323b4c4..70740f37 100644 --- a/internal/volumes/put/endpoint_test.go +++ b/internal/volumes/put/endpoint_test.go @@ -3,6 +3,7 @@ package put import "testing" func TestEndpointIdentityNormalizesEquivalentURLs(t *testing.T) { + t.Parallel() want, err := endpointIdentity("https://example.test/volumes") if err != nil { t.Fatal(err) @@ -25,6 +26,7 @@ func TestEndpointIdentityNormalizesEquivalentURLs(t *testing.T) { } func TestEndpointIdentityRejectsSecretBearingURLs(t *testing.T) { + t.Parallel() for _, url := range []string{ "https://user:sample@example.test", "https://example.test/?key=sample", diff --git a/internal/volumes/put/hashcache_test.go b/internal/volumes/put/hashcache_test.go index 9b67a853..5dbf96d4 100644 --- a/internal/volumes/put/hashcache_test.go +++ b/internal/volumes/put/hashcache_test.go @@ -14,6 +14,7 @@ import ( ) func TestHashCacheKey(t *testing.T) { + t.Parallel() c := loadHashCache(t.TempDir()) mod := time.Date(2026, time.November, 16, 9, 0, 0, 123, time.UTC) sum := sha256.Sum256([]byte("content")) @@ -46,6 +47,7 @@ func TestHashCacheKey(t *testing.T) { } func TestHashCacheRoundTrip(t *testing.T) { + t.Parallel() dir := filepath.Join(t.TempDir(), "volumes") c := loadHashCache(dir) mod := time.Date(2026, time.November, 16, 9, 0, 0, 0, time.UTC) @@ -63,6 +65,7 @@ func TestHashCacheRoundTrip(t *testing.T) { // TestHashCacheBypassLookup: a cache that bypasses lookups answers for no file, but still records // fresh entries and keeps the others. func TestHashCacheBypassLookup(t *testing.T) { + t.Parallel() dir := filepath.Join(t.TempDir(), "volumes") c := loadHashCache(dir) mod := time.Date(2026, time.November, 16, 9, 0, 0, 0, time.UTC) @@ -93,6 +96,7 @@ func TestHashCacheBypassLookup(t *testing.T) { } func TestHashCacheKeepsNewestEntriesWithinLimit(t *testing.T) { + t.Parallel() dir := t.TempDir() c := loadHashCache(dir) for i := range maxCachedHashes { @@ -118,6 +122,7 @@ func TestHashCacheKeepsNewestEntriesWithinLimit(t *testing.T) { } func TestHashCacheCorruptFileIsEmpty(t *testing.T) { + t.Parallel() dir := t.TempDir() writeFile(t, filepath.Join(dir, hashCacheFile), []byte("{not json")) @@ -133,6 +138,7 @@ func TestHashCacheCorruptFileIsEmpty(t *testing.T) { } func TestPutChecksContentWhenSourceMetadataMatches(t *testing.T) { + t.Parallel() e := newTestEnv(t) const name = "changed.bin" file := singleFile(t, e, name, []byte("new bytes")) @@ -160,6 +166,7 @@ func TestPutChecksContentWhenSourceMetadataMatches(t *testing.T) { } func TestHashCacheFilePerms(t *testing.T) { + t.Parallel() if runtime.GOOS == "windows" { t.Skip("Windows has no permission bits") } @@ -188,6 +195,7 @@ func TestHashCacheFilePerms(t *testing.T) { } func TestHashFileSetsDigestAndIdentity(t *testing.T) { + t.Parallel() content := patterned(3<<20+5, 1) file := filepath.Join(t.TempDir(), "a.bin") writeFile(t, file, content) @@ -209,6 +217,7 @@ func TestHashFileSetsDigestAndIdentity(t *testing.T) { } func TestHashFileHonorsContext(t *testing.T) { + t.Parallel() file := filepath.Join(t.TempDir(), "a.bin") writeFile(t, file, patterned(1<<20, 1)) ctx, cancel := context.WithCancel(t.Context()) @@ -244,6 +253,7 @@ type changedWhileReadCase struct { // TestHashFileRefusesAFileThatChangesWhileItIsRead: a file that grows, shrinks or is touched during the read is not hashed. func TestHashFileRefusesAFileThatChangesWhileItIsRead(t *testing.T) { + t.Parallel() cases := []changedWhileReadCase{ { name: "grows", @@ -311,6 +321,7 @@ func TestHashFileRefusesAFileThatChangesWhileItIsRead(t *testing.T) { } func TestUnchanged(t *testing.T) { + t.Parallel() file := filepath.Join(t.TempDir(), "a.bin") writeFile(t, file, patterned(10, 1)) info, err := os.Stat(file) diff --git a/internal/volumes/put/part_digest_test.go b/internal/volumes/put/part_digest_test.go index 595bea1f..98fc02d5 100644 --- a/internal/volumes/put/part_digest_test.go +++ b/internal/volumes/put/part_digest_test.go @@ -89,6 +89,7 @@ var treeSizes = map[string]int64{ // TestPutReadsEachFileTwice: hashing reads a file once for its digest and every part's digest, and // the send reads each part once more; nothing else reads it. func TestPutReadsEachFileTwice(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := resumeTree(t, e) vol := e.cloud.newVolume("model-weights", "") @@ -111,6 +112,7 @@ func TestPutReadsEachFileTwice(t *testing.T) { // TestPutCacheHitReadsEachFileOnce: a cache entry with the part digests stands for the hashing read, // so the file is read only to send it. func TestPutCacheHitReadsEachFileOnce(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := resumeTree(t, e) vol := e.cloud.newVolume("model-weights", "") @@ -148,6 +150,7 @@ func TestPutCacheHitReadsEachFileOnce(t *testing.T) { // TestPutOldCacheEntryIsAMiss: an entry saved before part digests were cached is a miss, so the file is // hashed again rather than read a third time to find its part digests. func TestPutOldCacheEntryIsAMiss(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := resumeTree(t, e) vol := e.cloud.newVolume("model-weights", "") @@ -221,6 +224,7 @@ func cachedTree(t *testing.T, opts Options) []Source { // TestHashCacheNeedsEveryPartDigest: an entry for a file of several parts is a hit only with a digest // for each part, and an entry for a one-part file answers the file's digest as its part's. func TestHashCacheNeedsEveryPartDigest(t *testing.T) { + t.Parallel() c := loadHashCache(t.TempDir()) mod := time.Unix(1, 0) sum := [32]byte{1} @@ -251,6 +255,7 @@ func TestHashCacheNeedsEveryPartDigest(t *testing.T) { // TestHashFileDigestsEveryPart: hashing gives each part of the layout the digest of its bytes. func TestHashFileDigestsEveryPart(t *testing.T) { + t.Parallel() file := filepath.Join(t.TempDir(), bigName) writeTwoPartFile(t, file) src := Source{Abs: file} @@ -282,6 +287,7 @@ type partChange struct { // part is sent, with the file's size and times unchanged, stop the part before its last segment is // sealed: it is never acknowledged and the put aborts. func TestChangeBetweenHashingAndSendNeverCompletesThePart(t *testing.T) { + t.Parallel() for _, tc := range []partChange{ { name: "in the first part", @@ -295,6 +301,7 @@ func TestChangeBetweenHashingAndSendNeverCompletesThePart(t *testing.T) { }, } { t.Run(tc.name, func(t *testing.T) { + t.Parallel() e := newTestEnv(t) file := filepath.Join(e.srcDir, bigName) writeTwoPartFile(t, file) @@ -360,6 +367,7 @@ type statChange struct { // file's size and times are checked against hashing, so a file that grew, or whose modification time // moved, after it was hashed never sends its last part, even when every part's bytes still match. func TestChangeBeforeTheLastPartStopsItBeforeItIsSent(t *testing.T) { + t.Parallel() for _, tc := range []statChange{ { name: "it grows by a byte", @@ -376,6 +384,7 @@ func TestChangeBeforeTheLastPartStopsItBeforeItIsSent(t *testing.T) { }, } { t.Run(tc.name, func(t *testing.T) { + t.Parallel() e := newTestEnv(t) file := filepath.Join(e.srcDir, bigName) writeTwoPartFile(t, file) diff --git a/internal/volumes/put/part_retry_test.go b/internal/volumes/put/part_retry_test.go index c2c1da2a..e6fa3206 100644 --- a/internal/volumes/put/part_retry_test.go +++ b/internal/volumes/put/part_retry_test.go @@ -87,6 +87,7 @@ func newTestPart(t *testing.T, tr Transport, plain []byte) (*runner, *fileState, } func TestPartRetryTimeBudget(t *testing.T) { + t.Parallel() for _, stall := range []time.Duration{0, 2 * time.Minute} { t.Run(stall.String(), func(t *testing.T) { synctest.Test(t, func(t *testing.T) { @@ -127,6 +128,7 @@ func (s *slowSuccessfulRetry) PutPart(ctx context.Context, _ Target, body io.Rea } func TestPartRetryCanFinishAfterRetryWindow(t *testing.T) { + t.Parallel() synctest.Test(t, func(t *testing.T) { tr := &slowSuccessfulRetry{} result, err := sendTestPart(t, tr) @@ -168,6 +170,7 @@ func (d *droppingTransport) PutPart(ctx context.Context, _ Target, body io.Reade // TestPartRetryWindowRestartsAfterSlowAttempts: attempts that each send for longer than the retry // window, as one part does among many on a slow link, keep getting retries. func TestPartRetryWindowRestartsAfterSlowAttempts(t *testing.T) { + t.Parallel() synctest.Test(t, func(t *testing.T) { tr := &droppingTransport{ attemptTime: 14 * time.Minute, @@ -185,6 +188,7 @@ func TestPartRetryWindowRestartsAfterSlowAttempts(t *testing.T) { // part, after sending 17 MiB of 18, more than the production threshold but less than the part, // restarts the retry window, so slow attempts that each drop before the end keep getting retries. func TestPartRetryWindowRestartsAfterAPartialSend(t *testing.T) { + t.Parallel() synctest.Test(t, func(t *testing.T) { tr := &droppingTransport{ attemptTime: 6 * time.Minute, @@ -202,6 +206,7 @@ func TestPartRetryWindowRestartsAfterAPartialSend(t *testing.T) { // TestPartFastFailuresStopAtTheAttemptLimit: attempts that send the body and fail at once restart // the retry window every time, and still stop at the attempt limit. func TestPartFastFailuresStopAtTheAttemptLimit(t *testing.T) { + t.Parallel() synctest.Test(t, func(t *testing.T) { tr := &droppingTransport{ attemptTime: 0, @@ -249,6 +254,7 @@ func (b *bufferedStallTransport) PutPart(ctx context.Context, _ Target, body io. // The last case keeps the production threshold and stalls after 16 MiB, written as a literal so // that lowering maxBufferedPartBytes below the send buffers it is sized for fails the test. func TestPartStalledRetriesStopAtTheRetryWindow(t *testing.T) { + t.Parallel() cases := []struct { threshold int64 // the runner's threshold; zero is maxBufferedPartBytes buffered int64 // bytes each stalled attempt sends @@ -333,6 +339,7 @@ func steadyGaps(n int, every time.Duration) []time.Duration { // the window, so an attempt that proves nothing stops the part after two attempts, and one that // proves progress lets it retry until it gets through or reaches the attempt limit. func TestPartRetryWindowRestartsAfterSlowReads(t *testing.T) { + t.Parallel() const tick = time.Nanosecond cases := []struct { name string diff --git a/internal/volumes/put/part_stream_test.go b/internal/volumes/put/part_stream_test.go index 819c1bb7..20a78a96 100644 --- a/internal/volumes/put/part_stream_test.go +++ b/internal/volumes/put/part_stream_test.go @@ -52,6 +52,7 @@ func (c *changingTransport) PutPart(_ context.Context, _ Target, body io.Reader, // TestChangeInsideAStreamingPartStopsBeforeItsLastSegment: bytes that change in a part while it // streams fail the send before the part's last segment goes out, without a retry. func TestChangeInsideAStreamingPartStopsBeforeItsLastSegment(t *testing.T) { + t.Parallel() segments := int64(volumeformat.MinSegmentsPerPart) plain := patterned(int(segments*volumeformat.SegmentPlaintextBytes), 3) tr := &changingTransport{after: volumeformat.SaltBytes + 2*volumeformat.SegmentBytes} @@ -72,6 +73,7 @@ func TestChangeInsideAStreamingPartStopsBeforeItsLastSegment(t *testing.T) { // TestChangeInsideAStreamingPartAbortsThePut: a file changed while one of its parts streams is never // acknowledged, and the put aborts and publishes nothing. func TestChangeInsideAStreamingPartAbortsThePut(t *testing.T) { + t.Parallel() e := newTestEnv(t) file := filepath.Join(e.srcDir, "big.bin") writeTwoPartFile(t, file) @@ -226,6 +228,7 @@ func (c *countingTransport) PutPart(ctx context.Context, target Target, body io. // TestPutStopsAtAReadErrorOfAStreamingPart: an I/O error reading a part while it streams stops the // put at once with that error, rather than being retried as a failure of the network. func TestPutStopsAtAReadErrorOfAStreamingPart(t *testing.T) { + t.Parallel() e := newTestEnv(t) file := filepath.Join(e.srcDir, "data.bin") writeFile(t, file, patterned(3*volumeformat.SegmentPlaintextBytes, 5)) diff --git a/internal/volumes/put/progress_test.go b/internal/volumes/put/progress_test.go index 922f97d0..a9a6cdef 100644 --- a/internal/volumes/put/progress_test.go +++ b/internal/volumes/put/progress_test.go @@ -8,6 +8,7 @@ import ( ) func TestFormatBytes(t *testing.T) { + t.Parallel() for n, want := range map[int64]string{ 0: "0 B", 1023: "1023 B", @@ -28,6 +29,7 @@ func TestFormatBytes(t *testing.T) { } func TestProgressLine(t *testing.T) { + t.Parallel() start := time.Unix(1000, 0) p := &progress{ label: "uploading", @@ -51,6 +53,7 @@ func TestProgressLine(t *testing.T) { } func TestNilProgressIsSilent(t *testing.T) { + t.Parallel() var p *progress p.begin("hashing", 1, 1) p.addBytes(1) @@ -63,6 +66,7 @@ func TestNilProgressIsSilent(t *testing.T) { // TestProgressIntervals: a line every few seconds off a terminal, and a rewrite each second on one. func TestProgressIntervals(t *testing.T) { + t.Parallel() if p := newProgress(io.Discard, false, 0, time.Now, nil); p.every < time.Second || p.every > 10*time.Second { t.Errorf("the default interval off a terminal is %v, want a few seconds", p.every) } @@ -90,6 +94,7 @@ func waitFor(t *testing.T, what string, cond func() bool) { } func TestProgressTerminalRewritesOneLine(t *testing.T) { + t.Parallel() var buf lockedBuffer tick := make(chan time.Time) now := time.Unix(1000, 0) @@ -114,6 +119,7 @@ func TestProgressTerminalRewritesOneLine(t *testing.T) { } func TestProgressPrintsLinesWithoutATerminal(t *testing.T) { + t.Parallel() var buf lockedBuffer tick := make(chan time.Time) now := time.Unix(1000, 0) @@ -137,6 +143,7 @@ func TestProgressPrintsLinesWithoutATerminal(t *testing.T) { } func TestProgressPhasesEndEachOther(t *testing.T) { + t.Parallel() var buf lockedBuffer p := newProgress(&buf, false, time.Minute, time.Now, nil) diff --git a/internal/volumes/put/put_test.go b/internal/volumes/put/put_test.go index 4430e9a0..a483d951 100644 --- a/internal/volumes/put/put_test.go +++ b/internal/volumes/put/put_test.go @@ -58,6 +58,7 @@ func requireFiles(t *testing.T, e *testEnv, vol VolumeRef, want []VolumeFile) st // AC 1: a directory put twice leaves the digest unchanged and sends nothing the second time. func TestPutNewVolumeThenRepeat(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := standardTree(t, e) vol := e.cloud.newVolume("model-weights", "") @@ -107,6 +108,7 @@ func TestPutNewVolumeThenRepeat(t *testing.T) { } func TestPutUnderDestinationDirectory(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := standardTree(t, e) vol := e.cloud.newVolume("model-weights", "") @@ -127,6 +129,7 @@ func TestPutUnderDestinationDirectory(t *testing.T) { } func TestPutAddressesTheEnvironment(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := standardTree(t, e) staging := e.cloud.newVolume("model-weights", "staging") @@ -144,6 +147,7 @@ func TestPutAddressesTheEnvironment(t *testing.T) { // AC 2: one new file uploads alone. func TestPutAddsOneFile(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := standardTree(t, e) vol := e.cloud.newVolume("model-weights", "") @@ -170,6 +174,7 @@ func TestPutAddsOneFile(t *testing.T) { // AC 2: the same files in another Volume send no file bytes. func TestPutReuseAcrossVolumes(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := standardTree(t, e) first := e.cloud.newVolume("first", "") @@ -195,6 +200,7 @@ func TestPutReuseAcrossVolumes(t *testing.T) { } func TestPutModeChangeReplacesThePathAndReusesItsContent(t *testing.T) { + t.Parallel() e := newTestEnv(t) file := singleFile(t, e, "example.sh", []byte("example")) vol := e.cloud.newVolume("model-weights", "") @@ -221,6 +227,7 @@ func TestPutModeChangeReplacesThePathAndReusesItsContent(t *testing.T) { // AC 3: a changed file uploads whole and nothing else does. func TestPutChangedFile(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := standardTree(t, e) vol := e.cloud.newVolume("model-weights", "") @@ -253,6 +260,7 @@ func TestPutChangedFile(t *testing.T) { // AC 3: a file rewritten at the same size with its modification time put back uploads its new content. func TestPutReusedFileWithRestoredMtimeUploadsNewContent(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := filepath.Join(e.srcDir, "weights") file := filepath.Join(dir, "model.bin") @@ -346,6 +354,7 @@ func (r *recordedOpen) OpenUpload(ctx context.Context, vol VolumeRef, open Uploa // AC 4: the engine passes the configured organization to Keys and uses the returned key pair to open the upload. func TestPutUsesConfiguredOrganizationAndReturnedKeyPair(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := standardTree(t, e) rec := &recordedOpen{API: e.cloud} @@ -399,6 +408,7 @@ func TestPutRequiresOrganization(t *testing.T) { // AC 5: the text summary. func TestPutSummaryText(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := standardTree(t, e) vol := e.cloud.newVolume("model-weights", "") @@ -465,6 +475,7 @@ func requireSummaryKeys(t *testing.T, raw []byte) { // AC 5: the JSON summary matches the Volume's latest files. func TestPutSummaryJSON(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := standardTree(t, e) vol := e.cloud.newVolume("model-weights", "") @@ -507,6 +518,7 @@ func TestPutSummaryJSON(t *testing.T) { // AC 6: the help states the additive rules and promises no deletion. func TestPutHelpText(t *testing.T) { + t.Parallel() help := strings.Join(strings.Fields(HelpShort+" "+HelpLong+" "+HelpExample), " ") const localLinkAdvice = "If a link points outside the local directory, remove the link or replace it with a copy of its target." for _, want := range []string{ @@ -600,6 +612,7 @@ type answerCase struct { } func TestPutAbortsOnBrokenAnswers(t *testing.T) { + t.Parallel() cases := []answerCase{ { name: "fewer answers than files", @@ -662,6 +675,7 @@ func TestPutAbortsOnBrokenAnswers(t *testing.T) { // AC 7: a file changed after hashing aborts the session and the error names it. func TestPutSourceChangedAborts(t *testing.T) { + t.Parallel() cases := []changeCase{ { name: "after hashing, before it is declared", @@ -717,6 +731,7 @@ func TestPutSourceChangedAborts(t *testing.T) { // AC 7: a reused file is checked by size and time too. func TestPutReusedFileChangedAborts(t *testing.T) { + t.Parallel() e := newTestEnv(t) file := filepath.Join(e.srcDir, "model", "weights.bin") writeFile(t, file, patterned(64, 1)) @@ -742,6 +757,7 @@ type truncationCase struct { // AC 7: a file truncated during the upload is a changed file. Truncated before its parts are sent, // the check of its size finds it; truncated while a part streams, that part finds it short. func TestPutTruncatedDuringUploadAborts(t *testing.T) { + t.Parallel() for _, tc := range []truncationCase{ { name: "before its parts are sent", @@ -818,6 +834,7 @@ func (h *heldPart) PutPart(ctx context.Context, target Target, body io.Reader, l } func TestPutRechecksEverySourceBeforePublish(t *testing.T) { + t.Parallel() for _, firstReused := range []bool{false, true} { name := "uploaded" if firstReused { diff --git a/internal/volumes/put/resume_journal_test.go b/internal/volumes/put/resume_journal_test.go index 92e3126f..a565eff9 100644 --- a/internal/volumes/put/resume_journal_test.go +++ b/internal/volumes/put/resume_journal_test.go @@ -9,6 +9,7 @@ import ( ) func TestLoadSavedRejectsInvalidJournal(t *testing.T) { + t.Parallel() type journalCase struct { name string data string diff --git a/internal/volumes/put/resume_recovery_test.go b/internal/volumes/put/resume_recovery_test.go index 104c665e..1fe5dbbb 100644 --- a/internal/volumes/put/resume_recovery_test.go +++ b/internal/volumes/put/resume_recovery_test.go @@ -27,6 +27,7 @@ func (b blockedPart) PutPart(ctx context.Context, target Target, body io.Reader, } func TestConcurrentPutLeavesActiveSessionAlone(t *testing.T) { + t.Parallel() e := newTestEnv(t) vol := e.cloud.newVolume("weights", "") first := singleFile(t, e, "first.txt", []byte("first")) @@ -64,6 +65,7 @@ func TestConcurrentPutLeavesActiveSessionAlone(t *testing.T) { } func TestResumeRecoversVerifiedFileFromOlderSnapshot(t *testing.T) { + t.Parallel() for _, when := range []string{"before declaration answer", "before part acknowledgement"} { t.Run(when, func(t *testing.T) { e := newTestEnv(t) @@ -104,6 +106,7 @@ func TestResumeRecoversVerifiedFileFromOlderSnapshot(t *testing.T) { } func TestIndependentPutLeavesSavedSessionAvailable(t *testing.T) { + t.Parallel() e := newTestEnv(t) vol := e.cloud.newVolume("weights", "") first := filepath.Join(t.TempDir(), "model.bin") @@ -165,6 +168,7 @@ func TestIndependentPutLeavesSavedSessionAvailable(t *testing.T) { } func TestIndependentPutPreservesOverlappingLegacySession(t *testing.T) { + t.Parallel() e := newTestEnv(t) vol := e.cloud.newVolume("weights", "") first := singleFile(t, e, "first.txt", []byte("first")) @@ -187,6 +191,7 @@ func TestIndependentPutPreservesOverlappingLegacySession(t *testing.T) { } func TestEmptyLegacySessionDoesNotMatchTargets(t *testing.T) { + t.Parallel() r := runner{invocation: "current"} targets := map[string]struct{}{ "first.txt": {}, @@ -197,6 +202,7 @@ func TestEmptyLegacySessionDoesNotMatchTargets(t *testing.T) { } func TestResumeRefusesFreshPutAfterUnconfirmedPublication(t *testing.T) { + t.Parallel() e := newTestEnv(t) vol := e.cloud.newVolume("weights", "") singleFile(t, e, "model.bin", []byte("original")) @@ -228,6 +234,7 @@ func TestResumeRefusesFreshPutAfterUnconfirmedPublication(t *testing.T) { } func TestPutKeepsSavedSessionsScopedToAPI(t *testing.T) { + t.Parallel() first := newTestEnv(t) second := newTestEnv(t) second.configDir = first.configDir @@ -266,6 +273,7 @@ func TestPutKeepsSavedSessionsScopedToAPI(t *testing.T) { } func TestOnlyDefaultAPIResumesJournalWithoutAnEndpoint(t *testing.T) { + t.Parallel() e := newTestEnv(t) vol := e.cloud.newVolume("weights", "") file := singleFile(t, e, "model.bin", []byte("original")) @@ -289,6 +297,7 @@ func TestOnlyDefaultAPIResumesJournalWithoutAnEndpoint(t *testing.T) { } func TestResumeRefusesChangeAfterUnappliedPublication(t *testing.T) { + t.Parallel() e := newTestEnv(t) vol := e.cloud.newVolume("weights", "") file := singleFile(t, e, "model.bin", []byte("original")) @@ -311,6 +320,7 @@ func TestResumeRefusesChangeAfterUnappliedPublication(t *testing.T) { } func TestResumeReportsUncertainPublicationIfSourceDisappearsDuringHash(t *testing.T) { + t.Parallel() e := newTestEnv(t) vol := e.cloud.newVolume("weights", "") file := singleFile(t, e, "model.bin", []byte("original")) diff --git a/internal/volumes/put/resume_test.go b/internal/volumes/put/resume_test.go index d41ef7b7..6c1c3cf0 100644 --- a/internal/volumes/put/resume_test.go +++ b/internal/volumes/put/resume_test.go @@ -256,6 +256,7 @@ func (s *sealRecorder) dataKeys() [][]byte { // TestSealRecorderCatchesReuse: the instrument reports a key and nonce pair that seals two plaintexts. func TestSealRecorderCatchesReuse(t *testing.T) { + t.Parallel() var rec sealRecorder key, salt := bytes.Repeat([]byte{1}, 32), bytes.Repeat([]byte{2}, 16) rec.add(sealRecord{ @@ -408,6 +409,7 @@ func patchFile(t *testing.T, p string, off int64, b []byte) { // AC 1: an interrupted put resumes from its acknowledged parts, sends none of them again and completes once. func TestResumeSendsOnlyUnacknowledgedParts(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := resumeTree(t, e) vol := e.cloud.newVolume("model-weights", "") @@ -449,6 +451,7 @@ func TestResumeSendsOnlyUnacknowledgedParts(t *testing.T) { // AC 1 and 2: a file that changed since the interrupt aborts the saved session, changes nothing in the // Volume, and the next put opens a new session with fresh keys. func TestResumeAbortsAChangedFileAndStartsOver(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := resumeTree(t, e) vol := e.cloud.newVolume("model-weights", "") @@ -492,6 +495,7 @@ func TestResumeAbortsAChangedFileAndStartsOver(t *testing.T) { // the part's last segment, or the size and time check before the last part stops it first. The session // aborts, nothing reaches the Volume, the state is gone, and the next put starts over. func TestResumeAbortsWhenAPartChangedBeforeItsRetry(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := resumeTree(t, e) vol := e.cloud.newVolume("model-weights", "") @@ -598,6 +602,7 @@ func TestResumeRehashesAFileTheCacheWouldTrust(t *testing.T) { // first went out, so a journalled digest that differs aborts the saved session before any part is sent // again, even when the file's own digest still matches. func TestResumeAbortsWhenAJournalledPartDigestDiffers(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := resumeTree(t, e) vol := e.cloud.newVolume("model-weights", "") @@ -641,6 +646,7 @@ func TestResumeAbortsWhenAJournalledPartDigestDiffers(t *testing.T) { // AC 2: a retry reads the part from the file again, and a part whose bytes changed since they were // journalled stops before its last segment is sealed: the put fails and the changed bytes never go out. func TestRetryOfAChangedPartFailsBeforeItCompletes(t *testing.T) { + t.Parallel() e := newTestEnv(t) content := patterned(5000, 1) file := singleFile(t, e, "weights.bin", content) @@ -683,6 +689,7 @@ func TestRetryOfAChangedPartFailsBeforeItCompletes(t *testing.T) { // AC 2: a retry of an unchanged part reads it from the file again and seals the same plaintext, every // segment of it, under a fresh salt. func TestRetryResealsTheSameBytes(t *testing.T) { + t.Parallel() e := newTestEnv(t) size := 3*volumeformat.SegmentPlaintextBytes + 7 file := singleFile(t, e, "weights.bin", patterned(size, 1)) @@ -715,6 +722,7 @@ func TestRetryResealsTheSameBytes(t *testing.T) { // AC 3: resuming from a snapshot taken before a part was acknowledged seals that part again under a // fresh salt, so no key and nonce pair repeats, and the session still completes. func TestResumeFromRolledBackState(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := resumeTree(t, e) vol := e.cloud.newVolume("model-weights", "") @@ -752,6 +760,7 @@ func TestResumeFromRolledBackState(t *testing.T) { // before the part was read again. The part is sealed with other plaintext under the same data key, and // only the per-part salt keeps every key and nonce pair unique; the whole-file check then aborts. func TestRolledBackStateNeverRepeatsAKeyAndNonce(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := resumeTree(t, e) big := filepath.Join(dir, bigName) @@ -791,6 +800,7 @@ func TestRolledBackStateNeverRepeatsAKeyAndNonce(t *testing.T) { // AC 3: two copies of the same state resume one session; the second finds it completed, seals nothing // new and removes its state. func TestResumeFromCopiedState(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := resumeTree(t, e) vol := e.cloud.newVolume("model-weights", "") @@ -825,6 +835,7 @@ func TestResumeFromCopiedState(t *testing.T) { // AC 4: resume state is 0700 and 0600, a resume narrows modes a copy widened, and completion removes it. func TestResumeStateModes(t *testing.T) { + t.Parallel() if runtime.GOOS == goosWindows { t.Skip("POSIX modes") } @@ -871,6 +882,7 @@ func TestResumeStateModes(t *testing.T) { // AC 4: expired state is removed, for every Volume, and unreadable state once it is older than any session. func TestExpiredStateIsRemoved(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := resumeTree(t, e) vol := e.cloud.newVolume("model-weights", "") @@ -909,6 +921,7 @@ func TestExpiredStateIsRemoved(t *testing.T) { // A saved key that no longer opens under the session sealing key is lost: the session is aborted and the // put starts over. func TestLostKeyAbortsTheSavedSession(t *testing.T) { + t.Parallel() cases := map[string]func(t *testing.T, snap journalSnapshot, index int){ "a key that does not open": func(t *testing.T, snap journalSnapshot, index int) { keys := snap.Keys[index] @@ -929,6 +942,7 @@ func TestLostKeyAbortsTheSavedSession(t *testing.T) { } for name, lose := range cases { t.Run(name, func(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := resumeTree(t, e) vol := e.cloud.newVolume("model-weights", "") @@ -964,6 +978,7 @@ func TestLostKeyAbortsTheSavedSession(t *testing.T) { // A file whose content the session reused has no saved keys left; the resume still continues the session. func TestResumeWithAReusedFile(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := resumeTree(t, e) small := singleFile(t, e, "small.txt", patterned(3000, 7)) @@ -996,6 +1011,7 @@ func TestResumeWithAReusedFile(t *testing.T) { // State saved in another journal format is not resumed: the session is aborted and the put starts over. func TestOtherJournalVersionAbortsTheSavedSession(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := resumeTree(t, e) vol := e.cloud.newVolume("model-weights", "") @@ -1023,6 +1039,7 @@ func TestOtherJournalVersionAbortsTheSavedSession(t *testing.T) { // A crash during a journal write leaves a torn last line; the resume drops it and carries on. func TestResumeDropsATornLastLine(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := resumeTree(t, e) vol := e.cloud.newVolume("model-weights", "") @@ -1053,6 +1070,7 @@ func TestResumeDropsATornLastLine(t *testing.T) { // AC 5: an interrupted and resumed upload at debug level writes no data key, session sealing key, // sealed key, part token or acknowledgement to its output, its errors or its log. func TestResumeCanaryHoldsNoSecrets(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := resumeTree(t, e) vol := e.cloud.newVolume("model-weights", "") @@ -1097,6 +1115,7 @@ func TestResumeCanaryHoldsNoSecrets(t *testing.T) { // A resumed put that is interrupted again keeps the session for the next resume, as a fresh put does. func TestInterruptedResumeKeepsTheSession(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := resumeTree(t, e) vol := e.cloud.newVolume("model-weights", "") @@ -1135,6 +1154,7 @@ func TestInterruptedResumeKeepsTheSession(t *testing.T) { // A resumed put that runs out of part retries keeps its acknowledged parts for the next run. func TestResumeOutOfRetriesKeepsSession(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := resumeTree(t, e) vol := e.cloud.newVolume("model-weights", "") @@ -1176,6 +1196,7 @@ func TestResumeOutOfRetriesKeepsSession(t *testing.T) { // A resumed put retries its completion through an outage, as a fresh put does. func TestResumedCompletionRecoversAfterExtendedOutage(t *testing.T) { + t.Parallel() e := newTestEnv(t) dir := resumeTree(t, e) vol := e.cloud.newVolume("model-weights", "") diff --git a/internal/volumes/put/retry_test.go b/internal/volumes/put/retry_test.go index cdd463be..1f67eefd 100644 --- a/internal/volumes/put/retry_test.go +++ b/internal/volumes/put/retry_test.go @@ -76,6 +76,7 @@ func (a *transientUploadAPI) CompleteUpload(ctx context.Context, ref UploadRef) } func TestPutRetriesTransientUploadAPICalls(t *testing.T) { + t.Parallel() for _, operation := range []string{"declare", retryRenewOperation, "complete-file", "complete"} { t.Run(operation, func(t *testing.T) { e := newTestEnv(t) @@ -128,6 +129,7 @@ func (a *unavailableCompletion) CompleteUpload(ctx context.Context, ref UploadRe } func TestUploadCompletionRecoversAfterExtendedOutage(t *testing.T) { + t.Parallel() e := newTestEnv(t) file := singleFile(t, e, "weights.bin", patterned(20, 1)) vol := e.cloud.newVolume("model-weights", "") @@ -150,6 +152,7 @@ func TestUploadCompletionRecoversAfterExtendedOutage(t *testing.T) { } func TestPublicationRetryRefusesChangedSource(t *testing.T) { + t.Parallel() e := newTestEnv(t) file := singleFile(t, e, "weights.bin", []byte("original")) vol := e.cloud.newVolume("weights", "") @@ -189,6 +192,7 @@ func (a *transientAbort) AbortUpload(ctx context.Context, ref UploadRef) error { } func TestSourceChangeRetriesAbort(t *testing.T) { + t.Parallel() e := newTestEnv(t) file := singleFile(t, e, "weights.bin", patterned(20, 1)) vol := e.cloud.newVolume("model-weights", "") @@ -211,6 +215,7 @@ func TestSourceChangeRetriesAbort(t *testing.T) { } func TestRenewalBackoffDoesNotPassSessionDeadline(t *testing.T) { + t.Parallel() e := newTestEnv(t) file := singleFile(t, e, "weights.bin", patterned(20, 1)) vol := e.cloud.newVolume("model-weights", "") @@ -233,6 +238,7 @@ func TestRenewalBackoffDoesNotPassSessionDeadline(t *testing.T) { } func TestUploadAPIStopsRetriesOnCancellation(t *testing.T) { + t.Parallel() ctx, cancel := context.WithCancel(t.Context()) defer cancel() calls, pauses := 0, 0 @@ -250,6 +256,7 @@ func TestUploadAPIStopsRetriesOnCancellation(t *testing.T) { } func TestAbortDeadlinePreservesLastServerError(t *testing.T) { + t.Parallel() synctest.Test(t, func(t *testing.T) { unavailable := &ProblemError{Status: http.StatusServiceUnavailable} api := &failingAbort{err: unavailable} @@ -284,6 +291,7 @@ func (a *lostCompletionResponse) CompleteUpload(ctx context.Context, ref UploadR } func TestLostCompletionCanBeRecovered(t *testing.T) { + t.Parallel() for _, name := range []string{"cancelled during backoff", "retry limit reached"} { t.Run(name, func(t *testing.T) { e := newTestEnv(t) @@ -327,6 +335,7 @@ func TestLostCompletionCanBeRecovered(t *testing.T) { } func TestUploadAPIPreservesAuthErrorsWithoutRetrying(t *testing.T) { + t.Parallel() for _, status := range []int{http.StatusUnauthorized, http.StatusForbidden} { t.Run(http.StatusText(status), func(t *testing.T) { authErr := transport.CreateRunwareError("forbidden", http.StatusText(status), transport.RunwareErrorDetails{ @@ -376,6 +385,7 @@ func (s *stalledCompletion) CompleteUpload(ctx context.Context, _ UploadRef) (Up // request limit, put stops retrying after maxCompletionRetryTime, not after // maxUploadAttempts stalls. func TestCompletionRetryTimeBudget(t *testing.T) { + t.Parallel() calls := map[string]func(ctx context.Context, r *runner) error{ "file": func(ctx context.Context, r *runner) error { return r.completeFile(ctx, &fileState{src: &Source{Abs: "weights.bin"}}) diff --git a/internal/volumes/put/transport_test.go b/internal/volumes/put/transport_test.go index 360df1c0..375f8ea8 100644 --- a/internal/volumes/put/transport_test.go +++ b/internal/volumes/put/transport_test.go @@ -41,6 +41,7 @@ func problemHandler(status int, body string) http.HandlerFunc { } func TestHTTPTransportPutsPart(t *testing.T) { + t.Parallel() var gotMethod, gotAuth, gotType, gotAgent string var gotLength int64 var gotBody []byte @@ -69,6 +70,7 @@ func TestHTTPTransportPutsPart(t *testing.T) { } func TestHTTPTransportDoesNotInheritClientTimeout(t *testing.T) { + t.Parallel() srv := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if _, err := io.Copy(io.Discard, r.Body); err != nil { return @@ -98,6 +100,7 @@ type problemCase struct { } func TestHTTPTransportMapsProblems(t *testing.T) { + t.Parallel() const base = `{"type":"https://docs.runware.ai/serverless/errors#` cases := []problemCase{ { @@ -166,6 +169,7 @@ type badAckCase struct { } func TestHTTPTransportRefusesBadAcks(t *testing.T) { + t.Parallel() cases := []badAckCase{ { name: "another part", @@ -198,6 +202,7 @@ func TestHTTPTransportRefusesBadAcks(t *testing.T) { } func TestHTTPTransportAcceptsAnAckAtTheBound(t *testing.T) { + t.Parallel() ack := strings.Repeat("a", 1024) tr, target := newWorker(t, func(w http.ResponseWriter, _ *http.Request) { _, _ = io.WriteString(w, `{"partNumber":3,"ack":"`+ack+`"}`) @@ -232,6 +237,7 @@ type roundGate struct { // TestDefaultTransportKeepsAnHTTP1ConnectionPerPart sends the most parts the engine runs at once, twice, to a server that offers HTTP/2. func TestDefaultTransportKeepsAnHTTP1ConnectionPerPart(t *testing.T) { + t.Parallel() const rounds = 2 parts := MaxParallelism seen := &connections{ @@ -291,6 +297,7 @@ func TestDefaultTransportKeepsAnHTTP1ConnectionPerPart(t *testing.T) { } func TestHTTPTransportRefusesCleartext(t *testing.T) { + t.Parallel() var requests atomic.Int32 srv := httptest.NewServer(http.HandlerFunc(func(http.ResponseWriter, *http.Request) { requests.Add(1) })) t.Cleanup(srv.Close) @@ -316,6 +323,7 @@ func TestHTTPTransportRefusesCleartext(t *testing.T) { } func TestHTTPTransportDoesNotFollowRedirects(t *testing.T) { + t.Parallel() var elsewhere atomic.Int32 other := httptest.NewTLSServer(http.HandlerFunc(func(http.ResponseWriter, *http.Request) { elsewhere.Add(1) })) t.Cleanup(other.Close) @@ -332,6 +340,7 @@ func TestHTTPTransportDoesNotFollowRedirects(t *testing.T) { } func TestHTTPTransportErrorsHoldNoAddress(t *testing.T) { + t.Parallel() srv := httptest.NewTLSServer(http.NotFoundHandler()) tr := NewHTTPTransport(srv.Client()) target := Target{ @@ -358,6 +367,7 @@ type retryableCase struct { } func TestRetryable(t *testing.T) { + t.Parallel() cases := []retryableCase{ { name: "a broken connection", @@ -413,6 +423,7 @@ func TestRetryable(t *testing.T) { } func TestDefaultTransportBoundsAStalledAnswer(t *testing.T) { + t.Parallel() tr, ok := NewHTTPTransport(nil).client.Transport.(*http.Transport) if !ok { t.Fatal("the default client has no *http.Transport") @@ -424,6 +435,7 @@ func TestDefaultTransportBoundsAStalledAnswer(t *testing.T) { // TestHTTPTransportStopsReadingTheBodyOnReturn: a refusal that comes before the body is sent leaves no read of it running. func TestHTTPTransportStopsReadingTheBodyOnReturn(t *testing.T) { + t.Parallel() tr, target := newWorker(t, problemHandler(http.StatusRequestEntityTooLarge, "too large")) body := &inFlightReader{r: bytes.NewReader(patterned(1<<20, 1))} @@ -444,6 +456,7 @@ type stallCase struct { } func TestHTTPTransportEndsAStalledPart(t *testing.T) { + t.Parallel() cases := []stallCase{ { name: "an answer that stops after its headers", @@ -462,6 +475,7 @@ func TestHTTPTransportEndsAStalledPart(t *testing.T) { } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { + t.Parallel() release := make(chan struct{}) tr, target := newWorker(t, func(w http.ResponseWriter, r *http.Request) { tc.handler(w, r) @@ -483,6 +497,7 @@ func TestHTTPTransportEndsAStalledPart(t *testing.T) { } func TestPartBodyEndsReadsOnStop(t *testing.T) { + t.Parallel() b := &partBody{ r: unreadReader{t: t}, timer: time.AfterFunc(time.Hour, func() {}), @@ -552,6 +567,7 @@ func TestHTTPTransportKeepsASlowPartThatMoves(t *testing.T) { // part's number, status and byte count, and never the upload address, the part // token or the acknowledgement. func TestHTTPTransportDebugLogShowsNoSecret(t *testing.T) { + t.Parallel() const secretAck = "SECRET-ACK" for _, status := range []int{http.StatusOK, http.StatusForbidden} { var logged bytes.Buffer @@ -583,6 +599,7 @@ func TestHTTPTransportDebugLogShowsNoSecret(t *testing.T) { // TestHTTPTransportRefusesATargetTheCheckRefuses: an upload address the target check refuses // is a protocol error, and nothing is sent to it. func TestHTTPTransportRefusesATargetTheCheckRefuses(t *testing.T) { + t.Parallel() var sent atomic.Int32 tr, target := newWorker(t, func(w http.ResponseWriter, _ *http.Request) { sent.Add(1) @@ -612,6 +629,7 @@ func TestHTTPTransportRefusesATargetTheCheckRefuses(t *testing.T) { // TestHTTPTransportSendsToATargetTheCheckAccepts: an accepted upload address is used as given. func TestHTTPTransportSendsToATargetTheCheckAccepts(t *testing.T) { + t.Parallel() tr, target := newWorker(t, func(w http.ResponseWriter, _ *http.Request) { _, _ = io.WriteString(w, `{"partNumber":3,"ack":"kid1.sealed-tag"}`) }) diff --git a/internal/volumes/put/walk_test.go b/internal/volumes/put/walk_test.go index ce1a7421..ba7abca7 100644 --- a/internal/volumes/put/walk_test.go +++ b/internal/volumes/put/walk_test.go @@ -26,6 +26,7 @@ func symlinkOrSkip(t *testing.T, oldname, newname string) { } func TestWalkDirectoryKeepsRelativePaths(t *testing.T) { + t.Parallel() root := filepath.Join(t.TempDir(), "weights") writeTree(t, root, map[string][]byte{ "a.bin": patterned(3, 1), @@ -56,6 +57,7 @@ func TestWalkDirectoryKeepsRelativePaths(t *testing.T) { } func TestWalkSingleFileLandsUnderTo(t *testing.T) { + t.Parallel() dir := t.TempDir() file := filepath.Join(dir, "tokenizer.json") writeFile(t, file, patterned(9, 1)) @@ -71,6 +73,7 @@ func TestWalkSingleFileLandsUnderTo(t *testing.T) { } func TestWalkModeKeepsReadAndExecuteBits(t *testing.T) { + t.Parallel() if runtime.GOOS == "windows" { t.Skip("Windows has no execute bit") } @@ -95,6 +98,7 @@ func TestWalkModeKeepsReadAndExecuteBits(t *testing.T) { } func TestWalkSymlinks(t *testing.T) { + t.Parallel() base := t.TempDir() outside := filepath.Join(base, "outside.bin") writeFile(t, outside, patterned(3, 1)) @@ -164,6 +168,7 @@ func TestWalkSymlinks(t *testing.T) { } func TestWalkRefusesDuplicateTargets(t *testing.T) { + t.Parallel() base := t.TempDir() first, second := filepath.Join(base, "one"), filepath.Join(base, "two") writeFile(t, filepath.Join(first, "x.bin"), patterned(3, 1)) @@ -192,6 +197,7 @@ type targetCase struct { } func TestCheckTarget(t *testing.T) { + t.Parallel() cases := []targetCase{ { name: "plain", @@ -283,6 +289,7 @@ func TestCheckTarget(t *testing.T) { } func TestWalkRefusesInvalidDestination(t *testing.T) { + t.Parallel() file := filepath.Join(t.TempDir(), "a.bin") writeFile(t, file, patterned(3, 1)) @@ -294,6 +301,7 @@ func TestWalkRefusesInvalidDestination(t *testing.T) { } func TestWalkMissingPath(t *testing.T) { + t.Parallel() missing := filepath.Join(t.TempDir(), "nope") _, err := Walk([]string{missing}, "") diff --git a/internal/volumes/put/wire_test.go b/internal/volumes/put/wire_test.go index 2cde408b..a9bfc36e 100644 --- a/internal/volumes/put/wire_test.go +++ b/internal/volumes/put/wire_test.go @@ -40,6 +40,7 @@ func decodeStrict(t *testing.T, data []byte, into any) { } func TestWireTypesMatchUploadFixture(t *testing.T) { + t.Parallel() data, err := os.ReadFile(filepath.Join("testdata", "upload-exchange.json")) if err != nil { t.Fatal(err) @@ -104,6 +105,7 @@ const specResult = `{"upload":{"id":"4b6d8f0a-2c4e-4f6a-8b0d-2f4a6c8e0b33","volu const specCompletion = `{"crc64nvme":"1f2e3d4c5b6a7980","parts":[{"partNumber":1,"ack":"YWNrLWV4YW1wbGUtcGFydC0x"},{"partNumber":2,"ack":"YWNrLWV4YW1wbGUtcGFydC0y"}]}` func TestWireTypesTakeSpecExamples(t *testing.T) { + t.Parallel() var answer DeclarationResult decodeStrict(t, []byte(specDeclareAnswer), &answer) if len(answer.Files) != 2 || answer.Files[0].File.State != stateUploading || len(answer.Files[0].UploadTargets) != 2 { @@ -152,6 +154,7 @@ func TestWireTypesTakeSpecExamples(t *testing.T) { } func TestCheckLayout(t *testing.T) { + t.Parallel() size := int64(10270000000) plan, err := volumeformat.PlanLayout(size) if err != nil { @@ -189,6 +192,7 @@ func TestCheckLayout(t *testing.T) { } func TestSecretIsRedacted(t *testing.T) { + t.Parallel() const value = "eyJ2IjoxfQ.c2lnbmF0dXJl" target := Target{ PartNumber: 1, @@ -227,6 +231,7 @@ type pointerCase struct { } func TestPointerFile(t *testing.T) { + t.Parallel() cases := []pointerCase{ { pointer: "/files/0/size", @@ -256,6 +261,7 @@ func TestPointerFile(t *testing.T) { } func TestParseProblem(t *testing.T) { + t.Parallel() body := `{"type":"https://docs.runware.ai/serverless/errors#volume-limit-exceeded","title":"Conflict","status":409, "detail":"maxFileBytes exceeds its limit","limit":"maxFileBytes","cap":268435456000, "errors":[{"detail":"maxFileBytes exceeds its limit","pointer":"/files/2/size"}]}` @@ -282,6 +288,7 @@ func TestParseProblem(t *testing.T) { } func TestLimitErrorsNameTheLimit(t *testing.T) { + t.Parallel() for limit, want := range map[string]string{ limitFileBytes: "file size", limitStoredBytes: "storage quota", From 1b5edc66ad6d99b50ad6fc66d0f6105ddd475f72 Mon Sep 17 00:00:00 2001 From: Emilio Del Tessandoro Date: Fri, 27 Nov 2026 11:42:16 +0100 Subject: [PATCH 2/3] test(volumes): pin reading time as a sum across short pauses Add two cases to the slow-reads table. Seventy 1 s gaps split by one 20 s pause still restart the retry window: the counted reading sums across the pause instead of starting over. Seven 11 s gaps prove nothing, which pins the longest counted gap at 10 s; the existing boundary cases follow the constant and would not notice it moving. --- internal/volumes/put/part_retry_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/volumes/put/part_retry_test.go b/internal/volumes/put/part_retry_test.go index e6fa3206..7d96da8a 100644 --- a/internal/volumes/put/part_retry_test.go +++ b/internal/volumes/put/part_retry_test.go @@ -355,6 +355,8 @@ func TestPartRetryWindowRestartsAfterSlowReads(t *testing.T) { {name: "reads for a tick under the minimum", gaps: append(steadyGaps(59, time.Second), time.Second-tick), tail: 5 * time.Minute, drops: 3, wantErr: errUploadRetriesExhausted, wantCalls: 2}, {name: "gaps of the longest counted length", gaps: steadyGaps(6, maxReadGap), tail: 5 * time.Minute, drops: 3, wantCalls: 4}, {name: "gaps a tick over the longest counted length", gaps: steadyGaps(7, maxReadGap+tick), tail: 5 * time.Minute, drops: 3, wantErr: errUploadRetriesExhausted, wantCalls: 2}, + {name: "reading summed across a pause", gaps: append(append(steadyGaps(35, time.Second), 20*time.Second), steadyGaps(35, time.Second)...), tail: 5 * time.Minute, drops: 3, wantCalls: 4}, + {name: "gaps of eleven seconds", gaps: steadyGaps(7, 11*time.Second), tail: 5 * time.Minute, drops: 3, wantErr: errUploadRetriesExhausted, wantCalls: 2}, {name: "burst, silence and a late read", gaps: []time.Duration{90 * time.Second}, tail: 4 * time.Minute, drops: 3, wantErr: errUploadRetriesExhausted, wantCalls: 2}, {name: "more slow drops than the attempt limit", gaps: steadyGaps(90, time.Second), drops: maxUploadAttempts + 2, wantErr: errUploadRetriesExhausted, wantCalls: maxUploadAttempts}, } From 604182960503276f3fe4f8a17aa0292a1069c1ba Mon Sep 17 00:00:00 2001 From: Emilio Del Tessandoro Date: Fri, 27 Nov 2026 11:42:20 +0100 Subject: [PATCH 3/3] ci: allow three minutes per test package --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4eb1f023..5e2f6345 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: run: make build-all - name: Test - run: go test -race -timeout 2m ./... + run: go test -race -timeout 3m ./... # Only a local development build compiles the volumesdevkeys code, so # the release-build test above cannot see it break. Keep in step with