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:
Klaus Post
2020-04-15 02:52:38 +02:00
committed by GitHub
parent 78f2183e70
commit f19cbfad5c
15 changed files with 227 additions and 132 deletions

View File

@@ -17,12 +17,15 @@
package cmd
import (
"context"
"reflect"
"testing"
)
// Tests initializing new object layer.
func TestNewObjectLayer(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Tests for FS object layer.
nDisks := 1
disks, err := getRandomDisks(nDisks)
@@ -31,7 +34,7 @@ func TestNewObjectLayer(t *testing.T) {
}
defer removeRoots(disks)
obj, err := newObjectLayer(mustGetZoneEndpoints(disks...))
obj, err := newObjectLayer(ctx, mustGetZoneEndpoints(disks...))
if err != nil {
t.Fatal("Unexpected object layer initialization error", err)
}
@@ -50,7 +53,7 @@ func TestNewObjectLayer(t *testing.T) {
}
defer removeRoots(disks)
obj, err = newObjectLayer(mustGetZoneEndpoints(disks...))
obj, err = newObjectLayer(ctx, mustGetZoneEndpoints(disks...))
if err != nil {
t.Fatal("Unexpected object layer initialization error", err)
}