Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions internal/volumes/put/behavior_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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", "")
Expand All @@ -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", "")
Expand Down Expand Up @@ -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", "")
Expand Down Expand Up @@ -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", "")
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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", "")
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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", "")
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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", "")
Expand All @@ -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", "")
Expand All @@ -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", "")
Expand All @@ -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", "")
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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", "")
Expand All @@ -740,6 +760,7 @@ type fatalPartCase struct {
}

func TestAbortsOnFatalPartRefusal(t *testing.T) {
t.Parallel()
cases := []fatalPartCase{
{
name: "volume-part-token-invalid",
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -881,6 +903,7 @@ type abortCase struct {
}

func TestAbortFailureStillRemovesJournal(t *testing.T) {
t.Parallel()
cases := []abortCase{
{
name: "the API is unreachable",
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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{
Expand All @@ -1051,6 +1077,7 @@ func TestDeclareLimitErrorNamesFile(t *testing.T) {
}

func TestKeyPairNotReadyRetries(t *testing.T) {
t.Parallel()
var (
mu sync.Mutex
pauses []time.Duration
Expand Down Expand Up @@ -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)

Expand All @@ -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 {
Expand All @@ -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)
Expand Down Expand Up @@ -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", "")
Expand Down Expand Up @@ -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)
Expand All @@ -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", "")
Expand All @@ -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")
}
Expand Down
3 changes: 3 additions & 0 deletions internal/volumes/put/crc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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} {
Expand All @@ -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} {
Expand Down
8 changes: 8 additions & 0 deletions internal/volumes/put/dedup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
)

func TestPutDeduplicatesAcrossDeclarationBatches(t *testing.T) {
t.Parallel()
e := newTestEnv(t)
vol := e.cloud.newVolume("weights", "")
content := []byte("common")
Expand Down Expand Up @@ -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"))
Expand All @@ -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"))
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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"))
Expand All @@ -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"))
Expand Down Expand Up @@ -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"))
Expand All @@ -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"))
Expand Down
2 changes: 2 additions & 0 deletions internal/volumes/put/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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",
Expand Down
Loading
Loading