chore(e2e): clean up e2e tests
This commit is contained in:
parent
5605839411
commit
74aa28d874
5 changed files with 31 additions and 49 deletions
|
@ -13,7 +13,7 @@ import (
|
||||||
|
|
||||||
func TestConcurrency(t *testing.T) {
|
func TestConcurrency(t *testing.T) {
|
||||||
addr := "http://127.0.0.1:8686"
|
addr := "http://127.0.0.1:8686"
|
||||||
root := "testData"
|
rootPath := "testData"
|
||||||
config := `{
|
config := `{
|
||||||
"users": {
|
"users": {
|
||||||
"enableAuth": true,
|
"enableAuth": true,
|
||||||
|
@ -37,20 +37,12 @@ func TestConcurrency(t *testing.T) {
|
||||||
|
|
||||||
adminName := "qs"
|
adminName := "qs"
|
||||||
adminPwd := "quicksh@re"
|
adminPwd := "quicksh@re"
|
||||||
os.Setenv("DEFAULTADMIN", adminName)
|
setUpEnv(t, rootPath, adminName, adminPwd)
|
||||||
os.Setenv("DEFAULTADMINPWD", adminPwd)
|
defer os.RemoveAll(rootPath)
|
||||||
|
|
||||||
os.RemoveAll(root)
|
|
||||||
err := os.MkdirAll(root, 0700)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(root)
|
|
||||||
|
|
||||||
srv := startTestServer(config)
|
srv := startTestServer(config)
|
||||||
defer srv.Shutdown()
|
defer srv.Shutdown()
|
||||||
// fs := srv.depsFS()
|
if !isServerReady(addr) {
|
||||||
if !waitForReady(addr) {
|
|
||||||
t.Fatal("fail to start server")
|
t.Fatal("fail to start server")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ import (
|
||||||
|
|
||||||
func TestFileHandlers(t *testing.T) {
|
func TestFileHandlers(t *testing.T) {
|
||||||
addr := "http://127.0.0.1:8686"
|
addr := "http://127.0.0.1:8686"
|
||||||
root := "testData"
|
rootPath := "testData"
|
||||||
config := `{
|
config := `{
|
||||||
"users": {
|
"users": {
|
||||||
"enableAuth": true,
|
"enableAuth": true,
|
||||||
|
@ -41,21 +41,13 @@ func TestFileHandlers(t *testing.T) {
|
||||||
|
|
||||||
adminName := "qs"
|
adminName := "qs"
|
||||||
adminPwd := "quicksh@re"
|
adminPwd := "quicksh@re"
|
||||||
os.Setenv("DEFAULTADMIN", adminName)
|
setUpEnv(t, rootPath, adminName, adminPwd)
|
||||||
os.Setenv("DEFAULTADMINPWD", adminPwd)
|
defer os.RemoveAll(rootPath)
|
||||||
|
|
||||||
os.RemoveAll(root)
|
|
||||||
err := os.MkdirAll(root, 0700)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(root)
|
|
||||||
|
|
||||||
srv := startTestServer(config)
|
srv := startTestServer(config)
|
||||||
defer srv.Shutdown()
|
defer srv.Shutdown()
|
||||||
fs := srv.depsFS()
|
fs := srv.depsFS()
|
||||||
|
if !isServerReady(addr) {
|
||||||
if !waitForReady(addr) {
|
|
||||||
t.Fatal("fail to start server")
|
t.Fatal("fail to start server")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,6 +61,7 @@ func TestFileHandlers(t *testing.T) {
|
||||||
token := client.GetCookie(resp.Cookies(), q.TokenCookie)
|
token := client.GetCookie(resp.Cookies(), q.TokenCookie)
|
||||||
cl := client.NewFilesClient(addr, token)
|
cl := client.NewFilesClient(addr, token)
|
||||||
|
|
||||||
|
var err error
|
||||||
// TODO: remove all files under home folder before testing
|
// TODO: remove all files under home folder before testing
|
||||||
// or the count of files is incorrect
|
// or the count of files is incorrect
|
||||||
t.Run("ListHome", func(t *testing.T) {
|
t.Run("ListHome", func(t *testing.T) {
|
||||||
|
|
|
@ -12,13 +12,12 @@ import (
|
||||||
|
|
||||||
func TestSpaceLimit(t *testing.T) {
|
func TestSpaceLimit(t *testing.T) {
|
||||||
addr := "http://127.0.0.1:8686"
|
addr := "http://127.0.0.1:8686"
|
||||||
root := "testData"
|
rootPath := "testData"
|
||||||
spaceLimit := 1000000
|
spaceLimit := 1000000
|
||||||
fileSize := 100000
|
fileSize := 100000
|
||||||
if spaceLimit%fileSize != 0 {
|
if spaceLimit%fileSize != 0 {
|
||||||
t.Fatal("spaceLimit % fileSize must be zero")
|
t.Fatal("spaceLimit % fileSize must be zero")
|
||||||
}
|
}
|
||||||
|
|
||||||
config := fmt.Sprintf(`{
|
config := fmt.Sprintf(`{
|
||||||
"users": {
|
"users": {
|
||||||
"enableAuth": true,
|
"enableAuth": true,
|
||||||
|
@ -42,20 +41,12 @@ func TestSpaceLimit(t *testing.T) {
|
||||||
|
|
||||||
adminName := "qs"
|
adminName := "qs"
|
||||||
adminPwd := "quicksh@re"
|
adminPwd := "quicksh@re"
|
||||||
os.Setenv("DEFAULTADMIN", adminName)
|
setUpEnv(t, rootPath, adminName, adminPwd)
|
||||||
os.Setenv("DEFAULTADMINPWD", adminPwd)
|
defer os.RemoveAll(rootPath)
|
||||||
|
|
||||||
os.RemoveAll(root)
|
|
||||||
err := os.MkdirAll(root, 0700)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(root)
|
|
||||||
|
|
||||||
srv := startTestServer(config)
|
srv := startTestServer(config)
|
||||||
defer srv.Shutdown()
|
defer srv.Shutdown()
|
||||||
// fs := srv.depsFS()
|
if !isServerReady(addr) {
|
||||||
if !waitForReady(addr) {
|
|
||||||
t.Fatal("fail to start server")
|
t.Fatal("fail to start server")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
|
|
||||||
func TestUsersHandlers(t *testing.T) {
|
func TestUsersHandlers(t *testing.T) {
|
||||||
addr := "http://127.0.0.1:8686"
|
addr := "http://127.0.0.1:8686"
|
||||||
root := "testData"
|
rootPath := "testData"
|
||||||
config := `{
|
config := `{
|
||||||
"users": {
|
"users": {
|
||||||
"enableAuth": true,
|
"enableAuth": true,
|
||||||
|
@ -45,15 +45,8 @@ func TestUsersHandlers(t *testing.T) {
|
||||||
adminName := "qs"
|
adminName := "qs"
|
||||||
adminPwd := "quicksh@re"
|
adminPwd := "quicksh@re"
|
||||||
adminNewPwd := "quicksh@re2"
|
adminNewPwd := "quicksh@re2"
|
||||||
os.Setenv("DEFAULTADMIN", adminName)
|
setUpEnv(t, rootPath, adminName, adminPwd)
|
||||||
os.Setenv("DEFAULTADMINPWD", adminPwd)
|
defer os.RemoveAll(rootPath)
|
||||||
|
|
||||||
os.RemoveAll(root)
|
|
||||||
err := os.MkdirAll(root, 0700)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(root)
|
|
||||||
|
|
||||||
srv := startTestServer(config)
|
srv := startTestServer(config)
|
||||||
defer srv.Shutdown()
|
defer srv.Shutdown()
|
||||||
|
@ -61,10 +54,12 @@ func TestUsersHandlers(t *testing.T) {
|
||||||
|
|
||||||
usersCl := client.NewSingleUserClient(addr)
|
usersCl := client.NewSingleUserClient(addr)
|
||||||
|
|
||||||
if !waitForReady(addr) {
|
if !isServerReady(addr) {
|
||||||
t.Fatal("fail to start server")
|
t.Fatal("fail to start server")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var err error
|
||||||
|
|
||||||
t.Run("test users APIs: Login-Self-SetPwd-Logout-Login", func(t *testing.T) {
|
t.Run("test users APIs: Login-Self-SetPwd-Logout-Login", func(t *testing.T) {
|
||||||
users := []*userstore.User{
|
users := []*userstore.User{
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -40,7 +41,17 @@ func startTestServer(config string) *Server {
|
||||||
return srv
|
return srv
|
||||||
}
|
}
|
||||||
|
|
||||||
func waitForReady(addr string) bool {
|
func setUpEnv(t *testing.T, rootPath string, adminName, adminPwd string) {
|
||||||
|
os.Setenv("DEFAULTADMIN", adminName)
|
||||||
|
os.Setenv("DEFAULTADMINPWD", adminPwd)
|
||||||
|
os.RemoveAll(rootPath)
|
||||||
|
err := os.MkdirAll(rootPath, 0700)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func isServerReady(addr string) bool {
|
||||||
retry := 20
|
retry := 20
|
||||||
setCl := client.NewSettingsClient(addr)
|
setCl := client.NewSettingsClient(addr)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue