Skip to content

Commit

Permalink
Add integration test cases of file share
Browse files Browse the repository at this point in the history
  • Loading branch information
Shruthi-1MN committed Nov 7, 2019
1 parent 0da2142 commit 457d398
Show file tree
Hide file tree
Showing 4 changed files with 316 additions and 35 deletions.
264 changes: 262 additions & 2 deletions test/integration/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ func init() {

func TestClientCreateProfile(t *testing.T) {
var body = &model.ProfileSpec{
Name: "silver",
Description: "silver policy",
Name: "default",
Description: "default policy",
StorageType: "block",
CustomProperties: model.CustomPropertiesSpec{
"diskType": "SAS",
Expand Down Expand Up @@ -75,6 +75,7 @@ func TestClientGetProfile(t *testing.T) {
}
}


func TestClientListProfiles(t *testing.T) {
prfs, err := c.ListProfiles()
if err != nil {
Expand All @@ -92,6 +93,9 @@ func TestClientListProfiles(t *testing.T) {
for i := range SampleProfiles {
expected = append(expected, &SampleProfiles[i])
}
//for j := range SampleFileShareProfiles{
// expected = append(expected, &SampleFileShareProfiles[j])
//}
if !reflect.DeepEqual(prfs, expected) {
t.Errorf("expected %+v, got %+v\n", expected, prfs)
}
Expand Down Expand Up @@ -546,3 +550,259 @@ func TestClientFailoverReplication(t *testing.T) {
t.Log("Disable volume replication not ready!")
}
*/

/*
File share integration test cases
*/

func TestClientCreateFileProfile(t *testing.T) {
var body = &model.ProfileSpec{
Name: "gold",
Description: "gold policy",
StorageType: "file",
}

prf, err := c.CreateProfile(body)
if err != nil {
t.Error("create profile in client failed:", err)
return
}
// If customized properties are not defined, create an empty one.
if prf.CustomProperties == nil {
prf.CustomProperties = model.CustomPropertiesSpec{}
}

var expected = &SampleFileShareProfiles[0]
if !reflect.DeepEqual(prf, expected) {
t.Errorf("expected %+v, got %+v\n", expected, prf)
}
}

func TestClientGetFileProfile(t *testing.T) {
var prfID = "3f9c0a04-66ef-11e7-ade2-43158893e017"

prf, err := c.GetProfile(prfID)
if err != nil {
t.Error("get profile in client failed:", err)
return
}

var expected = &SampleFileShareProfiles[1]
if !reflect.DeepEqual(prf, expected) {
t.Errorf("expected %+v, got %+v\n", expected, prf)
}
}

func TestClientCreateFileShare(t *testing.T) {
var body = &model.FileShareSpec{
Name: "test",
Description: "This is a test",
Size: int64(1),
ProfileId: "2106b972-66ef-11e7-b172-db03f3689c9c",
}

if _, err := c.CreateFileShare(body); err != nil {
t.Error("create file share in client failed:", err)
return
}

t.Log("Create file share success!")
}

func TestClientGetFileShare(t *testing.T) {
var fileshareID = "a2975ebe-d82c-430f-b28e-f373746a71ca"

fileshare, err := c.GetFileShare(fileshareID)
if err != nil {
t.Error("get file share in client failed:", err)
return
}

var expected = &SampleFileShares[0]
if !reflect.DeepEqual(fileshare, expected) {
t.Errorf("expected %+v, got %+v\n", expected, fileshare)
}
}

func TestClientListFileShares(t *testing.T) {
fileshares, err := c.ListFileShares()
if err != nil {
t.Error("list fileshares in client failed:", err)
return
}

var expected []*model.FileShareSpec
for i := range SampleFileShares {
expected = append(expected, &SampleFileShares[i])
}
if !reflect.DeepEqual(fileshares, expected) {
t.Errorf("expected %+v, got %+v\n", expected, fileshares)
}
}

func TestClientUpdateFileShare(t *testing.T) {
var fileshareID = "a2975ebe-d82c-430f-b28e-f373746a71ca"
body := &model.FileShareSpec{
Name: "sample-fileshare-01",
Description: "This is first sample fileshare for testing",
}

fileshare, err := c.UpdateFileShare(fileshareID, body)
if err != nil {
t.Error("update fileshare in client failed:", err)
return
}

var expected = &SampleFileShares[0]
if !reflect.DeepEqual(fileshare, expected) {
t.Errorf("expected %+v, got %+v\n", expected, fileshare)
}
}

func TestClientCreateFileShareAcl(t *testing.T) {
var body = &model.FileShareAclSpec{
Description: "This is a sample Acl for testing",
ProfileId: "1106b972-66ef-11e7-b172-db03f3689c9c",
Type: "ip",
AccessCapability: []string{"Read", "Write"},
AccessTo: "10.32.109.15",
FileShareId: "a2975ebe-d82c-430f-b28e-f373746a71ca",
}

if _, err := c.CreateFileShareAcl(body); err != nil {
t.Error("create file share acl in client failed:", err)
return
}

t.Log("Create file share acl success!")
}

func TestClientGetFileShareAcl(t *testing.T) {
var aclID = "6ad25d59-a160-45b2-8920-211be282e2df"

acls, err := c.GetFileShareAcl(aclID)
if err != nil {
t.Error("get file share acl in client failed:", err)
return
}

var expected = &SampleFileSharesAcl[0]
if !reflect.DeepEqual(acls, expected) {
t.Errorf("expected %+v, got %+v\n", expected, acls)
}
}

func TestClientListFileShareAcl(t *testing.T) {
acls, err := c.ListFileSharesAcl()
if err != nil {
t.Error("list fileshare acls in client failed:", err)
return
}

var expected []*model.FileShareAclSpec
for i := range SampleFileSharesAcl {
expected = append(expected, &SampleFileSharesAcl[i])
}
if !reflect.DeepEqual(acls, expected) {
t.Errorf("expected %+v, got %+v\n", expected, acls)
}
}

func TestClientCreateFileShareSnapshot(t *testing.T) {
var body = &model.FileShareSnapshotSpec{
Name: "test",
Description: "This is a test",
FileShareId: "a2975ebe-d82c-430f-b28e-f373746a71ca",
}

if _, err := c.CreateFileShareSnapshot(body); err != nil {
t.Error("create file share snapshot in client failed:", err)
return
}

t.Log("Create file share snapshot success!")
}

func TestClientGetFileShareSnapshot(t *testing.T) {
var snpID = "3769855c-a102-11e7-b772-17b880d2f537"

snp, err := c.GetFileShareSnapshot(snpID)
if err != nil {
t.Error("get file share snapshot in client failed:", err)
return
}

var expected = &SampleFileShareSnapshots[0]
if !reflect.DeepEqual(snp, expected) {
t.Errorf("expected %+v, got %+v\n", expected, snp)
}
}

func TestClientListFileShareSnapshots(t *testing.T) {
snps, err := c.ListFileShareSnapshots()
if err != nil {
t.Error("list file share snapshots in client failed:", err)
return
}

var expected []*model.FileShareSnapshotSpec
for i := range SampleFileShareSnapshots {
expected = append(expected, &SampleFileShareSnapshots[i])
}
if !reflect.DeepEqual(snps, expected) {
t.Errorf("expected %+v, got %+v\n", expected, snps)
}
}

func TestClientUpdateFileShareSnapshot(t *testing.T) {
var snpID = "3769855c-a102-11e7-b772-17b880d2f537"
body := &model.FileShareSnapshotSpec{
Name: "sample-snapshot-01",
Description: "This is the first sample snapshot for testing",
}

snp, err := c.UpdateFileShareSnapshot(snpID, body)
if err != nil {
t.Error("update file share snapshot in client failed:", err)
return
}

var expected = &SampleFileShareSnapshots[0]
if !reflect.DeepEqual(snp, expected) {
t.Errorf("expected %+v, got %+v\n", expected, snp)
}
}

func TestClientDeleteFileShareAcl(t *testing.T) {
var fileshareaclID = "d2975ebe-d82c-430f-b28e-f373746a71ca"

if err := c.DeleteFileShareAcl(fileshareaclID); err != nil {
t.Error("delete file share acl in client failed:", err)
return
}

t.Log("Delete file share acl success!")
}

func TestClientDeleteFileShareSnapshot(t *testing.T) {
var snapID = "3769855c-a102-11e7-b772-17b880d2f537"

if err := c.DeleteFileShareSnapshot(snapID); err != nil {
t.Error("delete file share snapshot in client failed:", err)
return
}

t.Log("Delete file share snapshot success!")
}


func TestClientDeleteFileProfile(t *testing.T) {
var prfID = "3f9c0a04-66ef-11e7-ade2-43158893e017"

if err := c.DeleteProfile(prfID); err != nil {
t.Error("delete profile in client failed:", err)
return
}

t.Log("Delete profile success!")
}
Empty file modified test/integration/integrationtest.sh
100644 → 100755
Empty file.
Loading

0 comments on commit 457d398

Please sign in to comment.