Skip to content

Commit c267bf3

Browse files
author
Shruthi-1MN
committed
Add integration test cases of file share
1 parent 0da2142 commit c267bf3

4 files changed

Lines changed: 285 additions & 13 deletions

File tree

test/integration/client_test.go

Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func TestClientGetProfile(t *testing.T) {
7575
}
7676
}
7777

78+
7879
func TestClientListProfiles(t *testing.T) {
7980
prfs, err := c.ListProfiles()
8081
if err != nil {
@@ -92,6 +93,7 @@ func TestClientListProfiles(t *testing.T) {
9293
for i := range SampleProfiles {
9394
expected = append(expected, &SampleProfiles[i])
9495
}
96+
9597
if !reflect.DeepEqual(prfs, expected) {
9698
t.Errorf("expected %+v, got %+v\n", expected, prfs)
9799
}
@@ -546,3 +548,259 @@ func TestClientFailoverReplication(t *testing.T) {
546548
t.Log("Disable volume replication not ready!")
547549
}
548550
*/
551+
552+
/*
553+
File share integration test cases
554+
*/
555+
556+
func TestClientCreateFileProfile(t *testing.T) {
557+
var body = &model.ProfileSpec{
558+
Name: "gold",
559+
Description: "gold policy",
560+
StorageType: "file",
561+
}
562+
563+
prf, err := c.CreateProfile(body)
564+
if err != nil {
565+
t.Error("create profile in client failed:", err)
566+
return
567+
}
568+
// If customized properties are not defined, create an empty one.
569+
if prf.CustomProperties == nil {
570+
prf.CustomProperties = model.CustomPropertiesSpec{}
571+
}
572+
573+
var expected = &SampleFileShareProfiles[0]
574+
if !reflect.DeepEqual(prf, expected) {
575+
t.Errorf("expected %+v, got %+v\n", expected, prf)
576+
}
577+
}
578+
579+
func TestClientGetFileProfile(t *testing.T) {
580+
var prfID = "3f9c0a04-66ef-11e7-ade2-43158893e017"
581+
582+
prf, err := c.GetProfile(prfID)
583+
if err != nil {
584+
t.Error("get profile in client failed:", err)
585+
return
586+
}
587+
588+
var expected = &SampleFileShareProfiles[1]
589+
if !reflect.DeepEqual(prf, expected) {
590+
t.Errorf("expected %+v, got %+v\n", expected, prf)
591+
}
592+
}
593+
594+
func TestClientCreateFileShare(t *testing.T) {
595+
var body = &model.FileShareSpec{
596+
Name: "test",
597+
Description: "This is a test",
598+
Size: int64(1),
599+
ProfileId: "2106b972-66ef-11e7-b172-db03f3689c9c",
600+
}
601+
602+
if _, err := c.CreateFileShare(body); err != nil {
603+
t.Error("create file share in client failed:", err)
604+
return
605+
}
606+
607+
t.Log("Create file share success!")
608+
}
609+
610+
func TestClientGetFileShare(t *testing.T) {
611+
var fileshareID = "a2975ebe-d82c-430f-b28e-f373746a71ca"
612+
613+
fileshare, err := c.GetFileShare(fileshareID)
614+
if err != nil {
615+
t.Error("get file share in client failed:", err)
616+
return
617+
}
618+
619+
var expected = &SampleFileShares[0]
620+
if !reflect.DeepEqual(fileshare, expected) {
621+
t.Errorf("expected %+v, got %+v\n", expected, fileshare)
622+
}
623+
}
624+
625+
func TestClientListFileShares(t *testing.T) {
626+
fileshares, err := c.ListFileShares()
627+
if err != nil {
628+
t.Error("list fileshares in client failed:", err)
629+
return
630+
}
631+
632+
var expected []*model.FileShareSpec
633+
for i := range SampleFileShares {
634+
expected = append(expected, &SampleFileShares[i])
635+
}
636+
if !reflect.DeepEqual(fileshares, expected) {
637+
t.Errorf("expected %+v, got %+v\n", expected, fileshares)
638+
}
639+
}
640+
641+
func TestClientUpdateFileShare(t *testing.T) {
642+
var fileshareID = "a2975ebe-d82c-430f-b28e-f373746a71ca"
643+
body := &model.FileShareSpec{
644+
Name: "sample-fileshare-01",
645+
Description: "This is first sample fileshare for testing",
646+
}
647+
648+
fileshare, err := c.UpdateFileShare(fileshareID, body)
649+
if err != nil {
650+
t.Error("update fileshare in client failed:", err)
651+
return
652+
}
653+
654+
var expected = &SampleFileShares[0]
655+
if !reflect.DeepEqual(fileshare, expected) {
656+
t.Errorf("expected %+v, got %+v\n", expected, fileshare)
657+
}
658+
}
659+
660+
func TestClientCreateFileShareAcl(t *testing.T) {
661+
var body = &model.FileShareAclSpec{
662+
Description: "This is a sample Acl for testing",
663+
ProfileId: "1106b972-66ef-11e7-b172-db03f3689c9c",
664+
Type: "ip",
665+
AccessCapability: []string{"Read", "Write"},
666+
AccessTo: "10.32.109.15",
667+
FileShareId: "a2975ebe-d82c-430f-b28e-f373746a71ca",
668+
}
669+
670+
if _, err := c.CreateFileShareAcl(body); err != nil {
671+
t.Error("create file share acl in client failed:", err)
672+
return
673+
}
674+
675+
t.Log("Create file share acl success!")
676+
}
677+
678+
func TestClientGetFileShareAcl(t *testing.T) {
679+
var aclID = "6ad25d59-a160-45b2-8920-211be282e2df"
680+
681+
acls, err := c.GetFileShareAcl(aclID)
682+
if err != nil {
683+
t.Error("get file share acl in client failed:", err)
684+
return
685+
}
686+
687+
var expected = &SampleFileSharesAcl[0]
688+
if !reflect.DeepEqual(acls, expected) {
689+
t.Errorf("expected %+v, got %+v\n", expected, acls)
690+
}
691+
}
692+
693+
func TestClientListFileShareAcl(t *testing.T) {
694+
acls, err := c.ListFileSharesAcl()
695+
if err != nil {
696+
t.Error("list fileshare acls in client failed:", err)
697+
return
698+
}
699+
700+
var expected []*model.FileShareAclSpec
701+
for i := range SampleFileSharesAcl {
702+
expected = append(expected, &SampleFileSharesAcl[i])
703+
}
704+
if !reflect.DeepEqual(acls, expected) {
705+
t.Errorf("expected %+v, got %+v\n", expected, acls)
706+
}
707+
}
708+
709+
func TestClientCreateFileShareSnapshot(t *testing.T) {
710+
var body = &model.FileShareSnapshotSpec{
711+
Name: "test",
712+
Description: "This is a test",
713+
FileShareId: "a2975ebe-d82c-430f-b28e-f373746a71ca",
714+
}
715+
716+
if _, err := c.CreateFileShareSnapshot(body); err != nil {
717+
t.Error("create file share snapshot in client failed:", err)
718+
return
719+
}
720+
721+
t.Log("Create file share snapshot success!")
722+
}
723+
724+
func TestClientGetFileShareSnapshot(t *testing.T) {
725+
var snpID = "3769855c-a102-11e7-b772-17b880d2f537"
726+
727+
snp, err := c.GetFileShareSnapshot(snpID)
728+
if err != nil {
729+
t.Error("get file share snapshot in client failed:", err)
730+
return
731+
}
732+
733+
var expected = &SampleFileShareSnapshots[0]
734+
if !reflect.DeepEqual(snp, expected) {
735+
t.Errorf("expected %+v, got %+v\n", expected, snp)
736+
}
737+
}
738+
739+
func TestClientListFileShareSnapshots(t *testing.T) {
740+
snps, err := c.ListFileShareSnapshots()
741+
if err != nil {
742+
t.Error("list file share snapshots in client failed:", err)
743+
return
744+
}
745+
746+
var expected []*model.FileShareSnapshotSpec
747+
for i := range SampleFileShareSnapshots {
748+
expected = append(expected, &SampleFileShareSnapshots[i])
749+
}
750+
if !reflect.DeepEqual(snps, expected) {
751+
t.Errorf("expected %+v, got %+v\n", expected, snps)
752+
}
753+
}
754+
755+
func TestClientUpdateFileShareSnapshot(t *testing.T) {
756+
var snpID = "3769855c-a102-11e7-b772-17b880d2f537"
757+
body := &model.FileShareSnapshotSpec{
758+
Name: "sample-snapshot-01",
759+
Description: "This is the first sample snapshot for testing",
760+
}
761+
762+
snp, err := c.UpdateFileShareSnapshot(snpID, body)
763+
if err != nil {
764+
t.Error("update file share snapshot in client failed:", err)
765+
return
766+
}
767+
768+
var expected = &SampleFileShareSnapshots[0]
769+
if !reflect.DeepEqual(snp, expected) {
770+
t.Errorf("expected %+v, got %+v\n", expected, snp)
771+
}
772+
}
773+
774+
func TestClientDeleteFileShareAcl(t *testing.T) {
775+
var fileshareaclID = "d2975ebe-d82c-430f-b28e-f373746a71ca"
776+
777+
if err := c.DeleteFileShareAcl(fileshareaclID); err != nil {
778+
t.Error("delete file share acl in client failed:", err)
779+
return
780+
}
781+
782+
t.Log("Delete file share acl success!")
783+
}
784+
785+
func TestClientDeleteFileShareSnapshot(t *testing.T) {
786+
var snapID = "3769855c-a102-11e7-b772-17b880d2f537"
787+
788+
if err := c.DeleteFileShareSnapshot(snapID); err != nil {
789+
t.Error("delete file share snapshot in client failed:", err)
790+
return
791+
}
792+
793+
t.Log("Delete file share snapshot success!")
794+
}
795+
796+
797+
func TestClientDeleteFileProfile(t *testing.T) {
798+
var prfID = "3f9c0a04-66ef-11e7-ade2-43158893e017"
799+
800+
if err := c.DeleteProfile(prfID); err != nil {
801+
t.Error("delete profile in client failed:", err)
802+
return
803+
}
804+
805+
t.Log("Delete profile success!")
806+
}

test/integration/integrationtest.sh

100644100755
File mode changed.

testutils/collection/data.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ var (
6060
BaseModel: &model.BaseModel{
6161
Id: "1106b972-66ef-11e7-b172-db03f3689c9c",
6262
},
63-
Name: "default",
63+
Name: "default_file",
6464
Description: "default policy",
6565
StorageType: "file",
6666
CustomProperties: model.CustomPropertiesSpec{},
@@ -69,8 +69,8 @@ var (
6969
BaseModel: &model.BaseModel{
7070
Id: "2f9c0a04-66ef-11e7-ade2-43158893e017",
7171
},
72-
Name: "silver",
73-
Description: "silver policy",
72+
Name: "gold",
73+
Description: "gold policy",
7474
StorageType: "file",
7575
CustomProperties: model.CustomPropertiesSpec{
7676
"dataStorage": map[string]interface{}{
@@ -209,8 +209,8 @@ var (
209209
Size: int64(1),
210210
Status: "available",
211211
PoolId: "a5965ebe-dg2c-434t-b28e-f373746a71ca",
212-
ProfileId: "b3585ebe-c42c-120g-b28e-f373746a71ca",
213-
SnapshotId: "b7602e18-771e-11e7-8f38-dbd6d291f4eg",
212+
ProfileId: "1106b972-66ef-11e7-b172-db03f3689c9c",
213+
SnapshotId: "3769855c-a102-11e7-b772-17b880d2f537",
214214
AvailabilityZone: "default",
215215
ExportLocations: []string{"192.168.100.100"},
216216
},
@@ -223,8 +223,8 @@ var (
223223
Size: int64(1),
224224
Status: "available",
225225
PoolId: "d5f65ebe-ag2c-341s-a25e-f373746a71dr",
226-
ProfileId: "1e643aca-4922-4b1a-bb98-4245054aeff4",
227-
SnapshotId: "a5965ebe-dg2c-434t-b28e-f373746a71ca",
226+
ProfileId: "1106b972-66ef-11e7-b172-db03f3689c9c",
227+
SnapshotId: "3bfaf2cc-a102-11e7-8ecb-63aea739d755",
228228
AvailabilityZone: "default",
229229
ExportLocations: []string{"192.168.100.101"},
230230
},
@@ -236,6 +236,7 @@ var (
236236
Id: "d2975ebe-d82c-430f-b28e-f373746a71ca",
237237
},
238238
Description: "This is a sample Acl for testing",
239+
Status: "available",
239240
},
240241
{
241242
BaseModel: &model.BaseModel{
@@ -248,22 +249,24 @@ var (
248249
Id: "6ad25d59-a160-45b2-8920-211be282e2df",
249250
},
250251
Description: "This is a sample Acl for testing",
251-
ProfileId: "1106b972-66ef-11e7-b172-db03f3689c9c",
252+
ProfileId: "2106b972-66ef-11e7-b172-db03f3689c9c",
252253
Type: "ip",
253254
AccessCapability: []string{"Read", "Write"},
254255
AccessTo: "10.32.109.15",
256+
Status: "available",
255257
FileShareId: "d2975ebe-d82c-430f-b28e-f373746a71ca",
256258
},
257259
{
258260
BaseModel: &model.BaseModel{
259261
Id: "ad25d59-a160-45b2-8920-211be282e2dfh",
260262
},
261263
Description: "This is a sample Acl for testing",
262-
ProfileId: "1106b972-66ef-11e7-b172-db03f3689c9c",
264+
ProfileId: "3f9c0a04-66ef-11e7-ade2-43158893e017",
263265
Type: "ip",
264266
AccessCapability: []string{"Read", "Write"},
265267
AccessTo: "10.32.109.151",
266-
FileShareId: "d2975ebe-d82c-430f-b28e-f373746a71ca",
268+
Status: "available",
269+
FileShareId: "1e643aca-4922-4b1a-bb98-4245054aeff4",
267270
},
268271
}
269272

@@ -277,6 +280,7 @@ var (
277280
SnapshotSize: int64(1),
278281
FileShareId: "d2975ebe-d82c-430f-b28e-f373746a71ca",
279282
Status: "available",
283+
ProfileId: "1106b972-66ef-11e7-b172-db03f3689c9c",
280284
},
281285
{
282286
BaseModel: &model.BaseModel{
@@ -285,7 +289,9 @@ var (
285289
Name: "sample-snapshot-02",
286290
Description: "This is the second sample snapshot for testing",
287291
SnapshotSize: int64(1),
292+
FileShareId: "1e643aca-4922-4b1a-bb98-4245054aeff4",
288293
Status: "available",
294+
ProfileId: "3f9c0a04-66ef-11e7-ade2-43158893e017",
289295
},
290296
}
291297

0 commit comments

Comments
 (0)