Skip to content

Commit

Permalink
Use separate subdirectory for each test group
Browse files Browse the repository at this point in the history
  • Loading branch information
iychoi committed May 25, 2022
1 parent d3bdc58 commit 3c77f8b
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 33 deletions.
46 changes: 28 additions & 18 deletions test/testcases/fs_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package testcases
import (
"crypto/sha1"
"encoding/hex"
"fmt"
"io"
"os"
"path"
Expand All @@ -14,14 +13,21 @@ import (
"github.com/cyverse/go-irodsclient/irods/fs"
"github.com/cyverse/go-irodsclient/irods/session"
"github.com/cyverse/go-irodsclient/irods/types"
"github.com/rs/xid"
"github.com/stretchr/testify/assert"
)

var (
fsAPITestID = xid.New().String()
)

func TestFSAPI(t *testing.T) {
setup()
defer shutdown()

t.Run("test PrepareSamples", testPrepareSamples)
makeHomeDir(t, fsAPITestID)

t.Run("test PrepareSamples", testPrepareSamplesForFSAPI)
t.Run("test GetIRODSCollection", testGetIRODSCollection)
t.Run("test ListIRODSCollections", testListIRODSCollections)
t.Run("test ListIRODSCollectionMeta", testListIRODSCollectionMeta)
Expand All @@ -43,6 +49,10 @@ func TestFSAPI(t *testing.T) {
t.Run("test ParallelUploadAndDownloadDataObject", testParallelUploadAndDownloadDataObject)
}

func testPrepareSamplesForFSAPI(t *testing.T) {
prepareSamples(t, fsAPITestID)
}

func testGetIRODSCollection(t *testing.T) {
account := GetTestAccount()

Expand All @@ -53,7 +63,7 @@ func testGetIRODSCollection(t *testing.T) {
assert.NoError(t, err)
defer conn.Disconnect()

homedir := fmt.Sprintf("/%s/home/%s", account.ClientZone, account.ClientUser)
homedir := getHomeDir(fsAPITestID)

collection, err := fs.GetCollection(conn, homedir)
assert.NoError(t, err)
Expand All @@ -72,7 +82,7 @@ func testListIRODSCollections(t *testing.T) {
assert.NoError(t, err)
defer conn.Disconnect()

homedir := fmt.Sprintf("/%s/home/%s", account.ClientZone, account.ClientUser)
homedir := getHomeDir(fsAPITestID)

collections, err := fs.ListSubCollections(conn, homedir)
assert.NoError(t, err)
Expand All @@ -98,7 +108,7 @@ func testListIRODSCollectionMeta(t *testing.T) {
assert.NoError(t, err)
defer conn.Disconnect()

homedir := fmt.Sprintf("/%s/home/%s", account.ClientZone, account.ClientUser)
homedir := getHomeDir(fsAPITestID)

metas, err := fs.ListCollectionMeta(conn, homedir)
assert.NoError(t, err)
Expand All @@ -118,7 +128,7 @@ func testListIRODSCollectionAccess(t *testing.T) {
assert.NoError(t, err)
defer conn.Disconnect()

homedir := fmt.Sprintf("/%s/home/%s", account.ClientZone, account.ClientUser)
homedir := getHomeDir(fsAPITestID)

accesses, err := fs.ListCollectionAccess(conn, homedir)
assert.NoError(t, err)
Expand All @@ -139,7 +149,7 @@ func testListIRODSDataObjects(t *testing.T) {
assert.NoError(t, err)
defer conn.Disconnect()

homedir := fmt.Sprintf("/%s/home/%s", account.ClientZone, account.ClientUser)
homedir := getHomeDir(fsAPITestID)

collection, err := fs.GetCollection(conn, homedir)
assert.NoError(t, err)
Expand Down Expand Up @@ -173,7 +183,7 @@ func testListIRODSDataObjectsMasterReplica(t *testing.T) {
assert.NoError(t, err)
defer conn.Disconnect()

homedir := fmt.Sprintf("/%s/home/%s", account.ClientZone, account.ClientUser)
homedir := getHomeDir(fsAPITestID)

collection, err := fs.GetCollection(conn, homedir)
assert.NoError(t, err)
Expand Down Expand Up @@ -209,7 +219,7 @@ func testGetIRODSDataObject(t *testing.T) {
assert.NoError(t, err)
defer conn.Disconnect()

homedir := fmt.Sprintf("/%s/home/%s", account.ClientZone, account.ClientUser)
homedir := getHomeDir(fsAPITestID)

collection, err := fs.GetCollection(conn, homedir)
assert.NoError(t, err)
Expand Down Expand Up @@ -243,7 +253,7 @@ func testGetIRODSDataObjectMasterReplica(t *testing.T) {
assert.NoError(t, err)
defer conn.Disconnect()

homedir := fmt.Sprintf("/%s/home/%s", account.ClientZone, account.ClientUser)
homedir := getHomeDir(fsAPITestID)

collection, err := fs.GetCollection(conn, homedir)
assert.NoError(t, err)
Expand Down Expand Up @@ -278,7 +288,7 @@ func testListIRODSDataObjectMeta(t *testing.T) {
assert.NoError(t, err)
defer conn.Disconnect()

homedir := fmt.Sprintf("/%s/home/%s", account.ClientZone, account.ClientUser)
homedir := getHomeDir(fsAPITestID)

collection, err := fs.GetCollection(conn, homedir)
assert.NoError(t, err)
Expand Down Expand Up @@ -308,7 +318,7 @@ func testListIRODSDataObjectAccess(t *testing.T) {
assert.NoError(t, err)
defer conn.Disconnect()

homedir := fmt.Sprintf("/%s/home/%s", account.ClientZone, account.ClientUser)
homedir := getHomeDir(fsAPITestID)

collection, err := fs.GetCollection(conn, homedir)
assert.NoError(t, err)
Expand Down Expand Up @@ -339,7 +349,7 @@ func testCreateDeleteIRODSCollection(t *testing.T) {
assert.NoError(t, err)
defer conn.Disconnect()

homedir := fmt.Sprintf("/%s/home/%s", account.ClientZone, account.ClientUser)
homedir := getHomeDir(fsAPITestID)

// create
newCollectionPath := homedir + "/test123"
Expand Down Expand Up @@ -379,7 +389,7 @@ func testCreateMoveDeleteIRODSCollection(t *testing.T) {
assert.NoError(t, err)
defer conn.Disconnect()

homedir := fmt.Sprintf("/%s/home/%s", account.ClientZone, account.ClientUser)
homedir := getHomeDir(fsAPITestID)

// create
newCollectionPath := homedir + "/test123"
Expand Down Expand Up @@ -430,7 +440,7 @@ func testCreateDeleteIRODSDataObject(t *testing.T) {
assert.NoError(t, err)
defer conn.Disconnect()

homedir := fmt.Sprintf("/%s/home/%s", account.ClientZone, account.ClientUser)
homedir := getHomeDir(fsAPITestID)

// create
newDataObjectFilename := "testobj123"
Expand Down Expand Up @@ -474,7 +484,7 @@ func testReadWriteIRODSDataObject(t *testing.T) {
assert.NoError(t, err)
defer conn.Disconnect()

homedir := fmt.Sprintf("/%s/home/%s", account.ClientZone, account.ClientUser)
homedir := getHomeDir(fsAPITestID)

// create
newDataObjectFilename := "testobjwrite123"
Expand Down Expand Up @@ -526,7 +536,7 @@ func testTruncateIRODSDataObject(t *testing.T) {
assert.NoError(t, err)
defer conn.Disconnect()

homedir := fmt.Sprintf("/%s/home/%s", account.ClientZone, account.ClientUser)
homedir := getHomeDir(fsAPITestID)

// create
newDataObjectFilename := "testobjtruncate123"
Expand Down Expand Up @@ -673,7 +683,7 @@ func testParallelUploadAndDownloadDataObject(t *testing.T) {
return
}

homedir := fmt.Sprintf("/%s/home/%s", account.ClientZone, account.ClientUser)
homedir := getHomeDir(fsAPITestID)

// gen very large file
testval := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" // 62
Expand Down
9 changes: 8 additions & 1 deletion test/testcases/fs_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@ import (
"testing"

"github.com/cyverse/go-irodsclient/fs"
"github.com/rs/xid"
"github.com/stretchr/testify/assert"
)

var (
fsCacheTestID = xid.New().String()
)

func TestFSCache(t *testing.T) {
setup()
defer shutdown()

makeHomeDir(t, fsCacheTestID)

t.Run("test MakeDir", testMakeDir)
}

Expand All @@ -26,7 +33,7 @@ func testMakeDir(t *testing.T) {
assert.NoError(t, err)
defer fs.Release()

homedir := fmt.Sprintf("/%s/home/%s", account.ClientZone, account.ClientUser)
homedir := getHomeDir(fsCacheTestID)

for i := 0; i < 10; i++ {
newdir := fmt.Sprintf("%s/test_dir_%d", homedir, i)
Expand Down
9 changes: 8 additions & 1 deletion test/testcases/fs_io_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@ import (
"time"

"github.com/cyverse/go-irodsclient/fs"
"github.com/rs/xid"
"github.com/stretchr/testify/assert"
)

var (
fsIOTestID = xid.New().String()
)

func TestFSIO(t *testing.T) {
setup()
defer shutdown()

makeHomeDir(t, fsIOTestID)

t.Run("test UpDownMBFiles", testUpDownMBFiles)
}

Expand All @@ -30,7 +37,7 @@ func testUpDownMBFiles(t *testing.T) {
assert.NoError(t, err)
defer fs.Release()

homedir := fmt.Sprintf("/%s/home/%s", account.ClientZone, account.ClientUser)
homedir := getHomeDir(fsIOTestID)

fileSize := int64(100 * 1024 * 1024) // 100MB
localPath, err := createLocalTestFile("test_file_", fileSize)
Expand Down
24 changes: 17 additions & 7 deletions test/testcases/fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,21 @@ import (
"time"

"github.com/cyverse/go-irodsclient/fs"
"github.com/rs/xid"
"github.com/stretchr/testify/assert"
)

var (
fsTestID = xid.New().String()
)

func TestFS(t *testing.T) {
setup()
defer shutdown()

t.Run("test PrepareSamples", testPrepareSamples)
makeHomeDir(t, fsTestID)

t.Run("test PrepareSamples", testPrepareSamplesForFS)
t.Run("test ListEntries", testListEntries)
t.Run("test ListEntriesByMeta", testListEntriesByMeta)
t.Run("test ListACLs", testListACLs)
Expand All @@ -29,6 +35,10 @@ func TestFS(t *testing.T) {
t.Run("test RemoveClose", testRemoveClose)
}

func testPrepareSamplesForFS(t *testing.T) {
prepareSamples(t, fsTestID)
}

func testListEntries(t *testing.T) {
account := GetTestAccount()

Expand All @@ -40,7 +50,7 @@ func testListEntries(t *testing.T) {
assert.NoError(t, err)
defer filesystem.Release()

homedir := fmt.Sprintf("/%s/home/%s", account.ClientZone, account.ClientUser)
homedir := getHomeDir(fsTestID)

collections, err := filesystem.List(homedir)
assert.NoError(t, err)
Expand Down Expand Up @@ -120,7 +130,7 @@ func testReadWrite(t *testing.T) {
assert.NoError(t, err)
defer filesystem.Release()

homedir := fmt.Sprintf("/%s/home/%s", account.ClientZone, account.ClientUser)
homedir := getHomeDir(fsTestID)

newDataObjectFilename := "testobj123"
newDataObjectPath := homedir + "/" + newDataObjectFilename
Expand Down Expand Up @@ -170,7 +180,7 @@ func testCreateStat(t *testing.T) {
assert.NoError(t, err)
defer filesystem.Release()

homedir := fmt.Sprintf("/%s/home/%s", account.ClientZone, account.ClientUser)
homedir := getHomeDir(fsTestID)

newDataObjectFilename := "testobj_create1234"
newDataObjectPath := homedir + "/" + newDataObjectFilename
Expand Down Expand Up @@ -228,7 +238,7 @@ func testWriteRename(t *testing.T) {
assert.NoError(t, err)
defer filesystem.Release()

homedir := fmt.Sprintf("/%s/home/%s", account.ClientZone, account.ClientUser)
homedir := getHomeDir(fsTestID)

newDataObjectFilename := "testobj1234"
newDataObjectPath := homedir + "/" + newDataObjectFilename
Expand Down Expand Up @@ -290,7 +300,7 @@ func testWriteRenameDir(t *testing.T) {
assert.NoError(t, err)
defer filesystem.Release()

homedir := fmt.Sprintf("/%s/home/%s", account.ClientZone, account.ClientUser)
homedir := getHomeDir(fsTestID)
newdir := fmt.Sprintf("%s/testdir", homedir)

err = filesystem.MakeDir(newdir, true)
Expand Down Expand Up @@ -361,7 +371,7 @@ func testRemoveClose(t *testing.T) {
assert.NoError(t, err)
defer filesystem.Release()

homedir := fmt.Sprintf("/%s/home/%s", account.ClientZone, account.ClientUser)
homedir := getHomeDir(fsTestID)

newDataObjectFilename := "testobj1234"
newDataObjectPath := homedir + "/" + newDataObjectFilename
Expand Down
27 changes: 25 additions & 2 deletions test/testcases/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,32 @@ func createLocalTestFile(name string, size int64) (string, error) {
return tempPath, nil
}

func testPrepareSamples(t *testing.T) {
func getHomeDir(testID string) string {
account := GetTestAccount()
return fmt.Sprintf("/%s/home/%s/%s", account.ClientZone, account.ClientUser, testID)
}

func makeHomeDir(t *testing.T, testID string) {
account := GetTestAccount()
account.ClientServerNegotiation = false

sessionConfig := session.NewIRODSSessionConfigWithDefault("go-irodsclient-test")

sess, err := session.NewIRODSSession(account, sessionConfig)
assert.NoError(t, err)
defer sess.Release()

// first
conn, err := sess.AcquireConnection()
assert.NoError(t, err)

homedir := getHomeDir(testID)
err = fs.CreateCollection(conn, homedir, true)
assert.NoError(t, err)
}

func prepareSamples(t *testing.T, testID string) {
account := GetTestAccount()
account.ClientServerNegotiation = false

sessionConfig := session.NewIRODSSessionConfigWithDefault("go-irodsclient-test")
Expand All @@ -135,7 +158,7 @@ func testPrepareSamples(t *testing.T) {
conn, err := sess.AcquireConnection()
assert.NoError(t, err)

homedir := fmt.Sprintf("/%s/home/%s", account.ClientZone, account.ClientUser)
homedir := getHomeDir(testID)

collection, err := fs.GetCollection(conn, homedir)
assert.NoError(t, err)
Expand Down
Loading

0 comments on commit 3c77f8b

Please sign in to comment.