mirror of https://github.com/minio/minio.git
Revert "Revert "tests: Add context cancelation (#15374)""
This reverts commit 564a0afae1
.
This commit is contained in:
parent
59e33b3b21
commit
6cb2f56395
|
@ -73,7 +73,7 @@ func prepareAdminErasureTestBed(ctx context.Context) (*adminErasureTestBed, erro
|
||||||
|
|
||||||
globalEndpoints = mustGetPoolEndpoints(erasureDirs...)
|
globalEndpoints = mustGetPoolEndpoints(erasureDirs...)
|
||||||
|
|
||||||
initAllSubsystems()
|
initAllSubsystems(ctx)
|
||||||
|
|
||||||
initConfigSubsystem(ctx, objLayer)
|
initConfigSubsystem(ctx, objLayer)
|
||||||
|
|
||||||
|
|
|
@ -100,14 +100,14 @@ type allHealState struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// newHealState - initialize global heal state management
|
// newHealState - initialize global heal state management
|
||||||
func newHealState(cleanup bool) *allHealState {
|
func newHealState(ctx context.Context, cleanup bool) *allHealState {
|
||||||
hstate := &allHealState{
|
hstate := &allHealState{
|
||||||
healSeqMap: make(map[string]*healSequence),
|
healSeqMap: make(map[string]*healSequence),
|
||||||
healLocalDisks: make(map[Endpoint]bool),
|
healLocalDisks: make(map[Endpoint]bool),
|
||||||
healStatus: make(map[string]healingTracker),
|
healStatus: make(map[string]healingTracker),
|
||||||
}
|
}
|
||||||
if cleanup {
|
if cleanup {
|
||||||
go hstate.periodicHealSeqsClean(GlobalContext)
|
go hstate.periodicHealSeqsClean(ctx)
|
||||||
}
|
}
|
||||||
return hstate
|
return hstate
|
||||||
}
|
}
|
||||||
|
|
|
@ -359,7 +359,10 @@ func mustNewSignedBadMD5Request(method string, urlStr string, contentLength int6
|
||||||
|
|
||||||
// Tests is requested authenticated function, tests replies for s3 errors.
|
// Tests is requested authenticated function, tests replies for s3 errors.
|
||||||
func TestIsReqAuthenticated(t *testing.T) {
|
func TestIsReqAuthenticated(t *testing.T) {
|
||||||
objLayer, fsDir, err := prepareFS()
|
ctx, cancel := context.WithCancel(GlobalContext)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
objLayer, fsDir, err := prepareFS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -368,10 +371,7 @@ func TestIsReqAuthenticated(t *testing.T) {
|
||||||
t.Fatalf("unable initialize config file, %s", err)
|
t.Fatalf("unable initialize config file, %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
initAllSubsystems()
|
initAllSubsystems(ctx)
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
initConfigSubsystem(ctx, objLayer)
|
initConfigSubsystem(ctx, objLayer)
|
||||||
|
|
||||||
|
@ -413,7 +413,10 @@ func TestIsReqAuthenticated(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCheckAdminRequestAuthType(t *testing.T) {
|
func TestCheckAdminRequestAuthType(t *testing.T) {
|
||||||
objLayer, fsDir, err := prepareFS()
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
objLayer, fsDir, err := prepareFS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -439,7 +442,6 @@ func TestCheckAdminRequestAuthType(t *testing.T) {
|
||||||
{Request: mustNewPresignedV2Request(http.MethodGet, "http://127.0.0.1:9000", 0, nil, t), ErrCode: ErrAccessDenied},
|
{Request: mustNewPresignedV2Request(http.MethodGet, "http://127.0.0.1:9000", 0, nil, t), ErrCode: ErrAccessDenied},
|
||||||
{Request: mustNewPresignedRequest(http.MethodGet, "http://127.0.0.1:9000", 0, nil, t), ErrCode: ErrAccessDenied},
|
{Request: mustNewPresignedRequest(http.MethodGet, "http://127.0.0.1:9000", 0, nil, t), ErrCode: ErrAccessDenied},
|
||||||
}
|
}
|
||||||
ctx := context.Background()
|
|
||||||
for i, testCase := range testCases {
|
for i, testCase := range testCases {
|
||||||
if _, s3Error := checkAdminRequestAuth(ctx, testCase.Request, iampolicy.AllAdminActions, globalSite.Region); s3Error != testCase.ErrCode {
|
if _, s3Error := checkAdminRequestAuth(ctx, testCase.Request, iampolicy.AllAdminActions, globalSite.Region); s3Error != testCase.ErrCode {
|
||||||
t.Errorf("Test %d: Unexpected s3error returned wanted %d, got %d", i, testCase.ErrCode, s3Error)
|
t.Errorf("Test %d: Unexpected s3error returned wanted %d, got %d", i, testCase.ErrCode, s3Error)
|
||||||
|
@ -451,7 +453,7 @@ func TestValidateAdminSignature(t *testing.T) {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
objLayer, fsDir, err := prepareFS()
|
objLayer, fsDir, err := prepareFS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -461,8 +463,7 @@ func TestValidateAdminSignature(t *testing.T) {
|
||||||
t.Fatalf("unable initialize config file, %s", err)
|
t.Fatalf("unable initialize config file, %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
initAllSubsystems()
|
initAllSubsystems(ctx)
|
||||||
|
|
||||||
initConfigSubsystem(ctx, objLayer)
|
initConfigSubsystem(ctx, objLayer)
|
||||||
|
|
||||||
globalIAMSys.Init(ctx, objLayer, globalEtcdClient, 2*time.Second)
|
globalIAMSys.Init(ctx, objLayer, globalEtcdClient, 2*time.Second)
|
||||||
|
|
|
@ -26,7 +26,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestServerConfig(t *testing.T) {
|
func TestServerConfig(t *testing.T) {
|
||||||
objLayer, fsDir, err := prepareFS()
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
objLayer, fsDir, err := prepareFS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -27,7 +28,10 @@ import (
|
||||||
|
|
||||||
// Test if config v1 is purged
|
// Test if config v1 is purged
|
||||||
func TestServerConfigMigrateV1(t *testing.T) {
|
func TestServerConfigMigrateV1(t *testing.T) {
|
||||||
objLayer, fsDir, err := prepareFS()
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
objLayer, fsDir, err := prepareFS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -154,10 +158,12 @@ func TestServerConfigMigrateInexistentConfig(t *testing.T) {
|
||||||
// Test if a config migration from v2 to v33 is successfully done
|
// Test if a config migration from v2 to v33 is successfully done
|
||||||
func TestServerConfigMigrateV2toV33(t *testing.T) {
|
func TestServerConfigMigrateV2toV33(t *testing.T) {
|
||||||
rootPath := t.TempDir()
|
rootPath := t.TempDir()
|
||||||
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
globalConfigDir = &ConfigDir{path: rootPath}
|
globalConfigDir = &ConfigDir{path: rootPath}
|
||||||
|
|
||||||
objLayer, fsDir, err := prepareFS()
|
objLayer, fsDir, err := prepareFS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,6 @@ func TestDynamicTimeoutConcurrent(t *testing.T) {
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
timeout.LogFailure()
|
|
||||||
for j := 0; j < 100; j++ {
|
for j := 0; j < 100; j++ {
|
||||||
timeout.LogSuccess(time.Duration(float64(time.Second) * rng.Float64()))
|
timeout.LogSuccess(time.Duration(float64(time.Second) * rng.Float64()))
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,8 +116,7 @@ func initMetaVolumeFS(fsPath, fsUUID string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFSObjectLayer - initialize new fs object layer.
|
// NewFSObjectLayer - initialize new fs object layer.
|
||||||
func NewFSObjectLayer(fsPath string) (ObjectLayer, error) {
|
func NewFSObjectLayer(ctx context.Context, fsPath string) (ObjectLayer, error) {
|
||||||
ctx := GlobalContext
|
|
||||||
if fsPath == "" {
|
if fsPath == "" {
|
||||||
return nil, errInvalidArgument
|
return nil, errInvalidArgument
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"context"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -29,17 +30,19 @@ import (
|
||||||
// TestNewFS - tests initialization of all input disks
|
// TestNewFS - tests initialization of all input disks
|
||||||
// and constructs a valid `FS` object layer.
|
// and constructs a valid `FS` object layer.
|
||||||
func TestNewFS(t *testing.T) {
|
func TestNewFS(t *testing.T) {
|
||||||
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
// Do not attempt to create this path, the test validates
|
// Do not attempt to create this path, the test validates
|
||||||
// so that NewFSObjectLayer initializes non existing paths
|
// so that NewFSObjectLayer initializes non existing paths
|
||||||
// and successfully returns initialized object layer.
|
// and successfully returns initialized object layer.
|
||||||
disk := filepath.Join(globalTestTmpDir, "minio-"+nextSuffix())
|
disk := filepath.Join(globalTestTmpDir, "minio-"+nextSuffix())
|
||||||
defer os.RemoveAll(disk)
|
defer os.RemoveAll(disk)
|
||||||
|
|
||||||
_, err := NewFSObjectLayer("")
|
_, err := NewFSObjectLayer(ctx, "")
|
||||||
if err != errInvalidArgument {
|
if err != errInvalidArgument {
|
||||||
t.Errorf("Expecting error invalid argument, got %s", err)
|
t.Errorf("Expecting error invalid argument, got %s", err)
|
||||||
}
|
}
|
||||||
_, err = NewFSObjectLayer(disk)
|
_, err = NewFSObjectLayer(ctx, disk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMsg := "Unable to recognize backend format, Drive is not in FS format."
|
errMsg := "Unable to recognize backend format, Drive is not in FS format."
|
||||||
if err.Error() == errMsg {
|
if err.Error() == errMsg {
|
||||||
|
|
|
@ -284,7 +284,7 @@ func StartGateway(ctx *cli.Context, gw Gateway) {
|
||||||
newObject = NewGatewayLayerWithLocker(newObject)
|
newObject = NewGatewayLayerWithLocker(newObject)
|
||||||
|
|
||||||
// Calls all New() for all sub-systems.
|
// Calls all New() for all sub-systems.
|
||||||
initAllSubsystems()
|
initAllSubsystems(GlobalContext)
|
||||||
|
|
||||||
// Once endpoints are finalized, initialize the new object api in safe mode.
|
// Once endpoints are finalized, initialize the new object api in safe mode.
|
||||||
globalObjLayerMutex.Lock()
|
globalObjLayerMutex.Lock()
|
||||||
|
|
|
@ -18,13 +18,17 @@
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Test printing Gateway common message.
|
// Test printing Gateway common message.
|
||||||
func TestPrintGatewayCommonMessage(t *testing.T) {
|
func TestPrintGatewayCommonMessage(t *testing.T) {
|
||||||
obj, fsDir, err := prepareFS()
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
obj, fsDir, err := prepareFS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -39,7 +43,10 @@ func TestPrintGatewayCommonMessage(t *testing.T) {
|
||||||
|
|
||||||
// Test print gateway startup message.
|
// Test print gateway startup message.
|
||||||
func TestPrintGatewayStartupMessage(t *testing.T) {
|
func TestPrintGatewayStartupMessage(t *testing.T) {
|
||||||
obj, fsDir, err := prepareFS()
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
obj, fsDir, err := prepareFS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ func (g *NAS) Name() string {
|
||||||
// NewGatewayLayer returns nas gatewaylayer.
|
// NewGatewayLayer returns nas gatewaylayer.
|
||||||
func (g *NAS) NewGatewayLayer(creds madmin.Credentials) (minio.ObjectLayer, error) {
|
func (g *NAS) NewGatewayLayer(creds madmin.Credentials) (minio.ObjectLayer, error) {
|
||||||
var err error
|
var err error
|
||||||
newObject, err := minio.NewFSObjectLayer(g.path)
|
newObject, err := minio.NewFSObjectLayer(minio.GlobalContext, g.path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,10 @@ import (
|
||||||
|
|
||||||
// Tests validate bucket LocationConstraint.
|
// Tests validate bucket LocationConstraint.
|
||||||
func TestIsValidLocationContraint(t *testing.T) {
|
func TestIsValidLocationContraint(t *testing.T) {
|
||||||
obj, fsDir, err := prepareFS()
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
obj, fsDir, err := prepareFS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -29,7 +30,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func testAuthenticate(authType string, t *testing.T) {
|
func testAuthenticate(authType string, t *testing.T) {
|
||||||
obj, fsDir, err := prepareFS()
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
obj, fsDir, err := prepareFS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -103,7 +107,10 @@ func getTokenString(accessKey, secretKey string) (string, error) {
|
||||||
|
|
||||||
// Tests web request authenticator.
|
// Tests web request authenticator.
|
||||||
func TestWebRequestAuthenticate(t *testing.T) {
|
func TestWebRequestAuthenticate(t *testing.T) {
|
||||||
obj, fsDir, err := prepareFS()
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
obj, fsDir, err := prepareFS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -157,7 +164,10 @@ func TestWebRequestAuthenticate(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkParseJWTStandardClaims(b *testing.B) {
|
func BenchmarkParseJWTStandardClaims(b *testing.B) {
|
||||||
obj, fsDir, err := prepareFS()
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
obj, fsDir, err := prepareFS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatal(err)
|
b.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -185,7 +195,10 @@ func BenchmarkParseJWTStandardClaims(b *testing.B) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkParseJWTMapClaims(b *testing.B) {
|
func BenchmarkParseJWTMapClaims(b *testing.B) {
|
||||||
obj, fsDir, err := prepareFS()
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
obj, fsDir, err := prepareFS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatal(err)
|
b.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -215,7 +228,10 @@ func BenchmarkParseJWTMapClaims(b *testing.B) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkAuthenticateNode(b *testing.B) {
|
func BenchmarkAuthenticateNode(b *testing.B) {
|
||||||
obj, fsDir, err := prepareFS()
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
obj, fsDir, err := prepareFS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatal(err)
|
b.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -244,7 +260,10 @@ func BenchmarkAuthenticateNode(b *testing.B) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkAuthenticateWeb(b *testing.B) {
|
func BenchmarkAuthenticateWeb(b *testing.B) {
|
||||||
obj, fsDir, err := prepareFS()
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
obj, fsDir, err := prepareFS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatal(err)
|
b.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -27,8 +28,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Helper function to create a lock server for testing
|
// Helper function to create a lock server for testing
|
||||||
func createLockTestServer(t *testing.T) (string, *lockRESTServer, string) {
|
func createLockTestServer(ctx context.Context, t *testing.T) (string, *lockRESTServer, string) {
|
||||||
obj, fsDir, err := prepareFS()
|
obj, fsDir, err := prepareFS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -52,7 +53,10 @@ func createLockTestServer(t *testing.T) (string, *lockRESTServer, string) {
|
||||||
|
|
||||||
// Test function to remove lock entries from map based on name & uid combination
|
// Test function to remove lock entries from map based on name & uid combination
|
||||||
func TestLockRpcServerRemoveEntry(t *testing.T) {
|
func TestLockRpcServerRemoveEntry(t *testing.T) {
|
||||||
testPath, locker, _ := createLockTestServer(t)
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
testPath, locker, _ := createLockTestServer(ctx, t)
|
||||||
defer os.RemoveAll(testPath)
|
defer os.RemoveAll(testPath)
|
||||||
|
|
||||||
lockRequesterInfo1 := lockRequesterInfo{
|
lockRequesterInfo1 := lockRequesterInfo{
|
||||||
|
|
|
@ -1877,7 +1877,7 @@ func initFSObjectsB(disk string, t *testing.B) (obj ObjectLayer) {
|
||||||
|
|
||||||
newTestConfig(globalMinioDefaultRegion, obj)
|
newTestConfig(globalMinioDefaultRegion, obj)
|
||||||
|
|
||||||
initAllSubsystems()
|
initAllSubsystems(GlobalContext)
|
||||||
return obj
|
return obj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -241,11 +241,11 @@ func serverHandleEnvVars() {
|
||||||
|
|
||||||
var globalHealStateLK sync.RWMutex
|
var globalHealStateLK sync.RWMutex
|
||||||
|
|
||||||
func initAllSubsystems() {
|
func initAllSubsystems(ctx context.Context) {
|
||||||
globalHealStateLK.Lock()
|
globalHealStateLK.Lock()
|
||||||
// New global heal state
|
// New global heal state
|
||||||
globalAllHealState = newHealState(true)
|
globalAllHealState = newHealState(ctx, true)
|
||||||
globalBackgroundHealState = newHealState(false)
|
globalBackgroundHealState = newHealState(ctx, false)
|
||||||
globalHealStateLK.Unlock()
|
globalHealStateLK.Unlock()
|
||||||
|
|
||||||
// Initialize notification peer targets
|
// Initialize notification peer targets
|
||||||
|
@ -263,7 +263,7 @@ func initAllSubsystems() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the bucket bandwidth monitor
|
// Create the bucket bandwidth monitor
|
||||||
globalBucketMonitor = bandwidth.NewMonitor(GlobalContext, totalNodeCount())
|
globalBucketMonitor = bandwidth.NewMonitor(ctx, totalNodeCount())
|
||||||
|
|
||||||
// Create a new config system.
|
// Create a new config system.
|
||||||
globalConfigSys = NewConfigSys()
|
globalConfigSys = NewConfigSys()
|
||||||
|
@ -450,7 +450,7 @@ func serverMain(ctx *cli.Context) {
|
||||||
initHelp()
|
initHelp()
|
||||||
|
|
||||||
// Initialize all sub-systems
|
// Initialize all sub-systems
|
||||||
initAllSubsystems()
|
initAllSubsystems(GlobalContext)
|
||||||
|
|
||||||
// Is distributed setup, error out if no certificates are found for HTTPS endpoints.
|
// Is distributed setup, error out if no certificates are found for HTTPS endpoints.
|
||||||
if globalIsDistErasure {
|
if globalIsDistErasure {
|
||||||
|
@ -696,7 +696,7 @@ func newObjectLayer(ctx context.Context, endpointServerPools EndpointServerPools
|
||||||
// For FS only, directly use the disk.
|
// For FS only, directly use the disk.
|
||||||
if endpointServerPools.NEndpoints() == 1 {
|
if endpointServerPools.NEndpoints() == 1 {
|
||||||
// Initialize new FS object layer.
|
// Initialize new FS object layer.
|
||||||
newObject, err = NewFSObjectLayer(endpointServerPools[0].Endpoints[0].Path)
|
newObject, err = NewFSObjectLayer(ctx, endpointServerPools[0].Endpoints[0].Path)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return newObject, nil
|
return newObject, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -71,7 +72,10 @@ func TestStripStandardPorts(t *testing.T) {
|
||||||
|
|
||||||
// Test printing server common message.
|
// Test printing server common message.
|
||||||
func TestPrintServerCommonMessage(t *testing.T) {
|
func TestPrintServerCommonMessage(t *testing.T) {
|
||||||
obj, fsDir, err := prepareFS()
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
obj, fsDir, err := prepareFS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -86,7 +90,10 @@ func TestPrintServerCommonMessage(t *testing.T) {
|
||||||
|
|
||||||
// Tests print cli access message.
|
// Tests print cli access message.
|
||||||
func TestPrintCLIAccessMsg(t *testing.T) {
|
func TestPrintCLIAccessMsg(t *testing.T) {
|
||||||
obj, fsDir, err := prepareFS()
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
obj, fsDir, err := prepareFS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -101,7 +108,10 @@ func TestPrintCLIAccessMsg(t *testing.T) {
|
||||||
|
|
||||||
// Test print startup message.
|
// Test print startup message.
|
||||||
func TestPrintStartupMessage(t *testing.T) {
|
func TestPrintStartupMessage(t *testing.T) {
|
||||||
obj, fsDir, err := prepareFS()
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
obj, fsDir, err := prepareFS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -41,7 +42,10 @@ func TestResourceListSorting(t *testing.T) {
|
||||||
|
|
||||||
// Tests presigned v2 signature.
|
// Tests presigned v2 signature.
|
||||||
func TestDoesPresignedV2SignatureMatch(t *testing.T) {
|
func TestDoesPresignedV2SignatureMatch(t *testing.T) {
|
||||||
obj, fsDir, err := prepareFS()
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
obj, fsDir, err := prepareFS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -161,7 +165,10 @@ func TestDoesPresignedV2SignatureMatch(t *testing.T) {
|
||||||
|
|
||||||
// TestValidateV2AuthHeader - Tests validate the logic of V2 Authorization header validator.
|
// TestValidateV2AuthHeader - Tests validate the logic of V2 Authorization header validator.
|
||||||
func TestValidateV2AuthHeader(t *testing.T) {
|
func TestValidateV2AuthHeader(t *testing.T) {
|
||||||
obj, fsDir, err := prepareFS()
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
obj, fsDir, err := prepareFS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -232,7 +239,10 @@ func TestValidateV2AuthHeader(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDoesPolicySignatureV2Match(t *testing.T) {
|
func TestDoesPolicySignatureV2Match(t *testing.T) {
|
||||||
obj, fsDir, err := prepareFS()
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
obj, fsDir, err := prepareFS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ func TestCheckValid(t *testing.T) {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
objLayer, fsDir, err := prepareFS()
|
objLayer, fsDir, err := prepareFS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,7 @@ func TestCheckValid(t *testing.T) {
|
||||||
t.Fatalf("unable initialize config file, %s", err)
|
t.Fatalf("unable initialize config file, %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
initAllSubsystems()
|
initAllSubsystems(ctx)
|
||||||
|
|
||||||
initConfigSubsystem(ctx, objLayer)
|
initConfigSubsystem(ctx, objLayer)
|
||||||
|
|
||||||
globalIAMSys.Init(ctx, objLayer, globalEtcdClient, 2*time.Second)
|
globalIAMSys.Init(ctx, objLayer, globalEtcdClient, 2*time.Second)
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -93,7 +94,10 @@ func TestDoesPolicySignatureMatch(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDoesPresignedSignatureMatch(t *testing.T) {
|
func TestDoesPresignedSignatureMatch(t *testing.T) {
|
||||||
obj, fsDir, err := prepareFS()
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
obj, fsDir, err := prepareFS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,7 +184,7 @@ func calculateStreamContentLength(dataLen, chunkSize int64) int64 {
|
||||||
return streamLen
|
return streamLen
|
||||||
}
|
}
|
||||||
|
|
||||||
func prepareFS() (ObjectLayer, string, error) {
|
func prepareFS(ctx context.Context) (ObjectLayer, string, error) {
|
||||||
nDisks := 1
|
nDisks := 1
|
||||||
fsDirs, err := getRandomDisks(nDisks)
|
fsDirs, err := getRandomDisks(nDisks)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -195,9 +195,9 @@ func prepareFS() (ObjectLayer, string, error) {
|
||||||
return nil, "", err
|
return nil, "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
initAllSubsystems()
|
initAllSubsystems(ctx)
|
||||||
|
|
||||||
globalIAMSys.Init(context.Background(), obj, globalEtcdClient, 2*time.Second)
|
globalIAMSys.Init(ctx, obj, globalEtcdClient, 2*time.Second)
|
||||||
return obj, fsDirs[0], nil
|
return obj, fsDirs[0], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ func initFSObjects(disk string, t *testing.T) (obj ObjectLayer) {
|
||||||
|
|
||||||
newTestConfig(globalMinioDefaultRegion, obj)
|
newTestConfig(globalMinioDefaultRegion, obj)
|
||||||
|
|
||||||
initAllSubsystems()
|
initAllSubsystems(GlobalContext)
|
||||||
return obj
|
return obj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,7 +365,7 @@ func initTestServerWithBackend(ctx context.Context, t TestErrHandler, testServer
|
||||||
globalMinioPort = port
|
globalMinioPort = port
|
||||||
globalMinioAddr = getEndpointsLocalAddr(testServer.Disks)
|
globalMinioAddr = getEndpointsLocalAddr(testServer.Disks)
|
||||||
|
|
||||||
initAllSubsystems()
|
initAllSubsystems(ctx)
|
||||||
|
|
||||||
globalEtcdClient = nil
|
globalEtcdClient = nil
|
||||||
|
|
||||||
|
@ -446,7 +446,7 @@ func resetGlobalIsErasure() {
|
||||||
func resetGlobalHealState() {
|
func resetGlobalHealState() {
|
||||||
// Init global heal state
|
// Init global heal state
|
||||||
if globalAllHealState == nil {
|
if globalAllHealState == nil {
|
||||||
globalAllHealState = newHealState(false)
|
globalAllHealState = newHealState(GlobalContext, false)
|
||||||
} else {
|
} else {
|
||||||
globalAllHealState.Lock()
|
globalAllHealState.Lock()
|
||||||
for _, v := range globalAllHealState.healSeqMap {
|
for _, v := range globalAllHealState.healSeqMap {
|
||||||
|
@ -459,7 +459,7 @@ func resetGlobalHealState() {
|
||||||
|
|
||||||
// Init background heal state
|
// Init background heal state
|
||||||
if globalBackgroundHealState == nil {
|
if globalBackgroundHealState == nil {
|
||||||
globalBackgroundHealState = newHealState(false)
|
globalBackgroundHealState = newHealState(GlobalContext, false)
|
||||||
} else {
|
} else {
|
||||||
globalBackgroundHealState.Lock()
|
globalBackgroundHealState.Lock()
|
||||||
for _, v := range globalBackgroundHealState.healSeqMap {
|
for _, v := range globalBackgroundHealState.healSeqMap {
|
||||||
|
@ -1492,7 +1492,7 @@ func getRandomDisks(N int) ([]string, error) {
|
||||||
|
|
||||||
// Initialize object layer with the supplied disks, objectLayer is nil upon any error.
|
// Initialize object layer with the supplied disks, objectLayer is nil upon any error.
|
||||||
func newTestObjectLayer(ctx context.Context, endpointServerPools EndpointServerPools) (newObject ObjectLayer, err error) {
|
func newTestObjectLayer(ctx context.Context, endpointServerPools EndpointServerPools) (newObject ObjectLayer, err error) {
|
||||||
initAllSubsystems()
|
initAllSubsystems(ctx)
|
||||||
|
|
||||||
return newErasureServerPools(ctx, endpointServerPools)
|
return newErasureServerPools(ctx, endpointServerPools)
|
||||||
}
|
}
|
||||||
|
@ -1536,7 +1536,7 @@ func removeDiskN(disks []string, n int) {
|
||||||
// initialies the root and returns its path.
|
// initialies the root and returns its path.
|
||||||
// return credentials.
|
// return credentials.
|
||||||
func initAPIHandlerTest(ctx context.Context, obj ObjectLayer, endpoints []string) (string, http.Handler, error) {
|
func initAPIHandlerTest(ctx context.Context, obj ObjectLayer, endpoints []string) (string, http.Handler, error) {
|
||||||
initAllSubsystems()
|
initAllSubsystems(ctx)
|
||||||
|
|
||||||
initConfigSubsystem(ctx, obj)
|
initConfigSubsystem(ctx, obj)
|
||||||
|
|
||||||
|
@ -1574,7 +1574,7 @@ func prepareTestBackend(ctx context.Context, instanceType string) (ObjectLayer,
|
||||||
return prepareErasure16(ctx)
|
return prepareErasure16(ctx)
|
||||||
default:
|
default:
|
||||||
// return FS backend by default.
|
// return FS backend by default.
|
||||||
obj, disk, err := prepareFS()
|
obj, disk, err := prepareFS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
@ -1746,7 +1746,7 @@ func ExecObjectLayerAPITest(t *testing.T, objAPITest objAPITestType, endpoints [
|
||||||
// this is to make sure that the tests are not affected by modified value.
|
// this is to make sure that the tests are not affected by modified value.
|
||||||
resetTestGlobals()
|
resetTestGlobals()
|
||||||
|
|
||||||
objLayer, fsDir, err := prepareFS()
|
objLayer, fsDir, err := prepareFS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Initialization of object layer failed for single node setup: %s", err)
|
t.Fatalf("Initialization of object layer failed for single node setup: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -1825,13 +1825,12 @@ func ExecObjectLayerTest(t TestErrHandler, objTest objTestType) {
|
||||||
localMetacacheMgr.deleteAll()
|
localMetacacheMgr.deleteAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
objLayer, fsDir, err := prepareFS()
|
objLayer, fsDir, err := prepareFS(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Initialization of object layer failed for single node setup: %s", err)
|
t.Fatalf("Initialization of object layer failed for single node setup: %s", err)
|
||||||
}
|
}
|
||||||
setObjectLayer(objLayer)
|
setObjectLayer(objLayer)
|
||||||
|
initAllSubsystems(ctx)
|
||||||
initAllSubsystems()
|
|
||||||
|
|
||||||
// initialize the server and obtain the credentials and root.
|
// initialize the server and obtain the credentials and root.
|
||||||
// credentials are necessary to sign the HTTP request.
|
// credentials are necessary to sign the HTTP request.
|
||||||
|
@ -1857,7 +1856,7 @@ func ExecObjectLayerTest(t TestErrHandler, objTest objTestType) {
|
||||||
localMetacacheMgr.deleteAll()
|
localMetacacheMgr.deleteAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
initAllSubsystems()
|
initAllSubsystems(ctx)
|
||||||
objLayer, fsDirs, err := prepareErasureSets32(ctx)
|
objLayer, fsDirs, err := prepareErasureSets32(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Initialization of object layer failed for Erasure setup: %s", err)
|
t.Fatalf("Initialization of object layer failed for Erasure setup: %s", err)
|
||||||
|
|
Loading…
Reference in New Issue