Skip to content

Commit

Permalink
remove fixed variable from test struct
Browse files Browse the repository at this point in the history
  • Loading branch information
Tulsishah committed Nov 20, 2024
1 parent 7348710 commit 2a86d0f
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions storage/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1515,38 +1515,32 @@ func TestRetryWriteReqStallWithDefaultChunkTransferTimeoutEmulated(t *testing.T)
t.Fatalf("creating bucket: %v", err)
}

chunkSize := 2 * 1024 * 1024 // 2 MiB
fileSize := 5 * 1024 * 1024 // 5 MiB
tests := []struct {
name string
instructions map[string][]string
chunkSize int
fileSize int
wantDuration time.Duration
}{
{
name: "stall-on-first-chunk-with-chunk-transfer-timeout-zero",
instructions: map[string][]string{
"storage.objects.insert": {"stall-for-10s-after-1024K"},
},
chunkSize: 2 * 1024 * 1024,
fileSize: 5 * 1024 * 1024,
wantDuration: 10 * time.Second,
},
{
name: "stall-on-second-chunk-with-chunk-transfer-timeout-zero",
instructions: map[string][]string{
"storage.objects.insert": {"stall-for-10s-after-3072K"},
},
chunkSize: 2 * 1024 * 1024,
fileSize: 5 * 1024 * 1024,
wantDuration: 10 * time.Second,
},
{
name: "stall-on-first-chunk-twice-with-chunk-transfer-timeout-zero",
instructions: map[string][]string{
"storage.objects.insert": {"stall-for-10s-after-1024K", "stall-for-10s-after-1024K"},
},
chunkSize: 2 * 1024 * 1024,
fileSize: 5 * 1024 * 1024,
wantDuration: 10 * time.Second,
},
}
Expand All @@ -1567,7 +1561,7 @@ func TestRetryWriteReqStallWithDefaultChunkTransferTimeoutEmulated(t *testing.T)
params := &openWriterParams{
attrs: want,
bucket: bucket,
chunkSize: tc.chunkSize,
chunkSize: chunkSize,
ctx: ctx,
donec: make(chan struct{}),
setError: func(_ error) {}, // no-op
Expand All @@ -1580,7 +1574,7 @@ func TestRetryWriteReqStallWithDefaultChunkTransferTimeoutEmulated(t *testing.T)
if err != nil {
t.Fatalf("failed to open writer: %v", err)
}
buffer := bytes.Repeat([]byte("A"), tc.fileSize)
buffer := bytes.Repeat([]byte("A"), fileSize)
if _, err := pw.Write(buffer); err != nil {
t.Fatalf("failed to populate test data: %v", err)
}
Expand Down Expand Up @@ -1629,42 +1623,36 @@ func TestRetryWriteReqStallWithNonZeroChunkTransferTimeoutEmulated(t *testing.T)
t.Fatalf("creating bucket: %v", err)
}

chunkSize := 2 * 1024 * 1024 // 2 MiB
fileSize := 5 * 1024 * 1024 // 5 MiB
tests := []struct {
name string
instructions map[string][]string
chunkSize int
chunkTransferTimeout time.Duration
fileSize int
wantDuration time.Duration
}{
{
name: "stall-on-first-chunk-with-chunk-transfer-timeout-nonzero",
instructions: map[string][]string{
"storage.objects.insert": {"stall-for-10s-after-1024K"},
},
chunkSize: 2 * 1024 * 1024,
chunkTransferTimeout: 2 * time.Second,
fileSize: 5 * 1024 * 1024,
wantDuration: 3 * time.Second,
},
{
name: "stall-on-second-chunk-with-chunk-transfer-timeout-nonzero",
instructions: map[string][]string{
"storage.objects.insert": {"stall-for-10s-after-3072K"},
},
chunkSize: 2 * 1024 * 1024,
chunkTransferTimeout: 2 * time.Second,
fileSize: 5 * 1024 * 1024,
wantDuration: 3 * time.Second,
},
{
name: "stall-on-first-chunk-twice-with-chunk-transfer-timeout-nonzero",
instructions: map[string][]string{
"storage.objects.insert": {"stall-for-10s-after-1024K", "stall-for-10s-after-1024K"},
},
chunkSize: 2 * 1024 * 1024,
chunkTransferTimeout: 2 * time.Second,
fileSize: 5 * 1024 * 1024,
wantDuration: 5 * time.Second,
},
}
Expand All @@ -1685,7 +1673,7 @@ func TestRetryWriteReqStallWithNonZeroChunkTransferTimeoutEmulated(t *testing.T)
params := &openWriterParams{
attrs: want,
bucket: bucket,
chunkSize: tc.chunkSize,
chunkSize: chunkSize,
chunkTransferTimeout: tc.chunkTransferTimeout,
ctx: ctx,
donec: make(chan struct{}),
Expand All @@ -1699,7 +1687,7 @@ func TestRetryWriteReqStallWithNonZeroChunkTransferTimeoutEmulated(t *testing.T)
if err != nil {
t.Fatalf("failed to open writer: %v", err)
}
buffer := bytes.Repeat([]byte("A"), tc.fileSize)
buffer := bytes.Repeat([]byte("A"), fileSize)
if _, err := pw.Write(buffer); err != nil {
t.Fatalf("failed to populate test data: %v", err)
}
Expand Down

0 comments on commit 2a86d0f

Please sign in to comment.