Skip to content

Commit

Permalink
update testcase.
Browse files Browse the repository at this point in the history
  • Loading branch information
huiguangjun committed Nov 16, 2022
1 parent 97c9cb1 commit 37772f2
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 21 deletions.
7 changes: 6 additions & 1 deletion oss/bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var (

// SetUpSuite runs once when the suite starts running.
func (s *OssBucketSuite) SetUpSuite(c *C) {
time.Sleep(timeoutInOperation)
if cloudboxControlEndpoint == "" {
client, err := New(endpoint, accessID, accessKey)
c.Assert(err, IsNil)
Expand Down Expand Up @@ -81,10 +82,12 @@ func (s *OssBucketSuite) SetUpSuite(c *C) {

testLogger.Println("test bucket started")
}
time.Sleep(timeoutInOperation)
}

// TearDownSuite runs before each test or benchmark starts running.
func (s *OssBucketSuite) TearDownSuite(c *C) {
time.Sleep(timeoutInOperation)
for _, bucket := range []*Bucket{s.bucket, s.archiveBucket} {
// Delete multipart
keyMarker := KeyMarker("")
Expand Down Expand Up @@ -128,7 +131,7 @@ func (s *OssBucketSuite) TearDownSuite(c *C) {
c.Assert(err, IsNil)
}
}

time.Sleep(timeoutInOperation)
testLogger.Println("test bucket completed")
}

Expand Down Expand Up @@ -3809,6 +3812,7 @@ func (s *OssBucketSuite) TestVersioningDeleteOldVersionObject(c *C) {
err = client.SetBucketVersioning(bucketName, versioningConfig)
c.Assert(err, IsNil)
time.Sleep(timeoutInOperation)
time.Sleep(timeoutInOperation)

bucketResult, err := client.GetBucketInfo(bucketName)
c.Assert(err, IsNil)
Expand Down Expand Up @@ -4082,6 +4086,7 @@ func (s *OssBucketSuite) TestVersioningBatchDeleteVersionObjects(c *C) {
err = client.SetBucketVersioning(bucketName, versioningConfig)
c.Assert(err, IsNil)
time.Sleep(timeoutInOperation)
time.Sleep(timeoutInOperation)

bucketResult, err := client.GetBucketInfo(bucketName)
c.Assert(err, IsNil)
Expand Down
25 changes: 19 additions & 6 deletions oss/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func (s *OssClientSuite) SetUpSuite(c *C) {
for _, bucket := range lbr.Buckets {
ForceDeleteBucket(client, bucket.Name, c)
}

time.Sleep(timeoutInOperation)
testLogger.Println("test client started")
}

Expand All @@ -245,7 +245,7 @@ func (s *OssClientSuite) TearDownSuite(c *C) {
for _, bucket := range lbr.Buckets {
s.deleteBucket(client, bucket.Name, c)
}

time.Sleep(timeoutInOperation)
testLogger.Println("test client completed")
}

Expand Down Expand Up @@ -640,6 +640,7 @@ func (s *OssClientSuite) TestSetBucketAcl(c *C) {
err = client.SetBucketACL(bucketNameTest, ACLPrivate)
c.Assert(err, IsNil)
time.Sleep(timeoutInOperation)
time.Sleep(timeoutInOperation)

res, err = client.GetBucketACL(bucketNameTest)
c.Assert(err, IsNil)
Expand Down Expand Up @@ -887,6 +888,7 @@ func (s *OssClientSuite) TestSetBucketLifecycleNew(c *C) {
rules = []LifecycleRule{rule1}
err = client.SetBucketLifecycle(bucketNameTest, rules)
c.Assert(err, IsNil)
time.Sleep(timeoutInOperation)

res, err := client.GetBucketLifecycle(bucketNameTest)
c.Assert(err, IsNil)
Expand All @@ -902,6 +904,7 @@ func (s *OssClientSuite) TestSetBucketLifecycleNew(c *C) {
rules = []LifecycleRule{rule1, rule2}
err = client.SetBucketLifecycle(bucketNameTest, rules)
c.Assert(err, IsNil)
time.Sleep(timeoutInOperation)

res, err = client.GetBucketLifecycle(bucketNameTest)
c.Assert(err, IsNil)
Expand All @@ -922,6 +925,7 @@ func (s *OssClientSuite) TestSetBucketLifecycleNew(c *C) {
rules = []LifecycleRule{rule2, rule3}
err = client.SetBucketLifecycle(bucketNameTest, rules)
c.Assert(err, IsNil)
time.Sleep(timeoutInOperation)

res, err = client.GetBucketLifecycle(bucketNameTest)
c.Assert(err, IsNil)
Expand All @@ -947,6 +951,7 @@ func (s *OssClientSuite) TestSetBucketLifecycleNew(c *C) {
rules = []LifecycleRule{rule1, rule3}
err = client.SetBucketLifecycle(bucketNameTest, rules)
c.Assert(err, IsNil)
time.Sleep(timeoutInOperation)

res, err = client.GetBucketLifecycle(bucketNameTest)
c.Assert(err, IsNil)
Expand All @@ -970,6 +975,7 @@ func (s *OssClientSuite) TestSetBucketLifecycleNew(c *C) {
rules = []LifecycleRule{rule1, rule2, rule3}
err = client.SetBucketLifecycle(bucketNameTest, rules)
c.Assert(err, IsNil)
time.Sleep(timeoutInOperation)

res, err = client.GetBucketLifecycle(bucketNameTest)
c.Assert(err, IsNil)
Expand Down Expand Up @@ -1080,7 +1086,7 @@ func (s *OssClientSuite) TestSetBucketLifecycleOverLap(c *C) {
//enable overlap,error
options := []Option{AllowSameActionOverLap(true)}
err = client.SetBucketLifecycle(bucketNameTest, rules, options...)
c.Assert(err, NotNil)
c.Assert(err, IsNil)
err = client.DeleteBucket(bucketNameTest)

}
Expand Down Expand Up @@ -2052,6 +2058,7 @@ func (s *OssClientSuite) TestSetBucketCORS(c *C) {
// Set
err = client.SetBucketCORS(bucketNameTest, []CORSRule{rule1})
c.Assert(err, IsNil)
time.Sleep(timeoutInOperation)

gbcr, err := client.GetBucketCORS(bucketNameTest)
c.Assert(err, IsNil)
Expand All @@ -2065,6 +2072,7 @@ func (s *OssClientSuite) TestSetBucketCORS(c *C) {
// Double set
err = client.SetBucketCORS(bucketNameTest, []CORSRule{rule1})
c.Assert(err, IsNil)
time.Sleep(timeoutInOperation)

gbcr, err = client.GetBucketCORS(bucketNameTest)
c.Assert(err, IsNil)
Expand Down Expand Up @@ -3325,7 +3333,7 @@ func (s *OssClientSuite) TestBucketQos(c *C) {
c.Assert(len(requestId) > 0, Equals, true)

// wait a moment for configuration effect
time.Sleep(time.Second)
time.Sleep(timeoutInOperation)

retQos, err := client.GetBucketQosInfo(bucketName)
c.Assert(err, IsNil)
Expand All @@ -3348,7 +3356,7 @@ func (s *OssClientSuite) TestBucketQos(c *C) {
c.Assert(err, IsNil)

// wait a moment for configuration effect
time.Sleep(time.Second)
time.Sleep(timeoutInOperation)

retQos, err = client.GetBucketQosInfo(bucketName)
c.Assert(err, IsNil)
Expand All @@ -3364,7 +3372,7 @@ func (s *OssClientSuite) TestBucketQos(c *C) {
c.Assert(err, IsNil)

// wait a moment for configuration effect
time.Sleep(time.Second)
time.Sleep(timeoutInOperation)

_, err = client.GetBucketQosInfo(bucketName)
c.Assert(err, NotNil)
Expand Down Expand Up @@ -5038,6 +5046,7 @@ func (s *OssClientSuite) TestBucketAccessMonitor(c *C) {

err = client.CreateBucket(bucketNameTest)
c.Assert(err, IsNil)
time.Sleep(3 * time.Second)

res, err := client.GetBucketInfo(bucketNameTest)
c.Assert(err, IsNil)
Expand All @@ -5049,13 +5058,15 @@ func (s *OssClientSuite) TestBucketAccessMonitor(c *C) {
}
err = client.PutBucketAccessMonitor(bucketNameTest, access)
c.Assert(err, IsNil)
time.Sleep(3 * time.Second)

// Put Bucket Access Monitor twice
access = PutBucketAccessMonitor{
Status: "Enabled",
}
err = client.PutBucketAccessMonitor(bucketNameTest, access)
c.Assert(err, IsNil)
time.Sleep(3 * time.Second)

// get bucket info
res, err = client.GetBucketInfo(bucketNameTest)
Expand Down Expand Up @@ -5137,6 +5148,7 @@ func (s *OssClientSuite) TestBucketAccessMonitor(c *C) {
var rules = []LifecycleRule{rule1, rule2, rule3, rule4, rule5}
err = client.SetBucketLifecycle(bucketNameTest, rules)
c.Assert(err, IsNil)
time.Sleep(3 * time.Second)

// Get bucket's cycle
lc, err := client.GetBucketLifecycle(bucketNameTest)
Expand Down Expand Up @@ -5176,6 +5188,7 @@ func (s *OssClientSuite) TestBucketAccessMonitor(c *C) {
}
err = client.PutBucketAccessMonitor(bucketNameTest, access)
c.Assert(err, IsNil)
time.Sleep(3 * time.Second)

// get bucket info
res, err = client.GetBucketInfo(bucketNameTest)
Expand Down
4 changes: 2 additions & 2 deletions oss/crc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func (s *OssCrcSuite) TestCRCRepeatedCombine(c *C) {
post := hash.Sum64()

crc := CRC64Combine(prev, post, uint64(len(str)-i))
testLogger.Println("TestCRCRepeatedCombine:", prev, post, crc, i, len(str))
//testLogger.Println("TestCRCRepeatedCombine:", prev, post, crc, i, len(str))
c.Assert(crc == 0x7AD25FAFA1710407, Equals, true)
}
}
Expand All @@ -236,7 +236,7 @@ func (s *OssCrcSuite) TestCRCRandomCombine(c *C) {
crc = CRC64Combine(crc, calc.Sum64(), (uint64)(part.Size))
}

testLogger.Println("TestCRCRandomCombine:", crc, i, fileParts)
//testLogger.Println("TestCRCRandomCombine:", crc, i, fileParts)
c.Assert(crc == 0x2B612D24FFF64222, Equals, true)
}
}
Expand Down
1 change: 1 addition & 0 deletions oss/select_csv_objcet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ func (s *OssSelectCsvSuite) TestSelectObjectIntoFile(c *C) {
c.Assert(err, IsNil)
c.Assert(string(str1), Equals, string(str2))

fd1.Close()
err = os.Remove(outfile)
c.Assert(err, IsNil)
err = s.bucket.DeleteObject(key)
Expand Down
26 changes: 14 additions & 12 deletions oss/type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package oss

import (
"encoding/xml"
. "gopkg.in/check.v1"
"net/url"
"sort"

. "gopkg.in/check.v1"
)

type OssTypeSuite struct{}
Expand Down Expand Up @@ -954,7 +955,7 @@ func (s *OssTypeSuite) TestLifeCycleRulesWithFilter(c *C) {
<Days>100</Days>
</Expiration>
<Transition>
<Days>Days</Days>
<Days>30</Days>
<StorageClass>Archive</StorageClass>
</Transition>
</Rule>
Expand Down Expand Up @@ -1003,14 +1004,15 @@ func (s *OssTypeSuite) TestLifeCycleRulesWithFilter(c *C) {
</Rule>
</LifecycleConfiguration>
`)
err = xml.Unmarshal(xmlData, &res)
c.Assert(err, IsNil)
c.Assert(res.Rules[0].ID, Equals, "test2")
c.Assert(res.Rules[0].Filter.Not[0].Prefix, Equals, "logs-demo")
c.Assert(res.Rules[0].Filter.Not[1].Prefix, Equals, "abc/not1/")
c.Assert(res.Rules[0].Filter.Not[1].Tag.Key, Equals, "notkey1")
c.Assert(res.Rules[0].Filter.Not[1].Tag.Value, Equals, "notvalue1")
c.Assert(res.Rules[0].Filter.Not[2].Prefix, Equals, "abc/not2/")
c.Assert(res.Rules[0].Filter.Not[2].Tag.Key, Equals, "notkey2")
c.Assert(res.Rules[0].Filter.Not[2].Tag.Value, Equals, "notvalue2")
var res1 GetBucketLifecycleResult
err = xml.Unmarshal(xmlData, &res1)
c.Assert(err, IsNil)
c.Assert(res1.Rules[0].ID, Equals, "test2")
c.Assert(res1.Rules[0].Filter.Not[0].Prefix, Equals, "logs-demo")
c.Assert(res1.Rules[0].Filter.Not[1].Prefix, Equals, "abc/not1/")
c.Assert(res1.Rules[0].Filter.Not[1].Tag.Key, Equals, "notkey1")
c.Assert(res1.Rules[0].Filter.Not[1].Tag.Value, Equals, "notvalue1")
c.Assert(res1.Rules[0].Filter.Not[2].Prefix, Equals, "abc/not2/")
c.Assert(res1.Rules[0].Filter.Not[2].Tag.Key, Equals, "notkey2")
c.Assert(res1.Rules[0].Filter.Not[2].Tag.Value, Equals, "notvalue2")
}

0 comments on commit 37772f2

Please sign in to comment.