@@ -10,20 +10,14 @@ import (
10
10
"os"
11
11
"path/filepath"
12
12
"strings"
13
- "sync"
14
13
"testing"
15
14
"time"
16
15
17
16
clientV1 "github.com/qiniu/go-sdk/v7/client"
18
17
"github.com/qiniu/go-sdk/v7/storagev2/uplog"
19
18
)
20
19
21
- var testLock sync.Mutex
22
-
23
20
func TestUploadManagerUplogForm (t * testing.T ) {
24
- testLock .Lock ()
25
- defer testLock .Unlock ()
26
-
27
21
tmpDir , err := ioutil .TempDir ("" , "test-uplog-*" )
28
22
if err != nil {
29
23
t .Fatal (err )
@@ -37,6 +31,10 @@ func TestUploadManagerUplogForm(t *testing.T) {
37
31
t .Fatal (err )
38
32
}
39
33
34
+ writeFileBufferInterval := uplog .GetWriteFileBufferInterval ()
35
+ uplog .SetFlushFileBufferInterval (1 * time .Hour )
36
+ defer uplog .SetFlushFileBufferInterval (writeFileBufferInterval )
37
+
40
38
clientV1 .DebugMode = true
41
39
defer func () {
42
40
clientV1 .DebugMode = false
@@ -54,7 +52,7 @@ func TestUploadManagerUplogForm(t *testing.T) {
54
52
}()
55
53
tempFile .Write (data )
56
54
57
- uploadManager := getUploadManager ( )
55
+ uploadManager := getUploadManagerV2 ([] string { "mock03.qiniu.com" , "mock04.qiniu.com" } )
58
56
var ret Ret
59
57
60
58
// 上传 file
@@ -104,7 +102,7 @@ func TestUploadManagerUplogForm(t *testing.T) {
104
102
if uplogs [0 ]["error_type" ] != "unknown_host" {
105
103
t .Fatalf ("unexpected uplog error_type:%v" , uplogs [0 ]["error_type" ])
106
104
}
107
- if uplogs [0 ]["host" ] != "mock01 .qiniu.com" {
105
+ if uplogs [0 ]["host" ] != "mock03 .qiniu.com" {
108
106
t .Fatalf ("unexpected uplog host:%v" , uplogs [0 ]["host" ])
109
107
}
110
108
if uplogs [0 ]["path" ] != "/" {
@@ -128,7 +126,7 @@ func TestUploadManagerUplogForm(t *testing.T) {
128
126
if uplogs [1 ]["error_type" ] != "unknown_host" {
129
127
t .Fatalf ("unexpected uplog error_type:%v" , uplogs [1 ]["error_type" ])
130
128
}
131
- if uplogs [1 ]["host" ] != "mock02 .qiniu.com" {
129
+ if uplogs [1 ]["host" ] != "mock04 .qiniu.com" {
132
130
t .Fatalf ("unexpected uplog host:%v" , uplogs [1 ]["host" ])
133
131
}
134
132
if uplogs [1 ]["target_bucket" ] != testBucket {
@@ -194,9 +192,6 @@ func TestUploadManagerUplogForm(t *testing.T) {
194
192
}
195
193
196
194
func TestUploadManagerUplogResumableV1 (t * testing.T ) {
197
- testLock .Lock ()
198
- defer testLock .Unlock ()
199
-
200
195
tmpDir , err := ioutil .TempDir ("" , "test-uplog-*" )
201
196
if err != nil {
202
197
t .Fatal (err )
@@ -210,6 +205,10 @@ func TestUploadManagerUplogResumableV1(t *testing.T) {
210
205
t .Fatal (err )
211
206
}
212
207
208
+ writeFileBufferInterval := uplog .GetWriteFileBufferInterval ()
209
+ uplog .SetFlushFileBufferInterval (1 * time .Hour )
210
+ defer uplog .SetFlushFileBufferInterval (writeFileBufferInterval )
211
+
213
212
clientV1 .DebugMode = true
214
213
defer func () {
215
214
clientV1 .DebugMode = false
@@ -229,7 +228,7 @@ func TestUploadManagerUplogResumableV1(t *testing.T) {
229
228
}()
230
229
tempFile .Write (data )
231
230
232
- uploadManager := getUploadManager ( )
231
+ uploadManager := getUploadManagerV2 ([] string { "mock05.qiniu.com" , "mock06.qiniu.com" } )
233
232
var ret Ret
234
233
235
234
// 上传 file
@@ -283,7 +282,7 @@ func TestUploadManagerUplogResumableV1(t *testing.T) {
283
282
if uplogs [i ]["error_type" ] != "unknown_host" {
284
283
t .Fatalf ("unexpected uplog error_type:%v" , uplogs [i ]["error_type" ])
285
284
}
286
- if uplogs [i ]["host" ] != "mock01 .qiniu.com" {
285
+ if uplogs [i ]["host" ] != "mock05 .qiniu.com" {
287
286
t .Fatalf ("unexpected uplog host:%v" , uplogs [i ]["host" ])
288
287
}
289
288
if uplogs [i ]["path" ] != "/mkblk/4194304" {
@@ -309,7 +308,7 @@ func TestUploadManagerUplogResumableV1(t *testing.T) {
309
308
if uplogs [i ]["error_type" ] != "unknown_host" {
310
309
t .Fatalf ("unexpected uplog error_type:%v" , uplogs [i ]["error_type" ])
311
310
}
312
- if uplogs [i ]["host" ] != "mock02 .qiniu.com" {
311
+ if uplogs [i ]["host" ] != "mock06 .qiniu.com" {
313
312
t .Fatalf ("unexpected uplog host:%v" , uplogs [i ]["host" ])
314
313
}
315
314
if uplogs [i ]["path" ] != "/mkblk/4194304" {
0 commit comments