test(server: add rounds for concurrency test
This commit is contained in:
parent
a36ef5f98f
commit
d0a8a6d43a
2 changed files with 35 additions and 18 deletions
|
@ -56,14 +56,17 @@ func TestConcurrency(t *testing.T) {
|
|||
}
|
||||
adminToken := client.GetCookie(resp.Cookies(), q.TokenCookie)
|
||||
|
||||
userCount := 5
|
||||
userCount := 2
|
||||
userPwd := "1234"
|
||||
users := addUsers(t, addr, userPwd, userCount, adminToken)
|
||||
filesCount := 10
|
||||
filesCount := 5
|
||||
rounds := 2
|
||||
|
||||
var wg sync.WaitGroup
|
||||
t.Run("Upload and download concurrently", func(t *testing.T) {
|
||||
for i := 0; i < rounds; i++ {
|
||||
clients := []*MockClient{}
|
||||
var wg sync.WaitGroup
|
||||
|
||||
for userName := range users {
|
||||
client := &MockClient{errs: []error{}}
|
||||
clients = append(clients, client)
|
||||
|
@ -82,5 +85,7 @@ func TestConcurrency(t *testing.T) {
|
|||
if len(errs) > 0 {
|
||||
t.Fatal(joinErrs(errs))
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
|
|
@ -337,4 +337,16 @@ func (cl *MockClient) uploadAndDownload(tb testing.TB, addr, name, pwd string, f
|
|||
))
|
||||
return
|
||||
}
|
||||
|
||||
// truncate all files
|
||||
for i := 1; i < filesCount; i++ {
|
||||
resp, _, errs = filesCl.Delete(getFilePath(name, i))
|
||||
if len(errs) > 0 {
|
||||
cl.errs = append(cl.errs, errs...)
|
||||
return
|
||||
} else if resp.StatusCode != 200 {
|
||||
cl.errs = append(cl.errs, errors.New("failed to delete file"))
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue