mirror of
https://github.com/pgsty/minio.git
synced 2026-08-04 15:12:47 +03:00
fix: use per test context (#9343)
Instead of GlobalContext use a local context for tests. Most notably this allows stuff created to be shut down when tests using it is done. After PR #9345 9331 CI is often running out of memory/time.
This commit is contained in:
+9
-2
@@ -17,6 +17,7 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
@@ -64,6 +65,9 @@ func TestCrcHashMod(t *testing.T) {
|
||||
// TestNewXL - tests initialization of all input disks
|
||||
// and constructs a valid `XL` object
|
||||
func TestNewXLSets(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
var nDisks = 16 // Maximum disks.
|
||||
var erasureDisks []string
|
||||
for i := 0; i < nDisks; i++ {
|
||||
@@ -92,7 +96,7 @@ func TestNewXLSets(t *testing.T) {
|
||||
t.Fatalf("Unable to format disks for erasure, %s", err)
|
||||
}
|
||||
|
||||
if _, err := newXLSets(endpoints, storageDisks, format, 1, 16); err != nil {
|
||||
if _, err := newXLSets(ctx, endpoints, storageDisks, format, 1, 16); err != nil {
|
||||
t.Fatalf("Unable to initialize erasure")
|
||||
}
|
||||
}
|
||||
@@ -100,10 +104,13 @@ func TestNewXLSets(t *testing.T) {
|
||||
// TestHashedLayer - tests the hashed layer which will be returned
|
||||
// consistently for a given object name.
|
||||
func TestHashedLayer(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
var objs []*xlObjects
|
||||
|
||||
for i := 0; i < 16; i++ {
|
||||
obj, fsDirs, err := prepareXL16()
|
||||
obj, fsDirs, err := prepareXL16(ctx)
|
||||
if err != nil {
|
||||
t.Fatal("Unable to initialize 'XL' object layer.", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user