Skip to content

Commit

Permalink
fix: modify sp tag
Browse files Browse the repository at this point in the history
  • Loading branch information
jingjunLi committed Oct 8, 2023
1 parent 2394dd9 commit 30b8273
Showing 1 changed file with 7 additions and 57 deletions.
64 changes: 7 additions & 57 deletions e2e/e2e_migrate_bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (s *BucketMigrateTestSuite) Test_Bucket_Migrate_Simple_Case() {
// selete a storage provider to miragte
destSP := s.SelectDestSP(objectDetail)

s.T().Logf(":Migrate Bucket DstPrimarySPID %d", destSP.GetId())
s.T().Logf("Migrate Bucket DstPrimarySPID %d", destSP.GetId())

// normal no conflict send migrate bucket transaction
txhash, err := s.Client.MigrateBucket(s.ClientContext, bucketName, destSP.GetId(), types.MigrateBucketOptions{TxOpts: nil, IsAsyncMode: false})
Expand All @@ -209,7 +209,7 @@ func (s *BucketMigrateTestSuite) Test_Bucket_Migrate_Simple_Case() {
s.CheckChallenge(uint32(objectDetail.ObjectInfo.Id.Uint64()))
}

// test only conflict sp's case
// test conflict sp's case & quota consumed
func (s *BucketMigrateTestSuite) Test_Bucket_Migrate_Simple_Conflict_Case() {
// 1) create bucket and object in srcSP
bucketName, _ := s.MustCreateBucket(storageTypes.VISIBILITY_TYPE_PUBLIC_READ)
Expand Down Expand Up @@ -288,13 +288,6 @@ func (s *BucketMigrateTestSuite) Test_Bucket_Migrate_Simple_Conflict_Case() {
s.CheckChallenge(uint32(objectDetail.ObjectInfo.Id.Uint64()))
}

func (s *BucketMigrateTestSuite) Test_Empty_Quota_Simple_Case() {
bucketName := "hks1vldl"
quotaAfter, err := s.Client.GetBucketReadQuota(s.ClientContext, bucketName)
s.Require().NoError(err)
s.T().Logf("succeed to migrate Bucket, current quota:%v", quotaAfter)
}

// test empty bucket case
func (s *BucketMigrateTestSuite) Test_Empty_Bucket_Migrate_Simple_Case() {
// 1) create bucket and object in srcSP
Expand Down Expand Up @@ -323,7 +316,7 @@ func (s *BucketMigrateTestSuite) Test_Empty_Bucket_Migrate_Simple_Case() {
}
s.Require().NotNil(destSP)

s.T().Logf(":Migrate Bucket DstPrimarySPID %s", destSP.String())
s.T().Logf("Migrate Bucket DstPrimarySPID %s", destSP.String())

// normal no conflict send migrate bucket transaction
txhash, err := s.Client.MigrateBucket(s.ClientContext, bucketName, destSP.GetId(), types.MigrateBucketOptions{TxOpts: nil, IsAsyncMode: false})
Expand Down Expand Up @@ -384,7 +377,10 @@ func (s *BucketMigrateTestSuite) Test_Bucket_Migrate_Cancel_Case() {
// selete a storage provider to miragte
destSP := s.SelectDestSP(objectDetail)

s.T().Logf(":Migrate Bucket DstPrimarySPID %d", destSP.GetId())
s.T().Logf("Migrate Bucket DstPrimarySPID %d", destSP.GetId())
quotaBefore, err := s.Client.GetBucketReadQuota(s.ClientContext, bucketName)
s.Require().NoError(err)
s.T().Logf("Migrate bucket %s from %d to DstPrimarySPID %d, current quota:%v", bucketName, objectDetail.GlobalVirtualGroup.PrimarySpId, destSP.GetId(), quotaBefore)

// normal no conflict send migrate bucket transaction
txhash, err := s.Client.MigrateBucket(s.ClientContext, bucketName, destSP.GetId(), types.MigrateBucketOptions{TxOpts: nil, IsAsyncMode: false})
Expand All @@ -402,8 +398,6 @@ func (s *BucketMigrateTestSuite) Test_Bucket_Migrate_Cancel_Case() {
s.Require().NoError(err)
s.T().Log(createTx.TxResult.String())

time.Sleep(10 * time.Second)

txhash, err = s.Client.MigrateBucket(s.ClientContext, bucketName, destSP.GetId(), types.MigrateBucketOptions{TxOpts: nil, IsAsyncMode: false})
s.Require().NoError(err)
s.T().Logf("MigrateBucket txhash : %s", txhash)
Expand All @@ -413,47 +407,3 @@ func (s *BucketMigrateTestSuite) Test_Bucket_Migrate_Cancel_Case() {

s.waitUntilBucketMigrateFinish(bucketName, destSP)
}

// test cancel migrate bucket
func (s *BucketMigrateTestSuite) Test_Bucket_Migrate_Cancel_Quota_Case() {
// 1) create bucket and object in srcSP
bucketName, _ := s.MustCreateBucket(storageTypes.VISIBILITY_TYPE_PUBLIC_READ)

// test only one object's case
objectDetails, _, err := s.CreateObjects(bucketName, 1)
s.Require().NoError(err)

objectDetail := objectDetails[0]

// selete a storage provider to miragte
destSP := s.SelectDestSP(objectDetail)

s.T().Logf(":Migrate Bucket DstPrimarySPID %d", destSP.GetId())

quotaBefore, err := s.Client.GetBucketReadQuota(s.ClientContext, bucketName)
s.Require().NoError(err)
s.T().Logf("Migrate bucket %s from %d to DstPrimarySPID %d, current quota:%v", bucketName, objectDetail.GlobalVirtualGroup.PrimarySpId, destSP.GetId(), quotaBefore)

// normal no conflict send migrate bucket transaction
txhash, err := s.Client.MigrateBucket(s.ClientContext, bucketName, destSP.GetId(), types.MigrateBucketOptions{TxOpts: nil, IsAsyncMode: false})
s.Require().NoError(err)
s.T().Logf("MigrateBucket txhash : %s", txhash)
createTx, err := s.Client.WaitForTx(s.ClientContext, txhash)
s.Require().NoError(err)
s.T().Log(createTx.TxResult.String())

time.Sleep(5 * time.Second)

txhash, err = s.Client.CancelMigrateBucket(s.ClientContext, bucketName, types.CancelMigrateBucketOptions{})
s.Require().NoError(err)
s.T().Logf("CancelMigrateBucket txhash : %s", txhash)

createTx, err = s.Client.WaitForTx(s.ClientContext, txhash)
s.Require().NoError(err)
s.T().Log(createTx.TxResult.String())

time.Sleep(10 * time.Second)
quotaAfter, err := s.Client.GetBucketReadQuota(s.ClientContext, bucketName)
s.Require().NoError(err)
s.T().Logf("succeed to cancel migrate bucket, current quota:%v", quotaAfter)
}

0 comments on commit 30b8273

Please sign in to comment.