mirror of
https://github.com/pgsty/minio.git
synced 2026-10-30 20:41:03 +03:00
test: isolate release acceptance fixtures across backends
Signed-off-by: Feng Ruohang <rh@vonng.com>
This commit is contained in:
@@ -511,14 +511,13 @@ func testSiteReplicationStatusDetectsCorsTimestampMismatch(obj ObjectLayer, _ st
|
|||||||
}))
|
}))
|
||||||
defer remote.Close()
|
defer remote.Close()
|
||||||
|
|
||||||
serviceCred, err := auth.CreateCredentials("cors-status-service", "cors-status-service-secret-key")
|
serviceCred, _, err := globalIAMSys.NewServiceAccount(ctx, credentials.AccessKey, nil, newServiceAccountOpts{
|
||||||
|
accessKey: "cors-status-service",
|
||||||
|
secretKey: "cors-status-service-secret-key",
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
serviceCred.ParentUser = credentials.AccessKey
|
|
||||||
if _, err = globalIAMSys.store.AddServiceAccount(ctx, serviceCred); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer globalIAMSys.DeleteServiceAccount(ctx, serviceCred.AccessKey, false)
|
defer globalIAMSys.DeleteServiceAccount(ctx, serviceCred.AccessKey, false)
|
||||||
|
|
||||||
globalSiteReplicationSys.Lock()
|
globalSiteReplicationSys.Lock()
|
||||||
@@ -585,14 +584,13 @@ func testSiteReplicationStatusCountsCorsPerSite(obj ObjectLayer, _ string, bucke
|
|||||||
}))
|
}))
|
||||||
defer remote.Close()
|
defer remote.Close()
|
||||||
|
|
||||||
serviceCred, err := auth.CreateCredentials("cors-count-service", "cors-count-service-secret-key")
|
serviceCred, _, err := globalIAMSys.NewServiceAccount(ctx, credentials.AccessKey, nil, newServiceAccountOpts{
|
||||||
|
accessKey: "cors-count-service",
|
||||||
|
secretKey: "cors-count-service-secret-key",
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
serviceCred.ParentUser = credentials.AccessKey
|
|
||||||
if _, err = globalIAMSys.store.AddServiceAccount(ctx, serviceCred); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer globalIAMSys.DeleteServiceAccount(ctx, serviceCred.AccessKey, false)
|
defer globalIAMSys.DeleteServiceAccount(ctx, serviceCred.AccessKey, false)
|
||||||
|
|
||||||
globalSiteReplicationSys.Lock()
|
globalSiteReplicationSys.Lock()
|
||||||
@@ -1190,14 +1188,13 @@ func testCorsReplicationDispatchStatusHealReload(obj ObjectLayer, _ string, buck
|
|||||||
}))
|
}))
|
||||||
defer remote.Close()
|
defer remote.Close()
|
||||||
|
|
||||||
serviceCred, err := auth.CreateCredentials("cors-integration-svc", "cors-integration-service-secret")
|
serviceCred, _, err := globalIAMSys.NewServiceAccount(ctx, credentials.AccessKey, nil, newServiceAccountOpts{
|
||||||
|
accessKey: "cors-integration-svc",
|
||||||
|
secretKey: "cors-integration-service-secret",
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
serviceCred.ParentUser = credentials.AccessKey
|
|
||||||
if _, err = globalIAMSys.store.AddServiceAccount(ctx, serviceCred); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer globalIAMSys.DeleteServiceAccount(ctx, serviceCred.AccessKey, false)
|
defer globalIAMSys.DeleteServiceAccount(ctx, serviceCred.AccessKey, false)
|
||||||
|
|
||||||
globalSiteReplicationSys.Lock()
|
globalSiteReplicationSys.Lock()
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import (
|
|||||||
|
|
||||||
// Tests create endpoints with ellipses and without.
|
// Tests create endpoints with ellipses and without.
|
||||||
func TestCreateServerEndpoints(t *testing.T) {
|
func TestCreateServerEndpoints(t *testing.T) {
|
||||||
|
useStaticTestEndpoints(t)
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
serverAddr string
|
serverAddr string
|
||||||
args []string
|
args []string
|
||||||
|
|||||||
@@ -27,6 +27,14 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func useStaticTestEndpoints(t *testing.T) {
|
||||||
|
t.Helper()
|
||||||
|
// These fixtures deliberately use localhost, including inside containers.
|
||||||
|
previous := orchestrated
|
||||||
|
orchestrated = false
|
||||||
|
t.Cleanup(func() { orchestrated = previous })
|
||||||
|
}
|
||||||
|
|
||||||
func TestNewEndpoint(t *testing.T) {
|
func TestNewEndpoint(t *testing.T) {
|
||||||
u2, _ := url.Parse("https://example.org/path")
|
u2, _ := url.Parse("https://example.org/path")
|
||||||
u4, _ := url.Parse("http://192.168.253.200/path")
|
u4, _ := url.Parse("http://192.168.253.200/path")
|
||||||
@@ -130,6 +138,7 @@ func TestNewEndpoints(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateEndpoints(t *testing.T) {
|
func TestCreateEndpoints(t *testing.T) {
|
||||||
|
useStaticTestEndpoints(t)
|
||||||
tempGlobalMinioPort := globalMinioPort
|
tempGlobalMinioPort := globalMinioPort
|
||||||
defer func() {
|
defer func() {
|
||||||
globalMinioPort = tempGlobalMinioPort
|
globalMinioPort = tempGlobalMinioPort
|
||||||
@@ -353,6 +362,7 @@ func TestCreateEndpoints(t *testing.T) {
|
|||||||
// So it means that if you have say localhost:9000 and localhost:9001 as endpointArgs then localhost:9001
|
// So it means that if you have say localhost:9000 and localhost:9001 as endpointArgs then localhost:9001
|
||||||
// is considered a remote service from localhost:9000 perspective.
|
// is considered a remote service from localhost:9000 perspective.
|
||||||
func TestGetLocalPeer(t *testing.T) {
|
func TestGetLocalPeer(t *testing.T) {
|
||||||
|
useStaticTestEndpoints(t)
|
||||||
tempGlobalMinioPort := globalMinioPort
|
tempGlobalMinioPort := globalMinioPort
|
||||||
defer func() {
|
defer func() {
|
||||||
globalMinioPort = tempGlobalMinioPort
|
globalMinioPort = tempGlobalMinioPort
|
||||||
@@ -393,6 +403,7 @@ func TestGetLocalPeer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetRemotePeers(t *testing.T) {
|
func TestGetRemotePeers(t *testing.T) {
|
||||||
|
useStaticTestEndpoints(t)
|
||||||
tempGlobalMinioPort := globalMinioPort
|
tempGlobalMinioPort := globalMinioPort
|
||||||
defer func() {
|
defer func() {
|
||||||
globalMinioPort = tempGlobalMinioPort
|
globalMinioPort = tempGlobalMinioPort
|
||||||
|
|||||||
@@ -815,11 +815,22 @@ func scanNullQuorumAbandoned(t *testing.T, z *erasureServerPools, bucket, object
|
|||||||
disks := z.serverPools[0].sets[0].getDisks()
|
disks := z.serverPools[0].sets[0].getDisks()
|
||||||
seq := newBgHealSequence()
|
seq := newBgHealSequence()
|
||||||
defer seq.cancelCtx()
|
defer seq.cancelCtx()
|
||||||
previousState, previousRoutine := globalBackgroundHealState, globalBackgroundHealRoutine
|
// Disk monitors may still read the shared state between object-layer tests.
|
||||||
globalBackgroundHealState = &allHealState{healSeqMap: map[string]*healSequence{"test": seq}}
|
// Install the test sequence under its lock without replacing the state.
|
||||||
|
state := globalBackgroundHealState
|
||||||
|
state.Lock()
|
||||||
|
previousSequences := state.healSeqMap
|
||||||
|
state.healSeqMap = map[string]*healSequence{"test": seq}
|
||||||
|
state.Unlock()
|
||||||
|
previousRoutine := globalBackgroundHealRoutine
|
||||||
routine := &healRoutine{tasks: make(chan healTask)}
|
routine := &healRoutine{tasks: make(chan healTask)}
|
||||||
globalBackgroundHealRoutine = routine
|
globalBackgroundHealRoutine = routine
|
||||||
defer func() { globalBackgroundHealState, globalBackgroundHealRoutine = previousState, previousRoutine }()
|
defer func() {
|
||||||
|
globalBackgroundHealRoutine = previousRoutine
|
||||||
|
state.Lock()
|
||||||
|
state.healSeqMap = previousSequences
|
||||||
|
state.Unlock()
|
||||||
|
}()
|
||||||
workerDone := make(chan struct{})
|
workerDone := make(chan struct{})
|
||||||
var healed []string
|
var healed []string
|
||||||
go func() {
|
go func() {
|
||||||
|
|||||||
@@ -503,6 +503,8 @@ func resetTestGlobals() {
|
|||||||
resetGlobalHealState()
|
resetGlobalHealState()
|
||||||
// Reset globalIAMSys to `nil`
|
// Reset globalIAMSys to `nil`
|
||||||
resetGlobalIAMSys()
|
resetGlobalIAMSys()
|
||||||
|
// Object-layer fixtures must not reuse the preceding IAM suite's etcd store.
|
||||||
|
globalEtcdClient = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure the server for the test run.
|
// Configure the server for the test run.
|
||||||
|
|||||||
Reference in New Issue
Block a user